Commit Graph

1316 Commits

Author SHA1 Message Date
Steve Yegge
b4cb636d92 Switch from hex to Base36 encoding for issue IDs (GH #213)
This change improves information density by using Base36 (0-9, a-z) instead
of hex (0-9, a-f) for hash-based issue IDs. Key benefits:

- Shorter IDs: Can now use 3-char IDs (was 4-char minimum)
- Better scaling: 3 chars good for ~160 issues, 4 chars for ~980 issues
- Case-insensitive: Maintains excellent CLI usability
- Backward compatible: Old hex IDs continue to work

Changes:
- Implemented Base36 encoding with proper truncation (keep LSB)
- Updated adaptive length thresholds (3-8 chars instead of 4-8)
- Fixed collision probability math to match encoding (was calculating
  for base36 but encoding in hex - now both use base36)
- Fixed ID parser bug (use prefixWithHyphen for substring matching)
- Updated all tests and test data patterns

Fixes #213

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 12:02:15 -08:00
Steve Yegge
add5599d7e bd sync: 2025-11-03 10:35:27 2025-11-03 10:35:27 -08:00
Steve Yegge
39840f6b67 Fix GH #210: bd init --no-db now creates metadata.json and config.yaml
Problem: bd init --no-db returned early (line 131) before creating config files,
causing 'no beads database found' errors on subsequent commands.

Solution:
- Extracted createConfigYaml() helper function
- Call it in both --no-db and normal paths
- Create metadata.json in --no-db path before early return

Fixes bd-c66a
2025-11-03 10:35:21 -08:00
Steve Yegge
3c87fdd928 Update CHANGELOG.md with correct 0.21.5 release notes 2025-11-02 22:42:51 -08:00
goreleaserbot
871ab48ade Brew formula update for beads version v0.21.5 2025-11-03 06:40:37 +00:00
Steve Yegge
3f28ea7981 Add 0.21.5 release notes 2025-11-02 22:39:32 -08:00
Steve Yegge
6fbc6d8a08 chore: Bump version to 0.21.5
Updated all component versions:
- bd CLI: 0.21.4 → 0.21.5
- Plugin: 0.21.4 → 0.21.5
- MCP server: 0.21.4 → 0.21.5
- Documentation: 0.21.4 → 0.21.5

Generated by scripts/bump-version.sh
2025-11-02 22:37:40 -08:00
Steve Yegge
481649a605 Fix widespread double JSON encoding bug in daemon RPC calls (bd-1048, bd-4ec8)
Multiple CLI commands had a systematic bug where ResolveID responses were
incorrectly converted using string(resp.Data) instead of json.Unmarshal.
Since resp.Data is json.RawMessage (already JSON-encoded), this preserved
the JSON quotes, causing IDs to become "bd-1048" instead of bd-1048.
When re-marshaled for subsequent RPC calls, these became double-quoted
("\"bd-1048\""), causing database lookups to fail.

Bugs fixed:
1. Nil pointer dereference in handleShow - added nil check after GetIssue
2. Double JSON encoding in 12 locations across 4 commands:
   - bd show (3 instances in show.go)
   - bd dep add/remove/tree (5 instances in dep.go)
   - bd label add/remove/list (3 instances in label.go)
   - bd reopen (1 instance in reopen.go)

All instances replaced string(resp.Data) with proper json.Unmarshal.
Removed debug logging added during investigation.

Tested: All affected commands now work correctly with daemon mode.
2025-11-02 22:34:24 -08:00
Steve Yegge
63ff9b93bc Update bd-1048 with investigation findings 2025-11-02 22:12:21 -08:00
Steve Yegge
7fe7d4d50a bd sync: 2025-11-02 22:12:17 2025-11-02 22:12:17 -08:00
Steve Yegge
4e30d91d52 Update issues (testing bd-1048) 2025-11-02 21:55:56 -08:00
Steve Yegge
c5dc490bc6 Merge branch 'pr-102'
Amp-Thread-ID: https://ampcode.com/threads/T-158775b4-36b5-41f2-808a-d236d7eecd4b
Co-authored-by: Amp <amp@ampcode.com>

# Conflicts:
#	cmd/bd/main.go
2025-11-02 21:53:55 -08:00
Steve Yegge
f5478b7400 Merge branch 'main' of github.com:steveyegge/beads
# Conflicts:
#	.beads/beads.jsonl
2025-11-02 21:53:39 -08:00
Steve Yegge
32fd74c680 bd sync: 2025-11-02 21:50:32 2025-11-02 21:50:32 -08:00
Steve Yegge
66589f5c93 bd sync
Amp-Thread-ID: https://ampcode.com/threads/T-ca5b1c5c-3e47-4f3a-bd64-d079f1cb1643
Co-authored-by: Amp <amp@ampcode.com>
2025-11-02 21:48:55 -08:00
Steve Yegge
0218ffa253 Document multiple bd binaries in PATH issue 2025-11-02 21:48:55 -08:00
goreleaserbot
ce3d708d4d Brew formula update for beads version v0.21.4 2025-11-03 05:45:33 +00:00
Steve Yegge
c45d4c9f80 Add 0.21.4 release notes 2025-11-02 21:42:27 -08:00
Steve Yegge
f7667c0145 bd sync: 2025-11-02 21:41:43 2025-11-02 21:41:43 -08:00
Steve Yegge
e6c1170e20 chore: Bump version to 0.21.4
Updated all component versions:
- bd CLI: 0.21.3 → 0.21.4
- Plugin: 0.21.3 → 0.21.4
- MCP server: 0.21.3 → 0.21.4
- Documentation: 0.21.3 → 0.21.4

Generated by scripts/bump-version.sh
2025-11-02 21:31:43 -08:00
Steve Yegge
d2e3a43902 bd sync: 2025-11-02 21:31:38 2025-11-02 21:31:38 -08:00
Steve Yegge
2aef84b6d7 bd sync: 2025-11-02 21:31:29
Amp-Thread-ID: https://ampcode.com/threads/T-61dc6400-6b66-4dc8-a0b4-60f0acbb8b88
Co-authored-by: Amp <amp@ampcode.com>
2025-11-02 21:31:29 -08:00
Steve Yegge
8efaefe18f bd sync: 2025-11-02 21:31:13 2025-11-02 21:31:13 -08:00
Steve Yegge
3d46170693 Add --json flag to stale command 2025-11-02 21:25:40 -08:00
Steve Yegge
0bae0d3e52 Merge wasm-port-bd-44d0 to main 2025-11-02 21:25:35 -08:00
Steve Yegge
8bbb710e6a Fix branchExists test after signature change
Updated tests to match the new branchExists() signature that returns
bool instead of (bool, error).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 20:30:31 -08:00
Steve Yegge
1b75a06ba6 Fix all remaining linter errors - golangci-lint passes
- Add #nosec comments for remaining G204 subprocess warnings in syncBranchPull
- Update .golangci.yml to exclude G306 and G204 warnings for worktree files
- Simplified exclusion pattern from "G306.*0644" to "G306" to match actual error text

All linter checks now pass locally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 20:16:40 -08:00
Steve Yegge
86c645603e Fix all gosec, misspell, and unparam linter errors
- Add #nosec directives with explanations for all gosec warnings in worktree operations
- Tighten directory permissions from 0755 to 0750 for better security
- Fix misspellings: archaeological -> archeological, cancelled -> canceled
- Remove unused jsonlPath parameter from syncBranchCommitAndPush
- Change branchExists to return bool instead of (bool, error) - error was never used

All changes maintain backward compatibility and improve code quality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 20:06:05 -08:00
Steve Yegge
b37e8b7c1b bd sync: 2025-11-02 19:37:13 2025-11-02 19:37:13 -08:00
Steve Yegge
0ac905e172 bd sync: 2025-11-02 19:11:16 2025-11-02 19:11:17 -08:00
Steve Yegge
22756509cc Refactor: Extract path canonicalization into utils.CanonicalizePath()
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>
2025-11-02 19:11:08 -08:00
Steve Yegge
e5f1e4b971 Fix --json flag shadowing issue causing test failures
Fixed TestHashIDs_IdenticalContentDedup test failure by removing duplicate
--json flag definitions that were shadowing the global persistent flag.

Root cause: Commands had both a persistent --json flag (main.go) and local
--json flags (in individual command files). The local flags shadowed the
persistent flag, preventing jsonOutput variable from being set correctly.

Changes:
- Removed 31 duplicate --json flag definitions from 15 command files
- All commands now use the single persistent --json flag from main.go
- Commands now correctly output JSON when --json flag is specified

Test results:
- TestHashIDs_IdenticalContentDedup: Now passes (was failing)
- TestHashIDs_MultiCloneConverge: Passes without JSON parsing warnings
- All other tests: Pass with no regressions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 18:52:44 -08:00
Steve Yegge
43fd90b61a Update beads issue database
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 18:42:48 -08:00
Steve Yegge
edf1f71fa7 Add comprehensive protected branch workflow documentation (bd-5ce8)
Created complete documentation suite for using beads with protected branches:

1. **docs/PROTECTED_BRANCHES.md** - Comprehensive 600+ line guide covering:
   - Quick start and setup
   - How git worktrees work
   - Daily workflow for agents and humans
   - Merging strategies (PR and direct)
   - Troubleshooting common issues
   - Platform-specific notes (GitHub, GitLab, Bitbucket)
   - Advanced topics (CI/CD, multi-clone sync, etc.)

2. **AGENTS.md** - Added "Protected Branch Workflow" section:
   - Quick reference for agents
   - No changes needed to agent workflows
   - Commands for setup and merging
   - Link to detailed docs

3. **README.md** - Updated with:
   - Protected branch support feature flag
   - Quick start instructions with --branch flag
   - Link to comprehensive guide

4. **examples/protected-branch/** - Working example with:
   - Step-by-step demo
   - Multi-clone sync workflow
   - GitHub Actions integration example
   - Directory structure explanation
   - Troubleshooting tips

All commands verified:
- bd init --branch <name>
- bd config get/set sync.branch
- bd sync --status
- bd sync --merge

Documentation is platform-agnostic and works with GitHub, GitLab,
Bitbucket, or any git platform with branch protection.

Closes bd-5ce8

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 18:41:51 -08:00
Steve Yegge
9f9167c5db bd sync: 2025-11-02 18:35:59 2025-11-02 18:36:30 -08:00
Steve Yegge
6ecfd04ec8 Implement BEADS_DIR environment variable (bd-e16b)
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>
2025-11-02 18:36:30 -08:00
Steve Yegge
c5b2fbbc9d Add comprehensive sync-branch test coverage (bd-0e74)
Added 4 new integration tests to ensure sync-branch workflow is robust:

1. TestSyncBranchConfigChange - Validates changing sync.branch config
   after worktrees exist. Tests smooth transition between branches.

2. TestSyncBranchMultipleConcurrentClones - Tests 3-way clone sync
   workflow. Simulates real multi-agent collaboration scenario.

3. TestSyncBranchPerformance - Validates commit overhead < 150ms.
   Current performance: avg 77ms (well within target).

4. TestSyncBranchNetworkFailure - Tests graceful handling of network
   errors during push. Ensures local commits succeed even when remote
   is unreachable.

All tests pass:
- cmd/bd (sync branch): PASS (5.361s)
- internal/git: PASS (1.071s)
- internal/syncbranch: PASS (0.312s)

Test coverage now includes: config change handling, multiple concurrent
clones, network failure recovery, performance validation, fresh setup,
issue operations, error handling, sparse checkout.

Closes bd-0e74

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 18:30:38 -08:00
Steve Yegge
b0513d8d1e Update beads issue database
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 18:18:44 -08:00
Steve Yegge
3b6856904f Fix critical double-release race in importInProgress flag
CRITICAL BUG: The previous fix had a race condition where the
importInProgress flag could be released twice, allowing two goroutines
to think they both hold the lock.

Bug scenario:
1. Goroutine A: acquires lock (CAS true)
2. Goroutine A: manually releases at line 208 for git dirty skip
3. Goroutine B: CAS succeeds, acquires lock
4. Goroutine A: defer runs, releases flag AGAIN (clears B lock)
5. Goroutine C: CAS succeeds - now TWO goroutines have lock

Root cause: Using both manual Store(false) AND defer Store(false)
created a window where the flag could be cleared twice.

Fix: Use a shouldDeferRelease flag to disable the deferred release
when we manually release early. This ensures exactly one release
per acquisition.

Testing: All auto-import tests still passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 18:16:25 -08:00
Steve Yegge
e8e9e729e5 Fix bd-8931: Prevent daemon corruption from git conflicts
CRITICAL FIX: The daemon could enter a corrupt state when auto-import
was triggered while uncommitted changes existed in .beads/ files. This
caused mysterious EOF errors requiring daemon restarts.

Root Causes Fixed:
1. No git dirty check before auto-import
2. Missing timeout protection (could hang indefinitely)
3. Race condition in importInProgress flag management
4. Improper git status parsing (false positives)
5. Context leak in export goroutine (accessing closed DB)
6. Data loss in triggerExport (missing deps/labels/comments)

Changes:
- Add hasUncommittedBeadsFiles() to check git status before import
  - Properly parses git porcelain format ("XY filename")
  - Ignores untracked files, only checks tracked .jsonl changes
  - 5-second timeout on git command to prevent hangs

- Add 30-second timeout to import operations
  - Prevents daemon from hanging on stuck imports
  - Returns clear error message on timeout

- Fix race condition in importInProgress flag
  - Explicitly release before early returns
  - Prevents other requests seeing incorrect "import in progress"

- Fix context leak in onChanged export goroutine
  - Check daemon shutdown state before export
  - Suppress expected "database closed" errors during shutdown
  - Pass storage/path as parameters to avoid closure issues

- Fix data loss in triggerExport()
  - Populate dependencies, labels, comments (mirrors handleExport)
  - Use atomic file write (temp + rename)
  - Sort issues for consistent output

Impact: Prevents daemon corruption in collaborative workflows where
users frequently pull updates while having local uncommitted changes.

Testing: All auto-import tests passing
- TestDaemonAutoImportAfterGitPull ✓
- TestDaemonAutoImportDataCorruption ✓
- internal/autoimport tests ✓

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 18:13:37 -08:00
Steve Yegge
fd93a29ab5 Add 'bd status' command for issue database overview (bd-28db)
Implement a new `bd status` command that provides a quick snapshot of the
issue database state, similar to how `git status` shows working tree state.

Features:
- Summary counts by state (open, in-progress, blocked, closed)
- Ready to work count
- Recent activity stats (last 7 days): created, closed, updated issues
- Support for --assigned flag to filter by current user
- JSON output format with --json flag
- Comprehensive test coverage

Usage examples:
  bd status                # Show summary
  bd status --json         # JSON output
  bd status --assigned     # Filter to assigned issues
  bd status --no-daemon    # Direct mode with recent activity

Note: Recent activity currently only works in direct mode (--no-daemon).
Daemon mode support marked with TODO for future enhancement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 17:57:59 -08:00
Steve Yegge
0539455b2d Merge remote changes to beads.jsonl 2025-11-02 17:32:29 -08:00
Steve Yegge
386b15b385 bd sync: 2025-11-02 17:31:45 2025-11-02 17:31:45 -08:00
Steve Yegge
0883fa3c84 Merge branch 'main' of github.com:steveyegge/beads 2025-11-02 17:25:13 -08:00
Steve Yegge
5b1f9a683c bd sync: 2025-11-02 17:20:26 2025-11-02 17:20:45 -08:00
Steve Yegge
01f13a6c18 Add 'bd comment' as alias for 'bd comments add' (bd-d3f0)
Implements a shorter, more natural syntax for adding comments to issues.
Users can now use 'bd comment <issue-id> <text>' instead of the more
verbose 'bd comments add <issue-id> <text>'.

Changes:
- cmd/bd/comments.go: Add commentCmd as top-level alias
- cmd/bd/comments_test.go: Add TestCommentAlias for verification
- commands/comments.md: Document the new shortcut

The alias delegates to the existing commentsAddCmd implementation,
ensuring all functionality (--file, --author flags) works identically.
Backwards compatibility is maintained - 'bd comments add' continues to work.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 17:20:45 -08:00
Steve Yegge
1880278905 Merge remote-tracking branch 'origin/main' 2025-11-02 17:20:35 -08:00
Steve Yegge
50cb2739c8 Import beads JSONL updates 2025-11-02 17:17:11 -08:00
Steve Yegge
e3a7a95831 bd sync: 2025-11-02 17:15:30 2025-11-02 17:15:42 -08:00
Steve Yegge
0599cb732f Fix bd doctor --json flag not working (bd-6049)
The --json flag was being ignored because doctor.go defined a local
flag that shadowed the persistent --json flag from main.go. The local
flag wasn't bound to the global jsonOutput variable, so it remained
false even when --json was passed.

Fixed by removing the duplicate local flag definition. The doctor
command now correctly uses the global persistent flag.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 17:14:22 -08:00