Remove nodb_prefix.txt in favor of config.yaml

Remove support for the legacy .beads/nodb_prefix.txt file and use
the cleaner config.yaml approach exclusively for setting the issue
prefix. This simplifies the configuration system and makes it more
consistent.

Changes:
- Remove nodb_prefix.txt creation in cmd/bd/init.go
- Remove nodb_prefix.txt check in cmd/bd/nodb.go detectPrefix()
- Update error message to recommend config.yaml instead
- Update documentation to reflect config.yaml-only approach

New prefix detection order for --no-db mode:
1. issue-prefix in config.yaml (if set)
2. Common prefix from existing issues (if all share same prefix)
3. Current directory name (fallback)

Users should now set the prefix in .beads/config.yaml:
  issue-prefix: "myproject"

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:
Ryan Newton + Claude
2025-10-26 14:46:28 +00:00
parent 7cf36cec23
commit 2ba7b5b3a3
2 changed files with 6 additions and 22 deletions

View File

@@ -20,7 +20,7 @@ var initCmd = &cobra.Command{
Long: `Initialize bd in the current directory by creating a .beads/ directory
and database file. Optionally specify a custom issue prefix.
With --no-db: creates .beads/ directory and nodb_prefix.txt file instead of SQLite database.`,
With --no-db: creates .beads/ directory and issues.jsonl file instead of SQLite database.`,
Run: func(cmd *cobra.Command, _ []string) {
prefix, _ := cmd.Flags().GetString("prefix")
quiet, _ := cmd.Flags().GetBool("quiet")
@@ -96,14 +96,8 @@ With --no-db: creates .beads/ directory and nodb_prefix.txt file instead of SQLi
os.Exit(1)
}
// Handle --no-db mode: create nodb_prefix.txt instead of database
// Handle --no-db mode: create issues.jsonl file instead of database
if noDb {
prefixFile := filepath.Join(localBeadsDir, "nodb_prefix.txt")
if err := os.WriteFile(prefixFile, []byte(prefix+"\n"), 0644); err != nil {
fmt.Fprintf(os.Stderr, "Error: failed to write prefix file: %v\n", err)
os.Exit(1)
}
// Create empty issues.jsonl file
jsonlPath := filepath.Join(localBeadsDir, "issues.jsonl")
if _, err := os.Stat(jsonlPath); os.IsNotExist(err) {

View File

@@ -111,20 +111,10 @@ func loadIssuesFromJSONL(path string) ([]*types.Issue, error) {
// detectPrefix detects the issue prefix to use in --no-db mode
// Priority:
// 1. .beads/nodb_prefix.txt file (if exists)
// 2. issue-prefix from config.yaml (if set)
// 3. Common prefix from existing issues (if all share same prefix)
// 4. Current directory name (fallback)
// 1. issue-prefix from config.yaml (if set)
// 2. Common prefix from existing issues (if all share same prefix)
// 3. Current directory name (fallback)
func detectPrefix(beadsDir string, memStore *memory.MemoryStorage) (string, error) {
// Check for nodb_prefix.txt
prefixFile := filepath.Join(beadsDir, "nodb_prefix.txt")
if data, err := os.ReadFile(prefixFile); err == nil {
prefix := strings.TrimSpace(string(data))
if prefix != "" {
return prefix, nil
}
}
// Check config.yaml for issue-prefix
configPrefix := config.GetString("issue-prefix")
if configPrefix != "" {
@@ -152,7 +142,7 @@ func detectPrefix(beadsDir string, memStore *memory.MemoryStorage) (string, erro
// If issues have mixed prefixes, we can't auto-detect
if !allSame {
return "", fmt.Errorf("issues have mixed prefixes, please create .beads/nodb_prefix.txt with the desired prefix")
return "", fmt.Errorf("issues have mixed prefixes, please set issue-prefix in .beads/config.yaml")
}
}