Skip to content

The machine-wide kit wrapper points at whichever kit wrote it — one run from a checkout aims every hook on the machine at a build artifact, and it fails open #509

Closed

Description

@sandstream

~/.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

  1. A repo-local command has a machine-wide effect. kit hooks add secret-scan inside a throwaway temp directory rewrote ~/.kit/bin/kit for every repo on the machine. Nothing in the command's output says so.
  2. A dev build is transient by design. npm run build starts with clean-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.
  3. 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.
  4. 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

  1. Prefer the installed kit when resolving the entrypoint. npm root -g / the resolved bin of the installed sandstream-kit should win over process.argv[1]; fall back to the running entrypoint only when kit is not installed globally.
  2. Refuse to bake a path inside a git working tree into the machine-wide wrapper, unless something explicit asks for it (--dev, or KIT_WRAPPER_ALLOW_DEV=1). A wrapper pointing at …/kit-public/dist/cli.js is almost always an accident of where the command was run.
  3. 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.
  4. Report it in kit check/kit doctor. The git hook floor row (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.
  5. 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 tree

Verified: after regenerating, ~/.kit/bin/kit --version still answers with the checkout's dist/ moved away.

Related

🤖 Generated with Claude Code

Activity

  1. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions