@docsxai/engine 0.3.0-rc.3 → 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 +44 -34
- 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 +4 -4
- 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 +24 -3
- 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 +30 -0
- package/dist/cli-messages.js +97 -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 +12 -2
- package/dist/cli-unexpected.js +50 -4
- package/dist/cli-usage.d.ts +1 -1
- package/dist/cli-usage.js +115 -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 +1 -0
- package/dist/cli.js +42 -19
- 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 +94 -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/doctor-checks.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
// `docsxai doctor
|
|
1
|
+
// `docsxai doctor`: the per-check probe catalogue.
|
|
2
2
|
//
|
|
3
3
|
// One pure(ish) function per row of the doctor checklist, each over injectable inputs (a workspace
|
|
4
4
|
// dir, an env source, a fake backend, a mocked chromium probe) so per-state coverage is cheap.
|
|
5
5
|
// `doctor.ts` orchestrates these into the printed checklist. Pure inspection throughout: no flow
|
|
6
|
-
// runs, no plugin code execution, no browser launch
|
|
7
|
-
// the configured backend's /v1/health.
|
|
6
|
+
// runs, no plugin code execution, no browser launch. The network touches are the opt-in GET of
|
|
7
|
+
// the configured backend's /v1/health here and the `app_url` HEAD in ./doctor-checks-config.js.
|
|
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
|
+
import { redactUrl, redactUrlsIn, shellQuote } from "./cli-messages.js";
|
|
12
12
|
import { EGRESS_DENY_PRIVATE_ENV, EGRESS_GUARD_ENV, envFlagOff, envFlagOn, } from "./egress-guard.js";
|
|
13
13
|
import { FlowFileError, parseFlowFile } from "./flow-file.js";
|
|
14
14
|
import { chromiumExecutablePath } from "./playwright-driver.js";
|
|
15
15
|
import { resolveViewerBin, VIEWER_BIN_ENV, VIEWER_BIN_NAME, VIEWER_PACKAGE } from "./viewer-bin.js";
|
|
16
16
|
import { resolveWorkspacePath, WORKSPACE_CONFIG_FILE } from "./workspace.js";
|
|
17
|
-
const CHROMIUM_FIX = "npx playwright-core install chromium
|
|
17
|
+
const CHROMIUM_FIX = "npx playwright-core install chromium";
|
|
18
18
|
/** Layer-3 default probe: does playwright-core have a cached Chromium binary?
|
|
19
19
|
* Synchronous - the sole work is the sanctioned `chromiumExecutablePath()`
|
|
20
20
|
* helper (a sync `executablePath()` + `existsSync`), no IO to await. */
|
|
21
21
|
export function probeChromium() {
|
|
22
22
|
try {
|
|
23
|
-
// Goes through playwright-driver's helper
|
|
23
|
+
// Goes through playwright-driver's helper, the one sanctioned playwright-core entry point,
|
|
24
24
|
// so doctor doesn't open a second import site for the SDK.
|
|
25
25
|
const p = chromiumExecutablePath();
|
|
26
26
|
if (p)
|
|
@@ -50,7 +50,7 @@ export function checkNode(nodeVersion) {
|
|
|
50
50
|
return {
|
|
51
51
|
name: "node",
|
|
52
52
|
ok: false,
|
|
53
|
-
detail: `v${nodeVersion}
|
|
53
|
+
detail: `v${nodeVersion}, the engine requires Node >= 26`,
|
|
54
54
|
fix: "upgrade Node (https://nodejs.org); the engine's `engines` field pins >= 26",
|
|
55
55
|
};
|
|
56
56
|
}
|
|
@@ -60,10 +60,32 @@ export async function checkChromium(probe) {
|
|
|
60
60
|
? { name: "chromium", ok: true, detail: r.detail }
|
|
61
61
|
: { name: "chromium", ok: false, detail: r.detail, fix: CHROMIUM_FIX };
|
|
62
62
|
}
|
|
63
|
+
/** The workspace row when the path, or the config file in it, cannot be used as given. */
|
|
64
|
+
function unusableWorkspace(detail, fix, present) {
|
|
65
|
+
return { check: { name: "workspace", ok: false, detail, fix }, config: null, present };
|
|
66
|
+
}
|
|
67
|
+
const JSON_KINDS = (v) => v === null ? "null" : Array.isArray(v) ? "an array" : `a ${typeof v}`;
|
|
63
68
|
export async function checkWorkspace(workspaceDir) {
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
69
|
+
const root = path.resolve(workspaceDir);
|
|
70
|
+
const configPath = path.join(root, WORKSPACE_CONFIG_FILE);
|
|
71
|
+
const dir = await fs.stat(root).catch(() => null);
|
|
72
|
+
if (!dir) {
|
|
73
|
+
return unusableWorkspace(`workspace directory ${workspaceDir} does not exist`, `docsxai init ${shellQuote(workspaceDir)} --app-url <url>, or fix the path`, false);
|
|
74
|
+
}
|
|
75
|
+
if (!dir.isDirectory()) {
|
|
76
|
+
return unusableWorkspace(`workspace path ${workspaceDir} is a file, not a directory`, "pass the workspace directory, or docsxai init <new-dir> --app-url <url>", false);
|
|
77
|
+
}
|
|
78
|
+
let text = null;
|
|
79
|
+
try {
|
|
80
|
+
text = await fs.readFile(configPath, "utf8");
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
const code = e.code;
|
|
84
|
+
if (code !== "ENOENT" && code !== "ENOTDIR") {
|
|
85
|
+
return unusableWorkspace(`${configPath} cannot be read (${code ?? e.message})`, `chmod u+r ${shellQuote(configPath)}`, true);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const flowsDirExists = existsSync(path.join(root, "flows"));
|
|
67
89
|
if (text === null) {
|
|
68
90
|
return {
|
|
69
91
|
check: {
|
|
@@ -71,8 +93,9 @@ export async function checkWorkspace(workspaceDir) {
|
|
|
71
93
|
ok: true,
|
|
72
94
|
info: true,
|
|
73
95
|
detail: flowsDirExists
|
|
74
|
-
? `flows/ present but no ${WORKSPACE_CONFIG_FILE} at ${workspaceDir}
|
|
75
|
-
: `no ${WORKSPACE_CONFIG_FILE} at ${workspaceDir}
|
|
96
|
+
? `flows/ present but no ${WORKSPACE_CONFIG_FILE} at ${workspaceDir}, \`docsxai init\` writes one`
|
|
97
|
+
: `no ${WORKSPACE_CONFIG_FILE} at ${workspaceDir}, not a docsxai workspace (pass <workspace-dir> or run doctor from one); workspace checks skipped`,
|
|
98
|
+
fix: `docsxai init ${shellQuote(workspaceDir)} --app-url <url>, or run doctor with a workspace dir`,
|
|
76
99
|
},
|
|
77
100
|
config: null,
|
|
78
101
|
present: flowsDirExists,
|
|
@@ -83,29 +106,14 @@ export async function checkWorkspace(workspaceDir) {
|
|
|
83
106
|
raw = JSON.parse(text);
|
|
84
107
|
}
|
|
85
108
|
catch (e) {
|
|
86
|
-
return {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
detail: `${configPath} is not valid JSON: ${e.message}`,
|
|
91
|
-
fix: `fix the JSON (or re-scaffold with \`docsxai init ${shellQuote(workspaceDir)} --force\`)`,
|
|
92
|
-
},
|
|
93
|
-
config: null,
|
|
94
|
-
present: true,
|
|
95
|
-
};
|
|
109
|
+
return unusableWorkspace(`${configPath} is not valid JSON: ${e.message}`, `fix the JSON syntax in ${WORKSPACE_CONFIG_FILE} at the position above`, true);
|
|
110
|
+
}
|
|
111
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
112
|
+
return unusableWorkspace(`${configPath} holds ${JSON_KINDS(raw)}, not a JSON object`, `make ${WORKSPACE_CONFIG_FILE} an object that starts with "schema": "docsxai/workspace@1"`, true);
|
|
96
113
|
}
|
|
97
114
|
const cfg = raw;
|
|
98
|
-
if (cfg
|
|
99
|
-
return {
|
|
100
|
-
check: {
|
|
101
|
-
name: "workspace",
|
|
102
|
-
ok: false,
|
|
103
|
-
detail: `${configPath} has schema "${String(cfg?.schema)}" — expected "docsxai/workspace@1"`,
|
|
104
|
-
fix: `set "schema": "docsxai/workspace@1" (or re-scaffold with \`docsxai init\`)`,
|
|
105
|
-
},
|
|
106
|
-
config: null,
|
|
107
|
-
present: true,
|
|
108
|
-
};
|
|
115
|
+
if (cfg.schema !== "docsxai/workspace@1") {
|
|
116
|
+
return unusableWorkspace(`${configPath} has schema "${String(cfg.schema)}", expected "docsxai/workspace@1"`, `set "schema": "docsxai/workspace@1" (or re-scaffold with \`docsxai init\`)`, true);
|
|
109
117
|
}
|
|
110
118
|
const appUrl = typeof cfg.app_url === "string" ? cfg.app_url : undefined;
|
|
111
119
|
return {
|
|
@@ -129,7 +137,7 @@ export async function checkFlows(workspaceDir) {
|
|
|
129
137
|
name: "flows",
|
|
130
138
|
ok: false,
|
|
131
139
|
detail: `no flows/ directory at ${flowsDir}`,
|
|
132
|
-
fix:
|
|
140
|
+
fix: `mkdir ${shellQuote(flowsDir)}, then docsxai add-flow ${shellQuote(workspaceDir)} --from <flow.yaml>`,
|
|
133
141
|
};
|
|
134
142
|
}
|
|
135
143
|
if (entries.length === 0) {
|
|
@@ -137,7 +145,7 @@ export async function checkFlows(workspaceDir) {
|
|
|
137
145
|
name: "flows",
|
|
138
146
|
ok: true,
|
|
139
147
|
info: true,
|
|
140
|
-
detail: "flows/ is empty
|
|
148
|
+
detail: "flows/ is empty, add one with add-flow, or hand-author flows/<name>.flow.yaml",
|
|
141
149
|
};
|
|
142
150
|
}
|
|
143
151
|
for (const entry of entries) {
|
|
@@ -170,7 +178,7 @@ export async function checkAuth(workspaceDir, now) {
|
|
|
170
178
|
name: "auth",
|
|
171
179
|
ok: true,
|
|
172
180
|
info: true,
|
|
173
|
-
detail: "no auth/strategy.yaml
|
|
181
|
+
detail: "no auth/strategy.yaml, flows run with a fresh, unauthenticated context",
|
|
174
182
|
},
|
|
175
183
|
];
|
|
176
184
|
}
|
|
@@ -194,7 +202,7 @@ export async function checkAuth(workspaceDir, now) {
|
|
|
194
202
|
{
|
|
195
203
|
name: "auth",
|
|
196
204
|
ok: true,
|
|
197
|
-
detail: `auth/strategy.yaml ok
|
|
205
|
+
detail: `auth/strategy.yaml ok, role(s) ${roles} (default "${role}", strategy ${descriptor.roles[role].strategy})`,
|
|
198
206
|
},
|
|
199
207
|
];
|
|
200
208
|
// Cached-session freshness for the default role (the one `run` loads).
|
|
@@ -205,7 +213,7 @@ export async function checkAuth(workspaceDir, now) {
|
|
|
205
213
|
name: "auth",
|
|
206
214
|
ok: true,
|
|
207
215
|
info: true,
|
|
208
|
-
detail: `no cached session for role "${role}"
|
|
216
|
+
detail: `no cached session for role "${role}", \`docsxai capture-auth ${shellQuote(workspaceDir)}\` before \`run\``,
|
|
209
217
|
});
|
|
210
218
|
return checks;
|
|
211
219
|
}
|
|
@@ -249,74 +257,64 @@ export async function checkBackend(workspaceDir, config, env, fetchImpl) {
|
|
|
249
257
|
name: "backend",
|
|
250
258
|
ok: true,
|
|
251
259
|
info: true,
|
|
252
|
-
detail: "no backend_url configured
|
|
260
|
+
detail: "no backend_url configured, the workspace operates fully locally",
|
|
253
261
|
};
|
|
254
262
|
}
|
|
255
|
-
// Token presence is a note, not a gate
|
|
263
|
+
// Token presence is a note, not a gate, /v1/health is unauthenticated.
|
|
256
264
|
const tokenNote = env.DOCSX_TOKEN
|
|
257
265
|
? "token: DOCSX_TOKEN set"
|
|
258
266
|
: existsSync(path.join(path.resolve(workspaceDir), ".auth", "backend-token.json"))
|
|
259
267
|
? "token: OAuth tokens at .auth/backend-token.json"
|
|
260
|
-
: "no token
|
|
268
|
+
: "no token, push/pull need DOCSX_TOKEN or `docsxai login --oauth`";
|
|
261
269
|
const base = backendUrl.replace(/\/+$/, "");
|
|
270
|
+
const shown = redactUrl(base);
|
|
262
271
|
try {
|
|
263
272
|
const res = await fetchImpl(`${base}/v1/health`, { signal: AbortSignal.timeout(2000) });
|
|
264
273
|
if (!res.ok) {
|
|
265
274
|
return {
|
|
266
275
|
name: "backend",
|
|
267
276
|
ok: false,
|
|
268
|
-
detail: `${
|
|
269
|
-
fix: "the backend answered but is unhealthy
|
|
277
|
+
detail: `${shown}/v1/health → HTTP ${res.status}`,
|
|
278
|
+
fix: "the backend answered but is unhealthy, try again, then contact whoever runs it",
|
|
270
279
|
};
|
|
271
280
|
}
|
|
272
|
-
return { name: "backend", ok: true, detail: `${
|
|
281
|
+
return { name: "backend", ok: true, detail: `${shown}/v1/health ok (${tokenNote})` };
|
|
273
282
|
}
|
|
274
283
|
catch (e) {
|
|
275
284
|
return {
|
|
276
285
|
name: "backend",
|
|
277
286
|
ok: false,
|
|
278
|
-
detail: `${
|
|
287
|
+
detail: `${shown}/v1/health unreachable (${redactUrlsIn(e.message)})`,
|
|
279
288
|
fix: "start the backend (or fix backend_url in .docsxai.json)",
|
|
280
289
|
};
|
|
281
290
|
}
|
|
282
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* The viewer row. It names the path that resolved, never the variable or lookup order: the
|
|
294
|
+
* `docsxai` bin sets the variable itself, so naming it would show users a setting they never made.
|
|
295
|
+
*/
|
|
283
296
|
export async function checkViewer(env, resolveFrom) {
|
|
284
297
|
const resolution = await resolveViewerBin({
|
|
285
298
|
env: env,
|
|
286
299
|
...(resolveFrom ? { resolveFrom } : {}),
|
|
287
300
|
});
|
|
288
|
-
if (resolution.source === "env") {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
ok: true,
|
|
292
|
-
detail: `$${VIEWER_BIN_ENV} → ${resolution.prefixArgs[0] ?? resolution.command} (layer 1: env override)`,
|
|
293
|
-
};
|
|
301
|
+
if (resolution.source === "env" || resolution.source === "package") {
|
|
302
|
+
const found = resolution.prefixArgs[0] ?? resolution.command;
|
|
303
|
+
return { name: "viewer", ok: true, detail: `found at ${found}` };
|
|
294
304
|
}
|
|
295
|
-
|
|
296
|
-
return {
|
|
297
|
-
name: "viewer",
|
|
298
|
-
ok: true,
|
|
299
|
-
detail: `${VIEWER_PACKAGE} installed next to the engine → ${resolution.prefixArgs[0]} (layer 2: installed package)`,
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
// Layer 3 is "trust PATH" — resolveViewerBin doesn't verify it, so doctor does.
|
|
305
|
+
// The PATH lookup is "trust PATH": resolveViewerBin doesn't verify it, so doctor does.
|
|
303
306
|
for (const dir of (env.PATH ?? "").split(path.delimiter)) {
|
|
304
307
|
if (!dir)
|
|
305
308
|
continue;
|
|
306
309
|
const candidate = path.join(dir, VIEWER_BIN_NAME);
|
|
307
|
-
if (existsSync(candidate))
|
|
308
|
-
return {
|
|
309
|
-
name: "viewer",
|
|
310
|
-
ok: true,
|
|
311
|
-
detail: `\`${VIEWER_BIN_NAME}\` on PATH → ${candidate} (layer 3: PATH)`,
|
|
312
|
-
};
|
|
313
|
-
}
|
|
310
|
+
if (existsSync(candidate))
|
|
311
|
+
return { name: "viewer", ok: true, detail: `found at ${candidate}` };
|
|
314
312
|
}
|
|
315
313
|
return {
|
|
316
314
|
name: "viewer",
|
|
317
315
|
ok: false,
|
|
318
|
-
detail:
|
|
319
|
-
fix: `install
|
|
316
|
+
detail: "not found",
|
|
317
|
+
fix: `npm install -g docsxai@next (it ships the viewer), or add ${VIEWER_PACKAGE} next to the engine`,
|
|
320
318
|
};
|
|
321
319
|
}
|
|
322
320
|
/** DOCSX_* env vars the docsxai packages read (engine, viewer, backend + mcp). */
|
|
@@ -328,12 +326,17 @@ export const KNOWN_DOCSX_ENV_VARS = [
|
|
|
328
326
|
"DOCSX_DATA_DIR",
|
|
329
327
|
"DOCSX_OAUTH_AUTO_APPROVE",
|
|
330
328
|
"DOCSX_WEBHOOK_SECRET",
|
|
329
|
+
"DOCSX_BACKEND_PLUGIN_DIRS",
|
|
330
|
+
"DOCSX_BACKEND_PUBLISHER_ORIGINS",
|
|
331
|
+
"DOCSX_BACKEND_PUBLISHER_ENV",
|
|
332
|
+
"DOCSX_OAUTH_REFRESH_TTL_DAYS",
|
|
331
333
|
"DOCSX_OXIPNG_BIN",
|
|
332
334
|
"DOCSX_BACKEND_DENY_PRIVATE_APP_URL",
|
|
333
335
|
"DOCSX_EGRESS_GUARD",
|
|
334
336
|
"DOCSX_EGRESS_DENY_PRIVATE",
|
|
335
337
|
"DOCSX_MCP_TOKEN",
|
|
336
338
|
"DOCSX_DEBUG",
|
|
339
|
+
"DOCSX_DEVICE_SCALE_FACTOR",
|
|
337
340
|
];
|
|
338
341
|
/** On/off switches: `1`, `true` or `yes` turns one on; anything else non-empty, `0`/`false`/`no` aside, is read as off. */
|
|
339
342
|
const FLAG_ENV_VARS = [
|
|
@@ -341,6 +344,8 @@ const FLAG_ENV_VARS = [
|
|
|
341
344
|
EGRESS_GUARD_ENV,
|
|
342
345
|
EGRESS_DENY_PRIVATE_ENV,
|
|
343
346
|
];
|
|
347
|
+
/** Server-side switch: a doctor row never prints its name to a user. */
|
|
348
|
+
const OPERATOR_ONLY_FLAG_ENV_VARS = ["DOCSX_BACKEND_DENY_PRIVATE_APP_URL"];
|
|
344
349
|
function misspelledFlags(env) {
|
|
345
350
|
return FLAG_ENV_VARS.filter((k) => {
|
|
346
351
|
const v = env[k];
|
|
@@ -348,23 +353,32 @@ function misspelledFlags(env) {
|
|
|
348
353
|
}).map((k) => ({
|
|
349
354
|
name: "env",
|
|
350
355
|
ok: false,
|
|
351
|
-
detail: `${k}=${JSON.stringify(env[k])} is not an on/off value, so the switch is off`,
|
|
356
|
+
detail: `${OPERATOR_ONLY_FLAG_ENV_VARS.includes(k) ? "a backend switch" : k}=${JSON.stringify(env[k])} is not an on/off value, so the switch is off`,
|
|
352
357
|
fix: "use 1, true or yes to turn it on, or unset it",
|
|
353
358
|
}));
|
|
354
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* The env rows. A passing row counts the recognised variables and names none of them; the viewer
|
|
362
|
+
* bin variable is left out because the `docsxai` bin sets it. A failing row names the one variable
|
|
363
|
+
* the user set wrong, since that is what they have to fix.
|
|
364
|
+
*/
|
|
355
365
|
export function checkEnv(env) {
|
|
356
366
|
const set = Object.keys(env)
|
|
357
367
|
.filter((k) => k.startsWith("DOCSX_"))
|
|
358
368
|
.sort();
|
|
359
|
-
|
|
360
|
-
return [
|
|
361
|
-
{ name: "env", ok: true, info: true, detail: "no DOCSX_* variables set (defaults apply)" },
|
|
362
|
-
];
|
|
363
|
-
}
|
|
369
|
+
const counted = set.filter((k) => KNOWN_DOCSX_ENV_VARS.includes(k) && k !== VIEWER_BIN_ENV);
|
|
364
370
|
const checks = [];
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
371
|
+
if (counted.length === 0 && set.every((k) => KNOWN_DOCSX_ENV_VARS.includes(k))) {
|
|
372
|
+
checks.push({
|
|
373
|
+
name: "env",
|
|
374
|
+
ok: true,
|
|
375
|
+
info: true,
|
|
376
|
+
detail: "no docsxai variables set, defaults apply",
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
else if (counted.length > 0) {
|
|
380
|
+
const noun = counted.length === 1 ? "variable" : "variables";
|
|
381
|
+
checks.push({ name: "env", ok: true, detail: `${counted.length} docsxai ${noun} set` });
|
|
368
382
|
}
|
|
369
383
|
checks.push(...misspelledFlags(env));
|
|
370
384
|
const cacheKey = env.DOCSX_CACHE_KEY;
|
|
@@ -380,12 +394,13 @@ export function checkEnv(env) {
|
|
|
380
394
|
}
|
|
381
395
|
}
|
|
382
396
|
for (const k of set) {
|
|
383
|
-
|
|
397
|
+
// `DOCSX_WEBHOOK_SECRET_<SUFFIX>` names a per-project webhook secret.
|
|
398
|
+
if (!KNOWN_DOCSX_ENV_VARS.includes(k) && !k.startsWith("DOCSX_WEBHOOK_SECRET_")) {
|
|
384
399
|
checks.push({
|
|
385
400
|
name: "env",
|
|
386
401
|
ok: false,
|
|
387
402
|
detail: `${k} is not a DOCSX_* variable any docsxai package reads (typo?)`,
|
|
388
|
-
fix:
|
|
403
|
+
fix: "unset it or fix the spelling (the CLI reference lists the names)",
|
|
389
404
|
});
|
|
390
405
|
}
|
|
391
406
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The next command for the workspace at `workspaceDir`. `dirArg` is the directory the user typed,
|
|
3
|
+
* or `undefined` when doctor ran in the current directory; the command repeats it as typed.
|
|
4
|
+
*/
|
|
5
|
+
export declare function doctorNextStep(dirArg: string | undefined, workspaceDir: string): Promise<string>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// The command `docsxai doctor` suggests after a passing check list, read from the workspace's
|
|
2
|
+
// state: no workspace, then init --example; no flow, then add-flow; nothing captured, then run;
|
|
3
|
+
// annotations present, then render --open.
|
|
4
|
+
import { existsSync, promises as fs } from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { shellQuote } from "./cli-messages.js";
|
|
7
|
+
import { WORKSPACE_CONFIG_FILE } from "./workspace.js";
|
|
8
|
+
async function hasFlowFile(flowsDir) {
|
|
9
|
+
try {
|
|
10
|
+
return (await fs.readdir(flowsDir)).some((e) => e.endsWith(".flow.yaml"));
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Whether `docs/<flow>/annotations.json` or `docs/<flow>/<variant>/annotations.json` exists. */
|
|
17
|
+
async function hasAnnotations(docsDir) {
|
|
18
|
+
let flows;
|
|
19
|
+
try {
|
|
20
|
+
flows = await fs.readdir(docsDir);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
for (const flow of flows) {
|
|
26
|
+
const flowDir = path.join(docsDir, flow);
|
|
27
|
+
if (existsSync(path.join(flowDir, "annotations.json")))
|
|
28
|
+
return true;
|
|
29
|
+
const variants = await fs.readdir(flowDir).catch(() => []);
|
|
30
|
+
if (variants.some((v) => existsSync(path.join(flowDir, v, "annotations.json"))))
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The next command for the workspace at `workspaceDir`. `dirArg` is the directory the user typed,
|
|
37
|
+
* or `undefined` when doctor ran in the current directory; the command repeats it as typed.
|
|
38
|
+
*/
|
|
39
|
+
export async function doctorNextStep(dirArg, workspaceDir) {
|
|
40
|
+
const root = path.resolve(workspaceDir);
|
|
41
|
+
const isWorkspace = existsSync(path.join(root, WORKSPACE_CONFIG_FILE)) || existsSync(path.join(root, "flows"));
|
|
42
|
+
if (!isWorkspace) {
|
|
43
|
+
return `docsxai init ${dirArg === undefined ? "<workspace-dir>" : shellQuote(dirArg)} --example`;
|
|
44
|
+
}
|
|
45
|
+
const ws = shellQuote(dirArg ?? ".");
|
|
46
|
+
if (!(await hasFlowFile(path.join(root, "flows")))) {
|
|
47
|
+
return `docsxai add-flow ${ws} --from <flow.yaml>`;
|
|
48
|
+
}
|
|
49
|
+
if (!(await hasAnnotations(path.join(root, "docs"))))
|
|
50
|
+
return `docsxai run ${ws}`;
|
|
51
|
+
return `docsxai render ${ws} --open`;
|
|
52
|
+
}
|
package/dist/doctor.d.ts
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
import { type DoctorCheck, type DoctorOptions } from "./doctor-checks.js";
|
|
2
2
|
export * from "./doctor-checks.js";
|
|
3
3
|
export * from "./doctor-checks-plugins.js";
|
|
4
|
+
export * from "./doctor-checks-config.js";
|
|
5
|
+
export * from "./doctor-checks-site.js";
|
|
6
|
+
export { doctorNextStep } from "./doctor-next.js";
|
|
4
7
|
export declare function buildDoctorChecks(opts?: DoctorOptions): Promise<DoctorCheck[]>;
|
|
5
|
-
export
|
|
8
|
+
export interface DoctorFormatOptions {
|
|
9
|
+
/** The docsxai version, printed as the first row when given. */
|
|
10
|
+
version?: string;
|
|
11
|
+
/** The command the passing summary line suggests; omitted from the line when absent. */
|
|
12
|
+
next?: string;
|
|
13
|
+
}
|
|
14
|
+
/** One `ok:` or `fail:` line per check, then one summary line. Plain ASCII, no colour, no timings. */
|
|
15
|
+
export declare function formatDoctorChecks(checks: DoctorCheck[], opts?: DoctorFormatOptions): string;
|
|
16
|
+
/** The schema id of `doctor --format json`. */
|
|
17
|
+
export declare const DOCTOR_JSON_SCHEMA = "docsxai/doctor@1";
|
|
18
|
+
/** One check in `doctor --format json`. Every key is always present. */
|
|
19
|
+
export interface DoctorJsonCheck {
|
|
20
|
+
name: string;
|
|
21
|
+
ok: boolean;
|
|
22
|
+
info: boolean;
|
|
23
|
+
detail: string;
|
|
24
|
+
next: string | null;
|
|
25
|
+
}
|
|
26
|
+
/** What `doctor --format json` prints. Every key is always present, in this order. */
|
|
27
|
+
export interface DoctorJsonReport {
|
|
28
|
+
schema: typeof DOCTOR_JSON_SCHEMA;
|
|
29
|
+
version: string;
|
|
30
|
+
ok: boolean;
|
|
31
|
+
checks: DoctorJsonCheck[];
|
|
32
|
+
/** The suggested command after a pass, the fix-and-rerun hint after a failure, or null. */
|
|
33
|
+
next: string | null;
|
|
34
|
+
}
|
|
35
|
+
/** The `doctor --format json` document for `checks`. */
|
|
36
|
+
export declare function doctorReport(checks: DoctorCheck[], opts: {
|
|
37
|
+
version: string;
|
|
38
|
+
next?: string;
|
|
39
|
+
}): DoctorJsonReport;
|
|
6
40
|
/** What `docsxai doctor --help` prints: the usage line from `docsxai --help`, then what the rows mean. */
|
|
7
41
|
export declare function doctorHelp(): string;
|
|
8
|
-
/** `docsxai doctor [<workspace-dir>]
|
|
42
|
+
/** `docsxai doctor [<workspace-dir>]`: returns the process exit code. */
|
|
9
43
|
export declare function runDoctor(args: string[]): Promise<number>;
|
package/dist/doctor.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
// `docsxai doctor
|
|
1
|
+
// `docsxai doctor`: environment + workspace health-check.
|
|
2
2
|
//
|
|
3
|
-
// Prints
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// the configured backend's /v1/health.
|
|
3
|
+
// Prints one `ok:` or `fail:` line per check, each with a `next:` step where there is one.
|
|
4
|
+
// Exits 0 iff no line failed, 1 otherwise. Pure inspection throughout: no flow runs, no plugin
|
|
5
|
+
// code execution, no browser launch. The network touches are a short HEAD of `app_url`
|
|
6
|
+
// (skipped with --offline) and a GET of the configured backend's /v1/health.
|
|
8
7
|
//
|
|
9
8
|
// The per-check probe catalogue lives in ./doctor-checks.js; this file owns the
|
|
10
9
|
// checklist assembly + CLI entry and re-exports the checks' public surface so
|
|
11
10
|
// every doctor symbol stays importable from ./doctor.js.
|
|
12
11
|
import { checkAuth, checkBackend, checkChromium, checkEnv, checkFlows, checkNode, checkViewer, checkWorkspace, probeChromium, } from "./doctor-checks.js";
|
|
12
|
+
import { checkAppUrl, checkConfigFields, checkLogin, checkWritable, } from "./doctor-checks-config.js";
|
|
13
13
|
import { checkPlugins } from "./doctor-checks-plugins.js";
|
|
14
|
-
import {
|
|
14
|
+
import { checkSite } from "./doctor-checks-site.js";
|
|
15
|
+
import { commandUsage, usageError } from "./cli-messages.js";
|
|
16
|
+
import { engineVersion } from "./cli-version.js";
|
|
17
|
+
import { doctorNextStep } from "./doctor-next.js";
|
|
18
|
+
import { parseCommandFlags } from "./cli-flags.js";
|
|
15
19
|
// Re-export the probe catalogue's public surface so importers keep reaching it
|
|
16
|
-
// through ./doctor.js (its original home)
|
|
20
|
+
// through ./doctor.js (its original home), no importer or test changes. The
|
|
17
21
|
// plugin-runtime probe lives in its own sibling but is re-exported here too.
|
|
18
22
|
export * from "./doctor-checks.js";
|
|
19
23
|
export * from "./doctor-checks-plugins.js";
|
|
24
|
+
export * from "./doctor-checks-config.js";
|
|
25
|
+
export * from "./doctor-checks-site.js";
|
|
26
|
+
export { doctorNextStep } from "./doctor-next.js";
|
|
20
27
|
// ---------------------------------------------------------------------------
|
|
21
28
|
// Assembly + CLI entry
|
|
22
29
|
// ---------------------------------------------------------------------------
|
|
@@ -31,56 +38,108 @@ export async function buildDoctorChecks(opts = {}) {
|
|
|
31
38
|
const ws = await checkWorkspace(workspaceDir);
|
|
32
39
|
checks.push(ws.check);
|
|
33
40
|
if (ws.present) {
|
|
41
|
+
checks.push(...checkConfigFields(ws.config));
|
|
42
|
+
checks.push(await checkWritable(workspaceDir));
|
|
34
43
|
checks.push(await checkFlows(workspaceDir));
|
|
35
44
|
checks.push(...(await checkAuth(workspaceDir, now)));
|
|
45
|
+
const appUrl = await checkAppUrl(ws.config, fetchImpl, opts.offline ?? false);
|
|
46
|
+
if (appUrl)
|
|
47
|
+
checks.push(appUrl);
|
|
36
48
|
checks.push(await checkBackend(workspaceDir, ws.config, env, fetchImpl));
|
|
37
|
-
checks.push(
|
|
49
|
+
checks.push(checkLogin(workspaceDir, ws.config, env));
|
|
50
|
+
// A config that does not load already failed the workspace row; the plugins row would repeat it.
|
|
51
|
+
if (ws.check.ok)
|
|
52
|
+
checks.push(...(await checkPlugins(workspaceDir)));
|
|
53
|
+
const site = checkSite(workspaceDir);
|
|
54
|
+
if (site)
|
|
55
|
+
checks.push(site);
|
|
38
56
|
}
|
|
39
57
|
checks.push(await checkViewer(env));
|
|
40
58
|
checks.push(...checkEnv(env));
|
|
41
59
|
return checks;
|
|
42
60
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
const oneLine = (t) => t.replace(/\s+/g, " ").trim();
|
|
62
|
+
/** What the closing line suggests after a failure. */
|
|
63
|
+
const FAILED_NEXT = "fix the fail lines above, then run docsxai doctor again";
|
|
64
|
+
/** One `ok:` or `fail:` line per check, then one summary line. Plain ASCII, no colour, no timings. */
|
|
65
|
+
export function formatDoctorChecks(checks, opts = {}) {
|
|
66
|
+
let out = opts.version === undefined ? "" : `ok: version: docsxai ${opts.version}\n`;
|
|
46
67
|
for (const c of checks) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
out +=
|
|
51
|
-
if (!c.ok && c.fix)
|
|
52
|
-
out += ` fix: ${c.fix}\n`;
|
|
68
|
+
out += `${c.ok ? "ok" : "fail"}: ${c.name}: ${oneLine(c.detail)}`;
|
|
69
|
+
if (c.fix)
|
|
70
|
+
out += ` next: ${oneLine(c.fix)}`;
|
|
71
|
+
out += "\n";
|
|
53
72
|
}
|
|
73
|
+
const failed = checks.filter((c) => !c.ok).length;
|
|
54
74
|
const infos = checks.filter((c) => c.info).length;
|
|
55
75
|
const scored = checks.length - infos;
|
|
76
|
+
const next = opts.next === undefined ? "" : ` next: ${opts.next}`;
|
|
56
77
|
out +=
|
|
57
78
|
failed === 0
|
|
58
|
-
?
|
|
59
|
-
:
|
|
79
|
+
? `ok: doctor: all checks passed (${scored} checks, ${infos} informational)${next}\n`
|
|
80
|
+
: `fail: doctor: ${failed} of ${scored} checks failed next: ${FAILED_NEXT}\n`;
|
|
60
81
|
return out;
|
|
61
82
|
}
|
|
83
|
+
/** The schema id of `doctor --format json`. */
|
|
84
|
+
export const DOCTOR_JSON_SCHEMA = "docsxai/doctor@1";
|
|
85
|
+
/** The `doctor --format json` document for `checks`. */
|
|
86
|
+
export function doctorReport(checks, opts) {
|
|
87
|
+
const ok = checks.every((c) => c.ok);
|
|
88
|
+
return {
|
|
89
|
+
schema: DOCTOR_JSON_SCHEMA,
|
|
90
|
+
version: opts.version,
|
|
91
|
+
ok,
|
|
92
|
+
checks: checks.map((c) => ({
|
|
93
|
+
name: c.name,
|
|
94
|
+
ok: c.ok,
|
|
95
|
+
info: c.info === true,
|
|
96
|
+
detail: oneLine(c.detail),
|
|
97
|
+
next: c.fix ? oneLine(c.fix) : null,
|
|
98
|
+
})),
|
|
99
|
+
next: ok ? (opts.next ?? null) : FAILED_NEXT,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
62
102
|
/** What `docsxai doctor --help` prints: the usage line from `docsxai --help`, then what the rows mean. */
|
|
63
103
|
export function doctorHelp() {
|
|
64
104
|
return `${commandUsage("doctor")
|
|
65
105
|
.map((l) => `usage: ${l}\n`)
|
|
66
106
|
.join("")}
|
|
67
|
-
Checks Node, Chromium, the workspace config
|
|
68
|
-
|
|
69
|
-
code and no browser.
|
|
107
|
+
Checks Node, Chromium, the workspace config (fields and burn.theme shape), write access, flow-files,
|
|
108
|
+
cached sessions, a HEAD to app_url, the backend and login state (when backend_url is set), plugin
|
|
109
|
+
declarations and lock, an emitted site folder with no astro installed, the viewer and environment settings. Runs no flow, no plugin code and no browser.
|
|
110
|
+
|
|
111
|
+
ok: <check>: <detail> next: <what to do> passed (next is present when there is a follow-up)
|
|
112
|
+
fail: <check>: <detail> next: <what to do> failed
|
|
70
113
|
|
|
71
|
-
|
|
114
|
+
--offline do not probe app_url
|
|
115
|
+
--format json one JSON document (schema docsxai/doctor@1) instead of the lines
|
|
72
116
|
|
|
73
|
-
Exit 0 when no
|
|
117
|
+
Exit 0 when no line starts with fail:, 1 otherwise.
|
|
74
118
|
`;
|
|
75
119
|
}
|
|
76
|
-
/** `docsxai doctor [<workspace-dir>]
|
|
120
|
+
/** `docsxai doctor [<workspace-dir>]`: returns the process exit code. */
|
|
77
121
|
export async function runDoctor(args) {
|
|
78
122
|
if (args.includes("--help") || args.includes("-h")) {
|
|
79
123
|
process.stdout.write(doctorHelp());
|
|
80
124
|
return 0;
|
|
81
125
|
}
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
126
|
+
const parsed = parseCommandFlags("doctor", args);
|
|
127
|
+
if (typeof parsed === "number")
|
|
128
|
+
return parsed;
|
|
129
|
+
const { positionals, flags } = parsed;
|
|
130
|
+
const format = flags.get("format") ?? "text";
|
|
131
|
+
if (format !== "text" && format !== "json") {
|
|
132
|
+
return usageError("doctor", "--format must be text or json");
|
|
133
|
+
}
|
|
134
|
+
const dirArg = positionals[0] || undefined;
|
|
135
|
+
const checks = await buildDoctorChecks({
|
|
136
|
+
...(dirArg ? { workspaceDir: dirArg } : {}),
|
|
137
|
+
offline: flags.get("offline") === true,
|
|
138
|
+
});
|
|
139
|
+
const version = engineVersion();
|
|
140
|
+
const next = await doctorNextStep(dirArg, dirArg ?? process.cwd());
|
|
141
|
+
process.stdout.write(format === "json"
|
|
142
|
+
? `${JSON.stringify(doctorReport(checks, { version, next }), null, 2)}\n`
|
|
143
|
+
: formatDoctorChecks(checks, { version, next }));
|
|
85
144
|
return checks.every((c) => c.ok) ? 0 : 1;
|
|
86
145
|
}
|