Commit Graph

1111 Commits

Author SHA1 Message Date
Steve Yegge
537844cb11 Fix bd-36870264: Prevent nested .beads directories with path canonicalization
- Add filepath.Abs() + EvalSymlinks() to FindDatabasePath() to normalize all database paths
- Add nested .beads directory detection in setupDaemonLock() with helpful error messages
- Prevents infinite .beads/.beads/.beads/ recursion when using relative BEADS_DB paths
- All acceptance criteria passed: singleton enforcement, lock release, no recursion

Amp-Thread-ID: https://ampcode.com/threads/T-c7fc78b8-a935-48dc-8453-a1bd47a14f72
Co-authored-by: Amp <amp@ampcode.com>
2025-11-01 19:50:34 -07:00
Steve Yegge
ce9a5164f7 Close daemon refactoring tasks and create sqlite.go refactor epic 2025-11-01 19:33:53 -07:00
Steve Yegge
3733b12f7b bd sync: 2025-11-01 19:29:40 2025-11-01 19:29:40 -07:00
Steve Yegge
a708c321fb Fix bd-11e0: Auto-upgrade database version in daemon instead of exiting 2025-11-01 19:28:37 -07:00
Steve Yegge
a4b9ae5fcf bd sync: 2025-11-01 19:28:32 2025-11-01 19:28:32 -07:00
Steve Yegge
72c4c908db bd sync: 2025-11-01 19:20:28 2025-11-01 19:20:28 -07:00
Steve Yegge
eb00ab8005 Refactor daemon.go for testability and maintainability (bd-2b34)
- Split 1567-line daemon.go into 5 focused modules
- daemon_config.go (122 lines): config/path resolution
- daemon_lifecycle.go (451 lines): start/stop/status/health/metrics
- daemon_sync.go (510 lines): export/import/sync logic
- daemon_server.go (115 lines): RPC server setup
- daemon_logger.go (43 lines): logging utilities
- Reduced main daemon.go to 389 lines (75% reduction)
- All tests pass, improved code organization

Amp-Thread-ID: https://ampcode.com/threads/T-7504c501-f962-4b82-a6d9-8e33f547757d
Co-authored-by: Amp <amp@ampcode.com>
2025-11-01 19:20:01 -07:00
Steve Yegge
d80e7a5fd2 Fix bd-6c68: preserve actual daemon failure reasons in bd info
Don't override connect_failed/health_failed with auto_start_disabled.
This preserves important diagnostic information about whether the
daemon crashed vs. was never running.

Amp-Thread-ID: https://ampcode.com/threads/T-a8da544a-3e59-4293-903c-ce6be85fc28b
Co-authored-by: Amp <amp@ampcode.com>
2025-11-01 19:14:24 -07:00
Steve Yegge
4879b1a8c4 bd sync: 2025-11-01 19:14:04 2025-11-01 19:14:04 -07:00
Steve Yegge
b5839b656d Fix compilation errors in internal/daemonrunner package
Created missing files:
- logger.go: Logger type, setupLogger method, and env helpers
- signals_unix.go: Unix signal definitions (SIGTERM, SIGINT, SIGHUP)
- signals_windows.go: Windows signal definitions
- sync.go: Sync loop implementation with export/import/validation helpers

Fixed errors:
- Added missing 'version' parameter to acquireDaemonLock call
- Removed duplicate setupLock method from process.go (kept in daemon.go)
- Removed duplicate startRPCServer from daemon.go (kept in rpc.go)
- Fixed LogPath -> LogFile config field reference
- Removed unused 'io' import from process.go

Implementation notes:
- exportToJSONL: Full implementation with dependencies, labels, comments
- importFromJSONL: Placeholder (TODO: extract from cmd/bd/import.go)
- countDBIssues: Uses SQL COUNT(*) optimization with fallback
- validatePostImport: Checks for data loss
- runSyncLoop/runEventLoop: Main daemon event loops with signal handling

All packages now compile successfully with 'go build ./...'

Amp-Thread-ID: https://ampcode.com/threads/T-36a7f730-3420-426f-9e23-f13d5fa089c4
Co-authored-by: Amp <amp@ampcode.com>
2025-11-01 19:10:27 -07:00
Steve Yegge
cbe70aa2c3 bd sync: 2025-11-01 17:00 2025-11-01 17:05:51 -07:00
Steve Yegge
f8ef180239 Fix bd-e652: Improve bd doctor daemon health checks
- Use path normalization (EvalSymlinks) to reliably match daemons across symlinks
- Check for stale sockets directly (catches cases where RPC failed)
- Detect multiple daemons for same workspace
- Enhanced error details for stale daemon detection
- Use global daemon registry instead of path-scoped discovery
2025-11-01 17:05:47 -07:00
Steve Yegge
87c60d1f43 bd sync: 2025-11-01 17:05:41 2025-11-01 17:05:41 -07:00
Steve Yegge
965e6af705 bd sync: 2025-11-01 16:56:12 2025-11-01 16:56:12 -07:00
Steve Yegge
70358d02c9 Add two-repo daemon auto-import test for bd-09b5f2f5
Test proves the bug exists:
- Agent A closes issue and pushes
- Agent B does git pull (JSONL shows 'closed')
- Daemon query returns 'open' (stale SQLite)

