diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md index d3aedb25..32558dc5 100644 --- a/docs/COMMANDS.md +++ b/docs/COMMANDS.md @@ -144,6 +144,7 @@ | `kit triage all ` | Auto-detect + run all checks. | | `kit triage tools` | List installed security tools. | | `kit triage check-deps` | Pre-commit gate: fail if staged deps lack triage entries. | +| `kit triage check-skills` | Pre-commit gate: fail if staged skills lack a `--deep` triage entry. | ## Packages + plugins diff --git a/docs/ENFORCEMENT_AND_AUDIT.md b/docs/ENFORCEMENT_AND_AUDIT.md index 815d365d..95a03e11 100644 --- a/docs/ENFORCEMENT_AND_AUDIT.md +++ b/docs/ENFORCEMENT_AND_AUDIT.md @@ -15,7 +15,8 @@ Deterministic, fail-closed, zero-LLM: - **PreToolUse gates** — `gate-bash`, `gate-env` block un-triaged installs and plaintext-secret writes *before* they land. - **Capture-time gates** — the memory write-gate (G1), install-gate, slopsquat scoring (G4). -- **Commit/CI chokepoints** — `kit triage check-deps` (pre-commit), branch-protected checks. +- **Commit/CI chokepoints** — `kit triage check-deps` + `kit triage check-skills` (pre-commit, + wired by `kit setup --recommended`), branch-protected checks. - **`warn → enforce` ramp** — a new gate warns first, then fails once enforced. This is the "gravitation": you *can't* do X. It shapes **how** software gets built. diff --git a/src/commands/setup.ts b/src/commands/setup.ts index 83a9c4e1..f8f64951 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -233,7 +233,7 @@ export async function cmdSetup(): Promise { recommended = profile.recommended; } else { recommended = await promptConfirm( - `Use the recommended profile? Wires cross-harness memory hooks (in ~/.claude) + git secret-scan${config.context ? " + context-check" : ""} gates after the core steps. [Y/n] `, + `Use the recommended profile? Wires cross-harness memory hooks (in ~/.claude) + git secret-scan + triage${config.context ? " + context-check" : ""} gates after the core steps. [Y/n] `, 10000, profile.recommended, ); diff --git a/src/recommended.test.ts b/src/recommended.test.ts index e69ffdb7..d4680e52 100644 --- a/src/recommended.test.ts +++ b/src/recommended.test.ts @@ -28,16 +28,18 @@ describe("applyRecommendedHardening", () => { return mkdtempSync(join(tmp, "git-")) + "/.git"; } - it("wires memory hooks + a pre-commit secret-scan, and a pre-push when context is declared", async () => { + it("wires memory hooks + a pre-commit secret-scan + triage gates, and a pre-push when context is declared", async () => { const g = gitDir(); const r = await applyRecommendedHardening({ context: { git: { email: "x@y.z" } } }, g); // 3 memory hooks (UserPromptSubmit/SessionEnd/SessionStart). assert.equal(r.memory.added.length, 3); - // pre-commit secret-scan gate. + // pre-commit secret-scan + triage gates (deps + skills). const pc = readFileSync(join(g, "hooks", "pre-commit"), "utf-8"); assert.ok(pc.includes("security scan-staged"), "pre-commit runs security scan-staged"); + assert.ok(pc.includes("triage check-deps"), "pre-commit runs the dep triage gate"); + assert.ok(pc.includes("triage check-skills"), "pre-commit runs the skill triage gate"); // pre-push context-check gate (context was declared). assert.ok(existsSync(join(g, "hooks", "pre-push")), "pre-push installed when context declared"); diff --git a/src/recommended.ts b/src/recommended.ts index c057833f..ff9cbed0 100644 --- a/src/recommended.ts +++ b/src/recommended.ts @@ -22,9 +22,14 @@ function kitInvocation(): string { /** * The opinionated "recommended" hardening layered on top of `kit setup`: * - cross-harness memory capture (the Claude Code hooks) - * - a pre-commit secret-scan gate + * - a pre-commit gate: secret-scan + triage gates for newly-added deps and staged skills * - a pre-push context-check gate (only when `[context]` is declared) * + * The triage gates (`kit triage check-deps` / `check-skills`) were always meant to run at + * commit time — they're the fail-closed chokepoint that refuses staged deps/skills lacking a + * recent triage. Wiring them into the recommended pre-commit turns the documented gates into + * enforced ones. Both are cheap no-ops when nothing relevant is staged. + * * Each piece is idempotent and uses the already-hardened installers * (absolute-path memory hooks; hooksPath-aware, no-clobber git hooks). It * touches GLOBAL `~/.claude` (memory hooks) and the repo's git hooks, so the @@ -37,7 +42,13 @@ export async function applyRecommendedHardening( const memory = installMemoryHooks(); const kit = kitInvocation(); - const hookConfig: HooksConfig = { "pre-commit": [`${kit} security scan-staged`] }; + const hookConfig: HooksConfig = { + "pre-commit": [ + `${kit} security scan-staged`, + `${kit} triage check-deps`, + `${kit} triage check-skills`, + ], + }; // The context-check gate only makes sense once a context is declared. if (config.context) { hookConfig["pre-push"] = [`${kit} context check`];