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
test(windows): make parts 5-7's hook and journey tests hold on Windows
Shrish Dwivedi7bfdf0dde7a7
diff --git a/test/claude-hooks-1b.test.ts b/test/claude-hooks-1b.test.tsindex 939cbb74..c283ed45 100644--- a/test/claude-hooks-1b.test.ts+++ b/test/claude-hooks-1b.test.ts@@ -15,8 +15,6 @@ import { everyRepoDir, writeEveryRepo } from '../src/notes/every-repo.js';import { writeLesson } from '../src/skills/lessons.js';import { guardrailLearning } from '../src/notes/guardrails.js';import { stopSkillsRun } from '../src/claude/stop-skills.js';-import { FIXED_DIRS } from '../src/trace/guard-fast.js';-import { statSync } from 'node:fs';import { keepReceiptPath } from '../src/init/keep-gate.js';import { keepCommand } from '../src/init/keep.js';import { offerLinesOf } from '../src/skills/offer-lines.js';@@ -26,7 +24,7 @@ import { relayLines } from '../src/init/review-screen.js';import type { InitItem } from '../src/init/types.js';import { factsOf, guardrailCandidate, skillCandidate } from './init-screen-fixtures.js';import {- agentRuns, at, box, cli, CWD, done, finish, hook, ls, offersLog, one, pathWithoutTimeout, preBashHook, promptHook, ran, release, reply, sayOfferLines, session, SHOP, skillsKept, startHook, stateOf, typedLine,+ agentRuns, at, box, cli, CWD, done, finish, hook, ls, offersLog, one, pathWithoutTimeout, preBashHook, promptHook, ran, release, reply, sayOfferLines, session, SHOP, skillsKept, startHook, stateOf, timeoutSeen, typedLine,type Box, type Session,} from './claude-skills-journey-fixtures.js';import { allowedValue, EVENTS } from '../src/telemetry/contract.js';@@ -167,10 +165,8 @@ test('J06 end to end: day 1 hits the docker wall and gets the fix, Stop records}});-/** A machine with a real `timeout` in a system folder of 4.11 can't show a deny. */-const SYSTEM_TIMEOUT = FIXED_DIRS.filter((d) => !d.startsWith('$HOME')).some((d) => {- try { return statSync(join(d.replace('$USER', process.env.USER ?? ''), 'timeout')).isFile(); } catch { return false; }-}) && 'this machine has a timeout in a system folder';+/** A machine where Trail still finds a `timeout` (a system folder of 4.11, or Windows' System32) can't show a deny. */+const SYSTEM_TIMEOUT = timeoutSeen();/** Stop's skills part in this process, with the telemetry it collected (the hook queues it; the test reads it). */const stopSent = (s: Session, iso: string, said: string) => stopSkillsRun({ ...s.payload, hook_event_name: 'Stop', stop_hook_active: false, last_assistant_message: said }, s.b.project,diff --git a/test/claude-hooks-fail-open-all.test.ts b/test/claude-hooks-fail-open-all.test.tsindex b55db1cc..769cd13b 100644--- a/test/claude-hooks-fail-open-all.test.ts+++ b/test/claude-hooks-fail-open-all.test.ts@@ -5,7 +5,8 @@* the untracked `.claude/helpers/trail-hooks.cjs` while the tracked* `.claude/settings.json` still names it; then Stop, the prompt hook and* SessionStart used to exit 1 on every turn. These tests run the exact- * command strings the installs write, through the platform shell, with a+ * command strings the installs write, through the shell Claude Code runs+ * hooks in (sh, or Git Bash on Windows), with a* payload like the host's. The next `trail init` repairs older wiring.* Made-up folders only; every run gets its own HOME and TRAIL_HOME.*/@@ -18,7 +19,7 @@ import { mergeGraftHooks, mergeGraftSettings } from '../src/claude/settings-mergimport { installCodexHooks } from '../src/hosts/codex-hooks.js';import { installCursorHooks } from '../src/hosts/cursor-hooks.js';import { toPosixPath } from '../src/util/paths.js';-import { tmpRepo } from './helpers.js';+import { hookShell, tmpRepo } from './helpers.js';type Cmd = { where: string; event: string; command: string };@@ -53,11 +54,15 @@ function payload(event: string, cwd: string): string {}function hostEnv(home: string, project: string): NodeJS.ProcessEnv {- return { PATH: process.env.PATH ?? '', HOME: home, USERPROFILE: home, TRAIL_HOME: join(home, '.trail'), CLAUDE_PROJECT_DIR: project };+ const win = process.platform === 'win32' ? { SystemRoot: process.env.SystemRoot, PATHEXT: process.env.PATHEXT } : {};+ return { PATH: process.env.PATH ?? '', HOME: home, USERPROFILE: home, TRAIL_HOME: join(home, '.trail'), CLAUDE_PROJECT_DIR: project, ...win };}+const SHELL = hookShell();+const NO_SHELL = SHELL === null && 'no Git Bash on this Windows machine, the shell Claude Code runs hooks in';+function run(command: string, cwd: string, input: string, env: NodeJS.ProcessEnv) {- return spawnSync(command, { shell: true, cwd, input, encoding: 'utf8', timeout: 20000, env });+ return spawnSync(command, { shell: SHELL ?? true, cwd, input, encoding: 'utf8', timeout: 20000, env });}test('every hook command Trail writes, on every event, ends in a shell-level fail-open', () => {@@ -66,7 +71,7 @@ test('every hook command Trail writes, on every event, ends in a shell-level faifor (const c of cmds) assert.match(c.command, /^node "[^"]+-hooks\.cjs" [\w-]+ \|\| exit 0$/, `${c.where} ${c.event}`);});-test('the lab case: settings.json kept, the helper stashed away; Stop, prompt and session-start exit 0 and print nothing', () => {+test('the lab case: settings.json kept, the helper stashed away; Stop, prompt and session-start exit 0 and print nothing', { skip: NO_SHELL }, () => {const home = tmpRepo('fail-open-stash-home');const project = tmpRepo('fail-open-stash-project');// Only the tracked settings remain, as after `git stash -u`: no .claude/helpers/ at all.@@ -80,7 +85,7 @@ test('the lab case: settings.json kept, the helper stashed away; Stop, prompt an}});-test('with the helper there, each command still runs it with its event and prints its one JSON object, even when it exits non-zero', () => {+test('with the helper there, each command still runs it with its event and prints its one JSON object, even when it exits non-zero', { skip: NO_SHELL }, () => {const home = tmpRepo('fail-open-present-home');const project = tmpRepo('fail-open-present-project');const helpers = join(project, '.claude', 'helpers');diff --git a/test/claude-pre-bash-fail-open.test.ts b/test/claude-pre-bash-fail-open.test.tsindex 8343486a..f808f7d7 100644--- a/test/claude-pre-bash-fail-open.test.ts+++ b/test/claude-pre-bash-fail-open.test.ts@@ -5,7 +5,7 @@* can't be found (started in a subfolder without CLAUDE_PROJECT_DIR, the shim* gone after an uninstall, no node on PATH) would deny every shell command.* These tests run the exact command strings the installs write, through the- * platform shell, the way a host runs them.+ * shell a host runs them in (sh, or Git Bash for Claude Code on Windows).*/import { test } from 'node:test';import assert from 'node:assert/strict';@@ -17,7 +17,7 @@ import { installCodexHooks } from '../src/hosts/codex-hooks.js';import { globalCopyCovers } from '../src/claude/hook-layers.js';import { hooksShim } from '../src/claude/shim-template.js';import { toPosixPath } from '../src/util/paths.js';-import { tmpRepo } from './helpers.js';+import { hookShell, tmpRepo } from './helpers.js';const PAYLOAD = JSON.stringify({ session_id: 's1', cwd: '/tmp/x', hook_event_name: 'PreToolUse', tool_name: 'Bash', tool_input: { command: 'npm test' } });@@ -35,9 +35,12 @@ function commands(home: string): Record<string, string> {};}-/** Runs `command` through the platform shell (sh, or cmd on Windows), as hosts do. */+const SHELL = hookShell();+const NO_SHELL = SHELL === null && 'no Git Bash on this Windows machine, the shell Claude Code runs hooks in';++/** Runs `command` through the shell hosts run hooks in (sh, or Git Bash on Windows: cmd can't expand `${CLAUDE_PROJECT_DIR:-.}`). */function run(command: string, cwd: string, env: NodeJS.ProcessEnv) {- return spawnSync(command, { shell: true, cwd, input: PAYLOAD, encoding: 'utf8', timeout: 20000, env });+ return spawnSync(command, { shell: SHELL ?? true, cwd, input: PAYLOAD, encoding: 'utf8', timeout: 20000, env });}/** The environment of a host started somewhere CLAUDE_PROJECT_DIR isn't set. */@@ -53,7 +56,7 @@ test('every PreToolUse command Trail writes ends in a shell-level fail-open', ()}});-test('a PreToolUse command whose script is missing exits 0 and prints nothing on stdout', () => {+test('a PreToolUse command whose script is missing exits 0 and prints nothing on stdout', { skip: NO_SHELL }, () => {const home = tmpRepo('fail-open-missing');// A subfolder of a project with no .claude/ of its own, as when a host// starts there without CLAUDE_PROJECT_DIR; every shim path is missing.@@ -78,7 +81,7 @@ test('a PreToolUse command exits 0 with no output when node is not on PATH', { s}});-test('the fail-open form still runs the shim with the event, and its answer reaches the host', () => {+test('the fail-open form still runs the shim with the event, and its answer reaches the host', { skip: NO_SHELL }, () => {const project = tmpRepo('fail-open-present');const helpers = join(project, '.claude', 'helpers');mkdirSync(helpers, { recursive: true });diff --git a/test/claude-pre-bash-guard.test.ts b/test/claude-pre-bash-guard.test.tsindex 108a02a0..7fe853de 100644--- a/test/claude-pre-bash-guard.test.ts+++ b/test/claude-pre-bash-guard.test.ts@@ -8,19 +8,17 @@*/import { test } from 'node:test';import assert from 'node:assert/strict';-import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';+import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';import { delimiter, join } from 'node:path';import { skillsPrefilter } from '../src/claude/pre-bash.js';-import { FIXED_DIRS, SURE_FAIL_REASON } from '../src/trace/guard-fast.js';+import { SURE_FAIL_REASON } from '../src/trace/guard-fast.js';import { sessionPath } from '../src/trace/gate-file.js';import { writeEveryRepo } from '../src/notes/every-repo.js';import { guardrailLearning } from '../src/notes/guardrails.js';-import { at, box, done, hook, one, pathWithoutTimeout, preBashHook, session, type Box, type Session } from './claude-skills-journey-fixtures.js';+import { at, box, done, hook, one, pathWithoutTimeout, preBashHook, session, timeoutSeen, type Box, type Session } from './claude-skills-journey-fixtures.js';-/** A machine with a real `timeout` in a system folder of 4.11 can't show a deny: those tests say so and skip. */-const SYSTEM_TIMEOUT = FIXED_DIRS.filter((d) => !d.startsWith('$HOME')).some((d) => {- try { return statSync(join(d.replace('$USER', process.env.USER ?? ''), 'timeout')).isFile(); } catch { return false; }-}) && 'this machine has a timeout in a system folder';+/** A machine where Trail still finds a `timeout` (a system folder of 4.11, or Windows' System32) can't show a deny: those tests say so and skip. */+const SYSTEM_TIMEOUT = timeoutSeen();/** The person kept the no-timeout guardrail at init (J01's end). */function keepGuardrail(b: Box): void {diff --git a/test/claude-skills-journey-fixtures.ts b/test/claude-skills-journey-fixtures.tsindex 88f67a90..56efee3d 100644--- a/test/claude-skills-journey-fixtures.ts+++ b/test/claude-skills-journey-fixtures.ts@@ -22,6 +22,8 @@ import { main as hooksMain } from '../src/claude/hooks.js';import { main as preBashMain } from '../src/claude/pre-bash.js';import { sessionPath } from '../src/trace/gate-file.js';import { cliAdd } from '../src/skills/save-gate.js';+import { repoPlace } from '../src/notes/home.js';+import { timeoutOnPath } from '../src/trace/guard-fast.js';import type { SkillSessionState } from '../src/trace/types.js';export const SHOP = 'github.com/acme/shop';@@ -63,6 +65,19 @@ export function pathWithoutTimeout(): string {return noTimeout;}+/**+ * Why the no-timeout guardrail can't deny on this machine, or false: Trail still finds a `timeout` once PATH is+ * cleared of the ones a test can hide (and with a home of no folders). A system folder of 4.11 holds one (Homebrew's+ * coreutils), or this is Windows, which ships System32\timeout.exe on every PATH: a `timeout N` command never+ * surely fails there, so the deny never comes, by design.+ */+export function timeoutSeen(): string | false {+ const home = join(tmpdir(), 'no-timeout-home-none');+ const env = { PATH: pathWithoutTimeout(), PATHEXT: process.env.PATHEXT, HOME: home, USER: process.env.USER };+ if (!timeoutOnPath(env)) return false;+ return process.platform === 'win32' ? 'Windows has System32\\timeout.exe on every PATH' : 'this machine has a timeout in a system folder';+}+let boxes = 0;/** Skills on since August, offers on, the repo index pointing /home/dev/shop at acme/shop. */@@ -77,7 +92,9 @@ export function box(tag: string, opts: { settings?: Record<string, unknown>; envconst project = join(root, 'project');for (const d of [home, join(trail, 'repos'), project]) mkdirSync(d, { recursive: true });writeFileSync(join(trail, 'settings.json'), JSON.stringify({ v: 1, skills: 'on', onSince: '2026-08-01T00:00:00.000Z', ...opts.settings }));- writeFileSync(join(trail, 'repos', 'index.json'), JSON.stringify({ aliases: { 'local/home-dev-shop': SHOP }, roots: {} }));+ // CWD's own key, as Trail makes it here: `local/home-dev-shop`, or `local/d-home-dev-shop` on Windows (the drive).+ const local = repoPlace(CWD, { TRAIL_HOME: trail }).key;+ writeFileSync(join(trail, 'repos', 'index.json'), JSON.stringify({ aliases: { [local]: SHOP }, roots: {} }));// The prompt hook's graph ask: answers nothing, at once.const stub = join(root, 'ask-stub.mjs');writeFileSync(stub, 'process.stdout.write("null");\n');diff --git a/test/helpers.ts b/test/helpers.tsindex 73073bdb..8349b123 100644--- a/test/helpers.ts+++ b/test/helpers.ts@@ -7,10 +7,10 @@* than being hand-rolled per file because both carry a platform trap that is* invisible until CI runs on Windows: see {@link tmpRepo} and {@link homeEnv}.*/-import { mkdtempSync, realpathSync } from "node:fs";+import { existsSync, mkdtempSync, realpathSync } from "node:fs";import { spawnSync, type SpawnSyncReturns } from "node:child_process";import { tmpdir } from "node:os";-import { join } from "node:path";+import { delimiter, join } from "node:path";import type { Summarizer, Synthesizer, SynthNode, SynthLink, FileSummary } from "../src/index.js";/**@@ -62,6 +62,20 @@ export function chmodDenialUnavailable(): string | null {return null;}+/**+ * The shell Claude Code runs a hook command in: the platform's own (`sh`) off Windows, Git Bash on Windows, which+ * Claude Code needs there. Not `cmd.exe`, Node's `shell: true` on Windows: it can't expand the+ * `${CLAUDE_PROJECT_DIR:-.}` the repo's hook commands start with, so a test run there proves nothing.+ * Null on a Windows machine with no Git Bash next to its git.+ */+export function hookShell(): string | true | null {+ if (process.platform !== "win32") return true;+ const roots = (process.env.PATH ?? "").split(delimiter).filter(Boolean).filter((d) => existsSync(join(d, "git.exe"))).map((d) => join(d, ".."));+ roots.push(join(process.env.ProgramFiles ?? "C:\\Program Files", "Git"));+ for (const r of roots) for (const bash of [join(r, "bin", "bash.exe"), join(r, "..", "bin", "bash.exe")]) if (existsSync(bash)) return bash;+ return null;+}+export interface CliRun extends SpawnSyncReturns<string> {/** status/signal/stdout/stderr in one string, for assertion messages. */describe(): string;diff --git a/test/init-sessions.test.ts b/test/init-sessions.test.tsindex bb8e0e8b..76c1b517 100644--- a/test/init-sessions.test.ts+++ b/test/init-sessions.test.ts@@ -67,13 +67,14 @@ function world() {test("a repo's sessions: its own, its worktrees', other clones of its remote; not a sibling's or another repo's", () => {const w = world();session(w.home, folderOf(w.repo), "own-1", [typed(w.repo, day(1), "run the tests before you push")]);- session(w.home, folderOf(`${w.repo}/.claude/worktrees/x`), "own-2", [typed(`${w.repo}/.claude/worktrees/x`, day(2), "use pnpm here")]);+ const inner = join(w.repo, ".claude", "worktrees", "x");+ session(w.home, folderOf(inner), "own-2", [typed(inner, day(2), "use pnpm here")]);session(w.home, folderOf(w.wt), "wt-1", [typed(w.wt, day(3), "keep the PR small")]);session(w.home, folderOf(w.clone), "clone-1", [typed(join(w.clone, "src"), day(4), "open the PR against dev")]);session(w.home, folderOf(w.sibling), "sib-1", [typed(w.sibling, day(5), "not this repo")]);session(w.home, folderOf(w.other), "web-1", [typed(w.other, day(6), "another repo")]);// Claude Code has kept a space in folder names too: the file's own cwd decides, not the folder's name.- session(w.home, `${w.repo.replace(/\//g, "-")} copy`, "own-3", [typed(w.repo, day(7), "explain it simply")]);+ session(w.home, `${w.repo.replace(/[\\/:]/g, "-")} copy`, "own-3", [typed(w.repo, day(7), "explain it simply")]);const d = discoverSessions(w.repo, w.home, undefined, envOf(w));const ids = d.sessions.map((s) => s.id).sort();diff --git a/test/known-repo-1b.test.ts b/test/known-repo-1b.test.tsindex 4194f3de..8f43be88 100644--- a/test/known-repo-1b.test.ts+++ b/test/known-repo-1b.test.ts@@ -4,16 +4,15 @@*/import { after, test } from 'node:test';import assert from 'node:assert/strict';-import { chmodSync, existsSync, mkdirSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs';+import { chmodSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';import { delimiter, join } from 'node:path';import { readWalls } from '../src/trace/wall-state.js';import { writeEveryRepo } from '../src/notes/every-repo.js';import { guardrailLearning } from '../src/notes/guardrails.js';-import { FIXED_DIRS } from '../src/trace/guard-fast.js';import { repoKnown } from '../src/trace/known-repo.js';import { poolPath } from '../src/trace/pool.js';import {- agentRuns, at, box, calling, done, finish, one, pathWithoutTimeout, postBashFailHook, promptHook, release, reply, resultOf, session, SHOP, startHook, stateOf, stopHook, type Box,+ agentRuns, at, box, calling, done, finish, one, pathWithoutTimeout, postBashFailHook, promptHook, release, reply, resultOf, session, SHOP, startHook, stateOf, stopHook, timeoutSeen, type Box,} from './claude-skills-journey-fixtures.js';import { tmpRepo } from './helpers.js';@@ -103,9 +102,8 @@ test('J16 control: the same days in a repo with .trail/ make the offer, and in oconst DOCKER_ERR = 'Exit code 1\n--- FAIL: TestOrders (0.01s)\npanic: rootless Docker not found [recovered]\nFAIL\tacme/shop/orders\t0.412s';const GO_TEST = 'go test -tags integration ./...';const FIXED = 'DOCKER_HOST=unix://$HOME/.colima/default/docker.sock go test -tags integration ./...';-const SYSTEM_TIMEOUT = FIXED_DIRS.filter((d) => !d.startsWith('$HOME')).some((d) => {- try { return statSync(join(d.replace('$USER', process.env.USER ?? ''), 'timeout')).isFile(); } catch { return false; }-});+/** A machine where Trail still finds a `timeout` (a system folder of 4.11, or Windows' System32) can't show a deny. */+const SYSTEM_TIMEOUT = timeoutSeen();test('J16: walls and guardrails still apply in a repo Trail never ran in: the fix comes, the hit is noted, the deny holds; no repair offer', async () => {const b = plainBox('j16-walls');diff --git a/test/skills-codex-sandbox.test.ts b/test/skills-codex-sandbox.test.tsindex c8a6879a..cbdc00e0 100644--- a/test/skills-codex-sandbox.test.ts+++ b/test/skills-codex-sandbox.test.ts@@ -15,9 +15,13 @@ import { cliAdd } from '../src/skills/save-gate.js';import { cliUpdate } from '../src/skills/update-gate.js';import { keepLessonCli } from '../src/skills/lesson-gate.js';import { sandboxLine, trailWritable } from '../src/skills/codex-sandbox.js';+import { chmodDenialUnavailable } from './helpers.js';const ctxOf = (out: Record<string, any> | null): string => out?.hookSpecificOutput?.additionalContext ?? '';+/** A refused write is made with chmod, which refuses nothing on Windows (or for root): those tests say so and skip. */+const NO_DENIAL = chmodDenialUnavailable() ?? false;+/** Makes each folder read-only for the call, then puts it back (so the temp home can be removed). */function readOnly<T>(dirs: string[], fn: () => T): T {for (const d of dirs) chmodSync(d, 0o555);@@ -28,7 +32,7 @@ function readOnly<T>(dirs: string[], fn: () => T): T {}}-test('sandboxLine is the 4.17 words; trailWritable probes skills and state (or the folder above one not made yet)', () => {+test('sandboxLine is the 4.17 words; trailWritable probes skills and state (or the folder above one not made yet)', { skip: NO_DENIAL }, () => {assert.equal(sandboxLine('trail skills add release-npm --run r-1'),"trail · couldn't write ~/.trail from Codex's sandbox. The person can run the same command in their own terminal within 30 minutes: trail skills add release-npm --run r-1");const root = mkdtempSync(join(tmpdir(), 'c8-sbx-'));@@ -46,7 +50,7 @@ test('sandboxLine is the 4.17 words; trailWritable probes skills and state (or t}});-test('trail skills add from Codex with ~/.trail refused: nothing kept, the receipt unused; the same command in the person\'s terminal keeps it', async () => {+test('trail skills add from Codex with ~/.trail refused: nothing kept, the receipt unused; the same command in the person\'s terminal keeps it', { skip: NO_DENIAL }, async () => {const b = box('c8-sbx-add', { env: { TRAIL_TIER_CODEX: 'A' } });try {const s = cxSession(b);@@ -80,7 +84,7 @@ test('trail skills add from Codex with ~/.trail refused: nothing kept, the recei}});-test('trail skills update and lesson from Codex with ~/.trail refused say the same, with their own command; other hosts are as they were', () => {+test('trail skills update and lesson from Codex with ~/.trail refused say the same, with their own command; other hosts are as they were', { skip: NO_DENIAL }, () => {const root = mkdtempSync(join(tmpdir(), 'c8-sbx-rc-'));try {const home = join(root, 'home');diff --git a/test/telemetry-contract.test.ts b/test/telemetry-contract.test.tsindex c598945d..afb65b7f 100644--- a/test/telemetry-contract.test.ts+++ b/test/telemetry-contract.test.ts@@ -183,7 +183,7 @@ test('hookMsBucket collapses a hook time to a label', () => {test('TELEMETRY.md lists every event and every key the contract allows, and no event the contract lacks', () => {const doc = readFileSync(join(process.cwd(), 'TELEMETRY.md'), 'utf8');const rows = new Map<string, string>();- for (const line of doc.split('\n')) {+ for (const line of doc.split(/\r?\n/)) {const m = /^\| `([a-z_]+)` \|(.*)$/.exec(line);if (m && !['app_version', 'os', 'arch', 'node_major', 'ci', 'agent_host', 'cli_name', 'repo_id'].includes(m[1]!)) rows.set(m[1]!, m[2]!);}diff --git a/test/trail-prompt-activity.test.ts b/test/trail-prompt-activity.test.tsindex 969d2151..8313cef0 100644--- a/test/trail-prompt-activity.test.ts+++ b/test/trail-prompt-activity.test.ts@@ -13,7 +13,7 @@ import { tmpdir } from "node:os";import { join } from "node:path";import { pathToFileURL } from "node:url";import { BRAND_ENV } from "../src/brand.js";-import { main } from "../src/claude/hooks.js";+import { handlePrompt } from "../src/claude/prompt-hook.js";import { writeCloud, type Cloud } from "../src/cloud/workspace.js";import { buildGraph } from "../src/graph/build.js";import { tmpRepo } from "./helpers.js";@@ -102,12 +102,12 @@ test("a prompt's ask in a connected repo queues a use of the learnings, never aprocess.stdout.write = ((chunk: unknown, ...rest: unknown[]) => (typeof chunk === "string" ? ((said += chunk), true) : (write as (...a: unknown[]) => boolean)(chunk, ...rest))) as typeof process.stdout.write;process.env.CLAUDE_PROJECT_DIR = d;process.env.GRAFT_TEST_CLI = cliFromSource();- process.env.GRAFT_TEST_STDIN = JSON.stringify({ session_id: "s1", prompt: PROMPT });try {- await main("prompt");+ // The hook's own budget is 4 s; an ask child started from source through tsx can take longer than that on a+ // slow runner (Windows), so the hook is given the installed 60 s here: what is under test is what the child keeps.+ await handlePrompt({ session_id: "s1", prompt: PROMPT }, d, { budgetMs: 60_000 });} finally {process.stdout.write = write;- delete process.env.GRAFT_TEST_STDIN;delete process.env.GRAFT_TEST_CLI;delete process.env.CLAUDE_PROJECT_DIR;}diff --git a/test/trail-skills.test.ts b/test/trail-skills.test.tsindex 90d99968..d6228269 100644--- a/test/trail-skills.test.ts+++ b/test/trail-skills.test.ts@@ -176,8 +176,9 @@ test("a session hears about skills Claude Code can't load by itself, and nothinglearn(repo, { skill: "pdf-coords", text: ROTATION, author: "Sam", date: DAY });learn(repo, { skill: "deploys", text: "Run the migration check first.", author: "Sam", date: DAY });const line = skillsDirective(repo);- assert.match(line, /deploys \(1 correction newer than its SKILL\.md, in \S+\/deploys\/takeaways\)/);- assert.match(line, /pdf-coords \(on this machine: \S+\/pdf-coords\/SKILL\.md, then 1 correction in \S+\/pdf-coords\/takeaways\)/);+ // The paths are this machine's own, for the agent to read: `\` between folders on Windows.+ assert.match(line, /deploys \(1 correction newer than its SKILL\.md, in \S+[\\/]deploys[\\/]takeaways\)/);+ assert.match(line, /pdf-coords \(on this machine: \S+[\\/]pdf-coords[\\/]SKILL\.md, then 1 correction in \S+[\\/]pdf-coords[\\/]takeaways\)/);// `trail skills show` is the learned skills' command now: it can't print these (g7 review).assert.doesNotMatch(line, /skills show|run `/);assert.match(line, /Read them before working in one's area, the corrections newest first; they win where they disagree/);