testingterm 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/AGENT-DOCS.md +77 -0
  2. package/LICENSE +21 -0
  3. package/dist/ai.d.ts +24 -0
  4. package/dist/attach.d.ts +6 -0
  5. package/dist/capabilities.d.ts +6 -0
  6. package/dist/chunks/ai-MISD5ZKB.js +260 -0
  7. package/dist/chunks/args-FJPX5SKE.js +8 -0
  8. package/dist/chunks/attach-STVPRW4U.js +30 -0
  9. package/dist/chunks/chunk-66N3P624.js +44 -0
  10. package/dist/chunks/chunk-IJ5VA4HN.js +41 -0
  11. package/dist/chunks/chunk-INTJPVJZ.js +191 -0
  12. package/dist/chunks/chunk-NM755IGG.js +658 -0
  13. package/dist/chunks/chunk-PA67Y4XN.js +65 -0
  14. package/dist/chunks/chunk-U52LFC23.js +68 -0
  15. package/dist/chunks/chunk-YFGNBX2I.js +229 -0
  16. package/dist/chunks/chunk-YHQYNBAN.js +801 -0
  17. package/dist/chunks/commands-IWTFRW33.js +540 -0
  18. package/dist/chunks/context-QML5TP36.js +14 -0
  19. package/dist/chunks/help-I5WIJHZM.js +359 -0
  20. package/dist/chunks/paths-X3C4P67K.js +18 -0
  21. package/dist/chunks/run-RNFQMMXD.js +95 -0
  22. package/dist/chunks/setup-WIZULKES.js +106 -0
  23. package/dist/chunks/themes.gen-E3CTYIQE.js +8 -0
  24. package/dist/chunks/upgrade-43JWCQ63.js +143 -0
  25. package/dist/chunks/verify-55DFXJOY.js +37 -0
  26. package/dist/cli/args.d.ts +13 -0
  27. package/dist/cli/commands.d.ts +5 -0
  28. package/dist/cli/help.d.ts +2 -0
  29. package/dist/cli/main.d.ts +2 -0
  30. package/dist/cli/main.js +83 -0
  31. package/dist/cli/run.d.ts +2 -0
  32. package/dist/cli/setup.d.ts +6 -0
  33. package/dist/cli/upgrade.d.ts +19 -0
  34. package/dist/cli/verify.d.ts +2 -0
  35. package/dist/context.d.ts +33 -0
  36. package/dist/engine.d.ts +56 -0
  37. package/dist/errors.d.ts +4 -0
  38. package/dist/expect.d.ts +62 -0
  39. package/dist/index.d.ts +27 -0
  40. package/dist/index.js +205 -0
  41. package/dist/install.d.ts +13 -0
  42. package/dist/instances.d.ts +23 -0
  43. package/dist/locator.d.ts +49 -0
  44. package/dist/paths.d.ts +7 -0
  45. package/dist/runner.d.ts +56 -0
  46. package/dist/sync.d.ts +8 -0
  47. package/dist/terminal.d.ts +146 -0
  48. package/dist/themes.gen.d.ts +4 -0
  49. package/dist/types.d.ts +214 -0
  50. package/package.json +41 -4
  51. package/skill/testingterm/SKILL.md +138 -0
  52. package/README.md +0 -3
