5526 Commits

Author SHA1 Message Date
Steve Yegge
cff10b1998 Add automatic log rotation for daemon (bd-154)
- Integrated lumberjack library for production-ready log rotation
- Configurable via env vars: BEADS_DAEMON_LOG_MAX_SIZE, BEADS_DAEMON_LOG_MAX_BACKUPS, BEADS_DAEMON_LOG_MAX_AGE, BEADS_DAEMON_LOG_COMPRESS
- Defaults: 10MB max size, 3 backups, 7 day retention, compression enabled
- Added comprehensive tests for env var parsing and rotation config
- Updated README.md and CHANGELOG.md with rotation documentation
- Prevents unbounded log growth for long-running daemons

Amp-Thread-ID: https://ampcode.com/threads/T-8232d41a-6872-4f4c-962c-7fae8f5e83b7
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 16:30:19 -07:00
Steve Yegge
8f80dde0ad Add global daemon auto-start support (bd-149)
- Implement shouldUseGlobalDaemon() with multi-repo detection
- Auto-detect 4+ beads repos and prefer global daemon
- Support BEADS_PREFER_GLOBAL_DAEMON env var for explicit control
- Add 'bd daemon --migrate-to-global' migration helper
- Update auto-start logic to use global daemon when appropriate
- Update documentation in AGENTS.md and README.md

Amp-Thread-ID: https://ampcode.com/threads/T-9af9372d-f3f3-4698-920d-e5ad1486d849
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 16:09:55 -07:00
Steve Yegge
5e0030d283 Add lifecycle management for beads-mcp processes (bd-148)
- Register atexit handler to close daemon connections
- Add signal handlers for SIGTERM/SIGINT for graceful shutdown
- Implement cleanup() to close all daemon client connections
- Track daemon clients globally for cleanup
- Add close() method to BdDaemonClient (no-op since connections are per-request)
- Register client on first use via _get_client()
- Add comprehensive lifecycle tests

This prevents MCP server processes from accumulating without cleanup.
Each tool invocation will now properly clean up on exit.

Amp-Thread-ID: https://ampcode.com/threads/T-05d76b8e-dac9-472b-bfd0-afe10e3457cd
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 14:27:37 -07:00
Steve Yegge
0baac7b22c Sync database export 2025-10-18 14:13:33 -07:00
Steve Yegge
bb13f4634b Fix daemon crash recovery race conditions (bd-147)
Improvements based on oracle code review:
- Move socket cleanup AFTER lock acquisition (prevents unlinking live sockets)
- Add PID liveness check before removing stale socket
- Add stale lock detection with retry mechanism
- Tighten directory permissions to 0700 for security
- Improve socket readiness probing with shorter timeouts
- Make removeOldSocket() ignore ENOENT errors

Fixes race condition where socket could be removed during daemon startup window,
potentially orphaning a running daemon process.

Amp-Thread-ID: https://ampcode.com/threads/T-63542c60-b5b9-4a34-9f22-415d9d7e8223
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 13:59:06 -07:00
Steve Yegge
9e2ee1889f Add daemon health check endpoint (bd-146)
- Add OpHealth RPC operation to protocol
- Implement handleHealth() with DB ping and 1s timeout
- Returns status (healthy/degraded/unhealthy), uptime, cache metrics
- Update TryConnect() to use health check instead of ping
- Add 'bd daemon --health' CLI command with JSON output
- Track cache hits/misses for metrics
- Unhealthy daemon triggers automatic fallback to direct mode
- Health check completes in <2 seconds

Amp-Thread-ID: https://ampcode.com/threads/T-1a4889f3-77cf-433a-a704-e1c383929f48
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 13:41:06 -07:00
Steve Yegge
f987722f96 Code review fixes for cache eviction (bd-145)
Oracle-recommended improvements:

**Thread Safety:**
- Fix lastAccess race: updates now under Write lock
- Make Stop() idempotent with sync.Once
- Close stores synchronously (not in goroutine)

**Performance:**
- Replace O(n²) sort with sort.Slice (O(n log n))
- Enforce LRU immediately on insert (prevents FD spikes)

**Correctness:**
- Canonicalize cache key to repo root (not cwd)
  - Prevents duplicate connections for same repo
  - Multiple subdirs → single cache entry
- Validate env vars: TTL <= 0 falls back to default

