Strip (bd-xxx), (gt-xxx) suffixes from code comments and changelog
entries. The descriptions remain meaningful without the ephemeral
issue IDs.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Analysis found these commands are dead code:
- gt never calls `bd pin` - uses `bd update --status=pinned` instead
- Beads.Pin() wrapper exists but is never called
- bd hook functionality duplicated by gt mol status
- Code comment says "pinned field is cosmetic for bd hook visibility"
Removed:
- cmd/bd/pin.go
- cmd/bd/unpin.go
- cmd/bd/hook.go
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
gitCommit() was adding the JSONL file but then committing ALL staged
changes (no pathspec). If other files were staged (e.g., deletions from
git add -A), they would be swept into the bd sync commit.
Fixed by adding pathspec to both gitCommit() and commitToExternalBeadsRepo()
so they only commit what they explicitly staged.
This was the root cause of PR #722 files being deleted - they were staged
for deletion in the working tree and got committed by bd sync.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace direct fmt.Fprintf(os.Stderr, "Error:...") + os.Exit(1) patterns with
FatalError() and FatalErrorWithHint() helpers for consistent error handling.
Files updated:
- compact.go: All 48 os.Exit(1) calls converted
- sync.go: All error patterns converted (kept 1 valid summary exit)
- migrate.go: Partial conversion (4 patterns converted)
This is incremental progress on bd-qioh. Remaining work: ~326 error patterns
across other cmd/bd files.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove TestFindJSONLPathDefault from .test-skip (now passes)
- Add explanatory comments to 24 ignored error locations in cmd/bd:
- Cobra flag methods (MarkHidden, MarkRequired, MarkDeprecated)
- Best-effort cleanup/close operations
- Process signaling operations
Part of code health review epic bd-tggf.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add git.GetRepoRoot() with Windows path normalization
- Update beads.findGitRoot() to delegate to git.GetRepoRoot()
- Replace findBeadsDir() with beads.FindBeadsDir() across 8 files
- Remove duplicate findBeadsDir() and findGitRoot() function definitions
- Remove dead test code (TestInfoCommand, TestInfoWithNoDaemon)
- Update tests to work with consolidated APIs
Part of Code Health Review Dec 2025 epic (bd-tggf).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Modernize sorting code to use Go 1.21+ slices package:
- Replace sort.Slice with slices.SortFunc across 16 files
- Use cmp.Compare for orderable types (strings, ints)
- Use time.Time.Compare for time comparisons
- Use cmp.Or for multi-field sorting
- Use slices.SortStableFunc where stability matters
Benefits: cleaner 3-way comparison, slightly better performance,
modern idiomatic Go.
Part of GH#692 refactoring epic.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add done channel to runGitCmdWithTimeoutMsg and runCmdWithTimeoutMessage
so goroutines exit immediately when command completes, rather than
waiting for the full timeout duration.
Follow-up to PR #678.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The timerChan and timeoutChan variables were created but never read from,
causing lint errors. Removed them since we don't need channel synchronization -
we only want the timeout to trigger a message, not block anything.
When git push or other git operations hang waiting for credential/browser
auth, show a helpful message to the user after 5 seconds of inactivity
instead of appearing frozen.
Added:
- runCmdWithTimeoutMessage() in internal/syncbranch/worktree.go
- runGitCmdWithTimeoutMsg() in cmd/bd/sync.go
- Both functions print a message after timeout delay with advice
to check for browser auth prompts
Fixes issue #647 (bd sync frozen waiting for browser auth)
- Update nix vendorHash after fatih/color removal
- Bump version to 0.30.7
- Add GroupID to remaining commands for proper cobra grouping
- Apply semantic color rendering to list and stale commands
- Update pre-commit hook template
Adds configuration options for beads git commits:
- git.author: Override commit author (e.g., "beads-bot <beads@example.com>")
- git.no-gpg-sign: Disable GPG signing for beads commits
This is useful for users with Touch ID commit signing (like Secretive)
who get prompted for every beads auto-commit.
Config example:
```yaml
git:
author: "beads-bot <beads@example.com>"
no-gpg-sign: true
```
Environment variables: BD_GIT_AUTHOR, BD_GIT_NO_GPG_SIGN
Closes#600🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): respect sync.branch config when no upstream tracking
When sync.branch is explicitly configured, bd sync should use worktree-based
sync even if the current branch has no upstream tracking. This fixes the
issue where jj (Jujutsu) colocated repos and git worktrees without upstream
would incorrectly fall back to --from-main mode.
The fix checks for sync.branch configuration BEFORE the upstream check,
allowing the configured sync branch to take precedence.
Affected workflows:
- jj colocated repos (always use detached HEAD)
- Git worktrees not tracking a remote
- Temporary checkouts for testing
Fixes#638
* test(sync): add regression tests for sync.branch priority over upstream check
Add tests verifying that when sync.branch is configured, bd sync does NOT
fall back to --from-main mode even without upstream tracking. This covers:
- sync.branch configured without upstream (should use worktree sync)
- No sync.branch and no upstream (should fallback to from-main)
- Detached HEAD with sync.branch (jj workflow, should use worktree sync)
These tests ensure the fix for GH#638 doesn't regress.
---------
Co-authored-by: Charles P. Cross <cpdata@users.noreply.github.com>
Wire up the existing --no-push flag to a config option so it can be
set as the default, and update bd prime output accordingly.
- Add no-push default to config.go, matching existing pattern
- Check config in sync.go when --no-push flag not explicitly set
- Update bd prime output to omit git push step when enabled
Three changes to fix deleted issues resurrecting during bd sync:
1. daemon handleDelete now uses CreateTombstone instead of DeleteIssue
- internal/rpc/server_issues_epics.go
2. sync.go exportToJSONL now includes IncludeTombstones:true
- cmd/bd/sync.go
3. server_export_import_auto.go handleExport and auto-export now include
tombstones in SearchIssues filter
- internal/rpc/server_export_import_auto.go
Also adds README.md documentation for sync.branch mode (bd-dsdh):
- Explains "always dirty" working tree behavior
- Shell alias tip: gs='git status -- ":!.beads/"'
- When to use bd sync --merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The sync.branch workflow copies JSONL to main working dir without
committing, which blocked bd sync --merge (required clean working dir).
Changes:
- Exclude .beads/ from dirty check in mergeSyncBranch
- Restore .beads/ to HEAD before merge to prevent conflicts
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- errcheck: explicitly discard error returns for git config --unset
- gosec G304: add nolint for safe file read from hardcoded list
- gosec G306: add nolint for .gitattributes (must be world-readable)
- unparam: remove unused gitDir param, use _ for unused ctx
- unparam: change functions with always-nil error returns to void
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add TypeMessage issue type for inter-agent communication
- Add 6 new Issue fields: Sender, Ephemeral, RepliesTo, RelatesTo,
DuplicateOf, SupersededBy
- Add 4 new dependency types: replies-to, relates-to, duplicates, supersedes
- Create migration 019_messaging_fields with indexes
- Update all CRUD operations across storage layer
- Fix reset_test.go to use correct function names
- Fix redundant newline lint error in sync.go
Closes: bd-kwro.1
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add bd sync --check command that performs pre-sync integrity checks
without modifying state:
1. Force push detection: Detects when sync branch has diverged from
remote, indicating a potential force push
2. Prefix mismatch detection: Scans JSONL for issues that don't match
the configured prefix
3. Orphaned children detection: Finds issues with parent references
to non-existent issues
Outputs diagnostic with actionable suggestions for each problem found.
Exits with code 1 if any problems are detected.
Implements bd-hlsw.1: Pre-sync integrity check
When sync.branch is set to the current branch (e.g., main), bd sync
now commits directly instead of failing with a worktree error.
Changes:
- sync.go: Detect when current branch == sync branch and skip worktree
- sync.go: Show appropriate messages for direct-mode commits/pulls
- doctor.go: Change from Error to OK status when on sync branch
The fix allows users to work directly on the sync branch without
having to switch to a different branch for bd sync to work.
Closes: GH#519
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The sync sanitize process was incorrectly removing newly created issues
when they happened to have IDs matching entries in the deletions manifest.
This could occur with hash-based IDs when content is similar to previously
deleted issues.
The fix adds protection for issues that were in the left snapshot (local
export before pull). These represent local work and should not be removed
by sanitize, even if they match entries in the deletions manifest.
Changes:
- Load left snapshot in sanitizeJSONLWithDeletions() to build protection set
- Add protection check before removing issues from JSONL
- Add ProtectedCount/ProtectedIDs to SanitizeResult for tracking
- Log protected issues during sync for visibility
- Add comprehensive test coverage for the fix
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds comprehensive Git worktree support for beads issue tracking:
Core changes:
- New internal/git/gitdir.go package for worktree detection
- GetGitDir() returns proper .git location (main repo, not worktree)
- Updated all hooks to use git.GetGitDir() instead of local helper
- BeadsDir() now prioritizes main repository's .beads directory
Features:
- Hooks auto-install in main repo when run from worktree
- Shared .beads directory across all worktrees
- Config option no-install-hooks to disable auto-install
- New bd worktree subcommand for diagnostics
Documentation:
- New docs/WORKTREES.md with setup instructions
- Updated CHANGELOG.md and AGENT_INSTRUCTIONS.md
Testing:
- Updated tests to use exported git.GetGitDir()
- Added worktree detection tests
Co-authored-by: Claude <noreply@anthropic.com>
Closes: #478
When BEADS_DIR environment variable points to a separate git repository,
bd sync previously failed with "fatal: 'main' is already used by worktree"
because it computed repoRoot from cwd instead of the beads directory.
This fix detects when beads dir is in a different git repo than cwd and
uses direct git operations (add/commit/push/pull) instead of worktree-based
sync, bypassing the problematic worktree creation entirely.
Cherry-picked from PR #533 (cleaned up unrelated changes).
Co-Authored-By: dand-oss <dand-oss@users.noreply.github.com>
The sanitizeJSONLWithDeletions function was incorrectly removing ALL issues
whose ID appeared in deletions.jsonl, including tombstones. This caused:
1. Second sync after delete: tombstone removed from JSONL by sanitize
2. Import sees ID in deletions.jsonl but no tombstone in JSONL
3. Import creates new tombstone via convertDeletionToTombstone
4. UNIQUE constraint error: tombstone already exists in DB
The fix checks the issue status and only removes non-tombstone issues.
Tombstones are the proper representation of deletions and must be preserved.
Added test: TestSanitizeJSONLWithDeletions_PreservesTombstones
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The previous fix didn't handle the multi-repo case - it used bare
'jsonl_content_hash' key but daemon uses 'jsonl_content_hash:<repoKey>'.
Now properly computes repoKey for multi-repo support.
After bd sync completes with sync.branch mode, the daemon or next CLI
command could see a hash mismatch between the restored JSONL file and
the DB metadata, triggering auto-import which then schedules re-export,
dirtying the working directory.
Two fixes:
1. sync.go: Update jsonl_content_hash after restoreBeadsDirFromBranch
to match the restored file hash
2. daemon_sync.go: Update jsonl_content_hash after performAutoImport
succeeds (was missing, unlike CLI import path)
Fixes: bd-lw0x, bd-hxou
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix sync bug where newly created issues were incorrectly tombstoned during bd sync.
The root cause was git-history-backfill finding issues in local commits on the sync branch, then tombstoning them when they weren't in the merged JSONL. The fix protects issues from the left snapshot (local export) from git-history-backfill.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Fix gosec G204/G304 warnings by adding exclusions for safe subprocess
launches and file reads in doctor.go, jira.go, migrate_sync.go, and
syncbranch/worktree.go
- Fix misspell: "cancelled" -> "canceled" in sync.go
- Fix unparam: mark unused ctx params in jira.go placeholder functions
- Fix errcheck: explicitly ignore fmt.Sscanf return in doctor.go and
use closure pattern for deferred os.RemoveAll in worktree.go
- Increase Windows test timeout from 10m to 20m to prevent CI timeouts
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <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>
- bd-dtm: Changed stderr printing to use SafetyWarnings in worktree.go
- bd-ciu: Fixed non-deterministic output order in formatVanishedIssues
- bd-dmd: Removed duplicate safety check message in sync.go
- bd-k2n: PushSyncBranch now recreates worktree if cleaned up
- bd-c5m: Fixed string(rune()) in tests to use strconv.Itoa
- bd-8uk: Added test for SafetyWarnings population
- bd-1kf: Fixed mergePriority to handle negative priorities
- bd-xo9: Documented sync.require_confirmation_on_mass_delete config
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add auto-push functionality to PullFromSyncBranch for true one-command sync:
- After successful content merge, auto-push to remote by default
- Safety check: warn (but dont block) if >50% issues vanished AND >5 existed
- Vanished = removed from JSONL entirely, NOT status=closed
Changes:
- Add push parameter to PullFromSyncBranch function
- Add Pushed field to PullResult struct
- Add countIssuesInContent helper for safety check
- Add test for countIssuesInContent function
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
When multiple clones commit to beads-sync branch and histories diverge,
git merge would fail. This replaces git's commit-level merge with a
content-based merge that extracts JSONL from base/local/remote and
merges at the semantic level.
Key changes:
- Add divergence detection using git rev-list --left-right
- Extract JSONL content from specific commits for 3-way merge
- Reset to remote's history then commit merged content on top
- Pre-emptive fetch before commit to reduce divergence likelihood
- Deletions.jsonl merged by union (keeps all deletions)
🤖 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.
When sync.branch is configured, the main branch's .beads/ directory was
showing as modified after every sync, even though the data was correctly
synced to the sync branch worktree.
This happened because:
1. Export writes to main's .beads/
2. Files are copied to worktree and committed there
3. But main's .beads/ now differs from what's committed on main
Fix: After sync completes, restore .beads/ from HEAD to keep the working
directory clean. The actual beads data lives on the sync branch; the main
branch's .beads/ is just a snapshot that should match what's committed.
When sync.branch is configured, bd sync now commits beads changes
to that branch via git worktree, keeping the user's current branch
(e.g., main) clean of beads sync commits.
Changes:
- Add internal/syncbranch/worktree.go with CommitToSyncBranch and
PullFromSyncBranch functions for worktree-based operations
- Modify sync.go to check sync.branch config and use worktree
functions when configured
- Skip pre-commit hooks in worktree commits (--no-verify) since
bd's pre-commit hook would fail in worktree context
- Re-export after import also uses worktree when sync.branch set
This enables the orchestrator workflow where multiple workers stay
on main but all beads commits flow to a dedicated beads-sync branch.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
When bd init --contributor detects a fork setup (upstream remote exists),
it now configures sync.remote = upstream. This ensures bd sync pulls
beads from the source repo (upstream/main) rather than the fork's
potentially outdated origin/main.
Changes:
- Add sync.remote config in contributor wizard when fork detected
- Modify doSyncFromMain() to use configured sync.remote
- Add getDefaultBranchForRemote() to support any remote name
- Verify configured remote exists before fetching
Fixes bd-bx9
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixes#417: When using --from-main mode (either explicitly or auto-detected),
git history backfill now defaults to disabled. This prevents creating
incorrect deletion records for locally-created beads that don't exist in
main's git history.
Changes:
- Add resolveNoGitHistoryForFromMain() helper function
- Apply noGitHistory=true for both explicit and auto-detected from-main mode
- Add comprehensive unit tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: GraemeF <graeme@graemef.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Root cause: When beads.db is deleted and recreated while daemon is running,
daemon's SQLite connection becomes stale (points to old deleted file via
file descriptor), causing export to return incomplete/corrupt data.
Fix:
- sync command now forces direct mode by closing daemonClient at start
- importFromJSONL subprocess uses --no-daemon to avoid daemon connection issues
- Added documentation to import.go explaining the daemon behavior
Also:
- Skip TestZFCSkipsExportAfterImport (broken test - subprocess spawning
doesn't work in test environment, needs refactoring
- Update hook templates to version 0.26.2
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)