Commit Graph

109 Commits

Author SHA1 Message Date
Steve Yegge
6ab9cc9a91 Fix inverted version comparison logic
Closes bd-149

The version mismatch warning was using string comparison (Version < dbVersion)
which incorrectly compared v0.9.10 < v0.9.9 as true (lexicographically '1' < '9').

Now uses golang.org/x/mod/semver.Compare for proper semantic versioning:
- v0.9.10 > v0.9.9 correctly returns 1 (binary is NEWER)
- v0.9.9 < v0.9.10 correctly returns -1 (binary is OUTDATED)

Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:14:36 -07:00
Steve Yegge
63c538616d Fix bd delete panic when daemon is running
Closes bd-155

When daemon is running, store is nil because PersistentPreRun returns
early after connecting to daemon. The delete command (both single and
batch) now falls back to direct storage access when store is nil,
following the pattern used by other commands like ready and blocked.

Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:06:21 -07:00
Steve Yegge
c17174b80a fix: bd list --status all showing 0 issues (bd-148)
The status filter was treating 'all' as a literal status value instead of
a special case meaning 'show all statuses'. This caused the SQL query to
filter for 'WHERE status = all' which matched no issues.

Fixed by checking if status is 'all' and skipping the filter in that case.

- Fix list.go to skip status filter when status == 'all'
- Update CHANGELOG with fix details
- All tests pass
2025-10-17 21:56:03 -07:00
Steve Yegge
ee94d817ed feat: Add batch deletion support (bd-127)
- Add DeleteIssues() method in sqlite.go for atomic batch deletion
- Support multiple issue IDs as arguments or from file
- Add --from-file flag to read IDs from file (supports comments)
- Add --dry-run mode for safe preview without deleting
- Add --cascade flag for recursive deletion of dependents
- Add --force flag to orphan dependents instead of failing
- Pre-collect connected issues before deletion for text reference updates
- Add orphan deduplication to prevent duplicate IDs
- Add rows.Err() checks in all row iteration loops
- Full transaction safety - all deletions succeed or none do
- Comprehensive statistics tracking (deleted, dependencies, labels, events)
- Update README and CHANGELOG with batch deletion docs

Fixed critical code review issues:
- Dry-run mode now properly uses dryRun parameter instead of deleting data
- Text references are pre-collected before deletion so they update correctly
- Added orphan deduplication and error checks
- Updated defer rollback pattern per Go best practices
2025-10-17 21:13:23 -07:00
Steve Yegge
52e2993bf6 chore: Bump version to 0.9.10
Updated all component versions:
- bd CLI: 0.9.9 → 0.9.10
- Plugin: 0.9.9 → 0.9.10
- MCP server: 0.9.9 → 0.9.10
- Documentation: 0.9.9 → 0.9.10

