Commit Graph

2706 Commits

Author SHA1 Message Date
matt wilkie
dee16db0c0 fix: suppress gosec lint warnings for file operations
All file reads/writes are from controlled paths (.beads/, .git/, or git root).
Add #nosec comments to suppress G304 and G204 warnings.

- cmd/bd/doctor.go:664 - ReadFile from .beads/config.yaml
- cmd/bd/main.go:645 - ReadFile from .beads/{issues,beads}.jsonl
- cmd/bd/doctor/fix/database_config.go:166 - ReadFile from git root .gitattributes
- cmd/bd/doctor/fix/untracked.go:61 - exec Command with whitelisted JSONL files
2025-11-29 00:44:23 -07:00
matt wilkie
f134a3d658 fix: remove duplicate countIssuesInJSONLFile function
Fixes build failure in Test, Lint, Test (Windows), and Test Nix Flake jobs.
The function was defined in both init.go and doctor.go. Removed the init.go
version which is now unused. The doctor.go version (which calls
countJSONLIssues) is the canonical implementation.

Fixes #19780439467
2025-11-29 00:39:28 -07:00
Steve Yegge
4ef5a28afc bd sync: 2025-11-28 22:17:18 2025-11-28 22:17:18 -08:00
Steve Yegge
01dde64b82 bd sync: apply DB changes after import 2025-11-28 22:17:12 -08:00
Steve Yegge
b7ed7b376e bd sync: 2025-11-28 22:16:11 2025-11-28 22:16:11 -08:00
Steve Yegge
6f9d8d3add bd-c8x: Stop searching parent directories at git root
Directory discovery (FindBeadsDir, findDatabaseInTree, FindAllDatabases)
now stops at the git repository root to avoid finding unrelated databases
in parent directories (e.g., ~/.beads).

Added findGitRoot() helper that uses 'git rev-parse --show-toplevel'.

Also updated TestCheckDatabaseVersionJSONLMode to properly simulate
no-db mode by creating config.yaml with 'no-db: true'.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 22:16:11 -08:00
Steve Yegge
69e724f2ae bd sync: 2025-11-28 22:15:45 2025-11-28 22:15:45 -08:00
Steve Yegge
13b2ab6c95 feat(doctor): add fresh clone detection check (bd-4ew)
Add CheckFreshClone function that detects when JSONL contains issues
but no database exists. Recommends 'bd init --prefix <detected-prefix>'
to hydrate the database. This check appears early in doctor output
to guide users on fresh clones.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 22:15:34 -08:00
Steve Yegge
675b7a43b7 bd sync: 2025-11-28 22:14:57 2025-11-28 22:15:34 -08:00
Steve Yegge
3a4840169d fix(init): add safety guard to prevent overwriting existing data
bd init now refuses when:
- JSONL file exists with >0 issues (fresh clone scenario)
- Database file already exists (already initialized)

Suggests `bd doctor --fix` for fresh clones and provides clear guidance.
Added --force flag to bypass the safety guard when needed.

Closes: bd-emg

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 22:15:13 -08:00
Steve Yegge
a34c56c43a bd sync: 2025-11-28 22:14:57 2025-11-28 22:15:04 -08:00
Steve Yegge
46862568f6 bd-4ew: Doctor detects fresh clone and recommends 'bd init'
When JSONL exists but no database (and not no-db mode), doctor now:
- Shows 'Fresh clone detected' warning
- Shows count of issues in JSONL
- Recommends 'bd init' with detected prefix

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:59:59 -08:00
Steve Yegge
d782574667 bd sync: 2025-11-28 21:57:22 2025-11-28 21:57:22 -08:00
Steve Yegge
82595468a6 bd sync: 2025-11-28 21:57:15 2025-11-28 21:57:22 -08:00
Steve Yegge
247672be54 test: improve coverage for config and git packages
- config: Add tests for GetStringSlice, GetMultiRepoConfig, and nil viper
  behavior. Coverage improved from 65.3% to 84.0%.
- git: Add tests for error paths in RemoveBeadsWorktree, SyncJSONLToWorktree,
  CheckWorktreeHealth, and sparse checkout functions. Coverage improved
  from 72.9% to 82.7%.

Closes: bd-t3b, bd-4h3, bd-ge7

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:56:52 -08:00
Steve Yegge
61c61d5957 bd sync: 2025-11-28 21:56:17 2025-11-28 21:56:52 -08:00
Steve Yegge
9d896c3b28 bd-bok: Add --yes/-y flag to bd doctor --fix for non-interactive mode
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:56:33 -08:00
Steve Yegge
284d61420e bd sync: 2025-11-28 21:56:19 2025-11-28 21:56:19 -08:00
Steve Yegge
898d586329 bd sync: 2025-11-28 21:54:46 2025-11-28 21:54:46 -08:00
Steve Yegge
c9d6c434b6 bd sync: 2025-11-28 21:54:38 2025-11-28 21:54:45 -08:00
Steve Yegge
e18a75347b bd sync: 2025-11-28 21:53:48 2025-11-28 21:53:48 -08:00
Steve Yegge
eeab5e55e3 test(doctor): add test for beads.base.jsonl merge artifacts (bd-ov1)
Verify that beads.base.jsonl and beads.left.jsonl patterns are correctly
excluded from the 'multiple JSONL files' warning, same as issues.base.jsonl.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:52:48 -08:00
Steve Yegge
f493ca41c1 bd sync: 2025-11-28 21:52:23 2025-11-28 21:52:35 -08:00
Steve Yegge
36705eb1a7 bd sync: 2025-11-28 21:52:08 2025-11-28 21:52:08 -08:00
Steve Yegge
271e75801e bd sync: 2025-11-28 21:51:56 2025-11-28 21:52:03 -08:00
Steve Yegge
3eced4e5ca bd sync: 2025-11-28 2025-11-28 21:51:19 -08:00
Steve Yegge
40b86a15a7 fix(sync): cleanup snapshots after sync regardless of --no-pull (bd-0io)
Moved snapshot cleanup call to the end of successful sync, outside the
!noPull block. This ensures snapshot files (beads.base.jsonl, beads.left.jsonl)
are removed even when --no-pull is used.

