Commit Graph

1077 Commits

Author SHA1 Message Date
Steve Yegge
cc7918daf4 Implement bd stale command (bd-c01f, closes #184)
- Add bd stale command to find abandoned/forgotten issues
- Support --days (default 30), --status, --limit, --json flags
- Implement GetStaleIssues in SQLite and Memory storage
- Add full RPC/daemon support
- Comprehensive test suite (6 tests, all passing)
- Update AGENTS.md documentation

Resolves GitHub issue #184

Amp-Thread-ID: https://ampcode.com/threads/T-f021ddb8-54e3-41bf-ba7a-071749663c1d
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 23:03:56 -07:00
Steve Yegge
645af0b72d bd daemon sync: 2025-10-31 22:58:01 2025-10-31 22:58:01 -07:00
Steve Yegge
2d6a32a7db Merge branch 'main' of github.com:steveyegge/beads 2025-10-31 22:39:54 -07:00
Steve Yegge
acb731a4ec bd sync: 2025-10-31 22:39:53 2025-10-31 22:39:53 -07:00
Steve Yegge
727aaf910e Add --json flag to delete command
Amp-Thread-ID: https://ampcode.com/threads/T-91803e1e-9e64-431e-87d8-d868ddab71d4
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 22:38:39 -07:00
Steve Yegge
c2d3ad2d63 Update issues 2025-10-31 22:08:32 -07:00
Steve Yegge
fbd3997a0e bd sync: 2025-10-31 22:08:18 2025-10-31 22:08:32 -07:00
Steve Yegge
079effdaeb Fix bd-373c: Surface daemon errors when multiple .db files exist
When daemon detects multiple .db files (after filtering .backup and vc.db),
it now writes detailed error to .beads/daemon-error file before exiting.

The error file is checked and displayed when:
- Daemon discovery fails to connect
- Auto-start fails to yield a running daemon
- User runs 'bd daemons list'

This makes the error immediately visible without requiring users to check
daemon logs.

Changes:
- cmd/bd/daemon.go: Write daemon-error file on multiple .db detection
- internal/daemon/discovery.go: Read and surface daemon-error in DaemonInfo.Error
- cmd/bd/main.go: Display daemon-error when auto-start fails

Amp-Thread-ID: https://ampcode.com/threads/T-1005a8d1-7a5a-4844-ad2d-2b8a6145825f
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 22:01:45 -07:00
Steve Yegge
31a936a4b4 bd sync: 2025-10-31 22:01:19 2025-10-31 22:01:45 -07:00
Steve Yegge
520af76234 Add comprehensive tests for create.go functionality
- Add 10 test cases covering basic creation, descriptions, design/acceptance
- Test labels, dependencies, discovered-from, explicit IDs, assignees
- Test all issue types and multiple dependencies
- All tests passing
- Maintains 27.6% coverage in cmd/bd

Amp-Thread-ID: https://ampcode.com/threads/T-2925a09a-b56d-4a2e-b79f-2d467c76feb2
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 21:51:54 -07:00
Steve Yegge
5a7e1b7c75 Fix bd sync git pull command to be explicit about remote and branch 2025-10-31 21:34:34 -07:00
Steve Yegge
816e7d5bfc bd sync: 2025-10-31 21:33:25 2025-10-31 21:33:25 -07:00
Steve Yegge
58609b2611 Update JSONL with closed issues 2025-10-31 21:27:33 -07:00
Steve Yegge
0b852f52d9 Remove obsolete renumber and stale commands, fix test
- Remove renumber.go: Hash IDs eliminated need for ID compaction
- Remove stale.go: Executor/heartbeat tables were never implemented
- Fix TestListCommand: duplicate dependency constraint violation
- Update comments removing references to removed commands

Amp-Thread-ID: https://ampcode.com/threads/T-3dcd8681-c7d3-4fe1-9750-b38279b56cdb
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 21:27:33 -07:00
Steve Yegge
af517b4b10 Enhance bd doctor with operational health checks (bd-40a0) 2025-10-31 21:27:05 -07:00
Steve Yegge
56cf62c538 bd sync: 2025-10-31 21:26:59 2025-10-31 21:26:59 -07:00
Steve Yegge
b138704179 bd sync: 2025-10-31 21:18:50 2025-10-31 21:18:50 -07:00
Steve Yegge
31fcb06059 Fix daemon crash when backup/vc.db files exist
- Changed backup file filtering from checking file extension (.backup) to checking if filename contains '.backup'
- This now properly filters files like 'beads.backup-pre-hash-20251030-171258.db'
- Also exclude vc.db from database detection
- Add strings import to beads.go
- Improve error message to suggest manual removal

Fixes bd-373c
2025-10-31 21:18:08 -07:00
Steve Yegge
2e21398982 bd sync: 2025-10-31 21:16:53 2025-10-31 21:16:53 -07:00
Steve Yegge
da48cdd841 bd sync: 2025-10-31 21:08:14 2025-10-31 21:08:14 -07:00
Steve Yegge
537b646968 bd sync: 2025-10-31 20:41:33 2025-10-31 20:41:34 -07:00
Steve Yegge
77142e9db3 Improve cmd/bd test coverage from 21% to 26.2%
- Add test for runCompactStats function (both JSON and regular output)
- Add tests for outputDotFormat and outputFormattedList functions
- Test dot format, digraph preset, custom templates, and error cases
- Coverage increased from 21.0% to 26.2% (5.2 percentage points)

Part of bd-27ea (multi-session effort to reach 40% coverage)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 20:40:04 -07:00
Steve Yegge
dedf3c5f3a bd sync: 2025-10-31 20:36:51 2025-10-31 20:36:51 -07:00
Steve Yegge
fbc95bcf11 bd sync: 2025-10-31 20:35:20 2025-10-31 20:35:20 -07:00
Steve Yegge
ebda4b4e6a Merge: accept remote JSONL 2025-10-31 20:35:20 -07:00
Steve Yegge
366ad6204e bd sync: 2025-10-31 20:35:08 2025-10-31 20:35:08 -07:00
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