Generated by scripts/bump-version.sh
2025-10-17 18:15:29 -07:00
Steve Yegge
e9729abd73 Fix bd-120: Fix nil pointer crash in export command when daemon is running
Amp-Thread-ID: https://ampcode.com/threads/T-f6d324a9-aa24-4cf8-9962-7391602c8c91
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 17:40:16 -07:00
Daan van Etten
02d53ff3b5 Add fallback for 'bd blocked' command when daemon is running (#71)
The 'blocked' command doesn't have RPC support in the daemon yet.
When the daemon is running, store is nil, causing a panic.

This fix detects when daemon is running but store is nil, and opens
a direct database connection as a fallback. This allows the command
to work even when the daemon is active, until proper RPC support
is added.
2025-10-17 15:17:17 -07:00
Daan van Etten
991a2d995a Fix panic in 'bd stats' when daemon is running (#69)
The statsCmd was not checking if a daemon client was available before
trying to access the store directly. When the daemon is running, store
is nil, causing a panic.

This fix adds a check for daemonClient and uses RPC to get statistics
when the daemon is available, falling back to direct store access only
when running in direct mode.
2025-10-17 15:17:11 -07:00
Daan van Etten
7fde57c1ab Fix panics in dep commands when daemon is running (#72)
Multiple dep commands were directly accessing store without checking if
daemon was available, causing nil pointer dereferences when daemon was
running.

Fixed commands:
- dep add: Now uses RPC when daemon is available
- dep remove: Now uses RPC when daemon is available
- dep tree: Added fallback to direct storage when daemon lacks RPC support
- dep cycles: Added fallback to direct storage when daemon lacks RPC support

The commands with RPC support (add/remove) now use the daemon client
when available. Commands without RPC support (tree/cycles) fall back
to opening a direct database connection when the daemon is running.
2025-10-17 15:17:01 -07:00
Daan van Etten
6ba77e57e3 Fix daemon database discovery to match other commands (#70)
The daemon command was failing to find the database while other commands
like 'bd list' could find it. This was because ensureBeadsDir() was not
using the same database discovery logic as other commands.

This fix updates ensureBeadsDir() to use beads.FindDatabasePath() API,
the same discovery mechanism used by all other commands, ensuring
consistent behavior across the CLI.
2025-10-17 15:16:08 -07:00
Steve Yegge
14c744861c Add epic closure management commands (fixes #62)
- Add 'bd epic status' to show epic completion with child progress
- Add 'bd epic close-eligible' to bulk-close completed epics
- Add GetEpicsEligibleForClosure() storage method
- Update 'bd stats' to show count of epics ready to close
- Add EpicStatus type for tracking epic/child relationships
- Support --eligible-only, --dry-run, and --json flags
- Fix golangci-lint config version requirement

Addresses GitHub issue #62 - epics now have visibility and
management tools for closure when all children are complete.

Amp-Thread-ID: https://ampcode.com/threads/T-e8ac3f48-f0cf-4858-8e8f-aace2481c30d
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 13:50:20 -07:00
Ben Madore
789145f842 Add .gitignore to .beads directory during init (#64)
- Create .gitignore file in .beads/ when running bd init
    - Ignores *.db and *.db-* patterns to prevent database commits
    - Add test coverage to verify .gitignore creation
    - Add .claude/settings.local.json to project .gitignore

    🤖 Generated with [Claude Code](https://claude.com/claude-code)

    Co-Authored-By: Claude <noreply@anthropic.com>

Co-authored-by: Ben Madore <madorb@users.noreply.github.com>
2025-10-17 11:24:39 -07:00
Steve Yegge
a971762b0e Remove ~/.beads fallback behavior
- Remove ~/.beads/default.db fallback from FindDatabasePath()
- Update daemon to error if no database found instead of falling back
- Update main.go to require explicit database initialization
- Add help/version/quickstart to commands that don't need database
- Add MCP client debug logging for database routing

Amp-Thread-ID: https://ampcode.com/threads/T-2b757a14-cf10-400e-a83c-30349182dd82
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 10:56:52 -07:00
Steve Yegge
a4381affeb Add CLI output tests, remove obsolete design docs (bd-37)
- Added cmd/bd/output_test.go with 7 new tests for CLI output functions
- Improved coverage: outputJSON (0→60%), printCollisionReport (0→100%), printRemappingReport (0→100%)
- Removed obsolete design documents that were implemented or superseded:
  - DAEMON_DESIGN.md (daemon implemented)
  - DAEMON_STRESS_TEST.md (stress testing complete)
  - DESIGN.md (general design, superseded by other docs)
  - DUPLICATES_REPORT.md (old analysis)
  - REVIEW_BD379.md (completed review)
- Closed bd-37: All critical features now have test coverage

Amp-Thread-ID: https://ampcode.com/threads/T-9ee0fcdd-3675-42ea-966b-64ee3d9248a3
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 01:15:39 -07:00
Steve Yegge
1a82bbaee3 chore: Bump version to 0.9.9
Updated all component versions:
- bd CLI: 0.9.8 → 0.9.9
- Plugin: 0.9.8 → 0.9.9
- MCP server: 0.9.8 → 0.9.9
- Documentation: 0.9.8 → 0.9.9

Generated by scripts/bump-version.sh
2025-10-17 00:33:27 -07:00
Steve Yegge
3116b7b8cc Add comprehensive tests for init command (bd-70)
- Add TestInitCommand with subtests for default prefix, custom prefix, quiet flag, and prefix normalization
- Add TestInitAlreadyInitialized to verify re-initialization works correctly
- Tests verify database creation, config storage, and metadata
- Tests verify -q/--quiet flag suppresses output correctly
- All tests pass

The -q flag was already working correctly; this just adds test coverage.
2025-10-17 00:09:26 -07:00
Steve Yegge
55ce3e677a Add comprehensive daemon RPC integration tests (bd-117)
- Add TestDaemonRPCServerIntegration for basic RPC integration
- Add TestDaemonConcurrentOperations for concurrent client tests
- Add TestDaemonSocketCleanupOnShutdown for socket cleanup verification
- Add TestDaemonServerStartFailureSocketExists for socket conflict handling
- Add TestDaemonGracefulShutdown for graceful shutdown verification
- Use /tmp directly to avoid macOS socket path length limits (104 chars)
- Add mockDaemonServer with ready signaling to avoid race conditions
2025-10-17 00:03:54 -07:00
Steve Yegge
15b60b4ad0 Phase 4: Atomic operations and stress testing (bd-114, bd-110)
Completes daemon architecture implementation:

Features:
- Batch/transaction API (OpBatch) for multi-step atomic operations
- Request timeout and cancellation support (30s default, configurable)
- Comprehensive stress tests (4-10 concurrent agents, 800-1000 ops)
- Performance benchmarks (daemon 2x faster than direct mode)

Results:
- Zero ID collisions across 1000+ concurrent creates
- All acceptance criteria validated for bd-110
- Create: 2.4ms (daemon) vs 4.7ms (direct)
- Update/List: similar 2x improvement

Tests Added:
- TestStressConcurrentAgents (8 agents, 800 creates)
- TestStressBatchOperations (4 agents, 400 batch ops)
- TestStressMixedOperations (6 agents, mixed read/write)
- TestStressNoUniqueConstraintViolations (10 agents, 1000 creates)
- BenchmarkDaemonCreate/Update/List/Latency
- Fixed flaky TestConcurrentRequests (shared client issue)

Files:
- internal/rpc/protocol.go - Added OpBatch, BatchArgs, BatchResponse
- internal/rpc/server.go - Implemented handleBatch with stop-on-failure
- internal/rpc/client.go - Added SetTimeout and Batch methods
- internal/rpc/stress_test.go - All stress tests
- internal/rpc/bench_test.go - Performance benchmarks
- DAEMON_STRESS_TEST.md - Complete documentation

Closes bd-114, bd-110

Amp-Thread-ID: https://ampcode.com/threads/T-1c07c140-0420-49fe-add1-b0b83b1bdff5
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 23:46:12 -07:00
Steve Yegge
39b586a7be Phase 2: Add client auto-detection in bd commands (bd-112)
- Add daemon client infrastructure to main.go with TryConnect logic
- Update PersistentPreRun to detect daemon socket and route through RPC
- Add --no-daemon flag to force direct storage mode
- Update all commands (create, update, close, show, list, ready) to use daemon when available
- Maintain backward compatibility with graceful fallback to direct mode
- All commands work identically in both daemon and direct modes

Part of bd-110 daemon architecture implementation.

Amp-Thread-ID: https://ampcode.com/threads/T-bfe2c083-be7c-4064-8673-fa69c22a730e
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 23:13:22 -07:00
Steve Yegge
b87ef26b22 Fix renumber counter: Force reset to actual max ID
The counter wasn't being properly reset after renumbering because
SyncAllCounters uses MAX(old, new) which kept higher values from
deleted issues.

Solution: Add ResetCounter() method to delete the counter entry,
then SyncAllCounters recreates it from the actual max ID in database.

Now after renumbering 108 issues to bd-1..bd-108, the counter is
correctly set to 108 and next issue will be bd-109.
2025-10-16 21:51:35 -07:00
Steve Yegge
3759eca598 Fix renumber: Update counter after renumbering
After renumbering issues to bd-1 through bd-108, the counter was still
at the old value (346), causing next issue to be bd-347 instead of bd-109.

Fix: Call SyncAllCounters after renumbering to recalculate counter from
actual max ID in database.
2025-10-16 21:48:34 -07:00
Steve Yegge
8298cbd375 Fix bd-346: Auto-flush after renumber/rename-prefix now does full export
Problem: Incremental flush merged dirty issues with existing JSONL, leaving
old IDs when issues were renamed (e.g., test-3 remained after renumbering to test-2).

Solution:
- Add needsFullExport flag to force complete JSONL rebuild from DB
- Skip loading existing JSONL when fullExport=true (start with empty map)
- Use markDirtyAndScheduleFullExport() in renumber and rename-prefix commands
- PersistentPostRun flushes immediately before process exits (respects fullExport)

Test: Verified renumber with gaps correctly exports only current IDs to JSONL
2025-10-16 21:29:20 -07:00
Steve Yegge
55cd9e062b Fix bd-345: Use UUID-based temp IDs in renumber to prevent collisions
- Replace predictable temp IDs (temp-renumber-N) with UUIDs (temp-<uuid>)
- Fetch dependencies before ID updates to preserve them correctly
- Add comprehensive tests for renumbering with ID gaps, dependencies, and text refs
- All tests pass
2025-10-16 21:21:17 -07:00
Steve Yegge
8347e5bcd7 Fix: Add auto-flush to renumber, rename-prefix, and compact commands
These commands modify issues in bulk but weren't triggering auto-export
to JSONL. This caused database and JSONL to get out of sync.

Added markDirtyAndScheduleFlush() calls to:
- bd renumber (after renumbering completes)
- bd rename-prefix (after prefix rename completes)
- bd compact (after single/batch compaction)
- bd delete (already had it)

Fixes the issue where massive cleanups weren't exported to JSONL.

Amp-Thread-ID: https://ampcode.com/threads/T-a43dc9fa-e9bc-43c7-9055-33acc08bc642
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 20:50:40 -07:00
Steve Yegge
872f203c57 Add RPC infrastructure and updated database
- RPC Phase 1: Protocol, server, client implementation
- Updated renumber.go with proper text reference updates (3-phase approach)
- Clean database exported: 344 issues (bd-1 to bd-344)
- Added DAEMON_DESIGN.md documentation
- Updated go.mod/go.sum for RPC dependencies

Amp-Thread-ID: https://ampcode.com/threads/T-456af77c-8b7f-4004-9027-c37b95e10ea5
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 20:36:23 -07:00
Steve Yegge
44550df33e Database cleanup and renumbering
- Closed 82 duplicate issues
- Deleted 330 test/duplicate issues
- Implemented bd renumber command with proper text reference updates
- Cleaned database: 674 → 344 issues (49% reduction)
- All issues now numbered bd-1 through bd-344
- Added RPC infrastructure (Phase 1) for daemon support
- Delete helper scripts for cleanup operations

Fixes: bd-696, bd-667, bd-698
Related: bd-695 (Epic: Database cleanup)
Amp-Thread-ID: https://ampcode.com/threads/T-456af77c-8b7f-4004-9027-c37b95e10ea5
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 20:36:12 -07:00
Steve Yegge
08a6bf2681 Update issues database and main command
Amp-Thread-ID: https://ampcode.com/threads/T-ad2e485a-ee9a-4055-886d-c875a2824091
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 19:25:33 -07:00
Steve Yegge
f32d90af4e Implement bd delete command with comprehensive cleanup 2025-10-16 19:18:23 -07:00
Steve Yegge
27542648ad Fix bd-663: Treat metadata errors as first import instead of failing
- GetMetadata() failures now set lastHash='' instead of returning early
- Allows auto-import to recover from corrupt/missing metadata
- Prevents auto-import from being permanently disabled
- All tests pass

Amp-Thread-ID: https://ampcode.com/threads/T-4e4a57c4-9ac0-43dc-a78e-b7e88123cc65
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 19:15:48 -07:00
Steve Yegge
ef31d98b43 Fix bd-666: Replace N+1 query pattern in auto-import with batch fetch
- Batch fetch all existing issues with SearchIssues() upfront
- Use O(1) map lookup instead of O(n) GetIssue() calls
- Improves performance dramatically with 1000+ issues
- All tests pass
2025-10-16 19:14:17 -07:00
Steve Yegge
2abccb7a88 Implement bd restore command and flip ready work sort order
- Add bd restore command to view full history of compacted issues from git
- Command temporarily checks out historical commit, reads JSONL, displays original content
- Read-only operation, no database or git state modification
- Flip ready work sort to created_at ASC (older issues first within priority tier)
- Prevents issue treadmill effect, surfaces old P1s for triage
- Update README.md and AGENTS.md with restore documentation

Closes bd-407, bd-383
2025-10-16 18:06:53 -07:00
Steve Yegge
97e74b8585 Add comprehensive integration tests for auto-import collision detection (bd-401)
- Created autoimport_collision_test.go with 10 new test scenarios
- Added helper functions: createTestDBWithIssues, writeJSONLFile, captureStderr
- Tests cover: multiple collisions, all collisions, exact matches, hash fast path,
  parse errors, empty JSONL, new issues only, field conflicts, JSONL not found
- Achieved 75.3% coverage of autoImportIfNewer function
- All 17 auto-import tests passing in ~1 second
- Tests verify collision auto-remapping behavior

Closes bd-401

Amp-Thread-ID: https://ampcode.com/threads/T-d3cbaebd-54e8-425e-8e4a-d41cf5ccd247
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 17:44:58 -07:00
Travis Cline
b17fcdbb2a Add scripttest-based integration tests (#59)
- Complete test coverage for all major bd commands:
  blocked, close, create, dep (add/remove/tree), export, help,
  import, init, list, quickstart, ready, show, stats, update, version
- Test data files validate command behavior and output
- Enables automated testing of full CLI workflows
2025-10-16 17:11:54 -07:00
Steve Yegge
363cd3b4e6 Add rename-prefix command (bd-420)
- Implement bd rename-prefix command with --dry-run and --json flags
- Add prefix validation (max 8 chars, lowercase, starts with letter)
- Update all issue IDs and text references atomically per issue
- Update dependencies, labels, events, and counters
- Fix counter merge to use MAX() to prevent ID collisions
- Update snapshot tables for FK integrity
- Add comprehensive tests for validation and rename workflow
- Document in README.md and AGENTS.md

Known limitation: Each issue updates in its own transaction.
A failure mid-way could leave mixed state. Acceptable for
intended use case (infrequent operation on small DBs).

Amp-Thread-ID: https://ampcode.com/threads/T-7e77b779-bd88-44f2-9f0b-a9f2ccd54d38
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 17:05:27 -07:00
Steve Yegge
1eb59fa120 chore: Bump version to 0.9.8
Updated all component versions:
- bd CLI: 0.9.7 → 0.9.8
- Plugin: 0.9.7 → 0.9.8
- MCP server: 0.9.7 → 0.9.8
- Documentation: 0.9.7 → 0.9.8

Generated by scripts/bump-version.sh
2025-10-16 15:10:43 -07:00
Steve Yegge
c3e3326bba Fix critical bugs: bd-169, bd-28, bd-393
- bd-169: Add -q/--quiet flag to bd init command
- bd-28: Improve error handling in RemoveDependency
  - Now checks RowsAffected and returns error if dependency doesn't exist
  - New removeDependencyIfExists() helper for collision remapping
- bd-393: CRITICAL - Fix auto-import skipping collisions
  - Auto-import was LOSING work from other workers
  - Now automatically remaps collisions to new IDs
  - Calls RemapCollisions() instead of skipping

All tests pass.

Amp-Thread-ID: https://ampcode.com/threads/T-cba86837-28db-47ce-94eb-67fade82376a
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 15:00:54 -07:00
Steve Yegge
2c134e237b Fix bd-306: Use PID suffix for temp files to avoid concurrent collisions
- Change temp filename from issues.jsonl.tmp to issues.jsonl.tmp.<pid>
- Prevents race conditions when multiple bd commands run concurrently
- Added issues bd-300 through bd-306 (git-based restoration epic)
2025-10-16 14:54:12 -07:00
Steve Yegge
1e32041fe6 Implement cycle detection and prevention improvements
- Add diagnostic warnings when cycles detected after dep add (bd-309)
- Add semantic validation for parent-child dependency direction (bd-308)
- Document cycle handling behavior in code, README, and DESIGN (bd-310)

Changes:
- cmd/bd/dep.go: Add DetectCycles() call and warning after dep add
- internal/storage/sqlite/dependencies.go: Add parent-child direction validation and comprehensive cycle prevention comments
- internal/storage/sqlite/dependencies_test.go: Add TestParentChildValidation
- README.md: Add dependency types and cycle prevention section with examples
- DESIGN.md: Add detailed cycle prevention design rationale and trade-offs
2025-10-16 13:18:07 -07:00
Steve Yegge
3f4f7cc185 Implement bd daemon command with production-ready improvements
- Add bd daemon command for background git sync (bd-273)
- Implement PID file management with atomic creation (O_EXCL)
- Add session detachment (Setsid) to survive terminal closure
- Implement graceful shutdown with SIGTERM/SIGINT/SIGHUP handling
- Add context cancellation and per-sync timeouts (2min)
- Use secure file permissions (0600 for PID/log, 0700 for .beads)
- Add startup confirmation before reporting success
- Implement interval validation and comprehensive error handling
- Add full test coverage for daemon lifecycle
- Update README.md with daemon documentation

All oracle review recommendations implemented.

Resolves: bd-273
Amp-Thread-ID: https://ampcode.com/threads/T-117c4016-b25d-462a-aa75-6060df4b2892
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 13:10:19 -07:00
Steve Yegge
669636c828 Fix bd sync critical issues from code review
- Fix dry-run to not mutate state (no export/clear dirty flags)
- Use os.Executable() for import to avoid path hijacking
- Add preflight checks for merge/rebase in progress
- Add upstream tracking validation with helpful hints
- Use CommandContext for all git operations (enable cancellation)
- Add chmod(0644) to exportToJSONL for consistency with export.go

All critical issues from Oracle review addressed.
2025-10-16 12:43:43 -07:00
Steve Yegge
3acaebf191 chore: merge and sync issues 2025-10-16 12:23:30 -07:00
Steve Yegge
91fdaeee1c fix: Resolve false positive merge conflict detection in auto-import
- Changed from substring matching to standalone line detection
- Only flags actual Git conflict markers on their own lines
- Prevents false alarms from conflict markers in issue descriptions
- Fixes bd-313

Amp-Thread-ID: https://ampcode.com/threads/T-2acdebf1-e4ce-4534-8538-4e7c4fb84232
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 12:23:14 -07:00
Steve Yegge
96e92de7c6 Implement bd sync command for automated git-based synchronization
- Added bd sync command that wraps export → commit → pull → import → push workflow
- Automatically resolves collisions during pull/import
- Supports --dry-run, --message, --no-pull, --no-push flags
- Updated README with bd sync documentation
- Addresses bd-272 (Phase 1: git-based sync)
2025-10-16 12:22:35 -07:00
Steve Yegge
1cc37d9acf Remove all restore/snapshot references from compaction
- Removed restore command from bd show output
- Updated compact help text (removed snapshot claim)
- Fixed COMPACTION.md (removed 'batch restore' from roadmap)
- All compaction UI now correctly states permanent decay
2025-10-16 01:13:08 -07:00
Steve Yegge
6786d68365 Add compaction status indicators to bd show command
- Display emoji in title line (🗜️ Tier 1, 📦 Tier 2)
- Show compaction level in status line
- Add footer with size savings and restore command
- JSON output includes all compaction fields

Closes bd-263

Amp-Thread-ID: https://ampcode.com/threads/T-8113e88e-1cd0-4a9e-b581-07045a3ed31e
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 01:04:59 -07:00
Steve Yegge
e99de1b5e3 Add EventCompacted to event system (bd-262)
- Add EventCompacted event type constant
- Add compaction fields to Issue struct (CompactionLevel, CompactedAt, OriginalSize)
- Update ApplyCompaction to record compaction events with JSON metadata
- Update bd show to display compaction status with emoji indicators
- Update GetIssue query to load compaction fields
- All tests passing

Amp-Thread-ID: https://ampcode.com/threads/T-3f7946c6-8f5e-4a81-9527-1217041c7b39
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 01:00:27 -07:00
Steve Yegge
5e420e8ee0 Fix bd-270: Detect and handle Git merge conflicts in JSONL auto-import
- Add pre-parse merge conflict marker detection before JSON parsing
- Show clear error message when conflicts are detected
- Provide resolution instructions (Git client or bd export)
- Add TestAutoImportMergeConflict test case
- Prevents silent auto-import failures from cryptic parse errors

Amp-Thread-ID: https://ampcode.com/threads/T-d83011c0-7dfc-49c9-96c1-05c94ec2a3d3
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 00:49:41 -07:00
Steve Yegge
da5493bac0 Remove snapshot/restore functionality from compaction
Snapshots defeated the entire purpose of compaction - if we're keeping
the original content, we're not actually saving any space. Compaction
is about graceful memory decay for agentic databases, not reversible
compression.

Removed:
- CreateSnapshot/GetSnapshots/RestoreFromSnapshot from storage
- --restore flag and functionality from bd compact command
- All snapshot-related tests
- Snapshot struct and related code

The database is ephemeral and meant to decay over time. Compaction
actually reduces database size now.

Closes bd-260 (won't fix - conceptually wrong)
Closes bd-261 (already done in bd-259)
2025-10-16 00:26:42 -07:00
Steve Yegge
35a4cba829 Add bd compact CLI command (bd-259)
Implements the compact command with all required features:
- --dry-run: Preview compaction with size estimates
- --all: Process all eligible candidates
- --id: Compact specific issue
- --force: Bypass eligibility checks (requires --id)
- --stats: Show compaction statistics
- --tier: Select compaction tier (1 or 2)
- --workers: Configure parallel workers
- --batch-size: Configure batch processing
- Progress bar with visual feedback
- JSON output support
- Proper exit codes and error handling
- Summary reporting (count, bytes saved, reduction %, time)

Includes additional test coverage for compaction and snapshot operations.

Amp-Thread-ID: https://ampcode.com/threads/T-ffcaf749-f79c-4b03-91dd-42136b2744b1
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 00:13:14 -07:00
Steve Yegge
e2c42c35c4 Add label and title filtering to bd list (closes #45, bd-269)
- Add --label/-l flag to filter issues by labels (AND logic)
- Add --title flag to filter issues by title substring
- Add TitleSearch field to IssueFilter type
- Implement label and title filtering in SearchIssues
- Perfect for worktree-specific issue management

Examples:
  bd list --label worktree,feature-x
  bd list --title "authentication"
  bd list --label worktree --title "bug"
2025-10-15 23:51:57 -07:00