waygraph 0.15.22 → 0.15.24

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 (58) 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 -8494
  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/runner/chain-run.js +102 -0
  33. package/dist/runner/cursor.js +140 -0
  34. package/dist/runner/demo-log.js +314 -0
  35. package/dist/runner/device-stage.js +400 -0
  36. package/dist/runner/discovery.js +105 -0
  37. package/dist/runner/index.js +2 -0
  38. package/dist/runner/interaction-patch.js +353 -0
  39. package/dist/runner/main.js +397 -0
  40. package/dist/runner/overlay-css.js +342 -0
  41. package/dist/runner/overlay-install.js +1301 -0
  42. package/dist/runner/rings.js +490 -0
  43. package/dist/runner/seed-mem.js +110 -0
  44. package/dist/runner/slides.js +272 -0
  45. package/dist/runner/step-mode.js +776 -0
  46. package/dist/runner/step-panels.js +723 -0
  47. package/dist/runner/teardown.js +195 -0
  48. package/dist/runner/todo-dock.js +142 -0
  49. package/examples/saucedemo/.waygraph-auto/0ac58118.log +0 -0
  50. package/examples/saucedemo/.waygraph-auto/309c107f.log +0 -0
  51. package/examples/saucedemo/.waygraph-auto/3ab7c7bd.log +44 -0
  52. package/examples/saucedemo/.waygraph-auto/45864828.log +0 -0
  53. package/examples/saucedemo/.waygraph-auto/95bd8371.log +0 -0
  54. package/examples/saucedemo/.waygraph-auto/bcb9e31a.log +0 -0
  55. package/examples/saucedemo/.waygraph-auto/cd3e528c.log +0 -0
  56. package/examples/saucedemo/.waygraph-auto/dce1535d.log +0 -0
  57. package/examples/saucedemo/.waygraph-auto/e280bf20.log +0 -0
  58. package/package.json +5 -2
