diff --git a/src/commands/triage.ts b/src/commands/triage.ts index 56391547..d44bb0cd 100644 --- a/src/commands/triage.ts +++ b/src/commands/triage.ts @@ -151,7 +151,7 @@ export async function cmdTriage(): Promise { // a failed triage means the user explicitly chose not to install, so it // shouldn't unblock the commit. if (overall && target) { - await recordTriageRun(type, target, sandbox); + await recordTriageRun(type, target, sandbox, deep); } return overall; @@ -415,10 +415,17 @@ interface TriageLogEntry { type: string; target: string; sandbox: boolean; + /** Whether a deep delegate scan (SkillSpector Stage 1) ran — lets a gate require it for skills. */ + deep?: boolean; granter: string; } -async function recordTriageRun(type: string, target: string, sandbox: boolean): Promise { +async function recordTriageRun( + type: string, + target: string, + sandbox: boolean, + deep = false, +): Promise { const { appendFile } = await import("node:fs/promises"); const { resolve } = await import("node:path"); const entry: TriageLogEntry = { @@ -426,6 +433,7 @@ async function recordTriageRun(type: string, target: string, sandbox: boolean): type, target, sandbox, + deep, granter: process.env.USER ?? "unknown", }; try { diff --git a/src/doctor.test.ts b/src/doctor.test.ts index 07863f63..382f0947 100644 --- a/src/doctor.test.ts +++ b/src/doctor.test.ts @@ -215,6 +215,21 @@ describe("runDoctor", () => { } }); + it("deep skill scanner: skips when SkillSpector is not installed (optional delegate)", async () => { + const tmpDir = join(tmpdir(), `kit-doctor-test-${process.pid}-deep`); + await mkdir(tmpDir, { recursive: true }); + try { + const result = await runDoctor({}, tmpDir); + const deep = result.checks.find((c) => c.name === "deep skill scanner"); + assert.ok(deep, "deep skill scanner check should always be present"); + // Not installed in CI → skip (optional); if a future runner has it, pass is also honest. + assert.ok(["skip", "pass"].includes(deep.status), `unexpected status: ${deep.status}`); + assert.ok(deep.detail.length > 0); + } finally { + await rm(tmpDir, { recursive: true }); + } + }); + it("surfaces the identity keystore posture (Pelare 1 — never silent)", async () => { const tmpDir = join(tmpdir(), `kit-doctor-test-${process.pid}-9`); await mkdir(tmpDir, { recursive: true }); diff --git a/src/doctor.ts b/src/doctor.ts index e6c4f809..43830869 100644 --- a/src/doctor.ts +++ b/src/doctor.ts @@ -352,6 +352,28 @@ async function checkBrokerRuntime(cwd: string): Promise { }; } +/** + * Deep skill-scanner delegate posture. The optional SkillSpector (NVIDIA) delegate deepens + * `kit triage skill --deep` (static Stage 1 only — kit never runs its LLM stage). Optional, so its + * absence is a `skip`, not a failure: + * pass installed — deep static skill triage is available + * skip not installed — --deep falls back to kit's built-in checks + */ +async function checkDeepSkillScanner(): Promise { + const name = "deep skill scanner"; + const category = "security"; + const { skillspectorStatus } = await import("./skillspector-delegate.js"); + const s = await skillspectorStatus(); + return s.available + ? { + name, + status: "pass", + detail: `SkillSpector ${s.version ? `${s.version} ` : ""}— deep skill triage available (static Stage 1 only; kit never runs its LLM stage)`, + category, + } + : { name, status: "skip", detail: s.detail, category }; +} + /** * Keyless-credential posture (Pelare 2 tail — "sign, don't store"). Reports whether any hosts are * declared keyless (`[scope].sign`) and whether kit can actually sign for them — never silent: @@ -484,6 +506,7 @@ export async function runDoctor(config: kitConfig, cwd: string): Promise c.status === "pass").length; diff --git a/src/skillspector-delegate.test.ts b/src/skillspector-delegate.test.ts index 07d3cfc9..3480cf71 100644 --- a/src/skillspector-delegate.test.ts +++ b/src/skillspector-delegate.test.ts @@ -5,6 +5,7 @@ import { stage1Args, normalizeSkillspectorSarif, runSkillspectorStage1, + skillspectorStatus, LLM_ENV_VARS, SKILLSPECTOR_SOURCE, SKILLSPECTOR_BIN, @@ -102,4 +103,10 @@ describe("skillspector delegate — fail-closed when the binary is absent", () = assert.equal(r.status, "unavailable"); if (r.status === "unavailable") assert.match(r.detail, new RegExp(SKILLSPECTOR_BIN)); }); + + it("skillspectorStatus reports not-available when the binary is absent", async () => { + const s = await skillspectorStatus(); + assert.equal(s.available, false); + assert.match(s.detail, new RegExp(SKILLSPECTOR_BIN)); + }); }); diff --git a/src/skillspector-delegate.ts b/src/skillspector-delegate.ts index f88939ac..549b37dc 100644 --- a/src/skillspector-delegate.ts +++ b/src/skillspector-delegate.ts @@ -78,6 +78,30 @@ export function normalizeSkillspectorSarif(sarifJson: string): SecurityCheckResu })); } +export interface SkillspectorStatus { + available: boolean; + version?: string; + detail: string; +} + +/** + * Detect whether the SkillSpector delegate is installed (mise-first, then PATH) and its version. + * Runs `--version` with the SAME scrubbed env as a scan, so probing can never touch a provider. + * Never throws. + */ +export async function skillspectorStatus(): Promise { + const bin = await resolveToolBin(SKILLSPECTOR_BIN); + if (!bin) { + return { + available: false, + detail: `${SKILLSPECTOR_BIN} not installed — 'kit triage skill --deep' uses kit's built-in checks only`, + }; + } + const res = await execFileNoThrow(bin, ["--version"], { timeout: 10_000, env: scrubbedEnv() }); + const version = (res.stdout.trim() || res.stderr.trim()).split("\n")[0] || undefined; + return { available: true, version, detail: version ? `available (${version})` : "available" }; +} + export type SkillspectorResult = | { status: "ok"; findings: SecurityCheckResult[]; worst: SecurityCheckResult["severity"] } | { status: "unavailable"; detail: string }