**Tests (6 new edge cases):**
- Canonical key behavior across subdirectories
- Immediate LRU enforcement without periodic cleanup
- Invalid TTL handling
- Re-open after eviction
- Stop idempotency
- All tests pass with -race flag

This addresses potential data races, resource spikes, and duplicate
connections identified during code review.
2025-10-18 13:24:59 -07:00
Steve Yegge
259e994522 Add storage cache eviction policy to daemon (bd-145)
Implemented TTL-based and LRU cache eviction for daemon storage connections:

- Add StorageCacheEntry with lastAccess timestamp tracking
- Cleanup goroutine runs every 5 minutes to evict stale entries
- TTL-based eviction: remove entries idle >30min (configurable)
- LRU eviction: enforce max cache size (default: 50 repos)
- Configurable via BEADS_DAEMON_MAX_CACHE_SIZE and BEADS_DAEMON_CACHE_TTL
- Proper cleanup on server shutdown
- Update lastAccess on cache hits
- Comprehensive tests for eviction logic

Fixes memory leaks and file descriptor exhaustion for multi-repo users.

Amp-Thread-ID: https://ampcode.com/threads/T-1148d8b3-b8a8-45fc-af9c-b5be14c4834d
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 13:17:07 -07:00
Steve Yegge
491cb82489 Add ready test for handling closed/blocked filter combinations
- Add test case for verifying --closed and --blocked filters don't apply to ready command
- Update issues.jsonl with new test-related issues

Amp-Thread-ID: https://ampcode.com/threads/T-1148d8b3-b8a8-45fc-af9c-b5be14c4834d
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 13:12:14 -07:00
Steve Yegge
9924c507ac Merge PR #81: Add Claude Code skill for beads usage patterns
Adds comprehensive skill documentation teaching Claude agents when and how
to use beads effectively, including decision criteria for bd vs TodoWrite,
workflow patterns, and integration guidance.
2025-10-18 12:08:23 -07:00
Steve Yegge
d2e34b863b Add --show-all-paths flag to bd dep tree
Implements bd-9: Allow users to view all paths through diamond dependencies
without deduplication. Useful for debugging complex dependency structures.

Changes:
- Added --show-all-paths flag to bd dep tree command
- Updated GetDependencyTree interface to accept showAllPaths parameter
- Modified deduplication logic to be conditional on flag
- Updated tests to pass new parameter

