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
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,56 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

## [Unreleased]

### Added

- **`kit tools list` — the inventory that did not exist**, and the measurement three surfaces
were missing (#500). Per tool: the resolved path, the installer that owns it (classified from
the path, never assumed), the installed version, and with `--latest` how far behind it is.
Covers the declared `[tools]` **and** the undeclared CLIs an agent decides from — `gh`, `op`,
`jq`, `mise`, `docker`, `gcloud`, `kubectl`, `supabase`, `stripe`, `psql`, … — which were
invisible precisely because nothing declared them.

Measured on the machine that filed the report, first run: `trivy 0.72.0 → 0.74.0`,
`trufflehog 3.95.9 → 3.97.0`, `gh 2.96.0 → 2.97.0`, `mise 2026.6.11 → 2026.8.9`,
`npm 10.9.8 → 12.0.2`, `op 2.34.0 → 2.39.0`. Cold 12s, warm 4s.

- **`latest` is now checked against the installer that would satisfy it.** `versionSatisfies`
answered `if (required === "latest") return true;`, so `✓ vercel 53.1.1 (need latest)` printed
while the registry had 59.1.4 — six majors. The tools table now shows the installer in brackets
and, for a `latest` pin, `!` with `53.1.1 → 59.1.4 available`. A pin of `any` / `present` / `*`
asserts presence only, and says so, for repos that genuinely mean "whatever is installed".

Lookups are per-installer (`npm view`, `mise latest`, `brew info --json=v2`, `pip index`),
cached per machine in `~/.kit/tool-latest.json` with a TTL (`KIT_TOOL_LATEST_TTL_H`, default
24h), so the gate makes no network call once warm. A failed lookup is **not** cached — a flaky
network must not become a day-long policy.

### Fixed

- **`cli-lock.json` recorded a provenance it never measured, and the check called it `in sync`.**
Both writers did the same thing:

```ts
tools[name] = { version, source: "mise" }; // version = the DECLARED string
```

so an entry read `{"vercel":{"version":"latest","source":"mise"}}` for a binary in
`/opt/homebrew/bin` that mise does not manage, and the lock check compared **names only**.
Now the version is the resolved one, the source is classified from the path, `sourceDetail`
carries installers the lock's four-value vocabulary cannot name (`brew`, `system`, `cargo`,
`kit-shim`), and a recorded source that contradicts the PATH winner fails the row with
`provenance drift: vercel: lock says mise, but /opt/homebrew/bin/vercel comes from brew`.

- **An unrunnable currency check now reports why, instead of passing.** Air-gap makes no outbound
call and says so; an installer kit cannot query (`system`, `cargo`, `go`, a kit PATH shim) says
which; a timeout or an unparseable answer says that. Same rule as the scanners: coverage that
could not run is UNKNOWN, never clean.

- **Prefixed declarations were reported as not installed.** `[tools]` carries backend prefixes
(`aqua:aquasecurity/trivy`, `npm:@socketsecurity/cli`), and the probe used the raw declaration
rather than the executable name — the same false statement as the one above, pointed the other
way.

### Fixed

