Repository navigation
Open
Labels
contract:hook-managerTool capability: git-hook managers under the secure setup (install target, sandbox / host homes)family:setupsetup-* skillsgood first issueGood for newcomers
Description
The hook-manager contract (#1819) defines how the secure agent setup integrates a git-hook manager: where its install puts the hook, how its home is split between sandboxed and host runs, and how the setup detects that a repository uses it.
prek is the only adapter so far.
This issue adds husky (JavaScript), which needs a strategy the shim cannot provide.
What the source says (husky v9.1.7)
- Install target.
husky(the install) runsgit config core.hooksPath .husky/_: a repository-level value, written on every install (index.js:14).
A repository-levelcore.hooksPathoverrides the global one, so git never runs the whole-user dispatcher in a husky repository, and with it the host-only homes.
magpie-setup's session-start hook (drop_redundant_hooks_pathinsetup_preflight/isolated.py) reports this value today but does not remove it, because it does not point at.git/hooks. - Trigger. The npm
preparescript ("prepare": "husky", written byhusky init,bin.js:14), so it runs again on everynpm install.
npm putsnode_modules/.binfirst onPATH, so a~/.claude/bin/huskyshim never sees it. - Skip.
HUSKY=0skips the install entirely (index.js:9) and every hook run. - Home. No cache, but every hook sources
${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh(husky:11-12), so a hook runs code from the home directory.
Check whether any sandbox grant makes that file writable; if one can, it is the same escape the home rule exists for. - Generated hook.
.husky/_/<name>is. "$(dirname "$0")/h", andhfinds.husky/<name>from$0(husky:3-6): it must be exec'd by its real path, which the dispatcher already does for.git/hooks. - Detection. A
.husky/directory, or ahuskyentry inpackage.jsondevDependencies; hook marker.husky.
What to do
Pick and implement one strategy, and add it to the contract's install-strategy table:
- Chain to the repository's hooks path. When the repository-level
core.hooksPathis.husky/_, the session-start hook moves it to a Magpie-specific key (for examplemagpie.localHooksPath) and the dispatcher chains to<toplevel>/<that path>/<name>instead of.git/hooks/<name>.
husky rewrites the key on the nextnpm install, so the session-start hook has to keep doing it. - Or recommend
HUSKY=0for sandboxed installs and document how operators run husky hooks; weigh that this disables the repository's hooks for agent commits.
Then add the husky adapter to tools/hook-manager/registry.json, run tools/dev/sync-hook-managers.py, and update docs/setup/secure-agent-setup.md (the validated-behaviour table under Whole-user with the per-repo dispatcher).
Acceptance
- In a husky repository under the whole-user setup, a commit runs both the dispatcher and the repository's
.husky/pre-commit, and a failing husky hook still aborts the commit. - Tests for the session-start rewrite and the dispatcher chaining.
prek run --all-files --skip workspace-pytestand the affected tests pass.
Metadata
Metadata
Assignees
Labels
contract:hook-managerTool capability: git-hook managers under the secure setup (install target, sandbox / host homes)family:setupsetup-* skillsgood first issueGood for newcomers
Activity
Kaap10 commentedon Oct 26, 2026
A few thoughts on the two approaches:
Option A (Chaining via
magpie.localHooksPath) vs Option B (HUSKY=0):.husky/pre-commitand propagating failures to abort commits).core.hooksPathtomagpie.localHooksPathduring session-start and having the dispatcher chain to<toplevel>/<that path>/<name>preserves whole-user isolation without disabling repo checks.HUSKY=0) avoids rewrites but silences pre-commit hooks entirely during agent commits.On
${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh:sandbox.filesystem.allowWriteonly grants~/.cache/(not~/.config/), so sandboxed commands cannot write toinit.sh. Adding an explicitEdit(~/.config/husky/**)topermissions.denywould give clean defense-in-depth.Option A seems like the right path to meet the acceptance goals.
leninworld commentedon Oct 30, 2026
I’d like to work on this if it’s still available. I plan to take the chaining approach (Option A): keep the whole-user dispatcher, capture the repository’s configured
core.hooksPath(.husky/_for husky), and invoke the repository hook by its resolved real path, so both hooks run and a failing husky hook aborts the commit. The existing isolation safeguards should stay intact; if chaining turns out to conflict with them, I’ll raise it here before going further. I plan to add regression tests with real Git and husky covering both hooks running, failure propagation, repeated installs and linked worktrees. Nothing is implemented or tested yet. Could you assign this issue to me?AI-generated planning note (Codex), reviewed by Claude.
Kaap10 commentedon Oct 31, 2026
Go ahead @leninworld, we dont assign issues.