waygraph 0.15.23 → 0.15.25

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 (65) hide show
  1. package/dist/cli/discover.d.ts +40 -0
  2. package/dist/cli/discover.js +148 -0
  3. package/dist/cli/flags.d.ts +91 -0
  4. package/dist/cli/flags.js +442 -0
  5. package/dist/cli/run-chain.d.ts +8 -0
  6. package/dist/cli/run-chain.js +67 -0
  7. package/dist/cli/usage.d.ts +4 -0
  8. package/dist/cli/usage.js +236 -0
  9. package/dist/cli/util.d.ts +4 -0
  10. package/dist/cli/util.js +24 -0
  11. package/dist/cli.js +45 -2448
  12. package/dist/commands/agent-dive.d.ts +1 -0
  13. package/dist/commands/agent-dive.js +52 -0
  14. package/dist/commands/check.d.ts +4 -0
  15. package/dist/commands/check.js +192 -0
  16. package/dist/commands/init.d.ts +1 -0
  17. package/dist/commands/init.js +54 -0
  18. package/dist/commands/list.d.ts +2 -0
  19. package/dist/commands/list.js +67 -0
  20. package/dist/commands/map.d.ts +1 -0
  21. package/dist/commands/map.js +29 -0
  22. package/dist/commands/run.d.ts +3 -0
  23. package/dist/commands/run.js +104 -0
  24. package/dist/commands/session.d.ts +2 -0
  25. package/dist/commands/session.js +600 -0
  26. package/dist/commands/test.d.ts +1 -0
  27. package/dist/commands/test.js +33 -0
  28. package/dist/commands/traverse.d.ts +1 -0
  29. package/dist/commands/traverse.js +177 -0
  30. package/dist/commands/try.d.ts +1 -0
  31. package/dist/commands/try.js +298 -0
  32. package/dist/engine/blocks/effect.d.ts +41 -0
  33. package/dist/engine/blocks/effect.js +23 -0
  34. package/dist/engine/blocks/method.d.ts +90 -0
  35. package/dist/engine/blocks/method.js +70 -0
  36. package/dist/engine/blocks/nav.d.ts +138 -0
  37. package/dist/engine/blocks/nav.js +110 -0
  38. package/dist/engine/blocks/page.d.ts +59 -0
  39. package/dist/engine/blocks/page.js +91 -0
  40. package/dist/engine/compose.d.ts +75 -0
  41. package/dist/engine/compose.js +76 -0
  42. package/dist/engine/config.d.ts +55 -0
  43. package/dist/engine/config.js +17 -0
  44. package/dist/engine/core.d.ts +92 -0
  45. package/dist/engine/core.js +256 -0
  46. package/dist/engine/engine-class.d.ts +289 -0
  47. package/dist/engine/engine-class.js +257 -0
  48. package/dist/engine/flow.d.ts +266 -0
  49. package/dist/engine/flow.js +387 -0
  50. package/dist/engine/locate.d.ts +26 -0
  51. package/dist/engine/locate.js +62 -0
  52. package/dist/engine/run-graph.d.ts +147 -0
  53. package/dist/engine/run-graph.js +223 -0
  54. package/dist/engine.d.ts +11 -1224
  55. package/dist/engine.js +12 -1550
  56. package/examples/saucedemo/.waygraph-auto/0ac58118.log +0 -0
  57. package/examples/saucedemo/.waygraph-auto/309c107f.log +0 -0
  58. package/examples/saucedemo/.waygraph-auto/3ab7c7bd.log +44 -0
  59. package/examples/saucedemo/.waygraph-auto/45864828.log +0 -0
  60. package/examples/saucedemo/.waygraph-auto/95bd8371.log +0 -0
  61. package/examples/saucedemo/.waygraph-auto/bcb9e31a.log +0 -0
  62. package/examples/saucedemo/.waygraph-auto/cd3e528c.log +0 -0
  63. package/examples/saucedemo/.waygraph-auto/dce1535d.log +0 -0
  64. package/examples/saucedemo/.waygraph-auto/e280bf20.log +0 -0
  65. package/package.json +1 -1
