fix(setup): wire the agent-guard hook into settings.local.json, not settings.json - #1115
fix(setup): wire the agent-guard hook into settings.local.json, not settings.json#1115AmirF194 wants to merge 2 commits into
Conversation
|
Flagging for whoever reviews this: #913 also touches the same "Hook wired in settings.json" bullet in |
|
Thanks for the review. The red |
…ettings.json The adopt flow committed the agent-guard PreToolUse wiring into the tracked .claude/settings.json while the script it invokes (.claude/hooks/agent-guard.py) stayed gitignored, synced in only by /magpie-setup. That split forced two prior workarounds for the same root cause: apache#786 guarded the command against a fresh clone that has the wiring but not yet the script, and apache#823 rewrote that guard for Windows, where the POSIX conditional does not run. Move the wiring itself into the gitignored, per-machine settings.local.json, written by Step 12 pass 1 at the same moment the script is deposited. Once wiring and script exist together on the same schedule, the fresh-clone race is gone and the command collapses to a plain `python3 "..."` call that runs the same on POSIX and Windows, so both the apache#786 guard and the apache#823 rewrite become unnecessary. This supersedes apache#823 and retro-justifies removing the apache#786 guard. Updates the merge/read/clean side for the same wiring across adopt.md (Step 12 pass 1, Step 2), worktree-init.md (Step 1d), unadopt.md, and verify.md, plus tools/agent-guard/README.md's documented snippet. The idempotent-merge Python (skip if already wired, preserve every other settings.local.json key and hooks.PreToolUse matcher, leave a hand-edited/corrupt file alone) is unchanged from the existing Step 12 pass 3 pattern for the sandbox-allowlist entry. Fixes apache#824 Generated-by: Claude Code (Sonnet 5)
e62c5c1 to
662cd63
Compare
|
Rebased onto main to resolve the conflict with #913 flagged above. Both bullets now point at install.md (the renamed file) while keeping the settings.local.json content from this PR. No other changes. |
…tall.md The apache#913 rebase repointed two of the three adopt.md links in this file but missed the one inside the settings.local.json wiring bullet this PR adds, which is what the CI link validator (prek, validate skills and tool contracts) has been failing on.
|
Found and fixed a leftover: the #913 rebase repointed two of the three |
Summary
.claude/settings.jsonwhile the script it invokes stays gitignored, which forced two prior workarounds for the same root cause (fix(agent-guard): make the PreToolUse hook a no-op until agent-guard.py is present #786, fix(agent-guard): make the fresh-clone hook guard cross-platform (Windows) #823)..claude/settings.local.json, written at the same moment the script is deposited, so the fresh-clone race that both workarounds guarded against no longer exists.Type of change
.claude/skills/<name>/): eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)Test plan
prek run --all-filespassesuv run pytest/ruff check/mypypassesprek run --all-files(installingprek's full tool set was not practical here):markdownlint-cli2andtyposon all 6 changed files (clean);skill-and-tool-validaterun directly withPYTHONPATHagainst the stdlib-only validator package (0 hard failures, same 29 pre-existing soft warnings on unrelated skills, none on the touched files). Could not run thelycheelink-check hook (itscargo installbuild ran the local disk near empty and was aborted); checked by hand instead that every link this diff adds or edits is an in-repo anchor (worktree-init.md#step-1d-...,adopt.md#step-10-...,adopt.md#step-12-...,../../tools/agent-guard/README.md) and confirmed each target heading/file exists on this branch. Also extracted the diff's own idempotent-merge Python and ran it standalone against five fixtures (missing file, unrelated existing keys, already-wired no-op, hand-corrupted JSON, a second pre-existingBashmatcher) to confirm the merge behaves as described in each case. Checkeddocs/vendor-neutrality.md's inputs (**Vendor:**/**Harness:**fields intools/agent-guard/README.md) are untouched by this diff, so thevendor-neutrality-scorehook has nothing to regenerate.RFC-AI-0004 compliance
<PROJECT>,<tracker>,<upstream>,<security-list>) used in all skill / tool prose (thecheck-placeholdersprek hook is the mechanical gate)Linked issues
Fixes #824
Notes for reviewers
.gitignorealready lists/.claude/settings.local.jsonas a base entry (Step 7), so nothing there needed to change; only the destination the docs point/magpie-setupat moved.