ptywright 0.3.0 → 0.5.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 CHANGED
@@ -315,64 +315,71 @@ expose the terminal root as `[data-terminal-root]`.
315
315
 
316
316
  ```bash
317
317
  # First run records snapshots, screenshots, replay metadata, and report.
318
- bun run bin/ptywright agent run examples/agent_deterministic.json --update-snapshots
318
+ bun run src/cli.ts agent run examples/agent_deterministic.json --update-snapshots
319
319
 
320
320
  # Later runs compare terminal + DOM snapshots like a test snapshot.
321
- bun run bin/ptywright agent run examples/agent_deterministic.json
321
+ bun run src/cli.ts agent run examples/agent_deterministic.json
322
322
 
323
323
  # Replay does not need AI; it uses the recorded flow artifact.
324
- bun run bin/ptywright agent replay .tmp/agent/agent_deterministic/agent_deterministic.agent-run.json
324
+ bun run src/cli.ts agent replay .tmp/agent/agent_deterministic/agent_deterministic.agent-run.json
325
325
 
326
326
  # Cassette files are also directly replayable.
327
- bun run bin/ptywright agent replay .tmp/agent/agent_deterministic/agent_deterministic.cassette.json
327
+ bun run src/cli.ts agent replay .tmp/agent/agent_deterministic/agent_deterministic.cassette.json
328
328
 
329
329
  # Promote a live run/cassette into the committed non-AI regression suite.
330
- bun run bin/ptywright agent promote \
330
+ bun run src/cli.ts agent promote \
331
331
  .tmp/agent/agent_deterministic/agent_deterministic.cassette.json \
332
332
  --update-snapshots
333
333
 
334
334
  # Batch replay committed cassettes/run records as a regression suite.
335
- bun run bin/ptywright agent replay-all .tmp/agent --artifacts-root .tmp/agent-replay-all
335
+ bun run src/cli.ts agent replay-all .tmp/agent --artifacts-root .tmp/agent-replay-all
336
336
 
337
337
  # Rerun directly from a generated summary artifact.
338
- bun run bin/ptywright agent rerun .tmp/agent-promote/agent_deterministic/agent-promote.summary.json
339
- bun run bin/ptywright agent rerun .tmp/agent-check/agent-check.summary.json
340
- bun run bin/ptywright agent rerun .tmp/agent-check/agent-replay.summary.json --update-snapshots
338
+ bun run src/cli.ts agent rerun .tmp/agent-promote/agent_deterministic/agent-promote.summary.json
339
+ bun run src/cli.ts agent rerun .tmp/agent-check/agent-check.summary.json
340
+ bun run src/cli.ts agent rerun .tmp/agent-check/agent-replay.summary.json --update-snapshots
341
341
 
342
342
  # Read reusable commands from any supported agent artifact.
343
- bun run bin/ptywright agent commands .tmp/agent-check/agent-check.summary.json --json
344
- bun run bin/ptywright agent commands .tmp/agent-check/agent-check.summary.json --command rerun
345
- bun run bin/ptywright agent commands .tmp/agent-check --json
346
- bun run bin/ptywright agent inspect .tmp/agent-check
347
- bun run bin/ptywright agent inspect .tmp/agent-check --json
348
- bun run bin/ptywright agent validate .tmp/agent-check
349
- bun run bin/ptywright agent exec .tmp/agent-check --command rerun
350
- bun run bin/ptywright agent exec .tmp/agent-check --command updateSnapshots
351
- bun run bin/ptywright agent exec .tmp/agent-check/agent-check.summary.json --command rerun
352
- bun run bin/ptywright agent exec .tmp/agent-check/agent-check.summary.json --command updateSnapshots
343
+ bun run src/cli.ts agent commands .tmp/agent-check/agent-check.summary.json --json
344
+ bun run src/cli.ts agent commands .tmp/agent-check/agent-check.summary.json --command rerun
345
+ bun run src/cli.ts agent commands .tmp/agent-check --json
346
+ bun run src/cli.ts agent inspect .tmp/agent-check
347
+ bun run src/cli.ts agent inspect .tmp/agent-check --json
348
+ bun run src/cli.ts agent validate .tmp/agent-check
349
+ bun run src/cli.ts agent exec .tmp/agent-check --command rerun
350
+ bun run src/cli.ts agent exec .tmp/agent-check --command updateSnapshots
351
+ bun run src/cli.ts agent exec .tmp/agent-check/agent-check.summary.json --command rerun
352
+ bun run src/cli.ts agent exec .tmp/agent-check/agent-check.summary.json --command updateSnapshots
353
353
 
354
354
  # Validate flow/cassette/run-record/summary artifacts before committing.
355
- bun run bin/ptywright agent validate .tmp/agent-replay-all
355
+ bun run src/cli.ts agent validate .tmp/agent-replay-all
356
356
 
357
357
  # Run committed cassette replay regression without launching live agents.
358
- bun run bin/ptywright agent check
359
- bun run bin/ptywright agent check --json
358
+ bun run src/cli.ts agent check
359
+ bun run src/cli.ts agent check --json
360
360
 
361
361
  # Update terminal/DOM baselines from committed cassettes intentionally.
362
- bun run bin/ptywright agent replay-all tests/agent-cassettes --update-snapshots
362
+ bun run src/cli.ts agent replay-all tests/agent-cassettes --update-snapshots
363
363
 
364
364
  # Record browser interactions into a replayable flow spec.
365
- bun run bin/ptywright agent record examples/agents/codex_browser_smoke.json \
365
+ bun run src/cli.ts agent record examples/agents/codex_browser_smoke.json \
366
366
  --out scripts/agents/codex_recorded.flow.json \
367
367
  --duration-ms 60000 \
368
368
  --headed
369
369
 
370
370
  # Generate starter specs for real agents.
371
- bun run bin/ptywright agent init codex examples/agents/codex_browser_smoke.json
372
- bun run bin/ptywright agent init claude examples/agents/claude_browser_smoke.json
373
- bun run bin/ptywright agent init droidx examples/agents/droidx_browser_smoke.json
371
+ bun run src/cli.ts agent init codex examples/agents/codex_browser_smoke.json
372
+ bun run src/cli.ts agent init claude examples/agents/claude_browser_smoke.json
373
+ bun run src/cli.ts agent init droidx examples/agents/droidx_browser_smoke.json
374
374
  ```