Test currently fails, confirming daemon doesn't auto-import
after git pull updates JSONL. Will pass once fix is complete.
2025-11-01 12:41:49 -07:00
Steve Yegge
1bdf6e0fbe bd sync: 2025-11-01 12:24:02 2025-11-01 12:24:02 -07:00
Steve Yegge
e5a3f8ce25 Add quoting guidance to AGENTS.md and SKILL.md
Fixes #194 - Claude Code was failing to quote titles/descriptions with
special characters. Added explicit warnings and examples showing proper
quoting for arguments containing spaces, apostrophes, and special chars.

Amp-Thread-ID: https://ampcode.com/threads/T-0570ff80-8115-479d-b39c-dbdf2ada5215
Co-authored-by: Amp <amp@ampcode.com>
2025-11-01 12:23:39 -07:00
Steve Yegge
d12b5b7221 Fix bd doctor to respect custom database names from config.json
Fixes #197: bd doctor was hardcoded to look for beads.db and didn't
check config.json for custom database names like beady.db.

Now both checkDatabaseVersion() and checkIDFormat() check config.json
first before falling back to the canonical database name.
2025-11-01 11:56:48 -07:00
Steve Yegge
94f2dc1198 WIP: Extract daemon runtime into internal/daemonrunner
- Created config.go with Config struct
- Created daemon.go with Daemon struct and Start/Stop methods
- Created logger.go for logging setup
- Created process.go for lock/PID management
- Created fingerprint.go for database validation
- Created flock_unix.go/flock_windows.go for platform-specific locking
- Created git.go for git operations

Still TODO:
- Implement runGlobalDaemon, startRPCServer, runSyncLoop
- Create sync.go, rpc.go, jsonl.go, validation.go
- Update cmd/bd/daemon.go to use daemonrunner

Part of bd-5f26
2025-11-01 11:47:41 -07:00
Steve Yegge
95560dc6e8 Add refactoring issues for sqlite.go and daemon.go 2025-11-01 11:41:29 -07:00
Steve Yegge
a4b4778ced test: improve coverage for importer and sqlite utils
- Fix TestImportIssues_Update by adding timestamps to test issue
- Add comprehensive tests for sqlite utility functions (IsUniqueConstraintError, QueryContext, BeginTx, ExecInTransaction)
- Coverage improvements: sqlite util.go 0% -> 95%, sqlite package 56.4% -> 57.1%

Amp-Thread-ID: https://ampcode.com/threads/T-17e6a3e4-f881-4f53-b670-bdd796d58f68
Co-authored-by: Amp <amp@ampcode.com>
2025-11-01 11:35:31 -07:00
Steve Yegge
48469585b4 Close bd-2530 and bd-373c 2025-11-01 11:16:25 -07:00
Steve Yegge
69e2144e88 Improve cmd/bd test coverage to 42.9%
- Add epic_test.go with 3 tests for epic functionality
- Enhance compact_test.go with dry-run scenario tests
- Test epic-child relationships via dependencies
- All tests passing

Closes bd-27ea

Amp-Thread-ID: https://ampcode.com/threads/T-d88e08a0-f082-47a3-82dd-0a9b9117ecbf
Co-authored-by: Amp <amp@ampcode.com>
2025-11-01 11:11:20 -07:00
Steve Yegge
be109512ad Merge branch 'main' of github.com:steveyegge/beads 2025-11-01 11:07:44 -07:00
Steve Yegge
d163b797e0 bd sync: 2025-11-01 11:07:43 2025-11-01 11:07:43 -07:00
goreleaserbot
a49a341832 Brew formula update for beads version v0.21.2 2025-11-01 18:07:10 +00:00
Steve Yegge
edf6008f63 Fix GoReleaser homebrew config: use 'directory' not 'folder' 2025-11-01 11:04:09 -07:00
Steve Yegge
77819ff63c chore: Bump version to 0.21.2 2025-11-01 10:43:38 -07:00
Steve Yegge
e05c898987 Update CHANGELOG for 0.21.2 2025-11-01 10:43:12 -07:00
Steve Yegge
0c9a6ab72a Configure GoReleaser to publish Homebrew formula in main repo 2025-11-01 10:42:07 -07:00
Steve Yegge
731ab31dc6 chore: Bump version to 0.21.1 2025-10-31 23:47:20 -07:00
Steve Yegge
fc2213dfe4 Auto-sync beads database 2025-10-31 23:46:56 -07:00
Steve Yegge
6e0dee17d2 Update CHANGELOG for 0.21.1 2025-10-31 23:46:50 -07:00
Steve Yegge
5d64c09237 bd sync: 2025-10-31 23:04:08 2025-10-31 23:04:08 -07:00
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