- Refactor bd onboard to output instructions instead of doing string replacement
- Leverage agent intelligence to naturally integrate bd into documentation
- Bootstrap via 'BEFORE ANYTHING ELSE: run bd onboard' in AGENTS.md
- Agent receives formatted instructions to update AGENTS.md and CLAUDE.md
- More agentic approach - adapts to existing project structure
- Update README with new bootstrap workflow
Amp-Thread-ID: https://ampcode.com/threads/T-d70fd1bf-8d44-48b6-bb55-5ae49efb23b8
Co-authored-by: Amp <amp@ampcode.com>
- Add --label flag for AND filtering (must have ALL labels)
- Add --label-any flag for OR filtering (must have AT LEAST ONE label)
- Add normalizeLabels() helper to trim, dedupe, and clean inputs
- Fix RPC title filtering parity bug (forward via Query field)
- Add comprehensive tests for label filtering including combined AND+OR
- Update documentation in README and CHANGELOG
- Improve flag help text to clarify combined semantics
Closes bd-161
- Populate labels in bd list human-readable output (direct mode)
- Populate labels in bd list JSON output (direct and daemon modes)
- Populate labels in daemon RPC handlers (handleList, handleShow)
- handleShow now returns full IssueDetails with labels/deps/dependents
- Labels displayed with 'Labels: [label1, label2]' format
Closes bd-164
Amp-Thread-ID: https://ampcode.com/threads/T-30cd607d-c509-4a8c-9cac-c2aea2ad75c6
Co-authored-by: Amp <amp@ampcode.com>
- Updated label CLI commands to support both daemon and direct modes
- Added label fetching to GetIssue() and scanIssues() methods
- All label operations (add, remove, list, list-all) work with daemon
- Closed bd-162 (label CLI commands), bd-166 (duplicate), bd-141 (daemon support)
Amp-Thread-ID: https://ampcode.com/threads/T-4858f62e-ad06-4cc7-ad05-17ee76861f86
Co-authored-by: Amp <amp@ampcode.com>
Changes to cmd/bd/main.go:
- Add BEADS_NO_DAEMON env var to explicitly disable daemon (single-user mode)
- Keep BEADS_AUTO_START_DAEMON for backward compatibility
- Lower global daemon threshold from 4+ repos to 2+ repos
- Document always-daemon mode as default behavior
Also create bd-161 epic for label enhancements with child tasks.
Amp-Thread-ID: https://ampcode.com/threads/T-675a2db5-b1b3-480d-a108-b003d8139d08
Co-authored-by: Amp <amp@ampcode.com>
Add WaitReady() channel to RPC server that signals when the socket is
listening and ready to accept connections. Previously daemon startup
waited a fixed 2 seconds which could fail if the server took longer.
Changes:
- Add readyChan to Server struct
- Signal ready after listener bind completes
- Update daemon startup to wait on WaitReady() channel
- Increase timeout to 5s with proper signaling
This fixes multi-repo daemon routing test failures where daemon would
start but not be ready to handle requests within the timeout window.
Amp-Thread-ID: https://ampcode.com/threads/T-675a2db5-b1b3-480d-a108-b003d8139d08
Co-authored-by: Amp <amp@ampcode.com>
- Add --max-depth/-d flag with default of 50
- Wire flag through to store.GetDependencyTree()
- Add input validation (must be >= 1)
- Show inline '… [truncated]' markers on truncated nodes
- Update truncation warning to show actual depth used
- Add comprehensive tests (truncation, default depth, boundary cases)
- Update CLI docs and reference
Thanks to @yashwanth-reddy909 for the initial implementation in PR #87.
This commit completes the feature with full wiring, validation, tests, and docs.
Amp-Thread-ID: https://ampcode.com/threads/T-c439b09c-cff2-48d9-8988-cf9353f0d32e
Co-authored-by: Amp <amp@ampcode.com>
Implemented bd-150: Improve daemon fallback visibility and user feedback
- Added DaemonStatus struct to track connection state
- Enhanced BD_DEBUG logging with detailed diagnostics and timing
- Added BD_VERBOSE mode with actionable warnings when falling back
- Implemented health checks before using daemon
- Clear fallback reasons: connect_failed, health_failed, auto_start_disabled, auto_start_failed, flag_no_daemon
- Updated documentation
Implemented bd-151: Add version compatibility checks for daemon RPC protocol
- Added ClientVersion field to RPC Request struct
- Client sends version (0.9.10) in all requests
- Server validates version compatibility using semver:
- Major version must match
- Daemon >= client for backward compatibility
- Clear error messages with directional hints (upgrade daemon vs upgrade client)
- Added ClientVersion and Compatible fields to HealthResponse
- Implemented 'bd version --daemon' command to check compatibility
- Fixed batch operations to propagate ClientVersion for proper checks
- Updated documentation with version compatibility section
Code review improvements:
- Propagate ClientVersion in batch sub-requests
- Directional error messages based on which side is older
- Made ServerVersion a var for future unification
Amp-Thread-ID: https://ampcode.com/threads/T-b5fe36b8-c065-44a9-a55b-582573671609
Co-authored-by: Amp <amp@ampcode.com>
- Refactored autoImportIfNewer() to use shared importIssuesCore()
- Removed ~200 lines of duplicated import logic from main.go
- Manual and auto-import now use identical collision detection/resolution
- Added auto-export scheduling after successful import (prevents JSONL drift)
- Optimized remapping notification (O(n) instead of O(n²), sorted output)
- Removed obsolete test functions for deleted helper functions
- Use bytes.NewReader instead of string conversion for better performance
Benefits:
- Future bug fixes only need to be made once
- Guaranteed consistency between manual and auto-import
- JSONL stays in sync with database after auto-import
- Clearer, more consistent user feedback
Amp-Thread-ID: https://ampcode.com/threads/T-1925a48d-ca8a-4b54-b4e7-de3ec755d25a
Co-authored-by: Amp <amp@ampcode.com>
- Implements bd stale command to show issues with execution_state where executor is dead/stopped
- Adds --release flag to automatically release orphaned issues
- Adds --threshold flag to customize heartbeat staleness threshold (default: 300s/5min)
- Handles missing executor instances (LEFT JOIN) for cases where executor was deleted
- Adds QueryContext and BeginTx helper methods to SQLiteStorage for advanced queries
- Fixes ExternalRef comparison bug in import_shared.go (pointer vs string)
- Removes unused imports in import.go
Resolves vc-124
- Implement shouldUseGlobalDaemon() with multi-repo detection
- Auto-detect 4+ beads repos and prefer global daemon
- Support BEADS_PREFER_GLOBAL_DAEMON env var for explicit control
- Add 'bd daemon --migrate-to-global' migration helper
- Update auto-start logic to use global daemon when appropriate
- Update documentation in AGENTS.md and README.md
Amp-Thread-ID: https://ampcode.com/threads/T-9af9372d-f3f3-4698-920d-e5ad1486d849
Co-authored-by: Amp <amp@ampcode.com>
Improvements based on oracle code review:
- Move socket cleanup AFTER lock acquisition (prevents unlinking live sockets)
- Add PID liveness check before removing stale socket
- Add stale lock detection with retry mechanism
- Tighten directory permissions to 0700 for security
- Improve socket readiness probing with shorter timeouts
- Make removeOldSocket() ignore ENOENT errors
Fixes race condition where socket could be removed during daemon startup window,
potentially orphaning a running daemon process.
Amp-Thread-ID: https://ampcode.com/threads/T-63542c60-b5b9-4a34-9f22-415d9d7e8223
Co-authored-by: Amp <amp@ampcode.com>
- Add OpHealth RPC operation to protocol
- Implement handleHealth() with DB ping and 1s timeout
- Returns status (healthy/degraded/unhealthy), uptime, cache metrics
- Update TryConnect() to use health check instead of ping
- Add 'bd daemon --health' CLI command with JSON output
- Track cache hits/misses for metrics
- Unhealthy daemon triggers automatic fallback to direct mode
- Health check completes in <2 seconds
Amp-Thread-ID: https://ampcode.com/threads/T-1a4889f3-77cf-433a-a704-e1c383929f48
Co-authored-by: Amp <amp@ampcode.com>
Implements bd-9: Allow users to view all paths through diamond dependencies
without deduplication. Useful for debugging complex dependency structures.
Changes:
- Added --show-all-paths flag to bd dep tree command
- Updated GetDependencyTree interface to accept showAllPaths parameter
- Modified deduplication logic to be conditional on flag
- Updated tests to pass new parameter
Amp-Thread-ID: https://ampcode.com/threads/T-43807dd5-8732-49ad-a839-cdb5dae70c35
Co-authored-by: Amp <amp@ampcode.com>
- bd-170: Implement hybrid sorting for ready work (recent 48h first, then oldest)
- bd-87: Use safer null-byte placeholders in ID remapping
- bd-92: Make auto-flush debounce configurable via BEADS_FLUSH_DEBOUNCE
- bd-171: Fix nil pointer dereference in renumber command
- Delete spurious test issues (bd-7, bd-130-134)
- Renumber database from 171 down to 144 issues
The show command was crashing with a nil pointer dereference when
accessing issue.CompactionLevel. This occurred due to two issues in
the daemon mode response handling:
1. The IssueDetails struct incorrectly embedded *types.Issue as a
pointer, causing the JSON unmarshaling to leave it nil. Changed
to embed types.Issue directly.
2. Missing null check for non-existent issues. The daemon returns
null when an issue is not found, which wasn't handled properly.
Added explicit null checking before parsing the response to provide
a clear error message when issues don't exist.
Fixes panic when running: bd show <non-existent-id>
- Split platform-specific daemon process configuration into separate files
- daemon_unix.go: Uses Setsid for Unix/Linux/macOS
- daemon_windows.go: Uses CREATE_NEW_PROCESS_GROUP for Windows
- Fixes compilation error: "unknown field Setsid in struct literal"
This allows bd.exe to build successfully on Windows while maintaining
proper daemon behavior on all platforms.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Auto-starts daemon on first bd command (unless --no-daemon or BEADS_AUTO_START_DAEMON=false)
- Exponential backoff on failures: 5s, 10s, 20s, 40s, 80s, 120s (max)
- Lockfile prevents race conditions when multiple commands start daemon simultaneously
- Stdio redirected to /dev/null to prevent daemon output in foreground
- Uses os.Executable() for security (prevents PATH hijacking)
- Socket readiness verified with actual connection test
- Accepts multiple falsy values: false, 0, no, off (case-insensitive)
- Working directory set to database directory for local daemon context
- Comprehensive test coverage including backoff math and concurrent starts
Fixes:
- Closes bd-1 (won't fix - compaction keeps DBs small)
- Closes bd-124 (daemon auto-start implemented)
Documentation updated in README.md and AGENTS.md
Amp-Thread-ID: https://ampcode.com/threads/T-b10fe866-ab85-417f-9c4c-5d1f044c5796
Co-authored-by: Amp <amp@ampcode.com>
- bd-159: Global daemon now runs in routing mode without opening DB
- bd-158: Set socket permissions to 0600 for security
- bd-160: Reject --auto-commit/--auto-push with --global
- bd-157: Verified stale socket cleanup (already working)
- bd-56: Closed as won't-do (cycle prevention is better)
- bd-73: Multi-repo support complete
Implements bd-121: Global daemon with system-wide socket
Changes:
- Add --global flag to daemon command
- Use ~/.beads/bd.sock when --global is set
- Skip git repo validation for global daemon
- Update daemon discovery to check ~/.beads/ as fallback
- Both Go CLI and Python MCP client check global socket
- Update all tests to pass global parameter
Benefits:
- Single daemon serves all repos on system
- No per-repo daemon management needed
- Better resource usage for users with many repos
- Automatic fallback when local daemon not running
Usage:
bd daemon --global # Start global daemon
bd daemon --status --global # Check global status
bd daemon --stop --global # Stop global daemon
Related: bd-73 (multi-repo epic)
Amp-Thread-ID: https://ampcode.com/threads/T-ea606216-b886-4af0-bba8-56d000362d01
Co-authored-by: Amp <amp@ampcode.com>
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>
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
- 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
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.
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.
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.
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.
- 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>
- 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>
- 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>
- 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.