@@ -0,0 +1,359 @@
1
+ // src/cli/help.ts
2
+ var COMMANDS = {
3
+ run: {
4
+ summary: "Run test scripts and print the results",
5
+ usage: "testingterm run <file...> [options]\n testingterm run -e '<code>'",
6
+ body: `
7
+ Runs JavaScript or TypeScript files that use the testingterm library, then
8
+ prints what passed, what failed, and where the screenshots, videos and
9
+ profiles are. A file can be a plain script (top level await) or declare
10
+ tests with test(). "testingterm" resolves automatically, nothing to install.
11
+
12
+ Options:
13
+ -e, --eval <code> Run code directly; launch, expect and test are in scope
14
+ --headed Show every terminal in a window while it runs
15
+ --slow-mo <ms> Pause after every action (pairs well with --headed)
16
+ --video <mode> on, off or retain-on-failure (default off)
17
+ --profile Record a performance profile for every terminal
18
+ --out <dir> Where artifacts go (default a fresh temp folder)
19
+ --timeout <ms> Default timeout for waits and assertions (default 5000)
20
+ --test-timeout <ms> Timeout for each test (default 30000)
21
+ --retries <n> Retry failed tests n times
22
+ --workers <n> Files to run at once (default: number of CPUs)
23
+ --grep <pattern> Only run tests whose name matches
24
+ --theme <name> Theme for every terminal (testingterm themes lists them)
25
+ --capabilities <preset>
26
+ Imitate another terminal for every terminal: full,
27
+ xterm, apple-terminal, tmux, basic, dumb
28
+ --json Print results as JSON
29
+
30
+ Examples:
31
+ testingterm run tests/menu.test.mjs
32
+ testingterm run -e 'const t = launch("ls"); await expect(t).toHaveText("package.json"); await t.screenshot()'
33
+ testingterm run tests/*.mjs --video retain-on-failure --headed
34
+ `
35
+ },
36
+ new: {
37
+ summary: "Start a program in a new terminal and print its id",
38
+ usage: "testingterm new [options] [-- <command...>]",
39
+ body: `
40
+ Starts a terminal that stays open between commands, so you can drive it step
41
+ by step: screen, press, type, click, screenshot. Without a command it runs
42
+ your shell. Close it with testingterm close.
43
+
44
+ Options:
45
+ --name <name> A name to find it by (also used in file names)
46
+ --size <cols>x<rows> Grid size (default 100x30)
47
+ --cwd <dir> Working directory (default the current one)
48
+ --env KEY=VALUE Extra environment variable (repeatable)
49
+ --theme <name> dark, light, ghostty, rex, or any theme from testingterm themes
50
+ --headed Show the terminal in a window
51
+ --record [file] Record a video from the start
52
+ --profile [file] Record a profile from the start
53
+ --isolate Give the program a fresh, empty HOME
54
+ --capabilities <preset>
55
+ Imitate another terminal: full, xterm, apple-terminal,
56
+ tmux, basic, dumb (default full)
57
+ --disable <features> Turn features off, comma separated: mouse,
58
+ bracketed-paste, focus-events, synchronized-output,
59
+ alternate-screen, kitty-keyboard, kitty-graphics,
60
+ clipboard, hyperlinks, title, graphemes
61
+ --enable <features> Turn features back on after a preset
62
+ --colors <n> truecolor, 256, 16, 8 or none
63
+ --term <name> The TERM the program sees
64
+ --json Print the terminal's details as JSON
65
+
66
+ Examples:
67
+ testingterm new -- htop
68
+ testingterm new --name app --size 120x40 -- npm run dev
69
+ testingterm new --headed --record -- python3 tui.py
70
+ testingterm new --capabilities apple-terminal -- ./my-tui
71
+ testingterm new --disable mouse,kitty-keyboard --colors 16 -- ./my-tui
72
+ `
73
+ },
74
+ ls: {
75
+ summary: "List running terminals",
76
+ usage: "testingterm ls [--json]",
77
+ body: `
78
+ Lists terminals started with testingterm new and terminals that running
79
+ scripts opened, with the ids the other commands take.
80
+ `
81
+ },
82
+ screen: {
83
+ summary: "Print the screen's text, cursor and modes",
84
+ usage: "testingterm screen [--id <id>] [options]",
85
+ body: `
86
+ Prints the visible screen as text. The header line has the cursor position,
87
+ title and modes (alternate screen, mouse tracking) that decide how the
88
+ program reacts to input.
89
+
90
+ Options:
91
+ --styles Include colors and bold/underline for each span
92
+ --json Everything as JSON
93
+ `
94
+ },
95
+ scrollback: {
96
+ summary: "Print everything the program printed, including scrolled-off lines",
97
+ usage: "testingterm scrollback [--id <id>]",
98
+ body: ""
99
+ },
100
+ find: {
101
+ summary: "Show where text is on screen, in cells and screenshot pixels",
102
+ usage: "testingterm find [--id <id>] <text> [--regex]",
103
+ body: `
104
+ Prints each match with its row, column and the pixel center you can pass to
105
+ testingterm click.
106
+ `
107
+ },
108
+ type: {
109
+ summary: "Type text like a person at a keyboard",
110
+ usage: "testingterm type [--id <id>] <text> [--delay <ms>]",
111
+ body: `
112
+ Types the text. \\n presses Enter. --delay types one character at a time.
113
+
114
+ Examples:
115
+ testingterm type "hello world"
116
+ testingterm type 'ls -la\\n'
117
+ `
118
+ },
119
+ press: {
120
+ summary: "Press keys",
121
+ usage: "testingterm press [--id <id>] <key...> [--count <n>]",
122
+ body: `
123
+ Presses each key in order. Keys: Enter, Tab, Escape, Backspace, Up, Down,
124
+ Left, Right, Home, End, PageUp, PageDown, F1-F12, space, or a character,
125
+ with modifiers like ctrl+c, shift+Tab, alt+x, cmd+s.
126
+
127
+ Examples:
128
+ testingterm press Enter
129
+ testingterm press Down Down Enter
130
+ testingterm press ctrl+c
131
+ testingterm press j --count 5
132
+ `
133
+ },
134
+ paste: {
135
+ summary: "Paste text (bracketed paste when the program supports it)",
136
+ usage: "testingterm paste [--id <id>] <text>",
137
+ body: ""
138
+ },
139
+ click: {
140
+ summary: "Click at a pixel, a cell, or on text",
141
+ usage: "testingterm click [--id <id>] <x> <y> [options]\n testingterm click [--id <id>] --text <text> [options]",
142
+ body: `
143
+ Coordinates are pixels in screenshot space, so a point read off a screenshot
144
+ clicks that spot. --cell takes a column and row instead. --text waits for the
145
+ text and clicks its center. Programs only see clicks when they turned on mouse
146
+ reporting; the output says whether the click was sent.
147
+
148
+ Options:
149
+ --cell x and y are column and row
150
+ --text <text> Click this text (waits for it)
151
+ --nth <n> Which match when the text appears more than once
152
+ --right / --middle Another button
153
+ --double Double click
154
+ --timeout <ms> How long --text waits (default 5000)
155
+
156
+ Examples:
157
+ testingterm click 412 230
158
+ testingterm click --cell 10 4
159
+ testingterm click --text "Save"
160
+ `
161
+ },
162
+ move: {
163
+ summary: "Move the mouse (hover)",
164
+ usage: "testingterm move [--id <id>] <x> <y> [--cell]",
165
+ body: ""
166
+ },
167
+ drag: {
168
+ summary: "Drag with the left button from one point to another",
169
+ usage: "testingterm drag [--id <id>] <x1> <y1> <x2> <y2> [--cell]",
170
+ body: ""
171
+ },
172
+ wheel: {
173
+ summary: "Scroll the mouse wheel (positive is down)",
174
+ usage: "testingterm wheel [--id <id>] <lines> [<x> <y>]",
175
+ body: ""
176
+ },
177
+ wait: {
178
+ summary: "Wait for text, quiet, a steady screen, or exit",
179
+ usage: "testingterm wait [--id <id>] <condition> [--timeout <ms>]",
180
+ body: `
181
+ Waits until the condition holds and exits 0, or prints the screen and exits
182
+ 1 after the timeout (default 5000ms). Prefer this to sleeping.
183
+
184
+ Conditions:
185
+ --text <text> The text is on screen
186
+ --regex <pattern> A regex matches the screen
187
+ --gone <text> The text is no longer on screen
188
+ --idle <ms> The program printed nothing for this long
189
+ --stable <ms> The screen did not change for this long
190
+ --title <text> The title contains the text
191
+ --exit The program exited (prints the exit code)
192
+ --scrollback Search the whole history, not just the screen
193
+
194
+ Examples:
195
+ testingterm wait --text "Ready"
196
+ testingterm wait --stable 300
197
+ testingterm wait --exit --timeout 60000
198
+ `
199
+ },
200
+ screenshot: {
201
+ summary: "Save a PNG of the terminal",
202
+ usage: "testingterm screenshot [--id <id>] [file]",
203
+ body: `
204
+ Saves a pixel-exact PNG and prints its path. Without a file it goes in the
205
+ terminal's artifacts folder.
206
+
207
+ Options:
208
+ --no-cursor Leave the cursor out
209
+ `
210
+ },
211
+ record: {
212
+ summary: "Record a video",
213
+ usage: "testingterm record [--id <id>] start [file] [--fps <n>]\n testingterm record [--id <id>] stop",
214
+ body: `
215
+ Records an MP4 of the terminal, with the mouse pointer, clicks and key
216
+ presses drawn in. stop prints the file path.
217
+ `
218
+ },
219
+ profile: {
220
+ summary: "Record a performance profile",
221
+ usage: "testingterm profile [--id <id>] start [file]\n testingterm profile [--id <id>] stop",
222
+ body: `
223
+ Records what the program printed and when, its CPU and memory, every action
224
+ and wait, and render times. stop prints the path of a trace you can open at
225
+ https://ui.perfetto.dev.
226
+ `
227
+ },
228
+ theme: {
229
+ summary: "Switch a running terminal to another theme",
230
+ usage: "testingterm theme [--id <id>] <name>\n testingterm theme [--id <id>] [--base <name>] [--background <#hex>] [--foreground <#hex>] [--cursor <#hex>] [--cursor-text <#hex>]",
231
+ body: `
232
+ Applies a theme right away: dark, light, or any Ghostty or Rex theme by name
233
+ (case and spaces don't matter). "ghostty" and "rex" use the theme your
234
+ Ghostty config or Rex settings pick (add :light or :dark to choose a side).
235
+ Pass colors to override parts of a theme.
236
+
237
+ Examples:
238
+ testingterm theme Dracula
239
+ testingterm theme "Catppuccin Mocha"
240
+ testingterm theme ghostty
241
+ testingterm theme rex:light
242
+ testingterm theme --base Nord --background "#000000"
243
+ `
244
+ },
245
+ themes: {
246
+ summary: "List the themes testingterm knows",
247
+ usage: "testingterm themes [filter] [--json]",
248
+ body: `
249
+ Lists dark, light, ghostty, rex and every bundled Ghostty and Rex theme. A
250
+ filter keeps names that contain it.
251
+
252
+ Examples:
253
+ testingterm themes
254
+ testingterm themes catppuccin
255
+ `
256
+ },
257
+ resize: {
258
+ summary: "Change the grid size",
259
+ usage: "testingterm resize [--id <id>] <cols> <rows>",
260
+ body: ""
261
+ },
262
+ signal: {
263
+ summary: "Send a signal to the program",
264
+ usage: "testingterm signal [--id <id>] <signal>",
265
+ body: `
266
+ Examples:
267
+ testingterm signal SIGINT
268
+ testingterm signal TERM
269
+ `
270
+ },
271
+ close: {
272
+ summary: "Close a terminal",
273
+ usage: "testingterm close [--id <id>] [--all]",
274
+ body: `
275
+ Stops the program and the terminal, finishing any video or profile, and
276
+ prints their paths.
277
+ `
278
+ },
279
+ verify: {
280
+ summary: "Experimental: have Claude Code or Codex check the terminal",
281
+ usage: "testingterm verify [--id <id>] <what should be true> [options]",
282
+ body: `
283
+ Starts a coding agent over ACP (Claude Code if installed, otherwise Codex,
284
+ with their own sign-in) to look at the terminal and decide whether the
285
+ statement is true. Exits 0 on pass and 1 on fail, printing the agent's reason
286
+ and, on failure, a screenshot and notes.
287
+
288
+ Options:
289
+ --agent <name> claude or codex
290
+ --model <model> Model for the agent
291
+ --effort <level> Reasoning effort, if the agent supports it
292
+ --interact Let the agent press keys and click
293
+ --timeout <ms> Default 180000
294
+ --json Print the result as JSON
295
+ `
296
+ },
297
+ report: {
298
+ summary: "Record a check result (used by agents during verify)",
299
+ usage: "testingterm report [--id <id>] --pass <reason>\n testingterm report [--id <id>] --fail <reason>",
300
+ body: ""
301
+ },
302
+ setup: {
303
+ summary: "Install the testingterm skill for coding agents",
304
+ usage: "testingterm setup [--yes]",
305
+ body: `
306
+ Installs the testingterm skill for Claude Code, Codex, Cursor and Gemini so
307
+ they know how to test terminal apps with testingterm.
308
+ `
309
+ },
310
+ upgrade: {
311
+ summary: "Upgrade to the latest release",
312
+ usage: "testingterm upgrade [--check]",
313
+ body: `
314
+ Downloads and installs the latest release of this install's channel. Does
315
+ nothing when already up to date. --check only reports whether there is one.
316
+ `
317
+ },
318
+ version: {
319
+ summary: "Print the version",
320
+ usage: "testingterm version",
321
+ body: ""
322
+ }
323
+ };
324
+ function block(text) {
325
+ return `${text.trim()}
326
+ `;
327
+ }
328
+ function rootHelp() {
329
+ const width = Math.max(...Object.keys(COMMANDS).map((name) => name.length));
330
+ const lines = Object.entries(COMMANDS).map(([name, help]) => ` ${name.padEnd(width)} ${help.summary}`);
331
+ return block(`
332
+ Usage: testingterm <command> [args]
333
+
334
+ Test terminal apps: run them in a real terminal, drive them with keys and
335
+ mouse, read the screen, and capture screenshots, videos and profiles.
336
+
337
+ Commands:
338
+ ${lines.join("\n")}
339
+
340
+ Commands that act on a terminal take --id <id> (see testingterm ls); with one
341
+ terminal running they use it.
342
+
343
+ Run testingterm <command> --help for details.
344
+ `);
345
+ }
346
+ function commandHelp(name) {
347
+ const help = COMMANDS[name];
348
+ if (!help) return null;
349
+ return block(`${help.summary}
350
+
351
+ Usage: ${help.usage}
352
+ ${help.body ? `
353
+ ${help.body.trim()}
354
+ ` : ""}`);
355
+ }
356
+ export {
357
+ commandHelp,
358
+ rootHelp
359
+ };
@@ -0,0 +1,18 @@
1
+ import {
2
+ INSTANCES_DIR,
3
+ PACKAGE_ROOT,
4
+ SOCKETS_DIR,
5
+ STATE_DIR,
6
+ TARGET,
7
+ engineBinary,
8
+ version
9
+ } from "./chunk-PA67Y4XN.js";
10
+ export {
11
+ INSTANCES_DIR,
12
+ PACKAGE_ROOT,
13
+ SOCKETS_DIR,
14
+ STATE_DIR,
15
+ TARGET,
16
+ engineBinary,
17
+ version
18
+ };
@@ -0,0 +1,95 @@
1
+ import {
2
+ defaultWorkers,
3
+ evalFile,
4
+ runFiles
5
+ } from "./chunk-YHQYNBAN.js";
6
+ import "./chunk-INTJPVJZ.js";
7
+ import "./chunk-YFGNBX2I.js";
8
+ import {
9
+ settings
10
+ } from "./chunk-IJ5VA4HN.js";
11
+ import "./chunk-PA67Y4XN.js";
12
+ import {
13
+ UsageError
14
+ } from "./chunk-U52LFC23.js";
15
+
16
+ // src/cli/run.ts
17
+ import path from "node:path";
18
+ import os from "node:os";
19
+ var color = process.stdout.isTTY && !process.env.NO_COLOR;
20
+ var paint = (code, text) => color ? `\x1B[${code}m${text}\x1B[0m` : text;
21
+ function indent(text, by = " ") {
22
+ return text.split("\n").map((line2) => `${by}${line2}`).join("\n");
23
+ }
24
+ function line(result, single) {
25
+ const file = path.basename(result.file).startsWith("eval-") ? "inline script" : path.relative(process.cwd(), result.file);
26
+ const name = single ? file : `${file} \u203A ${result.name}`;
27
+ const time = paint("2", `(${result.durationMs}ms${result.attempts > 1 ? `, ${result.attempts} attempts` : ""})`);
28
+ if (result.status === "skipped") return `${paint("33", "-")} ${name} ${paint("2", "skipped")}`;
29
+ if (result.status === "passed") {
30
+ const files = result.artifacts.length ? `
31
+ ${indent(result.artifacts.join("\n"))}` : "";
32
+ return `${paint("32", "\u2713")} ${name} ${time}${files}`;
33
+ }
34
+ const parts = [`${paint("31", "\u2717")} ${name} ${time}`, indent(result.error ?? "failed")];
35
+ if (result.screen && !result.error?.includes("screen:")) parts.push(indent(`screen:
36
+ ${indent(result.screen.split("\n").slice(0, 40).join("\n"), " ")}`));
37
+ if (result.artifacts.length) parts.push(indent(`artifacts:
38
+ ${indent(result.artifacts.join("\n"), " ")}`));
39
+ return parts.join("\n");
40
+ }
41
+ async function runCommand(args) {
42
+ const code = args.value("-e", "--eval");
43
+ const headed = args.flag("--headed");
44
+ const slowMo = args.number("--slow-mo");
45
+ const video = args.value("--video");
46
+ const profile = args.flag("--profile");
47
+ const out = args.value("--out");
48
+ const timeout = args.number("--timeout");
49
+ const testTimeout = args.number("--test-timeout");
50
+ const retries = args.number("--retries") ?? 0;
51
+ const workers = args.number("--workers") ?? defaultWorkers();
52
+ const grep = args.value("--grep");
53
+ const json = args.flag("--json");
54
+ const theme = args.value("--theme");
55
+ const capabilities = args.value("--capabilities");
56
+ const files = args.positional();
57
+ if (video && !["on", "off", "retain-on-failure"].includes(video)) throw new UsageError("--video must be on, off or retain-on-failure");
58
+ if (!code && files.length === 0) throw new UsageError("needs test files or -e <code>");
59
+ const artifacts = path.resolve(out ?? settings.artifacts);
60
+ if (headed) settings.headed = true;
61
+ if (slowMo !== void 0) settings.slowMo = slowMo;
62
+ if (video) settings.video = video;
63
+ if (profile) settings.profile = true;
64
+ if (timeout !== void 0) settings.timeout = timeout;
65
+ if (theme) settings.theme = theme;
66
+ if (capabilities) settings.capabilities = capabilities;
67
+ const targets = code ? [evalFile(code, path.join(os.tmpdir(), "testingterm", "eval"))] : files.map((f) => path.resolve(f));
68
+ const single = targets.length === 1;
69
+ const result = await runFiles(targets, {
70
+ artifacts,
71
+ retries,
72
+ timeout: testTimeout ?? 3e4,
73
+ workers,
74
+ grep: grep ? new RegExp(grep) : void 0,
75
+ onResult: json ? void 0 : (r) => process.stdout.write(`${line(r, single && r.name === path.basename(r.file).replace(/\.[^.]+$/, ""))}
76
+ `)
77
+ });
78
+ if (json) {
79
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
80
+ `);
81
+ return result.ok ? 0 : 1;
82
+ }
83
+ const passed = result.tests.filter((t) => t.status === "passed").length;
84
+ const failed = result.tests.filter((t) => t.status === "failed").length;
85
+ const skipped = result.tests.filter((t) => t.status === "skipped").length;
86
+ const summary = [`${passed} passed`, failed ? paint("31", `${failed} failed`) : "", skipped ? `${skipped} skipped` : ""].filter(Boolean).join(", ");
87
+ process.stdout.write(`
88
+ ${summary} in ${result.durationMs}ms
89
+ artifacts: ${artifacts}
90
+ `);
91
+ return result.ok ? 0 : 1;
92
+ }
93
+ export {
94
+ runCommand
95
+ };
@@ -0,0 +1,106 @@
1
+ import {
2
+ installPaths,
3
+ installed
4
+ } from "./chunk-66N3P624.js";
5
+ import {
6
+ PACKAGE_ROOT,
7
+ STATE_DIR
8
+ } from "./chunk-PA67Y4XN.js";
9
+
10
+ // src/cli/setup.ts
11
+ import fs from "node:fs";
12
+ import os from "node:os";
13
+ import path from "node:path";
14
+ var AGENTS = [
15
+ { name: "Claude Code", dir: ".claude", skills: ".claude/skills" },
16
+ { name: "Codex", dir: ".codex", skills: ".codex/skills" },
17
+ { name: "Cursor", dir: ".cursor", skills: ".cursor/skills" },
18
+ { name: "Gemini", dir: ".gemini", skills: ".gemini/skills" }
19
+ ];
20
+ function skillSource() {
21
+ const shipped = path.join(PACKAGE_ROOT, "skill", "testingterm");
22
+ if (!installed()) return shipped;
23
+ fs.rmSync(installPaths.skill, { recursive: true, force: true });
24
+ fs.mkdirSync(installPaths.skill, { recursive: true });
25
+ fs.cpSync(shipped, path.join(installPaths.skill, "testingterm"), { recursive: true });
26
+ return path.join(installPaths.skill, "testingterm");
27
+ }
28
+ function ask(question) {
29
+ let tty;
30
+ try {
31
+ tty = fs.openSync("/dev/tty", "r+");
32
+ } catch {
33
+ return null;
34
+ }
35
+ try {
36
+ fs.writeSync(tty, question);
37
+ const byte = Buffer.alloc(1);
38
+ let line = "";
39
+ for (; ; ) {
40
+ let read;
41
+ try {
42
+ read = fs.readSync(tty, byte, 0, 1, null);
43
+ } catch (error) {
44
+ if (error.code === "EAGAIN") continue;
45
+ throw error;
46
+ }
47
+ if (read === 0 || byte.toString() === "\n") break;
48
+ line += byte.toString();
49
+ }
50
+ return line;
51
+ } finally {
52
+ fs.closeSync(tty);
53
+ }
54
+ }
55
+ function link(target, at) {
56
+ const existing = fs.lstatSync(at, { throwIfNoEntry: false });
57
+ if (existing && !existing.isSymbolicLink()) return "kept";
58
+ fs.mkdirSync(path.dirname(at), { recursive: true });
59
+ fs.rmSync(at, { force: true });
60
+ fs.symlinkSync(target, at);
61
+ return "linked";
62
+ }
63
+ function linkSkill() {
64
+ const source = skillSource();
65
+ const home = os.homedir();
66
+ const agents = [];
67
+ const kept = [];
68
+ for (const agent of AGENTS) {
69
+ if (!fs.existsSync(path.join(home, agent.dir))) continue;
70
+ const at = path.join(home, agent.skills, "testingterm");
71
+ if (link(source, at) === "linked") agents.push(agent.name);
72
+ else kept.push(at);
73
+ }
74
+ const shared = path.join(process.env.AGENT_SKILLS_HOME ?? path.join(home, ".agents", "skills"), "testingterm");
75
+ if (link(source, shared) === "kept") kept.push(shared);
76
+ fs.mkdirSync(STATE_DIR, { recursive: true });
77
+ fs.writeFileSync(path.join(STATE_DIR, "skill-choice"), "yes\n");
78
+ return { agents, kept };
79
+ }
80
+ async function setupCommand(args) {
81
+ const yes = args.flag("--yes", "-y");
82
+ const quietIfDeclined = args.flag("--from-installer");
83
+ args.positional();
84
+ if (!yes) {
85
+ const answer = ask("Install the testingterm skill so your coding agents know how to test terminal apps (recommended)? [Y/n] ");
86
+ if (answer === null && quietIfDeclined) return 0;
87
+ if (answer !== null && !/^(y|yes|)$/i.test(answer.trim())) {
88
+ fs.mkdirSync(STATE_DIR, { recursive: true });
89
+ fs.writeFileSync(path.join(STATE_DIR, "skill-choice"), "no\n");
90
+ if (!quietIfDeclined) process.stdout.write("skipped the skill; run testingterm setup any time to add it\n");
91
+ return 0;
92
+ }
93
+ }
94
+ const { agents, kept } = linkSkill();
95
+ process.stdout.write(`installed the testingterm skill ${agents.length ? `for ${agents.join(", ")} and ` : ""}in ~/.agents/skills
96
+ `);
97
+ for (const file of kept) {
98
+ process.stdout.write(`left ${file} alone because it is not a link testingterm made
99
+ `);
100
+ }
101
+ return 0;
102
+ }
103
+ export {
104
+ linkSkill,
105
+ setupCommand
106
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ GHOSTTY_THEMES,
3
+ REX_THEMES
4
+ } from "./chunk-NM755IGG.js";
5
+ export {
6
+ GHOSTTY_THEMES,
7
+ REX_THEMES
8
+ };