Commit Graph

1051 Commits

Author SHA1 Message Date
Steve Yegge
c840ba50bc Add comprehensive tests for show.go commands (bd-12c2)
Added test coverage for show, update, close, and edit commands in
cmd/bd/show_test.go:

- TestShowCommand (6 subtests): single/multiple issues, JSON output,
  dependencies, labels, compaction
- TestUpdateCommand (11 subtests): status, priority, title, assignee,
  description, design, notes, acceptance criteria, multiple fields/issues
- TestCloseCommand (4 subtests): single/multiple issues, JSON output,
  with/without reason
- TestEditCommand (1 subtest): argument validation

Key improvements:
- Properly sets global store variable to avoid "no issue found" errors
- Uses direct mode (BEADS_NO_DAEMON=1) for test isolation
- Follows existing test patterns from init_test.go and list_test.go
- All 22 test cases passing

Total cmd/bd coverage improved to 39.6%

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 20:29:17 -07:00
Steve Yegge
d8ff53a662 Merge remote changes 2025-10-31 20:28:58 -07:00
Steve Yegge
4fd1e20091 bd sync: 2025-10-31 20:28:38 2025-10-31 20:28:38 -07:00
Steve Yegge
b2d66b54e0 bd sync: 2025-10-31 20:21:25 2025-10-31 20:21:25 -07:00
Steve Yegge
fae597c4f5 Bump version to 0.21.0
Amp-Thread-ID: https://ampcode.com/threads/T-a9a67394-37ca-4b79-aa23-c5c011f9c0cd
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 20:21:15 -07:00
Steve Yegge
8cbcde134a Make event-driven mode the default
Event-driven daemon is now production-ready after hardening fixes in
commit 349b892. Making it the default for v0.21.0.

Users can still opt back to polling mode with BEADS_DAEMON_MODE=poll
if needed.

Benefits:
- <500ms sync latency (vs 5000ms with polling)
- ~60% less CPU usage
- Instant reactivity to mutations and file changes
- Fallback polling when file watcher unavailable

Amp-Thread-ID: https://ampcode.com/threads/T-a9a67394-37ca-4b79-aa23-c5c011f9c0cd
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 20:20:44 -07:00
Steve Yegge
8415639a32 bd sync: 2025-10-31 20:18:15 2025-10-31 20:18:15 -07:00
Steve Yegge
349b892123 Harden event-driven daemon for production
Three critical fixes to make event-driven mode production-ready:

1. Skip redundant imports: Check JSONL mtime vs DB mtime to avoid
   self-triggered import loops after export writes JSONL

2. Add server.Stop() in serverErrChan case: Ensures clean RPC
   server shutdown on errors

3. Fallback ticker (60s): When file watcher unavailable (e.g., network
   filesystems), fall back to periodic polling to detect remote changes

These minimal fixes address Oracle's concerns without over-engineering.
Event-driven mode is now safe for default.

Amp-Thread-ID: https://ampcode.com/threads/T-a9a67394-37ca-4b79-aa23-c5c011f9c0cd
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 20:18:05 -07:00
Steve Yegge
c460d00861 bd sync: 2025-10-31 20:15:58 2025-10-31 20:15:58 -07:00
Steve Yegge
7d73082d7e Fix duplicate pollution: filter closed issues from detection
- Closed issues no longer appear in duplicate scans
- Prevents infinite reappearance of merged duplicates
- Deleted 29 low-value closed issues to shrink DB
- Closes bd-c577

Amp-Thread-ID: https://ampcode.com/threads/T-51165824-9559-4696-919f-2c40459d5ef9
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 19:51:44 -07:00
Steve Yegge
76069a09dc Improve cmd/bd test coverage from 21% to 23.1% (bd-27ea)
Added comprehensive tests for:
- validate.go (parseChecks, validation results, orphaned deps, duplicates, git conflicts)
- restore.go (readIssueFromJSONL, git helpers)
- sync.go (git helpers, JSONL counting)

Progress: 21.0% → 23.1% (+2.1%)
Target: 40% (multi-session effort)
Amp-Thread-ID: https://ampcode.com/threads/T-540ebf64-e14f-4541-b098-586d2b07dc3e
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 19:44:43 -07:00
Steve Yegge
ef69d08afc Merge remote changes
Amp-Thread-ID: https://ampcode.com/threads/T-540ebf64-e14f-4541-b098-586d2b07dc3e
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 19:39:44 -07:00
Steve Yegge
5a34c6069f bd sync: 2025-10-31 19:39:38 2025-10-31 19:39:38 -07:00
Steve Yegge
a753ce1e50 bd sync: 2025-10-31 19:39:20 2025-10-31 19:39:20 -07:00
Steve Yegge
b7252c1a16 bd sync: 2025-10-31 19:38:14 2025-10-31 19:38:14 -07:00
Steve Yegge
1cc1e6615c Code review improvements to bd validate
Based on oracle feedback:
- Add parseChecks() helper for check normalization and validation
  - Supports synonyms: dupes→duplicates, git-conflicts→conflicts
  - Case-insensitive, whitespace-tolerant parsing
  - Deduplicates repeated checks while preserving order
  - Returns error for unknown checks (exit code 2)

