diff --git a/.beads/beads.jsonl b/.beads/beads.jsonl index 3237f457..7b1df755 100644 --- a/.beads/beads.jsonl +++ b/.beads/beads.jsonl @@ -65,5 +65,6 @@ {"id":"bd-68","title":"Test close issue","description":"","status":"closed","priority":1,"issue_type":"task","created_at":"2025-10-22T17:27:56.89475-07:00","updated_at":"2025-10-22T17:28:00.795511-07:00","closed_at":"2025-10-22T17:28:00.795511-07:00"} {"id":"bd-69","title":"Fix pre-existing MCP test failures - show/update return arrays not dicts","description":"9 tests fail in beads-mcp because bd CLI commands return arrays but MCP client expects dicts:\n\nFailing tests:\n- test_create_and_show_issue: show returns array, expects dict\n- test_update_issue: update returns array, expects dict \n- test_add_dependency: show returns array, expects dict\n- test_invalid_issue_id: show returns empty dict instead of error\n- test_dependency_types: show returns array, expects dict\n- test_show_issue_tool: show returns array, expects dict\n- test_update_issue_tool: update returns array, expects dict\n- test_update_partial_fields: update returns array, expects dict\n- test_client_lazy_initialization: BdClient import issue\n\nRoot cause: bd CLI commands like 'bd show' and 'bd update' output JSON arrays, but BdCliClient.show() and BdCliClient.update() expect single dict objects.\n\nExample:\n```bash\nbd show test-1 --json\n[{\"id\":\"test-1\",...}] # Array, not dict\n```\n\nFix needed: Update bd_client.py to handle array responses and extract first element, or change CLI to return single object for single-ID operations.","status":"in_progress","priority":1,"issue_type":"bug","created_at":"2025-10-22T17:43:23.29302-07:00","updated_at":"2025-10-22T17:47:06.900031-07:00"} {"id":"bd-7","title":"Write tests for merge functionality","description":"Unit tests: validation, merge logic, data integrity. Integration tests: end-to-end workflow, export/import. Edge case tests: chains, circular refs, epics.","status":"closed","priority":1,"issue_type":"task","created_at":"2025-10-21T23:53:44.31362-07:00","updated_at":"2025-10-22T11:56:36.523309-07:00","closed_at":"2025-10-22T01:07:04.72062-07:00"} +{"id":"bd-70","title":"Fix bd sync prefix mismatch error message suggesting non-existent flag","description":"GH #103: bd sync suggests using --rename-on-import flag that doesn't exist. Need to either implement the flag or fix the error message to suggest the correct workflow.","status":"open","priority":1,"issue_type":"bug","created_at":"2025-10-22T17:54:24.473508-07:00","updated_at":"2025-10-22T17:54:24.473508-07:00"} {"id":"bd-8","title":"Improve error handling in dependency removal during remapping","description":"In updateDependencyReferences(), RemoveDependency errors are caught and ignored with continue (line 392). Comment says 'if dependency doesn't exist' but this catches ALL errors including real failures. Should check error type with errors.Is(err, ErrDependencyNotFound) and only ignore not-found errors, returning other errors properly.","status":"closed","priority":3,"issue_type":"bug","created_at":"2025-10-21T23:53:44.31362-07:00","updated_at":"2025-10-22T11:56:36.523529-07:00","closed_at":"2025-10-18T09:41:18.209717-07:00"} {"id":"bd-9","title":"Test issue 2","description":"","status":"closed","priority":1,"issue_type":"task","created_at":"2025-10-21T23:53:44.31362-07:00","updated_at":"2025-10-22T11:56:36.523753-07:00","closed_at":"2025-10-21T22:06:41.257019-07:00","labels":["test-label"]} diff --git a/cmd/bd/sync.go b/cmd/bd/sync.go index 00af00cc..57f5ea53 100644 --- a/cmd/bd/sync.go +++ b/cmd/bd/sync.go @@ -34,6 +34,7 @@ This command wraps the entire git-based sync workflow for multi-device use.`, dryRun, _ := cmd.Flags().GetBool("dry-run") noPush, _ := cmd.Flags().GetBool("no-push") noPull, _ := cmd.Flags().GetBool("no-pull") + renameOnImport, _ := cmd.Flags().GetBool("rename-on-import") // Find JSONL path jsonlPath := findJSONLPath() @@ -112,7 +113,7 @@ This command wraps the entire git-based sync workflow for multi-device use.`, // Step 4: Import updated JSONL after pull fmt.Println("→ Importing updated JSONL...") - if err := importFromJSONL(ctx, jsonlPath); err != nil { + if err := importFromJSONL(ctx, jsonlPath, renameOnImport); err != nil { fmt.Fprintf(os.Stderr, "Error importing: %v\n", err) os.Exit(1) } @@ -146,6 +147,7 @@ func init() { syncCmd.Flags().Bool("dry-run", false, "Preview sync without making changes") syncCmd.Flags().Bool("no-push", false, "Skip pushing to remote") syncCmd.Flags().Bool("no-pull", false, "Skip pulling from remote") + syncCmd.Flags().Bool("rename-on-import", false, "Rename imported issues to match database prefix (updates all references)") rootCmd.AddCommand(syncCmd) } @@ -351,15 +353,21 @@ func exportToJSONL(ctx context.Context, jsonlPath string) error { } // importFromJSONL imports the JSONL file by running the import command -func importFromJSONL(ctx context.Context, jsonlPath string) error { +func importFromJSONL(ctx context.Context, jsonlPath string, renameOnImport bool) error { // Get current executable path to avoid "./bd" path issues exe, err := os.Executable() if err != nil { return fmt.Errorf("cannot resolve current executable: %w", err) } + // Build args for import command + args := []string{"import", "-i", jsonlPath, "--resolve-collisions"} + if renameOnImport { + args = append(args, "--rename-on-import") + } + // Run import command with --resolve-collisions to automatically handle conflicts - cmd := exec.CommandContext(ctx, exe, "import", "-i", jsonlPath, "--resolve-collisions") + cmd := exec.CommandContext(ctx, exe, args...) output, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("import failed: %w\n%s", err, output)