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:
@@ -18,14 +18,31 @@ import (
|
||||
// This is called when --no-db flag is set
|
||||
func initializeNoDbMode() error {
|
||||
// Find .beads directory
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get current directory: %w", err)
|
||||
var beadsDir string
|
||||
|
||||
// Check BEADS_DIR environment variable first
|
||||
if envDir := os.Getenv("BEADS_DIR"); envDir != "" {
|
||||
// Canonicalize the path
|
||||
if absDir, err := filepath.Abs(envDir); err == nil {
|
||||
if canonical, err := filepath.EvalSymlinks(absDir); err == nil {
|
||||
beadsDir = canonical
|
||||
} else {
|
||||
beadsDir = absDir
|
||||
}
|
||||
} else {
|
||||
beadsDir = envDir
|
||||
}
|
||||
} else {
|
||||
// Fall back to current directory
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get current directory: %w", err)
|
||||
}
|
||||
beadsDir = filepath.Join(cwd, ".beads")
|
||||
}
|
||||
|
||||
beadsDir := filepath.Join(cwd, ".beads")
|
||||
if _, err := os.Stat(beadsDir); os.IsNotExist(err) {
|
||||
return fmt.Errorf("no .beads directory found (hint: run 'bd init' first)")
|
||||
return fmt.Errorf("no .beads directory found (hint: run 'bd init' first or set BEADS_DIR)")
|
||||
}
|
||||
|
||||
jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
|
||||
|
||||
Reference in New Issue
Block a user