Steve Yegge
3fc8922c86
Refactor daemon runtime into internal/daemonrunner package
...
- Extract Daemon struct with Start/Stop methods
- Create focused modules: config, daemon, rpc, sync, git, process, logger
- Move platform-specific code to separate files (signals_*.go, flock_*.go)
- Add database fingerprint validation
- Keep import logic in cmd/bd for now (TODO: extract later)
- All builds pass, most daemon tests pass
Closes bd-b5a3
2025-11-01 20:02:30 -07:00
Steve Yegge
53e340e54f
Merge branch 'main' of github.com:steveyegge/beads
2025-11-01 20:02:24 -07:00
Steve Yegge
6076651d28
bd sync: 2025-11-01 20:02:23
2025-11-01 20:02:23 -07:00
Nikolai Prokoschenko
c65cfa1ebd
Add dependency and dependent counts to bd list JSON output ( #198 )
...
When using `bd list --json`, each issue now includes:
- `dependency_count`: Number of issues this issue depends on
- `dependent_count`: Number of issues that depend on this issue
This provides quick access to dependency relationship counts without
needing to fetch full dependency lists or run multiple bd show commands.
Performance:
- Uses single bulk query (GetDependencyCounts) instead of N individual queries
- Overhead: ~26% for 500 issues (24ms vs 19ms baseline)
- Avoids N+1 query problem that would have caused 2.2x slowdown
Implementation:
- Added GetDependencyCounts() to Storage interface for bulk counting
- Efficient SQLite query using UNION ALL + GROUP BY
- Memory storage implementation for testing
- Moved IssueWithCounts to types package to avoid duplication
- Both RPC and direct modes use optimized bulk query
Tests:
- Added comprehensive tests for GetDependencyCounts
- Tests cover: normal operation, empty list, nonexistent IDs
- All existing tests continue to pass
Backwards compatible: JSON structure is additive, all original fields preserved.
Generated with [Claude Code](https://claude.com/claude-code )
Co-authored-by: Claude <noreply@anthropic.com >
2025-11-01 19:59:15 -07:00
Midworld Kim
21ab565819
Fix hyphenated issue prefix detection ( #199 )
...
- update prefix/number parsing to use the last hyphen across utils and nodb paths
- add regression tests covering multi-hyphen prefixes in both packages
2025-11-01 19:57:37 -07:00
Steve Yegge
b5db80c412
Refactor sqlite.go: Extract hash IDs, batch ops, validators (bd-90a5, bd-c796, bd-d9e0)
...
- Extract hash ID generation to hash_ids.go (bd-90a5)
- generateHashID, getNextChildNumber, GetNextChildID
- Reduced sqlite.go from 1880 to 1799 lines
- Extract batch operations to batch_ops.go (bd-c796)
- validateBatchIssues, generateBatchIDs, bulkInsertIssues
- bulkRecordEvents, bulkMarkDirty, CreateIssues
- Reduced sqlite.go from 1799 to 1511 lines
- Extract validation functions to validators.go (bd-d9e0)
- validatePriority, validateStatus, validateIssueType
- validateTitle, validateEstimatedMinutes, validateFieldUpdate
- Reduced sqlite.go from 1511 to 1447 lines
- Add comprehensive validator tests (bd-3b7f)
- validators_test.go with full coverage
Total reduction: 2298 → 1447 lines (851 lines extracted, 37% reduction)
Part of epic bd-fc2d to modularize sqlite.go
All tests pass
Amp-Thread-ID: https://ampcode.com/threads/T-09c4383b-bc5c-455e-be24-02b4f9df7d78
Co-authored-by: Amp <amp@ampcode.com >
2025-11-01 19:55:48 -07:00
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