waygraph 0.10.4 → 0.10.6

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
@@ -3,7 +3,7 @@
3
3
  A typed graph of reusable Blocks for driving a browser through E2E flows, in place of a
4
4
  flat pile of ad hoc helper functions.
5
5
 
6
- **Current:** `0.10.4` — CLI less-is-more (`auto` / `demo` / `run` + `.flow.ts` paths). Page hubs still as in 0.9.0.
6
+ **Current:** `0.10.6` — `try auto` headed by default; `init` / create-waygraph scaffolds on 0.10 + `.flow.ts` scripts.
7
7
 
8
8
  This repo is the `waygraph` npm package itself. The full live **Sauce Demo** example
9
9
  (Page inventory hub, Effect Add/Remove, MemNav Open details, `waygraph auto`) ships
@@ -262,12 +262,13 @@ Deliberately **not yet implemented** (tracked on the project board):
262
262
  Mermaid) is `waygraph graph [project]` (`--mermaid`). Unattended JSON execution is
263
263
  `chain` + `WAYGRAPH_JSON=1`.
264
264
 
265
- **Friendly demo / run / auto (0.10.4 — flows are files):**
265
+ **Friendly demo / run / auto (0.10.5 — flows are files):**
266
266
 
267
267
  | Want | Command |
268
268
  |------|---------|
269
269
  | List flows | `waygraph list` → `src/flows/shop.flow.ts shopFlow` |
270
270
  | Run by file | `waygraph run src/flows/shop.flow.ts --data '{…}'` |
271
+ | Same via `auto` | `waygraph auto src/flows/shop.flow.ts --data '{…}'` |
271
272
  | Run by export | `waygraph run --blocks shopFlow` |
272
273
  | Manual watch | `waygraph demo src/flows/shop.flow.ts` |
273
274
  | Auto-advance | `waygraph demo --blocks shopFlow --auto-next` |
@@ -278,6 +279,7 @@ Mermaid) is `waygraph graph [project]` (`--mermaid`). Unattended JSON execution
278
279
  | Path-find | `waygraph auto --blocks LoginPage OrderComplete` |
279
280
 
280
281
  `--blocks` / positional accepts a Flow export, a `.flow.ts` path, or `"a then b"`.
282
+ `auto <file.flow.ts>` **runs** that flow (same as `run`); bare `auto` still explores.
281
283
  `--auto-next` (alias `--autoplay`) = panel Auto-advance. `--auto-play-video` is **demo only**.
282
284
  `chain` remains a compat alias for `run --blocks` / `auto --blocks`.
283
285
 
package/dist/cli.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * waygraph CLI -- tooling around this same package's engine.
4
4
  *
5
5
  * Primary verbs (less is more):
6
- * auto Explore picker; `--blocks From To` = graph path-find + run
6
+ * auto Explore picker; `.flow.ts` / `--blocks From To` = run that path
7
7
  * demo Watch (step overlay); `--blocks` `--data` `--auto-next` `--auto-play-video`
8
8
  * run Execute; `--blocks` `--data` `--non-headless` `--video`
9
9
  *
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * waygraph CLI -- tooling around this same package's engine.
4
4
  *
5
5
  * Primary verbs (less is more):
6
- * auto Explore picker; `--blocks From To` = graph path-find + run
6
+ * auto Explore picker; `.flow.ts` / `--blocks From To` = run that path
7
7
  * demo Watch (step overlay); `--blocks` `--data` `--auto-next` `--auto-play-video`
8
8
  * run Execute; `--blocks` `--data` `--non-headless` `--video`
9
9
  *
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * "project" defaults to cwd. Flags beat WAYGRAPH_* env.
14
14
  */
15
- import { existsSync, readdirSync, readFileSync, writeFileSync, rmSync, cpSync, mkdirSync, mkdtempSync } from "node:fs";
15
+ import { existsSync, readdirSync, readFileSync, writeFileSync, rmSync, cpSync, mkdirSync, mkdtempSync, statSync } from "node:fs";
16
16
  import { resolve, relative, join, basename, dirname } from "node:path";
17
17
  import { tmpdir } from "node:os";
