Commit Graph

1970 Commits

Author SHA1 Message Date
Steve Yegge
2156ed593c Update land the plane instructions to use 'bd cleanup' command
- Changed 'bd clean' to 'bd cleanup' (correct command name)
- Added cleanup step to remove backup files and temporary artifacts
- Ensures clean repository state at end of agent sessions
2025-11-20 20:40:11 -05:00
Steve Yegge
e9aaf7799b bd sync: 2025-11-20 20:32:52 2025-11-20 20:32:52 -05:00
Steve Yegge
06d655ae83 Delete 490 closed issues to streamline database
Ran bd cleanup --force to remove all closed issues, keeping only 48 open issues.
This significantly reduces the database size and makes it easier to work with.

Deleted:
- 490 closed issues
- 221 dependency links
- 54 labels
- 755 events

Orphaned issues (will need parent repair):
- bd-tne, bd-tru, bd-ktng, bd-c362, bd-98c4e1fa.1, bd-7e7ddffa.1, bd-o78

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:31:59 -05:00
Steve Yegge
968d9e2ea1 Optimize bd list: replace N+1 label queries with bulk fetch
Problem:
In direct mode, bd list was making a separate GetLabels() call for
each issue when displaying labels. With 538 issues, this resulted in
538 separate database queries.

While investigating the reported 5+ second slowness, discovered this
N+1 query issue that would impact performance with many issues.

Solution:
1. Added GetLabelsForIssues(issueIDs []string) to Storage interface
2. Implemented bulk fetch in SQLite (already existed, now exposed)
3. Implemented bulk fetch in MemoryStorage
4. Updated list.go to fetch all labels in single query

Changes:
- internal/storage/storage.go: Add GetLabelsForIssues to interface
- internal/storage/memory/memory.go: Implement GetLabelsForIssues
- cmd/bd/list.go: Use bulk fetching in all output modes

Impact:
Eliminates N queries for labels, replacing with 1 bulk query.
This optimization applies to direct mode only (daemon mode already
uses bulk operations via RPC).

Note: The reported 5s slowness was actually caused by daemon auto-start
timeout. Use --no-daemon flag or run 'bd migrate --update-repo-id' to
resolve the legacy database issue causing daemon startup failures.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:27:09 -05:00
Steve Yegge
0916abf8fe Add debug logging to bd merge for troubleshooting
- Log all arguments received by merge driver
- Check file existence for each path
- Help diagnose 'open 7: no such file or directory' errors
2025-11-20 20:24:36 -05:00
Steve Yegge
13be84d99f Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-20 20:23:28 -05:00
Steve Yegge
3520321591 bd sync: 2025-11-20 20:22:39 2025-11-20 20:22:40 -05:00
Steve Yegge
62e39d0ec1 Delete 490 closed beads to streamline database
Removed all closed beads (490 total, 497 including cascade deletions):
- Completed feature implementations
- Fixed bugs and resolved issues
- Test issues from development
- Deprecated/removed features
- Refactoring tasks

Database reduced from 538 to 48 beads (46 open, 2 other states)

All deleted beads preserved in git history for reference.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:22:07 -05:00
Steve Yegge
e8355c26f0 Add 'bd clean' command to remove temporary merge artifacts
This command cleans up temporary files created during git merges by reading
patterns directly from .beads/.gitignore (Merge artifacts section).

Files removed:
- 3-way merge snapshots (beads.base.jsonl, beads.left.jsonl, beads.right.jsonl)
- Merge metadata (*.meta.json)
- Git merge driver temp files (*.json[0-9], *.jsonl[0-9])

Files preserved:
- beads.jsonl (source of truth)
- beads.db (SQLite database)
- metadata.json, config.yaml
- All daemon files

Usage:
  bd clean           # Clean up temporary files
  bd clean --dry-run # Preview what would be deleted

Implementation:
- Reads patterns from .beads/.gitignore instead of hardcoding them
- No --force flag needed - just runs by default
- Only cleans truly temporary merge artifacts, never the database

Also:
- Restored beads.jsonl to 538 issues from commit 6cd3a32
- Set issue-prefix to "bd" in config.yaml

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:21:37 -05:00
Steve Yegge
6cd3a32329 Restore beads.jsonl to 538 issues from d99222d 2025-11-20 19:59:19 -05:00
Steve Yegge
8d52f1deb5 removed zombie backup 2025-11-20 19:51:04 -05:00
Steve Yegge
d99222d895 Restore stable state: revert to beads.jsonl with 538 issues
- Revert migration to issues.jsonl (was causing data corruption)
- Backup issues.jsonl for reference
- Database and beads.jsonl now in sync (538 issues)
- Clean slate for stable operations
2025-11-20 19:48:26 -05:00
Steve Yegge
d1d06e75ff Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-20 19:38:14 -05:00
Steve Yegge
764886b3e7 bd sync: 2025-11-20 19:38:13 2025-11-20 19:38:13 -05:00
Steve Yegge
e447acce9e Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-20 19:37:01 -05:00
Steve Yegge
f01326832f Enhance bd doctor with bd prime migration recommendations (bd-0fvq)
Add comprehensive detection and migration guidance for old beads integration
patterns. This helps users adopt the more efficient bd prime approach.

