5526 Commits

Author SHA1 Message Date
Steve Yegge
347100319e Document CreateIssues API (bd-243)
- Add comprehensive godoc to CreateIssues with usage examples
- Add batch operations section to EXTENDING.md with performance comparison
- Add performance feature to README.md
- Include when to use CreateIssue vs CreateIssues guidance
- Document counter sync requirement after explicit IDs

Amp-Thread-ID: https://ampcode.com/threads/T-59fc78c3-a7f2-4c33-b074-2fa840c97c87
Co-authored-by: Amp <amp@ampcode.com>
2025-10-15 20:24:07 -07:00
Steve Yegge
58bdf4bc0b Update issues: close bd-222 (CreateIssues complete) 2025-10-15 20:20:20 -07:00
Steve Yegge
de236d0d1f Fix skip-existing logic for batch import duplicates
The skipUpdate flag should only apply to existing DB issues, not to
duplicates within the import batch. Batch duplicates always use
last-one-wins semantics.
2025-10-15 20:09:24 -07:00
Steve Yegge
3eb4f4d040 Optimize import with batch CreateIssues (bd-242)
- Replace CreateIssue loop with single CreateIssues batch call
- Add in-memory de-duplication for duplicate IDs (last one wins)
- 5-15x faster for bulk imports
- All tests pass
2025-10-15 19:57:46 -07:00
Steve Yegge
0a81b08c4f chore: Close bd-71 code review follow-up epic
Amp-Thread-ID: https://ampcode.com/threads/T-8a764023-ed80-4333-a037-46936e5e5d08
Co-authored-by: Amp <amp@ampcode.com>
2025-10-15 19:41:57 -07:00
Steve Yegge
5ab7ff0f84 Add comprehensive unit tests for CreateIssues (bd-241)
- Added 12 table-driven test cases covering all validation scenarios
- Added 2 rollback tests (validation error + DB conflict)
- Added nil item detection to prevent panic
- Fixed nil pointer panic in CreateIssues
- Tests verify ID uniqueness, timestamps, closed_at invariant
- All tests pass

Amp-Thread-ID: https://ampcode.com/threads/T-61c584cd-d873-4a1a-bfa6-d739b630b3e5
Co-authored-by: Amp <amp@ampcode.com>
2025-10-15 19:33:53 -07:00
Steve Yegge
e7d4a9c822 Implement CreateIssues batch API (bd-240, bd-244)
- Add CreateIssues method to Storage interface
- Implement SQLiteStorage.CreateIssues with atomic ID range reservation
- Single transaction for N issues (5-10x speedup expected)
- Set timestamps before validation to match CreateIssue behavior
- All tests passing
2025-10-15 19:13:27 -07:00
Steve Yegge
e4394df604 Close bd-224: status/closed_at invariant fully enforced 2025-10-15 18:03:58 -07:00
Steve Yegge
737f354066 Update issue tracking after label test implementation 2025-10-15 17:51:14 -07:00
Steve Yegge
a00c0e2199 Add comprehensive tests for label management commands
- Test add/remove labels
- Test multiple labels and duplicates
- Test label persistence across updates
- Test event creation for label operations
- Test labels with different issue types
- All 10 test cases passing
2025-10-15 17:51:09 -07:00
Steve Yegge
3c8e4d78e5 Add label management and import collision detection
- Implement 'bd label' command with add/remove/list subcommands
- Add import --dry-run and --resolve-collisions for safe merges
- Support label filtering in 'bd list' and 'bd create'
- Update AGENTS.md with collision handling workflow
- Extends bd-224 (data consistency) and bd-84 (import reliability)
2025-10-15 17:19:16 -07:00
Steve Yegge
6bfaad8731 Add reopen command tests (bd-248)
Amp-Thread-ID: https://ampcode.com/threads/T-7c3a7351-f785-440d-8200-da858cf98426
Co-authored-by: Amp <amp@ampcode.com>
2025-10-15 17:06:59 -07:00
Steve Yegge
f78f529087 Add bd reopen command for explicit issue reopening
Implements bd-235: New reopen command makes reopening issues more explicit
than 'bd update --status open'.

Features:
- Sets status to 'open' and automatically clears closed_at
- Emits EventReopened via UpdateIssue
- Optional --reason flag to add comment
- JSON output support
- Auto-flush after operation

