beads/cmd/bd/setup
Vishnu J cad7e17d70
fix(setup/claude): keep settings.json's trailing newline and skip no-op rewrites (#5944)
* fix(setup/claude): keep settings.json's trailing newline and skip no-op rewrites (#5693)

bd setup claude (and bd init, which calls it) marshalled the Claude settings
map with json.MarshalIndent and wrote it unconditionally. MarshalIndent emits
no trailing newline, so every run stripped the one Claude Code's own writes
leave behind, and re-wrote the file even when no hook changed. Because bd init
git-adds .claude/settings.json, that surfaced as a staged diff with no
semantic content.

The same marshal-then-write pattern appears at four call sites in claude.go:
installClaude's settings write and its settings.local.json migration, and
removeClaude's settings write and its settings.local.json cleanup. Fixing one
would have left the bug live in the other three, so both halves are now shared
helpers -- marshalSettings appends the newline, writeSettingsIfChanged compares
against the bytes already on disk and returns early when they match -- and all
four sites go through them.

Reported by @maphew.

* chore(setup/claude): use the repo spelling "marshaled" in the new comments

The misspell linter flags British "marshalled"; CI pins golangci-lint
v2.10.1 and runs it with --new-from-merge-base, so both new comment lines
are in scope. Comment text only, no behaviour change.
2026-09-02 18:11:20 -07:00
..
agent_skill.go cleanup: remove unused private helpers (#4205) 2026-05-27 17:53:16 -07:00
agents.go test(dolt): add TestNoPushSkipsDoltPush for push guard coverage (#4323) 2026-06-20 13:23:40 -07:00
agents_marker_test.go fix(setup): clarify symlinked agents skip 2026-05-27 12:51:57 -07:00
aider.go fix(cli): printed doc paths point at the new docs locations 2026-07-12 10:37:17 -07:00
aider_test.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
claude.go fix(setup/claude): keep settings.json's trailing newline and skip no-op rewrites (#5944) 2026-09-02 18:11:20 -07:00
claude_test.go fix(setup/claude): keep settings.json's trailing newline and skip no-op rewrites (#5944) 2026-09-02 18:11:20 -07:00
codex.go fix(setup): migrate legacy Codex session hook (#4953) 2026-07-22 21:20:04 -07:00
codex_test.go fix(setup): migrate legacy Codex session hook (#4953) 2026-07-22 21:20:04 -07:00
constants.go feat: add context optimization features for AI agents (#297) 2025-11-12 10:48:36 -08:00
cursor.go feat(cursor): bring Cursor integration to parity with Claude/Codex (#4649) 2026-07-10 13:10:46 -07:00
cursor_test.go feat(cursor): bring Cursor integration to parity with Claude/Codex (#4649) 2026-07-10 13:10:46 -07:00
exit.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
factory.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
factory_test.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
gemini.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
gemini_test.go fix(setup): finish hook JSON migration 2026-05-08 09:21:39 -07:00
hooks_json.go feat(cursor): bring Cursor integration to parity with Claude/Codex (#4649) 2026-07-10 13:10:46 -07:00
junie.go feat: add bd unclaim command to release stuck issues (replaces #3694) (#4614) 2026-07-06 22:51:35 -07:00
junie_test.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
mux.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
mux_test.go fix(setup): harden symlink follow-up handling 2026-05-27 13:32:00 -07:00
opencode.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
opencode_test.go feat: add OpenCode recipe to bd setup 2026-03-03 13:39:56 -07:00
plugin_layout_test.go fix(plugin): make command argument hints strings (#4969) 2026-07-22 21:48:45 -07:00
setup_test_helpers.go : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
utils.go fix(setup): harden symlink follow-up handling 2026-05-27 13:32:00 -07:00
utils_test.go fix(setup): harden symlink follow-up handling 2026-05-27 13:32:00 -07:00