@docsxai/engine 0.3.0-rc.2 → 0.3.0-rc.5

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 (181) hide show
  1. package/README.md +45 -35
  2. package/dist/atomic-write.d.ts +19 -0
  3. package/dist/atomic-write.js +127 -0
  4. package/dist/auth/api-login.d.ts +9 -51
  5. package/dist/auth/api-login.js +3 -3
  6. package/dist/auth/browser-session.js +1 -1
  7. package/dist/auth/cookie-jar.d.ts +4 -4
  8. package/dist/auth/cookie-jar.js +4 -4
  9. package/dist/auth/email-otp.d.ts +11 -147
  10. package/dist/auth/email-otp.js +4 -4
  11. package/dist/auth/http-basic.js +1 -1
  12. package/dist/auth/index.js +3 -3
  13. package/dist/auth/jwt-injection.d.ts +7 -131
  14. package/dist/auth/jwt-injection.js +5 -5
  15. package/dist/auth/manual-capture.d.ts +3 -3
  16. package/dist/auth/manual-capture.js +2 -2
  17. package/dist/auth/mtls.d.ts +1 -6
  18. package/dist/auth/mtls.js +1 -1
  19. package/dist/auth/pat-header.d.ts +1 -9
  20. package/dist/auth/pat-header.js +1 -1
  21. package/dist/auth/storage-state-cache.d.ts +16 -6
  22. package/dist/auth/storage-state-cache.js +65 -15
  23. package/dist/auth/test-backdoor.d.ts +2 -13
  24. package/dist/auth/test-backdoor.js +3 -3
  25. package/dist/auth/totp.d.ts +1 -1
  26. package/dist/auth/totp.js +4 -4
  27. package/dist/auth/types.d.ts +3 -3
  28. package/dist/auth/types.js +4 -4
  29. package/dist/auth/ui-form.d.ts +24 -153
  30. package/dist/auth/ui-form.js +3 -3
  31. package/dist/auth/webauthn.d.ts +7 -67
  32. package/dist/auth/webauthn.js +3 -3
  33. package/dist/auth.js +1 -1
  34. package/dist/backend-client-contracts.d.ts +1 -1
  35. package/dist/backend-client-contracts.js +2 -2
  36. package/dist/backend-client-oauth-login.js +1 -1
  37. package/dist/backend-client-state-cache.d.ts +2 -2
  38. package/dist/backend-client-state-cache.js +8 -8
  39. package/dist/backend-client-token.js +5 -5
  40. package/dist/backend-client-transport.d.ts +2 -2
  41. package/dist/backend-client-transport.js +3 -3
  42. package/dist/backend-client.js +6 -6
  43. package/dist/browser-build.d.ts +6 -0
  44. package/dist/browser-build.js +12 -0
  45. package/dist/browser-launch-error.d.ts +18 -0
  46. package/dist/browser-launch-error.js +63 -0
  47. package/dist/browser-wait.d.ts +7 -0
  48. package/dist/browser-wait.js +12 -0
  49. package/dist/calibrate.d.ts +6 -2
  50. package/dist/calibrate.js +20 -13
  51. package/dist/cli-backend-errors.d.ts +5 -0
  52. package/dist/cli-backend-errors.js +28 -6
  53. package/dist/cli-commands-auth.d.ts +1 -0
  54. package/dist/cli-commands-auth.js +114 -0
  55. package/dist/cli-commands-authoring.d.ts +0 -1
  56. package/dist/cli-commands-authoring.js +124 -101
  57. package/dist/cli-commands-backend.d.ts +1 -1
  58. package/dist/cli-commands-backend.js +76 -21
  59. package/dist/cli-commands-docpack.d.ts +3 -1
  60. package/dist/cli-commands-docpack.js +145 -39
  61. package/dist/cli-commands-init.d.ts +1 -0
  62. package/dist/cli-commands-init.js +100 -0
  63. package/dist/cli-commands-pack.d.ts +1 -1
  64. package/dist/cli-commands-pack.js +6 -4
  65. package/dist/cli-commands-session.d.ts +1 -3
  66. package/dist/cli-commands-session.js +109 -180
  67. package/dist/cli-commands-site.d.ts +2 -0
  68. package/dist/cli-commands-site.js +77 -0
  69. package/dist/cli-commands-style.d.ts +1 -0
  70. package/dist/cli-commands-style.js +85 -0
  71. package/dist/cli-flags.d.ts +18 -0
  72. package/dist/cli-flags.js +77 -0
  73. package/dist/cli-help.d.ts +30 -0
  74. package/dist/cli-help.js +174 -0
  75. package/dist/cli-messages.d.ts +35 -0
  76. package/dist/cli-messages.js +104 -0
  77. package/dist/cli-node-guard.d.ts +1 -0
  78. package/dist/cli-node-guard.js +8 -0
  79. package/dist/cli-retired.js +6 -0
  80. package/dist/cli-run-stale.d.ts +2 -0
  81. package/dist/cli-run-stale.js +13 -0
  82. package/dist/cli-run-summary.js +7 -3
  83. package/dist/cli-shared.d.ts +30 -1
  84. package/dist/cli-shared.js +112 -12
  85. package/dist/cli-unexpected.d.ts +16 -0
  86. package/dist/cli-unexpected.js +76 -0
  87. package/dist/cli-usage.d.ts +1 -1
  88. package/dist/cli-usage.js +116 -66
  89. package/dist/cli-value-flags.d.ts +8 -0
  90. package/dist/cli-value-flags.js +34 -0
  91. package/dist/cli-version.d.ts +6 -0
  92. package/dist/cli-version.js +25 -0
  93. package/dist/cli.d.ts +3 -0
  94. package/dist/cli.js +46 -20
  95. package/dist/deprecation.d.ts +2 -0
  96. package/dist/deprecation.js +2 -0
  97. package/dist/device-scale-factor.d.ts +14 -0
  98. package/dist/device-scale-factor.js +38 -0
  99. package/dist/diagnose.js +14 -13
  100. package/dist/diff-compute.js +22 -8
  101. package/dist/diff-report.js +3 -3
  102. package/dist/diff-types.js +1 -1
  103. package/dist/diff.js +3 -3
  104. package/dist/doc-pack-io.js +62 -47
  105. package/dist/doc-pack.d.ts +567 -3487
  106. package/dist/doc-pack.js +47 -33
  107. package/dist/doctor-checks-config.d.ts +12 -0
  108. package/dist/doctor-checks-config.js +229 -0
  109. package/dist/doctor-checks-plugins.js +2 -2
  110. package/dist/doctor-checks-site.d.ts +3 -0
  111. package/dist/doctor-checks-site.js +21 -0
  112. package/dist/doctor-checks.d.ts +13 -2
  113. package/dist/doctor-checks.js +95 -79
  114. package/dist/doctor-next.d.ts +5 -0
  115. package/dist/doctor-next.js +52 -0
  116. package/dist/doctor.d.ts +36 -2
  117. package/dist/doctor.js +88 -29
  118. package/dist/environment-spec.d.ts +36 -44
  119. package/dist/environment-spec.js +31 -3
  120. package/dist/export/adf.d.ts +1 -1
  121. package/dist/export/adf.js +16 -27
  122. package/dist/export/playwright-test.d.ts +1 -1
  123. package/dist/export/playwright-test.js +13 -15
  124. package/dist/flow-file.d.ts +1 -1
  125. package/dist/flow-file.js +22 -4
  126. package/dist/flow-halt.d.ts +1 -1
  127. package/dist/flow-halt.js +15 -3
  128. package/dist/flow-lint.d.ts +3 -1
  129. package/dist/flow-lint.js +39 -26
  130. package/dist/flow-matrix-lint.js +2 -2
  131. package/dist/flow-runtime.d.ts +17 -6
  132. package/dist/flow-runtime.js +48 -17
  133. package/dist/flow-success.js +4 -4
  134. package/dist/flow-tree.js +2 -2
  135. package/dist/index.d.ts +2 -0
  136. package/dist/index.js +2 -0
  137. package/dist/main-module.d.ts +1 -0
  138. package/dist/main-module.js +17 -0
  139. package/dist/matrix-spec.d.ts +33 -106
  140. package/dist/matrix-spec.js +12 -3
  141. package/dist/node-floor.d.ts +4 -0
  142. package/dist/node-floor.js +14 -0
  143. package/dist/obstacles.js +1 -1
  144. package/dist/open-in-browser.d.ts +22 -0
  145. package/dist/open-in-browser.js +37 -0
  146. package/dist/playwright-driver.d.ts +8 -12
  147. package/dist/playwright-driver.js +75 -70
  148. package/dist/playwright-instrumented-browser.d.ts +10 -7
  149. package/dist/playwright-instrumented-browser.js +35 -12
  150. package/dist/plugins/load.d.ts +1 -1
  151. package/dist/plugins/load.js +4 -4
  152. package/dist/plugins/lock.js +11 -8
  153. package/dist/plugins/manifest.d.ts +16 -35
  154. package/dist/plugins/manifest.js +5 -5
  155. package/dist/plugins/plan.d.ts +3 -3
  156. package/dist/plugins/plan.js +14 -14
  157. package/dist/plugins/registry.d.ts +1 -1
  158. package/dist/plugins/registry.js +1 -1
  159. package/dist/plugins/runtime.js +3 -3
  160. package/dist/plugins/types.d.ts +1 -1
  161. package/dist/plugins-cli.js +36 -28
  162. package/dist/posix-path.d.ts +2 -0
  163. package/dist/posix-path.js +7 -0
  164. package/dist/redact.js +2 -2
  165. package/dist/run-flows.d.ts +7 -0
  166. package/dist/run-flows.js +75 -27
  167. package/dist/style.d.ts +2 -2
  168. package/dist/style.js +13 -11
  169. package/dist/verify-determinism.js +2 -1
  170. package/dist/verify-next-step.d.ts +2 -0
  171. package/dist/verify-next-step.js +24 -0
  172. package/dist/verify-report.js +3 -2
  173. package/dist/viewer-bin.d.ts +9 -3
  174. package/dist/viewer-bin.js +35 -12
  175. package/dist/workspace-templates.d.ts +15 -0
  176. package/dist/workspace-templates.js +88 -0
  177. package/dist/workspace.d.ts +78 -5
  178. package/dist/workspace.js +47 -28
  179. package/dist/zip.d.ts +1 -1
  180. package/dist/zip.js +23 -6
  181. package/package.json +6 -6