Closes: bd-234, bd-235, bd-236, bd-237, bd-238, bd-239
Related: bd-224 (status/closed_at invariant enforcement)
Amp-Thread-ID: https://ampcode.com/threads/T-b1c82629-3521-440f-9f16-ab6d66fb5091
Co-authored-by: Amp <amp@ampcode.com>
2025-10-15 16:31:11 -07:00
Travis Cline
4131e6bf38 list: add status-based color coding to dot format
Enhance Graphviz dot output with status-based fill colors:
- open: white background (default)
- in_progress: light yellow background
- blocked: light coral background
- closed: light gray background with dimmed text

Node labels show: ID, type, priority, title, and status.
Priority is visible in the label (e.g., [bug P0]) but not color-coded
to keep the visualization clean and focused on status.
2025-10-15 15:27:49 -07:00
Travis Cline
6f357ea536 list: add --format flag with template support
Add flexible --format flag to 'bd list' command supporting:
- Built-in presets: 'digraph' (basic 'from to' format) and 'dot' (Graphviz)
- Custom Go templates for dependency output
- Template variables: IssueID, DependsOnID, Type, Issue, Dependency

This enables graph analysis with tools like golang.org/x/tools/cmd/digraph while allowing users to customize output format for their specific needs.

Examples:
  bd list --format=digraph | digraph nodes
  bd list --format=dot | dot -Tsvg -o deps.svg
  bd list --format='{{.IssueID}} -> {{.DependsOnID}} [{{.Type}}]'
2025-10-15 15:27:24 -07:00
Travis Cline
0c3c613890 list: add filter value enums to help 2025-10-15 15:27:24 -07:00
Travis Cline
cf8ff4227d list: extract command to separate file 2025-10-15 15:27:24 -07:00
Steve Yegge
d2b50e6cdc Add closed_at timestamp tracking to issues
- Add closed_at field to Issue type with JSON marshaling
- Implement closed_at timestamp in SQLite storage layer
- Update import/export to handle closed_at field
- Add comprehensive tests for closed_at functionality
- Maintain backward compatibility with existing databases

Amp-Thread-ID: https://ampcode.com/threads/T-f3a7799b-f91e-4432-a690-aae0aed364b3
Co-authored-by: Amp <amp@ampcode.com>
2025-10-15 14:52:29 -07:00
Steve Yegge
ab809c5baf Create issue structure for bd-222 and bd-224
- Added design documents (ULTRATHINK_BD222.md, ULTRATHINK_BD224.md)
- Created bd-224 epic with 6 child issues for status/closed_at invariant fix
- Created bd-222 epic with 7 child issues for batching API
- Set up dependencies: bd-224 blocks bd-222 (must fix invariant first)
- Dependencies enable max parallelism while ensuring correct order
2025-10-15 14:27:10 -07:00
Steve Yegge
9f11d4e6db synced issues database 2025-10-15 13:50:59 -07:00
Steve Yegge
619ce51250 Fix auto-import collision detection and enforce status/closed_at invariant (bd-226)
Code review and fixes:
- Increased scanner buffer to 2MB for large JSON lines
- Added line numbers and snippets to parse error messages
- Made non-SQLite fallback conservative (skip import to prevent data loss)
- Improved collision warnings (concise, show first 10 IDs)
- Removed unused autoImportWithoutCollisionDetection function

Status/closed_at invariant enforcement:
- Auto-import now enforces invariant on all creates/updates
- Fixed CreateIssue to respect closed_at field (was ignoring it)
- Closed issues without closed_at get timestamp set automatically

Integration tests:
- TestAutoImportWithCollision: verifies local changes preserved
- TestAutoImportNoCollision: happy path with new issues
- TestAutoImportClosedAtInvariant: enforces invariant

Closes bd-226, bd-230, bd-231
2025-10-15 13:47:46 -07:00
Steve Yegge
ff2ca503db migrated bootup instructions to AGENTS.md 2025-10-15 13:16:06 -07:00
Steve Yegge
00e2f7e963 Apply bd-227 cleanup: Fix 86 closed issues missing timestamps
Ran: UPDATE issues SET closed_at = updated_at WHERE status = 'closed' AND closed_at IS NULL
Result: 0 remaining inconsistencies (verified)