Changes:
- Enhanced CheckLegacyBeadsSlashCommands with detailed migration steps
  and token efficiency benefits (99% reduction: ~10.5k → ~50 tokens)
- Added CheckAgentDocumentation to detect missing AGENTS.md/CLAUDE.md
  and suggest bd onboard or bd setup claude
- Enhanced CheckClaude to recommend bd prime hooks for MCP-only setups
  with clear token efficiency messaging
- Added comprehensive tests for all new checks

bd doctor now detects:
1. Old slash command patterns (/beads:*) and recommends bd prime hooks
2. Missing agent documentation and suggests creating it
3. MCP-only setups without hooks and shows token savings potential
4. Provides clear migration paths and benefits for all scenarios

Token efficiency messaging:
- MCP mode: ~50 tokens vs ~10.5k for full scan (99% reduction)
- CLI mode: ~1-2k tokens with automatic context recovery
- Hooks auto-refresh context on SessionStart and PreCompact

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:36:48 -05:00
Steve Yegge
34c311aba6 Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-20 19:33:14 -05:00
Steve Yegge
7806937b0a Add bd doctor --fix flag to automatically repair issues (bd-ykd9)
Implements automatic fix capability for bd doctor with user confirmation
and security hardening.

Features:
- Organizes fix implementations under doctor/fix/ directory structure
- Shows all fixable issues and prompts for confirmation (Y/n) before applying
- Provides clear output about what was fixed and any errors encountered
- Re-runs diagnostics after fixes to show updated state
- Each fix is idempotent and safe to run multiple times

Automatic fixes implemented:
- Git hooks (runs bd hooks install)
- Daemon health issues (runs bd daemons killall)
- DB-JSONL sync problems (runs bd sync --import-only)
- File permissions (fixes .beads/ and database permissions)
- Database version mismatches (runs bd migrate)
- Schema compatibility issues (runs bd migrate)
- Gitignore updates (writes canonical template)

Security improvements:
- Prevents command injection by using os.Executable() instead of PATH lookup
- Prevents path traversal attacks with workspace validation
- Fixes race conditions by using cmd.Dir instead of os.Chdir()
- Corrects file permission logic (proper bit masking)
- Validates all operations run in beads workspaces only

Files changed:
- cmd/bd/doctor.go: Enhanced applyFixes() with confirmation and better UX
- cmd/bd/doctor/gitignore.go: Fixed permissions (0600 → 0644)
- cmd/bd/doctor/fix/common.go: Security helpers (getBdBinary, validateBeadsWorkspace)
- cmd/bd/doctor/fix/hooks.go: Git hooks fix
- cmd/bd/doctor/fix/daemon.go: Daemon health fix
- cmd/bd/doctor/fix/sync.go: DB-JSONL sync fix
- cmd/bd/doctor/fix/permissions.go: File permissions fix
- cmd/bd/doctor/fix/migrate.go: Database migration fixes

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:33:12 -05:00
Steve Yegge
1458519536 Merge remote-tracking branch 'origin/main'
Resolved JSONL conflicts using bd merge tool.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:31:16 -05:00
Steve Yegge
8b0a8faa76 Merge remote-tracking branch 'origin/main'
Resolved JSONL conflicts using bd merge tool.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:31:00 -05:00
Steve Yegge
4f481c88b1 Close bd-5qim (GetReadyWork optimization completed in 690c73f) 2025-11-20 19:30:27 -05:00
Steve Yegge
25e0ff6335 bd sync: 2025-11-20 19:29:56 2025-11-20 19:29:56 -05:00
Steve Yegge
8952254ed8 Update bd JSONL
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:29:44 -05:00
Steve Yegge
614ba8ab20 Add cache invalidation for blocked_issues_cache
Ensures cache stays synchronized with dependency and status changes
by calling invalidateBlockedCache() at all mutation points (bd-5qim).

