ptywright 0.1.1 → 0.2.0
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/README.md +287 -1
- package/dist/agent.mjs +2 -0
- package/dist/bin/ptywright.mjs +6 -0
- package/dist/cli-DIUx2w6X.mjs +3587 -0
- package/dist/cli.mjs +2 -0
- package/{src/index.ts → dist/index.mjs} +7 -9
- package/dist/mcp.mjs +2 -0
- package/dist/pty-cassette.mjs +24 -0
- package/dist/pty_like-Cpkh_O9B.mjs +404 -0
- package/dist/runner-DzZlFrt1.mjs +1897 -0
- package/dist/runner-zApMYWZx.mjs +3257 -0
- package/dist/script.mjs +2 -0
- package/dist/server-VHuEWWj_.mjs +3068 -0
- package/dist/session.mjs +2 -0
- package/dist/terminal_session-DopC7Xg6.mjs +893 -0
- package/package.json +28 -21
- package/schemas/ptywright-agent-cassette.schema.json +57 -0
- package/schemas/ptywright-agent-check.schema.json +122 -0
- package/schemas/ptywright-agent-manifest.schema.json +107 -0
- package/schemas/ptywright-agent-promote.schema.json +146 -0
- package/schemas/ptywright-agent-replay-summary.schema.json +140 -0
- package/schemas/ptywright-agent-run.schema.json +126 -0
- package/schemas/ptywright-agent.schema.json +182 -0
- package/schemas/ptywright-pty-cassette.schema.json +86 -0
- package/schemas/ptywright-script-manifest.schema.json +75 -0
- package/schemas/ptywright-script-run-summary.schema.json +114 -0
- package/schemas/ptywright-script.schema.json +55 -3
- package/bin/ptywright +0 -4
- package/src/cli.ts +0 -414
- package/src/generator/doc_parser.ts +0 -341
- package/src/generator/generate.ts +0 -161
- package/src/generator/index.ts +0 -10
- package/src/generator/script_generator.ts +0 -209
- package/src/generator/step_extractor.ts +0 -397
- package/src/mcp/http_server.ts +0 -174
- package/src/mcp/script_recording.ts +0 -238
- package/src/mcp/server.ts +0 -1348
- package/src/pty/bun_pty_adapter.ts +0 -34
- package/src/pty/bun_terminal_adapter.ts +0 -149
- package/src/pty/pty_adapter.ts +0 -31
- package/src/script/dsl.ts +0 -188
- package/src/script/module.ts +0 -43
- package/src/script/path.ts +0 -151
- package/src/script/run.ts +0 -108
- package/src/script/run_all.ts +0 -229
- package/src/script/runner.ts +0 -983
- package/src/script/schema.ts +0 -237
- package/src/script/steps/assert_snapshot_equals.ts +0 -21
- package/src/script/steps/index.ts +0 -2
- package/src/script/suite_report.ts +0 -626
- package/src/session/session_manager.ts +0 -145
- package/src/session/terminal_session.ts +0 -473
- package/src/terminal/ansi.ts +0 -142
- package/src/terminal/keys.ts +0 -180
- package/src/terminal/mask.ts +0 -70
- package/src/terminal/mouse.ts +0 -75
- package/src/terminal/snapshot.ts +0 -196
- package/src/terminal/style.ts +0 -121
- package/src/terminal/view.ts +0 -49
- package/src/trace/asciicast.ts +0 -20
- package/src/trace/asciinema_player_assets.ts +0 -44
- package/src/trace/cast_to_txt.ts +0 -116
- package/src/trace/recorder.ts +0 -110
- package/src/trace/report.ts +0 -2092
- package/src/types.ts +0 -86
- package/src/util/hash.ts +0 -8
- package/src/util/sleep.ts +0 -5
package/src/script/schema.ts
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export const textMaskRuleSchema = z.object({
|
|
4
|
-
regex: z.string().min(1),
|
|
5
|
-
flags: z.string().optional(),
|
|
6
|
-
replacement: z.string().optional(),
|
|
7
|
-
preserveLength: z.boolean().optional(),
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export const launchConfigSchema = z.object({
|
|
11
|
-
command: z.string().min(1),
|
|
12
|
-
args: z.array(z.string()).optional(),
|
|
13
|
-
cwd: z.string().optional(),
|
|
14
|
-
env: z.record(z.string()).optional(),
|
|
15
|
-
cols: z.number().int().positive().optional(),
|
|
16
|
-
rows: z.number().int().positive().optional(),
|
|
17
|
-
name: z.string().optional(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export const scriptTraceSchema = z.object({
|
|
21
|
-
saveCast: z.boolean().optional(),
|
|
22
|
-
saveReport: z.boolean().optional(),
|
|
23
|
-
castPath: z.string().optional(),
|
|
24
|
-
reportPath: z.string().optional(),
|
|
25
|
-
reportScope: z.enum(["visible", "buffer"]).optional(),
|
|
26
|
-
reportMaxFrames: z.number().int().positive().optional(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const sendTextStepSchema = z.object({
|
|
30
|
-
type: z.literal("sendText"),
|
|
31
|
-
text: z.string(),
|
|
32
|
-
enter: z.boolean().optional(),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const pressKeyStepSchema = z.object({
|
|
36
|
-
type: z.literal("pressKey"),
|
|
37
|
-
key: z.string().min(1),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const sendMouseStepSchema = z.object({
|
|
41
|
-
type: z.literal("sendMouse"),
|
|
42
|
-
action: z.enum(["down", "up", "move", "click", "scroll_up", "scroll_down"]),
|
|
43
|
-
x: z.number().int(),
|
|
44
|
-
y: z.number().int(),
|
|
45
|
-
button: z.enum(["left", "middle", "right"]).optional(),
|
|
46
|
-
shift: z.boolean().optional(),
|
|
47
|
-
alt: z.boolean().optional(),
|
|
48
|
-
ctrl: z.boolean().optional(),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const resizeStepSchema = z.object({
|
|
52
|
-
type: z.literal("resize"),
|
|
53
|
-
cols: z.number().int().positive(),
|
|
54
|
-
rows: z.number().int().positive(),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const markStepSchema = z.object({
|
|
58
|
-
type: z.literal("mark"),
|
|
59
|
-
label: z.string().optional(),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const sleepStepSchema = z.object({
|
|
63
|
-
type: z.literal("sleep"),
|
|
64
|
-
ms: z.number().int().nonnegative(),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const waitForTextStepSchema = z
|
|
68
|
-
.object({
|
|
69
|
-
type: z.literal("waitForText"),
|
|
70
|
-
scope: z.enum(["visible", "buffer"]).optional(),
|
|
71
|
-
text: z.string().optional(),
|
|
72
|
-
regex: z.string().optional(),
|
|
73
|
-
timeoutMs: z.number().int().positive().optional(),
|
|
74
|
-
intervalMs: z.number().int().positive().optional(),
|
|
75
|
-
})
|
|
76
|
-
.superRefine((value, ctx) => {
|
|
77
|
-
if (!value.text && !value.regex) {
|
|
78
|
-
ctx.addIssue({
|
|
79
|
-
code: z.ZodIssueCode.custom,
|
|
80
|
-
message: "waitForText requires text or regex",
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const waitForStableScreenStepSchema = z.object({
|
|
86
|
-
type: z.literal("waitForStableScreen"),
|
|
87
|
-
timeoutMs: z.number().int().positive().optional(),
|
|
88
|
-
quietMs: z.number().int().positive().optional(),
|
|
89
|
-
intervalMs: z.number().int().positive().optional(),
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const waitForExitStepSchema = z.object({
|
|
93
|
-
type: z.literal("waitForExit"),
|
|
94
|
-
timeoutMs: z.number().int().positive().optional(),
|
|
95
|
-
intervalMs: z.number().int().positive().optional(),
|
|
96
|
-
exitCode: z.number().int().optional(),
|
|
97
|
-
signal: z.union([z.number().int(), z.string()]).optional(),
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
const expectMetaStepSchema = z
|
|
101
|
-
.object({
|
|
102
|
-
type: z.literal("expectMeta"),
|
|
103
|
-
bufferType: z.enum(["normal", "alternate"]).optional(),
|
|
104
|
-
cols: z.number().int().positive().optional(),
|
|
105
|
-
rows: z.number().int().positive().optional(),
|
|
106
|
-
cursor: z
|
|
107
|
-
.object({
|
|
108
|
-
x: z.number().int().positive(),
|
|
109
|
-
y: z.number().int().positive(),
|
|
110
|
-
})
|
|
111
|
-
.optional(),
|
|
112
|
-
})
|
|
113
|
-
.superRefine((value, ctx) => {
|
|
114
|
-
if (
|
|
115
|
-
value.bufferType === undefined &&
|
|
116
|
-
value.cols === undefined &&
|
|
117
|
-
value.rows === undefined &&
|
|
118
|
-
value.cursor === undefined
|
|
119
|
-
) {
|
|
120
|
-
ctx.addIssue({
|
|
121
|
-
code: z.ZodIssueCode.custom,
|
|
122
|
-
message: "expectMeta requires at least one assertion (bufferType/cols/rows/cursor)",
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
const snapshotStepSchema = z
|
|
128
|
-
.object({
|
|
129
|
-
type: z.literal("snapshot"),
|
|
130
|
-
kind: z.enum(["text", "view", "ansi", "view_ansi", "grid"]),
|
|
131
|
-
scope: z.enum(["visible", "buffer"]).optional(),
|
|
132
|
-
trimRight: z.boolean().optional(),
|
|
133
|
-
trimBottom: z.boolean().optional(),
|
|
134
|
-
maxLines: z.number().int().positive().optional(),
|
|
135
|
-
tailLines: z.number().int().positive().optional(),
|
|
136
|
-
lineNumbers: z.boolean().optional(),
|
|
137
|
-
includeStyles: z.boolean().optional(),
|
|
138
|
-
mask: z.array(textMaskRuleSchema).optional(),
|
|
139
|
-
saveAs: z.string().optional(),
|
|
140
|
-
saveTo: z.string().optional(),
|
|
141
|
-
})
|
|
142
|
-
.superRefine((value, ctx) => {
|
|
143
|
-
if (value.maxLines !== undefined && value.tailLines !== undefined) {
|
|
144
|
-
ctx.addIssue({
|
|
145
|
-
code: z.ZodIssueCode.custom,
|
|
146
|
-
message: "snapshot: maxLines and tailLines are mutually exclusive",
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const expectStepSchema = z
|
|
152
|
-
.object({
|
|
153
|
-
type: z.literal("expect"),
|
|
154
|
-
from: z.string().optional(),
|
|
155
|
-
equals: z.string().optional(),
|
|
156
|
-
contains: z.array(z.string()).optional(),
|
|
157
|
-
notContains: z.array(z.string()).optional(),
|
|
158
|
-
regex: z.string().optional(),
|
|
159
|
-
})
|
|
160
|
-
.superRefine((value, ctx) => {
|
|
161
|
-
if (
|
|
162
|
-
value.equals === undefined &&
|
|
163
|
-
!value.contains?.length &&
|
|
164
|
-
!value.notContains?.length &&
|
|
165
|
-
!value.regex
|
|
166
|
-
) {
|
|
167
|
-
ctx.addIssue({
|
|
168
|
-
code: z.ZodIssueCode.custom,
|
|
169
|
-
message: "expect requires at least one matcher (equals/contains/notContains/regex)",
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
const expectGoldenStepSchema = z.object({
|
|
175
|
-
type: z.literal("expectGolden"),
|
|
176
|
-
from: z.string().optional(),
|
|
177
|
-
path: z.string().min(1),
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const customStepSchema = z.object({
|
|
181
|
-
type: z.literal("custom"),
|
|
182
|
-
name: z.string().min(1),
|
|
183
|
-
payload: z.unknown().optional(),
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
const assertStepSchema = z
|
|
187
|
-
.object({
|
|
188
|
-
type: z.literal("assert"),
|
|
189
|
-
scope: z.enum(["visible", "buffer"]).optional(),
|
|
190
|
-
text: z.string().optional(),
|
|
191
|
-
regex: z.string().optional(),
|
|
192
|
-
description: z.string().optional(),
|
|
193
|
-
})
|
|
194
|
-
.superRefine((value, ctx) => {
|
|
195
|
-
if (!value.text && !value.regex) {
|
|
196
|
-
ctx.addIssue({
|
|
197
|
-
code: z.ZodIssueCode.custom,
|
|
198
|
-
message: "assert requires text or regex",
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
const assertSemanticStepSchema = z.object({
|
|
204
|
-
type: z.literal("assertSemantic"),
|
|
205
|
-
prompt: z.string().min(1),
|
|
206
|
-
description: z.string().optional(),
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
export const scriptStepSchema = z.union([
|
|
210
|
-
sendTextStepSchema,
|
|
211
|
-
pressKeyStepSchema,
|
|
212
|
-
sendMouseStepSchema,
|
|
213
|
-
resizeStepSchema,
|
|
214
|
-
markStepSchema,
|
|
215
|
-
sleepStepSchema,
|
|
216
|
-
waitForTextStepSchema,
|
|
217
|
-
waitForStableScreenStepSchema,
|
|
218
|
-
waitForExitStepSchema,
|
|
219
|
-
expectMetaStepSchema,
|
|
220
|
-
snapshotStepSchema,
|
|
221
|
-
expectStepSchema,
|
|
222
|
-
expectGoldenStepSchema,
|
|
223
|
-
customStepSchema,
|
|
224
|
-
assertStepSchema,
|
|
225
|
-
assertSemanticStepSchema,
|
|
226
|
-
]);
|
|
227
|
-
|
|
228
|
-
export const scriptSchema = z.object({
|
|
229
|
-
name: z.string().optional(),
|
|
230
|
-
artifactsDir: z.string().optional(),
|
|
231
|
-
launch: launchConfigSchema,
|
|
232
|
-
trace: scriptTraceSchema.optional(),
|
|
233
|
-
steps: z.array(scriptStepSchema).min(1),
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
export type Script = z.infer<typeof scriptSchema>;
|
|
237
|
-
export type ScriptStep = z.infer<typeof scriptStepSchema>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { CustomStepHandler } from "../runner";
|
|
2
|
-
|
|
3
|
-
export type AssertSnapshotEqualsPayload = {
|
|
4
|
-
expected: string;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export function createAssertSnapshotEqualsStep(
|
|
8
|
-
from: string,
|
|
9
|
-
): CustomStepHandler<AssertSnapshotEqualsPayload> {
|
|
10
|
-
return (ctx, step) => {
|
|
11
|
-
const expected = step.payload?.expected;
|
|
12
|
-
if (typeof expected !== "string") {
|
|
13
|
-
throw new Error("assertSnapshotEquals: missing payload.expected");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const record = ctx.getSnapshot(from);
|
|
17
|
-
if (record.text.trimEnd() !== expected) {
|
|
18
|
-
throw new Error("assertSnapshotEquals failed");
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|