Database now ready for CHECK constraint migration
2025-10-15 13:11:51 -07:00
Steve Yegge
f0266339c5 Complete bd-227: Audit status/closed_at inconsistencies
Findings:
- 86/93 closed issues (92%) are missing closed_at timestamps
- All inconsistencies are historical (old issues bd-1 through bd-93)
- No cases of non-closed issues with timestamps

Recommendation: Set closed_at = updated_at for affected issues
Next: Apply cleanup SQL and add constraint
2025-10-15 13:08:48 -07:00
Steve Yegge
7106df48e7 chore: Bump version to 0.9.7
Updated all component versions:
- bd CLI: 0.9.6 → 0.9.7
- Plugin: 0.9.6 → 0.9.7
- MCP server: 0.9.6 → 0.9.7
- Documentation: 0.9.6 → 0.9.7

Generated by scripts/bump-version.sh
2025-10-15 12:47:26 -07:00
Steve Yegge
f755472410 fix: Remove unsupported env vars and fix slash commands directory structure
Fixes #42 and #44

- Remove BEADS_ACTOR and BEADS_WORKING_DIR from plugin.json env
  (Claude Code only supports ${CLAUDE_PLUGIN_ROOT} expansion)
- Move commands from .claude-plugin/commands/ to commands/ at root
- Rename command files to remove redundant bd- prefix

This fixes MCP server crashes with literal ${PWD} directory errors
and makes slash commands discoverable in Claude Code.

Amp-Thread-ID: https://ampcode.com/threads/T-69426d6c-25ea-4333-8955-5b624001c8c6
Co-authored-by: Amp <amp@ampcode.com>
2025-10-15 12:47:21 -07:00
Steve Yegge
8dd92dfe7f Merge PR #31: Refactor export file writing to avoid Windows Defender false positives 2025-10-15 11:53:49 -07:00
Steve Yegge
aeab8c6704 Merge PR #38: Add Nix flake for declarative builds 2025-10-15 11:50:18 -07:00
Steve Yegge
1ce8be6f58 Update flake version to 0.9.6 to match project version 2025-10-15 11:50:13 -07:00
Steve Yegge
991eb281a8 Merge PR #40: Fix MCP integration tests and linting errors 2025-10-15 11:45:20 -07:00
Steve Yegge
691f90f833 Auto-fix remaining linting issues - remove unused imports 2025-10-15 11:45:11 -07:00
Steve Yegge
3347fd65ca Fix remaining linting issues - combine nested with statements 2025-10-15 11:44:59 -07:00
Matt Wilkie
e2703d3d9b Merge branch 'main' into win-defender-mitigation
# Conflicts:
#	.beads/issues.jsonl
#	README.md
2025-10-15 06:32:44 -07:00
Willi Ballenthin
6a3edefad3 docs: Update CHANGELOG with Nix flake support
docs: Add nix run example to CHANGELOG
2025-10-15 13:45:05 +02:00
Willi Ballenthin
84ba574dff feat: Add apps.default output to flake for nix run support
Add an apps.default output to the Nix flake that enables running bd
directly with 'nix run .' without needing to use the full package path.

The apps output references the built bd binary from packages.default,
allowing users to easily run the tool with: nix run . -- <command>

Tested with 'nix run . -- version' which correctly executes bd.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 13:45:05 +02:00
Willi Ballenthin
e89cfbf473 feat: Add Nix flake for declarative builds
Add flake.nix with computed vendorHash for Go dependencies. The flake
supports all major platforms (x86_64/aarch64 Linux and macOS) and
builds the bd binary from cmd/bd.

Removed unnecessary postInstall section as buildGoModule already names
the binary correctly from subPackages.

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

Co-Authored-By: Claude <noreply@anthropic.com>

perf: Use self input instead of ./. for faster Nix evaluation

Replace src = ./. with src = self in flake.nix to reduce unnecessary
file copying during evaluation. This eliminates the Nix warning about
evaluation performance.
2025-10-15 13:45:05 +02:00
Baishampayan Ghose
4353592fe6 test(mcp): Fix two failing integration tests and linting errors
1. Fix `test_default_beads_path_auto_detection`
    - Changed beads_path to use `Field(default_factory=_default_beads_path)` so the default is evaluated at instance
    creation time, not class definition time
    - Updated test to mock both `shutil.which` and `os.access`
