@docsxai/engine 0.3.0-rc.2 → 0.3.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -35
- package/dist/atomic-write.d.ts +19 -0
- package/dist/atomic-write.js +127 -0
- package/dist/auth/api-login.d.ts +9 -51
- package/dist/auth/api-login.js +3 -3
- package/dist/auth/browser-session.js +1 -1
- package/dist/auth/cookie-jar.d.ts +4 -4
- package/dist/auth/cookie-jar.js +4 -4
- package/dist/auth/email-otp.d.ts +11 -147
- package/dist/auth/email-otp.js +4 -4
- package/dist/auth/http-basic.js +1 -1
- package/dist/auth/index.js +3 -3
- package/dist/auth/jwt-injection.d.ts +7 -131
- package/dist/auth/jwt-injection.js +5 -5
- package/dist/auth/manual-capture.d.ts +3 -3
- package/dist/auth/manual-capture.js +2 -2
- package/dist/auth/mtls.d.ts +1 -6
- package/dist/auth/mtls.js +1 -1
- package/dist/auth/pat-header.d.ts +1 -9
- package/dist/auth/pat-header.js +1 -1
- package/dist/auth/storage-state-cache.d.ts +16 -6
- package/dist/auth/storage-state-cache.js +65 -15
- package/dist/auth/test-backdoor.d.ts +2 -13
- package/dist/auth/test-backdoor.js +3 -3
- package/dist/auth/totp.d.ts +1 -1
- package/dist/auth/totp.js +4 -4
- package/dist/auth/types.d.ts +3 -3
- package/dist/auth/types.js +4 -4
- package/dist/auth/ui-form.d.ts +24 -153
- package/dist/auth/ui-form.js +3 -3
- package/dist/auth/webauthn.d.ts +7 -67
- package/dist/auth/webauthn.js +3 -3
- package/dist/auth.js +1 -1
- package/dist/backend-client-contracts.d.ts +1 -1
- package/dist/backend-client-contracts.js +2 -2
- package/dist/backend-client-oauth-login.js +1 -1
- package/dist/backend-client-state-cache.d.ts +2 -2
- package/dist/backend-client-state-cache.js +8 -8
- package/dist/backend-client-token.js +5 -5
- package/dist/backend-client-transport.d.ts +2 -2
- package/dist/backend-client-transport.js +3 -3
- package/dist/backend-client.js +6 -6
- package/dist/browser-build.d.ts +6 -0
- package/dist/browser-build.js +12 -0
- package/dist/browser-launch-error.d.ts +18 -0
- package/dist/browser-launch-error.js +63 -0
- package/dist/browser-wait.d.ts +7 -0
- package/dist/browser-wait.js +12 -0
- package/dist/calibrate.d.ts +6 -2
- package/dist/calibrate.js +20 -13
- package/dist/cli-backend-errors.d.ts +5 -0
- package/dist/cli-backend-errors.js +28 -6
- package/dist/cli-commands-auth.d.ts +1 -0
- package/dist/cli-commands-auth.js +114 -0
- package/dist/cli-commands-authoring.d.ts +0 -1
- package/dist/cli-commands-authoring.js +124 -101
- package/dist/cli-commands-backend.d.ts +1 -1
- package/dist/cli-commands-backend.js +76 -21
- package/dist/cli-commands-docpack.d.ts +3 -1
- package/dist/cli-commands-docpack.js +145 -39
- package/dist/cli-commands-init.d.ts +1 -0
- package/dist/cli-commands-init.js +100 -0
- package/dist/cli-commands-pack.d.ts +1 -1
- package/dist/cli-commands-pack.js +6 -4
- package/dist/cli-commands-session.d.ts +1 -3
- package/dist/cli-commands-session.js +109 -180
- package/dist/cli-commands-site.d.ts +2 -0
- package/dist/cli-commands-site.js +77 -0
- package/dist/cli-commands-style.d.ts +1 -0
- package/dist/cli-commands-style.js +85 -0
- package/dist/cli-flags.d.ts +18 -0
- package/dist/cli-flags.js +77 -0
- package/dist/cli-help.d.ts +30 -0
- package/dist/cli-help.js +174 -0
- package/dist/cli-messages.d.ts +35 -0
- package/dist/cli-messages.js +104 -0
- package/dist/cli-node-guard.d.ts +1 -0
- package/dist/cli-node-guard.js +8 -0
- package/dist/cli-retired.js +6 -0
- package/dist/cli-run-stale.d.ts +2 -0
- package/dist/cli-run-stale.js +13 -0
- package/dist/cli-run-summary.js +7 -3
- package/dist/cli-shared.d.ts +30 -1
- package/dist/cli-shared.js +112 -12
- package/dist/cli-unexpected.d.ts +16 -0
- package/dist/cli-unexpected.js +76 -0
- package/dist/cli-usage.d.ts +1 -1
- package/dist/cli-usage.js +116 -66
- package/dist/cli-value-flags.d.ts +8 -0
- package/dist/cli-value-flags.js +34 -0
- package/dist/cli-version.d.ts +6 -0
- package/dist/cli-version.js +25 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +46 -20
- package/dist/deprecation.d.ts +2 -0
- package/dist/deprecation.js +2 -0
- package/dist/device-scale-factor.d.ts +14 -0
- package/dist/device-scale-factor.js +38 -0
- package/dist/diagnose.js +14 -13
- package/dist/diff-compute.js +22 -8
- package/dist/diff-report.js +3 -3
- package/dist/diff-types.js +1 -1
- package/dist/diff.js +3 -3
- package/dist/doc-pack-io.js +62 -47
- package/dist/doc-pack.d.ts +567 -3487
- package/dist/doc-pack.js +47 -33
- package/dist/doctor-checks-config.d.ts +12 -0
- package/dist/doctor-checks-config.js +229 -0
- package/dist/doctor-checks-plugins.js +2 -2
- package/dist/doctor-checks-site.d.ts +3 -0
- package/dist/doctor-checks-site.js +21 -0
- package/dist/doctor-checks.d.ts +13 -2
- package/dist/doctor-checks.js +95 -79
- package/dist/doctor-next.d.ts +5 -0
- package/dist/doctor-next.js +52 -0
- package/dist/doctor.d.ts +36 -2
- package/dist/doctor.js +88 -29
- package/dist/environment-spec.d.ts +36 -44
- package/dist/environment-spec.js +31 -3
- package/dist/export/adf.d.ts +1 -1
- package/dist/export/adf.js +16 -27
- package/dist/export/playwright-test.d.ts +1 -1
- package/dist/export/playwright-test.js +13 -15
- package/dist/flow-file.d.ts +1 -1
- package/dist/flow-file.js +22 -4
- package/dist/flow-halt.d.ts +1 -1
- package/dist/flow-halt.js +15 -3
- package/dist/flow-lint.d.ts +3 -1
- package/dist/flow-lint.js +39 -26
- package/dist/flow-matrix-lint.js +2 -2
- package/dist/flow-runtime.d.ts +17 -6
- package/dist/flow-runtime.js +48 -17
- package/dist/flow-success.js +4 -4
- package/dist/flow-tree.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/main-module.d.ts +1 -0
- package/dist/main-module.js +17 -0
- package/dist/matrix-spec.d.ts +33 -106
- package/dist/matrix-spec.js +12 -3
- package/dist/node-floor.d.ts +4 -0
- package/dist/node-floor.js +14 -0
- package/dist/obstacles.js +1 -1
- package/dist/open-in-browser.d.ts +22 -0
- package/dist/open-in-browser.js +37 -0
- package/dist/playwright-driver.d.ts +8 -12
- package/dist/playwright-driver.js +75 -70
- package/dist/playwright-instrumented-browser.d.ts +10 -7
- package/dist/playwright-instrumented-browser.js +35 -12
- package/dist/plugins/load.d.ts +1 -1
- package/dist/plugins/load.js +4 -4
- package/dist/plugins/lock.js +11 -8
- package/dist/plugins/manifest.d.ts +16 -35
- package/dist/plugins/manifest.js +5 -5
- package/dist/plugins/plan.d.ts +3 -3
- package/dist/plugins/plan.js +14 -14
- package/dist/plugins/registry.d.ts +1 -1
- package/dist/plugins/registry.js +1 -1
- package/dist/plugins/runtime.js +3 -3
- package/dist/plugins/types.d.ts +1 -1
- package/dist/plugins-cli.js +36 -28
- package/dist/posix-path.d.ts +2 -0
- package/dist/posix-path.js +7 -0
- package/dist/redact.js +2 -2
- package/dist/run-flows.d.ts +7 -0
- package/dist/run-flows.js +75 -27
- package/dist/style.d.ts +2 -2
- package/dist/style.js +13 -11
- package/dist/verify-determinism.js +2 -1
- package/dist/verify-next-step.d.ts +2 -0
- package/dist/verify-next-step.js +24 -0
- package/dist/verify-report.js +3 -2
- package/dist/viewer-bin.d.ts +9 -3
- package/dist/viewer-bin.js +35 -12
- package/dist/workspace-templates.d.ts +15 -0
- package/dist/workspace-templates.js +88 -0
- package/dist/workspace.d.ts +78 -5
- package/dist/workspace.js +47 -28
- package/dist/zip.d.ts +1 -1
- package/dist/zip.js +23 -6
- package/package.json +6 -6
package/dist/cli-usage.js
CHANGED
|
@@ -1,56 +1,76 @@
|
|
|
1
1
|
// `docsxai` CLI help text. Split out of cli.ts so the dispatch barrel and every command cluster
|
|
2
2
|
// can share the one authoritative USAGE string (commands print it on a missing-arg bail; the
|
|
3
|
-
// barrel prints it for --help / unknown-command). Text only
|
|
4
|
-
export const USAGE = `docsxai
|
|
3
|
+
// barrel prints it for --help / unknown-command). Text only, no imports, the truest leaf.
|
|
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 <
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
docsxai
|
|
11
|
-
docsxai inspect <workspace-dir> [--url <url>] [--selector <css>] [--cdp <endpoint>]
|
|
12
|
-
|
|
13
|
-
docsxai run <workspace-dir>
|
|
7
|
+
docsxai init <workspace-dir> [--app-url <url>] [--auth manual-capture|none] [--role <role>]
|
|
8
|
+
[--ttl <dur>] [--capture-trigger console|button] [--auth-cookie <name>]
|
|
9
|
+
[--ignore-https-errors] [--persist tmp] [--force] [--example]
|
|
10
|
+
docsxai add-flow <workspace-dir> --from <flow.md|.yaml> [--name <flow>]
|
|
11
|
+
docsxai inspect <workspace-dir> [--url <url>] [--selector <css>] [--cdp <endpoint>]
|
|
12
|
+
[--wait <ms>] [--wait-for <css>] [--headed] [--ignore-https-errors] [--role <role>]
|
|
13
|
+
docsxai run <workspace-dir> [--flow <name>] [--base-url <url>] [--headed]
|
|
14
|
+
[--ignore-https-errors] [--stop-after <step-id>] [--start-from <step-id>]
|
|
15
|
+
[--variant <id>] [--cdp <endpoint>] [--pause] [--concurrency <N>]
|
|
16
|
+
[--device-scale-factor <1-4>]
|
|
17
|
+
docsxai run <workspace-dir> --verify-determinism [--runs <2-5>] [--format text|md|json]
|
|
18
|
+
[--flow <name>] [--base-url <url>] [--concurrency <N>]
|
|
14
19
|
docsxai lint <workspace-dir> [--flow <name>] [--format text|json]
|
|
15
20
|
docsxai flow-tree <workspace-dir> [--format text|json]
|
|
16
|
-
docsxai diagnose <workspace-dir> --flow <name> --step <step-id> [--variant <id>]
|
|
17
|
-
|
|
21
|
+
docsxai diagnose <workspace-dir> --flow <name> --step <step-id> [--variant <id>]
|
|
22
|
+
[--cdp <endpoint>] [--format text|json]
|
|
23
|
+
docsxai doctor [<workspace-dir>] [--offline] [--format text|json]
|
|
18
24
|
docsxai style <workspace-dir> [--check] [--format text|json]
|
|
19
25
|
docsxai zip <workspace-dir> [--out <output.zip>] [--include-viewer]
|
|
20
26
|
docsxai baseline <workspace-dir> [--out <dir>]
|
|
21
|
-
docsxai diff <workspace-dir> [--against <dir>] [--format
|
|
22
|
-
docsxai export adf <workspace-dir> [--flow <name>] [--mode single|page-tree]
|
|
27
|
+
docsxai diff <workspace-dir> [--against <dir>] [--format text|md|json] [--fail-on warn|fail]
|
|
28
|
+
docsxai export adf <workspace-dir> [--flow <name>] [--mode single|page-tree]
|
|
29
|
+
[--title <text>] [--out <dir>]
|
|
23
30
|
docsxai export playwright <workspace-dir> [--flow <name>] [--out <dir>]
|
|
24
31
|
docsxai plugins <list|info|sync> <workspace-dir> [<namespace>] [--format text|json]
|
|
25
32
|
docsxai login --backend-url <url> [--oauth <workspace-dir>]
|
|
26
33
|
docsxai push <workspace-dir> [--kind calibrate|run|edit] [--author <name>]
|
|
27
34
|
docsxai pull <workspace-dir> [--rev <id>]
|
|
28
|
-
docsxai render <workspace-dir>
|
|
29
|
-
docsxai burn <workspace-dir> [--flow <name>] [--out <dir>] [--report <file>]
|
|
30
|
-
|
|
31
|
-
docsxai
|
|
32
|
-
|
|
35
|
+
docsxai render <workspace-dir> [--lang <locale>] [--open]
|
|
36
|
+
docsxai burn <workspace-dir> [--flow <name>] [--out <dir>] [--report <file>]
|
|
37
|
+
[--no-connector-outline] [--strict-glyphs]
|
|
38
|
+
docsxai site <workspace-dir> [--out <dir>] [--build] [--title <text>] [--accent <hex>]
|
|
39
|
+
[--lang <locale>] [--flow <name>]
|
|
40
|
+
docsxai pack <workspace-or-raw-dir> [--from-raw] [--out <dir>] [--public-prefix <path>]
|
|
41
|
+
[--no-optimise] [--generated-for <text>]
|
|
42
|
+
docsxai pack <workspace-or-raw-dir> --check --against <pack-dir> [--from-raw]
|
|
43
|
+
[--threshold <pct>]
|
|
44
|
+
docsxai capture-auth <workspace-dir> [--base-url <url>] [--role <role>] [--auth-cookie <name>]
|
|
45
|
+
[--cdp <endpoint>] [--fresh] [--headless] [--ignore-https-errors]
|
|
33
46
|
docsxai --help
|
|
47
|
+
docsxai --version
|
|
34
48
|
|
|
35
49
|
Notes:
|
|
36
50
|
• A *workspace* (created by \`init\`) holds flows/<flow>.flow.yaml, docs/, auth/strategy.yaml, .auth/, .viewer/,
|
|
37
|
-
and a .docsxai.json config. Put it OUTSIDE the app's source repo
|
|
51
|
+
and a .docsxai.json config. Put it OUTSIDE the app's source repo, docsxai documents a running app from
|
|
38
52
|
outside and never writes into the app repo.
|
|
53
|
+
• init --example makes a workspace for https://example.com with no login and writes
|
|
54
|
+
flows/hello.flow.yaml, so run and render --open are all that's left. It can't be combined with
|
|
55
|
+
--app-url, --auth, --role, --ttl, --capture-trigger or --auth-cookie.
|
|
39
56
|
• run / capture-auth read app_url + ignore_https_errors from .docsxai.json if you don't pass the flags.
|
|
40
57
|
• run launches Chromium; if no browser binary is present, install one: npx playwright-core install chromium
|
|
41
|
-
(source checkout: pnpm -C packages/engine exec playwright-core install chromium)
|
|
42
58
|
• --ignore-https-errors accepts self-signed/invalid TLS (e.g. an app's local HTTPS dev cert)
|
|
43
59
|
• run --stop-after <step-id> runs only a prefix of the flow (up to & incl. that step); --pause keeps the
|
|
44
|
-
(headed) browser open at the last step run
|
|
60
|
+
(headed) browser open at the last step run, so you can inspect the live state mid-flow when calibrating
|
|
45
61
|
(pair with --flow <name>). For waiting on a slow backend op, give a step a wait_for of the form
|
|
46
|
-
{ selector: $x, timeout_ms: 180000 }
|
|
62
|
+
{ selector: $x, timeout_ms: 180000 }, a per-step override of the default ~30s selector-wait timeout.
|
|
47
63
|
For a page that settles late (web fonts swapping, images arriving), use wait_for: settled: it waits for
|
|
48
64
|
fonts, the images in view and the layout of what's on screen to stop changing, within the step's
|
|
49
65
|
timeout_ms (default 10s), and halts with the cause if the page never settles.
|
|
50
66
|
• run --concurrency <N> runs up to N flows in parallel (each its own Chromium session, isolated; default 1).
|
|
51
|
-
Useful when several flows share a long preamble
|
|
67
|
+
Useful when several flows share a long preamble, total wall time = max(per-flow), not sum. Force-clamped
|
|
52
68
|
to 1 when --pause / --stop-after / --start-from / --cdp is set. The target app must tolerate multiple sessions from one user.
|
|
53
|
-
• run --
|
|
69
|
+
• run --device-scale-factor <1-4> captures at that many device pixels per CSS pixel (a whole number or one
|
|
70
|
+
decimal, default 1): at 2 a 1280 by 800 viewport gives a 2560 by 1600 PNG. DOCSX_DEVICE_SCALE_FACTOR sets it
|
|
71
|
+
when the flag is absent. annotations.json records device_scale_factor above 1; its boxes are in the PNG's
|
|
72
|
+
own pixels, and burn reads the factor from it. Not combinable with --cdp (the attached browser owns its scale).
|
|
73
|
+
• run --start-from <step-id> --flow <name> SKIPS every step before <step-id> and starts execution there,
|
|
54
74
|
the inverse of --stop-after. Pair with --cdp to attach to a Chrome that's already in the post-prior-steps
|
|
55
75
|
state (e.g. left over from a paused previous run) and iterate on the new tail step in seconds rather
|
|
56
76
|
than re-walking the whole extends chain. New annotations MERGE into the existing annotations.json by
|
|
@@ -62,8 +82,8 @@ Notes:
|
|
|
62
82
|
prints them, diagnose --variant <id> picks one. --cdp cannot run a matrix flow.
|
|
63
83
|
• run --cdp <endpoint> attaches to a running Chrome (start it with --remote-debugging-port=N) instead of
|
|
64
84
|
launching one. docsxai won't close that Chrome. When --cdp is set, the cached storageState is NOT
|
|
65
|
-
loaded into the context
|
|
66
|
-
|
|
85
|
+
loaded into the context, the attached Chrome keeps its own auth state. Useful with --start-from for a
|
|
86
|
+
fast iteration loop on long-async flows.
|
|
67
87
|
• run --verify-determinism runs the selected flows N times (--runs, 2 to 5, default 2), each into its own
|
|
68
88
|
root under <ws>/.docsxai-verify/run-<k>/, then byte-compares every artefact: annotations.json, screenshots,
|
|
69
89
|
step markdown, locators, halt context. The workspace output is written only when every run agrees (run 1's
|
|
@@ -72,67 +92,71 @@ Notes:
|
|
|
72
92
|
stderr) and names the first differing artefact by path with a cause: the JSON key path, the changed-pixel
|
|
73
93
|
region of a PNG, the first differing line of text, or the sizes. Exit 0 identical, 1 differing or a flow
|
|
74
94
|
halted, 2 bad flags. Not combinable with --pause / --stop-after / --start-from / --cdp.
|
|
75
|
-
• capture-auth runs the role's auth strategy (
|
|
76
|
-
|
|
95
|
+
• capture-auth runs the role's auth strategy (manual-capture: a headed, instrumented browser you log
|
|
96
|
+
into; window.__docsxai.capture() or an injected button snapshots the session) and caches
|
|
77
97
|
it to <workspace-dir>/.auth/<role>.json for subsequent \`run\`s. It prints the captured cookie jar so you
|
|
78
98
|
can identify the app's real auth/session cookie.
|
|
79
|
-
• capture-auth keeps a persistent Chrome profile at <workspace>/.auth/chrome-profile/ (gitignored)
|
|
99
|
+
• capture-auth keeps a persistent Chrome profile at <workspace>/.auth/chrome-profile/ (gitignored), re-running
|
|
80
100
|
it reuses the login (just trigger capture again). Use --fresh for a clean profile (forces a fresh login).
|
|
81
101
|
• --cdp <endpoint> makes capture-auth *attach to an already-running Chrome* (start it with
|
|
82
|
-
--remote-debugging-port=N --disable-web-security --user-data-dir=<dir>) instead of launching a fresh one
|
|
83
|
-
use this to capture from the
|
|
84
|
-
driving for discovery), so
|
|
102
|
+
--remote-debugging-port=N --disable-web-security --user-data-dir=<dir>) instead of launching a fresh one,
|
|
103
|
+
use this to capture from the Chrome you are already logged into (and that a browser agent may be
|
|
104
|
+
driving for discovery), so you don't log in twice. docsxai won't close that Chrome. (--cdp ignores --fresh.)
|
|
85
105
|
• auth_cookie (set via \`init --auth-cookie\`, \`capture-auth --auth-cookie\`, or hand-edited into
|
|
86
106
|
auth/strategy.yaml) names that cookie; when set, the cached session's expiry tracks *that* cookie's
|
|
87
|
-
expiry
|
|
88
|
-
\`min(cookie.expires)\` ≈ now
|
|
107
|
+
expiry and not the \`ttl\` guess (an interactive SSO login leaves ephemeral IdP scratch cookies, so
|
|
108
|
+
\`min(cookie.expires)\` ≈ now, don't rely on it). If unset/unfound, \`ttl\` (or a 1h default) is used.
|
|
89
109
|
• inspect opens the app in a headless (or --headed) browser *with the cached session loaded* and prints the
|
|
90
|
-
page's [data-testid] elements (or, with --selector, matching elements' HTML)
|
|
110
|
+
page's [data-testid] elements (or, with --selector, matching elements' HTML), for pinning locators when
|
|
91
111
|
hand-authoring a flow-file (the captured session can't be replayed in a browser the agent's MCP controls
|
|
92
112
|
because the auth cookie is usually httpOnly; inspect does the storageState→Playwright bridge for you). On a
|
|
93
113
|
slow SPA, settle before the snapshot with --wait <ms> (default 800) or --wait-for '<css>'. --cdp <endpoint>
|
|
94
114
|
attaches to an already-running Chrome (e.g. the one from capture-auth --cdp) instead of launching one.
|
|
95
115
|
--ignore-https-errors accepts a self-signed/invalid TLS certificate (also read from ignore_https_errors in .docsxai.json).
|
|
96
|
-
• calibrate takes a *structured flow-guide* (a flow-file in
|
|
97
|
-
writes flows/<name>.flow.yaml + a default docs/style.yaml.
|
|
98
|
-
need the host agent
|
|
99
|
-
the flow-file; this CLI command covers only the
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
• add-flow (calibrate is deprecated since 0.3.0 and removed in 0.5.0) takes a *structured flow-guide* (a flow-file in
|
|
117
|
+
YAML, or a .md with a yaml fenced block) and writes flows/<name>.flow.yaml + a default docs/style.yaml.
|
|
118
|
+
Loose-prose descriptions / live element-picking need the host agent, that's the /docsxai:add-flow *skill*
|
|
119
|
+
(see the plugin), which then refines/produces the flow-file; this CLI command covers only the
|
|
120
|
+
deterministic structured-input case.
|
|
121
|
+
• lint runs pure-static checks across the workspace's flow-files, no Playwright, no live page. Rules:
|
|
122
|
+
R001 (deep extends chain), R002 (annotation anchored to a likely-unmounting click/navigate target,
|
|
102
123
|
suggest annotation.target override), R003 (wait_for with no timeout_ms on a long-async-looking step),
|
|
103
|
-
R004 (bare [data-*=…] selector
|
|
124
|
+
R004 (bare [data-*=…] selector, may have hidden duplicates; suggest :visible / :has-text qualifier).
|
|
104
125
|
Exit 1 if any warning/error; 0 otherwise. --format json emits machine-readable output for tooling.
|
|
105
126
|
• flow-tree prints the workspace's extends graph (root flows + their descendants), plus any orphans
|
|
106
127
|
(flows whose extends parent isn't in the workspace) and resolution issues (cycles / step-id collisions
|
|
107
128
|
across the merge). Pure-static, ~no I/O beyond reading the flow files. Exit 1 if any issues.
|
|
108
129
|
• diagnose gathers halt context for a specific step (the step's selector/wait_for/success, the halt
|
|
109
|
-
screenshot if one exists, and
|
|
130
|
+
screenshot if one exists, and, with --cdp, a live actionable() probe of the target on the running
|
|
110
131
|
page) and prints recommendations (selector / wait_for / success / annotation_target / split_step /
|
|
111
|
-
investigate). The engine never patches the flow-file itself
|
|
132
|
+
investigate). The engine never patches the flow-file itself, that's the agent's explicit opt-in
|
|
112
133
|
action. --format json emits machine-readable output for an agent to act on. Pair with
|
|
113
134
|
--start-from <step-id> --cdp on a follow-up run to validate the fix in seconds.
|
|
114
|
-
• doctor health-checks the environment + workspace: Node >= 26, Chromium presence
|
|
115
|
-
found +
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
and
|
|
135
|
+
• doctor health-checks the environment + workspace: Node >= 26, Chromium presence (with the install
|
|
136
|
+
command), .docsxai.json found + valid (fields, burn.theme shape), write access to the workspace and
|
|
137
|
+
its output dirs, flow-file parses, auth descriptor + cached-session freshness, a short HEAD to
|
|
138
|
+
app_url (--offline skips it), backend reachability and login state (when backend_url is set), the
|
|
139
|
+
plugin declarations and lock (same inspection as \`plugins list\`, no plugin code is executed),
|
|
140
|
+
where the viewer was found, and environment settings. The first line is the docsxai version; one
|
|
141
|
+
\`ok:\` or \`fail:\` line per check follows, and the last line names the next command for the
|
|
142
|
+
workspace's state (init --example, add-flow, run or render --open). --format json prints one
|
|
143
|
+
document (schema docsxai/doctor@1). Exit 1 if any line is \`fail:\`.
|
|
120
144
|
• style initialises docs/style.yaml + derived docs/style.json if absent (otherwise validates the
|
|
121
145
|
existing YAML against the schema and rederives the JSON). --check additionally scans every
|
|
122
146
|
docs/<flow>/<step>.md user-facing write-up for jargon leaks against the style's pruning_rules
|
|
123
147
|
(e.g. VERIFY / WAIT / data-testid leaking into user-facing prose). The engine never re-shapes
|
|
124
|
-
prose itself (LLM-agnostic)
|
|
148
|
+
prose itself (LLM-agnostic), the agent does that at calibration time; this command is the
|
|
125
149
|
enforcement layer for the semantic-reshape exit criterion. --format json emits machine-readable
|
|
126
150
|
output for tooling.
|
|
127
151
|
• zip packages the workspace's doc pack into a single archive for hand-off. Includes flows/, docs/,
|
|
128
152
|
.docsxai.json, auth/strategy.yaml (env-var names only, no creds), README.md. Excludes .auth/
|
|
129
|
-
(
|
|
153
|
+
(local session state), **/halts/ (debug screenshots), .viewer/ by default (re-renderable
|
|
130
154
|
from the doc pack; pass --include-viewer to bundle it). Defaults output to <workspace-name>.zip
|
|
131
155
|
in the current dir; override with --out <path>. Zips in-process (no system 'zip' binary needed)
|
|
132
|
-
and deterministically
|
|
156
|
+
and deterministically, sorted entries, fixed mtime, fixed compression, so the same doc pack
|
|
133
157
|
always produces a byte-identical archive.
|
|
134
|
-
• baseline snapshots the doc pack
|
|
135
|
-
docs/locators.yaml
|
|
158
|
+
• baseline snapshots the doc pack, flows/, docs/<flow>/*.md, annotations.json, screenshots/, and
|
|
159
|
+
docs/locators.yaml, into <ws>/.baseline/ (or --out <dir>). Commit the baseline: it's the "before"
|
|
136
160
|
that diff compares against in CI.
|
|
137
161
|
• diff compares the workspace against a baseline (default <ws>/.baseline/, or --against <dir>) and
|
|
138
162
|
emits a deterministic drift report: per flow, step field deltas (id-keyed), annotation moves,
|
|
@@ -141,19 +165,30 @@ Notes:
|
|
|
141
165
|
--fail-on warn|fail exits 1 when the report severity is at/above the threshold (screenshot
|
|
142
166
|
severity: ≥1% changed pixels = warn, ≥5% = fail; structural changes = warn).
|
|
143
167
|
• export playwright emits one self-contained Playwright .spec.ts per flow (extends resolved) into
|
|
144
|
-
<ws>/.export/tests/ (or --out <dir>)
|
|
168
|
+
<ws>/.export/tests/ (or --out <dir>), locators as consts, steps as page actions, success criteria
|
|
145
169
|
as expect() assertions, environment as test.use(); optional steps are try/catch-wrapped. Generated
|
|
146
170
|
files say so in a header: regenerate, don't hand-edit.
|
|
147
171
|
• render builds the static viewer by spawning the docsxai-viewer bin, resolved in order: the
|
|
148
172
|
DOCSX_VIEWER_BIN env var (path to the viewer's bin script), the @docsxai/viewer
|
|
149
|
-
package installed next to the engine, then \`docsxai-viewer\` on PATH.
|
|
173
|
+
package installed next to the engine, then \`docsxai-viewer\` on PATH. --lang sets the language of the
|
|
174
|
+
text the viewer adds, e.g. es or es-ES (default en; a tag with no translation gives en). --open then
|
|
175
|
+
opens .viewer/index.html in the default browser; where none can be opened it prints the path instead.
|
|
150
176
|
• burn bakes each flow's annotations (halo, badge, callout) into copies of its clean screenshots, for
|
|
151
177
|
surfaces that can't run the interactive viewer, via the same viewer bin as render. Reads
|
|
152
178
|
<ws>/docs/<flow>/annotations.json and writes docs/<flow>/burned/<step>.png (or <out>/<flow>/<step>.png
|
|
153
179
|
with --out). --flow limits it to named flows (repeatable); the default is every flow with annotations.
|
|
154
180
|
--report <file> writes a JSON placement report (callout and badge boxes, overlaps, callouts flagged
|
|
155
|
-
unplaceable), resolved under the workspace when relative.
|
|
156
|
-
|
|
181
|
+
unplaceable), resolved under the workspace when relative. The workspace's burn.theme block (.docsxai.json)
|
|
182
|
+
sets the look; see docs/burn-theming.md. --no-connector-outline skips reading the screenshot's pixels: an
|
|
183
|
+
arrow or stem stays plain ink (by default one over a dark part gets a white outline), a themed line keeps
|
|
184
|
+
the callout's outline colour, and no text is estimated from the pixels. A caption with characters the
|
|
185
|
+
font can't draw (Japanese, Arabic, Hebrew, Thai with the bundled Inter) prints a warning naming the
|
|
186
|
+
annotation and script and gets missing_glyphs in the report; --strict-glyphs makes it exit 1.
|
|
187
|
+
• site writes an Astro Starlight docs site project from <ws>/docs and <ws>/flows into --out (default
|
|
188
|
+
<ws>/site), preferring burned images. --build also runs the Astro build into <out>/dist. --title names
|
|
189
|
+
the site (default "Documentation"), --accent sets the accent colour as a hex value, --lang sets the
|
|
190
|
+
site's language (same rule as render), --flow limits it to named flows (repeatable). Runs the viewer's
|
|
191
|
+
\`site\` through the same bin resolution as render; its exit code is the command's.
|
|
157
192
|
• pack builds the screenshot pack a docs site or README ships: it burns each step's annotations into its
|
|
158
193
|
clean screenshot, optimises the PNG losslessly with the external \`oxipng\` binary (on PATH, or
|
|
159
194
|
$DOCSX_OXIPNG_BIN; \`brew install oxipng\`; --no-optimise skips it), names it
|
|
@@ -171,7 +206,7 @@ Notes:
|
|
|
171
206
|
a pass or fail against --threshold (default 0.5). A resized, new or missing variant, or a committed file
|
|
172
207
|
that does not match its name, always fails. Exit 1 on any failure, 2 on a bad argument. The report has no
|
|
173
208
|
timestamps. The old \`docsxai drift\` still works for now: it prints a deprecation warning and runs pack --check.
|
|
174
|
-
• login validates a bearer token against a backend URL
|
|
209
|
+
• login validates a bearer token against a backend URL, hits /v1/health, /v1/workspaces. Reads
|
|
175
210
|
the token from DOCSX_TOKEN env var. Prints what the backend sees if the call succeeds,
|
|
176
211
|
or a clear error if not. Stateless: doesn't store anything; configure the env var in your shell.
|
|
177
212
|
login --oauth <workspace-dir> instead signs in as a person: OAuth 2.1 authorization code + PKCE against
|
|
@@ -182,29 +217,44 @@ Notes:
|
|
|
182
217
|
optionally backend_workspace_id / backend_project_id; created on first push if absent and
|
|
183
218
|
persisted to the config). --kind defaults to "calibrate"; --author defaults to the OS user.
|
|
184
219
|
• pull fetches a revision's artifacts back into the workspace files (default: HEAD). Useful for
|
|
185
|
-
syncing with
|
|
220
|
+
syncing with someone else's edits or rolling back to a named revision.
|
|
186
221
|
• A command that works on a workspace takes its directory as the first argument. Reports and data go to
|
|
187
222
|
stdout; progress lines and warnings go to stderr where a command already splits them. Output has no
|
|
188
223
|
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
|
|
190
|
-
|
|
224
|
+
Exit 0 success, 1 runtime failure, 2 usage error; Ctrl-C prints one line with the command to rerun and
|
|
225
|
+
exits 130. An error no command handled is a bug: it prints one \`docsxai: unexpected error\` line; set
|
|
226
|
+
DOCSX_DEBUG=1 to print its stack trace.
|
|
227
|
+
• --version (or -v) prints \`docsxai <version>\` and exits 0.
|
|
228
|
+
• --format json (lint, flow-tree, diagnose, style, diff, plugins, doctor, run --verify-determinism) is the
|
|
191
229
|
machine-readable output; the text formats are for people and may change.
|
|
192
|
-
• run,
|
|
230
|
+
• run, add-flow, burn, pack, zip, baseline, push, pull and doctor end with one line,
|
|
193
231
|
\`<command>: <result> …\`, naming the counts and where the output went (run --verify-determinism
|
|
194
232
|
ends with its report).
|
|
195
233
|
|
|
196
234
|
Examples:
|
|
197
235
|
docsxai init ~/docsxai/my-app --app-url https://app.example.com
|
|
198
236
|
docsxai capture-auth ~/docsxai/my-app
|
|
199
|
-
docsxai
|
|
237
|
+
docsxai add-flow ~/docsxai/my-app --from login.flow.yaml
|
|
238
|
+
docsxai inspect ~/docsxai/my-app --url https://app.example.com/login
|
|
200
239
|
docsxai run ~/docsxai/my-app --flow login
|
|
201
240
|
docsxai run ~/docsxai/my-app --verify-determinism --runs 3 --format md
|
|
202
241
|
docsxai lint ~/docsxai/my-app --format json
|
|
242
|
+
docsxai flow-tree ~/docsxai/my-app
|
|
243
|
+
docsxai diagnose ~/docsxai/my-app --flow login --step submit
|
|
244
|
+
docsxai style ~/docsxai/my-app --check
|
|
245
|
+
docsxai zip ~/docsxai/my-app --out my-app.zip
|
|
246
|
+
docsxai export adf ~/docsxai/my-app --flow login --mode single
|
|
247
|
+
docsxai export playwright ~/docsxai/my-app --out ./e2e
|
|
248
|
+
docsxai plugins list ~/docsxai/my-app
|
|
249
|
+
docsxai login --backend-url https://docsxai.example.com
|
|
203
250
|
docsxai render ~/docsxai/my-app
|
|
251
|
+
docsxai render ~/docsxai/my-app --lang es
|
|
204
252
|
docsxai burn ~/docsxai/my-app --flow login --out ~/docsxai/my-app/burned
|
|
253
|
+
docsxai site ~/docsxai/my-app --title "Help centre" --build
|
|
205
254
|
docsxai pack ~/docsxai/my-app --out ~/docsxai/my-app/.screens
|
|
206
255
|
docsxai pack ~/docsxai/my-app --check --against ./public/screens
|
|
207
256
|
docsxai baseline ~/docsxai/my-app
|
|
208
257
|
docsxai diff ~/docsxai/my-app --fail-on warn
|
|
209
258
|
docsxai doctor ~/docsxai/my-app
|
|
210
|
-
docsxai push ~/docsxai/my-app --kind run
|
|
259
|
+
docsxai push ~/docsxai/my-app --kind run
|
|
260
|
+
docsxai pull ~/docsxai/my-app --rev r12`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first value flag of `cmd` that `args` gives with no value, with the label its usage error
|
|
3
|
+
* starts with (`export adf` for `export adf <dir>`). `undefined` when every value flag has one.
|
|
4
|
+
*/
|
|
5
|
+
export declare function bareValueFlag(cmd: string, args: string[]): {
|
|
6
|
+
label: string;
|
|
7
|
+
flag: string;
|
|
8
|
+
} | undefined;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// The flags that take a value, per command. One of them given with nothing after it (`zip ws --out`)
|
|
2
|
+
// is a usage error: reading it as a boolean would run the command as if the flag was absent. `run`,
|
|
3
|
+
// `baseline`, `diff` and `pack` check their own flags. Leaf: imports only the flag parser.
|
|
4
|
+
import { flagMissingValue, parseFlags } from "./cli-shared.js";
|
|
5
|
+
const VALUE_FLAGS = {
|
|
6
|
+
init: ["app-url", "auth", "role", "ttl", "capture-trigger", "auth-cookie", "persist"],
|
|
7
|
+
"add-flow": ["from", "name"],
|
|
8
|
+
inspect: ["url", "selector", "cdp", "wait", "wait-for", "role"],
|
|
9
|
+
lint: ["flow", "format"],
|
|
10
|
+
"flow-tree": ["format"],
|
|
11
|
+
diagnose: ["flow", "step", "variant", "cdp", "format"],
|
|
12
|
+
style: ["format"],
|
|
13
|
+
doctor: ["format"],
|
|
14
|
+
zip: ["out"],
|
|
15
|
+
render: ["lang"],
|
|
16
|
+
"export adf": ["flow", "mode", "title", "out"],
|
|
17
|
+
"export playwright": ["flow", "out"],
|
|
18
|
+
login: ["backend-url"],
|
|
19
|
+
push: ["kind", "author"],
|
|
20
|
+
pull: ["rev"],
|
|
21
|
+
"capture-auth": ["base-url", "role", "auth-cookie", "cdp"],
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The first value flag of `cmd` that `args` gives with no value, with the label its usage error
|
|
25
|
+
* starts with (`export adf` for `export adf <dir>`). `undefined` when every value flag has one.
|
|
26
|
+
*/
|
|
27
|
+
export function bareValueFlag(cmd, args) {
|
|
28
|
+
const label = cmd === "export" ? `export ${args[0] ?? ""}` : cmd;
|
|
29
|
+
if (!Object.hasOwn(VALUE_FLAGS, label))
|
|
30
|
+
return undefined;
|
|
31
|
+
const names = VALUE_FLAGS[label];
|
|
32
|
+
const flag = flagMissingValue(parseFlags(args).flags, names);
|
|
33
|
+
return flag === undefined ? undefined : { label, flag };
|
|
34
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The version in the engine's `package.json`, or `unknown` when it can't be read. */
|
|
2
|
+
export declare function engineVersion(): string;
|
|
3
|
+
/** The flags that print the version. */
|
|
4
|
+
export declare const VERSION_FLAGS: readonly string[];
|
|
5
|
+
/** Print `docsxai <version>` when `cmd` asks for it. Returns exit code 0, or `undefined` otherwise. */
|
|
6
|
+
export declare function tryVersion(cmd: string | undefined): number | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// `docsxai --version` / `-v`: the engine's package version. `package.json` sits one level above
|
|
2
|
+
// both `src/` and `dist/`, so the same relative URL works from source and from the build.
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
/** The version in the engine's `package.json`, or `unknown` when it can't be read. */
|
|
5
|
+
export function engineVersion() {
|
|
6
|
+
try {
|
|
7
|
+
const raw = readFileSync(new URL("../package.json", import.meta.url), "utf8");
|
|
8
|
+
const { version } = JSON.parse(raw);
|
|
9
|
+
if (typeof version === "string")
|
|
10
|
+
return version;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
// fall through
|
|
14
|
+
}
|
|
15
|
+
return "unknown";
|
|
16
|
+
}
|
|
17
|
+
/** The flags that print the version. */
|
|
18
|
+
export const VERSION_FLAGS = ["--version", "-v"];
|
|
19
|
+
/** Print `docsxai <version>` when `cmd` asks for it. Returns exit code 0, or `undefined` otherwise. */
|
|
20
|
+
export function tryVersion(cmd) {
|
|
21
|
+
if (cmd === undefined || !VERSION_FLAGS.includes(cmd))
|
|
22
|
+
return undefined;
|
|
23
|
+
process.stdout.write(`docsxai ${engineVersion()}\n`);
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,46 +1,71 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// `docsxai
|
|
2
|
+
// `docsxai`: the deterministic CLI. The plugin's commands wrap this; calibration runs in an agent
|
|
3
3
|
// context and is exposed by the plugin, not here.
|
|
4
4
|
//
|
|
5
5
|
// Barrel / dispatch: the command bodies live in flat siblings, grouped by cohesion. This file parses
|
|
6
6
|
// argv, routes the subcommand to its handler, and re-exports `main` so `./cli.js` callers (the bin,
|
|
7
7
|
// the colocated tests) are unchanged. The clusters import shared helpers from cli-shared.ts (a leaf)
|
|
8
|
-
// and the help text from cli-usage.ts
|
|
9
|
-
// • cli-usage.ts
|
|
10
|
-
// • cli-
|
|
11
|
-
// • cli-
|
|
12
|
-
// • cli-
|
|
13
|
-
// • cli-commands-
|
|
14
|
-
// • cli-commands-
|
|
15
|
-
// • cli-commands-
|
|
16
|
-
|
|
8
|
+
// and the help text from cli-usage.ts, no cluster imports back from here, so there's no cycle.
|
|
9
|
+
// • cli-usage.ts: the USAGE help-text constant
|
|
10
|
+
// • cli-help.ts: help screens, per-command help and "did you mean"
|
|
11
|
+
// • cli-version.ts: --version / -v
|
|
12
|
+
// • cli-shared.ts: parseFlags + listFlowFiles (the shared leaf)
|
|
13
|
+
// • cli-commands-init.ts: init (scaffolding, --example)
|
|
14
|
+
// • cli-commands-session.ts: add-flow / run (live-browser)
|
|
15
|
+
// • cli-commands-auth.ts: capture-auth
|
|
16
|
+
// • cli-commands-authoring.ts: inspect / lint / flow-tree / diagnose (calibration aids)
|
|
17
|
+
// • cli-commands-style.ts: style (docs/style.yaml + the jargon check)
|
|
18
|
+
// • cli-commands-docpack.ts: render / zip / export / baseline / diff (doc-pack ops)
|
|
19
|
+
// • cli-commands-pack.ts: pack / pack --check (screenshot pack + drift check, run by the viewer bin)
|
|
20
|
+
// • cli-commands-site.ts: site (Starlight docs site, run by the viewer bin)
|
|
21
|
+
// • cli-commands-backend.ts: login / push / pull / plugins (backend + sync)
|
|
22
|
+
import "./cli-node-guard.js";
|
|
17
23
|
import { runDoctor } from "./doctor.js";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
24
|
+
import { tryHelp, unknownCommand } from "./cli-help.js";
|
|
25
|
+
import { tryVersion } from "./cli-version.js";
|
|
26
|
+
import { usageError } from "./cli-messages.js";
|
|
27
|
+
import { bareValueFlag } from "./cli-value-flags.js";
|
|
28
|
+
import { runAsBin } from "./cli-unexpected.js";
|
|
29
|
+
import { isMainModule } from "./main-module.js";
|
|
30
|
+
import { cmdCaptureAuth } from "./cli-commands-auth.js";
|
|
31
|
+
import { cmdAddFlow, cmdRun } from "./cli-commands-session.js";
|
|
32
|
+
import { cmdInit } from "./cli-commands-init.js";
|
|
33
|
+
import { cmdDiagnose, cmdFlowTree, cmdInspect, cmdLint } from "./cli-commands-authoring.js";
|
|
34
|
+
import { cmdStyle } from "./cli-commands-style.js";
|
|
21
35
|
import { cmdBaseline, cmdBurn, cmdDiff, cmdExport, cmdRender, cmdZip, } from "./cli-commands-docpack.js";
|
|
22
36
|
import { cmdLogin, cmdPlugins, cmdPull, cmdPush } from "./cli-commands-backend.js";
|
|
23
37
|
import { cmdPack } from "./cli-commands-pack.js";
|
|
38
|
+
import { cmdSite } from "./cli-commands-site.js";
|
|
24
39
|
import { RETIRED_COMMANDS } from "./cli-retired.js";
|
|
25
40
|
import { findRetired, warnDeprecated } from "./deprecation.js";
|
|
41
|
+
// The bins wrap `main` in this, so an error no command handled prints one line, not a stack.
|
|
42
|
+
export { runAsBin };
|
|
26
43
|
export async function main(argv) {
|
|
27
44
|
const [cmd, ...rest] = argv;
|
|
45
|
+
const version = tryVersion(cmd);
|
|
46
|
+
if (version !== undefined)
|
|
47
|
+
return version;
|
|
28
48
|
const retired = cmd === undefined ? undefined : findRetired(RETIRED_COMMANDS, cmd);
|
|
29
49
|
if (retired) {
|
|
30
50
|
warnDeprecated(`the ${cmd} command`, retired);
|
|
31
51
|
return main(retired.rewrite(rest));
|
|
32
52
|
}
|
|
53
|
+
const helped = tryHelp(cmd, rest);
|
|
54
|
+
if (helped !== undefined)
|
|
55
|
+
return helped;
|
|
56
|
+
const bare = cmd === undefined ? undefined : bareValueFlag(cmd, rest);
|
|
57
|
+
if (bare)
|
|
58
|
+
return usageError(bare.label, `--${bare.flag} needs a value`);
|
|
33
59
|
switch (cmd) {
|
|
34
60
|
case undefined:
|
|
35
61
|
case "--help":
|
|
36
62
|
case "-h":
|
|
37
63
|
case "help":
|
|
38
|
-
process.stdout.write(USAGE + "\n");
|
|
39
64
|
return 0;
|
|
40
65
|
case "init":
|
|
41
66
|
return cmdInit(rest);
|
|
42
|
-
case "
|
|
43
|
-
return
|
|
67
|
+
case "add-flow":
|
|
68
|
+
return cmdAddFlow(rest);
|
|
44
69
|
case "inspect":
|
|
45
70
|
return cmdInspect(rest);
|
|
46
71
|
case "run":
|
|
@@ -49,6 +74,8 @@ export async function main(argv) {
|
|
|
49
74
|
return cmdRender(rest);
|
|
50
75
|
case "burn":
|
|
51
76
|
return cmdBurn(rest);
|
|
77
|
+
case "site":
|
|
78
|
+
return cmdSite(rest);
|
|
52
79
|
case "pack":
|
|
53
80
|
return cmdPack(rest);
|
|
54
81
|
case "capture-auth":
|
|
@@ -80,11 +107,10 @@ export async function main(argv) {
|
|
|
80
107
|
case "pull":
|
|
81
108
|
return cmdPull(rest);
|
|
82
109
|
default:
|
|
83
|
-
|
|
84
|
-
return 2;
|
|
110
|
+
return unknownCommand(cmd);
|
|
85
111
|
}
|
|
86
112
|
}
|
|
87
113
|
// Run as the bin entry, but not when imported (e.g. in tests).
|
|
88
|
-
if (
|
|
89
|
-
void main
|
|
114
|
+
if (isMainModule(import.meta.url, process.argv[1])) {
|
|
115
|
+
void runAsBin(main, process.argv.slice(2)).then((code) => process.exit(code));
|
|
90
116
|
}
|
package/dist/deprecation.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface RetiredEntry {
|
|
|
5
5
|
replacement?: string;
|
|
6
6
|
/** One extra clause, for example why. */
|
|
7
7
|
note?: string;
|
|
8
|
+
/** The whole warning after `docsxai: `, for a plain rename. Replaces the built line. */
|
|
9
|
+
message?: string;
|
|
8
10
|
}
|
|
9
11
|
/** The warning line (without a trailing newline) for a retired `item`. */
|
|
10
12
|
export declare function deprecationMessage(item: string, entry: RetiredEntry): string;
|
package/dist/deprecation.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// An unknown input is not here: it is a typo and stays a loud error.
|
|
7
7
|
/** The warning line (without a trailing newline) for a retired `item`. */
|
|
8
8
|
export function deprecationMessage(item, entry) {
|
|
9
|
+
if (entry.message)
|
|
10
|
+
return `docsxai: ${entry.message}`;
|
|
9
11
|
const use = entry.replacement ? `, use ${entry.replacement}` : "";
|
|
10
12
|
const note = entry.note ? ` (${entry.note})` : "";
|
|
11
13
|
return `docsxai: ${item} is deprecated since ${entry.since}${use}${note}`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const DEVICE_SCALE_FACTOR_ENV = "DOCSX_DEVICE_SCALE_FACTOR";
|
|
2
|
+
export declare const MIN_DEVICE_SCALE_FACTOR = 1;
|
|
3
|
+
export declare const MAX_DEVICE_SCALE_FACTOR = 4;
|
|
4
|
+
/** A whole number or one with a single decimal, from 1 to 4. `undefined` for anything else. */
|
|
5
|
+
export declare function parseDeviceScaleFactor(raw: string): number | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* The factor a run uses: the flag when given, else the variable (empty counts as unset), else
|
|
8
|
+
* `undefined` (the browser default of 1). With `cdp` the variable is ignored and the flag is an error. A bad value is an `error` that names its source.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveDeviceScaleFactor(flagValue: string | boolean | undefined, env: NodeJS.ProcessEnv, cdp?: boolean): {
|
|
11
|
+
factor: number | undefined;
|
|
12
|
+
} | {
|
|
13
|
+
error: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The device scale factor of a `docsxai run`: `--device-scale-factor <1-4>` or, when the flag is
|
|
2
|
+
// absent, the DOCSX_DEVICE_SCALE_FACTOR variable. Leaf module, no imports.
|
|
3
|
+
export const DEVICE_SCALE_FACTOR_ENV = "DOCSX_DEVICE_SCALE_FACTOR";
|
|
4
|
+
export const MIN_DEVICE_SCALE_FACTOR = 1;
|
|
5
|
+
export const MAX_DEVICE_SCALE_FACTOR = 4;
|
|
6
|
+
/** A whole number or one with a single decimal, from 1 to 4. `undefined` for anything else. */
|
|
7
|
+
export function parseDeviceScaleFactor(raw) {
|
|
8
|
+
if (!/^\d(\.\d)?$/.test(raw))
|
|
9
|
+
return undefined;
|
|
10
|
+
const n = Number(raw);
|
|
11
|
+
return n >= MIN_DEVICE_SCALE_FACTOR && n <= MAX_DEVICE_SCALE_FACTOR ? n : undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The factor a run uses: the flag when given, else the variable (empty counts as unset), else
|
|
15
|
+
* `undefined` (the browser default of 1). With `cdp` the variable is ignored and the flag is an error. A bad value is an `error` that names its source.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveDeviceScaleFactor(flagValue, env, cdp = false) {
|
|
18
|
+
const flag = typeof flagValue === "string" ? flagValue : undefined;
|
|
19
|
+
const fromEnv = flag === undefined && env[DEVICE_SCALE_FACTOR_ENV] ? env[DEVICE_SCALE_FACTOR_ENV] : undefined;
|
|
20
|
+
const raw = flag ?? fromEnv;
|
|
21
|
+
if (raw === undefined)
|
|
22
|
+
return { factor: undefined };
|
|
23
|
+
// An attached browser owns its scale: the flag cannot apply, and the variable is left unused.
|
|
24
|
+
if (cdp) {
|
|
25
|
+
return flag === undefined
|
|
26
|
+
? { factor: undefined }
|
|
27
|
+
: {
|
|
28
|
+
error: "--device-scale-factor cannot be combined with --cdp, the attached browser owns its scale",
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const factor = parseDeviceScaleFactor(raw);
|
|
32
|
+
if (factor !== undefined)
|
|
33
|
+
return { factor };
|
|
34
|
+
const source = flag !== undefined ? "--device-scale-factor" : DEVICE_SCALE_FACTOR_ENV;
|
|
35
|
+
return {
|
|
36
|
+
error: `${source} must be 1 to 4, a whole number or one with one decimal such as 1.5 (got "${raw}")`,
|
|
37
|
+
};
|
|
38
|
+
}
|