- **The install-gate's refusal described its own machinery instead of the hazard it caught.**
Expand Down
8 changes: 8 additions & 0 deletions contracts/kit.opencli.json
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,14 @@
"x-kit-mcp": false,
"x-kit-stability": "experimental"
},
"tools": {
"kind": "command",
"summary": "Inventory the CLIs on this machine — path, installer, installed version, and (with --latest) how far behind each one is",
"x-kit-args-modeled": false,
"x-kit-audience": "all",
"x-kit-mcp": false,
"x-kit-stability": "experimental"
},
"triage": {
"kind": "command",
"summary": "Security evaluation before installing packages, images, or skills",
Expand Down
2 changes: 2 additions & 0 deletions contracts/public-surface.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"statusline": "stable",
"supply-chain": "stable",
"team": "experimental",
"tools": "experimental",
"triage": "stable",
"upgrade": "stable",
"verify-provenance": "stable",
Expand Down Expand Up @@ -255,6 +256,7 @@
"statusline",
"supply-chain",
"team",
"tools",
"triage",
"upgrade",
"verify-provenance",
Expand Down
10 changes: 10 additions & 0 deletions docs/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ written before or after the command word — `kit --read-only check` and
`kit check --read-only` are equivalent. Every command accepts them; a command
that rejects unknown flags allows these on top of its own.

**`[tools]` pins say what they check.** An exact pin (`bun = "1.3.10"`) is a prefix match on
the installed version. `latest` now means *current*: kit resolves the newest version the tool's
own installer would give and reports drift — `!` with `53.1.1 → 59.1.4 available` in the tools
table — instead of passing because the binary answered `--version`, which is how
`✓ vercel 53.1.1 (need latest)` stood for six majors. When the newest version cannot be
determined (air-gap, an installer with no registry kit can query, a lookup that timed out) the
row is `− currency unchecked: <reason>` — never a pass. A pin of `any`, `present` or `*`
asserts presence only, and says so.

**Unknown flags are rejected.** Every command validates its flags at dispatch
against a declared table (`src/flag-surface.ts`), prints what it accepts, and
exits 1 — a flag that silently does nothing is indistinguishable from a working
Expand Down Expand Up @@ -355,6 +364,7 @@ Deterministic, zero-LLM code map: load only the relevant slice of a growing repo

| Command | Purpose |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `kit tools list [--latest] [--json]` | Inventory the CLIs on this machine: resolved path, the installer that owns it (measured from the path, never assumed), installed version, and — with `--latest` — how far behind each one is. Covers the declared `[tools]` **and** the undeclared CLIs an agent decides from (`gh`, `op`, `docker`, `gcloud`, `kubectl`, `psql`, …). An installer kit cannot query (`system`, `cargo`, a kit PATH shim) reports `unchecked` **with the reason**; air-gap reports `unchecked`, never a version it did not verify. Answers are cached per machine (`~/.kit/tool-latest.json`, TTL `KIT_TOOL_LATEST_TTL_H`, default 24h), so the normal path makes no network call. `KIT_TOOLS_PATHS=1` prints paths. |
| `kit map <path...>` | The files connected to the seed(s) within `--depth` import hops (both directions) + external packages. TS/JS + Python. |
| `kit map <path> --depth N` | Widen the neighborhood (default 1). |
| `kit map <path> --budget N` | Keep only the N nearest-to-seed files; every drop is logged (never silent truncation). |
Expand Down
2 changes: 1 addition & 1 deletion docs/MCP_TOOLS_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tool-by-tool reference lives in [MCP_TOOLS_REFERENCE.md](MCP_TOOLS_REFERENCE.md)
this guide covers how to wire it up and how the surface is meant to be used.

**The CLI-first rule.** An agent with shell access should run `kit <command>`
directly: the CLI covers all ~71 commands, costs zero standing context, and
directly: the CLI covers all ~72 commands, costs zero standing context, and
`kit <command> --help` self-documents. The server's own `instructions` field
(sent in the MCP `initialize` result) says exactly this, so well-behaved
clients route accordingly. The MCP tools exist for clients that cannot shell
Expand Down
32 changes: 26 additions & 6 deletions src/check-lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,25 @@ export async function checkLockFiles(config: kitConfig, cwd?: string): Promise<L
} else {
const missing: string[] = [];
const authRequired: string[] = [];
// Provenance drift: the lock claims an installer, the PATH winner comes from another one.
// The old check compared names only, so a lock saying `mise` for /opt/homebrew/bin/vercel
// reported `in sync` (#500). A lock whose purpose is provenance has to be checked on it.
const drifted: string[] = [];
const { describeTool } = await import("./tool-inventory.js");
const { provenanceMismatch } = await import("./tool-provenance.js");

for (const toolName of configToolNames) {
if (!cliLock.tools[toolName]) {
const entry = cliLock.tools[toolName];
if (!entry) {
missing.push(toolName);
} else if (cliLock.tools[toolName].auth) {
authRequired.push(toolName);
continue;
}
if (entry.auth) authRequired.push(toolName);
const facts = await describeTool(toolName);
if (!facts.provenance) continue; // not installed here — nothing measured to contradict
const recorded = entry.sourceDetail ?? entry.source;
const verdict = provenanceMismatch(recorded, facts.provenance);
if (verdict.mismatch) drifted.push(`${toolName}: ${verdict.reason}`);
}

const authDetails =
Expand All @@ -108,16 +120,24 @@ export async function checkLockFiles(config: kitConfig, cwd?: string): Promise<L
.join(", ")})`
: "";

const driftDetail =
drifted.length > 0
? ` — provenance drift: ${drifted.join("; ")} (re-run \`kit fix\` to re-record)`
: "";
results.push({
category: "cli-lock",
exists: true,
inSync: missing.length === 0,
// Drift counts against sync: the lock is a provenance record, and a record that names
// the wrong installer is not in sync with the machine it describes.
inSync: missing.length === 0 && drifted.length === 0,
missing,
authRequired,
detail:
missing.length === 0
missing.length === 0 && drifted.length === 0
? `all tools locked${authDetails}`
: `${missing.length} tool(s) not in lock file${authDetails}`,
: missing.length > 0
? `${missing.length} tool(s) not in lock file${authDetails}${driftDetail}`
: `${drifted.length} tool(s) with wrong recorded provenance${authDetails}${driftDetail}`,
});
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/check-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,15 @@ export async function runCheckGate(opts: RunCheckOptions = {}): Promise<CheckRun
const scope: CheckCategory[] | null = selected ? [...selected] : null;

const tools =
wants("tools") && config.tools ? await step("tools", () => checkTools(config.tools!)) : [];
wants("tools") && config.tools
? await step("tools", async () => {
// Currency from the cache only: the gate reports drift it already knows about and
// never makes the network a dependency of `kit check` (#500, requirement 6).
const { cachedCurrencyChecker } = await import("./tool-inventory.js");
const { resolveToolBin } = await import("./utils/resolveTool.js");
return checkTools(config.tools!, resolveToolBin, await cachedCurrencyChecker());
})
: [];
const services =
wants("services") && config.services
? await step("services", () => checkServices(config.services!))
Expand Down
58 changes: 56 additions & 2 deletions src/check-tools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { ToolConfig } from "./config.js";
import { exec } from "./utils/exec.js";
import { resolveToolBin } from "./utils/resolveTool.js";
import { homedir } from "node:os";
import { classifyToolPath, type ToolSource } from "./tool-provenance.js";
import { probeName } from "./tool-inventory.js";
import type { DriftVerdict } from "./tool-latest.js";

/** Resolve a tool name to its executable path (mise-first), or null. */
export type ToolResolver = (tool: string) => Promise<string | null>;
Expand All @@ -9,9 +13,30 @@ export interface ToolStatus {
name: string;
required: string;
installed: string | null;
/** Satisfies the declared pin. Unchanged meaning — every existing consumer reads this. */
ok: boolean;
/** Resolved executable path, when known. */
path?: string;
/** Which installer owns that path (measured, never assumed). */
source?: ToolSource;
/**
* Currency, for a pin that promises it (`latest`). `undefined` when the pin does not ask:
* an exact pin is about matching, not about being newest.
*
* `behind` is a WARNING, not a failure — the tool works, it is just old. But it must be
* visible: `✓ vercel 53.1.1 (need latest)` was printed for six majors of drift (#500).
* `unknown` carries the reason the lookup could not answer, and never reads as current.
*/
currency?: DriftVerdict;
}

/** How a `latest` pin gets its answer. Injected so `checkTools` stays offline in tests. */
export type CurrencyChecker = (
tool: string,
source: ToolSource,
installed: string | null,
) => Promise<DriftVerdict>;

async function getToolVersion(tool: string, resolve: ToolResolver): Promise<string | null> {
// Fast path: `mise current` gives the project-pinned version directly when the
// tool is declared in the project's mise config.
Expand Down Expand Up @@ -42,22 +67,51 @@ async function getToolVersion(tool: string, resolve: ToolResolver): Promise<stri
}
}