2. Fix `test_init_creates_beads_directory`
    - Fixed test to pass `working_dir=temp_dir` to `BdClient` instead of using `os.chdir()`
    - The `_get_working_dir()` method checks `PWD` env var first, which isn't updated by `os.chdir()`
3. Fix minor linting errors reported by `ruff` tool
4. Update `beads` version to `0.9.6` in `uv.lock` file

MCP Server test coverage is now excellent, at 92% overall maintaining our high-standards of production level quality.

```
Name                         Stmts   Miss  Cover
------------------------------------------------
src/beads_mcp/__init__.py        1      0   100%
src/beads_mcp/__main__.py        3      3     0%
src/beads_mcp/bd_client.py     214     14    93%
src/beads_mcp/config.py         51      2    96%
src/beads_mcp/models.py         92      1    99%
src/beads_mcp/server.py         58     16    72%
src/beads_mcp/tools.py          59      0   100%
------------------------------------------------
TOTAL                          478     36    92%
```
2025-10-15 16:59:16 +05:30
Steve Yegge
953858b853 fix: Resolve race condition in parallel issue creation (bd-89)
Fixed UNIQUE constraint errors when creating multiple issues in parallel.

Root cause: The previous two-step approach used INSERT OR IGNORE to
pre-initialize counters, followed by an UPSERT to increment. Multiple
concurrent transactions could all execute the INSERT OR IGNORE with the
same initial value, causing them to generate duplicate IDs.

Solution: Replaced with a single atomic UPSERT that:
1. Initializes counter from MAX(existing IDs) if needed
2. Updates counter to MAX(current, max existing) + 1 on conflict
3. Returns the final incremented value

This ensures counters are correctly initialized from existing issues
(fixing lazy init tests) while preventing race conditions through the
BEGIN IMMEDIATE transaction serialization.

Tested with 10 parallel processes - all succeeded with unique IDs.

Also added comprehensive profiling test suite for import performance
investigation (bd-199).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 02:57:10 -07:00
Steve Yegge
0afbbfa5cc chore: Remove LOST_ISSUES_RECOVERY.md
Recovery investigation complete. Key findings documented in bd-229 notes.
No need for separate recovery doc - issue tracker has the details.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 02:40:56 -07:00
Steve Yegge
e3bc9161fe docs: Add testing phase banner for auto-import fix (v0.9.6)
Auto-import collision detection fix (bd-228) is deployed and needs field testing.
Banner alerts users that the critical bug is fixed but testing is ongoing.

Links to LOST_ISSUES_RECOVERY.md for transparency about recovered data.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 02:32:58 -07:00
Steve Yegge
2b03805651 chore: Bump version to 0.9.6
Updated all component versions:
- bd CLI: 0.9.5 → 0.9.6
- Plugin: 0.9.5 → 0.9.6
- MCP server: 0.9.5 → 0.9.6
- Documentation: 0.9.5 → 0.9.6

Generated by scripts/bump-version.sh
2025-10-15 02:32:15 -07:00
Steve Yegge
46258c6834 chore: Complete lost issues recovery investigation (bd-229)
Successfully recovered 3 valuable issues from 22 total lost during auto-import bug:
- bd-222 → bd-232: Batching API feature request
- bd-223 → bd-233: Early context check optimization
- bd-221 context preserved in bd-89 notes

19 test fixtures identified but not recovered (no production value).

Auto-import collision detection fix (bd-228) prevents future data loss.

See LOST_ISSUES_RECOVERY.md for full investigation details.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 02:32:10 -07:00
Steve Yegge
6b88d60d6e fix: Add collision detection to auto-import (bd-228)
CRITICAL FIX: Auto-import was silently overwriting local changes without any
collision detection or warning. This caused data loss in multi-developer workflows.

Changes:
- Auto-import now uses sqlite.DetectCollisions() before importing
- Colliding issues are skipped (preserves local changes)
- Warning printed with list of skipped issues and resolution instructions
- Added autoImportWithoutCollisionDetection() fallback for non-SQLite backends
- All tests pass

Impact:
- Local changes are now preserved during git pull
- Users are informed when collisions occur
- Can manually resolve with 'bd import --resolve-collisions'
- No more silent data corruption

