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>
This commit is contained in:
Steve Yegge
2025-11-02 18:34:34 -08:00
parent c5b2fbbc9d
commit 6ecfd04ec8
8 changed files with 187 additions and 54 deletions
+8 -3
View File
@@ -146,7 +146,8 @@ This means bd found multiple `.beads` directories in your directory hierarchy. T
1. **If you have nested projects** (intentional):
- This is fine! bd is designed to support this
- Just be aware which database you're using
- Set `BEADS_DB` environment variable if you want to override the default selection
- Set `BEADS_DIR` environment variable to point to your `.beads` directory if you want to override the default selection
- Or use `BEADS_DB` (deprecated) to point directly to the database file
2. **If you have accidental duplicates** (unintentional):
- Decide which database to keep
@@ -156,10 +157,14 @@ This means bd found multiple `.beads` directories in your directory hierarchy. T
3. **Override database selection**:
```bash
# Temporarily use specific database
BEADS_DB=/path/to/.beads/issues.db bd list
# Temporarily use specific .beads directory (recommended)
BEADS_DIR=/path/to/.beads bd list
# Or add to shell config for permanent override
export BEADS_DIR=/path/to/.beads
# Legacy method (deprecated, points to database file directly)
BEADS_DB=/path/to/.beads/issues.db bd list
export BEADS_DB=/path/to/.beads/issues.db
```