@docsxai/engine 0.2.1-rc.1 → 0.3.0-rc.2
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 +18 -5
- package/dist/address-class.d.ts +14 -0
- package/dist/address-class.js +151 -0
- package/dist/auth/api-login.d.ts +3 -3
- package/dist/auth/email-otp.d.ts +60 -60
- package/dist/auth/jwt-injection.d.ts +45 -45
- package/dist/auth/pat-header.d.ts +2 -2
- package/dist/auth/types.d.ts +2 -2
- package/dist/auth/ui-form.d.ts +54 -54
- package/dist/auth/webauthn.d.ts +22 -22
- package/dist/backend-client-contracts.d.ts +4 -2
- package/dist/backend-client-token.js +2 -1
- package/dist/calibrate.d.ts +2 -2
- package/dist/calibrate.js +5 -0
- package/dist/cli-backend-errors.d.ts +7 -0
- package/dist/cli-backend-errors.js +65 -0
- package/dist/cli-commands-authoring.js +57 -51
- package/dist/cli-commands-backend.js +49 -42
- package/dist/cli-commands-docpack.d.ts +5 -0
- package/dist/cli-commands-docpack.js +106 -66
- package/dist/cli-commands-pack.d.ts +2 -0
- package/dist/cli-commands-pack.js +65 -0
- package/dist/cli-commands-session.js +120 -125
- package/dist/cli-messages.d.ts +17 -0
- package/dist/cli-messages.js +80 -0
- package/dist/cli-retired.d.ts +6 -0
- package/dist/cli-retired.js +12 -0
- package/dist/cli-run-summary.d.ts +15 -0
- package/dist/cli-run-summary.js +33 -0
- package/dist/cli-usage.d.ts +1 -1
- package/dist/cli-usage.js +78 -5
- package/dist/cli-verify.d.ts +14 -0
- package/dist/cli-verify.js +54 -0
- package/dist/cli.js +15 -2
- package/dist/deprecation.d.ts +19 -0
- package/dist/deprecation.js +32 -0
- package/dist/diagnose.d.ts +25 -0
- package/dist/diagnose.js +69 -3
- package/dist/diff-compute.js +1 -0
- package/dist/doc-pack-io.d.ts +14 -0
- package/dist/doc-pack-io.js +121 -14
- package/dist/doc-pack.d.ts +2282 -387
- package/dist/doc-pack.js +135 -43
- package/dist/doctor-checks-plugins.js +4 -3
- package/dist/doctor-checks.d.ts +1 -1
- package/dist/doctor-checks.js +31 -6
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.js +27 -3
- package/dist/driver-budget.d.ts +6 -0
- package/dist/driver-budget.js +15 -0
- package/dist/egress-guard.d.ts +58 -0
- package/dist/egress-guard.js +136 -0
- package/dist/environment-spec.d.ts +67 -0
- package/dist/environment-spec.js +38 -0
- package/dist/export/playwright-test.js +42 -10
- package/dist/flow-file.d.ts +9 -3
- package/dist/flow-file.js +21 -1
- package/dist/flow-halt.d.ts +16 -0
- package/dist/flow-halt.js +76 -0
- package/dist/flow-hidden.d.ts +9 -0
- package/dist/flow-hidden.js +20 -0
- package/dist/flow-lint.js +91 -1
- package/dist/flow-matrix-lint.d.ts +10 -0
- package/dist/flow-matrix-lint.js +40 -0
- package/dist/flow-matrix.d.ts +44 -0
- package/dist/flow-matrix.js +238 -0
- package/dist/flow-name-rules.d.ts +15 -0
- package/dist/flow-name-rules.js +39 -0
- package/dist/flow-runtime.d.ts +52 -22
- package/dist/flow-runtime.js +63 -117
- package/dist/flow-success.d.ts +3 -0
- package/dist/flow-success.js +37 -0
- package/dist/flow-tree.d.ts +2 -0
- package/dist/flow-tree.js +17 -5
- package/dist/flow-wait.d.ts +3 -0
- package/dist/flow-wait.js +22 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/matrix-spec.d.ts +145 -0
- package/dist/matrix-spec.js +120 -0
- package/dist/page-hide.d.ts +10 -0
- package/dist/page-hide.js +45 -0
- package/dist/page-settle.d.ts +39 -0
- package/dist/page-settle.js +142 -0
- package/dist/playwright-driver.d.ts +28 -8
- package/dist/playwright-driver.js +73 -28
- package/dist/plugins/manifest.d.ts +9 -9
- package/dist/run-flows.d.ts +40 -0
- package/dist/run-flows.js +129 -0
- package/dist/style.d.ts +2 -2
- package/dist/upload-path.d.ts +15 -0
- package/dist/upload-path.js +63 -0
- package/dist/verify-compare.d.ts +43 -0
- package/dist/verify-compare.js +237 -0
- package/dist/verify-determinism.d.ts +16 -0
- package/dist/verify-determinism.js +88 -0
- package/dist/verify-report.d.ts +53 -0
- package/dist/verify-report.js +141 -0
- package/dist/verify-tree.d.ts +27 -0
- package/dist/verify-tree.js +95 -0
- package/dist/viewer-bin.d.ts +6 -0
- package/dist/viewer-bin.js +24 -0
- package/dist/zip.d.ts +2 -2
- package/package.json +3 -2
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
import { promises as fs } from "node:fs";
|
|
9
9
|
import * as path from "node:path";
|
|
10
10
|
import { LocalStorageStateCache, parseAuthStrategyFile } from "./auth.js";
|
|
11
|
-
import { FlowFileError, parseFlowFile, resolveFlowExtends } from "./flow-file.js";
|
|
12
|
-
import {
|
|
11
|
+
import { expandFlowVariants, FlowFileError, parseFlowFile, resolveFlowExtends, } from "./flow-file.js";
|
|
12
|
+
import { variantDocDir } from "./flow-matrix.js";
|
|
13
|
+
import { buildDiagnoseReport, formatReportText, pickDiagnoseVariant, probeLive, } from "./diagnose.js";
|
|
13
14
|
import { formatIssuesText, lintFlow } from "./flow-lint.js";
|
|
14
15
|
import { buildFlowTree, formatTreeText } from "./flow-tree.js";
|
|
15
16
|
import { formatJargonHitsText, initStyleIfAbsent, loadStyle, scanWorkspaceForJargon, StyleError, writeStyle, } from "./style.js";
|
|
@@ -18,21 +19,18 @@ import { resolvePlugins } from "./plugins/runtime.js";
|
|
|
18
19
|
import { launchPlaywrightSession } from "./playwright-driver.js";
|
|
19
20
|
import { loadWorkspaceConfig, resolveWorkspacePath } from "./workspace.js";
|
|
20
21
|
import { listFlowFiles, parseFlags } from "./cli-shared.js";
|
|
21
|
-
import {
|
|
22
|
+
import { shellQuote, usageError, withNext } from "./cli-messages.js";
|
|
22
23
|
export async function cmdInspect(args) {
|
|
23
24
|
const { positionals, flags } = parseFlags(args);
|
|
24
25
|
const workspaceDir = positionals[0];
|
|
25
|
-
if (!workspaceDir)
|
|
26
|
-
|
|
27
|
-
return 2;
|
|
28
|
-
}
|
|
26
|
+
if (!workspaceDir)
|
|
27
|
+
return usageError("inspect", "missing <workspace-dir>");
|
|
29
28
|
const wsCfg = await loadWorkspaceConfig(workspaceDir);
|
|
30
29
|
const cdp = typeof flags.get("cdp") === "string" ? flags.get("cdp") : undefined;
|
|
31
30
|
const explicitUrl = typeof flags.get("url") === "string" ? flags.get("url") : undefined;
|
|
32
31
|
const url = explicitUrl ?? wsCfg?.app_url;
|
|
33
32
|
if (!cdp && !url) {
|
|
34
|
-
|
|
35
|
-
return 2;
|
|
33
|
+
return usageError("inspect", "no URL — pass --url <url>, set app_url in .docsxai.json, or use --cdp <endpoint>");
|
|
36
34
|
}
|
|
37
35
|
const selector = typeof flags.get("selector") === "string" ? flags.get("selector") : undefined;
|
|
38
36
|
const headed = flags.get("headed") === true;
|
|
@@ -83,7 +81,10 @@ export async function cmdInspect(args) {
|
|
|
83
81
|
try {
|
|
84
82
|
// In CDP-attach mode without an explicit --url, inspect whatever the attached browser already has open.
|
|
85
83
|
if (url && (!cdp || explicitUrl))
|
|
86
|
-
await session.page.goto(url, { waitUntil: "domcontentloaded" }).catch(() =>
|
|
84
|
+
await session.page.goto(url, { waitUntil: "domcontentloaded" }).catch((e) => {
|
|
85
|
+
const why = e.message.split("\n")[0];
|
|
86
|
+
process.stderr.write(`inspect: warning — could not load ${url}: ${why}; is the app running?\n`);
|
|
87
|
+
});
|
|
87
88
|
if (waitForSel)
|
|
88
89
|
await session.page.waitForSelector(waitForSel, { timeout: 30_000 }).catch(() => undefined);
|
|
89
90
|
else if (waitMs > 0)
|
|
@@ -134,16 +135,13 @@ export async function cmdInspect(args) {
|
|
|
134
135
|
}
|
|
135
136
|
export async function cmdLint(args) {
|
|
136
137
|
const { positionals, flags } = parseFlags(args);
|
|
137
|
-
if (!positionals[0])
|
|
138
|
-
|
|
139
|
-
return 2;
|
|
140
|
-
}
|
|
138
|
+
if (!positionals[0])
|
|
139
|
+
return usageError("lint", "missing <workspace-dir>");
|
|
141
140
|
const projectDir = positionals[0];
|
|
142
141
|
const flowFilter = typeof flags.get("flow") === "string" ? flags.get("flow") : undefined;
|
|
143
142
|
const format = typeof flags.get("format") === "string" ? flags.get("format") : "text";
|
|
144
143
|
if (format !== "text" && format !== "json") {
|
|
145
|
-
|
|
146
|
-
return 2;
|
|
144
|
+
return usageError("lint", '--format must be "text" or "json"');
|
|
147
145
|
}
|
|
148
146
|
let flowPaths;
|
|
149
147
|
try {
|
|
@@ -162,7 +160,7 @@ export async function cmdLint(args) {
|
|
|
162
160
|
}
|
|
163
161
|
catch (e) {
|
|
164
162
|
const msg = e instanceof FlowFileError ? e.message : e.message;
|
|
165
|
-
process.stderr.write(`lint: parse error in ${p}: ${msg}\n`);
|
|
163
|
+
process.stderr.write(`lint: ${withNext(`parse error in ${p}: ${msg}`, `fix the flow-file, then docsxai lint ${shellQuote(projectDir)}`)}\n`);
|
|
166
164
|
return 1;
|
|
167
165
|
}
|
|
168
166
|
}
|
|
@@ -172,8 +170,8 @@ export async function cmdLint(args) {
|
|
|
172
170
|
: []
|
|
173
171
|
: Array.from(flowsByName.values());
|
|
174
172
|
if (flowFilter && targets.length === 0) {
|
|
175
|
-
|
|
176
|
-
return
|
|
173
|
+
const known = [...flowsByName.keys()].join(", ") || "none";
|
|
174
|
+
return usageError("lint", `flow not found: ${flowFilter} (flows: ${known})`);
|
|
177
175
|
}
|
|
178
176
|
const loadFlow = (name) => {
|
|
179
177
|
const f = flowsByName.get(name);
|
|
@@ -216,15 +214,12 @@ export async function cmdLint(args) {
|
|
|
216
214
|
}
|
|
217
215
|
export async function cmdFlowTree(args) {
|
|
218
216
|
const { positionals, flags } = parseFlags(args);
|
|
219
|
-
if (!positionals[0])
|
|
220
|
-
|
|
221
|
-
return 2;
|
|
222
|
-
}
|
|
217
|
+
if (!positionals[0])
|
|
218
|
+
return usageError("flow-tree", "missing <workspace-dir>");
|
|
223
219
|
const projectDir = positionals[0];
|
|
224
220
|
const format = typeof flags.get("format") === "string" ? flags.get("format") : "text";
|
|
225
221
|
if (format !== "text" && format !== "json") {
|
|
226
|
-
|
|
227
|
-
return 2;
|
|
222
|
+
return usageError("flow-tree", '--format must be "text" or "json"');
|
|
228
223
|
}
|
|
229
224
|
let flowPaths;
|
|
230
225
|
try {
|
|
@@ -243,7 +238,7 @@ export async function cmdFlowTree(args) {
|
|
|
243
238
|
}
|
|
244
239
|
catch (e) {
|
|
245
240
|
const msg = e instanceof FlowFileError ? e.message : e.message;
|
|
246
|
-
process.stderr.write(`flow-tree: parse error in ${p}: ${msg}\n`);
|
|
241
|
+
process.stderr.write(`flow-tree: ${withNext(`parse error in ${p}: ${msg}`, `fix the flow-file, then docsxai flow-tree ${shellQuote(projectDir)}`)}\n`);
|
|
247
242
|
return 1;
|
|
248
243
|
}
|
|
249
244
|
}
|
|
@@ -258,26 +253,20 @@ export async function cmdFlowTree(args) {
|
|
|
258
253
|
}
|
|
259
254
|
export async function cmdDiagnose(args) {
|
|
260
255
|
const { positionals, flags } = parseFlags(args);
|
|
261
|
-
if (!positionals[0])
|
|
262
|
-
|
|
263
|
-
return 2;
|
|
264
|
-
}
|
|
256
|
+
if (!positionals[0])
|
|
257
|
+
return usageError("diagnose", "missing <workspace-dir>");
|
|
265
258
|
const projectDir = positionals[0];
|
|
266
259
|
const flowName = typeof flags.get("flow") === "string" ? flags.get("flow") : undefined;
|
|
267
260
|
const stepId = typeof flags.get("step") === "string" ? flags.get("step") : undefined;
|
|
268
261
|
const cdpEndpoint = typeof flags.get("cdp") === "string" ? flags.get("cdp") : undefined;
|
|
262
|
+
const variantFlag = typeof flags.get("variant") === "string" ? flags.get("variant") : undefined;
|
|
269
263
|
const format = typeof flags.get("format") === "string" ? flags.get("format") : "text";
|
|
270
|
-
if (!flowName)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (!stepId) {
|
|
275
|
-
process.stderr.write(`diagnose: --step <step-id> required\n`);
|
|
276
|
-
return 2;
|
|
277
|
-
}
|
|
264
|
+
if (!flowName)
|
|
265
|
+
return usageError("diagnose", "--flow <name> required");
|
|
266
|
+
if (!stepId)
|
|
267
|
+
return usageError("diagnose", "--step <step-id> required");
|
|
278
268
|
if (format !== "text" && format !== "json") {
|
|
279
|
-
|
|
280
|
-
return 2;
|
|
269
|
+
return usageError("diagnose", '--format must be "text" or "json"');
|
|
281
270
|
}
|
|
282
271
|
// Load the flow (resolving `extends` so step lookup works against the merged step list).
|
|
283
272
|
const loadFlowFile = async (name) => {
|
|
@@ -287,23 +276,39 @@ export async function cmdDiagnose(args) {
|
|
|
287
276
|
text = await fs.readFile(fp, "utf8");
|
|
288
277
|
}
|
|
289
278
|
catch {
|
|
290
|
-
throw new FlowFileError(`no flow named "${name}" at ${fp}`);
|
|
279
|
+
throw new FlowFileError(withNext(`no flow named "${name}" at ${fp}`, `docsxai flow-tree ${shellQuote(projectDir)} (lists the flows)`));
|
|
291
280
|
}
|
|
292
281
|
return parseFlowFile(text, fp);
|
|
293
282
|
};
|
|
294
283
|
let flow;
|
|
284
|
+
let variants;
|
|
295
285
|
try {
|
|
296
286
|
const parsed = await loadFlowFile(flowName);
|
|
297
287
|
flow = parsed.extends ? await resolveFlowExtends(parsed, loadFlowFile) : parsed;
|
|
288
|
+
variants = expandFlowVariants(flow);
|
|
298
289
|
}
|
|
299
290
|
catch (e) {
|
|
300
291
|
const msg = e instanceof FlowFileError ? e.message : e.message;
|
|
301
292
|
process.stderr.write(`diagnose: ${msg}\n`);
|
|
302
293
|
return 1;
|
|
303
294
|
}
|
|
295
|
+
// A flow with a `matrix` is diagnosed one variant at a time: its steps and halt shot are the variant's.
|
|
296
|
+
const picked = await pickDiagnoseVariant({
|
|
297
|
+
workspace: projectDir,
|
|
298
|
+
flow: flowName,
|
|
299
|
+
stepId,
|
|
300
|
+
variants,
|
|
301
|
+
requested: variantFlag,
|
|
302
|
+
});
|
|
303
|
+
if ("error" in picked) {
|
|
304
|
+
process.stderr.write(`diagnose: ${picked.error}\n`);
|
|
305
|
+
return 2;
|
|
306
|
+
}
|
|
307
|
+
const variantId = picked.variant.id;
|
|
308
|
+
flow = picked.variant.flow;
|
|
304
309
|
const step = flow.steps.find((s) => s.id === stepId);
|
|
305
310
|
if (!step) {
|
|
306
|
-
process.stderr.write(`diagnose: no step "${stepId}" in flow "${flowName}" (merged step list: ${flow.steps.map((s) => s.id).join(", ")})\n`);
|
|
311
|
+
process.stderr.write(`diagnose: no step "${stepId}" in flow "${flowName}"${variantId ? ` variant "${variantId}"` : ""} (${variantId ? "variant" : "merged"} step list: ${flow.steps.map((s) => s.id).join(", ")})\n`);
|
|
307
312
|
return 1;
|
|
308
313
|
}
|
|
309
314
|
const resolvedSelector = step.target
|
|
@@ -311,7 +316,7 @@ export async function cmdDiagnose(args) {
|
|
|
311
316
|
? (flow.locators[step.target.slice(1)] ?? step.target)
|
|
312
317
|
: step.target
|
|
313
318
|
: undefined;
|
|
314
|
-
const haltScreenshotAbsPath = resolveWorkspacePath(projectDir,
|
|
319
|
+
const haltScreenshotAbsPath = resolveWorkspacePath(projectDir, variantDocDir(flowName, variantId), "halts", `${stepId}.png`);
|
|
315
320
|
// Optional live probe via --cdp.
|
|
316
321
|
let liveProbe;
|
|
317
322
|
let liveSession;
|
|
@@ -333,10 +338,14 @@ export async function cmdDiagnose(args) {
|
|
|
333
338
|
...(resolvedSelector ? { resolvedSelector } : {}),
|
|
334
339
|
haltScreenshotAbsPath,
|
|
335
340
|
...(liveProbe ? { liveProbe } : {}),
|
|
341
|
+
...(variantId ? { variant: { id: variantId, all: picked.ids } } : {}),
|
|
336
342
|
});
|
|
337
343
|
}
|
|
338
344
|
catch (e) {
|
|
339
|
-
|
|
345
|
+
const hint = cdpEndpoint
|
|
346
|
+
? withNext("", `check Chrome is running with --remote-debugging-port and --cdp ${shellQuote(cdpEndpoint)} points at it, or drop --cdp`)
|
|
347
|
+
: "";
|
|
348
|
+
process.stderr.write(`diagnose: live probe failed: ${e.message}${hint}\n`);
|
|
340
349
|
return 1;
|
|
341
350
|
}
|
|
342
351
|
finally {
|
|
@@ -353,16 +362,13 @@ export async function cmdDiagnose(args) {
|
|
|
353
362
|
}
|
|
354
363
|
export async function cmdStyle(args) {
|
|
355
364
|
const { positionals, flags } = parseFlags(args);
|
|
356
|
-
if (!positionals[0])
|
|
357
|
-
|
|
358
|
-
return 2;
|
|
359
|
-
}
|
|
365
|
+
if (!positionals[0])
|
|
366
|
+
return usageError("style", "missing <workspace-dir>");
|
|
360
367
|
const projectDir = positionals[0];
|
|
361
368
|
const check = flags.get("check") === true;
|
|
362
369
|
const format = typeof flags.get("format") === "string" ? flags.get("format") : "text";
|
|
363
370
|
if (format !== "text" && format !== "json") {
|
|
364
|
-
|
|
365
|
-
return 2;
|
|
371
|
+
return usageError("style", '--format must be "text" or "json"');
|
|
366
372
|
}
|
|
367
373
|
// init-if-absent (idempotent); then load + validate; then rederive JSON; then optional jargon check.
|
|
368
374
|
const { created } = await initStyleIfAbsent(projectDir);
|
|
@@ -372,7 +378,7 @@ export async function cmdStyle(args) {
|
|
|
372
378
|
}
|
|
373
379
|
catch (e) {
|
|
374
380
|
if (e instanceof StyleError) {
|
|
375
|
-
process.stderr.write(`style: ${e.message}\n`);
|
|
381
|
+
process.stderr.write(`style: ${withNext(e.message, `fix docs/style.yaml, then docsxai style ${shellQuote(projectDir)}`)}\n`);
|
|
376
382
|
return 1;
|
|
377
383
|
}
|
|
378
384
|
throw e;
|
|
@@ -6,17 +6,18 @@
|
|
|
6
6
|
// plugins — forwards to plugins-cli (list | info | sync over the plugin runtime; no plugin code runs)
|
|
7
7
|
import { promises as fs } from "node:fs";
|
|
8
8
|
import * as path from "node:path";
|
|
9
|
-
import { BackendClient,
|
|
10
|
-
import { fetchScreenshotBlobs, readDocPack, uploadScreenshotBlobs, writeDocPack, } from "./doc-pack-io.js";
|
|
9
|
+
import { BackendClient, createBackendClient, oauthLogin, saveBackendTokenFile, } from "./backend-client.js";
|
|
10
|
+
import { fetchScreenshotBlobs, readDocPack, UnsafePackNameError, uploadScreenshotBlobs, writeDocPack, } from "./doc-pack-io.js";
|
|
11
11
|
import { pluginsCli } from "./plugins-cli.js";
|
|
12
12
|
import { loadWorkspaceConfig, resolveWorkspacePath } from "./workspace.js";
|
|
13
13
|
import { parseFlags } from "./cli-shared.js";
|
|
14
|
+
import { configProblem, explainBackendFailure } from "./cli-backend-errors.js";
|
|
15
|
+
import { redactUrl, sanitizeForTerminal, shellQuote, usageError, withNext, } from "./cli-messages.js";
|
|
14
16
|
export async function cmdLogin(args) {
|
|
15
17
|
const { positionals, flags } = parseFlags(args);
|
|
16
18
|
const backendUrl = typeof flags.get("backend-url") === "string" ? flags.get("backend-url") : undefined;
|
|
17
19
|
if (!backendUrl) {
|
|
18
|
-
|
|
19
|
-
return 2;
|
|
20
|
+
return usageError("login", "--backend-url <url> required");
|
|
20
21
|
}
|
|
21
22
|
const oauthFlag = flags.get("oauth");
|
|
22
23
|
if (oauthFlag !== undefined) {
|
|
@@ -26,8 +27,7 @@ export async function cmdLogin(args) {
|
|
|
26
27
|
// from the positional.
|
|
27
28
|
const workspaceDir = typeof oauthFlag === "string" ? oauthFlag : positionals[0];
|
|
28
29
|
if (!workspaceDir) {
|
|
29
|
-
|
|
30
|
-
return 2;
|
|
30
|
+
return usageError("login", "--oauth requires a <workspace-dir> (tokens are stored at <workspace>/.auth/backend-token.json)");
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
const tokens = await oauthLogin({
|
|
@@ -41,12 +41,14 @@ export async function cmdLogin(args) {
|
|
|
41
41
|
return 0;
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
|
-
|
|
44
|
+
const text = explainBackendFailure(e, backendUrl) ?? sanitizeForTerminal(e.message);
|
|
45
|
+
process.stderr.write(`login: ${text}\n`);
|
|
45
46
|
return 1;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
if (!process.env.DOCSX_TOKEN) {
|
|
49
|
-
|
|
50
|
+
const next = `DOCSX_TOKEN=<token> docsxai login --backend-url ${shellQuote(redactUrl(backendUrl))} (or add --oauth <workspace-dir> to sign in as a person)`;
|
|
51
|
+
process.stderr.write(`login: ${withNext("DOCSX_TOKEN env var not set", next)}\n`);
|
|
50
52
|
return 2;
|
|
51
53
|
}
|
|
52
54
|
let client;
|
|
@@ -54,25 +56,26 @@ export async function cmdLogin(args) {
|
|
|
54
56
|
client = new BackendClient({ baseUrl: backendUrl });
|
|
55
57
|
}
|
|
56
58
|
catch (e) {
|
|
57
|
-
process.stderr.write(`login: ${e.message}\n`);
|
|
59
|
+
process.stderr.write(`login: ${sanitizeForTerminal(e.message)}\n`);
|
|
58
60
|
return 1;
|
|
59
61
|
}
|
|
60
62
|
try {
|
|
61
63
|
const h = await client.health();
|
|
62
64
|
if (!h.ok) {
|
|
63
|
-
|
|
65
|
+
const note = withNext(`backend health-check at ${redactUrl(backendUrl)} returned ok=false`, "check the backend's logs, then retry");
|
|
66
|
+
process.stderr.write(`login: ${note}\n`);
|
|
64
67
|
return 1;
|
|
65
68
|
}
|
|
66
69
|
const wss = await client.listWorkspaces();
|
|
67
|
-
process.stdout.write(`login: ok. ${wss.length} workspace${wss.length !== 1 ? "s" : ""} visible at ${backendUrl}\n`);
|
|
70
|
+
process.stdout.write(`login: ok. ${wss.length} workspace${wss.length !== 1 ? "s" : ""} visible at ${redactUrl(backendUrl)}\n`);
|
|
68
71
|
return 0;
|
|
69
72
|
}
|
|
70
73
|
catch (e) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
74
|
+
const text = explainBackendFailure(e, backendUrl);
|
|
75
|
+
if (text === undefined)
|
|
76
|
+
throw e;
|
|
77
|
+
process.stderr.write(`login: ${text}\n`);
|
|
78
|
+
return 1;
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
/** Ensure the workspace has a backend workspace + project to push to; create them on first push. */
|
|
@@ -94,20 +97,20 @@ async function ensureBackendBinding(client, projectDir, cfg, workspaceName) {
|
|
|
94
97
|
}
|
|
95
98
|
export async function cmdPush(args) {
|
|
96
99
|
const { positionals, flags } = parseFlags(args);
|
|
97
|
-
if (!positionals[0])
|
|
98
|
-
|
|
99
|
-
return 2;
|
|
100
|
-
}
|
|
100
|
+
if (!positionals[0])
|
|
101
|
+
return usageError("push", "missing <workspace-dir>");
|
|
101
102
|
const projectDir = positionals[0];
|
|
102
103
|
const wsCfg = await loadWorkspaceConfig(projectDir);
|
|
103
104
|
if (!wsCfg?.backend_url) {
|
|
104
|
-
|
|
105
|
+
const file = path.join(projectDir, ".docsxai.json");
|
|
106
|
+
const why = wsCfg ? "" : ` (${await configProblem(projectDir)})`;
|
|
107
|
+
const next = 'add "backend_url": "<url>" to it, then docsxai login --backend-url <url>';
|
|
108
|
+
process.stderr.write(`push: ${withNext(`no backend_url in ${file}${why}`, next)}\n`);
|
|
105
109
|
return 2;
|
|
106
110
|
}
|
|
107
111
|
const kindArg = typeof flags.get("kind") === "string" ? flags.get("kind") : "calibrate";
|
|
108
112
|
if (kindArg !== "calibrate" && kindArg !== "run" && kindArg !== "edit") {
|
|
109
|
-
|
|
110
|
-
return 2;
|
|
113
|
+
return usageError("push", `--kind must be calibrate | run | edit (got "${kindArg}")`);
|
|
111
114
|
}
|
|
112
115
|
const author = (typeof flags.get("author") === "string" ? flags.get("author") : null) ??
|
|
113
116
|
process.env.USER ??
|
|
@@ -117,7 +120,7 @@ export async function cmdPush(args) {
|
|
|
117
120
|
client = await createBackendClient({ baseUrl: wsCfg.backend_url, workspaceDir: projectDir });
|
|
118
121
|
}
|
|
119
122
|
catch (e) {
|
|
120
|
-
process.stderr.write(`push: ${e.message}\n`);
|
|
123
|
+
process.stderr.write(`push: ${sanitizeForTerminal(e.message)}\n`);
|
|
121
124
|
return 1;
|
|
122
125
|
}
|
|
123
126
|
try {
|
|
@@ -150,27 +153,29 @@ export async function cmdPush(args) {
|
|
|
150
153
|
pushed++;
|
|
151
154
|
}
|
|
152
155
|
await client.finalizeRevision(binding.wsId, binding.projectId, rev.id);
|
|
153
|
-
process.stdout.write(`push: revision ${rev.id} (${kindArg}, ${author}) — ${pushed} artifact slot${pushed !== 1 ? "s" : ""} uploaded, finalized\n`);
|
|
156
|
+
process.stdout.write(`push: revision ${sanitizeForTerminal(rev.id)} (${kindArg}, ${sanitizeForTerminal(author)}) on ${redactUrl(wsCfg.backend_url)} — ${pushed} artifact slot${pushed !== 1 ? "s" : ""} uploaded, finalized\n`);
|
|
154
157
|
return 0;
|
|
155
158
|
}
|
|
156
159
|
catch (e) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
160
|
+
const text = explainBackendFailure(e, wsCfg.backend_url, projectDir);
|
|
161
|
+
if (text === undefined)
|
|
162
|
+
throw e;
|
|
163
|
+
process.stderr.write(`push: ${text}\n`);
|
|
164
|
+
return 1;
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
export async function cmdPull(args) {
|
|
165
168
|
const { positionals, flags } = parseFlags(args);
|
|
166
|
-
if (!positionals[0])
|
|
167
|
-
|
|
168
|
-
return 2;
|
|
169
|
-
}
|
|
169
|
+
if (!positionals[0])
|
|
170
|
+
return usageError("pull", "missing <workspace-dir>");
|
|
170
171
|
const projectDir = positionals[0];
|
|
171
172
|
const wsCfg = await loadWorkspaceConfig(projectDir);
|
|
172
173
|
if (!wsCfg?.backend_url || !wsCfg.backend_workspace_id || !wsCfg.backend_project_id) {
|
|
173
|
-
|
|
174
|
+
const gap = wsCfg
|
|
175
|
+
? "backend_url, backend_workspace_id and backend_project_id are all needed"
|
|
176
|
+
: await configProblem(projectDir);
|
|
177
|
+
const next = `docsxai push ${shellQuote(projectDir)} (binds it on the first push), or set the three keys in .docsxai.json`;
|
|
178
|
+
process.stderr.write(`pull: ${withNext(`workspace isn't bound to a backend yet (${gap})`, next)}\n`);
|
|
174
179
|
return 2;
|
|
175
180
|
}
|
|
176
181
|
const revArg = typeof flags.get("rev") === "string" ? flags.get("rev") : "head";
|
|
@@ -179,7 +184,7 @@ export async function cmdPull(args) {
|
|
|
179
184
|
client = await createBackendClient({ baseUrl: wsCfg.backend_url, workspaceDir: projectDir });
|
|
180
185
|
}
|
|
181
186
|
catch (e) {
|
|
182
|
-
process.stderr.write(`pull: ${e.message}\n`);
|
|
187
|
+
process.stderr.write(`pull: ${sanitizeForTerminal(e.message)}\n`);
|
|
183
188
|
return 1;
|
|
184
189
|
}
|
|
185
190
|
try {
|
|
@@ -194,15 +199,17 @@ export async function cmdPull(args) {
|
|
|
194
199
|
? await fetchScreenshotBlobs(payloads.screenshots, client)
|
|
195
200
|
: undefined;
|
|
196
201
|
const r = await writeDocPack(projectDir, payloads, screenshotBytes ? { screenshotBytes } : {});
|
|
197
|
-
process.stdout.write(`pull: revision ${rev.id} (${rev.kind}, ${rev.author}) — wrote ${r.filesWritten} file(s)\n`);
|
|
202
|
+
process.stdout.write(`pull: revision ${sanitizeForTerminal(rev.id)} (${sanitizeForTerminal(rev.kind)}, ${sanitizeForTerminal(rev.author)}) — wrote ${r.filesWritten} file(s) to ${sanitizeForTerminal(projectDir)}\n`);
|
|
198
203
|
return 0;
|
|
199
204
|
}
|
|
200
205
|
catch (e) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
const text = e instanceof UnsafePackNameError
|
|
207
|
+
? withNext(`${sanitizeForTerminal(e.message)}\n why: the revision names a file a workspace would not produce; nothing was written`, `docsxai pull ${shellQuote(projectDir)} --rev <older-revision-id>`)
|
|
208
|
+
: explainBackendFailure(e, wsCfg.backend_url, projectDir);
|
|
209
|
+
if (text === undefined)
|
|
210
|
+
throw e;
|
|
211
|
+
process.stderr.write(`pull: ${text}\n`);
|
|
212
|
+
return 1;
|
|
206
213
|
}
|
|
207
214
|
}
|
|
208
215
|
/** `docsxai plugins …` — forwards to the plugin-runtime CLI verbatim. */
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export declare function cmdRender(args: string[]): Promise<number>;
|
|
2
|
+
/**
|
|
3
|
+
* `burn` — bake each annotation into a copy of its screenshot, for surfaces that can't run the
|
|
4
|
+
* interactive viewer. The renderer lives in `@docsxai/viewer`; this runs its `burn` command.
|
|
5
|
+
*/
|
|
6
|
+
export declare function cmdBurn(args: string[]): Promise<number>;
|
|
2
7
|
export declare function cmdZip(args: string[]): Promise<number>;
|
|
3
8
|
export declare function cmdExport(args: string[]): Promise<number>;
|
|
4
9
|
export declare function cmdBaseline(args: string[]): Promise<number>;
|