Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/commands/triage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export async function cmdTriage(): Promise<boolean> {
// 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;
Expand Down Expand Up @@ -415,17 +415,25 @@ 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<void> {
async function recordTriageRun(
type: string,
target: string,
sandbox: boolean,
deep = false,
): Promise<void> {
const { appendFile } = await import("node:fs/promises");
const { resolve } = await import("node:path");
const entry: TriageLogEntry = {
timestamp: new Date().toISOString(),
type,
target,
sandbox,
deep,
granter: process.env.USER ?? "unknown",
};
try {
Expand Down
15 changes: 15 additions & 0 deletions src/doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
23 changes: 23 additions & 0 deletions src/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,28 @@ async function checkBrokerRuntime(cwd: string): Promise<DoctorCheck> {
};
}

/**
* 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<DoctorCheck> {
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:
Expand Down Expand Up @@ -484,6 +506,7 @@ export async function runDoctor(config: kitConfig, cwd: string): Promise<DoctorR
allChecks.push(await checkBrokerScope(cwd));
allChecks.push(await checkBrokerRuntime(cwd));
allChecks.push(await checkKeyless(cwd));
allChecks.push(await checkDeepSkillScanner());
allChecks.push(checkControlPlane(cwd));

const passed = allChecks.filter((c) => c.status === "pass").length;
Expand Down
7 changes: 7 additions & 0 deletions src/skillspector-delegate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
stage1Args,
normalizeSkillspectorSarif,
runSkillspectorStage1,
skillspectorStatus,
LLM_ENV_VARS,
SKILLSPECTOR_SOURCE,
SKILLSPECTOR_BIN,
Expand Down Expand Up @@ -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));
});
});
24 changes: 24 additions & 0 deletions src/skillspector-delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SkillspectorStatus> {
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 }
Expand Down
Loading