- Fix JSON output robustness
  - Serialize errors as strings, not objects
  - Add 'failed' boolean per check
  - Fix 'healthy' to include error state

- Improve error handling
  - hasFailures() now includes check errors
  - Exit code 1 for any failures (issues or errors)
  - Exit code 2 for usage errors (invalid checks)

- Optimize database access
  - Single SearchIssues() call shared across checks
  - Only fetch if needed (orphans/duplicates/pollution)

- Stabilize output ordering
  - Print checks in deterministic order (not map iteration)
  - Use result.name for display labels

- Better UX
  - Unknown checks fail fast with helpful message
  - Deterministic output for CI/scripting
  - More robust JSON for machine consumption
2025-10-31 19:37:18 -07:00
Steve Yegge
75a118b47c bd sync: 2025-10-31 19:21:40 2025-10-31 19:21:40 -07:00
Steve Yegge
e2bb4311f1 Improve mutation channel robustness
- Add event type constants (MutationCreate, MutationUpdate, MutationDelete, MutationComment)
- Make buffer size configurable via BEADS_MUTATION_BUFFER (default 512, up from 100)
- Add defensive closed-channel handling in event loop consumer
- Add 1s dropped-events ticker (down from 60s) for faster recovery
- Verify mutationChan is never closed (prevents panic)

Oracle review findings addressed:
- Eliminates panic risk from send-on-closed-channel
- Reduces worst-case recovery latency from 60s to 1s
- Increases buffer capacity for better burst handling
- Type-safe event constants prevent string typos

Related: bd-36320a04, bd-1f4086c5
2025-10-31 19:12:02 -07:00
Steve Yegge
45504dde91 bd sync: 2025-10-31 19:10:08 2025-10-31 19:10:08 -07:00
Steve Yegge
e313e6e2c2 Improve test coverage for cmd/bd
- Add comprehensive version mismatch tests (checkVersionMismatch: 25% → 100%)
- Add daemon formatting helper tests (formatDaemonDuration, formatDaemonRelativeTime: 0% → 100%)
- Add auto-import test cases (checkAndAutoImport: 27.8% → 44.4%)
- Add compact eligibility test

Overall coverage: 47.9% → 48.3%
cmd/bd coverage: 20.5% → 21.0%

New test files:
- cmd/bd/autoflush_version_test.go (5 test functions)
- cmd/bd/daemons_test.go (2 test functions)

All tests passing.

Amp-Thread-ID: https://ampcode.com/threads/T-29fa5379-fd71-4f75-bc4f-272beff96c8f
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 18:40:32 -07:00
Steve Yegge
4fbff148f0 bd sync: 2025-10-31 18:27:27 2025-10-31 18:27:27 -07:00
Steve Yegge
7ad15fe524 Fix #188: Add --json flag to blocked command
- Added --json flag registration for blockedCmd
- Fixed blockedCmd to read json flag from cmd.Flags()
- All commands now consistently support --json for agent use
- Completes the fix started in earlier commits for show/update/close/stats
2025-10-31 18:15:13 -07:00
Steve Yegge
fa1d13af11 Fix #190: Clarify onboarding completion message
Changed 'confirm by saying' to 'tell your AI assistant' to make it clear
this is meant for the AI, not a bd command to run.
2025-10-31 18:12:40 -07:00
Steve Yegge
253caef761 Fix bd-e55c: Import respects updated_at timestamps
- Import now checks timestamps before updating issues
- Only applies updates if incoming version is newer than local
- Prevents older remote versions from overwriting newer local changes
- Added comprehensive tests for timestamp precedence
- Fixes issue where git pull would revert local changes to open status
2025-10-31 18:06:05 -07:00
Steve Yegge
19c1c1570d bd sync: 2025-10-31 18:05:57 2025-10-31 18:06:05 -07:00
Steve Yegge
4d2efdc7b3 test: add autoimport and utility function tests
- Test checkAndAutoImport with various conditions
- Test findBeadsDir and findBeadsDir in parent
- Test checkGitForIssues edge cases
- Test boolToFlag utility function
- cmd/bd coverage: 20.4% -> 20.5%
2025-10-31 18:04:29 -07:00
Steve Yegge
f1dd1e4446 test: improve internal/importer coverage from 33.5% to 70.5%
- Add comprehensive tests for ImportIssues main function
- Test basic import, updates, dry-run, dependencies, labels
- Test helper functions: getOrCreateStore, GetPrefixList
- All tests passing
2025-10-31 18:01:43 -07:00
Steve Yegge
5b342ff827 bd sync: apply rename detection from import 2025-10-31 17:56:47 -07:00
Steve Yegge
c2f7019786 bd sync: 2025-10-31 17:56:46 2025-10-31 17:56:47 -07:00
Steve Yegge
ddc04eb6f9 bd sync: 2025-10-31 17:54:26 2025-10-31 17:54:26 -07:00
Steve Yegge
9ae40eb3cd Merge branch 'main' of github.com:steveyegge/beads 2025-10-31 17:54:25 -07:00
Steve Yegge
54391798a0 Add tests for internal/importer field comparison functions
- Added tests for equalPtrStr (0% -> 100% coverage)
- Added tests for equalIssueType (50% -> 100% coverage)
- Improved internal/importer coverage from 31.2% to 33.5%
- Overall project coverage increased to 46.0%
2025-10-31 17:54:14 -07:00
Steve Yegge
48fdb3ee9c bd sync: 2025-10-31 17:54:06 2025-10-31 17:54:06 -07:00
Steve Yegge
cbd0bf0b53 bd sync: 2025-10-31 17:54:01 2025-10-31 17:54:01 -07:00
Steve Yegge
29f77b2220 bd sync: 2025-10-31 17:53:48 2025-10-31 17:53:49 -07:00
Steve Yegge
cd8cf997c9 Add comprehensive tests for internal/utils ID parsing functions
- Added tests for ExtractIssuePrefix (100% coverage)
- Added tests for ExtractIssueNumber (100% coverage)
- Enhanced ResolvePartialID tests with edge cases
- Added ResolvePartialIDs error handling tests
- Improved internal/utils coverage from 42% to 88%
- Overall project coverage increased from 45.6% to 45.8%

