testSessionSaysWhereItsScratchFilesAre
A session says where its scratch files are, a directory named after its branch with / made _: in its
instructions, and in tcm_status. tcm_edit writes there, and a scratch file named by itself is there.
import { okIn, tempDir, withChildren } from "#codebase/tcmts/cli/test/e2e/harness"; import { session } from "#codebase/tcmts/cli/test/e2e/mcp"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; export const testSessionSaysWhereItsScratchFilesAre = () => withChildren(async (keep) => { const dir = tempDir("session scratch"); okIn(dir, "init"); fs.writeFileSync(path.join(dir, "scratch.ts"), `// tcm: namespace lib\nexport const x = 1;\n`); okIn(dir, "add"); const a = session(dir, keep, "--branch", "agent/a"); const init = await a.request("initialize", { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "test", version: "0" }, }); assert.match( String(init.result!.instructions), /scratch files are its own, in \.tcm\/sessions\/agent_a\//, ); assert.match((await a.call("tcm_status")).text, /scratch files +in \.tcm\/sessions\/agent_a\//); assert.match( (await a.call("tcm_edit", { names: ["lib.x"] })).text, /\.tcm\/sessions\/agent_a\/scratch\.ts/, ); assert.ok(fs.existsSync(path.join(dir, ".tcm", "sessions", "agent_a", "scratch.ts"))); })