refactor: remove deprecated .beads-wisp directory support (bd-bkul)

Wisps now use Wisp=true flag in the main database. The separate
.beads-wisp/ directory is no longer needed.

Removed:
- WispDirName constant
- FindWispDir()
- FindWispDatabasePath()
- NewWispStorage()
- EnsureWispGitignore()
- IsWispDatabase()
- All related tests
- .beads-wisp/ from .gitignore
This commit is contained in:
Steve Yegge
2025-12-24 21:30:20 -08:00
parent 94c3fa2b29
commit 5a46879741
3 changed files with 0 additions and 438 deletions
-152
View File
@@ -616,155 +616,3 @@ func FindAllDatabases() []DatabaseInfo {
return databases
}
// WispDirName is the default name for the wisp storage directory.
// This directory is a sibling to .beads/ and should be gitignored.
// Wisps are ephemeral molecules - the "steam" in Gas Town's engine metaphor.
//
// Deprecated: Wisps are now stored in the main database with Wisp=true.
// The separate .beads-wisp/ directory is no longer used ("bd-bkul").
const WispDirName = ".beads-wisp"
// FindWispDir locates or determines the wisp storage directory.
// The wisp directory is a sibling to the .beads directory.
//
// Returns the path to the wisp directory (which may not exist yet).
// Returns empty string if no .beads directory can be found.
//
// Deprecated: Wisps are now stored in the main database with Wisp=true.
// The separate .beads-wisp/ directory is no longer used ("bd-bkul").
func FindWispDir() string {
beadsDir := FindBeadsDir()
if beadsDir == "" {
return ""
}
// Wisp dir is a sibling to .beads
// e.g., /project/.beads -> /project/.beads-wisp
projectRoot := filepath.Dir(beadsDir)
return filepath.Join(projectRoot, WispDirName)
}
// FindWispDatabasePath returns the path to the wisp database file.
// Creates the wisp directory if it doesn't exist.
// Returns empty string if no .beads directory can be found.
//
// Deprecated: Wisps are now stored in the main database with Wisp=true.
// The separate .beads-wisp/ directory is no longer used ("bd-bkul").
func FindWispDatabasePath() (string, error) {
wispDir := FindWispDir()
if wispDir == "" {
return "", fmt.Errorf("no .beads directory found")
}
// Create wisp directory if it doesn't exist
if err := os.MkdirAll(wispDir, 0755); err != nil {
return "", fmt.Errorf("creating wisp directory: %w", err)
}
return filepath.Join(wispDir, CanonicalDatabaseName), nil
}
// NewWispStorage opens the wisp database for ephemeral molecule storage.
// Creates the database and directory if they don't exist.
// The wisp database uses the same schema as the main database.
// Automatically copies issue_prefix from the main beads config if not set.
//
// Deprecated: Wisps are now stored in the main database with Wisp=true.
// The separate .beads-wisp/ directory is no longer used ("bd-bkul").
func NewWispStorage(ctx context.Context) (Storage, error) {
dbPath, err := FindWispDatabasePath()
if err != nil {
return nil, err
}
wispStore, err := sqlite.New(ctx, dbPath)
if err != nil {
return nil, err
}
// Check if wisp db has issue_prefix configured
prefix, err := wispStore.GetConfig(ctx, "issue_prefix")
if err != nil || prefix == "" {
// Copy issue_prefix from main beads database
mainDBPath := FindDatabasePath()
if mainDBPath != "" {
mainStore, mainErr := sqlite.New(ctx, mainDBPath)
if mainErr == nil {
defer func() { _ = mainStore.Close() }()
mainPrefix, _ := mainStore.GetConfig(ctx, "issue_prefix")
if mainPrefix != "" {
if setErr := wispStore.SetConfig(ctx, "issue_prefix", mainPrefix); setErr != nil {
_ = wispStore.Close()
return nil, fmt.Errorf("setting wisp issue_prefix: %w", setErr)
}
}
}
}
}
return wispStore, nil
}
// EnsureWispGitignore ensures the wisp directory is gitignored.
// This should be called after creating the wisp directory.
//
// Deprecated: Wisps are now stored in the main database with Wisp=true.
// The separate .beads-wisp/ directory is no longer used ("bd-bkul").
func EnsureWispGitignore() error {
beadsDir := FindBeadsDir()
if beadsDir == "" {
return fmt.Errorf("no .beads directory found")
}
projectRoot := filepath.Dir(beadsDir)
gitignorePath := filepath.Join(projectRoot, ".gitignore")
// Check if .gitignore exists and already contains the wisp dir
content, err := os.ReadFile(gitignorePath)
if err == nil {
// File exists, check if already gitignored
lines := strings.Split(string(content), "\n")
for _, line := range lines {
line = strings.TrimSpace(line)
if line == WispDirName || line == WispDirName+"/" {
return nil // Already gitignored
}
}
}
// Append to .gitignore (or create it)
// #nosec G302 -- .gitignore is a public config file, 0644 is standard
f, err := os.OpenFile(gitignorePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return fmt.Errorf("opening .gitignore: %w", err)
}
defer f.Close()
// Add newline before if file doesn't end with one
if len(content) > 0 && content[len(content)-1] != '\n' {
if _, err := f.WriteString("\n"); err != nil {
return fmt.Errorf("writing to .gitignore: %w", err)
}
}
// Add the wisp directory
if _, err := f.WriteString(WispDirName + "/\n"); err != nil {
return fmt.Errorf("writing to .gitignore: %w", err)
}
return nil
}
// IsWispDatabase checks if a database path is a wisp database.
// Returns true if the database is in a .beads-wisp directory.
//
// Deprecated: Wisps are now stored in the main database with Wisp=true.
// The separate .beads-wisp/ directory is no longer used ("bd-bkul").
func IsWispDatabase(dbPath string) bool {
if dbPath == "" {
return false
}
dir := filepath.Dir(dbPath)
return filepath.Base(dir) == WispDirName
}