Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

triagePrompt.test.ts

59 lines2.7 KB

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 { buildTriageContext, buildTriageLaunchPrompt, TRIAGE_PLAYBOOK } from "./triagePrompt.ts";
8​
9it("stays byte-identical to .github/triage/PLAYBOOK.md", () => {
10 // Old releases fetch the repo copy from `main` and follow it when it differs
11 // from their bundled playbook. The two must say the same thing at HEAD, or a
12 // playbook edit silently changes behavior only for old (or only for new)
13 // installs.
14 const canonicalPath = NodePath.join(
15 import.meta.dirname,
16 "../../../../.github/triage/PLAYBOOK.md",
17 );
18 assert.equal(TRIAGE_PLAYBOOK, NodeFS.readFileSync(canonicalPath, "utf8"));
19});
20​
21it("launch prompt stays a single argv-safe line naming the prompt file", () => {
22 // The launch argument goes through cmd.exe on Windows (.cmd shims), which
23 // cannot carry newlines; the playbook itself must stay on disk.
24 const launch = buildTriageLaunchPrompt(String.raw`C:\Users\a b\.t3\userdata\triage\x\prompt.md`);
25 assert.notInclude(launch, "\n");
26 assert.include(launch, String.raw`C:\Users\a b\.t3\userdata\triage\x\prompt.md`);
27 assert.isBelow(launch.length, 1_000);
28});
29​
30it("context file labels the CLI version as the CLI's, not the user's build", () => {
31 // `npx t3 triage` can resolve a different `t3` than the app the bug
32 // happened on (#13337), so the agent must not read it as the user's version.
33 const context = buildTriageContext({
34 generatedAt: "2026-09-24T00:00:00.000Z",
35 cliVersion: "0.0.42",
36 os: "linux x64 (7.2.0)",
37 nodeVersion: "v26.8.2",
38 launchedAs: "npx t3 triage",
39 server: "running (pid 42, http://127.0.0.1:3773, version 0.0.43-nightly.20260923.2173)",
40 paths: {
41 stateDir: "/home/u/.t3/userdata",
42 dbPath: "/home/u/.t3/userdata/state.sqlite",
43 settingsPath: "/home/u/.t3/userdata/settings.json",
44 logsDir: "/home/u/.t3/userdata/logs",
45 serviceLogPath: "/home/u/.t3/userdata/logs/boot-service.log",
46 desktopBackendLogGlob: "/home/u/.t3/userdata/logs/server-child*.log*",
47 serverTracePath: "/home/u/.t3/userdata/logs/server.trace.ndjson",
48 providerEventLogPath: "/home/u/.t3/userdata/logs/provider/events.log",
49 terminalLogsDir: "/home/u/.t3/userdata/logs/terminals",
50 providerStatusCacheDir: "/home/u/.t3/caches",
51 secretsDir: "/home/u/.t3/userdata/secrets",
52 sourceCacheDir: "/home/u/.t3/source",
53 },
54 });
55 assert.notInclude(context, "Installed version");
56 assert.notInclude(context, "Release tag");
57 assert.include(context, "- Triage CLI version: 0.0.42 (");
58 assert.include(context, "version 0.0.43-nightly.20260923.2173");
59});