5526 Commits

Author SHA1 Message Date
Johannes Schickling
e36e2f6679 feat(nix): add shell completion outputs to flake (#1210)
Add fish, bash, and zsh completion packages to the Nix flake.
Completions are generated at build time using `bd completion <shell>`.

Usage:
  nix build .#fish-completions
  nix build .#bash-completions
  nix build .#zsh-completions

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 14:05:44 -08:00
Eugene Sukhodolin
4ccdd7a2df fix(routing): close original store before replacing with target store (#1215)
* fix(routing): close original store before replacing with target store

Fix "database is closed" error during auto-flush when contributor routing
redirects issue creation to a different repository (e.g., ~/.beads-planning).

When a user is detected as a contributor (based on git remote URL pattern),
the default configuration routes new issues to ~/.beads-planning instead of
the current repository. This routing caused auto-flush to fail with:

  Warning: auto-flush failed: failed to get stored JSONL hash:
  failed to get jsonl_file_hash: sql: database is closed

In create.go, when switching to the planning repo:
1. targetStore was opened for the planning database
2. A defer was set to close targetStore at function end
3. store = targetStore replaced the global store pointer
4. Issue was created successfully
5. Command Run ended → defer closed targetStore
6. PersistentPostRun tried to flush using the global store → error!

The bug: the defer closed targetStore, but the global `store` variable
pointed to the same object. When PersistentPostRun called flushManager.Shutdown(),
it tried to use the already-closed store for the flush operation.

- Remove the defer that prematurely closed targetStore
- Explicitly close the ORIGINAL store before replacing it (it won't be used)
- Let PersistentPostRun close whatever store is current at exit time

This ensures proper store lifecycle:
- Original store: closed when replaced (no longer needed)
- Target store: closed by PersistentPostRun after flush completes

1. Have a git repo with a remote URL that doesn't match maintainer patterns
   (e.g., github-a:org/repo.git instead of git@github.com:org/repo.git)
2. Have ~/.beads-planning directory with beads initialized
3. Run: cd /path/to/repo && bd create "Test issue"
4. Observe: Issue created successfully, but followed by:
   Warning: auto-flush failed: ... sql: database is closed

Added debug prints to SQLiteStorage.Close() and GetJSONLFileHash() which
revealed two different databases were involved:
- /path/to/repo/.beads/beads.db (closed first, unexpectedly)
- ~/.beads-planning/.beads/beads.db (used for flush after being closed)

* fix(test): resolve race condition in TestAutoFlushOnExit

Not directly related to the previous routing fix, but exposed by CI timing.

Root cause: The test had a latent race condition between two channel operations:
1. markDirtyAndScheduleFlush() sends event to markDirtyCh
2. Shutdown() sends request to shutdownCh

Without any delay, Go's scheduler might process the shutdown event first.
Since isDirty was still false (markDirty event not yet processed), the
FlushManager would skip the flush entirely, causing the test to fail with
"Expected JSONL file to be created on exit".

The race was always present but only manifested in CI environments with
different timing characteristics (CPU contention, virtualization, scheduler
behavior).

Fix: Add a 10ms sleep after markDirtyAndScheduleFlush() to allow the
FlushManager's background goroutine to process the event before shutdown.
This mimics real-world behavior where there's always some time between
CRUD operations and process exit.
2026-01-20 14:05:40 -08:00
Peter Chanthamynavong
228d78c180 fix(routing): disable auto-routing by default (#1177)
Change routing.mode default from "auto" to "" (empty/disabled).

This fixes GH#1165 where fresh `bd init --prefix X` followed by
`bd create` would unexpectedly route to ~/.beads-planning and fail
with "database not initialized: issue_prefix config is missing".

Auto-routing now requires explicit opt-in via:
- `bd init --contributor` flag, OR
- `bd config set routing.mode auto`

Includes test verifying the default and doc updates clarifying
the opt-in requirement.
2026-01-20 14:05:07 -08:00
Perttu Landström
9ed74ca233 fix(types): show custom types when daemon is running (#1216)
The `bd types` command only checked `if store != nil` to fetch custom
types. In daemon mode, `store` is nil (daemonClient handles RPC instead),
so custom types were never displayed even when configured.

This caused a mismatch where `bd config get types.custom` showed the
correct values but `bd types` showed none.

Fix by calling ensureDirectMode() at the start of the command, matching
the pattern used by `bd config get`. This falls back from daemon mode
to direct storage access when needed.

Co-authored-by: Perttulands <perttu.landstrom@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 14:05:03 -08:00
Wilhelm Uschtrin
f7134954b9 fix(worktree): correct redirect path computation in bd worktree create (#1217)
Computes the relative path from the worktree root instead of the .beads directory. This ensures that FollowRedirect resolves paths correctly relative to the parent of .beads.
2026-01-20 14:04:51 -08:00
coffeegoddd☕️✨
4e386c8adf /cmd/bd/doctor/integrity.go: fix unable to query issues bug with dolt backend 2026-01-20 14:00:37 -08:00
coffeegoddd☕️✨
a097fc546b /{cmd,internal}: fix lint issues 2026-01-20 13:46:57 -08:00
coffeegoddd☕️✨
422bc838ed /{website,internal,docs,cmd}: integration tests and more split backend fixes 2026-01-20 13:39:04 -08:00
coffeegoddd☕️✨
ba432847e0 /{cmd,internal}: get dolt backend init working and allow issue creation 2026-01-20 12:24:14 -08:00
collins
521239cfdc refactor(config): improve sync config with warnings toggle and dedup
Code review improvements to internal/config/sync.go:

1. Warning suppression toggle
   - Add ConfigWarnings bool to enable/disable warnings
   - Add ConfigWarningWriter io.Writer for testable output

2. Consolidate sync mode constants
   - cmd/bd/sync_mode.go now imports from internal/config
   - Single source of truth for mode values
   - Uses shared IsValidSyncMode() for validation

3. Fix empty sovereignty semantics
   - Empty now returns SovereigntyNone (no restriction)
   - Only non-empty invalid values fall back to T1 with warning

4. Export validation helpers
   - IsValidSyncMode(), IsValidConflictStrategy(), IsValidSovereignty()
   - ValidSyncModes(), ValidConflictStrategies(), ValidSovereigntyTiers()
   - String() methods on all typed values

5. Logger interface
   - ConfigWarningWriter allows custom logging destinations
   - Tests can capture warnings without os.Stderr manipulation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 11:49:44 -08:00
jane
80cd1f35c0 fix(sync): address code review issues in manual conflict resolution
Fixes from code review:
- Fix duplicate check in merge logic (use else clause)
- Handle io.EOF gracefully (treat as quit)
- Add quit (q) option to abort resolution early
- Add accept-all (a) option to auto-merge remaining conflicts
- Fix skipped conflicts to keep local version (not auto-merge)
- Handle json.MarshalIndent errors properly
- Fix truncateText to use rune count for UTF-8 safety
- Update help text with new options
- Add UTF-8 and emoji test cases

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 11:44:24 -08:00
lydia
5d68e6b61a refactor(hook): simplify export state logic, add tests
Code review fixes:
- Renamed misleading exportIncrementalDolt to hasDoltChanges (now just checks for changes)
- Extracted stageJSONLFiles() helper to eliminate duplication
- Extracted runJSONLExport() helper
- Removed unused Actor field from ExportState (add back when implementing filtering)
- Consolidated hookPreCommitDoltFallback into doExportAndSaveState
- Added updateExportStateCommit for no-change fast path

Net reduction: 44 lines (-116/+72)

Added tests for:
- getWorktreeHash
- Export state paths
- Save/load export state
- JSON serialization with omitempty
- updateExportStateCommit
- computeJSONLHashForHook

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 11:44:08 -08:00
lizzy
38af99f300 fix(config): improve cross-platform path handling and regex efficiency
Code review fixes for bd config validate:
- Use filepath.Join instead of string concatenation for paths
- Use filepath.Dir instead of strings.LastIndex for parent directory
- Move gitSSHRemotePattern regex to package-level var (compile once)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 11:42:09 -08:00
collins
0335067e34 fix(config): restore sync.go with warning implementations
Commit 356ab92b deleted internal/config/sync.go while adding
cmd/bd/sync_mode.go, but config.go still references the types and
functions from sync.go, causing build failures.

These serve different purposes:
- internal/config/sync.go: viper-based (config.yaml), has warnings
- cmd/bd/sync_mode.go: storage-based (database), no warnings

Both should coexist. This restores sync.go and sync_test.go from
e82e15a8, and fixes type conversion in sync.go:805.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 11:18:14 -08:00
Bo
6a4a6170e7 fix(sync): add --sparse flag to git add for worktree compatibility (#1143)
Fixes #1076.

When git worktrees have sparse-checkout enabled, git add operations can
fail with 'outside of sparse-checkout cone' errors. Adding the --sparse
flag allows git to stage files outside the sparse-checkout cone.

Changes:
- Add --sparse flag to git add in daemon_sync_branch.go (line 165)
- Add --sparse flag to git add in migrate_sync.go (line 343)
- Add --sparse flag to git add in sync_branch.go (line 308)
- Add --sparse flag to git add in worktree.go (line 732)

All changes include comments referencing #1076 for traceability.
2026-01-19 10:21:12 -08:00
Steven Syrek
82426423fe fix(sqlite): Add missing rows.Err() checks after row iteration (#1141)
The scanIssues and scanIssuesWithDependencyType helper functions were
not checking rows.Err() after iterating through query results. This
could cause errors during iteration (connection drops, context
cancellation, etc.) to be silently ignored.

Per Go database/sql best practices, rows.Err() should always be checked
after a rows.Next() loop completes to catch any errors that occurred
during iteration.

Co-authored-by: Steven Syrek <steven.syrek@deepl.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:12:26 -08:00
Roland Tritsch
34b741d2e0 Fix doctor DB-JSONL sync check to exclude ephemeral wisps (#1144)
The DB-JSONL Sync check was showing a false positive warning when wisps
(ephemeral issues) existed in the database. Wisps are intentionally
excluded from JSONL exports, so they shouldn't be counted when comparing
database and JSONL issue counts.

Changes:
- Updated CheckDatabaseJSONLSync to exclude ephemeral issues from count
  using 'WHERE ephemeral = 0 OR ephemeral IS NULL'
- Added 'ephemeral' column to test database schema
- Added test case to verify ephemeral issues are excluded from count
- Updated TestCheckDatabaseJSONLSync_MoleculePrefix to include ephemeral column

This prevents false warnings like 'database has 92 issues, JSONL has 30'
when the difference is entirely due to wisps that should not be exported.

Co-authored-by: Roland Tritsch <roland@ailtir.com>
2026-01-19 10:11:23 -08:00
Bobby Johnson
aa3b318939 Fix issue-prefix config fallback to config.yaml (GH#1145) (#1146)
The config.yaml file uses "issue-prefix" (with hyphen) but this setting
was only read during bd init. After initialization, all code read from
the database's "issue_prefix" key, so subsequent changes to config.yaml
were silently ignored.

This fix adds a fallback to config.yaml's "issue-prefix" in the key
locations where the prefix is retrieved from the database:

1. autoflush.go: Auto-import now checks config.yaml before falling back
   to auto-detection from JSONL or directory name

2. autoflush.go: filterByMultiRepoPrefix now checks config.yaml as fallback

3. create.go: Direct mode prefix validation now checks config.yaml as fallback

Priority order is preserved:
1. Database issue_prefix (if set)
2. Config.yaml issue-prefix (new fallback)
3. Auto-detection from JSONL/directory (existing fallback)

Fixes #1145

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:11:19 -08:00
Damir Vandic
b09aee377f fix: set git index flags on init when sync-branch is configured (#1158)
Fresh clones with sync-branch configured in .beads/config.yaml would show
.beads/issues.jsonl as modified in git status because the git index flags
(skip-worktree, assume-unchanged) are local-only and don't transfer via clone.

This fix ensures bd init sets these flags in two scenarios:
1. `bd init --branch <name>` - when user explicitly sets sync branch
2. `bd init` on cloned repo - when sync-branch already exists in config.yaml

Added SetSyncBranchGitignoreFlags() helper and two tests for coverage.
2026-01-19 10:11:16 -08:00
Subhrajit Makur
065ca3d6af fix(config): remove duplicate declarations and fix test failures (#1160)
* fix(config): remove duplicate declarations between config.go and sync.go

Commit e82e15a8 created sync.go with typed constants (SyncMode,
ConflictStrategy, Sovereignty) but didn't remove the original untyped
constants from config.go that were added in 16f8c3d3. This caused
redeclaration errors preventing the project from building.

Changes:
- Remove duplicate SyncMode, ConflictStrategy, Sovereignty constants
  from config.go (keep typed versions in sync.go)
- Remove duplicate GetSyncMode, GetConflictStrategy, GetSovereignty
  functions from config.go (keep sync.go versions with warnings)
- Update SyncConfig, ConflictConfig, FederationConfig structs to use
  typed fields instead of string
- Add IsSyncModeValid, IsConflictStrategyValid, IsSovereigntyValid
  wrapper functions that use sync.go's validation maps
- Update cmd/bd/sync.go to use typed ConflictStrategy parameter
- Update tests to work with typed constants

* fix(dolt): handle Merge return values in concurrent test

* fix(test): add --repo flag to show_test.go to bypass auto-routing

The tests were failing because the create command was routing issues
to ~/.beads-planning instead of the test's temp directory. Adding
--repo . overrides auto-routing and creates issues in the test dir.
2026-01-19 10:11:14 -08:00
Peter Chanthamynavong
2cbf3a5497 fix: Validate sync-branch at config-time and runtime (closes #1166) (#1168)
* fix(config): validate sync-branch at config time

Add sync-branch validation to validateYamlConfigValue() to reject
main/master at config time, preventing the validation bypass in GH#1166.

- Add case for sync-branch and sync.branch keys
- Inline validation logic to avoid import cycle (config <-> syncbranch)
- Add unit tests for rejection (main/master) and acceptance (valid names)

Part of: #1166

* fix(sync): add runtime guard for sync-branch == current-branch

Add dynamic runtime check before worktree operations to catch cases
where sync-branch matches the current branch. This provides defense
in depth for manual YAML edits, pre-fix configs, or non-main/master
branch names (trunk, develop, production, etc.).

- Check IsSyncBranchSameAsCurrent() after hasSyncBranchConfig is set
- Position check BEFORE worktree entry (CWD changes inside worktree)
- Add integration test TestSync_FailsWhenOnSyncBranch

Part of: #1166

* docs: note main/master restriction in sync-branch FAQ

Clarifies that git worktrees cannot checkout the same branch in
multiple locations, so main/master cannot be used as sync branch.
2026-01-19 10:11:06 -08:00
Daniel Sauer
4fffdb7fae fix(sqlite): add missing agent fields to scanIssues and related queries (#1176)
The scanIssues() function and multiple SQL queries were not selecting or
scanning agent-related fields (hook_bead, role_bead, agent_state, last_activity,
role_type, rig, mol_type) and time-based scheduling fields (due_at, defer_until).

This caused bd list --json to return null for last_activity even when the
database contained valid timestamps, preventing proper agent health monitoring.

Updated files:
- dependencies.go: scanIssues() variable declarations, scan calls, assignments
- queries.go: SearchIssues query
- labels.go: GetIssuesByLabel query
- ready.go: GetReadyWork and GetNewlyUnblockedByClose queries
- transaction.go: GetIssue query, SearchIssues query, scanIssueRow()

Fixes steveyegge/beads#1175
2026-01-19 10:11:03 -08:00
aleiby
f4ee7ee73b fix(routing): default to Maintainer when no git remote exists (#1185)
When no git remote is configured, DetectUserRole() now defaults to
Maintainer instead of Contributor. This fixes issue routing for:

1. New personal projects (no remote configured yet)
2. Intentionally local-only repositories

Previously, issues would silently route to ~/.beads-planning instead
of the local .beads/ directory.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:11:00 -08:00
Peter Chanthamynavong
460d2bf113 fix(doctor): improve diagnostic fix message output (#1187)
Problem:
- Diagnostic fix messages were restricted to single lines
- Inconsistent file path formatting in database sync issues
- Outdated cleanup command suggested in maintenance fixes

Solution:
- Implement multiline support for doctor fix messages
- Standardize issue file paths across database diagnostics
- Update maintenance fix instructions to use 'bd admin cleanup'

Impact:
- Clearer and more accurate recovery instructions for users
- Better readability of complex diagnostic output

Fixes: GH#1170, GH#1171, GH#1172
2026-01-19 10:10:57 -08:00
Steven Syrek
73d4d5ecb2 fix(create): validate explicit IDs against allowed_prefixes using starts-with matching (#1137)
When creating issues with explicit IDs like `bd create --id hq-cv-test`,
the prefix validation was failing even when `hq-cv` was in `allowed_prefixes`.

Root cause: `ExtractIssuePrefix("hq-cv-test")` returns `"hq"` (not `"hq-cv"`)
because "test" looks like an English word, causing the algorithm to fall back
to the first hyphen. The validation then checked if `"hq"` was in the allowed
list containing `"hq-cv"` - which failed.

The fix adds `ValidateIDPrefixAllowed()` which validates the full ID using
"starts with" matching (the same approach the importer uses successfully).
This correctly handles multi-hyphen prefixes like `hq-cv-` regardless of
what the suffix looks like.

Fixes #1135

Co-authored-by: Steven Syrek <steven.syrek@deepl.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:08:56 -08:00
Steven Syrek
8e40018701 fix(daemon): Fix double-unlock risk in debouncer on action panic (#1140)
The debouncer's timer callback used a pattern that could cause a
double-unlock panic if the action function panicked:

  d.mu.Lock()
  defer d.mu.Unlock()
  if d.seq == currentSeq {
      d.mu.Unlock()  // Manual unlock
      d.action()     // If this panics...
      d.mu.Lock()    // ...this never runs
  }                  // ...but defer still tries to unlock

Fix: Remove the defer and manually manage lock state. Now if the
action panics, the lock is already released, preventing a
double-unlock panic that would mask the original panic.

Co-authored-by: Steven Syrek <steven.syrek@deepl.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:08:53 -08:00
Steven Syrek
ba832c4f37 fix(daemon): Eliminate race condition in sync state load-modify-save (#1139)
The RecordSyncFailure and ResetBackoffOnDaemonStart functions had a
TOCTOU (time-of-check-time-of-use) race condition. They called
LoadSyncState (which locks, reads, unlocks) then modified the state,
then called SaveSyncState (which locks, writes, unlocks).

Between LoadSyncState returning and SaveSyncState being called, another
goroutine could load the old state, modify it, and save it - then this
goroutine's save would overwrite those changes.

Fix: Create internal unlocked helper functions (loadSyncStateUnlocked,
saveSyncStateUnlocked) and have RecordSyncFailure and
ResetBackoffOnDaemonStart hold the lock for the entire load-modify-save
operation.

Co-authored-by: Steven Syrek <steven.syrek@deepl.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:08:41 -08:00
beads/crew/emma
4bc0b698a8 fix(staleness): skip auto-import when store is read-only (GH#1089)
Track whether the store was actually opened read-only (vs just requested)
since the fallback logic may change opts.ReadOnly. Use this to skip
auto-import in staleness checks - importing would fail anyway if the
store is read-only.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 18:25:50 -08:00
beads/crew/emma
c8ffcce621 fix(validation): accept prefix when it's a prefix of allowed entry (GH#1135)
When ExtractIssuePrefix returns "hq" from an ID like "hq-cv-test"
(because "test" is word-like), but "hq-cv" is in allowedPrefixes,
we should accept "hq" since it's clearly intended to be part of "hq-cv".

This handles cases where the prefix extraction algorithm yields a
shorter prefix than the user intended, but the full intended prefix
is in the allowed list.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 18:25:33 -08:00
beads/crew/emma
356ab92b78 feat(sync): wire up sync.mode config to change sync behavior
Implements hq-ew1mbr.27: The sync.mode config now actually changes how
bd sync operates:

- git-portable (default): JSONL exported on push, imported on pull
- realtime: JSONL exported on every change (placeholder for daemon hook)
- dolt-native: Uses Dolt Push/Pull, skips JSONL workflow entirely
- belt-and-suspenders: Both Dolt remotes AND JSONL for redundancy

Changes:
- Add sync_mode.go with mode constants, Get/Set functions, and helpers
- Update bd sync --status to show actual mode from config
- Add --set-mode flag to bd sync for configuring the mode
- Modify doExportSync to respect mode (Dolt push for dolt-native)
- Modify doPullFirstSync to use Dolt pull for dolt-native mode
- Add RemoteStorage interface for Push/Pull operations
- Add comprehensive tests for sync mode functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 10:36:20 -08:00
jane
c99bd00ca7 feat(sync): implement interactive conflict resolution for manual strategy
Adds interactive manual conflict resolution for `bd sync --resolve --manual`:
- Shows field-by-field diff between local and remote versions
- Prompts user to choose: local (l), remote (r), merge (m), skip (s)
- Supports viewing full JSON diff with 'd' option
- Skipped conflicts remain in conflict state for later resolution
- Integrates with existing 3-way merge infrastructure

New files:
- cmd/bd/sync_manual.go: Interactive conflict resolution logic
- cmd/bd/sync_manual_test.go: Unit tests for helper functions

Closes hq-ew1mbr.28

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 14:02:47 -08:00
lizzy
9ddd7a2620 feat(config): add validate command for sync config
Add `bd config validate` command to validate sync-related configuration:

- sync.mode: validates values (local, git-branch, external)
- conflict.strategy: validates values (lww, manual, ours, theirs)
- federation.sovereignty: validates values (none, isolated, federated)
- federation.remote: ensures set when sync.mode is 'external'
- Remote URL format: validates dolthub://, gs://, s3://, file://, etc.

Also validates existing config via doctor.CheckConfigValues (sync.branch,
routing.mode, etc.)

Closes: hq-ew1mbr.29

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 14:02:28 -08:00
collins
e82e15a8c2 feat(config): add GetSyncMode, GetConflictStrategy, GetSovereignty with warnings
Add config accessor functions for sync mode, conflict strategy, and
federation sovereignty tier settings. These functions:

- Read from config.yaml via viper
- Validate against known valid values
- Return sensible defaults when not set
- Log warnings to stderr when invalid values are configured (instead
  of silently falling back to defaults)

Closes: hq-ew1mbr.26

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 13:58:00 -08:00
darcy
16f8c3d3ae feat(sync): add sync mode configuration (hq-ew1mbr.3)
Add configurable sync modes for Dolt storage integration:

Sync modes:
- git-portable (default): Export JSONL on push, import on pull
- realtime: Export JSONL on every database change
- dolt-native: Use Dolt remotes directly (no JSONL)
- belt-and-suspenders: Both Dolt remote AND JSONL backup

Configuration options in .beads/config.yaml:
- sync.mode: Select sync mode
- sync.export_on: push (default) or change
- sync.import_on: pull (default) or change
- conflict.strategy: newest (default), ours, theirs, manual
- federation.remote: Dolt remote URL for dolt-native mode
- federation.sovereignty: T1-T4 data sovereignty tier

The sync command now displays configuration in `bd sync --status`
and uses configured conflict strategy for resolution.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 10:52:29 -08:00
lydia
ba0e754dc8 feat(hook): implement per-worktree export state tracking (Design Part 21)
Updates ExportState to track Dolt commits (not git commits) for accurate
change detection. This prevents polecats sharing a Dolt DB from exporting
each others uncommitted work.

Changes:
- ExportState now tracks Dolt commit hash via VersionedStorage.GetCurrentCommit()
- Added WorktreeHash and Actor fields for debugging and future filtering
- hookPreCommitDolt uses Diff() to detect changes since last export
- Added hookPreCommitDoltFallback for graceful degradation
- Added exportIncrementalDolt and exportFullDolt helper functions
- Removed unused exportToJSONLFromStore function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 10:46:44 -08:00
dennis
1f59119144 fix(sync): use town-level routes for prefix validation
Follow-up to 828fc11b addressing code review feedback:

1. Added LoadTownRoutes() - exported function that walks up to find
   town-level routes.jsonl (e.g., ~/gt/.beads/routes.jsonl)

2. Updated buildAllowedPrefixSet to use LoadTownRoutes instead of
   LoadRoutes, so it finds routes even when importing from a rig's
   local beads directory

3. Added unit tests for buildAllowedPrefixSet covering:
   - Primary prefix inclusion
   - allowed_prefixes config parsing
   - Routes from routes.jsonl
   - Missing routes.jsonl handling
   - Empty beadsDir handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:51:46 -08:00
beads/crew/emma
4f0f5744a6 feat(types): remove Gas Town types from core built-in types
Core beads built-in types now only include work types:
- bug, feature, task, epic, chore

Gas Town types (molecule, gate, convoy, merge-request, slot, agent,
role, rig, event, message) are now "well-known custom types":
- Constants still exist for code convenience
- Require types.custom configuration for validation
- bd types command shows core types and configured custom types

Changes:
- types.go: Separate core work types from well-known custom types
- IsValid(): Only accepts core work types
- bd types: Updated to show core types and custom types from config
- memory.go: Use ValidateWithCustom for custom type support
- multirepo.go: Only check core types as built-in
- Updated all tests to configure custom types

This allows Gas Town (and other projects) to define their own types
via config while keeping beads core focused on work tracking.

Closes: bd-find4

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 05:07:11 -08:00
emma
88a6438c80 chore(release): bump version to 0.48.0
Release highlights:
- VersionedStorage interface for pluggable backends
- bd types command and enhancement type alias
- bd close -m flag (git commit convention)
- RepoContext API for centralized git operations
- Dolt backend improvements (WIP)
- Many bug fixes for doctor, sync, hooks, worktrees

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 04:36:41 -08:00
mayor
6af5cae1d1 chore: ignore metadata.json in .beads 2026-01-17 04:22:35 -08:00
emma
10bdc94294 feat(close): add -m as alias for --reason
Adds -m/--message as a hidden alias for --reason, following the git
commit convention where -m specifies a message. This makes the command
more intuitive for users familiar with git workflows.

Usage: bd close <id> -m "reason for closing"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 03:48:51 -08:00
dennis
828fc11b57 fix(sync): allow routed prefixes in import validation
When importing issues in a multi-rig setup (Gas Town), the prefix
validation was failing for issues with prefixes from other rigs
(e.g., hq-* prefixes from town-level beads).

This fix extends buildAllowedPrefixSet to also load prefixes from
routes.jsonl, allowing issues from any routed rig to pass validation.

Fixes: gt-2maz79

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 03:45:02 -08:00
lydia
feed888b57 fix(duplicates): use combined weight (dependents + dependencies) for merge target selection (GH#1022)
When choosing which duplicate to keep, the merge target now considers
both dependentCount (children/blocked-by) AND dependsOnCount (dependencies).
This ensures issues with ANY structural connections are preferred over
empty shells, rather than only considering children.

- Updated chooseMergeTarget to calculate weight = dependentCount + dependsOnCount
- Updated display output to show weight instead of just dependents
- Updated JSON output to include dependencies and weight fields
- Added tests for dependsOnCount inclusion and combined weight calculation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 03:44:13 -08:00
jane
251ded73be fix(merge-slot): use daemon RPC to get issue_prefix in daemon mode
When running in daemon mode, getMergeSlotID() was not using the daemon
RPC to retrieve the configured issue_prefix, causing it to fall back
to the hardcoded "bd" default. This fix adds the missing daemon path
that uses daemonClient.GetConfig() to properly retrieve the prefix,
matching the pattern used in create.go.

Fixes #1096

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 03:44:02 -08:00
emma
a21a29c283 fix(doctor): remove destructive sync branch health check (GH#1062)
The "Sync Branch Health" check incorrectly warned when the sync branch
differed from main on source files. Since the sync branch only tracks
.beads/ data, source file differences are expected behavior.

The associated --fix action (reset sync branch to main and force push)
was destructive and destroyed legitimate sync branch history.

Removed Check 2 entirely - only Check 1 (detecting divergence from remote
after force-push) remains, which is a legitimate issue.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 03:42:35 -08:00
wickham
9f44884f9d docs(skill): sync CLI reference with v0.47.1 commands
Update SKILL.md prerequisite version from 0.43.0 to 0.47.0.

Add documentation for new commands in CLI_REFERENCE.md:
- Health & Status section: doctor, status, prime
- Quick capture (q) for scripting
- Comments management
- Full search command with sorting and filtering
- Visualization section with graph command
- Blocked issues filter

Fixes #1042

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 03:41:19 -08:00
elinor
f06e742273 fix(daemon): apply git.author config to sync branch commits
The daemon's gitCommitInWorktree function was building git commit
commands directly without checking the git.author and git.no-gpg-sign
config options. This caused daemon sync commits to use the local git
user config instead of the configured beads-specific author.

Now gitCommitInWorktree applies the same config-based author and
signing options that buildCommitArgs uses for regular commits.

Fixes #1051
2026-01-17 03:40:28 -08:00
emma
e60e8f1823 chore: remove placeholder comment in test
Remove `// See: https://github.com/steveyegge/beads/issues/XXX`
placeholder that was left in the regression test from PR #1131.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 02:51:06 -08:00
dave
c220542926 fix(init): use --git-common-dir for worktree exclude paths (GH#1053)
When running bd init --stealth in a worktree, excludes were being
written to .git/worktrees/<name>/info/exclude which has no effect.
Changed setupGitExclude and setupForkExclude to use --git-common-dir
instead of --git-dir so excludes go to the main repo .git/info/exclude.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 02:29:01 -08:00
quartz
94581ab233 feat(storage): add VersionedStorage interface with history/diff/branch operations
Extends Storage interface with Dolt-specific version control capabilities:

- New VersionedStorage interface in storage/versioned.go with:
  - History queries: History(), AsOf(), Diff()
  - Branch operations: Branch(), Merge(), CurrentBranch(), ListBranches()
  - Commit operations: Commit(), GetCurrentCommit()
  - Conflict resolution: GetConflicts(), ResolveConflicts()
  - Helper types: HistoryEntry, DiffEntry, Conflict

- DoltStore implements VersionedStorage interface

- New CLI commands:
  - bd history <id> - Show issue version history
  - bd diff <from> <to> - Show changes between commits/branches
  - bd branch [name] - List or create branches
  - bd vc merge <branch> - Merge branch to current
  - bd vc commit -m <msg> - Create a commit
  - bd vc status - Show current branch/commit

- Added --as-of flag to bd show for time-travel queries

- IsVersioned() helper for graceful SQLite backend detection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 01:55:16 -08:00
onyx
a7cd9136d8 feat(sync): implement bd sync command specification
Changes the default bd sync behavior to export-only per the spec:
- bd sync: Export to JSONL (no staging/committing)
- bd sync --import: Import from JSONL (shorthand for --import-only)
- bd sync --status: Show sync state (mode, last export, pending changes, conflicts)
- bd sync --resolve: Resolve conflicts with strategies (newest/ours/theirs)
- bd sync --force: Force full export/import (skip incremental)
- bd sync --full: Full sync (legacy pull→merge→export→commit→push behavior)

The new --status output format shows:
- Sync mode: git-portable
- Last export: timestamp (commit hash)
- Pending changes: N issues modified since last export
- Import branch: name or none
- Conflicts: count or none

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 01:55:06 -08:00