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.
- package/AGENT-DOCS.md +77 -0
- package/LICENSE +21 -0
- package/dist/ai.d.ts +24 -0
- package/dist/attach.d.ts +6 -0
- package/dist/capabilities.d.ts +6 -0
- package/dist/chunks/ai-MISD5ZKB.js +260 -0
- package/dist/chunks/args-FJPX5SKE.js +8 -0
- package/dist/chunks/attach-STVPRW4U.js +30 -0
- package/dist/chunks/chunk-66N3P624.js +44 -0
- package/dist/chunks/chunk-IJ5VA4HN.js +41 -0
- package/dist/chunks/chunk-INTJPVJZ.js +191 -0
- package/dist/chunks/chunk-NM755IGG.js +658 -0
- package/dist/chunks/chunk-PA67Y4XN.js +65 -0
- package/dist/chunks/chunk-U52LFC23.js +68 -0
- package/dist/chunks/chunk-YFGNBX2I.js +229 -0
- package/dist/chunks/chunk-YHQYNBAN.js +801 -0
- package/dist/chunks/commands-IWTFRW33.js +540 -0
- package/dist/chunks/context-QML5TP36.js +14 -0
- package/dist/chunks/help-I5WIJHZM.js +359 -0
- package/dist/chunks/paths-X3C4P67K.js +18 -0
- package/dist/chunks/run-RNFQMMXD.js +95 -0
- package/dist/chunks/setup-WIZULKES.js +106 -0
- package/dist/chunks/themes.gen-E3CTYIQE.js +8 -0
- package/dist/chunks/upgrade-43JWCQ63.js +143 -0
- package/dist/chunks/verify-55DFXJOY.js +37 -0
- package/dist/cli/args.d.ts +13 -0
- package/dist/cli/commands.d.ts +5 -0
- package/dist/cli/help.d.ts +2 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +83 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/setup.d.ts +6 -0
- package/dist/cli/upgrade.d.ts +19 -0
- package/dist/cli/verify.d.ts +2 -0
- package/dist/context.d.ts +33 -0
- package/dist/engine.d.ts +56 -0
- package/dist/errors.d.ts +4 -0
- package/dist/expect.d.ts +62 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +205 -0
- package/dist/install.d.ts +13 -0
- package/dist/instances.d.ts +23 -0
- package/dist/locator.d.ts +49 -0
- package/dist/paths.d.ts +7 -0
- package/dist/runner.d.ts +56 -0
- package/dist/sync.d.ts +8 -0
- package/dist/terminal.d.ts +146 -0
- package/dist/themes.gen.d.ts +4 -0
- package/dist/types.d.ts +214 -0
- package/package.json +41 -4
- package/skill/testingterm/SKILL.md +138 -0
- package/README.md +0 -3
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHANNEL,
|
|
3
|
+
RELEASES_URL,
|
|
4
|
+
TARGET,
|
|
5
|
+
installPaths,
|
|
6
|
+
installed
|
|
7
|
+
} from "./chunk-66N3P624.js";
|
|
8
|
+
import {
|
|
9
|
+
STATE_DIR,
|
|
10
|
+
version
|
|
11
|
+
} from "./chunk-PA67Y4XN.js";
|
|
12
|
+
|
|
13
|
+
// src/cli/upgrade.ts
|
|
14
|
+
import { execFile } from "node:child_process";
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
16
|
+
import fs from "node:fs";
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
import { promisify } from "node:util";
|
|
19
|
+
var run = promisify(execFile);
|
|
20
|
+
function newer(a, b) {
|
|
21
|
+
const parse = (v) => v.split(/[.-]/).map((part) => /^\d+$/.test(part) ? Number(part) : part);
|
|
22
|
+
const [x, y] = [parse(a), parse(b)];
|
|
23
|
+
for (let i = 0; i < Math.max(x.length, y.length); i++) {
|
|
24
|
+
const [p, q] = [x[i] ?? 0, y[i] ?? 0];
|
|
25
|
+
if (p === q) continue;
|
|
26
|
+
if (typeof p === "number" && typeof q === "number") return p > q;
|
|
27
|
+
return String(p) > String(q);
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
async function get(url) {
|
|
32
|
+
try {
|
|
33
|
+
return await fetch(url);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new Error(`could not reach ${url}: ${error.cause instanceof Error ? error.cause.message : error.message}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function latest() {
|
|
39
|
+
const response = await get(`${RELEASES_URL}/v1/${CHANNEL}/latest.json`);
|
|
40
|
+
if (response.status === 404) return null;
|
|
41
|
+
if (!response.ok) throw new Error(`could not check for updates: ${response.status} ${response.statusText}`);
|
|
42
|
+
return await response.json();
|
|
43
|
+
}
|
|
44
|
+
async function download(bundle, name) {
|
|
45
|
+
const response = await get(`${RELEASES_URL}/${bundle.file}`);
|
|
46
|
+
if (!response.ok || !response.body) throw new Error(`download failed: ${response.status} ${response.statusText}`);
|
|
47
|
+
fs.mkdirSync(installPaths.downloads, { recursive: true });
|
|
48
|
+
const file = path.join(installPaths.downloads, name);
|
|
49
|
+
const hash = createHash("sha256");
|
|
50
|
+
const out = fs.createWriteStream(`${file}.part`);
|
|
51
|
+
let received = 0;
|
|
52
|
+
const tty = process.stderr.isTTY;
|
|
53
|
+
for await (const chunk of response.body) {
|
|
54
|
+
hash.update(chunk);
|
|
55
|
+
received += chunk.length;
|
|
56
|
+
if (!out.write(chunk)) await new Promise((resolve) => out.once("drain", () => resolve()));
|
|
57
|
+
if (tty) process.stderr.write(`\r${name}: ${Math.round(received / bundle.size * 100)}%`);
|
|
58
|
+
}
|
|
59
|
+
await new Promise((resolve, reject) => out.end((error) => error ? reject(error) : resolve()));
|
|
60
|
+
if (tty) process.stderr.write("\n");
|
|
61
|
+
if (hash.digest("hex") !== bundle.sha256) {
|
|
62
|
+
fs.rmSync(`${file}.part`, { force: true });
|
|
63
|
+
throw new Error("the download was corrupted (checksum mismatch); try again");
|
|
64
|
+
}
|
|
65
|
+
fs.renameSync(`${file}.part`, file);
|
|
66
|
+
return file;
|
|
67
|
+
}
|
|
68
|
+
async function unpack(tarball, into) {
|
|
69
|
+
const staging = `${into}.staging-${process.pid}`;
|
|
70
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
71
|
+
fs.mkdirSync(staging, { recursive: true });
|
|
72
|
+
await run("tar", ["-xzf", tarball, "-C", staging, "--strip-components", "1"]);
|
|
73
|
+
fs.rmSync(into, { recursive: true, force: true });
|
|
74
|
+
fs.renameSync(staging, into);
|
|
75
|
+
fs.rmSync(tarball, { force: true });
|
|
76
|
+
}
|
|
77
|
+
function writeAtomic(file, text) {
|
|
78
|
+
fs.writeFileSync(`${file}.${process.pid}.tmp`, text);
|
|
79
|
+
fs.renameSync(`${file}.${process.pid}.tmp`, file);
|
|
80
|
+
}
|
|
81
|
+
function prune(keep) {
|
|
82
|
+
for (const name of fs.readdirSync(installPaths.builds)) {
|
|
83
|
+
if (!keep.includes(name) && !name.includes(".staging-")) fs.rmSync(path.join(installPaths.builds, name), { recursive: true, force: true });
|
|
84
|
+
}
|
|
85
|
+
const used = new Set(keep.map((v) => fs.readlinkSync(path.join(installPaths.builds, v, "runtime"), { encoding: "utf8" }).split("/").at(-1)));
|
|
86
|
+
for (const name of fs.readdirSync(installPaths.runtimes)) {
|
|
87
|
+
if (!used.has(name)) fs.rmSync(path.join(installPaths.runtimes, name), { recursive: true, force: true });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function upgradeCommand(args) {
|
|
91
|
+
const check = args.flag("--check");
|
|
92
|
+
args.positional();
|
|
93
|
+
const current = version();
|
|
94
|
+
const release = await latest();
|
|
95
|
+
if (!release) {
|
|
96
|
+
process.stdout.write(`no ${CHANNEL} release is published yet
|
|
97
|
+
`);
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
if (!newer(release.version, current)) {
|
|
101
|
+
process.stdout.write(`testingterm ${current} is up to date
|
|
102
|
+
`);
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
if (check) {
|
|
106
|
+
process.stdout.write(`testingterm ${release.version} is available (you have ${current}); run testingterm upgrade
|
|
107
|
+
`);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
if (!installed()) {
|
|
111
|
+
process.stdout.write(`testingterm ${release.version} is available. This copy came from npm, so upgrade it with:
|
|
112
|
+
npm install -g testingterm@latest
|
|
113
|
+
`);
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
const target = release.targets[TARGET];
|
|
117
|
+
if (!target) throw new Error(`${release.version} has no build for ${TARGET}`);
|
|
118
|
+
const runtimeDir = path.join(installPaths.runtimes, release.node);
|
|
119
|
+
if (!fs.existsSync(path.join(runtimeDir, "bin", "node"))) {
|
|
120
|
+
process.stdout.write(`downloading node ${release.node}
|
|
121
|
+
`);
|
|
122
|
+
await unpack(await download(target.runtime, `node-${release.node}-${TARGET}.tar.gz`), runtimeDir);
|
|
123
|
+
}
|
|
124
|
+
const buildDir = path.join(installPaths.builds, release.version);
|
|
125
|
+
await unpack(await download(target.app, `testingterm-${release.version}-${TARGET}.tar.gz`), buildDir);
|
|
126
|
+
fs.symlinkSync(path.join("..", "..", "runtimes", release.node), path.join(buildDir, "runtime"));
|
|
127
|
+
await run(path.join(buildDir, "runtime", "bin", "node"), [path.join(buildDir, "dist", "cli", "main.js"), "version"]);
|
|
128
|
+
const previous = fs.existsSync(installPaths.current) ? fs.readFileSync(installPaths.current, "utf8").trim() : null;
|
|
129
|
+
if (previous && previous !== release.version) writeAtomic(installPaths.previous, previous);
|
|
130
|
+
writeAtomic(installPaths.current, release.version);
|
|
131
|
+
prune([release.version, ...previous ? [previous] : []].filter((v) => fs.existsSync(path.join(installPaths.builds, v))));
|
|
132
|
+
if (fs.existsSync(path.join(STATE_DIR, "skill-choice")) && fs.readFileSync(path.join(STATE_DIR, "skill-choice"), "utf8").trim() === "yes") {
|
|
133
|
+
await run(path.join(buildDir, "runtime", "bin", "node"), [path.join(buildDir, "dist", "cli", "main.js"), "setup", "--yes"]).catch(() => {
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
process.stdout.write(`upgraded testingterm ${current} \u2192 ${release.version}
|
|
137
|
+
`);
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
latest,
|
|
142
|
+
upgradeCommand
|
|
143
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connectSocket,
|
|
3
|
+
findInstance
|
|
4
|
+
} from "./chunk-YFGNBX2I.js";
|
|
5
|
+
import "./chunk-PA67Y4XN.js";
|
|
6
|
+
import {
|
|
7
|
+
UsageError
|
|
8
|
+
} from "./chunk-U52LFC23.js";
|
|
9
|
+
|
|
10
|
+
// src/cli/verify.ts
|
|
11
|
+
async function verifyCommand(args) {
|
|
12
|
+
const agent = args.value("--agent");
|
|
13
|
+
const model = args.value("--model");
|
|
14
|
+
const effort = args.value("--effort");
|
|
15
|
+
const interact = args.flag("--interact");
|
|
16
|
+
const timeout = args.number("--timeout");
|
|
17
|
+
const json = args.flag("--json");
|
|
18
|
+
const expectation = args.positional().join(" ");
|
|
19
|
+
if (!expectation) throw new UsageError('needs what should be true, like "the menu lists three items"');
|
|
20
|
+
if (agent && agent !== "claude" && agent !== "codex") throw new UsageError("--agent must be claude or codex");
|
|
21
|
+
const record = findInstance(void 0);
|
|
22
|
+
const { attach } = await import("./attach-STVPRW4U.js");
|
|
23
|
+
const terminal = await attach(record, connectSocket);
|
|
24
|
+
const { verify } = await import("./ai-MISD5ZKB.js");
|
|
25
|
+
const { rootScope } = await import("./context-QML5TP36.js");
|
|
26
|
+
const result = await verify(terminal, expectation, { agent, model, effort, interact, timeout }, rootScope, "");
|
|
27
|
+
terminal.detach();
|
|
28
|
+
if (json) process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
29
|
+
`);
|
|
30
|
+
else process.stdout.write(`${result.error ? "error" : result.pass ? "pass" : "fail"} (${result.agent}, ${Math.round(result.durationMs / 1e3)}s): ${result.reason}${result.artifacts.length ? `
|
|
31
|
+
${result.artifacts.join("\n")}` : ""}
|
|
32
|
+
`);
|
|
33
|
+
return result.error ? 2 : result.pass ? 0 : 1;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
verifyCommand
|
|
37
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class Args {
|
|
2
|
+
readonly rest: string[];
|
|
3
|
+
readonly passthrough: string[];
|
|
4
|
+
constructor(argv: string[]);
|
|
5
|
+
flag(...names: string[]): boolean;
|
|
6
|
+
value(...names: string[]): string | undefined;
|
|
7
|
+
optional(name: string): string | true | undefined;
|
|
8
|
+
values(name: string): string[];
|
|
9
|
+
number(...names: string[]): number | undefined;
|
|
10
|
+
positional(): string[];
|
|
11
|
+
}
|
|
12
|
+
export declare class UsageError extends Error {
|
|
13
|
+
}
|
package/dist/cli/main.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/main.ts
|
|
4
|
+
import module from "node:module";
|
|
5
|
+
module.enableCompileCache?.();
|
|
6
|
+
var argv = process.argv.slice(2);
|
|
7
|
+
var command = argv[0];
|
|
8
|
+
async function main() {
|
|
9
|
+
const { commandHelp, rootHelp } = await import("../chunks/help-I5WIJHZM.js");
|
|
10
|
+
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
11
|
+
const topic = command === "help" ? argv[1] : void 0;
|
|
12
|
+
process.stdout.write(topic && commandHelp(topic) || rootHelp());
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
if (command === "--version" || command === "-v" || command === "version") {
|
|
16
|
+
const { version } = await import("../chunks/paths-X3C4P67K.js");
|
|
17
|
+
process.stdout.write(`${version()}
|
|
18
|
+
`);
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
const rest = argv.slice(1);
|
|
22
|
+
const idAt = rest.indexOf("--id");
|
|
23
|
+
if (idAt !== -1 && rest[idAt + 1] !== void 0 && command !== "run") {
|
|
24
|
+
process.env.TESTINGTERM_ID = rest[idAt + 1];
|
|
25
|
+
rest.splice(idAt, 2);
|
|
26
|
+
}
|
|
27
|
+
if (rest.includes("--help") || rest.includes("-h")) {
|
|
28
|
+
const help = commandHelp(command);
|
|
29
|
+
if (help) {
|
|
30
|
+
process.stdout.write(help);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const { Args, UsageError } = await import("../chunks/args-FJPX5SKE.js");
|
|
35
|
+
try {
|
|
36
|
+
const args = new Args(rest);
|
|
37
|
+
switch (command) {
|
|
38
|
+
case "run":
|
|
39
|
+
return await (await import("../chunks/run-RNFQMMXD.js")).runCommand(args);
|
|
40
|
+
case "setup":
|
|
41
|
+
return await (await import("../chunks/setup-WIZULKES.js")).setupCommand(args);
|
|
42
|
+
case "upgrade":
|
|
43
|
+
return await (await import("../chunks/upgrade-43JWCQ63.js")).upgradeCommand(args);
|
|
44
|
+
case "verify":
|
|
45
|
+
return await (await import("../chunks/verify-55DFXJOY.js")).verifyCommand(args);
|
|
46
|
+
default: {
|
|
47
|
+
const commands = await import("../chunks/commands-IWTFRW33.js");
|
|
48
|
+
const handler = commands.COMMANDS[command];
|
|
49
|
+
if (!handler) {
|
|
50
|
+
process.stderr.write(`testingterm: unknown command ${command}
|
|
51
|
+
|
|
52
|
+
${rootHelp()}`);
|
|
53
|
+
return 2;
|
|
54
|
+
}
|
|
55
|
+
return await handler(args);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (error instanceof UsageError) {
|
|
60
|
+
process.stderr.write(`testingterm ${command}: ${error.message}
|
|
61
|
+
|
|
62
|
+
${commandHelp(command) ?? ""}`);
|
|
63
|
+
return 2;
|
|
64
|
+
}
|
|
65
|
+
const screen = error.screen;
|
|
66
|
+
process.stderr.write(`testingterm ${command}: ${error.message}
|
|
67
|
+
${screen ? `
|
|
68
|
+
screen:
|
|
69
|
+
${screen}
|
|
70
|
+
` : ""}`);
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
main().then(
|
|
75
|
+
(code) => {
|
|
76
|
+
process.exitCode = code;
|
|
77
|
+
},
|
|
78
|
+
(error) => {
|
|
79
|
+
process.stderr.write(`testingterm: ${error.stack ?? error}
|
|
80
|
+
`);
|
|
81
|
+
process.exitCode = 1;
|
|
82
|
+
}
|
|
83
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Args } from "./args.ts";
|
|
2
|
+
interface Bundle {
|
|
3
|
+
file: string;
|
|
4
|
+
sha256: string;
|
|
5
|
+
size: number;
|
|
6
|
+
}
|
|
7
|
+
interface Release {
|
|
8
|
+
version: string;
|
|
9
|
+
channel: string;
|
|
10
|
+
node: string;
|
|
11
|
+
publishedAt: string;
|
|
12
|
+
targets: Record<string, {
|
|
13
|
+
app: Bundle;
|
|
14
|
+
runtime: Bundle;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export declare function latest(): Promise<Release | null>;
|
|
18
|
+
export declare function upgradeCommand(args: Args): Promise<number>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import type { VideoMode } from "./types.ts";
|
|
3
|
+
export interface Step {
|
|
4
|
+
at: number;
|
|
5
|
+
action: string;
|
|
6
|
+
terminal: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Scope {
|
|
9
|
+
name: string;
|
|
10
|
+
file: string | null;
|
|
11
|
+
artifacts: string;
|
|
12
|
+
terminals: Set<{
|
|
13
|
+
close(): Promise<unknown>;
|
|
14
|
+
failureArtifacts(): Promise<string[]>;
|
|
15
|
+
}>;
|
|
16
|
+
produced: string[];
|
|
17
|
+
steps: Step[];
|
|
18
|
+
started: number;
|
|
19
|
+
}
|
|
20
|
+
export declare const settings: {
|
|
21
|
+
artifacts: string;
|
|
22
|
+
headed: boolean;
|
|
23
|
+
slowMo: number;
|
|
24
|
+
video: VideoMode;
|
|
25
|
+
profile: boolean;
|
|
26
|
+
timeout: number;
|
|
27
|
+
theme: string | undefined;
|
|
28
|
+
capabilities: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
export declare const rootScope: Scope;
|
|
31
|
+
export declare const scopes: AsyncLocalStorage<Scope>;
|
|
32
|
+
export declare function currentScope(): Scope;
|
|
33
|
+
export declare function safeName(name: string): string;
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import { EngineError } from "./errors.ts";
|
|
3
|
+
export { EngineError };
|
|
4
|
+
export interface EngineConfig {
|
|
5
|
+
command: string[];
|
|
6
|
+
cwd?: string;
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
cols: number;
|
|
9
|
+
rows: number;
|
|
10
|
+
fontSize: number;
|
|
11
|
+
scale: number;
|
|
12
|
+
padding: number;
|
|
13
|
+
theme: unknown;
|
|
14
|
+
headed: boolean;
|
|
15
|
+
stdio: boolean;
|
|
16
|
+
listen?: string;
|
|
17
|
+
record?: string;
|
|
18
|
+
fps: number;
|
|
19
|
+
overlay: boolean;
|
|
20
|
+
profile?: string;
|
|
21
|
+
keepAlive: boolean;
|
|
22
|
+
cursor: boolean;
|
|
23
|
+
title?: string;
|
|
24
|
+
capabilities?: unknown;
|
|
25
|
+
}
|
|
26
|
+
export type Reply = Record<string, unknown> & {
|
|
27
|
+
ok?: boolean;
|
|
28
|
+
error?: string;
|
|
29
|
+
screen?: string;
|
|
30
|
+
};
|
|
31
|
+
export interface ExitEvent {
|
|
32
|
+
exitCode: number | null;
|
|
33
|
+
signal: string | null;
|
|
34
|
+
}
|
|
35
|
+
export declare class Connection {
|
|
36
|
+
private next;
|
|
37
|
+
private readonly pending;
|
|
38
|
+
private buffer;
|
|
39
|
+
private closed;
|
|
40
|
+
exit: ExitEvent | null;
|
|
41
|
+
onExit: ((event: ExitEvent) => void) | null;
|
|
42
|
+
onBusy: ((busy: boolean) => void) | null;
|
|
43
|
+
private readonly write;
|
|
44
|
+
private readonly end;
|
|
45
|
+
constructor(write: (line: string) => void, end: () => void);
|
|
46
|
+
data(chunk: string): void;
|
|
47
|
+
fail(error: Error): void;
|
|
48
|
+
request<T extends Reply = Reply>(op: string, params?: Record<string, unknown>): Promise<T>;
|
|
49
|
+
close(): void;
|
|
50
|
+
}
|
|
51
|
+
export interface Engine {
|
|
52
|
+
connection: Connection;
|
|
53
|
+
process: ChildProcess;
|
|
54
|
+
}
|
|
55
|
+
export declare function startEngine(config: EngineConfig): Engine;
|
|
56
|
+
export declare function connectSocket(socketPath: string): Promise<Connection>;
|
package/dist/errors.d.ts
ADDED
package/dist/expect.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Locator, type TextQuery } from "./locator.ts";
|
|
2
|
+
import { Terminal } from "./terminal.ts";
|
|
3
|
+
export declare class AssertionError extends Error {
|
|
4
|
+
readonly screen: string | undefined;
|
|
5
|
+
constructor(message: string, screen?: string);
|
|
6
|
+
}
|
|
7
|
+
export interface TerminalAssertions {
|
|
8
|
+
readonly not: TerminalAssertions;
|
|
9
|
+
/** Waits until the screen contains the text (or matches the regex). */
|
|
10
|
+
toHaveText(text: TextQuery, options?: {
|
|
11
|
+
timeout?: number;
|
|
12
|
+
scrollback?: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
/** Waits until the whole visible screen equals `text`, ignoring trailing whitespace. */
|
|
15
|
+
toHaveScreen(text: string, options?: {
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
/** Waits until the title contains `title`. */
|
|
19
|
+
toHaveTitle(title: TextQuery, options?: {
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
/** Waits until the cursor is at the cell. */
|
|
23
|
+
toHaveCursorAt(cell: {
|
|
24
|
+
col: number;
|
|
25
|
+
row: number;
|
|
26
|
+
}, options?: {
|
|
27
|
+
timeout?: number;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
/** Waits for the program to exit, with `code` if given. */
|
|
30
|
+
toHaveExited(options?: {
|
|
31
|
+
code?: number;
|
|
32
|
+
timeout?: number;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export interface LocatorAssertions {
|
|
36
|
+
readonly not: LocatorAssertions;
|
|
37
|
+
/** Waits until the locator matches somewhere on screen. */
|
|
38
|
+
toBeVisible(options?: {
|
|
39
|
+
timeout?: number;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
/** Waits until the locator matches exactly `count` places. */
|
|
42
|
+
toHaveCount(count: number, options?: {
|
|
43
|
+
timeout?: number;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export interface ValueAssertions<T> {
|
|
47
|
+
readonly not: ValueAssertions<T>;
|
|
48
|
+
toBe(expected: T): void;
|
|
49
|
+
toEqual(expected: unknown): void;
|
|
50
|
+
toBeTruthy(): void;
|
|
51
|
+
toContain(expected: unknown): void;
|
|
52
|
+
toMatch(pattern: RegExp | string): void;
|
|
53
|
+
toBeGreaterThan(value: number): void;
|
|
54
|
+
toBeLessThan(value: number): void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Assertions that retry until they pass or time out, so tests don't need sleeps.
|
|
58
|
+
* `expect(terminal)` and `expect(locator)` wait; `expect(value)` checks once.
|
|
59
|
+
*/
|
|
60
|
+
export declare function expect(target: Terminal): TerminalAssertions;
|
|
61
|
+
export declare function expect(target: Locator): LocatorAssertions;
|
|
62
|
+
export declare function expect<T>(target: T): ValueAssertions<T>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Terminal } from "./terminal.ts";
|
|
2
|
+
import type { LaunchOptions } from "./types.ts";
|
|
3
|
+
export { Terminal } from "./terminal.ts";
|
|
4
|
+
export { Locator, LocatorError } from "./locator.ts";
|
|
5
|
+
export type { TextQuery } from "./locator.ts";
|
|
6
|
+
export { expect, AssertionError } from "./expect.ts";
|
|
7
|
+
export type { TerminalAssertions, LocatorAssertions, ValueAssertions } from "./expect.ts";
|
|
8
|
+
export { test } from "./runner.ts";
|
|
9
|
+
export type { TestContext, TestOptions, TestFunction, TestResult, RunResult } from "./runner.ts";
|
|
10
|
+
export { EngineError } from "./errors.ts";
|
|
11
|
+
export type * from "./types.ts";
|
|
12
|
+
/** Every Ghostty theme name you can pass as `theme`, besides "dark" and "light". */
|
|
13
|
+
export { CAPABILITY_PRESETS as capabilityPresets } from "./capabilities.ts";
|
|
14
|
+
export { GHOSTTY_THEMES as ghosttyThemes, REX_THEMES as rexThemes } from "./themes.gen.ts";
|
|
15
|
+
/**
|
|
16
|
+
* Start a program in a new terminal.
|
|
17
|
+
*
|
|
18
|
+
* ```js
|
|
19
|
+
* const term = launch("htop");
|
|
20
|
+
* await term.waitForText("Load average");
|
|
21
|
+
* await term.screenshot();
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* A string runs through `sh -c`; an array runs the program directly. The terminal closes
|
|
25
|
+
* on its own when the script or test ends, or call `close()`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function launch(command?: string | string[] | LaunchOptions, options?: LaunchOptions): Terminal;
|