Also:
- Removed critical warning banner from README
- Created bd-229 for data recovery investigation
- Closed bd-228 as fixed

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 02:11:42 -07:00
Steve Yegge
38ae26d9e9 docs: Add critical bug warning banner to README (bd-228)
CRITICAL: Auto-import silently overwrites local changes without collision detection.

Changes:
- Added prominent warning banner at top of README
- Documents data corruption risk for multi-developer workflows
- Provides --no-auto-import workaround
- References bd-228 for tracking and updates

This affects anyone using bd with multiple developers or agent swarms.
Local updates/closes can be silently reverted by auto-import after git pull.

Also includes:
- ULTRATHINK_BD224.md analysis document (bd-224, bd-225)
- Updated issues.jsonl with bd-224, bd-225, bd-226, bd-227, bd-228

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 02:07:33 -07:00
Steve Yegge
174ff3270d fix: remove legacy beads.db and file import timeout bug (bd-199)
- Deleted stale beads.db (last modified Oct 14, 20KB)
- bd.db is the active database (2MB, 208 issues)
- Filed bd-199 to investigate import timeout with 208 issues
- Import should handle 100k+ issues, currently times out at 208

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 01:56:51 -07:00
Steve Yegge
68f1b9d2c9 feat: add label CLI feature request (bd-198)
Created bd-198: Add label management commands to CLI
- Add bd label add/remove/list subcommands
- Extend bd list with --label filter
- Enable organizing issues into streams/categories
- Support parallel workflow coordination

Closes mistakenly created GitHub issue #39 (should use beads itself).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 01:51:07 -07:00
Steve Yegge
587e1d9d0f test: Add comprehensive test coverage for storage layer
Added test files for core SQLite storage functionality:
- beads_test.go: Database path detection tests
- dirty_test.go: Dirty tracking for auto-flush
- events_test.go: Event logging tests
- labels_test.go: Label management tests
- sqlite_test.go: Added metadata tests (SetMetadata, GetMetadata)

Merged with upstream TestParallelIssueCreation (bd-89 regression test).

All tests passing. Ready to push.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 01:30:28 -07:00
Steve Yegge
42d2f71925 fix: Fix race condition in parallel issue creation (bd-89)
Use IMMEDIATE transactions with dedicated connections to fix race condition
where multiple processes creating issues concurrently caused "UNIQUE constraint
failed: issues.id" errors.

Key changes:
- Use BEGIN IMMEDIATE to acquire RESERVED lock early
- Use dedicated connection (sql.Conn) for transaction to ensure all operations
  happen on same connection
- Increase busy_timeout from 10s to 30s for better parallel write handling
- Use context.Background() for ROLLBACK to ensure cleanup even if ctx cancelled

Added regression test TestParallelIssueCreation that creates 20 issues in
parallel and verifies no ID collisions occur.

Fixes #6

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 01:26:27 -07:00
Steve Yegge
474d9e098f fix: Update minimum Go version requirement to 1.23
Fixes #34

Problem: Users with Go 1.18 were unable to install beads because go.mod
specifies 'go 1.23.0', which older Go toolchains cannot parse. The error
"invalid go version '1.23.0': must match format 1.23" occurs because
Go versions before 1.21 don't support the three-part version format.

Root cause: Our dependencies (especially modernc.org/sqlite) require Go 1.23,
which forces go.mod to use the 1.23.0 format. This is correct for our actual
requirements, but was incorrectly documented as requiring only Go 1.21.

Solution:
1. Updated install.sh to check for Go 1.23+ and show clear error messages
   if an older version is detected
2. Updated README.md to correctly state "requires Go 1.23+" instead of 1.21+
3. go.mod already correctly specifies go 1.23.0 (no changes needed there)

The version check in install.sh now:
- Parses the Go version from 'go version' output
- Compares major.minor version numbers
- Fails fast with helpful upgrade instructions if Go < 1.23

This prevents confusing build errors and guides users to upgrade Go before
attempting installation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 00:55:47 -07:00
Steve Yegge
588f554034 chore: Update issues (bd-182 closed, bd-197 completed)
- bd-182: Closed - auto-export works correctly in v0.9.5 (old binary issue)
- bd-197: Closed - version mismatch detection implemented
- bd-196: Closed - test issue

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 00:43:59 -07:00