@docsxai/engine 0.3.0-rc.2 → 0.3.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/backend-client-token.js +2 -2
- package/dist/cli-backend-errors.js +4 -3
- package/dist/cli-commands-session.js +1 -1
- package/dist/cli-messages.d.ts +5 -0
- package/dist/cli-messages.js +7 -0
- package/dist/cli-unexpected.d.ts +6 -0
- package/dist/cli-unexpected.js +30 -0
- package/dist/cli-usage.d.ts +1 -1
- package/dist/cli-usage.js +5 -4
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +4 -1
- package/dist/doctor-checks.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ The engine **never** calls a model API. Calibration-time inference is supplied b
|
|
|
8
8
|
|
|
9
9
|
- **Flow-file** — declarative YAML at `<workspace>/flows/<name>.flow.yaml`: `prerequisites` + `locators` + `steps[]` (`action`, `target`, `wait_for`, `success`, `annotation` / `annotations`, per-step `redactions`, `timeout_ms`). Actions: `navigate`, `click`, `fill`, `upload`, `press`, `hover`, `select`, `check`, `uncheck`, `wait`, `hide`, `show`. Hand-editable; schema-validated. `extends:` composition for shared preambles (with `environment` merged per-key, child wins; `redactions` concatenated).
|
|
10
10
|
- **Execution environment** — optional `environment` block (`EnvironmentSpec`): frozen `clock` (Playwright clock API), `locale`, `timezone`, `viewport` (`VIEWPORT_PRESETS`: desktop / tablet / mobile, or explicit size), `color_scheme`, `reduced_motion`. Applied at context creation by `launchPlaywrightSession({ environment })`; on CDP-attached sessions only the clock applies (one stderr warning lists skipped fields). `contextOptions` passes `httpCredentials` / `clientCertificates` / `extraHTTPHeaders` through to `browser.newContext`.
|
|
11
|
-
- **Request guard (opt-in)** — `DOCSX_EGRESS_GUARD=1` (or `launchPlaywrightSession({ egressGuard })`) routes every request of the browser context through `egress-guard.ts`: a host that is, or resolves (`dns.lookup`, all addresses) to, a link-local or cloud-metadata address is aborted, redirect hops and WebSocket connections included, and a failed lookup aborts too (the printed reason is generic: `address not allowed`); `DOCSX_EGRESS_DENY_PRIVATE=1` adds loopback and private ranges. Both take `1`, `true` or `yes`. Off by default for a local `run`; the backend runner turns it on for webhook runs. It does not stop DNS rebinding (`SECURITY.md`). An `upload` step reads only regular files under the workspace (`upload-path.ts`). The address rules in `address-class.ts` are a byte-identical copy of the backend's.
|
|
11
|
+
- **Request guard (opt-in)** — `DOCSX_EGRESS_GUARD=1` (or `launchPlaywrightSession({ egressGuard })`) routes every request of the browser context through `egress-guard.ts`: a host that is, or resolves (`dns.lookup`, all addresses) to, a link-local or cloud-metadata address is aborted, redirect hops and WebSocket connections included, and a failed lookup aborts too (the printed reason is generic: `address not allowed`); `DOCSX_EGRESS_DENY_PRIVATE=1` adds loopback and private ranges. Both take `1`, `true` or `yes`. Off by default for a local `run`; the backend runner turns it on for webhook runs, and so does the MCP HTTP transport for the browser `run_flows` starts. It does not stop DNS rebinding (`SECURITY.md`). An `upload` step reads only regular files under the workspace (`upload-path.ts`). The address rules in `address-class.ts` are a byte-identical copy of the backend's.
|
|
12
12
|
- **Hiding + step timeouts** — `hide` sets `visibility: hidden !important` on every element its `target` matches until a `show` (no target lifts all, a target lifts the `hide` that used the same selector). `PlaywrightDriver` marks the elements with a data attribute and adopts a fixed stylesheet keyed on it (`page-hide.ts`, in-page and engine-owned; the selector is data, never CSS or script). The rule lives on each element's own root, so it reaches shadow trees, and constructable stylesheets are not blocked by a page's CSP. Visibility keeps the box, so nothing reflows; there is deliberately no `display: none` option and no general CSS-injection step. The driver keeps the selectors and re-marks before every screenshot (halt shots included), so the hiding survives navigations and re-renders. `hide` waits for the element to exist (`attached`) and throws when none does, so `optional: true` covers dev-only UI such as `nextjs-portal`. A step's `timeout_ms` (100–30000) is passed to the driver call (`click(selector, timeoutMs?)`, `hideElements(selector, timeoutMs?)`, …); unset, nothing is passed and Playwright's 30 s default applies, so existing flows and non-optional steps are unchanged. `optional` does not shorten the wait by itself, so a missing optional target costs 30 s unless `timeout_ms` is set; `lint` R011 says so. `BrowserDriver` gains `hideElements` / `showElements` (required). The pure `hiddenAtEachStep` (`flow-hidden.ts`) tells `lint` (R013) and `diagnose` which selectors an earlier `hide` hid.
|
|
13
13
|
- **Redactions** — flow-level + per-step `RedactionSpec[]` (`{ selector }` or `{ region }`, style `box` | `pixelate`) masked deterministically before any screenshot (halt shots included) hits disk. The pure pixel transform is `applyRedactions` in `redact.ts`.
|
|
14
14
|
- **`BrowserDriver`** interface — what the runtime needs from a browser. The `PlaywrightDriver` implementation includes the `actionable()` predicate (see [`docs/actionability-contract.md`](../../docs/actionability-contract.md)) that browser-bridge consumers can mirror, plus a real `element_stable` wait (bounding-box polling, 10 s best-effort budget). `waitForSettled?`, `hideElements?`, `showElements?` and `nearbyBoxes?` are **optional** methods (behind `wait_for: settled`, the `hide` and `show` actions and `annotations.obstacles`), so a driver written before they existed still compiles; the runtime halts a step that needs a missing method with a message naming it (`obstacles` only when the workspace turned it on), and never calls a method the flow does not use. `PlaywrightDriver` runs the fixed in-page poll in `page-settle.ts` (fonts loaded, visible images complete, viewport box geometry unchanged for two consecutive polls, every 50 ms, bounded by the step's `timeout_ms`, default 10 s) and rejects with `settled: page did not settle within N ms ...` naming what kept moving; `inferHaltCause` turns that into the `[page never settled: ...]` prefix.
|
|
@@ -53,7 +53,7 @@ A flow with a top-level `matrix:` (`locales`, `color_schemes`, `viewports`; at m
|
|
|
53
53
|
|
|
54
54
|
`baseline` + `diff` are the drift-detection pair. `baseline` snapshots `flows/` + `docs/` (step `.md`s, `annotations.json`, `screenshots/`, `locators.yaml`) into `<workspace>/.baseline/` (or `--out <dir>`); `diff` compares the live workspace against it (`diffDocPacks` on the library surface) and emits a deterministic `docsxai/drift@1` report — per flow: id-keyed step field deltas, annotation moves beyond a pixel tolerance, screenshot pixel diffs via pngjs (changed-pixel count / pct / changed-region bbox; dimension changes flagged distinctly; `ignore_regions` excluded), prose line-change counts, and locator changes. `--format md` (`formatDriftReportMarkdown`) is PR-comment-ready; `--fail-on warn|fail` exits 1 at/above the threshold (defaults: ≥1% changed pixels = warn, ≥5% = fail, structural change = warn). The engine detects and reports; proposing flow-file patches stays with the host agent (`diagnose`).
|
|
55
55
|
|
|
56
|
-
`run --verify-determinism [--runs <2-5>] [--format
|
|
56
|
+
`run --verify-determinism [--runs <2-5>] [--format text|md|json]` runs the selected flows N times (default 2) through the same flow loop as a plain `run` (`runFlowsInSessions`), each into its own output root under `<workspace>/.docsxai-verify/run-<k>/` (`PlaywrightSessionOptions.outputRoot` redirects the screenshots; `upload` sources still resolve against the workspace), then byte-compares every file under the roots (`compareRuns` in `verify-compare.ts`, exported). The first differing artefact is named by path with a cause: JSON key path, PNG changed-pixel count and region (the `diffPngBuffers` of `diff`), first differing text line, or sizes. A halt is recorded as `docs/<flow>/halts/halt-context.json` in the run root, so halt context is compared like any artefact; a halted flow makes the verdict `halted` (exit 1). Run 1's tree is copied into the workspace only when every run agrees and none halted; otherwise the workspace is untouched. The roots are removed by their listing (unlink each file, rmdir each directory deepest first; `verify-tree.ts`), never recursively. The `docsxai/verify-determinism@1` report has no timestamps or paths and is ordered by ordinal path then run: exit 0 identical, 1 differing or halted, 2 usage. Nightly recipes for GitHub Actions, GitLab CI and Woodpecker are in `docs/ci-recipes.md` and `examples/ci/`.
|
|
57
57
|
|
|
58
58
|
`export playwright` renders each flow (with `extends` resolved) as a self-contained Playwright `.spec.ts` (`exportFlowAsPlaywrightTest`) into `<workspace>/.export/tests/`: locator consts, steps as page actions, `wait_for` as waits, `success` as `expect()` assertions, `environment` as `test.use()` + `page.clock.setFixedTime`, `optional` steps in try/catch. Deterministic; generated files carry a "regenerate, don't hand-edit" header.
|
|
59
59
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// the resolution precedence (explicit → `DOCSX_TOKEN` → stored, with refresh-rotation), and the
|
|
3
3
|
// load/save helpers. Re-exported from `./backend-client.js`.
|
|
4
4
|
import { promises as fs } from "node:fs";
|
|
5
|
-
import { redactUrl, shellQuote } from "./cli-messages.js";
|
|
5
|
+
import { redactUrl, redactUrlsIn, shellQuote } from "./cli-messages.js";
|
|
6
6
|
import { resolveWorkspacePath, resolveWorkspacePathReal } from "./workspace.js";
|
|
7
7
|
import { BackendClientError } from "./backend-client-contracts.js";
|
|
8
8
|
const BACKEND_TOKEN_FILE = "backend-token.json";
|
|
@@ -83,7 +83,7 @@ export async function resolveBackendToken(opts) {
|
|
|
83
83
|
refreshed = (await res.json());
|
|
84
84
|
}
|
|
85
85
|
catch (e) {
|
|
86
|
-
throw new BackendClientError(`stored backend token expired and the refresh failed (${e.message}) — ${reloginHint}`);
|
|
86
|
+
throw new BackendClientError(`stored backend token expired and the refresh failed (${redactUrlsIn(e.message)}) — ${reloginHint}`);
|
|
87
87
|
}
|
|
88
88
|
const tokens = {
|
|
89
89
|
access_token: refreshed.access_token,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// of terminal control characters.
|
|
6
6
|
import { promises as fs } from "node:fs";
|
|
7
7
|
import { BackendClientError } from "./backend-client.js";
|
|
8
|
-
import { redactUrl, sanitizeForTerminal, shellQuote, withNext } from "./cli-messages.js";
|
|
8
|
+
import { redactUrl, redactUrlsIn, sanitizeForTerminal, shellQuote, withNext, } from "./cli-messages.js";
|
|
9
9
|
import { resolveWorkspacePath, WORKSPACE_CONFIG_FILE } from "./workspace.js";
|
|
10
10
|
/** The error code Node's fetch buries in `cause` (ECONNREFUSED, ENOTFOUND, ...), or the message when there is none. */
|
|
11
11
|
function networkReason(e) {
|
|
@@ -30,8 +30,9 @@ export function explainBackendFailure(e, backendUrl, workspaceDir) {
|
|
|
30
30
|
}
|
|
31
31
|
if (!(e instanceof BackendClientError))
|
|
32
32
|
return undefined;
|
|
33
|
-
// The message carries the start of the response body, which the backend controls
|
|
34
|
-
|
|
33
|
+
// The message carries the start of the response body, which the backend controls, and can
|
|
34
|
+
// quote a URL with its credentials or query.
|
|
35
|
+
const message = sanitizeForTerminal(redactUrlsIn(e.message));
|
|
35
36
|
if (e.status === 401 || e.status === 403) {
|
|
36
37
|
const oauth = workspaceDir
|
|
37
38
|
? ` (or add --oauth ${shellQuote(workspaceDir)} to sign in as a person)`
|
|
@@ -257,7 +257,7 @@ export async function cmdCaptureAuth(args) {
|
|
|
257
257
|
const ra = descriptor.roles[role];
|
|
258
258
|
if (!ra) {
|
|
259
259
|
const roles = Object.keys(descriptor.roles).join(", ");
|
|
260
|
-
process.stderr.write(`capture-auth: role "${role}" not in ${descriptorPath} (roles: ${roles}); pass --role <
|
|
260
|
+
process.stderr.write(`capture-auth: role "${role}" not in ${descriptorPath} (roles: ${roles}); pass --role <role>\n`);
|
|
261
261
|
return 1;
|
|
262
262
|
}
|
|
263
263
|
roleAuth = ra;
|
package/dist/cli-messages.d.ts
CHANGED
|
@@ -15,3 +15,8 @@ export declare function shellQuote(value: string): string;
|
|
|
15
15
|
export declare function withNext(message: string, next: string): string;
|
|
16
16
|
/** `raw` without user:password, query or fragment, for printing a URL the operator typed. */
|
|
17
17
|
export declare function redactUrl(raw: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* `text` with every absolute URL in it passed through {@link redactUrl}. Error messages from
|
|
20
|
+
* `fetch` and from a backend can quote the URL they were given, user:password and query included.
|
|
21
|
+
*/
|
|
22
|
+
export declare function redactUrlsIn(text: string): string;
|
package/dist/cli-messages.js
CHANGED
|
@@ -78,3 +78,10 @@ export function redactUrl(raw) {
|
|
|
78
78
|
return invalid;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* `text` with every absolute URL in it passed through {@link redactUrl}. Error messages from
|
|
83
|
+
* `fetch` and from a backend can quote the URL they were given, user:password and query included.
|
|
84
|
+
*/
|
|
85
|
+
export function redactUrlsIn(text) {
|
|
86
|
+
return text.replace(/\b[a-z][a-z0-9+.-]*:\/\/[^\s"'<>()`]+/gi, (url) => redactUrl(url));
|
|
87
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
/** Run `main` as the bin does: an error it throws becomes exit 1 and {@link unexpectedErrorText}. */
|
|
6
|
+
export declare function runAsBin(main: (argv: string[]) => Promise<number>, argv: string[], env?: NodeJS.ProcessEnv): Promise<number>;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { redactUrlsIn, sanitizeForTerminal, withNext } from "./cli-messages.js";
|
|
6
|
+
const ISSUES = "https://github.com/kalebteccom/docsxai/issues";
|
|
7
|
+
/** True when `DOCSX_DEBUG` is `1`, `true` or `yes` (any case). */
|
|
8
|
+
export function debugEnabled(env = process.env) {
|
|
9
|
+
return /^(1|true|yes)$/i.test(env.DOCSX_DEBUG ?? "");
|
|
10
|
+
}
|
|
11
|
+
/** The stderr text for an error that reached the bin, with the stack only when `debug` is on. */
|
|
12
|
+
export function unexpectedErrorText(e, debug) {
|
|
13
|
+
const raw = e instanceof Error ? e.message : String(e);
|
|
14
|
+
const first = sanitizeForTerminal(redactUrlsIn(raw.split("\n")[0] ?? "")) || "(no message)";
|
|
15
|
+
if (debug) {
|
|
16
|
+
const stack = e instanceof Error && e.stack ? e.stack : raw;
|
|
17
|
+
return `docsxai: unexpected error: ${first}\n${sanitizeForTerminal(redactUrlsIn(stack), true)}\n next: report it at ${ISSUES} with the stack above\n`;
|
|
18
|
+
}
|
|
19
|
+
return `docsxai: ${withNext(`unexpected error: ${first}`, `rerun with DOCSX_DEBUG=1 for the stack trace, and report it at ${ISSUES}`)}\n`;
|
|
20
|
+
}
|
|
21
|
+
/** Run `main` as the bin does: an error it throws becomes exit 1 and {@link unexpectedErrorText}. */
|
|
22
|
+
export async function runAsBin(main, argv, env = process.env) {
|
|
23
|
+
try {
|
|
24
|
+
return await main(argv);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
process.stderr.write(unexpectedErrorText(e, debugEnabled(env)));
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dist/cli-usage.d.ts
CHANGED
|
@@ -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 \u2014 deterministic execution CLI\n\nUsage:\n docsxai init <workspace-dir> [--app-url <url>] [--auth manual-capture|none] [--role <role>] [--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 text|md|json] [--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 text|md|json] [--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. An error no command handled is a bug: it prints one\n `docsxai: unexpected error` line; set DOCSX_DEBUG=1 to print its stack trace.\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";
|
package/dist/cli-usage.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
export const USAGE = `docsxai — deterministic execution CLI
|
|
5
5
|
|
|
6
6
|
Usage:
|
|
7
|
-
docsxai init <workspace-dir> [--app-url <url>] [--auth manual-capture|none] [--role <
|
|
7
|
+
docsxai init <workspace-dir> [--app-url <url>] [--auth manual-capture|none] [--role <role>] [--ttl <dur>]
|
|
8
8
|
[--capture-trigger console|button] [--auth-cookie <name>] [--ignore-https-errors]
|
|
9
9
|
[--persist tmp] [--force]
|
|
10
10
|
docsxai calibrate <workspace-dir> --from <flow.md|.yaml> [--name <flow>]
|
|
11
11
|
docsxai inspect <workspace-dir> [--url <url>] [--selector <css>] [--cdp <endpoint>] [--wait <ms>] [--wait-for <css>] [--headed] [--ignore-https-errors] [--role <role>]
|
|
12
12
|
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>]
|
|
13
|
-
docsxai run <workspace-dir> --verify-determinism [--runs <2-5>] [--format
|
|
13
|
+
docsxai run <workspace-dir> --verify-determinism [--runs <2-5>] [--format text|md|json] [--flow <name>] [--base-url <url>] [--concurrency <N>]
|
|
14
14
|
docsxai lint <workspace-dir> [--flow <name>] [--format text|json]
|
|
15
15
|
docsxai flow-tree <workspace-dir> [--format text|json]
|
|
16
16
|
docsxai diagnose <workspace-dir> --flow <name> --step <step-id> [--variant <id>] [--cdp <endpoint>] [--format text|json]
|
|
@@ -18,7 +18,7 @@ Usage:
|
|
|
18
18
|
docsxai style <workspace-dir> [--check] [--format text|json]
|
|
19
19
|
docsxai zip <workspace-dir> [--out <output.zip>] [--include-viewer]
|
|
20
20
|
docsxai baseline <workspace-dir> [--out <dir>]
|
|
21
|
-
docsxai diff <workspace-dir> [--against <dir>] [--format
|
|
21
|
+
docsxai diff <workspace-dir> [--against <dir>] [--format text|md|json] [--fail-on warn|fail]
|
|
22
22
|
docsxai export adf <workspace-dir> [--flow <name>] [--mode single|page-tree] [--title <text>] [--out <dir>]
|
|
23
23
|
docsxai export playwright <workspace-dir> [--flow <name>] [--out <dir>]
|
|
24
24
|
docsxai plugins <list|info|sync> <workspace-dir> [<namespace>] [--format text|json]
|
|
@@ -186,7 +186,8 @@ Notes:
|
|
|
186
186
|
• A command that works on a workspace takes its directory as the first argument. Reports and data go to
|
|
187
187
|
stdout; progress lines and warnings go to stderr where a command already splits them. Output has no
|
|
188
188
|
colour. An error prints \`<command>: what failed\`, then \`next: <command to run>\` when there is one.
|
|
189
|
-
Exit 0 success, 1 runtime failure, 2 usage error.
|
|
189
|
+
Exit 0 success, 1 runtime failure, 2 usage error. An error no command handled is a bug: it prints one
|
|
190
|
+
\`docsxai: unexpected error\` line; set DOCSX_DEBUG=1 to print its stack trace.
|
|
190
191
|
• --format json (lint, flow-tree, diagnose, style, diff, plugins, run --verify-determinism) is the
|
|
191
192
|
machine-readable output; the text formats are for people and may change.
|
|
192
193
|
• run, calibrate, burn, pack, zip, baseline, push, pull and doctor end with one line,
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { pathToFileURL } from "node:url";
|
|
17
17
|
import { runDoctor } from "./doctor.js";
|
|
18
18
|
import { USAGE } from "./cli-usage.js";
|
|
19
|
+
import { runAsBin } from "./cli-unexpected.js";
|
|
19
20
|
import { cmdCalibrate, cmdCaptureAuth, cmdInit, cmdRun } from "./cli-commands-session.js";
|
|
20
21
|
import { cmdDiagnose, cmdFlowTree, cmdInspect, cmdLint, cmdStyle, } from "./cli-commands-authoring.js";
|
|
21
22
|
import { cmdBaseline, cmdBurn, cmdDiff, cmdExport, cmdRender, cmdZip, } from "./cli-commands-docpack.js";
|
|
@@ -23,6 +24,8 @@ import { cmdLogin, cmdPlugins, cmdPull, cmdPush } from "./cli-commands-backend.j
|
|
|
23
24
|
import { cmdPack } from "./cli-commands-pack.js";
|
|
24
25
|
import { RETIRED_COMMANDS } from "./cli-retired.js";
|
|
25
26
|
import { findRetired, warnDeprecated } from "./deprecation.js";
|
|
27
|
+
// The bins wrap `main` in this, so an error no command handled prints one line, not a stack.
|
|
28
|
+
export { runAsBin };
|
|
26
29
|
export async function main(argv) {
|
|
27
30
|
const [cmd, ...rest] = argv;
|
|
28
31
|
const retired = cmd === undefined ? undefined : findRetired(RETIRED_COMMANDS, cmd);
|
|
@@ -86,5 +89,5 @@ export async function main(argv) {
|
|
|
86
89
|
}
|
|
87
90
|
// Run as the bin entry, but not when imported (e.g. in tests).
|
|
88
91
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
89
|
-
void main
|
|
92
|
+
void runAsBin(main, process.argv.slice(2)).then((code) => process.exit(code));
|
|
90
93
|
}
|
package/dist/doctor-checks.js
CHANGED
|
@@ -333,6 +333,7 @@ export const KNOWN_DOCSX_ENV_VARS = [
|
|
|
333
333
|
"DOCSX_EGRESS_GUARD",
|
|
334
334
|
"DOCSX_EGRESS_DENY_PRIVATE",
|
|
335
335
|
"DOCSX_MCP_TOKEN",
|
|
336
|
+
"DOCSX_DEBUG",
|
|
336
337
|
];
|
|
337
338
|
/** On/off switches: `1`, `true` or `yes` turns one on; anything else non-empty, `0`/`false`/`no` aside, is read as off. */
|
|
338
339
|
const FLAG_ENV_VARS = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docsxai/engine",
|
|
3
|
-
"version": "0.3.0-rc.
|
|
3
|
+
"version": "0.3.0-rc.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/pngjs": "^6.0.5",
|
|
52
52
|
"typescript": "^5.5.0",
|
|
53
53
|
"vitest": "^2.0.0",
|
|
54
|
-
"@docsxai/backend": "0.3.0-rc.
|
|
54
|
+
"@docsxai/backend": "0.3.0-rc.3"
|
|
55
55
|
},
|
|
56
56
|
"author": "Kalebtec <security@kalebtec.com>",
|
|
57
57
|
"engines": {
|