@@ -0,0 +1,40 @@
1
+ export declare function walkDir(dir: string, pattern: RegExp): string[];
2
+ export declare function discoverFlows(projectDir: string): string[];
3
+ export declare function extractFlowNames(filePath: string): string[];
4
+ /** `LoginBlock` -> `"login"`; `OverviewMetricsBlock` -> `"overview-metrics"`. */
5
+ export declare function blockExportToLabel(exportId: string): string;
6
+ /** Every `...Block` identifier a `.flow.ts` file imports, in source order. */
7
+ export declare function parseBlockImports(filePath: string): string[];
8
+ /** Every `page.goto("...")` string literal in a file, in source order. */
9
+ export declare function extractGotos(filePath: string): string[];
10
+ /** Every `Trait.url({ pathname: "..." })` target in a file, in source order. */
11
+ export declare function extractUrlTraits(filePath: string): string[];
12
+ export declare function importModule(filePath: string): Promise<Record<string, unknown>>;
13
+ /** Kept as a named alias - `run`/`validate` below were written against this name first. */
14
+ export declare const importFlowFile: typeof importModule;
15
+ export declare function isFlowLike(val: unknown): val is {
16
+ run: (...args: unknown[]) => Promise<unknown>;
17
+ };
18
+ export declare function discoverBlocks(projectDir: string): string[];
19
+ export declare function isBlockLike(val: unknown): val is {
20
+ name: string;
21
+ instruction: {
22
+ act: unknown;
23
+ };
24
+ };
25
+ /** Set by `defineNavBlock` (non-enumerable) - see src/engine.ts. */
26
+ export declare function isNavBlockMarked(val: Record<string, unknown>): boolean;
27
+ export declare const NAV_METHOD_CALLS: readonly ["page.goto(", "page.reload(", "page.goBack(", "page.goForward("];
28
+ /**
29
+ * Matches a selector-taking Trait factory call whose first argument is a
30
+ * literal string/template, not an identifier or property access - the exact
31
+ * shape found repeatedly in hand-written assertion Blocks
32
+ * (`Trait.visible("#some-id")` instead of `Trait.visible(SomeSel.thing)`).
33
+ * `Trait.url(...)` is deliberately excluded - it takes a URLPatternInit, never
34
+ * a DOM selector. Same file-scoped-regex bluntness the nav-escape sweep above
35
+ * already accepts (see openspec/specs/nav-block-and-check/spec.md) - a known
36
+ * blind spot on string concatenation/template-built selectors, not solved
37
+ * here for the same "recipe before promotion" reason that check accepts its
38
+ * own shared-helper blind spot.
39
+ */
40
+ export declare const INLINE_SELECTOR_CALL: RegExp;
@@ -0,0 +1,148 @@
1
+ // Split out of the former 8,700-line cli.ts (see src/ARCHITECTURE.md). Behavior unchanged.
2
+ import { readFileSync, readdirSync } from "node:fs";
3
+ import { join, resolve } from "node:path";
4
+ // ---------------------------------------------------------------------------
5
+ // Filesystem
6
+ // ---------------------------------------------------------------------------
7
+ export function walkDir(dir, pattern) {
8
+ const results = [];
9
+ let entries;
10
+ try {
11
+ entries = readdirSync(dir, { withFileTypes: true });
12
+ }
13
+ catch {
14
+ return results;
15
+ }
16
+ for (const entry of entries) {
17
+ const full = join(dir, entry.name);
18
+ if (entry.isDirectory()) {
19
+ if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git")
20
+ continue;
21
+ results.push(...walkDir(full, pattern));
22
+ }
23
+ else if (pattern.test(entry.name)) {
24
+ results.push(full);
25
+ }
26
+ }
27
+ return results;
28
+ }
29
+ export function discoverFlows(projectDir) {
30
+ return walkDir(projectDir, /\.flow\.ts$/);
31
+ }
32
+ // ---------------------------------------------------------------------------
33
+ // Static analysis for `list`/`nav` (no import, regex only)
34
+ // ---------------------------------------------------------------------------
35
+ export function extractFlowNames(filePath) {
36
+ const src = readFileSync(filePath, "utf-8");
37
+ const names = [];
38
+ const re = /export\s+const\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*[=:]/g;
39
+ let m;
40
+ while ((m = re.exec(src)) !== null) {
41
+ const name = m[1];
42
+ if (name !== undefined)
43
+ names.push(name);
44
+ }
45
+ return names;
46
+ }
47
+ /** `LoginBlock` -> `"login"`; `OverviewMetricsBlock` -> `"overview-metrics"`. */
48
+ export function blockExportToLabel(exportId) {
49
+ const base = exportId.replace(/Block$/, "");
50
+ return base
51
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
52
+ .replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2")
53
+ .toLowerCase();
54
+ }
55
+ /** Every `...Block` identifier a `.flow.ts` file imports, in source order. */
56
+ export function parseBlockImports(filePath) {
57
+ const src = readFileSync(filePath, "utf-8");
58
+ const names = [];
59
+ const re = /import\s*\{([^}]*)\}\s*from\s*["'][^"']*\.block(?:\.js)?["']/g;
60
+ let m;
61
+ while ((m = re.exec(src)) !== null) {
62
+ for (const part of m[1].split(",")) {
63
+ const name = part.trim().split(/\s+as\s+/)[0]?.trim();
64
+ if (name)
65
+ names.push(name);
66
+ }
67
+ }
68
+ return names;
69
+ }
70
+ /** Every `page.goto("...")` string literal in a file, in source order. */
71
+ export function extractGotos(filePath) {
72
+ const src = readFileSync(filePath, "utf-8");
73
+ const results = [];
74
+ const re = /\.goto\(\s*["'`]([^"'`]*)["'`]/g;
75
+ let m;
76
+ while ((m = re.exec(src)) !== null) {
77
+ const url = m[1];
78
+ if (url !== undefined)
79
+ results.push(url);
80
+ }
81
+ return results;
82
+ }
83
+ /** Every `Trait.url({ pathname: "..." })` target in a file, in source order. */
84
+ export function extractUrlTraits(filePath) {
85
+ const src = readFileSync(filePath, "utf-8");
86
+ const results = [];
87
+ const re = /Trait\.url\(\s*\{[^}]*pathname:\s*["'`]([^"'`]*)["'`]/g;
88
+ let m;
89
+ while ((m = re.exec(src)) !== null) {
90
+ const url = m[1];
91
+ if (url !== undefined)
92
+ results.push(url);
93
+ }
94
+ return results;
95
+ }
96
+ // ---------------------------------------------------------------------------
97
+ // Dynamic import + validation
98
+ // ---------------------------------------------------------------------------
99
+ export async function importModule(filePath) {
100
+ const url = new URL(`file://${resolve(filePath)}`);
101
+ return (await import(url.href));
102
+ }
103
+ /** Kept as a named alias - `run`/`validate` below were written against this name first. */
104
+ export const importFlowFile = importModule;
105
+ export function isFlowLike(val) {
106
+ if (val === null || typeof val !== "object")
107
+ return false;
108
+ const obj = val;
109
+ return typeof obj.run === "function";
110
+ }
111
+ // ---------------------------------------------------------------------------
112
+ // `check` - secondary/complementary to the ActionPage @deprecated warning
113
+ // (src/types.ts). That's the primary, always-on signal an editor shows the
114
+ // instant a regular Block's act() calls a navigation method; this command
115
+ // sweeps a whole project in one shot for contexts with no editor watching
116
+ // (CI, an autonomous agent writing Block files without a language server).
117
+ // See openspec/specs/nav-block-and-check/spec.md for the full rationale.
118
+ // ---------------------------------------------------------------------------
119
+ export function discoverBlocks(projectDir) {
120
+ return walkDir(projectDir, /\.block\.ts$/);
121
+ }
122
+ export function isBlockLike(val) {
123
+ if (val === null || typeof val !== "object")
124
+ return false;
125
+ const obj = val;
126
+ if (typeof obj.name !== "string")
127
+ return false;
128
+ const instruction = obj.instruction;
129
+ return instruction !== null && typeof instruction === "object" && typeof instruction?.act === "function";
130
+ }
131
+ /** Set by `defineNavBlock` (non-enumerable) - see src/engine.ts. */
132
+ export function isNavBlockMarked(val) {
133
+ return val.__waygraphKind === "nav";
134
+ }
135
+ export const NAV_METHOD_CALLS = ["page.goto(", "page.reload(", "page.goBack(", "page.goForward("];
136
+ /**
137
+ * Matches a selector-taking Trait factory call whose first argument is a
138
+ * literal string/template, not an identifier or property access - the exact
139
+ * shape found repeatedly in hand-written assertion Blocks
140
+ * (`Trait.visible("#some-id")` instead of `Trait.visible(SomeSel.thing)`).
141
+ * `Trait.url(...)` is deliberately excluded - it takes a URLPatternInit, never
142
+ * a DOM selector. Same file-scoped-regex bluntness the nav-escape sweep above
143
+ * already accepts (see openspec/specs/nav-block-and-check/spec.md) - a known
144
+ * blind spot on string concatenation/template-built selectors, not solved
145
+ * here for the same "recipe before promotion" reason that check accepts its
146
+ * own shared-helper blind spot.
147
+ */
148
+ export const INLINE_SELECTOR_CALL = /\b(?:Trait\.visible|Trait\.text|textEquals|visible)\(\s*["'`]/;
@@ -0,0 +1,91 @@
1
+ interface RunFlags {
2
+ step?: boolean;
3
+ autoplay?: boolean;
4
+ /** demo only: --auto-next + --video (+ step). */
5
+ autoPlayVideo?: boolean;
6
+ /** run/demo: show browser (WAYGRAPH_HEADED=1). */
7
+ nonHeadless?: boolean;
8
+ baseUrl?: string;
9
+ title?: string;
10
+ /** Set when --video present; empty string = default dir under project. */
11
+ video?: string;
12
+ /** Recording viewport, e.g. 1920x1080 (--video-viewport). */
13
+ videoViewport?: string;
14
+ /** Global Mem seed JSON (--data). */
15
+ data?: string;
16
+ /** Fill any requires key with no --data coverage from registerMemStub's registry (--mem-stub). */
17
+ memStub?: boolean;
18
+ /** Flow/chain spec from --blocks <spec>. */
19
+ blocks?: string;
20
+ /** auto path-find: --blocks <fromCheckpoint> <toCheckpoint>. */
21
+ blocksFromTo?: [string, string];
22
+ cli?: boolean;
23
+ /** auto --cli --detach: run the explore session as a background socket server. */
24
+ detach?: boolean;
25
+ /** Force headed panel (compat; bare try auto / auto already headed). */
26
+ headed?: boolean;
27
+ mermaid?: boolean;
28
+ map?: boolean;
29
+ /** demo: faster transitions / shorter auto-next gates. */
30
+ fast?: boolean;
31
+ /** demo: classic wrap-all block chips instead of carousel. */
32
+ fullStepper?: boolean;
33
+ /** demo: force compact mini panel (--mini / WAYGRAPH_MINI=1). */
34
+ miniStepper?: boolean;
35
+ /** demo: floating todo dock side (--todo-left | --todo-right). */
36
+ todoPos?: "left" | "right";
37
+ /** demo: todo-dock UX — full list / no smart behaviors. */
38
+ todoUiFull?: boolean;
39
+ /** demo: todo-dock UX — smart compact/collision/behind (default). */
40
+ todoUiSmart?: boolean;
41
+ /** demo/run: expand fastForwardComposeBlock inners as separate steps. */
42
+ ffExpand?: boolean;
43
+ /** demo/run: dispute mode — expand FF + keep blitz on former FF inners. */
44
+ ffDisabled?: boolean;
45
+ /** Positional args with run flags stripped. */
46
+ positionals: string[];
47
+ /** browser/pilot: merge Block trees from preset names or paths (repeatable). */
48
+ inject?: string[];
49
+ /** browser/pilot: navigate on start (disables blank page). */
50
+ goto?: string;
51
+ /** browser/pilot: force about:blank on start. */
52
+ blank?: boolean;
53
+ /** browser/pilot: headless session (default visible for browser). */
54
+ headlessBrowser?: boolean;
55
+ /** browser/pilot sessions: machine-readable JSON. */
56
+ json?: boolean;
57
+ /** check/typecheck: skip bad-practice warnings. */
58
+ noPractices?: boolean;
59
+ }
60
+ /**
61
+ * Pulls run/demo/auto flags out of argv. Unknown bare `--*` that are not
62
+ * recognized stay as positionals only when they are project paths; known
63
+ * explore flags (--cli/--mermaid/--map) are parsed here.
64
+ */
65
+ export declare function parseRunFlags(argv: string[]): RunFlags;
66
+ /** Writes flag values into process.env so the chain child inherits them. Flags beat prior env. */
67
+ export declare function applyRunFlags(flags: RunFlags, opts?: {
68
+ allowAutoPlayVideo?: boolean;
69
+ allowDemoUi?: boolean;
70
+ }): void;
71
+ /**
72
+ * BASE_URL when neither --base-url nor WAYGRAPH_BASE_URL is set:
73
+ * package.json `waygraph.baseUrl` (or `baseURL`), then playwright.config `baseURL`.
74
+ */
75
+ export declare function resolveBaseUrl(projectDir: string): string | undefined;
76
+ /**
77
+ * Friendly demo defaults: STEP on; headed only for live watch (no --video).
78
+ * --video / --auto-play-video => headless unless --non-headless.
79
+ * Call after applyRunFlags so explicit flags already won.
80
+ */
81
+ export declare function applyDemoDefaults(projectDir: string): void;
82
+ export declare function resolveProjectDir(flags: RunFlags, fallbackIndex?: number): string;
83
+ export declare function resolveSpec(flags: RunFlags): string | undefined;
84
+ /** `shop.flow.ts` / `src/flows/cart-bulk.flow.ts` / absolute path — not a Checkpoint or export id. */
85
+ export declare function looksLikeFlowFileRef(ref: string): boolean;
86
+ /**
87
+ * Expand `.flow.ts` path segments in a run/demo spec to export names.
88
+ * `src/flows/shop.flow.ts` → `shopFlow`; leaves `loginFlow then nav-cart` alone.
89
+ */
90
+ export declare function expandSpecFlowFiles(projectDir: string, spec: string): Promise<string>;
91
+ export {};