@docsxai/engine 0.3.0-rc.1 → 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 +3 -2
- package/dist/cli-backend-errors.d.ts +7 -0
- package/dist/cli-backend-errors.js +66 -0
- package/dist/cli-commands-authoring.js +34 -47
- package/dist/cli-commands-backend.js +48 -41
- package/dist/cli-commands-docpack.js +41 -47
- package/dist/cli-commands-pack.js +1 -5
- package/dist/cli-commands-session.js +32 -40
- package/dist/cli-messages.d.ts +22 -0
- package/dist/cli-messages.js +87 -0
- package/dist/cli-run-summary.d.ts +15 -0
- package/dist/cli-run-summary.js +33 -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 +30 -4
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +5 -2
- package/dist/doctor-checks-plugins.js +4 -3
- package/dist/doctor-checks.js +7 -5
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.js +27 -3
- package/package.json +2 -2
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.";
|
|
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]
|
|
@@ -182,4 +182,30 @@ Notes:
|
|
|
182
182
|
optionally backend_workspace_id / backend_project_id; created on first push if absent and
|
|
183
183
|
persisted to the config). --kind defaults to "calibrate"; --author defaults to the OS user.
|
|
184
184
|
• pull fetches a revision's artifacts back into the workspace files (default: HEAD). Useful for
|
|
185
|
-
syncing with a different operator's edits or rolling back to a named revision
|
|
185
|
+
syncing with a different operator's edits or rolling back to a named revision.
|
|
186
|
+
• A command that works on a workspace takes its directory as the first argument. Reports and data go to
|
|
187
|
+
stdout; progress lines and warnings go to stderr where a command already splits them. Output has no
|
|
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. 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.
|
|
191
|
+
• --format json (lint, flow-tree, diagnose, style, diff, plugins, run --verify-determinism) is the
|
|
192
|
+
machine-readable output; the text formats are for people and may change.
|
|
193
|
+
• run, calibrate, burn, pack, zip, baseline, push, pull and doctor end with one line,
|
|
194
|
+
\`<command>: <result> …\`, naming the counts and where the output went (run --verify-determinism
|
|
195
|
+
ends with its report).
|
|
196
|
+
|
|
197
|
+
Examples:
|
|
198
|
+
docsxai init ~/docsxai/my-app --app-url https://app.example.com
|
|
199
|
+
docsxai capture-auth ~/docsxai/my-app
|
|
200
|
+
docsxai calibrate ~/docsxai/my-app --from login.flow.yaml
|
|
201
|
+
docsxai run ~/docsxai/my-app --flow login
|
|
202
|
+
docsxai run ~/docsxai/my-app --verify-determinism --runs 3 --format md
|
|
203
|
+
docsxai lint ~/docsxai/my-app --format json
|
|
204
|
+
docsxai render ~/docsxai/my-app
|
|
205
|
+
docsxai burn ~/docsxai/my-app --flow login --out ~/docsxai/my-app/burned
|
|
206
|
+
docsxai pack ~/docsxai/my-app --out ~/docsxai/my-app/.screens
|
|
207
|
+
docsxai pack ~/docsxai/my-app --check --against ./public/screens
|
|
208
|
+
docsxai baseline ~/docsxai/my-app
|
|
209
|
+
docsxai diff ~/docsxai/my-app --fail-on warn
|
|
210
|
+
docsxai doctor ~/docsxai/my-app
|
|
211
|
+
docsxai push ~/docsxai/my-app --kind run`;
|
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);
|
|
@@ -80,11 +83,11 @@ export async function main(argv) {
|
|
|
80
83
|
case "pull":
|
|
81
84
|
return cmdPull(rest);
|
|
82
85
|
default:
|
|
83
|
-
process.stderr.write(`unknown command: ${cmd}\
|
|
86
|
+
process.stderr.write(`unknown command: ${cmd}\nrun \`docsxai --help\` to list the commands\n`);
|
|
84
87
|
return 2;
|
|
85
88
|
}
|
|
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
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// the environment and workspace-content probes, with its own dependency set
|
|
4
4
|
// (the plugin runtime + lock + manifest domain).
|
|
5
5
|
import { promises as fs } from "node:fs";
|
|
6
|
+
import { shellQuote } from "./cli-messages.js";
|
|
6
7
|
import { isApiVersionCompatible, RUNTIME_API_VERSION } from "./plugins/manifest.js";
|
|
7
8
|
import { PLUGINS_LOCK_FILE, PluginsConfigError, PluginsLockError, readPluginsLock, readWorkspacePluginsConfig, verifyLock, } from "./plugins/lock.js";
|
|
8
9
|
import { resolvePluginSources } from "./plugins/runtime.js";
|
|
@@ -46,7 +47,7 @@ export async function checkPlugins(workspaceDir) {
|
|
|
46
47
|
name: "plugins",
|
|
47
48
|
ok: false,
|
|
48
49
|
detail: e.message,
|
|
49
|
-
fix: `re-pin: docsxai plugins sync ${workspaceDir}`,
|
|
50
|
+
fix: `re-pin: docsxai plugins sync ${shellQuote(workspaceDir)}`,
|
|
50
51
|
},
|
|
51
52
|
];
|
|
52
53
|
}
|
|
@@ -58,7 +59,7 @@ export async function checkPlugins(workspaceDir) {
|
|
|
58
59
|
name: "plugins",
|
|
59
60
|
ok: false,
|
|
60
61
|
detail: `${PLUGINS_LOCK_FILE} missing (${cfg.sources.length} plugin(s) configured — no reproducibility pin)`,
|
|
61
|
-
fix: `docsxai plugins sync ${workspaceDir}`,
|
|
62
|
+
fix: `docsxai plugins sync ${shellQuote(workspaceDir)}`,
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
const resolutions = await resolvePluginSources(workspaceDir, cfg.sources);
|
|
@@ -106,7 +107,7 @@ export async function checkPlugins(workspaceDir) {
|
|
|
106
107
|
if (mismatch) {
|
|
107
108
|
issues.push({
|
|
108
109
|
detail: mismatch,
|
|
109
|
-
fix: `after auditing the change: docsxai plugins sync ${workspaceDir}`,
|
|
110
|
+
fix: `after auditing the change: docsxai plugins sync ${shellQuote(workspaceDir)}`,
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
else {
|
package/dist/doctor-checks.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { existsSync, promises as fs } from "node:fs";
|
|
9
9
|
import * as path from "node:path";
|
|
10
10
|
import { parseAuthStrategyFile } from "./auth.js";
|
|
11
|
+
import { shellQuote } from "./cli-messages.js";
|
|
11
12
|
import { EGRESS_DENY_PRIVATE_ENV, EGRESS_GUARD_ENV, envFlagOff, envFlagOn, } from "./egress-guard.js";
|
|
12
13
|
import { FlowFileError, parseFlowFile } from "./flow-file.js";
|
|
13
14
|
import { chromiumExecutablePath } from "./playwright-driver.js";
|
|
@@ -87,7 +88,7 @@ export async function checkWorkspace(workspaceDir) {
|
|
|
87
88
|
name: "workspace",
|
|
88
89
|
ok: false,
|
|
89
90
|
detail: `${configPath} is not valid JSON: ${e.message}`,
|
|
90
|
-
fix: `fix the JSON (or re-scaffold with \`docsxai init ${workspaceDir} --force\`)`,
|
|
91
|
+
fix: `fix the JSON (or re-scaffold with \`docsxai init ${shellQuote(workspaceDir)} --force\`)`,
|
|
91
92
|
},
|
|
92
93
|
config: null,
|
|
93
94
|
present: true,
|
|
@@ -150,7 +151,7 @@ export async function checkFlows(workspaceDir) {
|
|
|
150
151
|
name: "flows",
|
|
151
152
|
ok: false,
|
|
152
153
|
detail: `${entry} does not parse: ${msg}`,
|
|
153
|
-
fix: `fix the flow-file (then \`docsxai lint ${workspaceDir}\` for the full static report)`,
|
|
154
|
+
fix: `fix the flow-file (then \`docsxai lint ${shellQuote(workspaceDir)}\` for the full static report)`,
|
|
154
155
|
};
|
|
155
156
|
}
|
|
156
157
|
}
|
|
@@ -204,7 +205,7 @@ export async function checkAuth(workspaceDir, now) {
|
|
|
204
205
|
name: "auth",
|
|
205
206
|
ok: true,
|
|
206
207
|
info: true,
|
|
207
|
-
detail: `no cached session for role "${role}" — \`docsxai capture-auth ${workspaceDir}\` before \`run\``,
|
|
208
|
+
detail: `no cached session for role "${role}" — \`docsxai capture-auth ${shellQuote(workspaceDir)}\` before \`run\``,
|
|
208
209
|
});
|
|
209
210
|
return checks;
|
|
210
211
|
}
|
|
@@ -221,7 +222,7 @@ export async function checkAuth(workspaceDir, now) {
|
|
|
221
222
|
name: "auth",
|
|
222
223
|
ok: false,
|
|
223
224
|
detail: `cached session ${sessionPath} is corrupt (no expiresAt)`,
|
|
224
|
-
fix: `re-capture: docsxai capture-auth ${workspaceDir}`,
|
|
225
|
+
fix: `re-capture: docsxai capture-auth ${shellQuote(workspaceDir)}`,
|
|
225
226
|
});
|
|
226
227
|
}
|
|
227
228
|
else if (expiresAt <= now) {
|
|
@@ -229,7 +230,7 @@ export async function checkAuth(workspaceDir, now) {
|
|
|
229
230
|
name: "auth",
|
|
230
231
|
ok: false,
|
|
231
232
|
detail: `cached session for role "${role}" expired ${new Date(expiresAt).toISOString()}`,
|
|
232
|
-
fix: `re-capture: docsxai capture-auth ${workspaceDir}`,
|
|
233
|
+
fix: `re-capture: docsxai capture-auth ${shellQuote(workspaceDir)}`,
|
|
233
234
|
});
|
|
234
235
|
}
|
|
235
236
|
else {
|
|
@@ -332,6 +333,7 @@ export const KNOWN_DOCSX_ENV_VARS = [
|
|
|
332
333
|
"DOCSX_EGRESS_GUARD",
|
|
333
334
|
"DOCSX_EGRESS_DENY_PRIVATE",
|
|
334
335
|
"DOCSX_MCP_TOKEN",
|
|
336
|
+
"DOCSX_DEBUG",
|
|
335
337
|
];
|
|
336
338
|
/** On/off switches: `1`, `true` or `yes` turns one on; anything else non-empty, `0`/`false`/`no` aside, is read as off. */
|
|
337
339
|
const FLAG_ENV_VARS = [
|
package/dist/doctor.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export * from "./doctor-checks.js";
|
|
|
3
3
|
export * from "./doctor-checks-plugins.js";
|
|
4
4
|
export declare function buildDoctorChecks(opts?: DoctorOptions): Promise<DoctorCheck[]>;
|
|
5
5
|
export declare function formatDoctorChecks(checks: DoctorCheck[]): string;
|
|
6
|
+
/** What `docsxai doctor --help` prints: the usage line from `docsxai --help`, then what the rows mean. */
|
|
7
|
+
export declare function doctorHelp(): string;
|
|
6
8
|
/** `docsxai doctor [<workspace-dir>]` — returns the process exit code. */
|
|
7
9
|
export declare function runDoctor(args: string[]): Promise<number>;
|
package/dist/doctor.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// every doctor symbol stays importable from ./doctor.js.
|
|
12
12
|
import { checkAuth, checkBackend, checkChromium, checkEnv, checkFlows, checkNode, checkViewer, checkWorkspace, probeChromium, } from "./doctor-checks.js";
|
|
13
13
|
import { checkPlugins } from "./doctor-checks-plugins.js";
|
|
14
|
+
import { commandUsage } from "./cli-messages.js";
|
|
14
15
|
// Re-export the probe catalogue's public surface so importers keep reaching it
|
|
15
16
|
// through ./doctor.js (its original home) — no importer or test changes. The
|
|
16
17
|
// plugin-runtime probe lives in its own sibling but is re-exported here too.
|
|
@@ -41,20 +42,43 @@ export async function buildDoctorChecks(opts = {}) {
|
|
|
41
42
|
}
|
|
42
43
|
export function formatDoctorChecks(checks) {
|
|
43
44
|
let out = "docsxai doctor — environment & workspace health\n\n";
|
|
44
|
-
let
|
|
45
|
+
let failed = 0;
|
|
45
46
|
for (const c of checks) {
|
|
46
47
|
if (!c.ok)
|
|
47
|
-
|
|
48
|
+
failed++;
|
|
48
49
|
const glyph = c.info ? "−" : c.ok ? "✓" : "✗";
|
|
49
50
|
out += ` ${glyph} ${c.name.padEnd(10)} ${c.detail}\n`;
|
|
50
51
|
if (!c.ok && c.fix)
|
|
51
52
|
out += ` fix: ${c.fix}\n`;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
const infos = checks.filter((c) => c.info).length;
|
|
55
|
+
const scored = checks.length - infos;
|
|
56
|
+
out +=
|
|
57
|
+
failed === 0
|
|
58
|
+
? `\ndoctor: all checks passed (${scored} checks, ${infos} informational)\n`
|
|
59
|
+
: `\ndoctor: fix the ✗ items above and run docsxai doctor again (${failed} of ${scored} checks failed)\n`;
|
|
54
60
|
return out;
|
|
55
61
|
}
|
|
62
|
+
/** What `docsxai doctor --help` prints: the usage line from `docsxai --help`, then what the rows mean. */
|
|
63
|
+
export function doctorHelp() {
|
|
64
|
+
return `${commandUsage("doctor")
|
|
65
|
+
.map((l) => `usage: ${l}\n`)
|
|
66
|
+
.join("")}
|
|
67
|
+
Checks Node, Chromium, the workspace config, flow-files, cached sessions, the backend (when
|
|
68
|
+
backend_url is set), plugin declarations, the viewer bin and DOCSX_* env. Runs no flow, no plugin
|
|
69
|
+
code and no browser.
|
|
70
|
+
|
|
71
|
+
✓ passed ✗ failed, with a one-line fix − informational, never fails
|
|
72
|
+
|
|
73
|
+
Exit 0 when no row failed, 1 otherwise.
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
56
76
|
/** `docsxai doctor [<workspace-dir>]` — returns the process exit code. */
|
|
57
77
|
export async function runDoctor(args) {
|
|
78
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
79
|
+
process.stdout.write(doctorHelp());
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
58
82
|
const positionals = args.filter((a) => !a.startsWith("--"));
|
|
59
83
|
const checks = await buildDoctorChecks(positionals[0] ? { workspaceDir: positionals[0] } : {});
|
|
60
84
|
process.stdout.write(formatDoctorChecks(checks));
|
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": {
|