375
375
 
376
+ DOM artifact viewers use `@aitty/snapshot` as the report renderer. ptywright
377
+ copies `@aitty/snapshot/style.css` and the classic
378
+ `@aitty/snapshot/web-component.global.js` bundle into the report artifacts, then
379
+ renders snapshots through `<aitty-snapshot>`. Terminal internals such as wterm
380
+ rows, ANSI styling, termvision, and viewport-pan come from `@aitty/snapshot`;
381
+ ptywright only supplies the report frame and copied assets.
382
+
376
383
  Artifacts are split intentionally:
377
384
  - `.tmp/agent/<name>/` contains run output, screenshots, `*.flow.json`,
378
385
  `*.agent-run.json`, `*.cassette.json`, `index.html`, and
@@ -380,6 +387,44 @@ Artifacts are split intentionally:
380
387
  - `tests/agent-snapshots/<name>/` contains stable terminal/DOM baselines.
381
388
  - `--update-snapshots` is the explicit update path for intentional UI changes.
382
389
 
390
+ ### Project Config
391
+
392
+ For repeated agent regression work, put project-level defaults in
393
+ `ptywright.config.ts` instead of repeating paths and browser defaults in every
394
+ flow file. The CLI discovers `ptywright.config.ts|mts|cts|js|mjs|cjs` from the
395
+ current directory upward, and `--config <file>` selects one explicitly.
396
+
397
+ ```ts
398
+ import { defineConfig } from "ptywright/config";
399
+
400
+ export default defineConfig({
401
+ agent: {
402
+ artifactsRoot: ".tmp/agent",
403
+ cassetteDir: "tests/agent-cassettes",
404
+ snapshotDir: "tests/agent-snapshots",
405
+ defaults: {
406
+ headless: true,
407
+ timeoutMs: 45_000,
408
+ screenshot: false,
409
+ viewports: [{ name: "desktop", width: 1280, height: 820 }],
410
+ mask: [{ regex: "session_[a-z0-9]+", replacement: "<session>" }],
411
+ },
412
+ },
413
+ });
414
+ ```
415
+
416
+ ```bash
417
+ ptywright agent run tests/agents/codex.flow.json --update-snapshots
418
+ ptywright agent check
419
+ ptywright agent replay-all --update-snapshots
420
+ ptywright agent promote .tmp/agent/codex/codex.cassette.json --update-snapshots
421
+ ```
422
+
423
+ Config paths are resolved relative to the config file directory. CLI arguments
424
+ override config defaults, and fields written in a flow file override config
425
+ defaults for that flow. The flow file remains the test case; the config file is
426
+ only for shared project defaults and common artifact locations.
427
+
383
428
  `launch.mode=command` is the recommended integration contract. `command` and
384
429
  `args` are spawned directly, and ptywright reads the first URL printed to stdout
385
430
  or stderr. Use `waitForUrlMs` to tune startup timeouts and `urlRegex` when the
@@ -529,7 +574,7 @@ details.
529
574
  bun install
530
575
 
531
576
  # Start MCP server
532
- bun run bin/ptywright mcp
577
+ bun run src/cli.ts mcp
533
578
 
534
579
  # Run tests
535
580
  bun run test
@@ -543,11 +588,11 @@ bun run lint
543
588
  bun run format:check
544
589
 
545
590
  # Run scripts
546
- bun run bin/ptywright run scripts/m5_mask_demo.json
547
- bun run bin/ptywright run-all
591
+ bun run src/cli.ts run scripts/m5_mask_demo.json
592
+ bun run src/cli.ts run-all
548
593
 
549
594
  # Run browser agent regression
550
- bun run bin/ptywright agent run examples/agent_deterministic.json --update-snapshots
595
+ bun run src/cli.ts agent run examples/agent_deterministic.json --update-snapshots
551
596
  ```
552
597
 
553
598
  ## Environment Variables
package/dist/agent.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as runAgentSpecPath, i as runAgentSpec, n as printAgentLaunchPlan, r as replayAgentRecordPath, t as defaultSpecNameForPath } from "./runner-zi0nItvB.mjs";
2
- export { defaultSpecNameForPath, printAgentLaunchPlan, replayAgentRecordPath, runAgentSpec, runAgentSpecPath };
1
+ import { a as formatAgentLaunchPlan, i as runAgentSpecPath, n as replayAgentRecordPath, r as runAgentSpec, t as defaultSpecNameForPath } from "./runner-C1gPRyCM.mjs";
2
+ export { defaultSpecNameForPath, formatAgentLaunchPlan, replayAgentRecordPath, runAgentSpec, runAgentSpecPath };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import { t as main } from "../cli-CfvlbRoZ.mjs";
2
+ import { t as main } from "../cli-PnG6UR43.mjs";
3
3
  //#region src/bin/ptywright.ts
4
4
  await main();
5
5
  //#endregion