@@ -0,0 +1,236 @@
1
+ export function printBrowserUsage() {
2
+ console.log(`waygraph browser — persistent Playwright sessions (headful by default)
3
+
4
+ waygraph browser start [--inject preset|path] [--goto <url>] [--blank] [--headless] [--cli] [project]
5
+ Open a new session (about:blank by default)
6
+ waygraph browser sessions [--json] [project]
7
+ List live sessions for a project
8
+ waygraph browser stop <sessionId|--all> [project]
9
+ waygraph browser attach <sessionId> Terminal picker on a live session
10
+
11
+ waygraph browser status <sessionId> Current menu (no side effects)
12
+ waygraph browser send <sessionId> "<pick>"
13
+ waygraph browser reach <sessionId> <Checkpoint>
14
+ waygraph browser dom|trace|console|storage|highlight <sessionId> …
15
+ waygraph browser click|type|press|goto|upload|reload|resync <sessionId> …
16
+
17
+ auto send|status|… and pilot send|status|… use the same session ids.`);
18
+ }
19
+ export function printBrowserSessionsList(sessions, projectDir) {
20
+ if (sessions.length === 0) {
21
+ console.log(`No live browser sessions for ${projectDir}.`);
22
+ console.log(" waygraph browser start");
23
+ return;
24
+ }
25
+ console.log(`Live browser sessions (${projectDir}):`);
26
+ for (const s of sessions) {
27
+ const mode = s.headless ? "headless" : "headful";
28
+ console.log(` ${s.sessionId} ${mode} pid ${s.pid}`);
29
+ console.log(` waygraph browser attach ${s.sessionId}`);
30
+ console.log(` waygraph browser stop ${s.sessionId}`);
31
+ }
32
+ }
33
+ export function usage() {
34
+ console.log(`waygraph -- graph project tool + engine CLI
35
+
36
+ Primary (less is more):
37
+ waygraph auto [project|.flow.ts] Interactive explore (picker)
38
+ --cli Terminal menu instead of browser panel
39
+ --cli --detach Run the --cli session as a background socket
40
+ server; prints {sessionId, socketPath} and exits
41
+ --blocks <From> <To> Graph path-find From->To, then run
42
+ --data '{...}' Mem seed (same as demo/run)
43
+ (pass a .flow.ts to run that flow - same as run)
44
+ --cli --detach --non-headless Detached session with a real visible browser
45
+ (same --non-headless flag run/demo already use)
46
+ waygraph auto send <sessionId> "<pick>" Send one pick to a --detach session, print
47
+ the resulting state as JSON (no TTY needed).
48
+ <pick> is a 1-based menu index, a Block name
49
+ (exact match; ambiguous names refuse rather than
50
+ guess), or "q"/"quit". Same command as
51
+ browser send <sessionId> "<pick>" (prefer that
52
+ prefix for a --detach/persistent session).
53
+ --timeout <ms> Override the 15s default wait for this one call -
54
+ a single Block can legitimately run a slow real
55
+ interaction (e.g. a multi-step mouse drag)
56
+ waygraph auto status <sessionId> Read a --detach session's state (no side effects)
57
+ waygraph auto attach <sessionId> Reopen an interactive terminal against a
58
+ running --detach session
59
+ waygraph auto dom <sessionId> Read the live page's structure (no side effects)
60
+ --mode aria|full Default aria (Playwright ariaSnapshotJSON, AI mode);
61
+ full = bounded raw DOM walk (tag/attrs/text/children)
62
+ --selector <sel> Scope either mode to one element's subtree
63
+ --depth N Limit snapshot depth (aria: native; full: caller cap)
64
+ waygraph auto trace <sessionId> Read the session's Checkpoint/Block-level history
65
+ (no side effects; not raw click/fill recording)
66
+ waygraph auto console <sessionId> Read the real browser console/pageerror messages and
67
+ failed (4xx/5xx) network responses seen so far - for
68
+ diagnosing a silent failure (e.g. a form submit that
69
+ does nothing observable in the DOM) that inspectDom
70
+ alone can't explain, since it only reads what actually
71
+ rendered, not what the page/network actually said
72
+ waygraph auto storage <sessionId> Read localStorage/sessionStorage plus registered
73
+ service workers (scope/active URL/state) - client-
74
+ side state (push-subscription/auth tokens etc.) that
75
+ never appears in the rendered DOM inspectDom reads
76
+ waygraph auto click <sessionId> <sel> Click a real element - works even with zero Blocks
77
+ (Blind Pilot: act before any Block covers this)
78
+ waygraph auto type <sessionId> <sel> <text> Fill a real input the same way
79
+ waygraph auto goto <sessionId> <url> Navigate the real live page
80
+ waygraph auto press <sessionId> <sel> <key>
81
+ Presses a real key (Playwright name, e.g. Enter,
82
+ Escape, Tab) on a real focused element - many real
83
+ inline-edit inputs (no visible Save button until you
84
+ type) commit on Enter, not blur/click-elsewhere
85
+ waygraph auto upload <sessionId> <sel> <image|pdf|video|path>
86
+ Fill a real <input type="file"> - a built-in stub
87
+ (small, real, valid: assets/stubs/stub.png|pdf|mp4)
88
+ or a caller-supplied file path
89
+ (click/type/goto/upload each re-detect the session's Checkpoint afterward,
90
+ same detection send/status already use)
91
+ waygraph auto reload <sessionId> Re-discover the project's Block library/graph
92
+ from disk without restarting the session - picks
93
+ up a Block written to disk mid-session
94
+ waygraph auto reach <sessionId> <Checkpoint> Path-find from here to Checkpoint and run
95
+ the whole route in one call - not one auto send
96
+ per step. Same findBlockPath BFS auto --blocks
97
+ <From> <To> already uses, against this session's
98
+ own live graph/position. Fails loud (not a guess)
99
+ if a step has several live options on the page
100
+ (an instanceOptions Block) - use send for that step
101
+ waygraph auto resync <sessionId> Force here to be re-detected from the real live
102
+ page right now, discarding whatever was cached -
103
+ fixes a session's tracked position going stale
104
+ after anything OUTSIDE this session changed the
105
+ page (e.g. a human clicking around in a visible
106
+ --non-headless session someone is co-driving);
107
+ send/reach never do this on their own, since they
108
+ only re-detect when the position is already unknown
109
+ waygraph auto highlight <sessionId> '<json>'
110
+ Paint agent highlight fixtures on the live page
111
+ (rings + optional todos). Same visual language as
112
+ Block stubBefore in demo. JSON: rings[{selector,
113
+ label,tone?,size?,weight?}], todos[], todoIndex?,
114
+ todoTitle?, holdMs? (0=until next), clear:true.
115
+ Missing selectors listed in response, not fatal.
116
+ Same command as browser highlight <sessionId>
117
+ '<json>' (prefer that prefix for a --detach/
118
+ persistent session).
119
+ <selector>|<label>[|<tone>] Shorthand for 1-3 rings, no JSON braces/quotes
120
+ to escape - rings separated by ";", e.g.
121
+ "#x|Login button|warning; .err|Error banner|danger".
122
+ Covers selector/label/tone only; anything else
123
+ (size/weight/zoom/focus/todos/...) needs the JSON
124
+ form above.
125
+ waygraph browser Show browser subcommands
126
+ waygraph browser start Open a new session (headful by default, about:blank)
127
+ --inject preset|path Merge an external Block library (e.g. saucedemo)
128
+ --goto <url> Navigate on start (disables blank page)
129
+ --blank Force about:blank on start (default)
130
+ --headless Headless session (default is visible browser)
131
+ --cli After start, open the terminal picker (auto attach)
132
+ waygraph browser sessions [project] List live browser sessions (attach/status/stop by id)
133
+ waygraph browser send|status|attach|… Same session control as auto (see auto send/status/…)
134
+ waygraph pilot start Bootstrap: browser session + whole-project graph +
135
+ starting snapshot in one call. Does not plan or act.
136
+ --inject / --goto / --headless / --cli / --base-url Same flags as browser start
137
+ waygraph pilot sessions [project] List live sessions (prefer attach over a new start)
138
+ waygraph pilot attach <sessionId> Graph + snapshot for an existing session (no new browser)
139
+ waygraph pilot send|status|highlight|… Same session control as browser/auto
140
+ waygraph auto Interactive explore (picker) — NOT the persistent browser
141
+ layer; use browser/pilot for agent-driven sessions.
142
+ waygraph demo [--blocks <flow|file|spec>] Watch with step overlay (QA path)
143
+ --data '{...}' Mem seed JSON (or inline flow({...}))
144
+ --mem-stub Fill any requires key --data didn't cover from
145
+ registerMemStub's registry (needs the key
146
+ registered, or the flow's own withMemStub - a
147
+ key with neither still fails preflight)
148
+ --auto-next Auto-advance steps (alias: --autoplay)
149
+ --fast Shorter auto-next / Next gates (keeps smooth cursor)
150
+ --full Classic wrap-all block chips (default: carousel)
151
+ --mini Force compact mini panel (Hide pill + Next); alias --stepper-mini
152
+ --todo-left|--todo-right Floating checklist dock side (also ctx.todoPos / WAYGRAPH_TODO_POS)
153
+ --todo-full Opt out: full checklist, no compact/collision/behind-ring
154
+ --todo-smart Opt in: compact + collision + behind-ring (default)
155
+ --ff-expand Expand fastForwardComposeBlock inners as separate steps
156
+ --ff-disabled Dispute: expand FF (alias --no-ff); blitz kept on those inners
157
+ --auto-play-video Unattended + recorded: --auto-next + --video (+ step); headless
158
+ --auto-play-video-head Same, but keep the browser visible (--non-headless)
159
+ --video [dir] Record .webm (demo: headless unless --non-headless)
160
+ --video-viewport WxH Recording size (default demo: 1920x1080)
161
+ --title / --base-url
162
+ waygraph run [--blocks <flow|file|spec>] Execute (no overlay unless --step)
163
+ --data '{...}'
164
+ --mem-stub Same as demo's --mem-stub
165
+ --non-headless Show browser
166
+ --video [dir] Record .webm
167
+ --video-viewport WxH Recording size (default run: 1280x720)
168
+ --ff-expand Same as demo (expand FFCompose inners)
169
+ --ff-disabled Same as demo (dispute: expand FF)
170
+ waygraph test Runs the project's @playwright/test suite (cwd) -
171
+ thin wrapper: forwards to the local playwright
172
+ binary (or npx playwright as a fallback)
173
+ test ui / test --ui Playwright UI Mode (interactive, watch + trace)
174
+ test report [dir] Open the last HTML report (playwright show-report)
175
+ test show-trace <file> Open one trace.zip in the trace viewer
176
+ <any other args> Forwarded verbatim (--grep, a spec path, --headed, …)
177
+ Scaffolds ship trace: "retain-on-failure" + the
178
+ html reporter, so a failed waygraph test already
179
+ has a trace - test report opens it.
180
+
181
+ Also:
182
+ waygraph list | nav | validate | check | typecheck | graph | init <name>
183
+ check/typecheck --no-practices Skip bad-practice warnings
184
+ waygraph map [project] Waygraph Map convention enforcement: every static
185
+ Nav/Page url must verbatim-match its src/map/ folder
186
+ path ((group) segments excluded) - exits 1 on a
187
+ violation, unlike check's warnings-only stance. A
188
+ no-op (exit 0, informational) if the project has no
189
+ src/map/ directory at all.
190
+ waygraph traverse [project] Graph crawl (Phase B-E)
191
+ --blocks <glob|/re/|sub> Phase C: filter *.block.ts discovery
192
+ --parallel N Phase D: N clone workers (max 4)
193
+ --session clone|inherit Phase D: default clone
194
+ --from <Checkpoint> Seed / start checkpoint
195
+ --data '{...}' Mem seed
196
+ --max-steps N Cap Block runs (default 50)
197
+ --max-visits N Cap visits per node (default 2)
198
+ --non-headless Show browser
199
+ waygraph agent-dive [--loop claude|opencode|cursor|vscode] [--prompts]
200
+ Initialize coding-agent defs (Playwright init-agents analogue)
201
+ waygraph try [demo|auto|auto:cli] One-shot saucedemo in a temp dir
202
+ try auto Headed browser panel (default)
203
+ try auto:cli / --cli Terminal menu instead
204
+ try auto --headed Same as try auto (compat)
205
+
206
+ Skills (print packaged skill markdown to stdout - for agents / paste):
207
+ waygraph --skill List available skills
208
+ waygraph --skill-pilot Drive an existing Block graph
209
+ waygraph --skill-pilot-blind Cold-start: raw ops + author Blocks
210
+ waygraph --skill-convention Block/Map authoring conventions
211
+
212
+ Examples:
213
+ waygraph list # file → export map
214
+ waygraph run src/flows/shop.flow.ts --data '{...}'
215
+ waygraph run --blocks shopFlow --non-headless --video
216
+ waygraph demo --blocks src/flows/cart-bulk.flow.ts --auto-next --fast
217
+ waygraph demo src/flows/shop.flow.ts --full
218
+ waygraph try auto
219
+ waygraph try auto:cli
220
+ waygraph auto src/flows/shop.flow.ts --data '{...}' # run by file (same as run)
221
+ waygraph auto --cli --data '{"saucedemo.credentials":{...}}'
222
+ waygraph auto --blocks LoginPage OrderComplete
223
+ waygraph auto --blocks '/mailpit/' # Phase C filtered explore
224
+ waygraph traverse --blocks '**/mailpit/**/*.block.ts' # Phase C filtered crawl
225
+ waygraph traverse --parallel 2 --session clone # Phase D clone workers
226
+ waygraph run --blocks "loginFlow then add-all-to-cart" --data '{...}' --video
227
+
228
+ Aliases (compat): \`chain <spec>\` -> run --blocks; \`chain auto A B\` -> auto --blocks A B;
229
+ --autoplay -> --auto-next. Prefer the primary verbs above.
230
+
231
+ Project path optional (defaults to cwd). Flags beat WAYGRAPH_* env.
232
+ \`run\`/\`demo\`/\`auto\`: Flow export, .flow.ts path, or "a then b" chain (auto also explores).
233
+ Hide stepper = compact "N / M · block" pill. Collapses while a step runs (clicks hit the page). Video mode stays compact.
234
+ `);
235
+ process.exit(0);
236
+ }
@@ -0,0 +1,4 @@
1
+ /** This package's own installed root - dist/cli.js -> .. */
2
+ export declare function packageRoot(): string;
3
+ /** Spawns with inherited stdio (the real npm/playwright output, visible) and resolves to its exit code. */
4
+ export declare function runInherited(cmd: string, args: string[], cwd: string): Promise<number>;
@@ -0,0 +1,24 @@
1
+ // Split out of the former 8,700-line cli.ts (see src/ARCHITECTURE.md). Behavior unchanged.
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { spawn } from "node:child_process";
5
+ // ---------------------------------------------------------------------------
6
+ // `try` - a bundled, self-contained showcase. No .flow.ts to write, no
7
+ // scenario to design - copies a small real Flow (nav/action Blocks, Trait
8
+ // verify, narrate()) into the target project and runs it in step mode
9
+ // against a public demo site, so a curious dev sees the real overlay/panel
10
+ // experience in under a minute, then gets pointed at the plain waygraph
11
+ // source that produced it.
12
+ // ---------------------------------------------------------------------------
13
+ /** This package's own installed root - dist/cli.js -> .. */
14
+ export function packageRoot() {
15
+ return resolve(dirname(fileURLToPath(import.meta.url)), "..");
16
+ }
17
+ /** Spawns with inherited stdio (the real npm/playwright output, visible) and resolves to its exit code. */
18
+ export function runInherited(cmd, args, cwd) {
19
+ return new Promise((res, rej) => {
20
+ const child = spawn(cmd, args, { cwd, stdio: "inherit", env: process.env });
21
+ child.on("error", rej);
22
+ child.on("exit", (code) => res(code ?? 1));
23
+ });
24
+ }