Amp-Thread-ID: https://ampcode.com/threads/T-1a44c987-7e49-431d-8e0b-467157d079eb
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 17:52:36 -07:00
Steve Yegge
a60ae8d2de bd sync: 2025-10-31 17:51:09 2025-10-31 17:51:09 -07:00
Steve Yegge
dd959d09cd bd sync: 2025-10-31 17:47:46 2025-10-31 17:47:46 -07:00
Steve Yegge
7eb315bbe0 bd sync: 2025-10-31 17:41:02 2025-10-31 17:41:04 -07:00
Steve Yegge
caf0161ed1 Add unit tests for nodb.go and daemon/discovery.go
- Added tests for extractIssuePrefix, loadIssuesFromJSONL, detectPrefix, writeIssuesToJSONL
- Added tests for walkWithDepth depth limiting and hidden directory skipping
- Added tests for DiscoverDaemons registry and legacy discovery paths
- Improved test coverage for cmd/bd and internal/daemon
2025-10-31 17:26:37 -07:00
Steve Yegge
8bf6b1eb63 Add unit tests for autoimport, importer, and main CLI
Amp-Thread-ID: https://ampcode.com/threads/T-b89cad6b-636f-477f-925d-4c3e3f769215
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 17:17:33 -07:00
Steve Yegge
d5483574fd Rebuild DB from JSONL after corruption cleanup
- Database had 72 duplicate issues from incomplete migration
- Sequential IDs (no content_hash) mixed with hash IDs
- Removed corrupt DB, rebuilt from JSONL (source of truth)
- 225 → 153 issues (duplicates eliminated)
- Updated config.json version to 0.20.1
2025-10-31 17:15:55 -07:00
Steve Yegge
a1b1b5b559 bd sync: 2025-10-31 17:15:49 2025-10-31 17:15:49 -07:00
Steve Yegge
33565f10db bd sync: 2025-10-31 15:12:13 2025-10-31 15:12:13 -07:00
Steve Yegge
39d5608497 Merge branch 'main' of github.com:steveyegge/beads
# Conflicts:
#	.beads/beads.jsonl
2025-10-31 15:12:08 -07:00
Steve Yegge
025166072c bd sync: 2025-10-31 15:12:02 2025-10-31 15:12:02 -07:00
Steve Yegge
ddab26315f Remove dead code found by deadcode analyzer
- Removed 5 unreachable functions (~200 LOC)
- computeIssueContentHash, shouldSkipExport from autoflush.go
- addDependencyUnchecked, removeDependencyIfExists from dependencies.go
- isUniqueConstraintError alias from util.go
- All tests still pass
- Closes bd-7c5915ae
2025-10-31 15:12:01 -07:00
Steve Yegge
aa567f6b9a feat: add Mermaid.js format for dependency tree visualization (#191)
Adds `bd dep tree --format mermaid` to export dependency trees as Mermaid.js flowcharts.

Features:
- Status indicators: ☐ open, ◧ in_progress, ⚠ blocked, ☑ closed
- Theme-agnostic design
- Works with --reverse flag
- Comprehensive unit tests following TDD

Co-authored-by: David Laing <david@davidlaing.com>
2025-10-31 15:11:29 -07:00
Steve Yegge
c070a9e7d4 bd sync: 2025-10-31 14:36:24 2025-10-31 14:36:24 -07:00
Steve Yegge
118d7541dd Add --json flag support to more bd commands
- stats: Added --json flag for programmatic output
- show, update: Added --json flag for issue details
- close, reopen: Added --json flag for bulk operations
- dep (add, remove, tree, cycles): Added --json flags
- label (add, remove, list, list-all): Added --json flags
- duplicates, merge: Added --json flags

Closes bd-4dcd2d09
2025-10-31 14:36:20 -07:00