Add issue-prefix as a config.yaml option
Allow setting issue prefix via config.yaml that works independently of --no-db mode. This provides a consistent way to set the prefix across the entire repository. Precedence order: 1. --prefix flag (highest) 2. issue-prefix in config.yaml 3. .beads/nodb_prefix.txt (no-db mode only) 4. Auto-detect from directory name (lowest) Changes: - Add issue-prefix to config defaults in internal/config/config.go - Update cmd/bd/init.go to read from config before auto-detecting - Update cmd/bd/nodb.go detectPrefix to check config.yaml - Update .beads/config.yaml with documentation and example Usage: # .beads/config.yaml issue-prefix: "myproject" # Or via environment variable BD_ISSUE_PREFIX=myproject bd init This makes the prefix setting repository-scoped and automatically respected by bd init in both normal and no-db modes. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -3,6 +3,11 @@
|
|||||||
# All settings can also be set via environment variables (BD_* prefix)
|
# All settings can also be set via environment variables (BD_* prefix)
|
||||||
# or overridden with command-line flags
|
# or overridden with command-line flags
|
||||||
|
|
||||||
|
# Issue prefix for this repository (used by bd init)
|
||||||
|
# If not set, bd init will auto-detect from directory name
|
||||||
|
# Example: issue-prefix: "myproject" creates issues like "myproject-1", "myproject-2", etc.
|
||||||
|
# issue-prefix: ""
|
||||||
|
|
||||||
# Use no-db mode: load from JSONL, no SQLite, write back after each command
|
# Use no-db mode: load from JSONL, no SQLite, write back after each command
|
||||||
# When true, bd will use .beads/issues.jsonl as the source of truth
|
# When true, bd will use .beads/issues.jsonl as the source of truth
|
||||||
# instead of SQLite database
|
# instead of SQLite database
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/steveyegge/beads/internal/config"
|
||||||
"github.com/steveyegge/beads/internal/storage/sqlite"
|
"github.com/steveyegge/beads/internal/storage/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,6 +25,12 @@ With --no-db: creates .beads/ directory and nodb_prefix.txt file instead of SQLi
|
|||||||
prefix, _ := cmd.Flags().GetString("prefix")
|
prefix, _ := cmd.Flags().GetString("prefix")
|
||||||
quiet, _ := cmd.Flags().GetBool("quiet")
|
quiet, _ := cmd.Flags().GetBool("quiet")
|
||||||
|
|
||||||
|
// Initialize config (PersistentPreRun doesn't run for init command)
|
||||||
|
if err := config.Initialize(); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Warning: failed to initialize config: %v\n", err)
|
||||||
|
// Non-fatal - continue with defaults
|
||||||
|
}
|
||||||
|
|
||||||
// Check BEADS_DB environment variable if --db flag not set
|
// Check BEADS_DB environment variable if --db flag not set
|
||||||
// (PersistentPreRun doesn't run for init command)
|
// (PersistentPreRun doesn't run for init command)
|
||||||
if dbPath == "" {
|
if dbPath == "" {
|
||||||
@@ -32,6 +39,12 @@ With --no-db: creates .beads/ directory and nodb_prefix.txt file instead of SQLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine prefix with precedence: flag > config > auto-detect
|
||||||
|
if prefix == "" {
|
||||||
|
// Try to get from config file
|
||||||
|
prefix = config.GetString("issue-prefix")
|
||||||
|
}
|
||||||
|
|
||||||
if prefix == "" {
|
if prefix == "" {
|
||||||
// Auto-detect from directory name
|
// Auto-detect from directory name
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/steveyegge/beads/internal/config"
|
||||||
"github.com/steveyegge/beads/internal/storage/memory"
|
"github.com/steveyegge/beads/internal/storage/memory"
|
||||||
"github.com/steveyegge/beads/internal/types"
|
"github.com/steveyegge/beads/internal/types"
|
||||||
)
|
)
|
||||||
@@ -111,8 +112,9 @@ func loadIssuesFromJSONL(path string) ([]*types.Issue, error) {
|
|||||||
// detectPrefix detects the issue prefix to use in --no-db mode
|
// detectPrefix detects the issue prefix to use in --no-db mode
|
||||||
// Priority:
|
// Priority:
|
||||||
// 1. .beads/nodb_prefix.txt file (if exists)
|
// 1. .beads/nodb_prefix.txt file (if exists)
|
||||||
// 2. Common prefix from existing issues (if all share same prefix)
|
// 2. issue-prefix from config.yaml (if set)
|
||||||
// 3. Current directory name (fallback)
|
// 3. Common prefix from existing issues (if all share same prefix)
|
||||||
|
// 4. Current directory name (fallback)
|
||||||
func detectPrefix(beadsDir string, memStore *memory.MemoryStorage) (string, error) {
|
func detectPrefix(beadsDir string, memStore *memory.MemoryStorage) (string, error) {
|
||||||
// Check for nodb_prefix.txt
|
// Check for nodb_prefix.txt
|
||||||
prefixFile := filepath.Join(beadsDir, "nodb_prefix.txt")
|
prefixFile := filepath.Join(beadsDir, "nodb_prefix.txt")
|
||||||
@@ -123,6 +125,12 @@ func detectPrefix(beadsDir string, memStore *memory.MemoryStorage) (string, erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check config.yaml for issue-prefix
|
||||||
|
configPrefix := config.GetString("issue-prefix")
|
||||||
|
if configPrefix != "" {
|
||||||
|
return configPrefix, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Check existing issues for common prefix
|
// Check existing issues for common prefix
|
||||||
issues := memStore.GetAllIssues()
|
issues := memStore.GetAllIssues()
|
||||||
if len(issues) > 0 {
|
if len(issues) > 0 {
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ func Initialize() error {
|
|||||||
v.SetDefault("no-db", false)
|
v.SetDefault("no-db", false)
|
||||||
v.SetDefault("db", "")
|
v.SetDefault("db", "")
|
||||||
v.SetDefault("actor", "")
|
v.SetDefault("actor", "")
|
||||||
|
v.SetDefault("issue-prefix", "")
|
||||||
|
|
||||||
// Additional environment variables (not prefixed with BD_)
|
// Additional environment variables (not prefixed with BD_)
|
||||||
// These are bound explicitly for backward compatibility
|
// These are bound explicitly for backward compatibility
|
||||||
|
|||||||
Reference in New Issue
Block a user