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,540 @@
1
+ import {
2
+ resolveCapabilities,
3
+ syncTheme
4
+ } from "./chunk-INTJPVJZ.js";
5
+ import {
6
+ DESCRIBE_HEADER,
7
+ connectSocket,
8
+ describe,
9
+ findInstance,
10
+ listInstances,
11
+ newId,
12
+ removeInstance,
13
+ socketPath,
14
+ writeInstance
15
+ } from "./chunk-YFGNBX2I.js";
16
+ import {
17
+ STATE_DIR,
18
+ engineBinary
19
+ } from "./chunk-PA67Y4XN.js";
20
+ import {
21
+ UsageError
22
+ } from "./chunk-U52LFC23.js";
23
+
24
+ // src/cli/commands.ts
25
+ import { spawn } from "node:child_process";
26
+ import fs from "node:fs";
27
+ import os from "node:os";
28
+ import path from "node:path";
29
+ import { setTimeout as sleep } from "node:timers/promises";
30
+ function print(value) {
31
+ process.stdout.write(typeof value === "string" ? value.endsWith("\n") ? value : `${value}
32
+ ` : `${JSON.stringify(value, null, 2)}
33
+ `);
34
+ }
35
+ async function open(args) {
36
+ const record = findInstance(args.value("--id"));
37
+ try {
38
+ return { record, connection: await connectSocket(record.socket) };
39
+ } catch {
40
+ removeInstance(record.id);
41
+ throw new Error(`terminal ${record.id} is not responding; it was removed from the list`);
42
+ }
43
+ }
44
+ async function call(args, op, params = {}) {
45
+ const { connection } = await open(args);
46
+ try {
47
+ return await connection.request(op, params);
48
+ } finally {
49
+ connection.close();
50
+ }
51
+ }
52
+ function artifactsDir(id) {
53
+ const dir = path.join(os.tmpdir(), "testingterm", id);
54
+ fs.mkdirSync(dir, { recursive: true });
55
+ return dir;
56
+ }
57
+ function point(values, cell) {
58
+ const [x, y] = values.map(Number);
59
+ if (!Number.isFinite(x) || !Number.isFinite(y)) throw new UsageError("needs <x> <y> as numbers");
60
+ return cell ? { x, y, unit: "cell" } : { x, y };
61
+ }
62
+ function parseSize(size) {
63
+ if (!size) return { cols: 100, rows: 30 };
64
+ const match = /^(\d+)x(\d+)$/.exec(size);
65
+ if (!match) throw new UsageError("--size must look like 100x30");
66
+ return { cols: Number(match[1]), rows: Number(match[2]) };
67
+ }
68
+ var FEATURES = {
69
+ mouse: "mouse",
70
+ "bracketed-paste": "bracketedPaste",
71
+ "focus-events": "focusEvents",
72
+ "synchronized-output": "synchronizedOutput",
73
+ "alternate-screen": "alternateScreen",
74
+ "kitty-keyboard": "kittyKeyboard",
75
+ "kitty-graphics": "kittyGraphics",
76
+ clipboard: "clipboard",
77
+ hyperlinks: "hyperlinks",
78
+ title: "title",
79
+ graphemes: "graphemes"
80
+ };
81
+ function capabilitiesFrom(args) {
82
+ const preset = args.value("--capabilities") ?? process.env.TESTINGTERM_CAPABILITIES;
83
+ const spec = { preset };
84
+ for (const [flag, value] of [["--disable", false], ["--enable", true]]) {
85
+ for (const list of args.values(flag)) {
86
+ for (const name of list.split(",").map((n) => n.trim()).filter(Boolean)) {
87
+ if (!FEATURES[name]) throw new UsageError(`unknown feature "${name}" (${Object.keys(FEATURES).join(", ")})`);
88
+ spec[FEATURES[name]] = value;
89
+ }
90
+ }
91
+ }
92
+ const colors = args.value("--colors");
93
+ if (colors) spec.colors = /^\d+$/.test(colors) ? Number(colors) : colors;
94
+ const term = args.value("--term");
95
+ if (term) spec.term = term;
96
+ return resolveCapabilities(spec);
97
+ }
98
+ function commandOf(passthrough) {
99
+ if (passthrough.length === 1 && /\s/.test(passthrough[0])) return ["/bin/sh", "-c", passthrough[0]];
100
+ return passthrough;
101
+ }
102
+ async function newCommand(args) {
103
+ const name = args.value("--name");
104
+ const { cols, rows } = parseSize(args.value("--size"));
105
+ const cwd = path.resolve(args.value("--cwd") ?? process.cwd());
106
+ const env = Object.fromEntries(
107
+ args.values("--env").map((pair) => {
108
+ const at = pair.indexOf("=");
109
+ if (at < 1) throw new UsageError("--env must look like KEY=VALUE");
110
+ return [pair.slice(0, at), pair.slice(at + 1)];
111
+ })
112
+ );
113
+ const requested = args.value("--theme") ?? process.env.TESTINGTERM_THEME ?? "dark";
114
+ const synced = syncTheme(requested);
115
+ const theme = synced?.theme ?? requested;
116
+ const headed = args.flag("--headed");
117
+ const record = args.optional("--record");
118
+ const profile = args.optional("--profile");
119
+ const isolate = args.flag("--isolate");
120
+ const capabilities = capabilitiesFrom(args);
121
+ const json = args.flag("--json");
122
+ args.positional();
123
+ const command = commandOf(args.passthrough);
124
+ const id = newId();
125
+ const artifacts = artifactsDir(id);
126
+ if (isolate) {
127
+ const home = path.join(artifacts, "home");
128
+ fs.mkdirSync(home, { recursive: true });
129
+ Object.assign(env, { HOME: home, XDG_CONFIG_HOME: path.join(home, ".config"), XDG_DATA_HOME: path.join(home, ".local/share"), XDG_STATE_HOME: path.join(home, ".local/state"), XDG_CACHE_HOME: path.join(home, ".cache"), ZDOTDIR: home });
130
+ }
131
+ const socket = socketPath(id);
132
+ const config = {
133
+ command,
134
+ cwd,
135
+ env,
136
+ cols,
137
+ rows,
138
+ fontSize: synced?.fontSize ?? 13,
139
+ scale: 2,
140
+ padding: 8,
141
+ theme,
142
+ headed,
143
+ stdio: false,
144
+ listen: socket,
145
+ record: record === void 0 ? void 0 : record === true ? path.join(artifacts, `${id}.mp4`) : path.resolve(record),
146
+ fps: 30,
147
+ overlay: true,
148
+ profile: profile === void 0 ? void 0 : profile === true ? path.join(artifacts, `${id}.profile.json`) : path.resolve(profile),
149
+ keepAlive: true,
150
+ cursor: true,
151
+ title: name ? `testingterm \u2014 ${name}` : void 0,
152
+ capabilities
153
+ };
154
+ const logs = path.join(STATE_DIR, "logs");
155
+ fs.mkdirSync(logs, { recursive: true });
156
+ const log = fs.openSync(path.join(logs, `${id}.log`), "a");
157
+ const child = spawn(engineBinary(headed), ["--config", JSON.stringify(config)], { detached: true, stdio: ["ignore", "ignore", log] });
158
+ child.unref();
159
+ fs.closeSync(log);
160
+ const deadline = Date.now() + 5e3;
161
+ for (; ; ) {
162
+ try {
163
+ const connection = await connectSocket(socket);
164
+ connection.close();
165
+ break;
166
+ } catch {
167
+ if (child.exitCode !== null || Date.now() > deadline) {
168
+ const detail = fs.readFileSync(path.join(logs, `${id}.log`), "utf8").trim().split("\n").at(-1);
169
+ throw new Error(`the terminal did not start${detail ? `: ${detail}` : ""}`);
170
+ }
171
+ await sleep(3);
172
+ }
173
+ }
174
+ const label = command.length ? command[0] === "/bin/sh" ? command[2].split(/\s+/)[0] : path.basename(command[0]) : "shell";
175
+ const instance = {
176
+ id,
177
+ name: name ?? label,
178
+ pid: child.pid ?? 0,
179
+ socket,
180
+ command,
181
+ cwd,
182
+ cols,
183
+ rows,
184
+ createdAt: Date.now(),
185
+ owner: "cli",
186
+ ownerPid: process.pid,
187
+ artifacts,
188
+ headed
189
+ };
190
+ writeInstance(instance);
191
+ if (json) print(instance);
192
+ else print(`${id}
193
+ (testingterm screen --id ${id} to read it, testingterm close --id ${id} when done)`);
194
+ return 0;
195
+ }
196
+ async function lsCommand(args) {
197
+ const json = args.flag("--json");
198
+ args.positional();
199
+ const all = listInstances();
200
+ if (json) print(all);
201
+ else print(all.length ? `${DESCRIBE_HEADER}
202
+ ${all.map(describe).join("\n")}` : "no terminals running");
203
+ return 0;
204
+ }
205
+ function header(screen) {
206
+ const parts = [];
207
+ const cursor = screen.cursor;
208
+ parts.push(cursor ? `cursor ${cursor.col},${cursor.row}${cursor.visible ? "" : " (hidden)"}` : "cursor off screen");
209
+ parts.push(`${screen.cols}x${screen.rows}`);
210
+ if (screen.title) parts.push(`title ${JSON.stringify(screen.title)}`);
211
+ if (screen.altScreen) parts.push("alt screen");
212
+ if (screen.mouseTracking) parts.push("mouse on");
213
+ if (screen.kittyKeyboard) parts.push(`kitty keys ${screen.kittyKeyboard}`);
214
+ if (screen.exited) parts.push(`exited ${screen.exitCode ?? screen.signal ?? ""}`.trim());
215
+ return `[${parts.join(" \xB7 ")}]`;
216
+ }
217
+ async function screenCommand(args) {
218
+ const styles = args.flag("--styles");
219
+ const json = args.flag("--json");
220
+ args.positional();
221
+ const screen = await call(args, "screen", { styles });
222
+ const { id: _, ok: __, ...rest } = screen;
223
+ if (json) {
224
+ print(rest);
225
+ return 0;
226
+ }
227
+ if (styles) {
228
+ const rows = screen.styles;
229
+ print(header(screen));
230
+ rows.forEach((spans, row) => {
231
+ const meaningful = spans.filter((s) => Object.keys(s).length > 2 || String(s.text).trim());
232
+ if (!meaningful.length) return;
233
+ print(`${String(row).padStart(3)}: ${meaningful.map((s) => {
234
+ const { text, col: ___, ...style } = s;
235
+ const tags = Object.entries(style).map(([k, v]) => v === true ? k : `${k}=${v}`).join(" ");
236
+ const shown = JSON.stringify(String(text).trimEnd() || " ");
237
+ return tags ? `[${tags}]${shown}` : shown;
238
+ }).join(" ")}`);
239
+ });
240
+ return 0;
241
+ }
242
+ print(`${header(screen)}
243
+ ${screen.text}`);
244
+ return 0;
245
+ }
246
+ async function scrollbackCommand(args) {
247
+ args.positional();
248
+ print(String((await call(args, "scrollback")).text ?? ""));
249
+ return 0;
250
+ }
251
+ async function findCommand(args) {
252
+ const regex = args.flag("--regex");
253
+ const json = args.flag("--json");
254
+ const [text] = args.positional();
255
+ if (!text) throw new UsageError("needs the text to find");
256
+ const reply = await call(args, "find", regex ? { regex: text } : { text });
257
+ const matches = reply.matches;
258
+ if (json) print(matches);
259
+ else print(matches.length ? matches.map((m) => `row ${m.row} col ${m.col} (${m.width} cells) center ${Math.round(m.center.x)},${Math.round(m.center.y)} ${JSON.stringify(m.text)}`).join("\n") : "not on screen");
260
+ return matches.length ? 0 : 1;
261
+ }
262
+ function unescape(text) {
263
+ return text.replace(/\\(n|r|t|e|\\)/g, (_, c) => ({ n: "\n", r: "\r", t: " ", e: "\x1B", "\\": "\\" })[c]);
264
+ }
265
+ async function typeCommand(args) {
266
+ const delay = args.number("--delay");
267
+ const text = args.positional().join(" ");
268
+ if (!text) throw new UsageError("needs the text to type");
269
+ await call(args, "type", { text: unescape(text), delay });
270
+ return 0;
271
+ }
272
+ async function pressCommand(args) {
273
+ const count = args.number("--count");
274
+ const keys = args.positional();
275
+ if (!keys.length) throw new UsageError("needs at least one key, like Enter or ctrl+c");
276
+ await call(args, "press", { keys, count });
277
+ return 0;
278
+ }
279
+ async function pasteCommand(args) {
280
+ const text = args.positional().join(" ");
281
+ await call(args, "paste", { text: unescape(text) });
282
+ return 0;
283
+ }
284
+ async function clickCommand(args) {
285
+ const cell = args.flag("--cell");
286
+ const text = args.value("--text");
287
+ const nth = args.number("--nth");
288
+ const button = args.flag("--right") ? "right" : args.flag("--middle") ? "middle" : "left";
289
+ const double = args.flag("--double");
290
+ const timeout = args.number("--timeout") ?? 5e3;
291
+ const values = args.positional();
292
+ const { connection } = await open(args);
293
+ try {
294
+ let target;
295
+ let label;
296
+ if (text !== void 0) {
297
+ await connection.request("wait", { text, timeout });
298
+ const matches = (await connection.request("find", { text })).matches;
299
+ if (matches.length > 1 && nth === void 0) {
300
+ throw new Error(`"${text}" is on screen ${matches.length} times; pass --nth <n>:
301
+ ${matches.map((m, i) => ` ${i}: row ${m.row} col ${m.col}`).join("\n")}`);
302
+ }
303
+ const match = matches[nth ?? 0];
304
+ if (!match) throw new Error(`no match ${nth} for "${text}"`);
305
+ target = match.center;
306
+ label = `"${text}" at row ${match.row} col ${match.col + Math.floor(match.width / 2)}`;
307
+ } else {
308
+ target = point(values, cell);
309
+ label = cell ? `cell ${values[0]},${values[1]}` : `${values[0]},${values[1]}`;
310
+ }
311
+ const reply = await connection.request("mouse", { action: double ? "dblclick" : "click", ...target, button });
312
+ print(reply.sent ? `clicked ${label}` : `clicked ${label}, but the program has mouse reporting off, so it got nothing`);
313
+ } finally {
314
+ connection.close();
315
+ }
316
+ return 0;
317
+ }
318
+ async function moveCommand(args) {
319
+ const cell = args.flag("--cell");
320
+ await call(args, "mouse", { action: "move", ...point(args.positional(), cell) });
321
+ return 0;
322
+ }
323
+ async function dragCommand(args) {
324
+ const cell = args.flag("--cell");
325
+ const [x1, y1, x2, y2] = args.positional();
326
+ const { connection } = await open(args);
327
+ try {
328
+ await connection.request("mouse", { action: "down", ...point([x1, y1], cell) });
329
+ for (let i = 1; i <= 5; i++) {
330
+ const x = Number(x1) + (Number(x2) - Number(x1)) * i / 5;
331
+ const y = Number(y1) + (Number(y2) - Number(y1)) * i / 5;
332
+ await connection.request("mouse", { action: "move", ...point([String(x), String(y)], cell) });
333
+ }
334
+ await connection.request("mouse", { action: "up", ...point([x2, y2], cell) });
335
+ } finally {
336
+ connection.close();
337
+ }
338
+ return 0;
339
+ }
340
+ async function wheelCommand(args) {
341
+ const [lines, x, y] = args.positional();
342
+ const info = await call(args, "info");
343
+ await call(args, "mouse", { action: "wheel", deltaY: Number(lines), x: x ? Number(x) : Number(info.width) / 2, y: y ? Number(y) : Number(info.height) / 2 });
344
+ return 0;
345
+ }
346
+ async function waitCommand(args) {
347
+ const timeout = args.number("--timeout") ?? 5e3;
348
+ const scrollback = args.flag("--scrollback");
349
+ const params = { timeout, scrollback };
350
+ const text = args.value("--text");
351
+ const regex = args.value("--regex");
352
+ const gone = args.value("--gone");
353
+ const idle = args.number("--idle");
354
+ const stable = args.number("--stable");
355
+ const title = args.value("--title");
356
+ const exit = args.flag("--exit");
357
+ const positional = args.positional();
358
+ if (text !== void 0) params.text = text;
359
+ else if (regex !== void 0) params.regex = regex;
360
+ else if (gone !== void 0) params.gone = gone;
361
+ else if (idle !== void 0) params.idle = idle;
362
+ else if (stable !== void 0) params.stable = stable;
363
+ else if (title !== void 0) params.title = title;
364
+ else if (exit) params.exit = true;
365
+ else if (positional.length) params.text = positional.join(" ");
366
+ else throw new UsageError("needs a condition: --text, --regex, --gone, --idle, --stable, --title or --exit");
367
+ const reply = await call(args, "wait", params);
368
+ if (exit) print(`exited with code ${reply.exitCode ?? "?"}${reply.signal ? ` (${reply.signal})` : ""} after ${reply.elapsedMs}ms`);
369
+ else print(`ok after ${reply.elapsedMs}ms${reply.match ? `: ${JSON.stringify(reply.match)}` : ""}`);
370
+ return 0;
371
+ }
372
+ async function screenshotCommand(args) {
373
+ const cursor = !args.flag("--no-cursor");
374
+ const [file] = args.positional();
375
+ const { record, connection } = await open(args);
376
+ try {
377
+ const target = file ? path.resolve(file) : path.join(record.artifacts, `${record.id}-${Date.now()}.png`);
378
+ const reply = await connection.request("screenshot", { path: target, cursor });
379
+ print(`${reply.path} (${reply.width}x${reply.height})`);
380
+ } finally {
381
+ connection.close();
382
+ }
383
+ return 0;
384
+ }
385
+ async function recordCommand(args) {
386
+ const fps = args.number("--fps");
387
+ const [action, file] = args.positional();
388
+ const { record, connection } = await open(args);
389
+ try {
390
+ if (action === "start") {
391
+ const target = file ? path.resolve(file) : path.join(record.artifacts, `${record.id}-${Date.now()}.mp4`);
392
+ await connection.request("record", { action: "start", path: target, fps });
393
+ print(`recording to ${target} (testingterm record stop to finish)`);
394
+ } else if (action === "stop") {
395
+ const reply = await connection.request("record", { action: "stop" });
396
+ print(`${reply.path} (${(reply.durationMs / 1e3).toFixed(1)}s)`);
397
+ } else {
398
+ throw new UsageError("needs start or stop");
399
+ }
400
+ } finally {
401
+ connection.close();
402
+ }
403
+ return 0;
404
+ }
405
+ async function profileCommand(args) {
406
+ const [action, file] = args.positional();
407
+ const { record, connection } = await open(args);
408
+ try {
409
+ if (action === "start") {
410
+ const target = file ? path.resolve(file) : path.join(record.artifacts, `${record.id}-${Date.now()}.profile.json`);
411
+ await connection.request("profile", { action: "start", path: target });
412
+ print(`profiling to ${target} (testingterm profile stop to finish)`);
413
+ } else if (action === "stop") {
414
+ const reply = await connection.request("profile", { action: "stop" });
415
+ print(`${reply.path}
416
+ open it at https://ui.perfetto.dev`);
417
+ } else {
418
+ throw new UsageError("needs start or stop");
419
+ }
420
+ } finally {
421
+ connection.close();
422
+ }
423
+ return 0;
424
+ }
425
+ async function resizeCommand(args) {
426
+ const [cols, rows] = args.positional().map(Number);
427
+ if (!cols || !rows) throw new UsageError("needs <cols> <rows>");
428
+ await call(args, "resize", { cols, rows });
429
+ return 0;
430
+ }
431
+ async function signalCommand(args) {
432
+ const [signal] = args.positional();
433
+ if (!signal) throw new UsageError("needs a signal, like SIGINT or TERM");
434
+ await call(args, "signal", { signal });
435
+ return 0;
436
+ }
437
+ async function scrollCommand(args) {
438
+ const [lines] = args.positional();
439
+ await call(args, "scroll", { lines: Number(lines) });
440
+ return 0;
441
+ }
442
+ async function closeOne(record) {
443
+ try {
444
+ const connection = await connectSocket(record.socket);
445
+ const reply = await connection.request("close").catch(() => ({}));
446
+ connection.close();
447
+ return [reply.video, reply.profile].filter((v) => typeof v === "string");
448
+ } catch {
449
+ try {
450
+ process.kill(record.pid, "SIGTERM");
451
+ } catch {
452
+ }
453
+ return [];
454
+ } finally {
455
+ removeInstance(record.id);
456
+ }
457
+ }
458
+ async function closeCommand(args) {
459
+ const all = args.flag("--all");
460
+ const id = args.value("--id");
461
+ args.positional();
462
+ const targets = all ? listInstances() : [findInstance(id)];
463
+ for (const record of targets) {
464
+ const files = await closeOne(record);
465
+ print(`closed ${record.id}${files.length ? `
466
+ ${files.join("\n")}` : ""}`);
467
+ }
468
+ return 0;
469
+ }
470
+ async function reportCommand(args) {
471
+ const pass = args.value("--pass");
472
+ const failed = args.value("--fail");
473
+ args.positional();
474
+ if (pass === void 0 && failed === void 0) throw new UsageError("needs --pass <reason> or --fail <reason>");
475
+ await call(args, "report", { result: { pass: pass !== void 0, reason: pass ?? failed } });
476
+ print("reported");
477
+ return 0;
478
+ }
479
+ async function themeCommand(args) {
480
+ const base = args.value("--base");
481
+ const custom = Object.fromEntries(
482
+ [
483
+ ["background", args.value("--background")],
484
+ ["foreground", args.value("--foreground")],
485
+ ["cursor", args.value("--cursor")],
486
+ ["cursorText", args.value("--cursor-text")]
487
+ ].filter(([, v]) => v !== void 0)
488
+ );
489
+ const [name] = args.positional();
490
+ const theme = Object.keys(custom).length || base ? { base: base ?? name, ...custom } : name;
491
+ if (!theme) throw new UsageError("needs a theme name (testingterm themes lists them) or colors like --background #000000");
492
+ const reply = await call(args, "theme", { theme: syncTheme(theme)?.theme ?? theme });
493
+ print(`theme set (background ${reply.background}, foreground ${reply.foreground})`);
494
+ return 0;
495
+ }
496
+ async function themesCommand(args) {
497
+ const json = args.flag("--json");
498
+ const filter = args.positional().join(" ").toLowerCase();
499
+ const { GHOSTTY_THEMES, REX_THEMES } = await import("./themes.gen-E3CTYIQE.js");
500
+ const names = ["dark", "light", "ghostty", "rex", ...GHOSTTY_THEMES, ...REX_THEMES].filter((name) => name.toLowerCase().includes(filter));
501
+ if (json) print(names);
502
+ else print(names.length ? names.join("\n") : `no theme matches "${filter}"`);
503
+ return names.length ? 0 : 1;
504
+ }
505
+ async function infoCommand(args) {
506
+ args.positional();
507
+ const { id: _, ok: __, ...info } = await call(args, "info");
508
+ print(info);
509
+ return 0;
510
+ }
511
+ var COMMANDS = {
512
+ new: newCommand,
513
+ ls: lsCommand,
514
+ screen: screenCommand,
515
+ scrollback: scrollbackCommand,
516
+ find: findCommand,
517
+ type: typeCommand,
518
+ press: pressCommand,
519
+ paste: pasteCommand,
520
+ click: clickCommand,
521
+ move: moveCommand,
522
+ drag: dragCommand,
523
+ wheel: wheelCommand,
524
+ wait: waitCommand,
525
+ screenshot: screenshotCommand,
526
+ record: recordCommand,
527
+ profile: profileCommand,
528
+ resize: resizeCommand,
529
+ signal: signalCommand,
530
+ scroll: scrollCommand,
531
+ close: closeCommand,
532
+ report: reportCommand,
533
+ info: infoCommand,
534
+ theme: themeCommand,
535
+ themes: themesCommand
536
+ };
537
+ export {
538
+ COMMANDS,
539
+ capabilitiesFrom
540
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ currentScope,
3
+ rootScope,
4
+ safeName,
5
+ scopes,
6
+ settings
7
+ } from "./chunk-IJ5VA4HN.js";
8
+ export {
9
+ currentScope,
10
+ rootScope,
11
+ safeName,
12
+ scopes,
13
+ settings
14
+ };