Previously, captureLeftSnapshot was called before the pull block, but
cleanup was only inside the pull block, leaving orphaned files when
--no-pull was used.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:51:08 -08:00
Steve Yegge
efff0c9851 bd sync: 2025-11-28 21:50:04 2025-11-28 21:51:08 -08:00
Steve Yegge
a7db382fda Merge conflict resolution: bd-0io cleanup comment wording 2025-11-28 21:50:46 -08:00
Steve Yegge
d4154ca0ab bd sync: 2025-11-28 21:50:01 2025-11-28 21:50:14 -08:00
Steve Yegge
1cb855712f fix(sync): cleanup snapshot files at end of sync (bd-0io)
Add cleanup call at end of successful sync to ensure snapshot files
(beads.base.jsonl, beads.left.jsonl) are removed even when --no-pull
is used. Previously, captureLeftSnapshot was called before the pull
block, but cleanup was only inside the !noPull block, leaving orphaned
files.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:49:52 -08:00
Steve Yegge
b97703dbee bd sync: 2025-11-28 21:49:39 2025-11-28 21:49:39 -08:00
Steve Yegge
92b7524059 bd sync: 2025-11-28 21:46:29 2025-11-28 21:46:29 -08:00
Steve Yegge
b5d436ca39 bd sync: 2025-11-28 21:46:21 2025-11-28 21:46:21 -08:00
Steve Yegge
74aac72575 bd sync: 2025-11-28 21:46:12 2025-11-28 21:46:12 -08:00
Steve Yegge
447181e483 bd sync: 2025-11-28 21:46:03 2025-11-28 21:46:03 -08:00
Steve Yegge
8f71b5fa22 bd sync: 2025-11-28 19:50:16 2025-11-28 19:50:16 -08:00
Steve Yegge
044e2ddb57 bd sync: 2025-11-28 18:52:00 2025-11-28 18:52:00 -08:00
Jimmy Stridh
bb16f247c6 fix(init): error on invalid JSON instead of overwriting settings (#404)
Previously, setupClaudeSettings would silently create an empty settings
map when json.Unmarshal failed, then write just a prompt field to the
file - destroying all existing user settings (permissions, hooks, etc).

Now returns a clear error asking the user to fix the JSON syntax
manually, preserving their original file contents.

Also properly handles permission errors when reading existing files.

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

Co-authored-by: Jimmy Stridh <jimmystridh@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-11-28 18:51:27 -08:00
Steve Yegge
1ec78c0b13 bd sync: 2025-11-28 18:46:56 2025-11-28 18:46:56 -08:00
Steve Yegge
95371ea116 Export and display close reasons for issues (beads-410)
- Add CloseReason field to Issue struct in types.go
- Add GetCloseReason() and batch GetCloseReasonsForIssues()
- Update issue loading to populate close reasons
- Update scanIssues() to include close_reason in JSONL export
- Update bd show to display close reason after status

Close reasons now survive sync between repos.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 18:39:07 -08:00
Steve Yegge
4575087752 bd sync: 2025-11-28 18:38:41 2025-11-28 18:38:55 -08:00
Steve Yegge
c0d7f0974f bd sync: 2025-11-28 18:36:54 2025-11-28 18:36:54 -08:00
Steve Yegge
e395b45e0a bd sync: 2025-11-28 18:22:16 2025-11-28 18:22:16 -08:00
Steve Yegge
1eb2e1c7ee bd sync: 2025-11-28 18:22:06 2025-11-28 18:22:13 -08:00
Steve Yegge
6df2b44787 bd sync: 2025-11-28 17:43:30 2025-11-28 17:43:30 -08:00
Steve Yegge
fe4f851d33 Fix validatePostImport false positive for legitimate deletions (bd-pg1)
The sync validation was incorrectly triggering 'data loss detected' when
issue count decreased after import, even for legitimate deletions recorded
in deletions.jsonl.

Changes:
- Modified validatePostImport to accept jsonlPath and check deletions manifest
- When issue count decreases, check if decrease is within recorded deletions
- Updated all call sites in sync.go and daemon_sync.go
- Added comprehensive tests for deletion-aware validation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:43:25 -08:00
Steve Yegge
b33259a94e bd sync: 2025-11-28 17:43:02 2025-11-28 17:43:25 -08:00
Steve Yegge
6cd9e88472 bd sync: 2025-11-28 17:42:51 2025-11-28 17:42:51 -08:00
Steve Yegge
30197ee1ae bd-upd: Add snapshot cleanup to daemon sync function
After sync completion, orphan .base.jsonl and .left.jsonl files were
remaining in .beads/ directory. These are merge artifacts that should be
cleaned up after successful sync.

The fix adds SnapshotManager.Cleanup() call to createSyncFunc in
daemon_sync.go after successful import, matching the behavior of the CLI
sync command. Supports both single-repo and multi-repo modes.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:42:47 -08:00