Amp-Thread-ID: https://ampcode.com/threads/T-43807dd5-8732-49ad-a839-cdb5dae70c35
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 11:52:57 -07:00
Steve Yegge
f44fc34761 renumbered database 2025-10-18 10:04:42 -07:00
Steve Yegge
6811d1cf42 Fix multiple issues and renumber database
- bd-170: Implement hybrid sorting for ready work (recent 48h first, then oldest)
- bd-87: Use safer null-byte placeholders in ID remapping
- bd-92: Make auto-flush debounce configurable via BEADS_FLUSH_DEBOUNCE
- bd-171: Fix nil pointer dereference in renumber command
- Delete spurious test issues (bd-7, bd-130-134)
- Renumber database from 171 down to 144 issues
2025-10-18 09:58:35 -07:00
spm1001
a373f8ab40 Clarify CLI vs MCP approach and context benefits 2025-10-18 17:58:04 +01:00
spm1001
7f93a602d2 Add Claude Code skill for beads usage
- Provides comprehensive workflow patterns and decision criteria
- Includes quick reference (SKILL.md) and detailed references
- Teaches when to use bd vs markdown/TodoWrite
- Covers dependency types and issue lifecycle management
- Complements existing plugin with usage philosophy
2025-10-18 17:54:46 +01:00
Steve Yegge
9d78a66dc3 new issues
Amp-Thread-ID: https://ampcode.com/threads/T-b66ca677-3810-44b1-bd13-4c887053f474
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 09:40:20 -07:00
Daan van Etten
86988fccf4 Fix nil pointer dereference in bd show command (#80)
The show command was crashing with a nil pointer dereference when
accessing issue.CompactionLevel. This occurred due to two issues in
the daemon mode response handling:

1. The IssueDetails struct incorrectly embedded *types.Issue as a
   pointer, causing the JSON unmarshaling to leave it nil. Changed
   to embed types.Issue directly.

2. Missing null check for non-existent issues. The daemon returns
   null when an issue is not found, which wasn't handled properly.

Added explicit null checking before parsing the response to provide
a clear error message when issues don't exist.

Fixes panic when running: bd show <non-existent-id>
2025-10-18 09:33:34 -07:00
Steve Yegge
82d8750e1f Migrate .golangci.yml to v2 format
- Removed invalid 'version: 2' field (must be string)
- Ran golangci-lint migrate to update to v2 schema
- Moved linters-settings -> linters.settings
- Moved issues.exclude-rules -> linters.exclusions.rules
- Moved issues.exclude -> linters.exclusions.rules with text field
- Config now validates successfully with golangci-lint v2.x

Amp-Thread-ID: https://ampcode.com/threads/T-d5fb1beb-0350-4a49-b8fa-ab752a82ef8e
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 09:08:50 -07:00
Steve Yegge
5f199a6c71 Update issues database
Amp-Thread-ID: https://ampcode.com/threads/T-d5fb1beb-0350-4a49-b8fa-ab752a82ef8e
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 09:05:05 -07:00
Steve Yegge
7cbc130fd7 Merge PR #78: Add Windows build support for daemon command 2025-10-18 00:44:23 -07:00
Steve Yegge
fb9b5864af feat: Add bd repos multi-repo commands and fix bd ready for in_progress issues
- Add 'bd repos' command for multi-repository management (bd-123)
  - bd repos list: show all cached repositories
  - bd repos ready: aggregate ready work across repos
  - bd repos stats: combined statistics across repos
  - bd repos clear-cache: clear repository cache
  - Requires global daemon (bd daemon --global)

- Fix bd ready to show in_progress issues (bd-165)
  - bd ready now shows both 'open' and 'in_progress' issues with no blockers
  - Allows epics/tasks ready to close to appear in ready work
  - Critical P0 bug fix for workflow

- Apply code review improvements to repos implementation
  - Use strongly typed RPC responses (remove interface{})
  - Fix clear-cache lock handling (close connections outside lock)
  - Add error collection for per-repo failures
  - Add context timeouts (1-2s) to prevent hangs
  - Add lock strategy comments

- Update documentation (README.md, AGENTS.md)
- Add comprehensive tests for both features

Amp-Thread-ID: https://ampcode.com/threads/T-1de989a1-1890-492c-9847-a34144259e0f
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 00:37:27 -07:00
Yunsik kim
fbb5e98293 fix: Add Windows build support for daemon command
- Split platform-specific daemon process configuration into separate files
- daemon_unix.go: Uses Setsid for Unix/Linux/macOS
- daemon_windows.go: Uses CREATE_NEW_PROCESS_GROUP for Windows
- Fixes compilation error: "unknown field Setsid in struct literal"

This allows bd.exe to build successfully on Windows while maintaining
proper daemon behavior on all platforms.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-18 15:59:03 +09:00
Steve Yegge
56a379dc5a Add GitHub Issues migration script (bd-68)
- New gh2jsonl.py script supports GitHub API and JSON file import
- Maps GitHub labels to bd priority/type/status
- Preserves metadata, assignees, timestamps, external refs
- Auto-detects cross-references and creates dependencies
- Production-ready: User-Agent, rate limit handling, UTF-8 support
- Comprehensive README with examples and troubleshooting
- Tested and reviewed

Amp-Thread-ID: https://ampcode.com/threads/T-2fc85f05-302b-4fc9-8cac-63ac0e03c9af
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 23:55:51 -07:00
Steve Yegge
9fb46d41b8 Implement daemon auto-start with comprehensive improvements (bd-124)
- Auto-starts daemon on first bd command (unless --no-daemon or BEADS_AUTO_START_DAEMON=false)
- Exponential backoff on failures: 5s, 10s, 20s, 40s, 80s, 120s (max)
- Lockfile prevents race conditions when multiple commands start daemon simultaneously
- Stdio redirected to /dev/null to prevent daemon output in foreground
- Uses os.Executable() for security (prevents PATH hijacking)
- Socket readiness verified with actual connection test
- Accepts multiple falsy values: false, 0, no, off (case-insensitive)
- Working directory set to database directory for local daemon context
- Comprehensive test coverage including backoff math and concurrent starts

Fixes:
- Closes bd-1 (won't fix - compaction keeps DBs small)
- Closes bd-124 (daemon auto-start implemented)

Documentation updated in README.md and AGENTS.md

Amp-Thread-ID: https://ampcode.com/threads/T-b10fe866-ab85-417f-9c4c-5d1f044c5796
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 23:42:57 -07:00
Steve Yegge
0dac4b9003 Fix global daemon implementation and improve security
- bd-159: Global daemon now runs in routing mode without opening DB
- bd-158: Set socket permissions to 0600 for security
- bd-160: Reject --auto-commit/--auto-push with --global
- bd-157: Verified stale socket cleanup (already working)
- bd-56: Closed as won't-do (cycle prevention is better)
- bd-73: Multi-repo support complete
2025-10-17 23:17:22 -07:00
Steve Yegge
0795797bac docs: Document multi-repo workflow with global daemon
Implements bd-122: Document how to use beads across multiple projects

Added comprehensive multi-repo documentation:
- README.md: Global daemon section with architecture diagram
- AGENTS.md: MCP multi-repo configuration (global daemon + per-project)
- integrations/beads-mcp/README.md: BEADS_WORKING_DIR usage
- Mermaid diagram showing one daemon serving multiple repos

Documentation covers:
- Global daemon (bd daemon --global) for system-wide usage
- Per-project MCP instances with BEADS_WORKING_DIR
- Comparison table (local vs global)
- When to use each approach
- Example workflows for multi-project setups

Benefits of global daemon:
- One daemon process for all repos
- Automatic socket discovery (local -> global fallback)
- Better resource usage
- Per-request context routing to correct database

Amp-Thread-ID: https://ampcode.com/threads/T-ea606216-b886-4af0-bba8-56d000362d01
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:49:22 -07:00
Steve Yegge
958bbc0853 feat(daemon): Add --global flag for multi-repo support
Implements bd-121: Global daemon with system-wide socket

Changes:
- Add --global flag to daemon command
- Use ~/.beads/bd.sock when --global is set
- Skip git repo validation for global daemon
- Update daemon discovery to check ~/.beads/ as fallback
- Both Go CLI and Python MCP client check global socket
- Update all tests to pass global parameter

Benefits:
- Single daemon serves all repos on system
- No per-repo daemon management needed
- Better resource usage for users with many repos
- Automatic fallback when local daemon not running

Usage:
  bd daemon --global         # Start global daemon
  bd daemon --status --global # Check global status
  bd daemon --stop --global   # Stop global daemon

Related: bd-73 (multi-repo epic)
Amp-Thread-ID: https://ampcode.com/threads/T-ea606216-b886-4af0-bba8-56d000362d01
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:45:33 -07:00
Steve Yegge
ad8f52eb87 fix(blocked): Add nil check for BlockedBy field
Fixes #74 - prevents panic when BlockedBy is nil

Amp-Thread-ID: https://ampcode.com/threads/T-ea606216-b886-4af0-bba8-56d000362d01
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:41:27 -07:00
Steve Yegge
3446bb0ee4 Merge pull request #76 from ghoseb/fix/windows-stdio-crash
fix(mcp): Fix AsyncIO crash on Windows
2025-10-17 22:25:42 -07:00
Steve Yegge
62bd4ff7c7 Merge pull request #75 from mshuffett/fix/mcp-plugin-bugs
fix(mcp): Fix three critical bugs in beads MCP plugin
2025-10-17 22:23:59 -07:00
Steve Yegge
048522c41a Add prefix validation to prevent wrong-database issue creation
Closes bd-156 (originally bd-151, remapped during auto-import)

Validates that explicit --id prefix matches database prefix from config.
Prevents accidental creation of issues with wrong prefix (e.g., creating
'bd-118' in a database configured for 'vc-' prefix).

Features:
- Checks issue_prefix from config table when --id is provided
- Fails with helpful error message showing the mismatch
- Suggests correct prefix format
- Adds --force flag to override validation if intentional
- Only validates in direct mode (daemon needs RPC enhancement)

Example: bd create 'Test' --id vc-99  # Error: prefix mismatch, use bd-99
  bd create 'Test' --id vc-99 --force  # OK, forced override
Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:20:18 -07:00
Steve Yegge
6ab9cc9a91 Fix inverted version comparison logic
Closes bd-149

The version mismatch warning was using string comparison (Version < dbVersion)
which incorrectly compared v0.9.10 < v0.9.9 as true (lexicographically '1' < '9').

Now uses golang.org/x/mod/semver.Compare for proper semantic versioning:
- v0.9.10 > v0.9.9 correctly returns 1 (binary is NEWER)
- v0.9.9 < v0.9.10 correctly returns -1 (binary is OUTDATED)

Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:14:36 -07:00
Steve Yegge
63c538616d Fix bd delete panic when daemon is running
Closes bd-155

When daemon is running, store is nil because PersistentPreRun returns
early after connecting to daemon. The delete command (both single and
batch) now falls back to direct storage access when store is nil,
following the pattern used by other commands like ready and blocked.

Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:06:21 -07:00
Steve Yegge
c17174b80a fix: bd list --status all showing 0 issues (bd-148)
The status filter was treating 'all' as a literal status value instead of
a special case meaning 'show all statuses'. This caused the SQL query to
filter for 'WHERE status = all' which matched no issues.

Fixed by checking if status is 'all' and skipping the filter in that case.

- Fix list.go to skip status filter when status == 'all'
- Update CHANGELOG with fix details
- All tests pass
2025-10-17 21:56:03 -07:00
Michael Shuffett
74b460b298 fix(mcp): Fix three critical bugs in beads MCP plugin
This PR fixes three bugs that prevented the MCP plugin from working:

1. **Fixed parameter name mismatch in tools.py**
   - Changed `workspace_root=workspace_root` to `working_dir=workspace_root`
   - The `create_bd_client()` function expects `working_dir` parameter,
     but tools.py was passing `workspace_root`
   - This caused "got an unexpected keyword argument 'workspace_root'" error

2. **Added version check guard for daemon client**
   - Added `hasattr(_client, '_check_version')` check before calling
   - BdDaemonClient doesn't have `_check_version()` method, only BdCliClient does
   - This caused "'BdDaemonClient' object has no attribute '_check_version'" error

3. **Implemented proper daemon socket detection for fallback**
   - Added synchronous socket file existence check before creating daemon client
   - Walks up directory tree looking for `.beads/bd.sock` file
   - Only creates daemon client if socket exists, otherwise falls back to CLI
   - Previously, daemon client was created but failed on first method call
   - This enables the documented "prefer_daemon with automatic CLI fallback" behavior

**Testing:**
- Verified MCP tools work correctly with single-repo setup
- Confirmed automatic fallback to CLI when daemon isn't running
- Tested on macOS with bd v0.9.9

**Related Issues:**
- Addresses symptoms similar to #65 (Windows BEADS_WORKING_DIR issue)
2025-10-17 21:16:19 -07:00
Baishampayan Ghose
67739fbdc7 fix(mcp): Fix AsyncIO crash on Windows
Since our implementation uses `async` IO for subprocess communication, it's
crucial to utilize the `fastMCP.run_async()` entry-point of FastMCP.

This should fix crashes on Windows.

ref: steveyegge/beads#53
2025-10-18 09:45:17 +05:30
Steve Yegge
ee94d817ed feat: Add batch deletion support (bd-127)
- Add DeleteIssues() method in sqlite.go for atomic batch deletion
- Support multiple issue IDs as arguments or from file
- Add --from-file flag to read IDs from file (supports comments)
- Add --dry-run mode for safe preview without deleting
- Add --cascade flag for recursive deletion of dependents
- Add --force flag to orphan dependents instead of failing
- Pre-collect connected issues before deletion for text reference updates
- Add orphan deduplication to prevent duplicate IDs
- Add rows.Err() checks in all row iteration loops
- Full transaction safety - all deletions succeed or none do
- Comprehensive statistics tracking (deleted, dependencies, labels, events)
- Update README and CHANGELOG with batch deletion docs

Fixed critical code review issues:
- Dry-run mode now properly uses dryRun parameter instead of deleting data
- Text references are pre-collected before deletion so they update correctly
- Added orphan deduplication and error checks
- Updated defer rollback pattern per Go best practices
2025-10-17 21:13:23 -07:00
Steve Yegge
c6ce88ebc7 Add Homebrew formula for v0.9.10 2025-10-17 19:33:14 -07:00
Steve Yegge
2678e572b9 Resolve merge conflict in issues.jsonl
Amp-Thread-ID: https://ampcode.com/threads/T-39c59655-3e0d-4060-85d1-cfcc7fa095ba
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 19:25:02 -07:00
Steve Yegge
52e2993bf6 chore: Bump version to 0.9.10
Updated all component versions:
- bd CLI: 0.9.9 → 0.9.10
- Plugin: 0.9.9 → 0.9.10
- MCP server: 0.9.9 → 0.9.10
- Documentation: 0.9.9 → 0.9.10

Generated by scripts/bump-version.sh
2025-10-17 18:15:29 -07:00
Steve Yegge
2b043b974f Auto-sync: export issues to JSONL 2025-10-17 18:15:13 -07:00
Steve Yegge
465e11cce2 Update AGENTS.md to recommend MCP server usage 2025-10-17 18:14:27 -07:00
Steve Yegge
e9729abd73 Fix bd-120: Fix nil pointer crash in export command when daemon is running
Amp-Thread-ID: https://ampcode.com/threads/T-f6d324a9-aa24-4cf8-9962-7391602c8c91
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 17:40:16 -07:00
Steve Yegge
afae421032 Sync issues: closed bd-105, bd-114, bd-115 2025-10-17 17:33:33 -07:00
Steve Yegge
ac5578d5f1 Complete daemon RPC with per-request context routing (bd-115)
- MCP server now uses daemon client by default with CLI fallback
- Added BEADS_USE_DAEMON environment variable (default: enabled)
- Created multi-repo integration test (all tests pass)
- Updated .gitignore for daemon runtime files
- Added SETUP_DAEMON.md with migration instructions
- Closed bd-105 (investigation complete) and bd-114 (multi-server confusion)

This enables single MCP server to handle multiple repos via daemon
with per-request context routing. No more multiple MCP server configs!

Amp-Thread-ID: https://ampcode.com/threads/T-c222692e-f6ef-4649-9726-db59470b82ef
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 16:55:14 -07:00
Steve Yegge
b40de9bc41 Implement daemon RPC with per-request context routing (bd-115)
- Added per-request storage routing in daemon server
  - Server now supports Cwd field in requests for database discovery
  - Tree-walking to find .beads/*.db from any working directory
  - Storage caching for performance across requests

- Created Python daemon client (bd_daemon_client.py)
  - RPC over Unix socket communication
  - Implements full BdClientBase interface
  - Auto-discovery of daemon socket from working directory

- Refactored bd_client.py with abstract interface
  - BdClientBase abstract class for common interface
  - BdCliClient for CLI-based operations (renamed from BdClient)
  - create_bd_client() factory with daemon/CLI fallback
  - Backwards-compatible BdClient alias

Next: Update MCP server to use daemon client when available
2025-10-17 16:28:29 -07:00
Steve Yegge
b8bcffba1d Complete script reorganization: move remaining scripts to scripts/ directory
Amp-Thread-ID: https://ampcode.com/threads/T-8d943ad6-b0ae-403c-94d0-8cce0feefa08
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 15:57:00 -07:00
Steve Yegge
5222f094f8 Document bd-105/bd-114 analysis: MCP context routing crisis
- bd-105: Comprehensive root cause analysis with 3 architectural paths
- bd-114: Documented as symptom of bd-105 (multi-server workaround backfire)
- Clarified daemon (v0.9.9) is orthogonal: solves concurrency, not routing
- Recommended solution: PATH 1 (SetContext/WhereAmI) - 8h effort, P0/P1
- Research complete: 1,034 misroutes quantified, MCP protocol analyzed

Amp-Thread-ID: https://ampcode.com/threads/T-8d943ad6-b0ae-403c-94d0-8cce0feefa08
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 15:55:19 -07:00
Daan van Etten
02d53ff3b5 Add fallback for 'bd blocked' command when daemon is running (#71)
The 'blocked' command doesn't have RPC support in the daemon yet.
When the daemon is running, store is nil, causing a panic.

This fix detects when daemon is running but store is nil, and opens
a direct database connection as a fallback. This allows the command
to work even when the daemon is active, until proper RPC support
is added.
2025-10-17 15:17:17 -07:00
Daan van Etten
991a2d995a Fix panic in 'bd stats' when daemon is running (#69)
The statsCmd was not checking if a daemon client was available before
trying to access the store directly. When the daemon is running, store
is nil, causing a panic.

This fix adds a check for daemonClient and uses RPC to get statistics
when the daemon is available, falling back to direct store access only
when running in direct mode.
2025-10-17 15:17:11 -07:00