Replaces manual working directory save/restore patterns
with Go's built-in `t.Chdir()` helper across 23 test files.
The manual pattern involved calling `os.Getwd()` to save
the original directory, using `defer os.Chdir(origWd)` for
restoration, and manually handling errors during directory
changes. This boilerplate has been replaced with single
`t.Chdir(path)` calls that handle cleanup automatically.
The `t.Chdir()` method automatically restores the working
directory when the test completes, eliminating the need for
manual defer statements and error handling.
Total:
~75 instances replaced (assuming Claude's math is right)
Co-authored-by: Claude <noreply@anthropic.com>
The test was picking up global git config when checking that --skip-merge-driver
didn't set the merge.beads.driver config locally.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
bd init now refuses when:
- JSONL file exists with >0 issues (fresh clone scenario)
- Database file already exists (already initialized)
Suggests `bd doctor --fix` for fresh clones and provides clear guidance.
Added --force flag to bypass the safety guard when needed.
Closes: bd-emg
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Previously, setupClaudeSettings would silently create an empty settings
map when json.Unmarshal failed, then write just a prompt field to the
file - destroying all existing user settings (permissions, hooks, etc).
Now returns a clear error asking the user to fix the JSON syntax
manually, preserving their original file contents.
Also properly handles permission errors when reading existing files.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Jimmy Stridh <jimmystridh@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
The mergeDriverInstalled() function was only checking for the legacy
"beads.jsonl" filename, but installMergeDriver() writes the canonical
"issues.jsonl" filename. This caused false negatives where users with
the correct canonical configuration would be incorrectly flagged as
"not installed", potentially triggering unnecessary reinstalls.
Changes:
- Update mergeDriverInstalled() to check for both filenames
- Add test for canonical issues.jsonl filename detection
- Ensure existing correct configs are not unnecessarily overwritten
This fixes the inconsistency found during code review of bd-3sz0.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Old bd versions (<0.24.0) installed merge driver with invalid %L/%R
placeholders. Git only supports %O (base), %A (current), %B (other).
Changes:
- mergeDriverInstalled() now detects %L/%R and returns false to trigger repair
- bd init automatically fixes stale configs during initialization
- bd doctor --fix also repairs stale configs
- Added comprehensive test coverage for auto-repair
Fixes: bd-3sz0
Epic: bd-tbz3 (all sub-issues now complete)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
The canonical beads database name is issues.jsonl. Tens of thousands of users
have issues.jsonl, and beads.jsonl was only used by the Beads project itself
due to git history pollution.
Changes:
- Updated bd doctor to warn about beads.jsonl instead of issues.jsonl
- Changed default config from beads.jsonl to issues.jsonl
- Reversed precedence in checkGitForIssues to prefer issues.jsonl
- Updated git merge driver config to use issues.jsonl
- Updated all tests to expect issues.jsonl as the default
issues.jsonl is now the canonical default; beads.jsonl is legacy
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Git merge drivers only support three placeholders:
- %O (ancestor/base)
- %A (current version)
- %B (other branch's version)
The code was incorrectly using %L and %R, which don't exist in git,
causing them to be passed through literally and breaking JSONL merges.
Changes:
- Fixed merge driver config in init.go, merge.go, README.md, docs
- Added detection in bd doctor with clear error messages
- Added auto-fix in bd doctor --fix
- Added proactive warning in bd sync before git pull
- Added reactive error detection after merge failures
- Updated all tests to use correct placeholders
Now users get helpful guidance at every step:
1. bd doctor detects the issue
2. bd doctor --fix auto-corrects it
3. bd sync warns before pulling if misconfigured
4. Error messages suggest bd doctor --fix when merge fails
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Check existing JSONL issues before falling back to directory name on initialization
- Implement readFirstIssueFromJSONL() to extract prefix from first issue
- Added tests for readFirstIssueFromJSONL
- Test auto-install in quiet mode (bd init --quiet)
- Test --skip-merge-driver flag
- Test detection of already-installed merge driver (no duplication)
- Test append to existing .gitattributes (preserve content)
- Test non-git repo gracefully skips merge driver
- Test git config has correct merge.beads.driver settings
Fixes: bd-csvy
Amp-Thread-ID: https://ampcode.com/threads/T-b237be26-6dd8-4d4e-9b9d-b460ace8ce72
Co-authored-by: Amp <amp@ampcode.com>
- Added merge_test.go with 797 lines of test coverage
- Tests for field merging, dependency merging, timestamp handling
- Tests for deletion detection and conflict generation
- Integration tests for merge driver auto-config in bd init
- Test helpers for git repository setup
Closes bd-kazt
All tests pass: go test ./internal/merge/... -v
Amp-Thread-ID: https://ampcode.com/threads/T-f0fe7c4c-13e7-486b-b073-fc64b81eeb4b
Co-authored-by: Amp <amp@ampcode.com>
GH #210: bd init --no-db was creating config.yaml but leaving
no-db commented out, forcing users to pass --no-db on every command.
Changes:
- Modified createConfigYaml() to accept noDbMode parameter
- When true, writes 'no-db: true' instead of '# no-db: false'
- Added TestInitNoDbMode() to verify end-to-end workflow
The config reading logic was already in place (main.go:122), just needed
to write the correct value during init.
Fixes bd-5cny
Amp-Thread-ID: https://ampcode.com/threads/T-2c569435-6291-40e8-b39b-c33fd317d853
Co-authored-by: Amp <amp@ampcode.com>
- Changed bd init to always create beads.db instead of {prefix}.db
- Added migration logic to detect and rename old databases
- Updated findDatabaseInTree to prefer beads.db and warn on multiple .db files
- Daemon now refuses to start if multiple .db files exist (ambiguity error)
- Updated tests to expect beads.db instead of prefix-based naming
- Tested migration, ambiguity detection, and warning messages
Fixes#118 - Users can now initialize databases outside project directory
Changes:
- Check BEADS_DB env var in init command (PersistentPreRun skipped for init)
- Use global dbPath from --db flag or BEADS_DB, else default to .beads/{prefix}.db
- Use canonical path comparison (filepath.Abs + Clean) instead of strings.Contains
- Only create .beads/ directory when database is actually local
- Ensure parent directory exists for custom database paths
- Add comprehensive tests for --db flag, BEADS_DB env var, and edge cases
- Fix test isolation by resetting global dbPath in test setup
Tests:
- Custom path with --db flag
- Custom path with BEADS_DB env var
- Custom path containing ".beads" substring (prevents false positive)
- Flag precedence over env var
- All existing tests still pass
Amp-Thread-ID: https://ampcode.com/threads/T-04e2c94f-894a-4b49-8132-980450b2300d
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.