Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
fix(check): keyless builds pass check; shims stop tripping DEP0190
Shrish Dwivedi47378c4c6cc0
diff --git a/src/claude/shim-template.ts b/src/claude/shim-template.tsindex 6499946e..5168194b 100644--- a/src/claude/shim-template.ts+++ b/src/claude/shim-template.ts@@ -33,7 +33,7 @@ function fromPkg(base) {// The global node_modules dir per npm (handles Homebrew/Windows/volta). Queried on demand.function globalRoot() {try {- const root = execFileSync('npm', ['root', '-g'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], shell: true }).trim();+ const root = execFileSync('npm', ['root', '-g'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], shell: process.platform === 'win32' }).trim();return root || null;} catch { return null; /* npm unavailable */ }}diff --git a/src/cli.ts b/src/cli.tsindex a855c6c3..40d250be 100644--- a/src/cli.ts+++ b/src/cli.ts@@ -141,15 +141,30 @@ programconst r = engine.check(dir, { extensions: opts.extensions });const g = engine.checkGraph(dir); // graph.json is only judged when it exists+ // Neither layer has ever been built → nothing to check.+ const bothMissing = r.missing && g.missing;+ // A layer that IS present must be in sync; a layer that was never built+ // (keyless `graft build` skips the markdown/concept layer) is informational,+ // not a failure — the wiring graph stands on its own.+ const markdownFail = !r.missing && !r.ok;+ const wiringFail = !g.missing && !g.ok;+if (opts.json) {console.log(JSON.stringify({ context: r, graph: g.missing ? null : g }, null, 2));+ } else if (bothMissing) {+ console.log("graft check: NO GRAPH\n\nNo graft/ graph found. Run `graft build` first.");} else {- console.log(formatCheckReport(r));+ if (r.missing) {+ console.log(+ "deep layer: not built (run `graft build --deep` for concept nodes) — wiring graph is the source of truth",+ );+ } else {+ console.log(formatCheckReport(r));+ }if (!g.missing) console.log("\n" + formatGraphCheckReport(g));}- // A missing graph.json is not a failure — the markdown graph stands alone.- if (!r.ok || (!g.missing && !g.ok)) process.exit(1);+ if (bothMissing || markdownFail || wiringFail) process.exit(1);});programdiff --git a/test/context.test.ts b/test/context.test.tsindex 7a87aca2..6017af9a 100644--- a/test/context.test.ts+++ b/test/context.test.ts@@ -7,10 +7,28 @@ import assert from "node:assert/strict";import { mkdtempSync, writeFileSync, readFileSync, existsSync, rmSync } from "node:fs";import { join } from "node:path";import { tmpdir } from "node:os";+import { execFileSync } from "node:child_process";import { buildContext } from "../src/context/build.js";import { checkContext } from "../src/context/check.js";import { fakeProviders } from "./helpers.js";+// CLI-spawn helper (same pattern as test/graph-traverse-cli.test.ts) — these tests+// exercise the real process boundary (exit codes), which a unit-level call into+// checkContext()/checkGraph() can't: the pass/fail decision lives in cli.ts's+// `check` action, combining both layers' results.+function runCli(args: string[]): { stdout: string; stderr: string; status: number } {+ try {+ const stdout = execFileSync(process.execPath, ["--import", "tsx", "src/cli.ts", ...args], {+ encoding: "utf8",+ stdio: ["ignore", "pipe", "pipe"],+ });+ return { stdout, stderr: "", status: 0 };+ } catch (err) {+ const e = err as { stdout?: string; stderr?: string; status?: number };+ return { stdout: e.stdout ?? "", stderr: e.stderr ?? "", status: e.status ?? 1 };+ }+}+function makeFixture(): string {const dir = mkdtempSync(join(tmpdir(), "ctxgraph-"));writeFileSync(@@ -134,3 +152,61 @@ test("human notes below the generated block survive regeneration", async () => {rmSync(dir, { recursive: true, force: true });}});++// `graft check` on the CLI combines the markdown-context layer (checkContext) and the+// wiring-graph layer (checkGraph). A keyless `graft build` (no --deep) only ever produces+// the wiring layer — manifest.json (markdown layer) is never written — so `check` must not+// treat that absence as failure on its own.+test("graft check: keyless build (no --deep) exits 0 — wiring graph present, markdown layer never built", () => {+ const dir = mkdtempSync(join(tmpdir(), "ctxgraph-cli-"));+ try {+ writeFileSync(join(dir, "math.ts"), "export function add(a: number, b: number): number {\n return a + b;\n}\n");+ const built = runCli(["build", dir]);+ assert.equal(built.status, 0);++ const r = runCli(["check", dir]);+ assert.equal(r.status, 0, `expected exit 0, got ${r.status}\nstdout: ${r.stdout}\nstderr: ${r.stderr}`);+ assert.match(r.stdout, /deep layer: not built/);+ assert.match(r.stdout, /wiring graph is the source of truth/);+ assert.match(r.stdout, /graph check: OK/);+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+});++test("graft check: neither layer ever built exits 1", () => {+ const dir = mkdtempSync(join(tmpdir(), "ctxgraph-cli-"));+ try {+ const r = runCli(["check", dir]);+ assert.equal(r.status, 1);+ assert.match(r.stdout, /NO GRAPH/);+ assert.match(r.stdout, /graft build/);+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+});++test("graft check: keyless build then code changes (wiring stale) exits 1", () => {+ const dir = mkdtempSync(join(tmpdir(), "ctxgraph-cli-"));+ try {+ const file = join(dir, "math.ts");+ writeFileSync(file, "export function add(a: number, b: number): number {\n return a + b;\n}\n");+ const built = runCli(["build", dir]);+ assert.equal(built.status, 0);++ // Change the code without rebuilding — the wiring graph (the only layer that+ // exists) is now stale, so check must fail even though the markdown layer is+ // still just "not built" rather than "stale".+ writeFileSync(+ file,+ "export function add(a: number, b: number): number {\n return a + b;\n}\n" ++ "export function sub(a: number, b: number): number {\n return a - b;\n}\n",+ );++ const r = runCli(["check", dir]);+ assert.equal(r.status, 1, `expected exit 1, got ${r.status}\nstdout: ${r.stdout}\nstderr: ${r.stderr}`);+ assert.match(r.stdout, /graph check: STALE/);+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+});