Cache invalidation points:
- AddDependency: when type is 'blocks' or 'parent-child'
- RemoveDependency: when removed dep was 'blocks' or 'parent-child'
- UpdateIssue: when status field changes
- CloseIssue: always (closed issues don't block)

The invalidation strategy is full cache rebuild on any change,
which is fast enough (<1ms for 10K issues) and keeps the logic simple.

Only 'blocks' and 'parent-child' dependency types affect blocking,
so 'relates-to' and other types skip invalidation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:29:30 -05:00
Steve Yegge
ed23f8f4fe Optimize GetReadyWork to use blocked_issues_cache
Replaces expensive recursive CTE query with simple cache lookup,
achieving 96% performance improvement on 10K databases (bd-5qim).

Performance results:
- Before: ~752ms (recursive CTE on every call)
- After: ~29ms (cache lookup + filters)
- Target: <50ms ✓

The query now uses a simple NOT EXISTS check against the
blocked_issues_cache table instead of computing the full
blocked issue tree on every call.

Cache is maintained by invalidateBlockedCache() called on
dependency and status changes (added in next commit).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:29:30 -05:00
Steve Yegge
62c1f42d9f Add blocked_issues_cache table for GetReadyWork optimization
Introduces a materialized cache table to store blocked issue IDs,
replacing the expensive recursive CTE computation that was causing
~752ms query times on 10K databases (bd-5qim).

The cache is maintained via invalidation on dependency and status
changes, reducing GetReadyWork from O(n²) recursive traversal to
O(1) cache lookup.

Technical details:
- New blocked_issues_cache table with single issue_id column
- ON DELETE CASCADE ensures automatic cleanup
- Migration populates cache using existing recursive CTE logic
- rebuildBlockedCache() fully rebuilds cache on invalidation
- execer interface allows both *sql.DB and *sql.Tx usage

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:29:30 -05:00
Steve Yegge
9e57cb69d8 Improve type safety and fix minor issues in beads-mcp
Type Safety Improvements:
- Change dict → dict[str, Any] throughout codebase for explicit typing
- Add PEP 561 py.typed marker file to export type information
- Add types-requests to dev dependencies
- Improve signal handler typing (FrameType | None)
- Improve decorator typing (Callable[..., Awaitable[T]])
- Add quickstart() abstract method to BdClientBase for interface completeness

Bug Fixes:
- Fix variable shadowing: beads_dir → local_beads_dir in bd_client.py
- Improve error handling in mail.py:_call_agent_mail() to prevent undefined error
- Make working_dir required (not Optional) in BdDaemonClient
- Remove unnecessary 'or' defaults for required Pydantic fields

Validation:
- mypy passes with no errors
- All unit tests passing
- Daemon quickstart returns helpful static text (RPC doesn't support this command)
2025-11-20 19:27:56 -05:00
Steve Yegge
e1c8853748 feat: Add .beads/README.md generation during bd init (bd-m7ge)
Automatically creates a promotional README.md in the .beads directory
when bd init is run. The README explains what Beads is, provides
essential commands, highlights key benefits for AI-assisted workflows,
and encourages developers to try Beads in their own projects.

Changes:
- Added createReadme() function to generate compelling README content
- Integrated README creation in both regular and --no-db init modes
- README creation is idempotent (skips if already exists)
- Non-fatal warnings if README creation fails

The README is designed to get open source contributors excited about
using Beads for their AI-assisted development workflows.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:24:26 -05:00
Steve Yegge
109b9d275a Close bd-g9eu (TestRoutingIntegration investigation)
Issue was already fixed in commit 8e05847. Build error was due to
accidentally deleted sqlite.go, now restored.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:24:16 -05:00
Steve Yegge
88210fe039 Clean up spurious and duplicate issues
Deleted 94 spurious test and duplicate issues:
- 39 simple test placeholders (Issue 1/2, Test issue 0/1/2, Batch/Rapid tests)
- 29 additional test issues with empty descriptions
- 3 test epic issues
- 23 duplicate issues (kept oldest instance of each)

Also cleaned up:
- 10 dependency links
- 17 labels
- 127 events

Reduced issue count from 540 to 446 issues.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:22:47 -05:00
Steve Yegge
0470105fee Merge branch 'main' of https://github.com/steveyegge/beads
# Conflicts:
#	.beads/issues.jsonl
2025-11-20 19:19:28 -05:00
Steve Yegge
3b2cac4d8f Centralize error handling patterns in storage layer (bd-bwk2)
Created internal/storage/sqlite/errors.go with:
- Sentinel errors: ErrNotFound, ErrInvalidID, ErrConflict, ErrCycle
- wrapDBError helpers that auto-convert sql.ErrNoRows to ErrNotFound
- Type-safe error checking with errors.Is() compatibility

Updated error handling across storage layer:
- dirty.go: Added context to error returns, converted sql.ErrNoRows checks
- util.go: Updated withTx to use wrapDBError
- batch_ops.go: Added context wrapping to batch operations
- dependencies.go: Wrapped errors from markIssuesDirtyTx calls
- ids.go: Added error wrapping for ID validation

Also restored sqlite.go that was accidentally deleted in previous commit.

All tests pass. Provides consistent error wrapping with operation context
for better debugging.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:17:57 -05:00
Steve Yegge
bc2c3517f9 bd sync: 2025-11-20 19:13:10 2025-11-20 19:13:10 -05:00
Steve Yegge
06b6f864b8 Merge remote-tracking branch 'origin/main'
Amp-Thread-ID: https://ampcode.com/threads/T-c8d369a3-32f0-42a0-96d1-fd589e89bd6b
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:12:06 -05:00
Steve Yegge
250386102e bd sync: 2025-11-20 19:11:36 2025-11-20 19:11:36 -05:00
Steve Yegge
bbfedb060a Refactor: extract duplicated validation and flag logic (bd-g5p7)
- Created internal/validation package for centralized validation logic
- Created cmd/bd/flags.go for shared flag registration
- Updated create and update commands to use shared logic
- Added support for 'P1' style priority to update command
- Added tests for validation logic

Amp-Thread-ID: https://ampcode.com/threads/T-c8d369a3-32f0-42a0-96d1-fd589e89bd6b
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:11:27 -05:00
Steve Yegge
221a7d4db6 bd sync: 2025-11-20 19:08:23 2025-11-20 19:10:37 -05:00
Steve Yegge
1736f9f12d bd sync: 2025-11-20 18:58:07 2025-11-20 19:10:37 -05:00
Steve Yegge
e9f5a0c35a Update issues.jsonl
Amp-Thread-ID: https://ampcode.com/threads/T-fc47ce9d-88a4-4bcd-b9cb-79327d98dee7
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:09:15 -05:00
Steve Yegge
5c177a4f27 Migrate to issues.jsonl
Amp-Thread-ID: https://ampcode.com/threads/T-fc47ce9d-88a4-4bcd-b9cb-79327d98dee7
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:08:39 -05:00
Steve Yegge
631c9236e7 Resolve merge conflict in beads.jsonl
Amp-Thread-ID: https://ampcode.com/threads/T-fc47ce9d-88a4-4bcd-b9cb-79327d98dee7
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:08:23 -05:00
Steve Yegge
8e05847d31 Fix TestRoutingIntegration and improve DetectUserRole robustness
Amp-Thread-ID: https://ampcode.com/threads/T-fc47ce9d-88a4-4bcd-b9cb-79327d98dee7
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:04:42 -05:00
Steve Yegge
2c6c7f36f3 chore: update beads.jsonl 2025-11-20 19:01:30 -05:00
Steve Yegge
6a25f5eaa6 fix: resolve remaining hyphenated ID issues in memory store and doctor 2025-11-20 19:01:30 -05:00
Zachary Rosen
408244ed73 fix: isHashID matches for hyphenated application names
Fixes `isHashID` checks for hyphenated application names

When a user calls bd init inside an application that has a "-" for
example my-first-application without any options than ids will follow a
pattern of my-first-application-{ID}. When using SplitN on the "-"
separator it would result in the split parts returning as [my,
first-application-{ID}] which is incorrectly pulling out the {ID}
resulting in the `isHashID` returning false when it could be a hash id.

Instead of using SplitN, this changes to find the last index of the
separator resulting in the suffix becoming the actual {ID}.
2025-11-20 19:01:30 -05:00
Steve Yegge
7b865eb541 Remove legacy issues.jsonl and update defaults to beads.jsonl
Amp-Thread-ID: https://ampcode.com/threads/T-ae11b392-24b5-4060-b431-606dd81c1763
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:00:36 -05:00
Steve Yegge
f3a678fc9d Fix MCP schema generation recursion bug (GH#346)
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-c992b759-8dac-467d-b87c-5633ae29aef8
2025-11-20 18:57:19 -05:00
Steve Yegge
345766badc Fix FK constraint failures in AddComment and ApplyCompaction (bd-5arw)
Amp-Thread-ID: https://ampcode.com/threads/T-4358e6e4-28ea-4ed7-ba3f-3da39072e169
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 18:55:10 -05:00
Steve Yegge
4560f55795 bd sync: 2025-11-20 14:25:18 2025-11-20 14:25:18 -05:00
Steve Yegge
6a562d53fa Merge remote-tracking branch 'origin/main'
Amp-Thread-ID: https://ampcode.com/threads/T-aa765a68-5cc4-465b-a2f6-aa008933c11e
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 14:21:06 -05:00