Open History to see the last commit
1// @effect-diagnostics nodeBuiltinImport:off
2import * as NodeFS from "node:fs";
3import * as NodePath from "node:path";
4
5import { assert, it } from "@effect/vitest";
6
7import {
8 buildTriageContext,
9 buildTriageLaunchPrompt,
10 buildTriageSeedPrompt,
11 TRIAGE_PLAYBOOK,
12} from "./triagePrompt.ts";
13
14it("stays byte-identical to .github/triage/PLAYBOOK.md", () => {
15 // Old releases fetch the repo copy from `main` and follow it when it differs
16 // from their bundled playbook. The two must say the same thing at HEAD, or a
17 // playbook edit silently changes behavior only for old (or only for new)
18 // installs. Edit both files together.
19 const canonicalPath = NodePath.join(
20 import.meta.dirname,
21 "../../../../.github/triage/PLAYBOOK.md",
22 );
23 assert.equal(TRIAGE_PLAYBOOK, NodeFS.readFileSync(canonicalPath, "utf8"));
24});
25
26it("seed prompt names the context file and embeds the playbook", () => {
27 const prompt = buildTriageSeedPrompt("/tmp/triage-run/context.md");
28 assert.include(prompt, "/tmp/triage-run/context.md");
29 assert.include(prompt, TRIAGE_PLAYBOOK);
30});
31
32it("launch prompt stays a single argv-safe line naming the prompt file", () => {
33 // The launch argument goes through cmd.exe on Windows (.cmd shims), which
34 // cannot carry newlines; the playbook itself must stay on disk.
35 const launch = buildTriageLaunchPrompt(String.raw`C:\Users\a b\.t3\userdata\triage\x\prompt.md`);
36 assert.notInclude(launch, "\n");
37 assert.include(launch, String.raw`C:\Users\a b\.t3\userdata\triage\x\prompt.md`);
38 assert.isBelow(launch.length, 1_000);
39});
40
41it("context file carries every path the playbook depends on", () => {
42 const context = buildTriageContext({
43 generatedAt: "2026-08-13T00:00:00.000Z",
44 version: "0.0.33",
45 releaseTag: "v0.0.33",
46 os: "linux x64 (7.0.0)",
47 nodeVersion: "v24.0.0",
48 launchedAs: "npx t3 triage",
49 server: "running (pid 42, http://127.0.0.1:4501)",
50 paths: {
51 stateDir: "/home/u/.t3/userdata",
52 dbPath: "/home/u/.t3/userdata/state.sqlite",
53 settingsPath: "/home/u/.t3/userdata/settings.json",
54 logsDir: "/home/u/.t3/userdata/logs",
55 serviceLogPath: "/home/u/.t3/userdata/logs/boot-service.log",
56 desktopBackendLogGlob: "/home/u/.t3/userdata/logs/server-child*.log*",
57 serverTracePath: "/home/u/.t3/userdata/logs/server.trace.ndjson",
58 providerEventLogPath: "/home/u/.t3/userdata/logs/provider/events.log",
59 terminalLogsDir: "/home/u/.t3/userdata/logs/terminals",
60 providerStatusCacheDir: "/home/u/.t3/caches",
61 secretsDir: "/home/u/.t3/userdata/secrets",
62 sourceCacheDir: "/home/u/.t3/source",
63 },
64 });
65 assert.include(context, "/home/u/.t3/userdata/state.sqlite");
66 assert.include(context, "/home/u/.t3/userdata/logs/server.trace.ndjson");
67 assert.include(context, "/home/u/.t3/userdata/logs/boot-service.log");
68 assert.include(context, "/home/u/.t3/userdata/logs/server-child*.log*");
69 assert.include(context, "/home/u/.t3/userdata/logs/provider/events.log");
70 assert.include(context, "/home/u/.t3/userdata/secrets");
71 assert.include(context, "/home/u/.t3/source");
72 assert.include(context, "npx t3 triage");
73 assert.include(context, "v0.0.33");
74});