Auto-import from git on empty DB (bd-189)
- Add checkAndAutoImport() that detects empty DB with issues in git - Automatically imports from git HEAD:.beads/issues.jsonl - Integrated into list, ready, and stats commands - Zero cognitive load for agents in fresh clones - Makes JSONL truly the source of truth - DB becomes ephemeral cache that auto-rebuilds Also: - Update AGENTS.md onboarding section with import instructions - Merge PR #98 (enhanced .gitignore) Amp-Thread-ID: https://ampcode.com/threads/T-ffcb5e95-e5a0-486b-a0ae-ce8bd861ab9d Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -91,10 +91,22 @@ var readyCmd = &cobra.Command{
|
||||
ctx := context.Background()
|
||||
issues, err := store.GetReadyWork(ctx, filter)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// If no ready work found, check if git has issues and auto-import
|
||||
if len(issues) == 0 {
|
||||
if checkAndAutoImport(ctx, store) {
|
||||
// Re-run the query after import
|
||||
issues, err = store.GetReadyWork(ctx, filter)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
// Always output array, even if empty
|
||||
if issues == nil {
|
||||
@@ -225,10 +237,22 @@ var statsCmd = &cobra.Command{
|
||||
ctx := context.Background()
|
||||
stats, err := store.GetStatistics(ctx)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// If no issues found, check if git has issues and auto-import
|
||||
if stats.TotalIssues == 0 {
|
||||
if checkAndAutoImport(ctx, store) {
|
||||
// Re-run the stats after import
|
||||
stats, err = store.GetStatistics(ctx)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
outputJSON(stats)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user