@@ -1,31 +1,133 @@
1
- // Shared CLI leaf — the helpers more than one command cluster reaches for. Kept dependency-free of
1
+ // Shared CLI leaf, the helpers more than one command cluster reaches for. Kept dependency-free of
2
2
  // the command clusters (and of cli.ts) so it can be imported anywhere without a cycle: the clusters
3
3
  // import from here; this file imports only from the engine's lower-level modules.
4
- // • parseFlags — the argv → { positionals, flags } parser every command opens with
5
- // • listFlowFiles — enumerate the workspace's flows/*.flow.yaml (run / lint / flow-tree)
4
+ // • parseFlags: the argv → { positionals, flags } parser every command opens with
5
+ // • claimFlowName: reject two flow files that declare one `name:`
6
+ // • listFlowFiles: enumerate the workspace's flows/*.flow.yaml (run / lint / flow-tree)
6
7
  import { promises as fs } from "node:fs";
7
- import { resolveWorkspacePath } from "./workspace.js";
8
- export function parseFlags(args) {
8
+ import * as path from "node:path";
9
+ import { shellQuote, usageError, withNext } from "./cli-messages.js";
10
+ import { resolveWorkspacePath, WORKSPACE_CONFIG_FILE } from "./workspace.js";
11
+ /**
12
+ * Split argv into positionals and `--flag [value]` / `--flag=value` pairs. A flag in `bool` never
13
+ * takes the next argument as its value. `repeated` lists the flags given more than once and
14
+ * `boolWithValue` the `bool` flags given as `--flag=value`; the caller turns either into a usage error.
15
+ */
16
+ export function parseFlags(args, bool = []) {
9
17
  const positionals = [];
10
18
  const flags = new Map();
19
+ const repeated = [];
20
+ const boolWithValue = [];
21
+ const set = (key, value) => {
22
+ if (flags.has(key) && !repeated.includes(key))
23
+ repeated.push(key);
24
+ flags.set(key, value);
25
+ };
11
26
  for (let i = 0; i < args.length; i++) {
12
27
  const a = args[i];
28
+ if (a === "--") {
29
+ positionals.push(...args.slice(i + 1));
30
+ break;
31
+ }
13
32
  if (a.startsWith("--")) {
33
+ const eq = a.indexOf("=");
34
+ if (eq > 2) {
35
+ const key = a.slice(2, eq);
36
+ if (bool.includes(key))
37
+ boolWithValue.push(key);
38
+ set(key, a.slice(eq + 1));
39
+ continue;
40
+ }
14
41
  const key = a.slice(2);
15
42
  const next = args[i + 1];
16
- if (next !== undefined && !next.startsWith("--")) {
17
- flags.set(key, next);
43
+ if (!bool.includes(key) && next !== undefined && !next.startsWith("--")) {
44
+ set(key, next);
18
45
  i++;
19
46
  }
20
47
  else {
21
- flags.set(key, true);
48
+ set(key, true);
22
49
  }
23
50
  }
24
51
  else {
25
52
  positionals.push(a);
26
53
  }
27
54
  }
28
- return { positionals, flags };
55
+ return { positionals, flags, repeated, boolWithValue };
56
+ }
57
+ /** True when `value` parses as an `http:` or `https:` URL. */
58
+ export function isHttpUrl(value) {
59
+ try {
60
+ const { protocol } = new URL(value);
61
+ return protocol === "http:" || protocol === "https:";
62
+ }
63
+ catch {
64
+ return false;
65
+ }
66
+ }
67
+ /** A URL `docsxai run` can open: http(s), or file: for a local static site. */
68
+ export function isRunnableUrl(value) {
69
+ try {
70
+ return new URL(value).protocol === "file:" || isHttpUrl(value);
71
+ }
72
+ catch {
73
+ return false;
74
+ }
75
+ }
76
+ /** The first of `names` given as a bare flag (`--flow` with nothing after it), or `undefined`. */
77
+ export function flagMissingValue(flags, names) {
78
+ return names.find((n) => flags.get(n) === true);
79
+ }
80
+ /**
81
+ * Exit code 2 (after the usage error) when any of `names` was given as a bare flag, else
82
+ * `undefined`. A value flag with nothing after it would otherwise fall back to its default.
83
+ */
84
+ export function bareValueFlagExit(label, flags, names) {
85
+ const bare = flagMissingValue(flags, names);
86
+ return bare ? usageError(label, `--${bare} needs a value`) : undefined;
87
+ }
88
+ /**
89
+ * Record that `file` declares the flow `name` in `owners`. Returns the error text when an earlier
90
+ * file already declared it: two files with one `name:` write to one `docs/<name>/` directory.
91
+ */
92
+ export function claimFlowName(owners, name, file) {
93
+ const first = owners.get(name);
94
+ if (first === undefined) {
95
+ owners.set(name, file);
96
+ return undefined;
97
+ }
98
+ return `flow name "${name}" is declared by both ${first} and ${file}; each flow needs its own name`;
99
+ }
100
+ /** Why `projectDir` has no flows/ to list, with the one command that fixes it. */
101
+ async function missingFlowsMessage(projectDir, flowsDir) {
102
+ const dir = shellQuote(projectDir);
103
+ let entries;
104
+ try {
105
+ entries = await fs.readdir(path.resolve(projectDir));
106
+ }
107
+ catch {
108
+ entries = undefined;
109
+ }
110
+ if (entries?.includes(WORKSPACE_CONFIG_FILE)) {
111
+ return withNext(`workspace ${projectDir} has no flows/ directory (expected ${flowsDir})`, `mkdir ${shellQuote(flowsDir)} (then docsxai add-flow ${dir} --from <flow.yaml>)`);
112
+ }
113
+ if (entries && entries.length > 0) {
114
+ return withNext(`${projectDir} is not a docsxai workspace (no ${WORKSPACE_CONFIG_FILE}, no flows/)`, "docsxai init <new-dir>, or pass the workspace directory");
115
+ }
116
+ return withNext(`workspace ${projectDir} has no flows/ directory (expected ${flowsDir}); it is not a docsxai workspace`, `docsxai init ${dir} (or fix the path; init needs a new or empty directory)`);
117
+ }
118
+ /**
119
+ * Why `projectDir` cannot be a workspace at all: it does not exist, or it is a file. `undefined` when
120
+ * it is a directory (an empty one included). Commands that write into the workspace call this first,
121
+ * so a mistyped path fails instead of creating the directory.
122
+ */
123
+ export async function workspaceDirProblem(projectDir) {
124
+ const stat = await fs.stat(path.resolve(projectDir)).catch(() => null);
125
+ if (stat?.isDirectory())
126
+ return undefined;
127
+ if (stat) {
128
+ return withNext(`${projectDir} is a file, not a workspace directory`, "docsxai init <new-dir>, or pass the workspace directory");
129
+ }
130
+ return withNext(`workspace doesn't exist: ${projectDir}`, `docsxai init ${shellQuote(projectDir)} (or fix the path)`);
29
131
  }
30
132
  export async function listFlowFiles(projectDir) {
31
133
  const dir = resolveWorkspacePath(projectDir, "flows");
@@ -34,9 +136,7 @@ export async function listFlowFiles(projectDir) {
34
136
  entries = await fs.readdir(dir);
35
137
  }
36
138
  catch {
37
- throw new Error(`workspace ${projectDir} has no flows/ directory (expected ${dir}). ` +
38
- `Is this a docsxai workspace? Create one with \`docsxai init <workspace-dir>\`, ` +
39
- `then add flows via \`docsxai calibrate\` or by writing flows/<name>.flow.yaml.`);
139
+ throw new Error(await missingFlowsMessage(projectDir, dir));
40
140
  }
41
141
  return entries
42
142
  .filter((e) => e.endsWith(".flow.yaml"))
@@ -0,0 +1,16 @@
1
+ /** True when `DOCSX_DEBUG` is `1`, `true` or `yes` (any case). */
2
+ export declare function debugEnabled(env?: NodeJS.ProcessEnv): boolean;
3
+ /** The stderr text for an error that reached the bin, with the stack only when `debug` is on. */
4
+ export declare function unexpectedErrorText(e: unknown, debug: boolean): string;
5
+ /** The line printed when the operator stops a command with Ctrl-C (or a SIGTERM), with the command to rerun. */
6
+ export declare function interruptedText(signal: string, argv: string[]): string;
7
+ /**
8
+ * Run `main` as the bin does: an error it throws becomes exit 1 and {@link unexpectedErrorText}, and
9
+ * Ctrl-C or SIGTERM prints {@link interruptedText} and ends the process with exit 130 or 143. While
10
+ * a viewer child runs, the signal goes to it and the process waits for it, then exits with the
11
+ * child's exit code, or the signal's when the child exited 0 after being told to stop. A child that
12
+ * has not ended `killAfterMs` later gets SIGKILL, and a second signal ends the process at once.
13
+ */
14
+ export declare function runAsBin(main: (argv: string[]) => Promise<number>, argv: string[], env?: NodeJS.ProcessEnv, opts?: {
15
+ killAfterMs?: number;
16
+ }): Promise<number>;
@@ -0,0 +1,76 @@
1
+ // The last line of defence for the `docsxai` bin: an error no command turned into a message is a
2
+ // bug. It prints one `docsxai:` line with the error's first line and how to get the stack, and the
3
+ // stack itself when DOCSX_DEBUG is set. URLs in the text are redacted. Commands keep their own
4
+ // error wording; this only sees what they rethrow.
5
+ import { describeFsError, redactUrlsIn, sanitizeForTerminal, shellQuote, withNext, } from "./cli-messages.js";
6
+ import { forwardSignalToViewer } from "./viewer-bin.js";
7
+ const ISSUES = "https://github.com/kalebteccom/docsxai/issues";
8
+ /** True when `DOCSX_DEBUG` is `1`, `true` or `yes` (any case). */
9
+ export function debugEnabled(env = process.env) {
10
+ return /^(1|true|yes)$/i.test(env.DOCSX_DEBUG ?? "");
11
+ }
12
+ /** The stderr text for an error that reached the bin, with the stack only when `debug` is on. */
13
+ export function unexpectedErrorText(e, debug) {
14
+ const raw = e instanceof Error ? e.message : String(e);
15
+ // A file the disk or its permissions refused is the operator's to fix, not a bug to report.
16
+ const fsLine = debug ? undefined : describeFsError(e);
17
+ if (fsLine)
18
+ return `docsxai: ${fsLine}\n`;
19
+ const first = sanitizeForTerminal(redactUrlsIn(raw.split("\n")[0] ?? "")) || "(no message)";
20
+ if (debug) {
21
+ const stack = e instanceof Error && e.stack ? e.stack : raw;
22
+ return `docsxai: unexpected error: ${first}\n${sanitizeForTerminal(redactUrlsIn(stack), true)}\n next: report it at ${ISSUES} with the stack above\n`;
23
+ }
24
+ return `docsxai: ${withNext(`unexpected error: ${first}`, `rerun with DOCSX_DEBUG=1 for the stack trace, and report it at ${ISSUES}`)}\n`;
25
+ }
26
+ /** The line printed when the operator stops a command with Ctrl-C (or a SIGTERM), with the command to rerun. */
27
+ export function interruptedText(signal, argv) {
28
+ const rerun = `docsxai ${argv.map(shellQuote).join(" ")}`.trimEnd();
29
+ return `docsxai: ${withNext(`interrupted (${signal}); anything a finished step wrote stays on disk`, `${rerun} (the same command starts over)`)}\n`;
30
+ }
31
+ /** Milliseconds a viewer child gets to end after a signal before it is killed. */
32
+ const KILL_AFTER_MS = 10_000;
33
+ /**
34
+ * Run `main` as the bin does: an error it throws becomes exit 1 and {@link unexpectedErrorText}, and
35
+ * Ctrl-C or SIGTERM prints {@link interruptedText} and ends the process with exit 130 or 143. While
36
+ * a viewer child runs, the signal goes to it and the process waits for it, then exits with the
37
+ * child's exit code, or the signal's when the child exited 0 after being told to stop. A child that
38
+ * has not ended `killAfterMs` later gets SIGKILL, and a second signal ends the process at once.
39
+ */
40
+ export async function runAsBin(main, argv, env = process.env, opts = {}) {
41
+ const signals = { SIGINT: 130, SIGTERM: 143 };
42
+ let received;
43
+ let killTimer;
44
+ const handlers = Object.keys(signals).map((sig) => {
45
+ const handler = () => {
46
+ if (received) {
47
+ // The child is slow to stop and the operator asked again: stop waiting for it.
48
+ forwardSignalToViewer("SIGKILL");
49
+ process.exit(signals[sig]);
50
+ return;
51
+ }
52
+ received = sig;
53
+ process.stderr.write(interruptedText(sig, argv));
54
+ // A render, burn or pack child gets the signal and ends the run itself, so its writes finish.
55
+ if (!forwardSignalToViewer(sig))
56
+ process.exit(signals[sig]);
57
+ else
58
+ killTimer = setTimeout(() => forwardSignalToViewer("SIGKILL"), opts.killAfterMs ?? KILL_AFTER_MS);
59
+ };
60
+ process.on(sig, handler);
61
+ return [sig, handler];
62
+ });
63
+ try {
64
+ const code = await main(argv);
65
+ return received && code === 0 ? signals[received] : code;
66
+ }
67
+ catch (e) {
68
+ process.stderr.write(unexpectedErrorText(e, debugEnabled(env)));
69
+ return 1;
70
+ }
71
+ finally {
72
+ clearTimeout(killTimer);
73
+ for (const [sig, handler] of handlers)
74
+ process.off(sig, handler);
75
+ }
76
+ }
@@ -1 +1 @@
1
- export declare const USAGE = "docsxai \u2014 deterministic execution CLI\n\nUsage:\n docsxai init <workspace-dir> [--app-url <url>] [--auth manual-capture|none] [--role <name>] [--ttl <dur>]\n [--capture-trigger console|button] [--auth-cookie <name>] [--ignore-https-errors]\n [--persist tmp] [--force]\n docsxai calibrate <workspace-dir> --from <flow.md|.yaml> [--name <flow>]\n docsxai inspect <workspace-dir> [--url <url>] [--selector <css>] [--cdp <endpoint>] [--wait <ms>] [--wait-for <css>] [--headed] [--ignore-https-errors] [--role <role>]\n docsxai run <workspace-dir> [--flow <name>] [--base-url <url>] [--headed] [--ignore-https-errors] [--stop-after <step-id>] [--start-from <step-id>] [--variant <id>] [--cdp <endpoint>] [--pause] [--concurrency <N>]\n docsxai run <workspace-dir> --verify-determinism [--runs <2-5>] [--format json|md|text] [--flow <name>] [--base-url <url>] [--concurrency <N>]\n docsxai lint <workspace-dir> [--flow <name>] [--format text|json]\n docsxai flow-tree <workspace-dir> [--format text|json]\n docsxai diagnose <workspace-dir> --flow <name> --step <step-id> [--variant <id>] [--cdp <endpoint>] [--format text|json]\n docsxai doctor [<workspace-dir>]\n docsxai style <workspace-dir> [--check] [--format text|json]\n docsxai zip <workspace-dir> [--out <output.zip>] [--include-viewer]\n docsxai baseline <workspace-dir> [--out <dir>]\n docsxai diff <workspace-dir> [--against <dir>] [--format json|md|text] [--fail-on warn|fail]\n docsxai export adf <workspace-dir> [--flow <name>] [--mode single|page-tree] [--title <text>] [--out <dir>]\n docsxai export playwright <workspace-dir> [--flow <name>] [--out <dir>]\n docsxai plugins <list|info|sync> <workspace-dir> [<namespace>] [--format text|json]\n docsxai login --backend-url <url> [--oauth <workspace-dir>]\n docsxai push <workspace-dir> [--kind calibrate|run|edit] [--author <name>]\n docsxai pull <workspace-dir> [--rev <id>]\n docsxai render <workspace-dir>\n docsxai burn <workspace-dir> [--flow <name>] [--out <dir>] [--report <file>] [--no-connector-outline]\n docsxai pack <workspace-or-raw-dir> [--from-raw] [--out <dir>] [--public-prefix <path>] [--no-optimise] [--generated-for <text>]\n docsxai pack <workspace-or-raw-dir> --check --against <pack-dir> [--from-raw] [--threshold <pct>]\n docsxai capture-auth <workspace-dir> [--base-url <url>] [--role <role>] [--auth-cookie <name>] [--cdp <endpoint>] [--fresh] [--headless] [--ignore-https-errors]\n docsxai --help\n\nNotes:\n \u2022 A *workspace* (created by `init`) holds flows/<flow>.flow.yaml, docs/, auth/strategy.yaml, .auth/, .viewer/,\n and a .docsxai.json config. Put it OUTSIDE the app's source repo \u2014 docsxai documents a running app from\n outside and never writes into the app repo.\n \u2022 run / capture-auth read app_url + ignore_https_errors from .docsxai.json if you don't pass the flags.\n \u2022 run launches Chromium; if no browser binary is present, install one: npx playwright-core install chromium\n (source checkout: pnpm -C packages/engine exec playwright-core install chromium)\n \u2022 --ignore-https-errors accepts self-signed/invalid TLS (e.g. an app's local HTTPS dev cert)\n \u2022 run --stop-after <step-id> runs only a prefix of the flow (up to & incl. that step); --pause keeps the\n (headed) browser open at the last step run \u2014 so you can inspect the live state mid-flow when calibrating\n (pair with --flow <name>). For waiting on a slow backend op, give a step a wait_for of the form\n { selector: $x, timeout_ms: 180000 } \u2014 a per-step override of the default ~30s selector-wait timeout.\n For a page that settles late (web fonts swapping, images arriving), use wait_for: settled: it waits for\n fonts, the images in view and the layout of what's on screen to stop changing, within the step's\n timeout_ms (default 10s), and halts with the cause if the page never settles.\n \u2022 run --concurrency <N> runs up to N flows in parallel (each its own Chromium session, isolated; default 1).\n Useful when several flows share a long preamble \u2014 total wall time = max(per-flow), not sum. Force-clamped\n to 1 when --pause / --stop-after / --start-from / --cdp is set. The target app must tolerate multiple sessions from one user.\n \u2022 run --start-from <step-id> --flow <name> SKIPS every step before <step-id> and starts execution there \u2014\n the inverse of --stop-after. Pair with --cdp to attach to a Chrome that's already in the post-prior-steps\n state (e.g. left over from a paused previous run) and iterate on the new tail step in seconds rather\n than re-walking the whole extends chain. New annotations MERGE into the existing annotations.json by\n step id; the prior steps' annotations and screenshots are preserved.\n \u2022 A flow with a top-level `matrix:` (locales, color_schemes, viewports) expands into one variant per\n combination. run gives each variant its own Chromium session and writes docs/<flow>/<variant>/\n {screenshots/, annotations.json, halts/} (variant id: <locale>.<scheme>.<viewport>, axes the matrix\n leaves out are dropped). run --variant <id> runs one variant. lint lists the variants (R015), flow-tree\n prints them, diagnose --variant <id> picks one. --cdp cannot run a matrix flow.\n \u2022 run --cdp <endpoint> attaches to a running Chrome (start it with --remote-debugging-port=N) instead of\n launching one. docsxai won't close that Chrome. When --cdp is set, the cached storageState is NOT\n loaded into the context \u2014 the operator's Chrome owns its auth state. Useful with --start-from for the\n sub-3-sec iteration loop on long-async flows.\n \u2022 run --verify-determinism runs the selected flows N times (--runs, 2 to 5, default 2), each into its own\n root under <ws>/.docsxai-verify/run-<k>/, then byte-compares every artefact: annotations.json, screenshots,\n step markdown, locators, halt context. The workspace output is written only when every run agrees (run 1's\n files are copied in, the bytes a plain run writes); on any difference or halt it is left untouched. The run\n roots are removed at the end. The report goes to stdout (--format text|md|json, default text; progress goes to\n stderr) and names the first differing artefact by path with a cause: the JSON key path, the changed-pixel\n region of a PNG, the first differing line of text, or the sizes. Exit 0 identical, 1 differing or a flow\n halted, 2 bad flags. Not combinable with --pause / --stop-after / --start-from / --cdp.\n \u2022 capture-auth runs the role's auth strategy (MVP: manual-capture \u2014 a headed, instrumented browser the\n engineer logs into; window.__docsxai.capture() or an injected button snapshots the session) and caches\n it to <workspace-dir>/.auth/<role>.json for subsequent `run`s. It prints the captured cookie jar so you\n can identify the app's real auth/session cookie.\n \u2022 capture-auth keeps a persistent Chrome profile at <workspace>/.auth/chrome-profile/ (gitignored) \u2014 re-running\n it reuses the login (just trigger capture again). Use --fresh for a clean profile (forces a fresh login).\n \u2022 --cdp <endpoint> makes capture-auth *attach to an already-running Chrome* (start it with\n --remote-debugging-port=N --disable-web-security --user-data-dir=<dir>) instead of launching a fresh one \u2014\n use this to capture from the same Chrome the engineer is already logged into (and that Claude in Chrome is\n driving for discovery), so they don't log in twice. docsxai won't close that Chrome. (--cdp ignores --fresh.)\n \u2022 auth_cookie (set via `init --auth-cookie`, `capture-auth --auth-cookie`, or hand-edited into\n auth/strategy.yaml) names that cookie; when set, the cached session's expiry tracks *that* cookie's\n expiry rather than the `ttl` guess (an interactive SSO login leaves ephemeral IdP scratch cookies, so\n `min(cookie.expires)` \u2248 now \u2014 don't rely on it). If unset/unfound, `ttl` (or a 1h default) is used.\n \u2022 inspect opens the app in a headless (or --headed) browser *with the cached session loaded* and prints the\n page's [data-testid] elements (or, with --selector, matching elements' HTML) \u2014 for pinning locators when\n hand-authoring a flow-file (the captured session can't be replayed in a browser the agent's MCP controls\n because the auth cookie is usually httpOnly; inspect does the storageState\u2192Playwright bridge for you). On a\n slow SPA, settle before the snapshot with --wait <ms> (default 800) or --wait-for '<css>'. --cdp <endpoint>\n attaches to an already-running Chrome (e.g. the one from capture-auth --cdp) instead of launching one.\n --ignore-https-errors accepts a self-signed/invalid TLS certificate (also read from ignore_https_errors in .docsxai.json).\n \u2022 calibrate takes a *structured flow-guide* (a flow-file in YAML, or a .md with a yaml fenced block) and\n writes flows/<name>.flow.yaml + a default docs/style.yaml. Loose-prose descriptions / live element-picking\n need the host agent \u2014 that's the /docsxai:calibrate *skill* (see the plugin), which then refines/produces\n the flow-file; this CLI command covers only the deterministic structured-input case.\n \u2022 lint runs pure-static checks across the workspace's flow-files \u2014 no Playwright, no live page. Rules:\n R001 (deep extends chain), R002 (annotation anchored to a likely-unmounting click/navigate target \u2014\n suggest annotation.target override), R003 (wait_for with no timeout_ms on a long-async-looking step),\n R004 (bare [data-*=\u2026] selector \u2014 may have hidden duplicates; suggest :visible / :has-text qualifier).\n Exit 1 if any warning/error; 0 otherwise. --format json emits machine-readable output for tooling.\n \u2022 flow-tree prints the workspace's extends graph (root flows + their descendants), plus any orphans\n (flows whose extends parent isn't in the workspace) and resolution issues (cycles / step-id collisions\n across the merge). Pure-static, ~no I/O beyond reading the flow files. Exit 1 if any issues.\n \u2022 diagnose gathers halt context for a specific step (the step's selector/wait_for/success, the halt\n screenshot if one exists, and \u2014 with --cdp \u2014 a live actionable() probe of the target on the running\n page) and prints recommendations (selector / wait_for / success / annotation_target / split_step /\n investigate). The engine never patches the flow-file itself \u2014 that's the agent's explicit opt-in\n action. --format json emits machine-readable output for an agent to act on. Pair with\n --start-from <step-id> --cdp on a follow-up run to validate the fix in seconds.\n \u2022 doctor health-checks the environment + workspace: Node >= 26, Chromium presence, .docsxai.json\n found + parseable (cwd or the arg), flow-file parses, auth descriptor + cached-session freshness,\n backend reachability (when backend_url is set), the plugin declarations (same inspection as\n `plugins list` \u2014 no plugin code is executed), viewer-bin resolution (which of the three layers\n hit), and DOCSX_* env sanity. \u2713/\u2717 rows with a one-line fix per failure; \u2212 rows are informational\n and never fail. Exit 1 if any \u2717.\n \u2022 style initialises docs/style.yaml + derived docs/style.json if absent (otherwise validates the\n existing YAML against the schema and rederives the JSON). --check additionally scans every\n docs/<flow>/<step>.md user-facing write-up for jargon leaks against the style's pruning_rules\n (e.g. VERIFY / WAIT / data-testid leaking into user-facing prose). The engine never re-shapes\n prose itself (LLM-agnostic) \u2014 the agent does that at calibration time; this command is the\n enforcement layer for the semantic-reshape exit criterion. --format json emits machine-readable\n output for tooling.\n \u2022 zip packages the workspace's doc pack into a single archive for hand-off. Includes flows/, docs/,\n .docsxai.json, auth/strategy.yaml (env-var names only, no creds), README.md. Excludes .auth/\n (operator-local session state), **/halts/ (debug screenshots), .viewer/ by default (re-renderable\n from the doc pack; pass --include-viewer to bundle it). Defaults output to <workspace-name>.zip\n in the current dir; override with --out <path>. Zips in-process (no system 'zip' binary needed)\n and deterministically \u2014 sorted entries, fixed mtime, fixed compression \u2014 so the same doc pack\n always produces a byte-identical archive.\n \u2022 baseline snapshots the doc pack \u2014 flows/, docs/<flow>/*.md, annotations.json, screenshots/, and\n docs/locators.yaml \u2014 into <ws>/.baseline/ (or --out <dir>). Commit the baseline: it's the \"before\"\n that diff compares against in CI.\n \u2022 diff compares the workspace against a baseline (default <ws>/.baseline/, or --against <dir>) and\n emits a deterministic drift report: per flow, step field deltas (id-keyed), annotation moves,\n screenshot pixel diffs (changed-pixel count / % / changed-region bbox; dimension changes flagged\n distinctly), prose line-change counts, and locator changes. --format md is PR-comment-ready.\n --fail-on warn|fail exits 1 when the report severity is at/above the threshold (screenshot\n severity: \u22651% changed pixels = warn, \u22655% = fail; structural changes = warn).\n \u2022 export playwright emits one self-contained Playwright .spec.ts per flow (extends resolved) into\n <ws>/.export/tests/ (or --out <dir>) \u2014 locators as consts, steps as page actions, success criteria\n as expect() assertions, environment as test.use(); optional steps are try/catch-wrapped. Generated\n files say so in a header: regenerate, don't hand-edit.\n \u2022 render builds the static viewer by spawning the docsxai-viewer bin, resolved in order: the\n DOCSX_VIEWER_BIN env var (path to the viewer's bin script), the @docsxai/viewer\n package installed next to the engine, then `docsxai-viewer` on PATH.\n \u2022 burn bakes each flow's annotations (halo, badge, callout) into copies of its clean screenshots, for\n surfaces that can't run the interactive viewer, via the same viewer bin as render. Reads\n <ws>/docs/<flow>/annotations.json and writes docs/<flow>/burned/<step>.png (or <out>/<flow>/<step>.png\n with --out). --flow limits it to named flows (repeatable); the default is every flow with annotations.\n --report <file> writes a JSON placement report (callout and badge boxes, overlaps, callouts flagged\n unplaceable), resolved under the workspace when relative. --no-connector-outline keeps every arrow and\n stem plain ink; by default one over a dark part of the screenshot gets a white outline.\n \u2022 pack builds the screenshot pack a docs site or README ships: it burns each step's annotations into its\n clean screenshot, optimises the PNG losslessly with the external `oxipng` binary (on PATH, or\n $DOCSX_OXIPNG_BIN; `brew install oxipng`; --no-optimise skips it), names it\n <flow>/<step>.<hash8>.png from the final bytes, and writes manifest.json (docsxai/screens-pack@2: flows,\n steps, localised alt, variants keyed <locale>.<theme>.<viewport> with src, size and callouts). <dir> is a\n workspace (docs/ plus a pack.json naming which capture flow feeds which variant, and the alt text) or,\n with --from-raw or no docs/, a raw capture directory (<flow>/<step>/<locale>.<theme>.<viewport>.png with a\n .json sidecar, step.json and flow.json). --out defaults to <workspace>/.screens and is required for a raw\n directory. Files the previous manifest listed and the new one does not are deleted by exact path; nothing\n else in --out is touched. Loopback and private-network addresses, emails, non-Bearer Authorization headers,\n URL-query tokens and obvious secrets in alt, caption, title or callout text stop the build. Runs the\n viewer's `pack` through the same bin resolution as render.\n \u2022 pack --check rebuilds the pack in memory (no oxipng, nothing written) and compares it with the committed pack\n in --against (required): equal hash is unchanged, otherwise a pixel diff gives changed %, the changed region and\n a pass or fail against --threshold (default 0.5). A resized, new or missing variant, or a committed file\n that does not match its name, always fails. Exit 1 on any failure, 2 on a bad argument. The report has no\n timestamps. The old `docsxai drift` still works for now: it prints a deprecation warning and runs pack --check.\n \u2022 login validates a bearer token against a backend URL \u2014 hits /v1/health, /v1/workspaces. Reads\n the token from DOCSX_TOKEN env var. Prints what the backend sees if the call succeeds,\n or a clear error if not. Stateless: doesn't store anything; configure the env var in your shell.\n login --oauth <workspace-dir> instead signs in as a person: OAuth 2.1 authorization code + PKCE against\n the backend. It prints a URL to open in a browser and stores the tokens at\n <workspace-dir>/.auth/backend-token.json (mode 0600); push, pull and run read them from there.\n \u2022 push serialises the workspace's doc pack (flows + annotations + screenshots + style + locators)\n and POSTs it as a new revision against the backend named in .docsxai.json (backend_url +\n optionally backend_workspace_id / backend_project_id; created on first push if absent and\n persisted to the config). --kind defaults to \"calibrate\"; --author defaults to the OS user.\n \u2022 pull fetches a revision's artifacts back into the workspace files (default: HEAD). Useful for\n syncing with a different operator's edits or rolling back to a named revision.\n \u2022 A command that works on a workspace takes its directory as the first argument. Reports and data go to\n stdout; progress lines and warnings go to stderr where a command already splits them. Output has no\n colour. An error prints `<command>: what failed`, then `next: <command to run>` when there is one.\n Exit 0 success, 1 runtime failure, 2 usage error.\n \u2022 --format json (lint, flow-tree, diagnose, style, diff, plugins, run --verify-determinism) is the\n machine-readable output; the text formats are for people and may change.\n \u2022 run, calibrate, burn, pack, zip, baseline, push, pull and doctor end with one line,\n `<command>: <result> \u2026`, naming the counts and where the output went (run --verify-determinism\n ends with its report).\n\nExamples:\n docsxai init ~/docsxai/my-app --app-url https://app.example.com\n docsxai capture-auth ~/docsxai/my-app\n docsxai calibrate ~/docsxai/my-app --from login.flow.yaml\n docsxai run ~/docsxai/my-app --flow login\n docsxai run ~/docsxai/my-app --verify-determinism --runs 3 --format md\n docsxai lint ~/docsxai/my-app --format json\n docsxai render ~/docsxai/my-app\n docsxai burn ~/docsxai/my-app --flow login --out ~/docsxai/my-app/burned\n docsxai pack ~/docsxai/my-app --out ~/docsxai/my-app/.screens\n docsxai pack ~/docsxai/my-app --check --against ./public/screens\n docsxai baseline ~/docsxai/my-app\n docsxai diff ~/docsxai/my-app --fail-on warn\n docsxai doctor ~/docsxai/my-app\n docsxai push ~/docsxai/my-app --kind run";
1
+ export declare const USAGE = "docsxai: deterministic execution CLI\n\nUsage:\n docsxai init <workspace-dir> [--app-url <url>] [--auth manual-capture|none] [--role <role>]\n [--ttl <dur>] [--capture-trigger console|button] [--auth-cookie <name>]\n [--ignore-https-errors] [--persist tmp] [--force] [--example]\n docsxai add-flow <workspace-dir> --from <flow.md|.yaml> [--name <flow>]\n docsxai inspect <workspace-dir> [--url <url>] [--selector <css>] [--cdp <endpoint>]\n [--wait <ms>] [--wait-for <css>] [--headed] [--ignore-https-errors] [--role <role>]\n docsxai run <workspace-dir> [--flow <name>] [--base-url <url>] [--headed]\n [--ignore-https-errors] [--stop-after <step-id>] [--start-from <step-id>]\n [--variant <id>] [--cdp <endpoint>] [--pause] [--concurrency <N>]\n [--device-scale-factor <1-4>]\n docsxai run <workspace-dir> --verify-determinism [--runs <2-5>] [--format text|md|json]\n [--flow <name>] [--base-url <url>] [--concurrency <N>]\n docsxai lint <workspace-dir> [--flow <name>] [--format text|json]\n docsxai flow-tree <workspace-dir> [--format text|json]\n docsxai diagnose <workspace-dir> --flow <name> --step <step-id> [--variant <id>]\n [--cdp <endpoint>] [--format text|json]\n docsxai doctor [<workspace-dir>] [--offline] [--format text|json]\n docsxai style <workspace-dir> [--check] [--format text|json]\n docsxai zip <workspace-dir> [--out <output.zip>] [--include-viewer]\n docsxai baseline <workspace-dir> [--out <dir>]\n docsxai diff <workspace-dir> [--against <dir>] [--format text|md|json] [--fail-on warn|fail]\n docsxai export adf <workspace-dir> [--flow <name>] [--mode single|page-tree]\n [--title <text>] [--out <dir>]\n docsxai export playwright <workspace-dir> [--flow <name>] [--out <dir>]\n docsxai plugins <list|info|sync> <workspace-dir> [<namespace>] [--format text|json]\n docsxai login --backend-url <url> [--oauth <workspace-dir>]\n docsxai push <workspace-dir> [--kind calibrate|run|edit] [--author <name>]\n docsxai pull <workspace-dir> [--rev <id>]\n docsxai render <workspace-dir> [--lang <locale>] [--open]\n docsxai burn <workspace-dir> [--flow <name>] [--out <dir>] [--report <file>]\n [--no-connector-outline] [--strict-glyphs]\n docsxai site <workspace-dir> [--out <dir>] [--build] [--title <text>] [--accent <hex>]\n [--lang <locale>] [--flow <name>]\n docsxai pack <workspace-or-raw-dir> [--from-raw] [--out <dir>] [--public-prefix <path>]\n [--no-optimise] [--generated-for <text>]\n docsxai pack <workspace-or-raw-dir> --check --against <pack-dir> [--from-raw]\n [--threshold <pct>]\n docsxai capture-auth <workspace-dir> [--base-url <url>] [--role <role>] [--auth-cookie <name>]\n [--cdp <endpoint>] [--fresh] [--headless] [--ignore-https-errors]\n docsxai --help\n docsxai --version\n\nNotes:\n \u2022 A *workspace* (created by `init`) holds flows/<flow>.flow.yaml, docs/, auth/strategy.yaml, .auth/, .viewer/,\n and a .docsxai.json config. Put it OUTSIDE the app's source repo, docsxai documents a running app from\n outside and never writes into the app repo.\n \u2022 init --example makes a workspace for https://example.com with no login and writes\n flows/hello.flow.yaml, so run and render --open are all that's left. It can't be combined with\n --app-url, --auth, --role, --ttl, --capture-trigger or --auth-cookie.\n \u2022 run / capture-auth read app_url + ignore_https_errors from .docsxai.json if you don't pass the flags.\n \u2022 run launches Chromium; if no browser binary is present, install one: npx playwright-core install chromium\n \u2022 --ignore-https-errors accepts self-signed/invalid TLS (e.g. an app's local HTTPS dev cert)\n \u2022 run --stop-after <step-id> runs only a prefix of the flow (up to & incl. that step); --pause keeps the\n (headed) browser open at the last step run, so you can inspect the live state mid-flow when calibrating\n (pair with --flow <name>). For waiting on a slow backend op, give a step a wait_for of the form\n { selector: $x, timeout_ms: 180000 }, a per-step override of the default ~30s selector-wait timeout.\n For a page that settles late (web fonts swapping, images arriving), use wait_for: settled: it waits for\n fonts, the images in view and the layout of what's on screen to stop changing, within the step's\n timeout_ms (default 10s), and halts with the cause if the page never settles.\n \u2022 run --concurrency <N> runs up to N flows in parallel (each its own Chromium session, isolated; default 1).\n Useful when several flows share a long preamble, total wall time = max(per-flow), not sum. Force-clamped\n to 1 when --pause / --stop-after / --start-from / --cdp is set. The target app must tolerate multiple sessions from one user.\n \u2022 run --device-scale-factor <1-4> captures at that many device pixels per CSS pixel (a whole number or one\n decimal, default 1): at 2 a 1280 by 800 viewport gives a 2560 by 1600 PNG. DOCSX_DEVICE_SCALE_FACTOR sets it\n when the flag is absent. annotations.json records device_scale_factor above 1; its boxes are in the PNG's\n own pixels, and burn reads the factor from it. Not combinable with --cdp (the attached browser owns its scale).\n \u2022 run --start-from <step-id> --flow <name> SKIPS every step before <step-id> and starts execution there,\n the inverse of --stop-after. Pair with --cdp to attach to a Chrome that's already in the post-prior-steps\n state (e.g. left over from a paused previous run) and iterate on the new tail step in seconds rather\n than re-walking the whole extends chain. New annotations MERGE into the existing annotations.json by\n step id; the prior steps' annotations and screenshots are preserved.\n \u2022 A flow with a top-level `matrix:` (locales, color_schemes, viewports) expands into one variant per\n combination. run gives each variant its own Chromium session and writes docs/<flow>/<variant>/\n {screenshots/, annotations.json, halts/} (variant id: <locale>.<scheme>.<viewport>, axes the matrix\n leaves out are dropped). run --variant <id> runs one variant. lint lists the variants (R015), flow-tree\n prints them, diagnose --variant <id> picks one. --cdp cannot run a matrix flow.\n \u2022 run --cdp <endpoint> attaches to a running Chrome (start it with --remote-debugging-port=N) instead of\n launching one. docsxai won't close that Chrome. When --cdp is set, the cached storageState is NOT\n loaded into the context, the attached Chrome keeps its own auth state. Useful with --start-from for a\n fast iteration loop on long-async flows.\n \u2022 run --verify-determinism runs the selected flows N times (--runs, 2 to 5, default 2), each into its own\n root under <ws>/.docsxai-verify/run-<k>/, then byte-compares every artefact: annotations.json, screenshots,\n step markdown, locators, halt context. The workspace output is written only when every run agrees (run 1's\n files are copied in, the bytes a plain run writes); on any difference or halt it is left untouched. The run\n roots are removed at the end. The report goes to stdout (--format text|md|json, default text; progress goes to\n stderr) and names the first differing artefact by path with a cause: the JSON key path, the changed-pixel\n region of a PNG, the first differing line of text, or the sizes. Exit 0 identical, 1 differing or a flow\n halted, 2 bad flags. Not combinable with --pause / --stop-after / --start-from / --cdp.\n \u2022 capture-auth runs the role's auth strategy (manual-capture: a headed, instrumented browser you log\n into; window.__docsxai.capture() or an injected button snapshots the session) and caches\n it to <workspace-dir>/.auth/<role>.json for subsequent `run`s. It prints the captured cookie jar so you\n can identify the app's real auth/session cookie.\n \u2022 capture-auth keeps a persistent Chrome profile at <workspace>/.auth/chrome-profile/ (gitignored), re-running\n it reuses the login (just trigger capture again). Use --fresh for a clean profile (forces a fresh login).\n \u2022 --cdp <endpoint> makes capture-auth *attach to an already-running Chrome* (start it with\n --remote-debugging-port=N --disable-web-security --user-data-dir=<dir>) instead of launching a fresh one,\n use this to capture from the Chrome you are already logged into (and that a browser agent may be\n driving for discovery), so you don't log in twice. docsxai won't close that Chrome. (--cdp ignores --fresh.)\n \u2022 auth_cookie (set via `init --auth-cookie`, `capture-auth --auth-cookie`, or hand-edited into\n auth/strategy.yaml) names that cookie; when set, the cached session's expiry tracks *that* cookie's\n expiry and not the `ttl` guess (an interactive SSO login leaves ephemeral IdP scratch cookies, so\n `min(cookie.expires)` \u2248 now, don't rely on it). If unset/unfound, `ttl` (or a 1h default) is used.\n \u2022 inspect opens the app in a headless (or --headed) browser *with the cached session loaded* and prints the\n page's [data-testid] elements (or, with --selector, matching elements' HTML), for pinning locators when\n hand-authoring a flow-file (the captured session can't be replayed in a browser the agent's MCP controls\n because the auth cookie is usually httpOnly; inspect does the storageState\u2192Playwright bridge for you). On a\n slow SPA, settle before the snapshot with --wait <ms> (default 800) or --wait-for '<css>'. --cdp <endpoint>\n attaches to an already-running Chrome (e.g. the one from capture-auth --cdp) instead of launching one.\n --ignore-https-errors accepts a self-signed/invalid TLS certificate (also read from ignore_https_errors in .docsxai.json).\n \u2022 add-flow (calibrate is deprecated since 0.3.0 and removed in 0.5.0) takes a *structured flow-guide* (a flow-file in\n YAML, or a .md with a yaml fenced block) and writes flows/<name>.flow.yaml + a default docs/style.yaml.\n Loose-prose descriptions / live element-picking need the host agent, that's the /docsxai:add-flow *skill*\n (see the plugin), which then refines/produces the flow-file; this CLI command covers only the\n deterministic structured-input case.\n \u2022 lint runs pure-static checks across the workspace's flow-files, no Playwright, no live page. Rules:\n R001 (deep extends chain), R002 (annotation anchored to a likely-unmounting click/navigate target,\n suggest annotation.target override), R003 (wait_for with no timeout_ms on a long-async-looking step),\n R004 (bare [data-*=\u2026] selector, may have hidden duplicates; suggest :visible / :has-text qualifier).\n Exit 1 if any warning/error; 0 otherwise. --format json emits machine-readable output for tooling.\n \u2022 flow-tree prints the workspace's extends graph (root flows + their descendants), plus any orphans\n (flows whose extends parent isn't in the workspace) and resolution issues (cycles / step-id collisions\n across the merge). Pure-static, ~no I/O beyond reading the flow files. Exit 1 if any issues.\n \u2022 diagnose gathers halt context for a specific step (the step's selector/wait_for/success, the halt\n screenshot if one exists, and, with --cdp, a live actionable() probe of the target on the running\n page) and prints recommendations (selector / wait_for / success / annotation_target / split_step /\n investigate). The engine never patches the flow-file itself, that's the agent's explicit opt-in\n action. --format json emits machine-readable output for an agent to act on. Pair with\n --start-from <step-id> --cdp on a follow-up run to validate the fix in seconds.\n \u2022 doctor health-checks the environment + workspace: Node >= 26, Chromium presence (with the install\n command), .docsxai.json found + valid (fields, burn.theme shape), write access to the workspace and\n its output dirs, flow-file parses, auth descriptor + cached-session freshness, a short HEAD to\n app_url (--offline skips it), backend reachability and login state (when backend_url is set), the\n plugin declarations and lock (same inspection as `plugins list`, no plugin code is executed),\n where the viewer was found, and environment settings. The first line is the docsxai version; one\n `ok:` or `fail:` line per check follows, and the last line names the next command for the\n workspace's state (init --example, add-flow, run or render --open). --format json prints one\n document (schema docsxai/doctor@1). Exit 1 if any line is `fail:`.\n \u2022 style initialises docs/style.yaml + derived docs/style.json if absent (otherwise validates the\n existing YAML against the schema and rederives the JSON). --check additionally scans every\n docs/<flow>/<step>.md user-facing write-up for jargon leaks against the style's pruning_rules\n (e.g. VERIFY / WAIT / data-testid leaking into user-facing prose). The engine never re-shapes\n prose itself (LLM-agnostic), the agent does that at calibration time; this command is the\n enforcement layer for the semantic-reshape exit criterion. --format json emits machine-readable\n output for tooling.\n \u2022 zip packages the workspace's doc pack into a single archive for hand-off. Includes flows/, docs/,\n .docsxai.json, auth/strategy.yaml (env-var names only, no creds), README.md. Excludes .auth/\n (local session state), **/halts/ (debug screenshots), .viewer/ by default (re-renderable\n from the doc pack; pass --include-viewer to bundle it). Defaults output to <workspace-name>.zip\n in the current dir; override with --out <path>. Zips in-process (no system 'zip' binary needed)\n and deterministically, sorted entries, fixed mtime, fixed compression, so the same doc pack\n always produces a byte-identical archive.\n \u2022 baseline snapshots the doc pack, flows/, docs/<flow>/*.md, annotations.json, screenshots/, and\n docs/locators.yaml, into <ws>/.baseline/ (or --out <dir>). Commit the baseline: it's the \"before\"\n that diff compares against in CI.\n \u2022 diff compares the workspace against a baseline (default <ws>/.baseline/, or --against <dir>) and\n emits a deterministic drift report: per flow, step field deltas (id-keyed), annotation moves,\n screenshot pixel diffs (changed-pixel count / % / changed-region bbox; dimension changes flagged\n distinctly), prose line-change counts, and locator changes. --format md is PR-comment-ready.\n --fail-on warn|fail exits 1 when the report severity is at/above the threshold (screenshot\n severity: \u22651% changed pixels = warn, \u22655% = fail; structural changes = warn).\n \u2022 export playwright emits one self-contained Playwright .spec.ts per flow (extends resolved) into\n <ws>/.export/tests/ (or --out <dir>), locators as consts, steps as page actions, success criteria\n as expect() assertions, environment as test.use(); optional steps are try/catch-wrapped. Generated\n files say so in a header: regenerate, don't hand-edit.\n \u2022 render builds the static viewer by spawning the docsxai-viewer bin, resolved in order: the\n DOCSX_VIEWER_BIN env var (path to the viewer's bin script), the @docsxai/viewer\n package installed next to the engine, then `docsxai-viewer` on PATH. --lang sets the language of the\n text the viewer adds, e.g. es or es-ES (default en; a tag with no translation gives en). --open then\n opens .viewer/index.html in the default browser; where none can be opened it prints the path instead.\n \u2022 burn bakes each flow's annotations (halo, badge, callout) into copies of its clean screenshots, for\n surfaces that can't run the interactive viewer, via the same viewer bin as render. Reads\n <ws>/docs/<flow>/annotations.json and writes docs/<flow>/burned/<step>.png (or <out>/<flow>/<step>.png\n with --out). --flow limits it to named flows (repeatable); the default is every flow with annotations.\n --report <file> writes a JSON placement report (callout and badge boxes, overlaps, callouts flagged\n unplaceable), resolved under the workspace when relative. The workspace's burn.theme block (.docsxai.json)\n sets the look; see docs/burn-theming.md. --no-connector-outline skips reading the screenshot's pixels: an\n arrow or stem stays plain ink (by default one over a dark part gets a white outline), a themed line keeps\n the callout's outline colour, and no text is estimated from the pixels. A caption with characters the\n font can't draw (Japanese, Arabic, Hebrew, Thai with the bundled Inter) prints a warning naming the\n annotation and script and gets missing_glyphs in the report; --strict-glyphs makes it exit 1.\n \u2022 site writes an Astro Starlight docs site project from <ws>/docs and <ws>/flows into --out (default\n <ws>/site), preferring burned images. --build also runs the Astro build into <out>/dist. --title names\n the site (default \"Documentation\"), --accent sets the accent colour as a hex value, --lang sets the\n site's language (same rule as render), --flow limits it to named flows (repeatable). Runs the viewer's\n `site` through the same bin resolution as render; its exit code is the command's.\n \u2022 pack builds the screenshot pack a docs site or README ships: it burns each step's annotations into its\n clean screenshot, optimises the PNG losslessly with the external `oxipng` binary (on PATH, or\n $DOCSX_OXIPNG_BIN; `brew install oxipng`; --no-optimise skips it), names it\n <flow>/<step>.<hash8>.png from the final bytes, and writes manifest.json (docsxai/screens-pack@2: flows,\n steps, localised alt, variants keyed <locale>.<theme>.<viewport> with src, size and callouts). <dir> is a\n workspace (docs/ plus a pack.json naming which capture flow feeds which variant, and the alt text) or,\n with --from-raw or no docs/, a raw capture directory (<flow>/<step>/<locale>.<theme>.<viewport>.png with a\n .json sidecar, step.json and flow.json). --out defaults to <workspace>/.screens and is required for a raw\n directory. Files the previous manifest listed and the new one does not are deleted by exact path; nothing\n else in --out is touched. Loopback and private-network addresses, emails, non-Bearer Authorization headers,\n URL-query tokens and obvious secrets in alt, caption, title or callout text stop the build. Runs the\n viewer's `pack` through the same bin resolution as render.\n \u2022 pack --check rebuilds the pack in memory (no oxipng, nothing written) and compares it with the committed pack\n in --against (required): equal hash is unchanged, otherwise a pixel diff gives changed %, the changed region and\n a pass or fail against --threshold (default 0.5). A resized, new or missing variant, or a committed file\n that does not match its name, always fails. Exit 1 on any failure, 2 on a bad argument. The report has no\n timestamps. The old `docsxai drift` still works for now: it prints a deprecation warning and runs pack --check.\n \u2022 login validates a bearer token against a backend URL, hits /v1/health, /v1/workspaces. Reads\n the token from DOCSX_TOKEN env var. Prints what the backend sees if the call succeeds,\n or a clear error if not. Stateless: doesn't store anything; configure the env var in your shell.\n login --oauth <workspace-dir> instead signs in as a person: OAuth 2.1 authorization code + PKCE against\n the backend. It prints a URL to open in a browser and stores the tokens at\n <workspace-dir>/.auth/backend-token.json (mode 0600); push, pull and run read them from there.\n \u2022 push serialises the workspace's doc pack (flows + annotations + screenshots + style + locators)\n and POSTs it as a new revision against the backend named in .docsxai.json (backend_url +\n optionally backend_workspace_id / backend_project_id; created on first push if absent and\n persisted to the config). --kind defaults to \"calibrate\"; --author defaults to the OS user.\n \u2022 pull fetches a revision's artifacts back into the workspace files (default: HEAD). Useful for\n syncing with someone else's edits or rolling back to a named revision.\n \u2022 A command that works on a workspace takes its directory as the first argument. Reports and data go to\n stdout; progress lines and warnings go to stderr where a command already splits them. Output has no\n colour. An error prints `<command>: what failed`, then `next: <command to run>` when there is one.\n Exit 0 success, 1 runtime failure, 2 usage error; Ctrl-C prints one line with the command to rerun and\n exits 130. An error no command handled is a bug: it prints one `docsxai: unexpected error` line; set\n DOCSX_DEBUG=1 to print its stack trace.\n \u2022 --version (or -v) prints `docsxai <version>` and exits 0.\n \u2022 --format json (lint, flow-tree, diagnose, style, diff, plugins, doctor, run --verify-determinism) is the\n machine-readable output; the text formats are for people and may change.\n \u2022 run, add-flow, burn, pack, zip, baseline, push, pull and doctor end with one line,\n `<command>: <result> \u2026`, naming the counts and where the output went (run --verify-determinism\n ends with its report).\n\nExamples:\n docsxai init ~/docsxai/my-app --app-url https://app.example.com\n docsxai capture-auth ~/docsxai/my-app\n docsxai add-flow ~/docsxai/my-app --from login.flow.yaml\n docsxai inspect ~/docsxai/my-app --url https://app.example.com/login\n docsxai run ~/docsxai/my-app --flow login\n docsxai run ~/docsxai/my-app --verify-determinism --runs 3 --format md\n docsxai lint ~/docsxai/my-app --format json\n docsxai flow-tree ~/docsxai/my-app\n docsxai diagnose ~/docsxai/my-app --flow login --step submit\n docsxai style ~/docsxai/my-app --check\n docsxai zip ~/docsxai/my-app --out my-app.zip\n docsxai export adf ~/docsxai/my-app --flow login --mode single\n docsxai export playwright ~/docsxai/my-app --out ./e2e\n docsxai plugins list ~/docsxai/my-app\n docsxai login --backend-url https://docsxai.example.com\n docsxai render ~/docsxai/my-app\n docsxai render ~/docsxai/my-app --lang es\n docsxai burn ~/docsxai/my-app --flow login --out ~/docsxai/my-app/burned\n docsxai site ~/docsxai/my-app --title \"Help centre\" --build\n docsxai pack ~/docsxai/my-app --out ~/docsxai/my-app/.screens\n docsxai pack ~/docsxai/my-app --check --against ./public/screens\n docsxai baseline ~/docsxai/my-app\n docsxai diff ~/docsxai/my-app --fail-on warn\n docsxai doctor ~/docsxai/my-app\n docsxai push ~/docsxai/my-app --kind run\n docsxai pull ~/docsxai/my-app --rev r12";