- Changed from substring matching to standalone line detection
- Only flags actual Git conflict markers on their own lines
- Prevents false alarms from conflict markers in issue descriptions
- Fixes bd-313
Amp-Thread-ID: https://ampcode.com/threads/T-2acdebf1-e4ce-4534-8538-4e7c4fb84232
Co-authored-by: Amp <amp@ampcode.com>
Implements the `bd` reopen command across the entire MCP stack, enabling
agents to reopen closed issues with optional reason tracking for audit
trails. This addresses the need to handle regressions and incorrectly
closed issues without manual `bd` CLI intervention.
The reopen command is more explicit than `bd update --status open` and
emits a dedicated Reopened event in the audit log, making it easier to
track why issues were reopened during analysis.
Changes:
- `models.py`: Add ReopenIssueParams with issue_ids list and optional reason
- `bd_client.py`: Implement reopen() method with JSON response parsing
- `tools.py`: Add beads_reopen_issue() wrapper with Annotated types for MCP
- `server.py`: Register 'reopen' MCP tool with description and parameters
Testing (10 new):
- `test_bd_client.py`: 4 unit tests (mocked subprocess)
- `test_bd_client_integration.py`: 3 integration tests (real `bd` CLI)
- `test_mcp_server_integration.py`: 3 MCP integration tests (FastMCP Client)
- `test_tools.py`: 3 tools wrapper tests (mocked BdClient)
Also updated `README.md`.
The collision resolver was failing when remapping issues to new IDs because
the issue_counters table was out of sync with actual database IDs. Test issues
(bd-200 through bd-312) were created without updating the counter, causing
UNIQUE constraint violations when --resolve-collisions tried to use those IDs.
Added SyncAllCounters() call before remapping to ensure counters reflect all
existing issues in the database. This prevents ID collisions during import.
Fixes the core functionality needed for multi-device git-based sync (bd-271).
Amp-Thread-ID: https://ampcode.com/threads/T-a2a94e1b-b220-41b0-bf7d-f2640a44292b
Co-authored-by: Amp <amp@ampcode.com>
- Remove type filter from cycle detection to check ALL dependency types
- Extract maxDependencyDepth=100 constant shared across AddDependency and DetectCycles
- Move cycle check before INSERT to avoid unnecessary write on failure
- Add comprehensive tests: self-dependency, related cycles, cross-type cycles
- Verify idx_dependencies_issue index exists for performance
Fixes bd-312. Prevents cross-type cycles (e.g., A blocks B, B parent-child A)
that previously hid work from ready list. Addresses oracle feedback for
proper implementation.
- Removed restore command from bd show output
- Updated compact help text (removed snapshot claim)
- Fixed COMPACTION.md (removed 'batch restore' from roadmap)
- All compaction UI now correctly states permanent decay
- Add EventCompacted event type constant
- Add compaction fields to Issue struct (CompactionLevel, CompactedAt, OriginalSize)
- Update ApplyCompaction to record compaction events with JSON metadata
- Update bd show to display compaction status with emoji indicators
- Update GetIssue query to load compaction fields
- All tests passing
Amp-Thread-ID: https://ampcode.com/threads/T-3f7946c6-8f5e-4a81-9527-1217041c7b39
Co-authored-by: Amp <amp@ampcode.com>
Snapshots defeated the entire purpose of compaction - if we're keeping
the original content, we're not actually saving any space. Compaction
is about graceful memory decay for agentic databases, not reversible
compression.
Removed:
- CreateSnapshot/GetSnapshots/RestoreFromSnapshot from storage
- --restore flag and functionality from bd compact command
- All snapshot-related tests
- Snapshot struct and related code
The database is ephemeral and meant to decay over time. Compaction
actually reduces database size now.
Closes bd-260 (won't fix - conceptually wrong)
Closes bd-261 (already done in bd-259)
- Add --label/-l flag to filter issues by labels (AND logic)
- Add --title flag to filter issues by title substring
- Add TitleSearch field to IssueFilter type
- Implement label and title filtering in SearchIssues
- Perfect for worktree-specific issue management
Examples:
bd list --label worktree,feature-x
bd list --title "authentication"
bd list --label worktree --title "bug"
- Fix unchecked error return in CreateIssues ROLLBACK (errcheck)
- Reduce cyclomatic complexity of CreateIssues from 28 to ~10 (gocyclo)
- Extract validateBatchIssues helper for validation phase
- Extract generateBatchIDs helper for ID generation
- Extract bulkInsertIssues helper for issue insertion
- Extract bulkRecordEvents helper for event recording
- Extract bulkMarkDirty helper for dirty marking
All refactored helpers maintain the same functionality and transaction safety.
Follows the same pattern used in main.go complexity reduction.
Breaks down large functions into smaller, focused helpers to pass gocyclo linter:
Auto-import refactoring:
- Extract parseJSONLIssues() to handle JSONL parsing
- Extract handleCollisions() to detect and report conflicts
- Extract importIssueData() to coordinate issue/dep/label imports
- Extract updateExistingIssue() and createNewIssue() for clarity
- Extract importDependencies() and importLabels() for modularity
Flush refactoring:
- Extract recordFlushFailure() and recordFlushSuccess() for state management
- Extract readExistingJSONL() to isolate file reading logic
- Extract fetchDirtyIssuesFromDB() to separate DB access
- Extract writeIssuesToJSONL() to handle atomic writes
Command improvements:
- Extract executeLabelCommand() to eliminate duplication in label.go
- Extract addLabelsToIssue() helper for label management
- Replace deprecated strings.Title with manual capitalization
Configuration:
- Add gocyclo exception for test files in .golangci.yml
All tests passing, no functionality changes.
* Fix error handling consistency in auto-import and fallback paths
- Add error checking/warnings for auto-import CRUD operations (UpdateIssue, CreateIssue, AddDependency)
- Add error checking/warnings for auto-import label operations (AddLabel, RemoveLabel)
- Add warning when import hash storage fails (prevents unnecessary re-imports)
- Add proper error handling for UserHomeDir with fallback to current directory
These changes make auto-import error handling consistent with manual operations
and prevent silent failures that could confuse users or cause data inconsistencies.
* Remove invalid version property from golangci-lint config
* Fix linter errors: errcheck, unused, goconst, and misspell
- Fix unchecked error returns in ROLLBACK statements
- Fix unchecked type assertion for status field
- Extract LIMIT SQL constant to reduce duplication
- Fix spelling: cancelled -> canceled
- Remove unused ensureCounterInitialized function
- Remove unused parameter in parallel test goroutine
- Add Compactor with CompactTier1 and CompactTier1Batch methods
- Single issue and batch compaction with 5 concurrent workers
- Dry-run mode for testing without API calls
- Smart size checking: keeps original if summary is longer
- Improved Haiku prompts to emphasize compression
- Add ApplyCompaction method for setting compaction metadata
- Comprehensive tests including API integration tests
- All tests passing
- Add comprehensive godoc to CreateIssues with usage examples
- Add batch operations section to EXTENDING.md with performance comparison
- Add performance feature to README.md
- Include when to use CreateIssue vs CreateIssues guidance
- Document counter sync requirement after explicit IDs
Amp-Thread-ID: https://ampcode.com/threads/T-59fc78c3-a7f2-4c33-b074-2fa840c97c87
Co-authored-by: Amp <amp@ampcode.com>
The skipUpdate flag should only apply to existing DB issues, not to
duplicates within the import batch. Batch duplicates always use
last-one-wins semantics.
- Replace CreateIssue loop with single CreateIssues batch call
- Add in-memory de-duplication for duplicate IDs (last one wins)
- 5-15x faster for bulk imports
- All tests pass
- Add CreateIssues method to Storage interface
- Implement SQLiteStorage.CreateIssues with atomic ID range reservation
- Single transaction for N issues (5-10x speedup expected)
- Set timestamps before validation to match CreateIssue behavior
- All tests passing
- Test add/remove labels
- Test multiple labels and duplicates
- Test label persistence across updates
- Test event creation for label operations
- Test labels with different issue types
- All 10 test cases passing
Enhance Graphviz dot output with status-based fill colors:
- open: white background (default)
- in_progress: light yellow background
- blocked: light coral background
- closed: light gray background with dimmed text
Node labels show: ID, type, priority, title, and status.
Priority is visible in the label (e.g., [bug P0]) but not color-coded
to keep the visualization clean and focused on status.
Add flexible --format flag to 'bd list' command supporting:
- Built-in presets: 'digraph' (basic 'from to' format) and 'dot' (Graphviz)
- Custom Go templates for dependency output
- Template variables: IssueID, DependsOnID, Type, Issue, Dependency
This enables graph analysis with tools like golang.org/x/tools/cmd/digraph while allowing users to customize output format for their specific needs.
Examples:
bd list --format=digraph | digraph nodes
bd list --format=dot | dot -Tsvg -o deps.svg
bd list --format='{{.IssueID}} -> {{.DependsOnID}} [{{.Type}}]'