/**
* Pins that only assert PRESENCE. `latest` is deliberately not one of them any more: it reads
* as a promise of currency, and for six majors it meant "answered --version" (#500). A repo that
* genuinely wants "whatever is installed" now says so with a pin that does not promise more.
*/
const PRESENCE_PINS = new Set(["any", "present", "*"]);

export function isPresencePin(required: string): boolean {
return PRESENCE_PINS.has(required.trim().toLowerCase());
}

/**
* Does the installed version satisfy the pin's MATCHING requirement?
*
* `latest` and the presence pins have nothing to match, so they are satisfied by existing —
* currency is reported separately (`ToolStatus.currency`) rather than folded in here, because
* an outdated tool is a warning and a missing one is a failure, and collapsing them is what
* made drift invisible.
*/
function versionSatisfies(installed: string, required: string): boolean {
if (required === "latest") return true;
if (required === "latest" || isPresencePin(required)) return true;
// Simple prefix match: required "22" matches "22.x.x", required "2.78" matches "2.78.x"
return installed.startsWith(required);
}

export async function checkTools(
tools: ToolConfig,
resolve: ToolResolver = resolveToolBin,
currency?: CurrencyChecker,
): Promise<ToolStatus[]> {
const results: ToolStatus[] = [];

for (const [name, required] of Object.entries(tools)) {
const installed = await getToolVersion(name, resolve);
const ok = installed !== null && versionSatisfies(installed, required);
results.push({ name, required, installed, ok });
// The executable, not the declaration: `aqua:aquasecurity/trivy` resolves as `trivy`.
const path = (await resolve(probeName(name))) ?? undefined;
const source = path ? classifyToolPath(path, { home: homedir() }).source : undefined;
// Only a pin that PROMISES currency pays for a lookup. An exact pin says nothing about
// being newest, and asking anyway would put the network on the gate's critical path.
const drift =
currency && required === "latest"
? await currency(name, source ?? "unknown", installed)
: undefined;
results.push({ name, required, installed, ok, path, source, currency: drift });
}

return results;
Expand Down
6 changes: 6 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import { cmdMcp } from "./commands/mcp.js";
import { cmdHooks } from "./commands/hooks.js";
import { cmdPlugin } from "./plugins-cli.js";
import { cmdTriage } from "./commands/triage.js";
import { cmdTools } from "./commands/tools.js";
import { cmdSlopsquat } from "./commands/slopsquat.js";
import { cmdMemory } from "./commands/memory.js";
import { escapeWorkflowCmd, xmlEscape } from "./utils/ci-escape.js";
Expand Down Expand Up @@ -763,6 +764,11 @@ const COMMAND_REGISTRY: Record<string, CommandDescriptor> = {
// layer cannot perform.
mcp: true,
},
tools: {
handler: cmdTools,
stability: "experimental",
help: "Inventory the CLIs on this machine — path, installer, installed version, and (with --latest) how far behind each one is",
},
slopsquat: {
handler: cmdSlopsquat,
stability: "experimental",
Expand Down
7 changes: 4 additions & 3 deletions src/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,10 @@ export async function cmdInit(): Promise<boolean> {
{ version: string; source: "mise" | "npm" | "pip" | "manual"; auth?: string }
> = {};
if (config.tools) {
for (const [name, version] of Object.entries(config.tools)) {
tools[name] = { version, source: "mise" };
}
// See fix.ts: the version and source are measured, not the declared string and a
// hardcoded "mise" (#500).
const { resolveLockEntries } = await import("../tool-inventory.js");
Object.assign(tools, await resolveLockEntries(config.tools));
}

await updateCliLock(tools);
Expand Down
Loading
Loading