Repository navigation
Description
~/.kit/bin/kit is the machine-wide wrapper every kit hook goes through, in every repo. It is written with the entrypoint of whichever kit happened to write it — so running kit once from a git checkout points the whole machine's enforcement floor at a build artifact that is deleted on the next npm run build.
Measured today: a session in an unrelated repo failed with
PreToolUse:Bash hook error
Failed with non-blocking status code: [kit] hook cannot start:
kit CLI entrypoint missing: /Users/…/kit-public/dist/cli.js
while a build was running in the kit checkout. The hook died; the session continued ungated.
Mechanism
// src/kit-wrapper.ts:162
const cliEntry = opts.cliPath ?? (process.argv[1] ? resolve(process.argv[1]) : undefined);ensureKitWrapper() is called from commands/hooks.ts:80, commands/hooks.ts:253, commands/memory.ts:1075 and agent-config.ts:1709. Any of those, run as node dist/cli.js … from a development checkout, rewrites the machine-wide wrapper to:
exec "…/node" "/Users/…/kit-public/dist/cli.js" "$@"The wrapper before and after regenerating it with the globally installed kit:
before: exec node /Users/…/Development/claude_code/kit-public/dist/cli.js
after: exec /usr/local/bin/node /Users/…/.npm-global/bin/kit
Why this is worse than a stale path
- A repo-local command has a machine-wide effect.
kit hooks add secret-scaninside a throwaway temp directory rewrote~/.kit/bin/kitfor every repo on the machine. Nothing in the command's output says so. - A dev build is transient by design.
npm run buildstarts withclean-dist.mjs, so the entrypoint the wrapper points at is expected to disappear — pointing the enforcement floor there guarantees an outage window on every build. - It fails open. The hook exits 127 and the harness reports a non-blocking status: the gate is gone, the session proceeds. That is the worst of the three properties, because the floor's whole claim is that it fires in any agent or none.
- It is silent in both directions. Nothing warns when the wrapper is (re)pointed at a working tree, and nothing warns while the target is missing — the operator sees one hook error line in an unrelated repo and no way to connect it to a build elsewhere.
Proposed
- Prefer the installed kit when resolving the entrypoint.
npm root -g/ the resolvedbinof the installedsandstream-kitshould win overprocess.argv[1]; fall back to the running entrypoint only when kit is not installed globally. - Refuse to bake a path inside a git working tree into the machine-wide wrapper, unless something explicit asks for it (
--dev, orKIT_WRAPPER_ALLOW_DEV=1). A wrapper pointing at…/kit-public/dist/cli.jsis almost always an accident of where the command was run. - Say what was written.
ensureKitWrapper()is silent; the commands that call it should print the entrypoint the wrapper now uses when it changes — "updated self-healing wrapper" without the target hides exactly this. - Report it in
kit check/kit doctor. Thegit hook floorrow (Git-hook floor can live outside the repo: an absolute core.hooksPath is honored but never reported, and an unrelated rm -rf silently removes the gate #496/kit hooks add context-check installs a gate that cannot fail when [context] is absent — no warning, wrong test hint, and no git-hook row in kit status #497) reports where the floor lives; the wrapper is the other half of the same question, and a wrapper pointing at a non-existent or working-tree path is a finding by the same argument. - Consider failing closed. Not proposed as a default here, because a broken wrapper blocking every tool call is its own outage — but a wrapper that cannot start should at minimum be loud in the session, not a single non-blocking line.
Workaround for anyone hitting it now
Regenerate the wrapper with the globally installed kit rather than a checkout:
~/.npm-global/bin/kit memory install # or: kit agent-config, from the global binary
grep '^exec' ~/.kit/bin/kit # verify it points at the install, not a working treeVerified: after regenerating, ~/.kit/bin/kit --version still answers with the checkout's dist/ moved away.
Related
- Git-hook floor can live outside the repo: an absolute core.hooksPath is honored but never reported, and an unrelated rm -rf silently removes the gate #496 / kit hooks add context-check installs a gate that cannot fail when [context] is absent — no warning, wrong test hint, and no git-hook row in kit status #497 — where the git-hook floor lives and whether an installed gate can actually fail. Same family: the floor's location and liveness were unreported.
🤖 Generated with Claude Code
Activity
chore(release): 6.8.0 (#516)