Remove dual code paths in the autoflush system. FlushManager is now the
only code path for auto-flush operations.
Changes:
- Remove legacy globals: isDirty, needsFullExport, flushTimer
- Remove flushToJSONL() wrapper function (was backward-compat shim)
- Simplify markDirtyAndScheduleFlush/FullExport to just call FlushManager
- Update tests to use FlushManager or flushToJSONLWithState directly
FlushManager handles all flush state internally in its run() goroutine,
eliminating the need for global state. Sandbox mode and tests that do
not need flushing get a no-op when FlushManager is nil.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add semantic coloring to help output (section headers, flags, types)
- Reorganize commands into clearer categories:
- "Views & Reports" for readonly queries (ready, stats, blocked, etc.)
- "Maintenance" for health/repair tasks (doctor, validate, migrate, etc.)
- Merge "Issue Metadata" back into "Working With Issues"
- Highlight "doctor" as primary maintenance entry point with "(start here)"
- Create docs/UI_PHILOSOPHY.md documenting Tufte-inspired design principles
- Add guidance for PR to not include .beads/issues.jsonl
Implements gt-0ei3: Template molecules now live in a separate molecules.jsonl
file, distinct from work items in issues.jsonl.
Key changes:
- Add internal/molecules package for loading molecule catalogs
- Implement hierarchical loading: built-in → town → user → project
- Molecules use their own ID namespace (mol-*) with prefix validation skipped
- Templates are marked with is_template: true and are read-only
- bd list excludes templates by default (existing functionality)
The hierarchical loading allows:
- Built-in molecules shipped with bd binary (placeholder for future)
- Town-level: ~/gt/.beads/molecules.jsonl (Gas Town)
- User-level: ~/.beads/molecules.jsonl
- Project-level: .beads/molecules.jsonl
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When bd detects it's running in a fork (origin != steveyegge/beads),
automatically add .beads/issues.jsonl to .git/info/exclude.
This prevents contributors from accidentally including issue database
changes in their PRs. The exclusion is:
- Per-clone (doesn't modify tracked files
- One-time setup (checks if already excluded)
- Silent (only logs in debug mode)
Maintainers (origin = steveyegge/beads) are not affected.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)
- bd mail reply: reply to messages with thread linking via replies_to
- bd show --thread: display full conversation threads
- bd relate/unrelate: bidirectional relates_to links for knowledge graph
- bd duplicate --of: mark issues as duplicates with auto-close
- bd supersede --with: mark issues as superseded with auto-close
- Hooks system: on_create, on_update, on_close, on_message in .beads/hooks/
- RPC protocol: added Sender, Ephemeral, RepliesTo fields to CreateArgs/UpdateArgs
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: auto-disable daemon in git worktrees for safety
Implement worktree daemon compatibility as proposed in the analysis.
The daemon is now automatically disabled when running in a git worktree
unless sync-branch is configured.
Git worktrees share the same .beads directory, and the daemon commits
to whatever branch its working directory has checked out. This causes
commits to go to the wrong branch when using daemon in worktrees.
- Add shouldDisableDaemonForWorktree() helper that checks:
1. If current directory is a git worktree (via git rev-parse)
2. If sync-branch is configured (env var or config.yaml)
- Modify shouldAutoStartDaemon() to call the helper
- Modify daemon connection logic in main.go to skip connection
- Add FallbackWorktreeSafety constant for daemon status reporting
- Update warnWorktreeDaemon() to skip warning when sync-branch configured
- In worktree WITHOUT sync-branch: daemon auto-disabled, direct mode used
- In worktree WITH sync-branch: daemon enabled (commits go to dedicated branch)
- In regular repo: no change (daemon works as before)
- Added comprehensive unit tests for shouldDisableDaemonForWorktree()
- Added integration tests for shouldAutoStartDaemon() in worktree contexts
- Manual E2E testing verified correct behavior
- Updated WORKTREES.md with new automatic safety behavior
- Updated DAEMON.md with Git Worktrees section
* feat: check database config for sync-branch in worktree safety logic
Previously, the worktree daemon safety check only looked at:
- BEADS_SYNC_BRANCH environment variable
- sync-branch in config.yaml
This meant users who configured sync-branch via `bd config set sync-branch`
(which stores in the database) would still have daemon disabled in worktrees.
Now the check also reads sync.branch from the database config table,
making daemon work in worktrees when sync-branch is configured via any method.
Changes:
- Add IsConfiguredWithDB() function that checks env, config.yaml, AND database
- Add findBeadsDB() to locate database (worktree-aware via git-common-dir)
- Add getMainRepoRoot() helper using git rev-parse
- Add getConfigFromDB() for lightweight database reads
- Update shouldDisableDaemonForWorktree() to use IsConfiguredWithDB()
- Update warnWorktreeDaemon() to use IsConfiguredWithDB()
- Add test case for database config path
* refactor: use existing beads.FindDatabasePath() instead of duplicating code
Remove duplicate getMainRepoRoot() and findBeadsDB() functions from
syncbranch.go and use the existing beads.FindDatabasePath() which is
already worktree-aware.
Changes:
- Replace custom findBeadsDB() with beads.FindDatabasePath()
- Remove duplicate getMainRepoRoot() (git.GetMainRepoRoot() exists)
- Remove unused imports (exec, strings, filepath)
- Clean up debug logging in tests
---------
Co-authored-by: Charles P. Cross <cpdata@users.noreply.github.com>
Added onboard and hooks commands to the noDbCommands list so they
skip database and daemon initialization. These commands don't need
database access - they just output documentation or manage git hooks.
On Windows, if no .beads directory exists, the PersistentPreRun
would attempt database discovery (including git worktree detection)
which could hang due to git command issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements single-shot mode improvements for Windows and Docker scenarios:
- Add --lock-timeout global flag (default 30s, 0 = fail immediately)
- Add config file support: lock-timeout: 100ms
- Parameterize SQLite busy_timeout via NewWithTimeout() function
- In --sandbox mode: default lock-timeout to 100ms
- In --sandbox mode: skip FlushManager creation (no background goroutines)
This addresses bd.exe hanging on Windows and locking conflicts when
using beads across host + Docker containers.
Closes: bd-59er, bd-r4od, bd-dh8a
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add JSONL-only mode detection in ensureStoreActive() with context-aware
error messages that suggest correct actions based on project state
- Improve error messages in main.go to detect JSONL presence and suggest
appropriate solutions (bd init, --no-db flag, or config.yaml setting)
- Update documentation to use issues.jsonl as canonical filename:
- AGENT_INSTRUCTIONS.md, README.md, resolve-beads-conflict.md
- docs/GIT_INTEGRATION.md
- Update hook template comments to clarify issues.jsonl is canonical
while maintaining backward compatibility for beads.jsonl
Fixes#534🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace fragile strings.Contains("no-db: true") with proper YAML parsing
to avoid false matches in comments or nested keys.
Changes:
- Add NoDb field to localConfig struct
- Add isNoDbModeConfigured() helper function
- Update main.go and doctor.go to use the helper
- Add 8 test cases for isNoDbModeConfigured
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a --readonly flag that blocks all write operations, allowing workers
to read beads state without modifying it. Workers can use:
- bd show, bd list, bd ready (read operations)
Workers cannot use:
- bd create, bd update, bd close, bd sync, etc. (write operations)
The flag can be set via:
- --readonly flag on command line
- BD_READONLY=true environment variable
- readonly: true in config file
This enables swarm workers to see their assigned work from a static
snapshot of the beads database without accidentally modifying it.
Commands protected by readonly mode:
- create, update, close, delete, edit
- sync, import, reopen
- comment add, dep add/remove, label add/remove
- repair-deps, compact, migrate, migrate-hash-ids, migrate-issues
- rename-prefix, validate --fix-all, duplicates --auto-merge
- epic close-eligible, jira sync
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
When sync.branch is configured, the sync command:
1. Exports changes to JSONL
2. Commits to sync branch via worktree
3. Pulls from sync branch
4. Restores .beads/ from HEAD to keep working directory clean
But PersistentPostRun's flushManager.Shutdown() was re-exporting to JSONL,
undoing the restore and leaving modified files.
Fix: Set skipFinalFlush flag when sync.branch mode completes successfully.
This prevents the final export in PersistentPostRun.
Also: Skip push to main branch when sync.branch is configured - all
pushes should go through the sync branch worktree.
Fixes from maphew including:
- Remove test for deleted isPathWithinDir function
- Add gosec nolint directives for safe file operations
- Add rm -rf .beads before init in CI workflow
- Simplify panic handling and file operations
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: maphew <maphew@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- issues.jsonl: Keep closed status for bd-5kj (already resolved)
- main.go: Clean up JSONL-only mode detection, include BD_ACTOR env check
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
When .beads exists with issues.jsonl but no SQLite database, and config.yaml
has no-db: true, automatically enable JSONL-only mode instead of failing
with 'no beads database found'. Also improved error message to mention
--no-db option.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- bound fresh-clone JSONL discovery to the .beads dir (abs path, traversal guard) before reading counts
- add safeWorkspacePath/isWithinWorkspace helpers and use in doctor fixes (database_config, untracked) to reject absolute/traversal inputs and confine .gitattributes edits
- normalize git status paths and path-guard tests for cross-OS (Windows) compatibility
- add regression tests for the new guards
When opening a database that exists but is missing issue_prefix config
(typical in fresh clone scenarios), show a helpful error message instead
of cryptic migration invariant errors.
The new message:
- Explains the database needs initialization
- Detects if a JSONL file exists and shows the issue count
- Suggests the exact command to run: bd import -i <path>
- Falls back to suggesting bd init --prefix if no JSONL exists
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Short tests were timing out after 13+ minutes due to:
1. TestZFCSkipsExportAfterImport spawning subprocess that tried to
auto-start daemon - now skipped in short mode
2. TestVersionFlag taking 5+ seconds because --version flag did not
skip PersistentPreRun daemon startup - added early return
3. TestGetVersionsSince* had hardcoded version expectations that
became stale - made tests dynamic using versionChanges array
Short tests now complete in ~8 seconds instead of timing out.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Critical fixes from code review:
1. **Moved auto-migration to correct location**
- Now runs AFTER daemon check but BEFORE opening database
- Prevents: database opened twice, conflicts with daemon
- Was: Running too early, before knowing if daemon exists
2. **Fixed context cancellation issue**
- Check if rootCtx is canceled before using it
- Fall back to Background() if canceled
- Fixes: "context canceled" errors in test suite
3. **Updated function signature**
- Takes dbPath as parameter (no longer searches for it)
- Simpler, more explicit, easier to test
- Caller already has dbPath, no need to re-discover
4. **Enhanced test reliability**
- Save/restore all global state
- Add debug logging for troubleshooting
- Verify preconditions before migration
Changes:
- cmd/bd/main.go: Move autoMigrateOnVersionBump call to correct location
- cmd/bd/version_tracking.go: Fix context handling, update signature
- cmd/bd/version_tracking_test.go: Improve test reliability
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
When CLI is upgraded (e.g., 0.24.0 → 0.24.1), the database version
is now automatically updated to match the CLI version during
PersistentPreRun. This fixes the recurring UX issue where bd doctor
shows version mismatch after every CLI upgrade.
Implementation:
- Added autoMigrateOnVersionBump() function in version_tracking.go
- Calls after trackBdVersion() in PersistentPreRun
- Best-effort and silent failures to avoid disrupting commands
- Only updates bd_version metadata field
- Includes comprehensive test coverage
Changes:
- cmd/bd/main.go: Call autoMigrateOnVersionBump() in PersistentPreRun
- cmd/bd/version_tracking.go: Implement auto-migration logic
- cmd/bd/version_tracking_test.go: Add tests for auto-migration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement automatic bd version tracking and upgrade awareness:
- Add LastBdVersion field to Config struct in metadata.json
- Auto-update version on every bd command in PersistentPreRun
- Add 'bd upgrade' command with status/review/ack subcommands
- Show upgrade notifications on 'bd ready' and 'bd list'
- Non-intrusive: only shows once per session, skipped for JSON output
The system tracks version changes automatically and helps users stay
aware of bd upgrades without manual intervention. Notifications are
graceful - failures don't break commands.
Example output on bd ready after upgrade:
🔄 bd upgraded from v0.22.0 to v0.24.2 since last use
💡 Run 'bd upgrade review' to see what changed
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implements GH#206 and bd-3djj: Add support for Aider AI pair programming
tool with beads issue tracking.
Changes:
- Added cmd/bd/setup/aider.go with InstallAider, CheckAider, RemoveAider
- Created .aider.conf.yml template with bd workflow instructions
- Added .aider/README.md template with quick reference
- Updated cmd/bd/setup.go to include aider subcommand
- Fixed cmd/bd/main.go to allow setup subcommands without database by
checking parent command name
- Added comprehensive docs/AIDER_INTEGRATION.md documentation
Key differences from Claude/Cursor integration:
- Aider requires explicit command execution via /run
- AI suggests bd commands rather than running autonomously
- Documentation emphasizes human-in-the-loop workflow
- Config instructs AI to always suggest, never execute
Usage:
bd setup aider # Install integration
bd setup aider --check # Verify installation
bd setup aider --remove # Remove integration
Resolves bd-3djj
Related to GH#206
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implements three quick fixes for users stuck in sandboxed environments
(e.g., Codex) where daemon cannot be stopped:
1. **--force flag for bd import**
- Forces metadata update even when DB is synced with JSONL
- Fixes stuck state caused by stale daemon cache
- Shows: "Metadata updated (database already in sync with JSONL)"
2. **--allow-stale global flag**
- Emergency escape hatch to bypass staleness check
- Shows warning: "⚠️ Staleness check skipped (--allow-stale)"
- Allows operations on potentially stale data
3. **Improved error message**
- Added sandbox-specific guidance to staleness error
- Suggests --sandbox, --force, and --allow-stale flags
- Provides clear fix steps for different scenarios
Also fixed:
- Removed unused import in cmd/bd/duplicates_test.go
Follow-up work filed:
- bd-u3t: Phase 2 - Sandbox auto-detection
- bd-e0o: Phase 3 - Daemon robustness enhancements
- bd-9nw: Documentation updates
Fixes#353 (Phase 1)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Critical fixes to context propagation implementation (bd-rtp, bd-yb8, bd-2o2):
1. Fix rootCtx lifecycle in main.go:
- Removed premature defer rootCancel() from PersistentPreRun (line 132)
- Added proper cleanup in PersistentPostRun (lines 544-547)
- Context now properly spans from setup through command execution to cleanup
2. Fix test context contamination in cli_fast_test.go:
- Reset rootCtx and rootCancel to nil in test cleanup (lines 139-140)
- Prevents cancelled contexts from affecting subsequent tests
3. Fix export tests missing context in export_test.go:
- Added rootCtx initialization in 5 export test subtests
- Tests now properly set up context before calling exportCmd.Run()
These fixes ensure:
- Signal-aware contexts work correctly for graceful cancellation
- Ctrl+C properly cancels import/export operations
- Database integrity is maintained after cancellation
- All cancellation tests pass (TestImportCancellation, TestExportCommand)
Tested:
- go build ./cmd/bd ✓
- go test ./cmd/bd -run TestImportCancellation ✓
- go test ./cmd/bd -run TestExportCommand ✓
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Critical fixes to code review findings:
1. Remove global state access from flushToJSONLWithState
- FlushManager now has true single ownership of flush state
- No more race conditions from concurrent global state access
- flushToJSONLWithState trusts only the flushState parameter
- Legacy wrapper handles success detection via failure count
2. Fix shutdown timeout data loss risk
- Increased timeout from 5s → 30s to prevent data loss
- Added detailed comments explaining the timeout rationale
- Better error message indicates potential data loss scenario
Implementation details:
- New FlushManager uses event-driven single-owner pattern
- Channels eliminate shared mutable state (markDirtyCh, flushNowCh, etc.)
- Comprehensive race detector tests verify concurrency safety
- Backward compatible with existing tests via legacy code path
- ARCHITECTURE.md documents design principles and guarantees
Test results:
- All race detector tests pass (TestFlushManager*)
- Legacy API compatibility verified (TestMarkDirtyAndScheduleFlush*)
- No race conditions detected under concurrent load
Future improvements tracked as beads:
- bd-gdn: Add functional tests for flush correctness verification
- bd-5xt: Log errors from timer-triggered flushes
- bd-i00: Convert magic numbers to named constants
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: add performance testing framework foundation
Implements foundation for comprehensive performance testing and user
diagnostics for beads databases at 10K-20K scale.
Components added:
- Fixture generator (internal/testutil/fixtures/) for realistic test data
* LargeSQLite/XLargeSQLite: 10K/20K issues with epic hierarchies
* LargeFromJSONL/XLargeFromJSONL: test JSONL import path
* Realistic cross-linked dependencies, labels, assignees
* Reproducible with seeded RNG
- User diagnostics (bd doctor --perf) for field performance data
* Collects platform info (OS, arch, Go/SQLite versions)
* Measures key operation timings (ready, list, show, search)
* Generates CPU profiles for bug reports
* Clean separation in cmd/bd/doctor/perf.go
Test data characteristics:
- 10% epics, 30% features, 60% tasks
- 4-level hierarchies (Epic → Feature → Task → Subtask)
- 20% cross-epic blocking dependencies
- Realistic status/priority/label distributions
Supports bd-l954 (Performance Testing Framework epic)
Closes bd-6ed8, bd-q59i
* perf: optimize GetReadyWork with compound index (20x speedup)
Add compound index on dependencies(depends_on_id, type, issue_id) to
eliminate performance bottleneck in GetReadyWork recursive CTE query.
Performance improvements (10K issue database):
- GetReadyWork: 752ms → 36.6ms (20.5x faster)
- Target: <50ms ✓ ACHIEVED
- 20K database: ~1500ms → 79.4ms (19x faster)
Benchmark infrastructure enhancements:
- Add dataset caching in /tmp/beads-bench-cache/ to avoid regenerating
10K-20K issues on every benchmark run (first run: ~2min, subsequent: <5s)
- Add progress logging during fixture generation (shows 10%, 20%... completion)
- Add database size logging (17.5 MB for 10K, 35.1 MB for 20K)
- Document rationale for only benchmarking large datasets (>10K issues)
- Add CPU/trace profiling with --profile flag for performance debugging
Schema changes:
- internal/storage/sqlite/schema.go: Add idx_dependencies_depends_on_type_issue
New files:
- internal/storage/sqlite/bench_helpers_test.go: Reusable benchmark setup with caching
- internal/storage/sqlite/sqlite_bench_test.go: Comprehensive benchmarks for critical operations
- Makefile: Convenient benchmark execution (make bench-quick, make bench)
Related:
- Resolves bd-5qim (optimize GetReadyWork performance)
- Builds on bd-6ed8 (fixture generator), bd-q59i (bd doctor --perf)
* perf: add WASM compilation cache to eliminate cold-start overhead
Configure wazero compilation cache for ncruces/go-sqlite3 to avoid
~220ms JIT compilation on every process start.
Cache configuration:
- Location: ~/.cache/beads/wasm/ (platform-specific via os.UserCacheDir)
- Automatic version management: wazero keys entries by its version
- Fallback: in-memory cache if directory creation fails
- No cleanup needed: old versions are harmless (~5-10MB each)
Performance impact:
- First run: ~220ms (populate cache)
- Subsequent runs: ~20ms (load from cache)
- Savings: ~200ms per cold start
Cache invalidation:
- Automatic when wazero version changes (upgrades use new cache dir)
- Manual cleanup: rm -rf ~/.cache/beads/wasm/ (safe to delete anytime)
This complements daemon mode:
- Daemon mode: eliminates startup cost by keeping process alive
- WASM cache: reduces startup cost for one-off commands or daemon restarts
Changes:
- internal/storage/sqlite/sqlite.go: Add init() with cache setup
* refactor: improve maintainability of performance testing code
Extract common patterns and eliminate duplication across benchmarks, fixture generation, and performance diagnostics. Replace magic numbers with explicit configuration to improve readability and make it easier to tune test parameters.
* docs: clarify profiling behavior and add missing documentation
Add explanatory comments for profiling setup to clarify why --profile
forces direct mode (captures actual database operations instead of RPC
overhead) and document the stopCPUProfile function's role in flushing
profile data to disk. Also fix gosec G104 linter warning by explicitly
ignoring Close() error during cleanup.
* fix: prevent bench-quick from running indefinitely
Added //go:build bench tags and skipped timeout-prone benchmarks to
prevent make bench-quick from running for hours.
Changes:
- Add //go:build bench tag to cycle_bench_test.go and compact_bench_test.go
- Skip Dense graph benchmarks (documented to timeout >120s)
- Fix compact benchmark prefix: bd- → bd (validation expects prefix without trailing dash)
Before: make bench-quick ran for 3.5+ hours (12,699s) before manual interrupt
After: make bench-quick completes in ~25 seconds
The Dense graph benchmarks are known to timeout and represent rare edge
cases that don't need optimization for typical workflows.
- Removes noisy version mismatch warnings on every bd upgrade
- Version field in metadata.json was redundant with daemon version checking via RPC
- Daemon version mismatches still detected via HealthResponse
- Removes checkVersionMismatch() function and related test file
- Updates .beads/.gitignore to properly ignore merge artifacts
Amp-Thread-ID: https://ampcode.com/threads/T-7ba8aff2-97a0-4d0c-9008-e858bdfadd61
Co-authored-by: Amp <amp@ampcode.com>
- Skip auto-import in PersistentPreRun for delete command
- Prevents resurrection of deleted issues from stale git JSONL
- Add TestBulkDeleteNoResurrection to prevent regression
- Verified with full test suite
Amp-Thread-ID: https://ampcode.com/threads/T-635e5cf4-fa2f-4ce3-9f05-43b48010baae
Co-authored-by: Amp <amp@ampcode.com>
Agents were failing with 'bd import' after nuking the database.
Now bd import automatically:
- Creates .beads/ directory if missing
- Detects prefix from imported issues (analyzes JSONL)
- Falls back to directory name if no issues
- Initializes database before proceeding
This fixes the common agent workflow: rm .beads/beads.db && bd import
Amp-Thread-ID: https://ampcode.com/threads/T-3ace45ce-3cd6-46ae-a201-39c3d7f48f0b
Co-authored-by: Amp <amp@ampcode.com>
- Vendored beads-merge algorithm into internal/merge/ with full MIT license attribution
- Created bd merge command as native wrapper (no external binary needed)
- Updated bd init to auto-configure git merge driver (both interactive and --quiet)
- Removed obsolete test files that were incompatible with vendored version
- Added merge to noDbCommands list so it can run standalone
- Tested: successful merge and conflict detection work correctly
Closes bd-bzfy
Thanks to @neongreen for permission to vendor!
See: https://github.com/neongreen/mono/issues/240
Original: https://github.com/neongreen/mono/tree/main/beads-merge
Amp-Thread-ID: https://ampcode.com/threads/T-f0fe7c4c-13e7-486b-b073-fc64b81eeb4b
Co-authored-by: Amp <amp@ampcode.com>
- bd edit now bypasses daemon to prevent broken pipe errors
- Editing in /usr/local/bin/emacsclient can take minutes, causing daemon timeout
- Added check in PersistentPreRun to set noDaemon=true for edit command
- Human-only interactive command doesn't benefit from daemon anyway
Fixes#227
Extracts duplicated path canonicalization logic (filepath.Abs + EvalSymlinks)
into a reusable helper function utils.CanonicalizePath() in internal/utils/path.go.
Changes:
- Add internal/utils/path.go with CanonicalizePath() function
- Add comprehensive tests in internal/utils/path_test.go
- Replace inline canonicalization in beads.go:131-140
- Replace inline canonicalization in cmd/bd/main.go:446-454
- Replace inline canonicalization in cmd/bd/nodb.go:25-33
The new helper maintains identical behavior:
1. Converts path to absolute form via filepath.Abs
2. Resolves symlinks via filepath.EvalSymlinks
3. Falls back gracefully on errors (returns absPath if EvalSymlinks fails,
returns original path if Abs fails)
Fixes bd-efe8
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add BEADS_DIR as a replacement for BEADS_DB to point to the .beads
directory instead of the database file directly.
Rationale:
- With --no-db mode, there's no .db file to point to
- The .beads directory is the logical unit (contains config.yaml, db
files, jsonl files)
- More intuitive: point to the beads directory not the database file
Implementation:
- Add BEADS_DIR environment variable support to FindDatabasePath()
- Priority order: BEADS_DIR > BEADS_DB > auto-discovery
- Maintain backward compatibility with BEADS_DB (now deprecated)
- Update --no-db mode to respect BEADS_DIR
- Update MCP integration (config.py, bd_client.py)
- Update documentation to show BEADS_DIR as preferred method
Testing:
- Backward compatibility: BEADS_DB still works
- BEADS_DIR works with regular database mode
- BEADS_DIR works with --no-db mode
- Priority: BEADS_DIR takes precedence over BEADS_DB
Follow-up issues for refactoring:
- bd-efe8: Refactor path canonicalization into helper function
- bd-c362: Extract database search logic into helper function
Closes bd-e16b
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Renamed config.json to metadata.json to clarify purpose (database metadata)
- Fixed config.yaml/config.json conflict by making Viper explicitly load only config.yaml
- Added automatic migration from config.json to metadata.json on first read
- Fixed jsonOutput variable shadowing across 22 command files
- Updated bd init to create both metadata.json and config.yaml template
- Fixed 5 failing JSON output tests
- All tests passing
Resolves config file confusion and makes config.yaml work correctly.
Closes#178 (global flags), addresses config issues from #193
Amp-Thread-ID: https://ampcode.com/threads/T-e6ac8192-e18f-4ed7-83bc-4a5986718bb7
Co-authored-by: Amp <amp@ampcode.com>
- Add nolint:gosec comments for safe file operations
- G304: File reads from validated/secure paths
- G306/G302: JSONL/error files need 0644 for sharing/debugging
- G204: Subprocess launches with validated arguments
- G104: Deferred file close errors are non-critical
- G115: Safe integer conversions in backoff
- G201: SQL placeholders for IN clause expansion
All warnings are for intentional behavior that is safe in context.
Amp-Thread-ID: https://ampcode.com/threads/T-d78f2780-4709-497f-97b0-035ca8c809e1
Co-authored-by: Amp <amp@ampcode.com>
- Remove broken import special case that created vc.db instead of using found database
- Add git to nativeBuildInputs in default.nix for tests
- Fix path comparison bug (symlink resolution caused prefix mismatch)
When daemon detects multiple .db files (after filtering .backup and vc.db),
it now writes detailed error to .beads/daemon-error file before exiting.
The error file is checked and displayed when:
- Daemon discovery fails to connect
- Auto-start fails to yield a running daemon
- User runs 'bd daemons list'
This makes the error immediately visible without requiring users to check
daemon logs.
Changes:
- cmd/bd/daemon.go: Write daemon-error file on multiple .db detection
- internal/daemon/discovery.go: Read and surface daemon-error in DaemonInfo.Error
- cmd/bd/main.go: Display daemon-error when auto-start fails
Amp-Thread-ID: https://ampcode.com/threads/T-1005a8d1-7a5a-4844-ad2d-2b8a6145825f
Co-authored-by: Amp <amp@ampcode.com>
* Add bd doctor command for installation health checks
Implements a comprehensive health check command similar to claude doctor
that validates beads installation and provides actionable recommendations.
Features:
- Installation check (.beads/ directory exists)
- Database version verification (compares with CLI version)
- ID format detection (hash-based vs sequential)
- CLI version check (fetches latest from GitHub)
- Storage type detection (SQLite vs JSONL-only mode)
- Tree-style output with color-coded warnings
- JSON output for scripting (--json flag)
- Actionable fix recommendations for each issue
Implementation improvements:
- Status constants instead of magic strings
- Semantic version comparison (fixes 0.10.0 vs 0.9.9 edge case)
- Documented defer pattern for intentional error ignore
- Comprehensive test coverage including version comparison edge cases
- Clean integration using slices.Contains for command list
Usage:
bd doctor # Check current directory
bd doctor /path/to/repo # Check specific repository
bd doctor --json # Machine-readable output
* Simplify bd doctor documentation in README
Reduce verbose health check section to 2 lines as requested.
* Fix bd doctor to handle JSONL-only mode for ID format check
When no SQLite database exists (JSONL-only mode), skip the ID format
check instead of showing an error. This prevents the confusing
'Unable to query issues' error when the installation is actually fine.