18
18
  import { fileURLToPath } from "node:url";
@@ -2557,26 +2557,27 @@ async function runTryDemo() {
2557
2557
  const TRY_AUTO_DATA = '{"saucedemo.credentials":{"username":"standard_user","password":"secret_sauce"}}';
2558
2558
  /**
2559
2559
  * `waygraph try auto` / `try auto:cli` - temp Sauce Demo explore.
2560
- * Default is CLI menu (same as `npm run auto:cli`). Pass `--headed` for the browser panel.
2560
+ * Default is the **headed** browser panel. Pass `auto:cli` or `--cli` for the
2561
+ * terminal menu (same rows).
2561
2562
  *
2562
2563
  * Runs as a child in the temp project so Block imports share that install's
2563
2564
  * `@playwright/test`. In-process explore from the outer CLI against a packed
2564
2565
  * `file:*.tgz` copy double-loads Playwright and silently yields 0 graph edges
2565
2566
  * ("LoginPage / No moves").
2566
2567
  */
2567
- async function runTryAuto(opts = { cli: true }) {
2568
+ async function runTryAuto(opts = { cli: false }) {
2568
2569
  const destDir = await prepareTryQuickstart("waygraph-try-auto");
2569
2570
  if (!destDir)
2570
2571
  return;
2571
2572
  process.env.WAYGRAPH_BASE_URL ??= "https://www.saucedemo.com";
2572
- const cli = opts.cli !== false;
2573
+ const cli = opts.cli === true;
2573
2574
  console.log(cli
2574
2575
  ? "waygraph try auto: CLI explore on Sauce Demo (temp dir).\n" +
2575
2576
  " Creds pre-seeded (saucedemo.credentials).\n" +
2576
2577
  " Pick [1] submit-login, then inventory Add/Remove / Open details.\n" +
2577
- " Type q to quit. Headed panel: waygraph try auto --headed\n"
2578
+ " Type q to quit. Headed panel: waygraph try auto\n"
2578
2579
  : "waygraph try auto: headed explore on Sauce Demo (temp dir).\n" +
2579
- " Creds pre-seeded. Prefer CLI: waygraph try auto:cli\n" +
2580
+ " Creds pre-seeded. CLI menu: waygraph try auto:cli\n" +
2580
2581
  " Pick submit-login, then inventory menus. Quit from the panel.\n");
2581
2582
  const bin = join(destDir, "node_modules", ".bin", "waygraph");
2582
2583
  const args = ["auto"];
@@ -2589,8 +2590,8 @@ async function runTryAuto(opts = { cli: true }) {
2589
2590
  console.log("\nwaygraph try auto: explorer closed.\n\n" +
2590
2591
  `Temp project:\n ${destDir}\n\n` +
2591
2592
  "Run again:\n" +
2592
- ` cd ${destDir} && npm run auto:cli\n` +
2593
- ` cd ${destDir} && npm run auto\n\n` +
2593
+ ` cd ${destDir} && npm run auto\n` +
2594
+ ` cd ${destDir} && npm run auto:cli\n\n` +
2594
2595
  "In-package: examples/saucedemo\n" +
2595
2596
  "Docs: https://deviate-dv8.github.io/waygraph/auto.html\n");
2596
2597
  }
@@ -2721,8 +2722,11 @@ function initCommand(projectName) {
2721
2722
  console.log(" npm install");
2722
2723
  console.log(" npx playwright install chromium");
2723
2724
  console.log(" npm test");
2725
+ console.log(" waygraph list # .flow.ts → export map");
2724
2726
  console.log(" waygraph check # nav hygiene + orphan Blocks");
2725
- console.log(" waygraph auto # interactive explore (headful picker)");
2727
+ console.log(" waygraph auto # interactive explore (headed panel)");
2728
+ console.log(" waygraph auto --cli # same menus in the terminal");
2729
+ console.log(" waygraph demo src/flows/example.flow.ts");
2726
2730
  console.log(" waygraph graph # static state graph JSON");
2727
2731
  }
2728
2732
  async function checkCommand(projectDir) {
@@ -3058,10 +3062,11 @@ function usage() {
3058
3062
  console.log(`waygraph -- graph project tool + engine CLI
3059
3063
 
3060
3064
  Primary (less is more):
3061
- waygraph auto [project] Interactive explore (picker)
3065
+ waygraph auto [project|.flow.ts] Interactive explore (picker)
3062
3066
  --cli Terminal menu instead of browser panel
3063
3067
  --blocks <From> <To> Graph path-find From->To, then run
3064
3068
  --data '{...}' Mem seed (same as demo/run)
3069
+ (pass a .flow.ts to run that flow - same as run)
3065
3070
  waygraph demo [--blocks <flow|file|spec>] Watch with step overlay (QA path)
3066
3071
  --data '{...}' Mem seed JSON (or inline flow({...}))
3067
3072
  --auto-next Auto-advance steps (alias: --autoplay)
@@ -3075,14 +3080,18 @@ Primary (less is more):
3075
3080
  Also:
3076
3081
  waygraph list | nav | validate | check | graph | init <name>
3077
3082
  waygraph try [demo|auto|auto:cli] One-shot saucedemo in a temp dir
3078
- try auto --headed Browser panel instead of CLI
3083
+ try auto Headed browser panel (default)
3084
+ try auto:cli / --cli Terminal menu instead
3085
+ try auto --headed Same as try auto (compat)
3079
3086
 
3080
3087
  Examples:
3081
3088
  waygraph list # file → export map
3082
3089
  waygraph run src/flows/shop.flow.ts --data '{...}'
3083
3090
  waygraph run --blocks shopFlow --non-headless --video
3084
3091
  waygraph demo --blocks src/flows/cart-bulk.flow.ts --auto-next
3092
+ waygraph try auto
3085
3093
  waygraph try auto:cli
3094
+ waygraph auto src/flows/shop.flow.ts --data '{...}' # run by file (same as run)
3086
3095
  waygraph auto --cli --data '{"saucedemo.credentials":{...}}'
3087
3096
  waygraph auto --blocks LoginPage OrderComplete
3088
3097
  waygraph run --blocks "loginFlow then add-all-to-cart" --data '{...}' --video
@@ -3091,7 +3100,7 @@ Aliases (compat): \`chain <spec>\` -> run --blocks; \`chain auto A B\` -> auto -
3091
3100
  --autoplay -> --auto-next. Prefer the primary verbs above.
3092
3101
 
3093
3102
  Project path optional (defaults to cwd). Flags beat WAYGRAPH_* env.
3094
- \`--blocks\` / positional: Flow export (shopFlow), .flow.ts path, or "a then b" chain.
3103
+ \`run\`/\`demo\`/\`auto\`: Flow export, .flow.ts path, or "a then b" chain (auto also explores).
3095
3104
  `);
3096
3105
  process.exit(0);
3097
3106
  }
@@ -3241,11 +3250,35 @@ async function main() {
3241
3250
  const mermaid = flags.mermaid === true;
3242
3251
  const mapOnly = command === "graph" || flags.map === true;
3243
3252
  const cliPicker = flags.cli === true;
3244
- const proj = resolve(flags.positionals[0] ?? process.cwd());
3253
+ const firstPos = flags.positionals[0];
3254
+ // auto src/flows/shop.flow.ts → run that flow (same as `run`). Do not
3255
+ // treat a .flow.ts path as a project directory (existsSync is true for files).
3256
+ if (command === "auto" && firstPos && looksLikeFlowFileRef(firstPos) && !flags.blocksFromTo) {
3257
+ const proj = resolve(process.cwd());
3258
+ if (!existsSync(proj) || !statSync(proj).isDirectory()) {
3259
+ console.error(`waygraph: no such directory: ${proj}`);
3260
+ process.exit(1);
3261
+ }
3262
+ if (!process.env.WAYGRAPH_BASE_URL) {
3263
+ const resolved = resolveBaseUrl(proj);
3264
+ if (resolved)
3265
+ process.env.WAYGRAPH_BASE_URL = resolved;
3266
+ }
3267
+ await runChain(proj, firstPos);
3268
+ break;
3269
+ }
3270
+ const proj = resolve(firstPos ?? process.cwd());
3245
3271
  if (!existsSync(proj)) {
3246
3272
  console.error(`waygraph: no such directory: ${proj}`);
3247
3273
  process.exit(1);
3248
3274
  }
3275
+ if (!statSync(proj).isDirectory()) {
3276
+ console.error(`waygraph ${command}: "${firstPos}" is a file, not a project directory\n` +
3277
+ " run a flow: waygraph auto src/flows/shop.flow.ts\n" +
3278
+ " or explore: waygraph auto\n" +
3279
+ " or path-find: waygraph auto --blocks LoginPage OrderComplete");
3280
+ process.exit(1);
3281
+ }
3249
3282
  // auto --blocks From To (graph path-find + run)
3250
3283
  if (command === "auto" && (flags.blocksFromTo || flags.blocks)) {
3251
3284
  if (flags.blocksFromTo) {
@@ -3255,7 +3288,8 @@ async function main() {
3255
3288
  }
3256
3289
  console.error("waygraph auto --blocks expects <fromCheckpoint> <toCheckpoint>\n" +
3257
3290
  ' e.g. waygraph auto --blocks LoginPage OrderComplete\n' +
3258
- ' for a hand-named chain use: waygraph run --blocks "a then b"');
3291
+ ' for a hand-named chain use: waygraph run --blocks "a then b"\n' +
3292
+ " or: waygraph auto src/flows/shop.flow.ts");
3259
3293
  process.exit(1);
3260
3294
  }
3261
3295
  if (mapOnly || mermaid) {
@@ -3283,19 +3317,18 @@ async function main() {
3283
3317
  const flags = parseRunFlags(args.slice(1));
3284
3318
  applyRunFlags(flags);
3285
3319
  const modeRaw = (flags.positionals[0] ?? "demo").toLowerCase();
3286
- // auto:cli / auto-cli = CLI explore; auto --headed = browser panel; auto = CLI default
3320
+ // auto:cli / --cli = CLI; bare try auto = headed panel
3287
3321
  const mode = modeRaw === "auto:cli" || modeRaw === "auto-cli"
3288
3322
  ? "auto:cli"
3289
3323
  : modeRaw === "auto"
3290
3324
  ? "auto"
3291
3325
  : modeRaw;
3292
3326
  if (mode === "auto" || mode === "auto:cli") {
3293
- // CLI is the default for try auto (same menus as headed). --headed = panel.
3294
3327
  const cli = mode === "auto:cli" || flags.cli === true
3295
3328
  ? true
3296
3329
  : flags.headed === true || flags.nonHeadless === true
3297
3330
  ? false
3298
- : true;
3331
+ : false; // try auto default = headed
3299
3332
  await runTryAuto({ cli });
3300
3333
  }
3301
3334
  else if (mode === "demo" || mode === "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waygraph",
3
- "version": "0.10.4",
3
+ "version": "0.10.6",
4
4
  "type": "module",
5
5
  "description": "A typed graph of reusable Blocks for driving a browser through E2E flows.",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "baseUrl": "https://www.saucedemo.com"
24
24
  },
25
25
  "dependencies": {
26
- "waygraph": "^0.10.4"
26
+ "waygraph": "^0.10.6"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@playwright/test": "^1.55.0",
@@ -6,17 +6,19 @@
6
6
  "scripts": {
7
7
  "typecheck": "tsc --noEmit",
8
8
  "test": "playwright test",
9
- "flows": "waygraph list",
9
+ "list": "waygraph list",
10
10
  "check": "waygraph check",
11
11
  "auto": "waygraph auto",
12
- "graph": "waygraph graph",
13
- "demo": "waygraph demo exampleFlow"
12
+ "auto:cli": "waygraph auto --cli",
13
+ "demo": "waygraph demo src/flows/example.flow.ts",
14
+ "run": "waygraph run src/flows/example.flow.ts",
15
+ "graph": "waygraph graph"
14
16
  },
15
17
  "waygraph": {
16
18
  "baseUrl": "https://example.com"
17
19
  },
18
20
  "dependencies": {
19
- "waygraph": "^0.9.0"
21
+ "waygraph": "^0.10.6"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@playwright/test": "^1.55.0",