The best way to control Claude Code, Codex and more from any computer or phone
| 1 | // @effect-diagnostics nodeBuiltinImport:off |
| 2 | import * as NodeFS from "node:fs"; |
| 3 | import * as NodePath from "node:path"; |
| 4 | |
| 5 | import { assert, it } from "@effect/vitest"; |
| 6 | |
| 7 | import { |
| 8 | buildTriageContext, |
| 9 | buildTriageLaunchPrompt, |
| 10 | type TriageContextInput, |
| 11 | TRIAGE_PLAYBOOK, |
| 12 | } from "./triagePrompt.ts"; |
| 13 | |
| 14 | it("stays byte-identical to .github/triage/PLAYBOOK.md", () => { |
| 15 | // Older releases fetch the repository playbook. |
| 16 | const canonicalPath = NodePath.join( |
| 17 | import.meta.dirname, |
| 18 | "../../../../.github/triage/PLAYBOOK.md", |
| 19 | ); |
| 20 | assert.equal(TRIAGE_PLAYBOOK, NodeFS.readFileSync(canonicalPath, "utf8")); |
| 21 | }); |
| 22 | |
| 23 | it("launch prompt stays a single argv-safe line naming the prompt file", () => { |
| 24 | // Windows .cmd shims cannot carry multiline argv. |
| 25 | const launch = buildTriageLaunchPrompt(String.raw`C:\Users\a b\.t3\userdata\triage\x\prompt.md`); |
| 26 | assert.notInclude(launch, "\n"); |
| 27 | assert.include(launch, String.raw`C:\Users\a b\.t3\userdata\triage\x\prompt.md`); |
| 28 | assert.isBelow(launch.length, 1_000); |
| 29 | }); |
| 30 | |
| 31 | it("context file labels the CLI version as the CLI's, not the user's build", () => { |
| 32 | const context = buildTriageContext({ |
| 33 | ...contextInput, |
| 34 | entry: { kind: "cli", cliVersion: "0.0.42", launchedAs: "npx t3 triage" }, |
| 35 | server: "running (pid 42, http://127.0.0.1:3773, version 0.0.43-nightly.20260923.2173)", |
| 36 | }); |
| 37 | assert.notInclude(context, "Installed version"); |
| 38 | assert.notInclude(context, "Release tag"); |
| 39 | assert.include(context, "- Triage CLI version: 0.0.42 ("); |
| 40 | assert.include(context, "version 0.0.43-nightly.20260923.2173"); |
| 41 | assert.notInclude(context, "runs inside T3 Code"); |
| 42 | }); |
| 43 | |
| 44 | it("in-app context warns the agent off its own server and points at the clone in progress", () => { |
| 45 | const context = buildTriageContext({ |
| 46 | ...contextInput, |
| 47 | entry: { kind: "app", client: "T3 Code Desktop version 0.1.1 on macos" }, |
| 48 | server: "running (pid 42, version 0.1.1); this session runs inside it", |
| 49 | sourceClone: { |
| 50 | _tag: "cloning", |
| 51 | directory: "/home/u/.t3/source/abc123", |
| 52 | ref: "v0.1.1", |
| 53 | commit: "abc123", |
| 54 | serverVersion: "0.1.1", |
| 55 | }, |
| 56 | }); |
| 57 | assert.notInclude(context, "Triage CLI version"); |
| 58 | assert.include(context, "- Started from: T3 Code Desktop version 0.1.1 on macos ("); |
| 59 | assert.include(context, "## This session runs inside T3 Code"); |
| 60 | assert.include(context, "/home/u/.t3/source/abc123 (v0.1.1, commit abc123)"); |
| 61 | assert.include(context, "Wait for it instead of\ncloning again."); |
| 62 | }); |
| 63 | |
| 64 | const contextInput = { |
| 65 | generatedAt: "2026-09-24T00:00:00.000Z", |
| 66 | os: "linux x64 (7.2.0)", |
| 67 | nodeVersion: "v26.8.2", |
| 68 | paths: { |
| 69 | stateDir: "/home/u/.t3/userdata", |
| 70 | dbPath: "/home/u/.t3/userdata/state.sqlite", |
| 71 | settingsPath: "/home/u/.t3/userdata/settings.json", |
| 72 | logsDir: "/home/u/.t3/userdata/logs", |
| 73 | serviceLogPath: "/home/u/.t3/userdata/logs/boot-service.log", |
| 74 | desktopBackendLogGlob: "/home/u/.t3/userdata/logs/server-child*.log*", |
| 75 | relayClientLogPath: "/home/u/.t3/userdata/logs/relay-client.ndjson", |
| 76 | serverTracePath: "/home/u/.t3/userdata/logs/server.trace.ndjson", |
| 77 | providerEventLogPath: "/home/u/.t3/userdata/logs/provider/events.log", |
| 78 | terminalLogsDir: "/home/u/.t3/userdata/logs/terminals", |
| 79 | providerStatusCacheDir: "/home/u/.t3/caches", |
| 80 | secretsDir: "/home/u/.t3/userdata/secrets", |
| 81 | sourceCacheDir: "/home/u/.t3/source", |
| 82 | }, |
| 83 | } satisfies Omit<TriageContextInput, "entry" | "server">; |