The --children flag would produce no output for issues without children.
Initialize the map entry in processIssue so the display loop can show
"No children found" message.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds a --children flag to the bd show command that displays only the
children of the specified issue. This is useful for quickly viewing
child steps of an epic without the full issue details.
The flag supports:
- Default mode: shows children with full dependency line formatting
- --short mode: shows compact one-liner per child
- --json mode: outputs children in JSON format
Fixes gt-lzf3.5
Co-authored-by: toast <julianknutsen@users.noreply.github>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add daemonClient.ResolveID() calls before AddComment and ListComments
operations in daemon mode, following the pattern from update.go.
Previously, short IDs (e.g., "5wbm") worked with most bd commands but
failed with `comments add` and `comments list` when using the daemon.
The short ID was passed directly to the RPC server which expected full
IDs (e.g., "prefix-5wbm").
Changes:
- cmd/bd/comments.go: Add ID resolution before daemon RPC calls
- internal/rpc/comments_test.go: Update tests to reflect client-side
resolution pattern (RPC server expects full IDs, CLI resolves first)
Fixes: https://github.com/steveyegge/beads/issues/1070
Add tests demonstrating that `bd comments add` and `bd comments list`
don't accept short IDs in daemon mode, while other commands do.
Tests added:
- TestCLI_CommentsAddShortID (cli_fast_test.go)
- Tests short ID, partial ID, and comment alias in direct mode (passes)
- TestCommentAddWithShortID (internal/rpc/comments_test.go)
- Tests RPC layer with short ID (FAILS - demonstrates bug)
- TestCommentListWithShortID (internal/rpc/comments_test.go)
- Tests listing comments with short ID (FAILS - demonstrates bug)
The fix should add daemonClient.ResolveID() before AddComment/ListComments,
following the pattern in update.go and label.go.
Refs: https://github.com/steveyegge/beads/issues/1070
Previously, displayGates() always showed 'Open Gates' header even when
closed gates were included via --all flag. Also, closed gates would
appear mixed with open gates under the misleading 'Open Gates' header.
Changes:
- Modified displayGates() to accept showAll parameter
- Separates gates into 'Open Gates' and 'Closed Gates' sections
- Closed gates only shown when --all flag is used
- Fixed handleGateList RPC handler to use ExcludeStatus instead of
Status filter for consistency with CLI behavior
Fixes gas-town issue go-47m
The test guard was flagging false positives when SQLite shm/wal files
had their mtime updated from read-only operations (config loading, etc.)
without any actual content modification.
Now only reports when file size changes, which indicates actual content
modification rather than just file access.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add multiple layers of defense against misclassified wisps:
- Importer auto-detects -wisp- pattern and sets ephemeral flag
- GetReadyWork excludes -wisp- IDs via SQL LIKE clause
- Doctor check 26d detects misclassified wisps in JSONL
This addresses recurring issue where wisps with missing ephemeral
flag would pollute bd ready output after JSONL import.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- sync_git_test.go: getCurrentBranchOrHEAD now returns 1 value (not 2)
- daemon_basics_test.go: getPIDFileForSocket uses dbPath not socketPath
- daemon_autostart.go: mark unused socketPath param with underscore
These tests were broken by recent refactors that changed function signatures
but didn't update the corresponding test files.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When using short socket paths (workspaces with paths >103 chars),
filepath.Dir(socketPath) returns /tmp/beads-XXXXX/ instead of the
actual .beads/ directory. This caused TryDaemonLock to look in the
wrong location, always return false, clean up the startlock, and
recurse infinitely causing stack overflow.
Changed 4 occurrences in acquireStartLock, handleStaleLock,
handleExistingSocket, and getPIDFileForSocket to use
filepath.Dir(dbPath) which correctly points to .beads/.
Fixes: gt-qlt
Co-authored-by: furiosa <mayor@gastown.local>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
The function always returns nil for error since it is designed to
return HEAD on detached HEAD state. Simplify signature to just
return string.
Fixes golangci-lint unparam warning.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add bd doctor check that detects legacy gastown merge queue JSON files
in .beads/mq/. These files are local-only remnants from the old mrqueue
implementation and can safely be deleted since gt done already creates
merge-request wisps in beads.
- CheckStaleMQFiles() detects .beads/mq/*.json files
- FixStaleMQFiles() removes the entire mq directory
- Comprehensive tests for check and fix
This is the first step toward removing the mrqueue side-channel from
gastown. The follow-up convoy will update Refinery/Witness to use
beads exclusively.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add bd doctor check that warns if .beads/last-touched is tracked by git.
This file is local runtime state that should never be committed, as it
causes spurious diffs in other clones.
- CheckLastTouchedNotTracked() detects if file is git-tracked
- FixLastTouchedTracking() untracks with git rm --cached
- Comprehensive tests for all scenarios
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
prek (https://prek.j178.dev) is a faster Rust-based alternative to
pre-commit that uses the same .pre-commit-config.yaml config files.
Changes:
- Add prek detection pattern in hookManagerPatterns (before pre-commit
to ensure correct detection since prek hooks may contain 'pre-commit')
- Handle prek in checkManagerBdIntegration using same config parser
- Update init_git_hooks.go to recognize prek-installed hooks
- Rename isPreCommit field to isPreCommitFramework for clarity
- Use regex pattern matching all pre-commit/prek signatures consistently
- Add test cases for prek run and prek hook-impl signatures
Co-authored-by: Ismar Iljazovic <ismar@gmail.com>
macOS allows file owners to write to their own read-only (0444) files,
so TestSetupGlobalGitIgnore_ReadOnly cannot exercise the "Unable to write"
code path on this platform.
Skip both test cases on darwin with an explanatory message.
The test was failing because it called 'git config --global core.excludesfile'
which returned the real user's gitignore path instead of using the test's
temp directory.
Fix: Set GIT_CONFIG_GLOBAL env var to an empty temp config file, ensuring
the test uses the temp directory's .config/git/ignore path as intended.
Also extracted the isolation logic into a reusable setupIsolatedGitConfig helper.
Co-authored-by: Ismar Iljazovic <ismar@gmail.com>
Fixes#1041
The pre-push hook was not passing arguments to chained hooks,
causing them to fail. This change:
1. Changes runPrePushHook() to accept args []string parameter
2. Passes args to runChainedHook() instead of nil
3. Updates call site to pass hookArgs
4. Renames local 'args' to 'statusArgs' to avoid variable shadowing
Co-authored-by: Ismar Iljazovic <ismar@gmail.com>
The export command was incorrectly listed in readOnlyCommands, causing the SQLite database to be opened in read-only mode. This prevented export from clearing dirty issues and updating the JSONL file hash.
Problem:
When a JSONL file hash mismatch was detected (e.g., after git operations
that modify the JSONL without updating export_hashes), the autoflush
system would trigger a full re-export. During this re-export, all issue
comments were silently dropped from the exported JSONL file.
Steps to reproduce:
1. Have a beads database with issues containing comments
2. Create a situation where JSONL hash doesn't match stored hash
(e.g., clone a repo, or manual JSONL edits)
3. Run any bd command that triggers autoflush (e.g., `bd create foo`)
4. Observe warning: "JSONL file hash mismatch detected"
5. Check .beads/issues.jsonl - all comments are now missing
Root cause:
Two different export code paths existed:
- exportToJSONLWithStore (daemon_sync.go) - correctly populated comments
- fetchAndMergeIssues (autoflush.go) - only fetched dependencies, NOT comments
When hash mismatch triggered a full re-export via the autoflush path,
fetchAndMergeIssues was called but it never populated issue.Comments,
resulting in all comments being lost.
Fix:
Add GetIssueComments call in fetchAndMergeIssues to populate comments
for each issue before export, matching the behavior of exportToJSONLWithStore.
Note: Labels were not affected because GetIssue() already populates them
internally. Comments are stored in a separate table and require explicit
fetching via GetIssueComments().
Add getCurrentBranchOrHEAD() which returns "HEAD" when in detached HEAD
state instead of failing. This fixes bd sync --status for jj/jujutsu users.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When sync-branch is configured, check that branch's upstream instead of
current HEAD's upstream. This fixes --auto-push with jj/jujutsu which
always operates in detached HEAD mode.
Adds gitBranchHasUpstream(branch) to check specific branch's upstream
tracking, independent of current HEAD state.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The --ready flag filters to status=open, excluding hooked, in_progress,
blocked, and deferred issues. This makes it easy to see work that can
actually be picked up.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
GetIssue returns (nil, nil) when an issue is not found, but the code
assumed a non-nil issue when err was nil. Added nil checks before
accessing issue fields.
Fixes crash when running `bd mol wisp create` with nonexistent proto.
Closes: gt-2uzn2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(create): Use prefix from routes.jsonl when creating issues with --rig
When using `bd create --rig <name>`, the prefix from routes.jsonl was
being discarded. This caused issues to be created with the target
database's default prefix instead of the route's prefix.
This is particularly problematic when using the redirect mechanism to
share a single database across multiple rigs - the redirect correctly
routes to the shared database, but the prefix was not being applied.
The fix:
1. Capture the prefix from routing.ResolveBeadsDirForRig()
2. Temporarily override the target database's issue_prefix config
3. Restore the original prefix after issue creation
Example scenario that now works:
- routes.jsonl: {"prefix": "aops-", "path": "src/academicOps"}
- src/academicOps/.beads/redirect points to ~/writing/.beads
- `bd create --rig aops "Test"` now creates aops-xxx instead of ns-xxx
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(create): pass prefix via struct field instead of mutating config
The previous approach temporarily mutated the database's issue_prefix
config during cross-rig issue creation, then restored it afterward.
This was fragile in multi-user scenarios where concurrent operations
could see the wrong prefix.
New approach:
- Add PrefixOverride field to types.Issue
- CreateIssue checks PrefixOverride first, uses it if set
- createInRig sets issue.PrefixOverride instead of mutating config
This passes state as a parameter rather than mutating shared state,
making it safe for concurrent multi-user access.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
The duplicate merge target selection now considers structural relationships:
1. Dependent count (children, blocked-by) - highest priority
2. Text reference count - secondary
3. Lexicographically smallest ID - tiebreaker
This fixes the bug where `bd duplicates --auto-merge` would suggest closing
an epic with 17 children instead of the empty shell duplicate.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
sync_base.jsonl is an internal sync mechanism file used for 3-way merge,
not a competing issue database. The doctor check now correctly ignores it.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Apply ui.RenderMarkdown() to comment text in both bd show and
bd comments commands. This enables syntax highlighting, code
blocks, and other Markdown formatting in comments.
Add check to prevent 'bd init' from running inside a git worktree.
Worktrees should share the .beads database from the main repository,
not create their own.
The error message guides users to:
1. Run 'bd init' from the main repository
2. Use 'bd worktree create' to create worktrees with proper
redirects
This prevents the confusing behavior where init would create files
in unexpected locations or fail with "pathspec '.beads/.gitignore' did
not match any files" errors.
According to docs/WORKTREES.md, the proper workflow is:
- Initialize beads once in the main repository
- Use 'bd worktree create' to create worktrees with redirect files
- All worktrees share the single .beads/ database via redirects
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Two code paths bypassed syncbranch.ValidateSyncBranchName(), allowing
main/master to be set as sync.branch and causing worktree conflicts.
Now both use syncbranch.Set() for proper validation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- multirepo.go: discoverChildTypes now returns []string instead of
([]string, error) since error was always nil
- socket_path.go: tmpDir changed from function to const since it
always returned "/tmp" regardless of platform
Fixes CI lint failures caused by unparam linter detecting unused
error returns and constant function results.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/dave
Rig: beads
Role: crew
fix(daemon): socket path shortening for long workspace paths
Fixes GH#1001 where long workspace paths (e.g., pytest temp directories) caused
socket path mismatches. The daemon now uses rpc.ShortSocketPath() consistently
with the client.
Changes:
- daemon.go: Use rpc.ShortSocketPath() + EnsureSocketDir() for daemon socket
- daemon_config.go: Update getSocketPathForPID() to use rpc.ShortSocketPath()
- Added tests for long path handling and client-daemon socket path agreement
Co-Authored-By: Eugene Sukhodolin <sukhodolin@users.noreply.github.com>
Tests were failing because beads.FindDatabasePath() follows the
project's .beads/redirect file, causing tests to find unexpected
databases. Fixed by:
- Setting BEADS_DIR in tests that need isolation from git repo detection
- Clearing BEADS_DIR in TestMain to prevent global contamination
- Updating migration test schema to include owner column
This ensures tests work correctly in crew directories that have
redirect files pointing to shared .beads directories.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/dave
Rig: beads
Role: crew
When a repo has a .beads/redirect file pointing to a shared beads
directory, restoreBeadsDirFromBranch would fail because it runs
git checkout from the local repo but with a path outside that repo.
Skip the restore when the beads directory is redirected since the
beads dir is managed by a different repo anyway.
Fixes: bd-lmqhe
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for gitHasBeadsChanges and gitHasUncommittedBeadsChanges
functions when .beads directory is redirected to another repo:
- Test non-redirected case (baseline functionality)
- Test redirected case with no changes (clean target repo)
- Test redirected case with changes (modified file in target)
These tests cover the redirect detection logic added in a61cbde6
that uses `git -C <targetRepoDir>` when beadsDir is redirected.
Closes: bd-hxcf
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add three new bd doctor checks for redirect configuration health:
1. CheckRedirectTargetValid - Verifies redirect target exists and
contains a valid beads database
2. CheckRedirectTargetSyncWorktree - Verifies redirect target has
beads-sync worktree when using sync-branch mode
3. CheckNoVestigialSyncWorktrees - Detects unused .beads-sync
worktrees in redirected repos that waste space
These checks help diagnose redirect configuration issues in
multi-clone setups like Gas Town polecats and crew workspaces.
Closes bd-b88x3
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 'owner' field to Issue struct for tracking the human responsible
for the issue, distinct from 'created_by' which tracks the executor.
Owner is populated from git author email (GIT_AUTHOR_EMAIL or git
config user.email), per Decision 008 for CV accumulation.
Changes:
- Add Owner field to types.Issue with omitempty JSON tag
- Include Owner in content hash computation
- Add owner column migration (036_owner_column.go)
- Update all SQL queries to include owner field
- Add getOwner() helper using git author email fallback chain
- Populate owner in bd create command
- Add owner to RPC CreateArgs protocol
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/dave
Rig: beads
Role: crew
Follow-up fixes to PR #1006:
- Silence deprecation warnings when --json flag is set (agent ergonomics)
- Remove unused outputStatusJSON() function
- Remove unused encoding/json import from daemon_status.go
Agents parsing JSON output dont need deprecation warnings cluttering stderr.
The subcommand syntax (bd daemon start) remains the documented path forward.
See bd-ntl3b for deduplication work, bd-kpa7c for type consolidation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Merging with plan to address in follow-up commits:
- Deduplicate daemon_start.go validation logic (call startDaemon())
- Silence deprecation warnings in --json mode for agent ergonomics
- Consolidate DaemonStatusReport with DaemonHealthReport
- Remove unused outputStatusJSON()
- Add tests for new subcommands
Same fix as PR #991 for FindBeadsDir() - the loop condition
dir != "/" && dir != "." doesn't handle Windows drive roots.
On Windows, filepath.Dir("C:\\") returns "C:\\", not "/" or ".".
Changed both functions to check parent == dir to detect filesystem root,
which works correctly on both Unix and Windows.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Insert git config user.name in fallback chain before final $USER default
- Consolidate duplicate actor resolution logic into single function
- Add BEADS_ACTOR as env var alias for MCP compatibility
- Add tests for actor resolution priority
- Update CONFIG.md with Actor Identity Resolution section
The new fallback order is:
--actor flag > BD_ACTOR > BEADS_ACTOR > git user.name > $USER > "unknown"
Co-authored-by: Ohffs <ohffsnotnow@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
On Unix systems, socket paths are limited to 104 chars (macOS) or 108 chars
(Linux). Deep workspace paths like /Volumes/External Drive/Dropbox/...
would exceed this limit and cause daemon startup failures.
This fix:
- Adds ShortSocketPath() which computes /tmp/beads-{hash}/bd.sock for
paths that would exceed the limit
- Keeps backward compatibility: short paths still use .beads/bd.sock
- Updates daemon discovery to check both locations
- Uses SHA256 hash of canonical workspace path for unique directories
Closes GH#1001
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
warnIfCyclesExist was called with nil storage when using daemon mode.
Add nil check to skip cycle warning in daemon mode (daemon handles it).
Fixes#998
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds ability to burn multiple molecules in a single command:
bd mol burn bd-a1 bd-b2 bd-c3
Changes:
- Accept multiple molecule IDs as arguments
- Add BatchBurnResult struct for aggregated results
- Implement burnMultipleMolecules for batch efficiency
- Wisps deleted in single batch call
- Maintains backward compatibility for single ID
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When removing all hooks from an event, the key was being set to null
instead of being deleted. Claude Code expects arrays, not null values,
causing startup failures with 'Expected array, but received null'.
Changes:
- removeHookCommand now deletes the event key when no hooks remain
- installClaude cleans up any existing null values from buggy removal
- Added tests for null value prevention and cleanup
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>