@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.
Files changed (104) hide show
  1. package/README.md +18 -5
  2. package/dist/address-class.d.ts +14 -0
  3. package/dist/address-class.js +151 -0
  4. package/dist/auth/api-login.d.ts +3 -3
  5. package/dist/auth/email-otp.d.ts +60 -60
  6. package/dist/auth/jwt-injection.d.ts +45 -45
  7. package/dist/auth/pat-header.d.ts +2 -2
  8. package/dist/auth/types.d.ts +2 -2
  9. package/dist/auth/ui-form.d.ts +54 -54
  10. package/dist/auth/webauthn.d.ts +22 -22
  11. package/dist/backend-client-contracts.d.ts +4 -2
  12. package/dist/backend-client-token.js +2 -1
  13. package/dist/calibrate.d.ts +2 -2
  14. package/dist/calibrate.js +5 -0
  15. package/dist/cli-backend-errors.d.ts +7 -0
  16. package/dist/cli-backend-errors.js +65 -0
  17. package/dist/cli-commands-authoring.js +57 -51
  18. package/dist/cli-commands-backend.js +49 -42
  19. package/dist/cli-commands-docpack.d.ts +5 -0
  20. package/dist/cli-commands-docpack.js +106 -66
  21. package/dist/cli-commands-pack.d.ts +2 -0
  22. package/dist/cli-commands-pack.js +65 -0
  23. package/dist/cli-commands-session.js +120 -125
  24. package/dist/cli-messages.d.ts +17 -0
  25. package/dist/cli-messages.js +80 -0
  26. package/dist/cli-retired.d.ts +6 -0
  27. package/dist/cli-retired.js +12 -0
  28. package/dist/cli-run-summary.d.ts +15 -0
  29. package/dist/cli-run-summary.js +33 -0
  30. package/dist/cli-usage.d.ts +1 -1
  31. package/dist/cli-usage.js +78 -5
  32. package/dist/cli-verify.d.ts +14 -0
  33. package/dist/cli-verify.js +54 -0
  34. package/dist/cli.js +15 -2
  35. package/dist/deprecation.d.ts +19 -0
  36. package/dist/deprecation.js +32 -0
  37. package/dist/diagnose.d.ts +25 -0
  38. package/dist/diagnose.js +69 -3
  39. package/dist/diff-compute.js +1 -0
  40. package/dist/doc-pack-io.d.ts +14 -0
  41. package/dist/doc-pack-io.js +121 -14
  42. package/dist/doc-pack.d.ts +2282 -387
  43. package/dist/doc-pack.js +135 -43
  44. package/dist/doctor-checks-plugins.js +4 -3
  45. package/dist/doctor-checks.d.ts +1 -1
  46. package/dist/doctor-checks.js +31 -6
  47. package/dist/doctor.d.ts +2 -0
  48. package/dist/doctor.js +27 -3
  49. package/dist/driver-budget.d.ts +6 -0
  50. package/dist/driver-budget.js +15 -0
  51. package/dist/egress-guard.d.ts +58 -0
  52. package/dist/egress-guard.js +136 -0
  53. package/dist/environment-spec.d.ts +67 -0
  54. package/dist/environment-spec.js +38 -0
  55. package/dist/export/playwright-test.js +42 -10
  56. package/dist/flow-file.d.ts +9 -3
  57. package/dist/flow-file.js +21 -1
  58. package/dist/flow-halt.d.ts +16 -0
  59. package/dist/flow-halt.js +76 -0
  60. package/dist/flow-hidden.d.ts +9 -0
  61. package/dist/flow-hidden.js +20 -0
  62. package/dist/flow-lint.js +91 -1
  63. package/dist/flow-matrix-lint.d.ts +10 -0
  64. package/dist/flow-matrix-lint.js +40 -0
  65. package/dist/flow-matrix.d.ts +44 -0
  66. package/dist/flow-matrix.js +238 -0
  67. package/dist/flow-name-rules.d.ts +15 -0
  68. package/dist/flow-name-rules.js +39 -0
  69. package/dist/flow-runtime.d.ts +52 -22
  70. package/dist/flow-runtime.js +63 -117
  71. package/dist/flow-success.d.ts +3 -0
  72. package/dist/flow-success.js +37 -0
  73. package/dist/flow-tree.d.ts +2 -0
  74. package/dist/flow-tree.js +17 -5
  75. package/dist/flow-wait.d.ts +3 -0
  76. package/dist/flow-wait.js +22 -0
  77. package/dist/index.d.ts +5 -0
  78. package/dist/index.js +5 -0
  79. package/dist/matrix-spec.d.ts +145 -0
  80. package/dist/matrix-spec.js +120 -0
  81. package/dist/page-hide.d.ts +10 -0
  82. package/dist/page-hide.js +45 -0
  83. package/dist/page-settle.d.ts +39 -0
  84. package/dist/page-settle.js +142 -0
  85. package/dist/playwright-driver.d.ts +28 -8
  86. package/dist/playwright-driver.js +73 -28
  87. package/dist/plugins/manifest.d.ts +9 -9
  88. package/dist/run-flows.d.ts +40 -0
  89. package/dist/run-flows.js +129 -0
  90. package/dist/style.d.ts +2 -2
  91. package/dist/upload-path.d.ts +15 -0
  92. package/dist/upload-path.js +63 -0
  93. package/dist/verify-compare.d.ts +43 -0
  94. package/dist/verify-compare.js +237 -0
  95. package/dist/verify-determinism.d.ts +16 -0
  96. package/dist/verify-determinism.js +88 -0
  97. package/dist/verify-report.d.ts +53 -0
  98. package/dist/verify-report.js +141 -0
  99. package/dist/verify-tree.d.ts +27 -0
  100. package/dist/verify-tree.js +95 -0
  101. package/dist/viewer-bin.d.ts +6 -0
  102. package/dist/viewer-bin.js +24 -0
  103. package/dist/zip.d.ts +2 -2
  104. package/package.json +3 -2
@@ -8,12 +8,12 @@ export declare const PreStep: z.ZodObject<{
8
8
  /** Env var *name* holding the fill value (required for `fill`). */
9
9
  value_env: z.ZodOptional<z.ZodString>;
10
10
  }, "strict", z.ZodTypeAny, {
11
- action: "click" | "fill";
12
11
  selector: string;
12
+ action: "fill" | "click";
13
13
  value_env?: string | undefined;
14
14
  }, {
15
- action: "click" | "fill";
16
15
  selector: string;
16
+ action: "fill" | "click";
17
17
  value_env?: string | undefined;
18
18
  }>;
19
19
  export type PreStep = z.infer<typeof PreStep>;
@@ -32,19 +32,19 @@ export declare const UiFormTotpOptions: z.ZodObject<{
32
32
  period: z.ZodDefault<z.ZodNumber>;
33
33
  algorithm: z.ZodDefault<z.ZodEnum<["sha1", "sha256"]>>;
34
34
  }, "strict", z.ZodTypeAny, {
35
+ digits: 8 | 6;
36
+ period: number;
37
+ algorithm: "sha1" | "sha256";
35
38
  secret_env: string;
36
39
  otp_selector: string;
37
40
  submit_selector?: string | undefined;
38
- digits: 6 | 8;
39
- period: number;
40
- algorithm: "sha1" | "sha256";
41
41
  }, {
42
42
  secret_env: string;
43
43
  otp_selector: string;
44
- submit_selector?: string | undefined;
45
- digits?: 6 | 8 | undefined;
44
+ digits?: 8 | 6 | undefined;
46
45
  period?: number | undefined;
47
46
  algorithm?: "sha1" | "sha256" | undefined;
47
+ submit_selector?: string | undefined;
48
48
  }>;
49
49
  export type UiFormTotpOptions = z.infer<typeof UiFormTotpOptions>;
50
50
  export declare const UiFormOptions: z.ZodEffects<z.ZodObject<{
@@ -67,12 +67,12 @@ export declare const UiFormOptions: z.ZodEffects<z.ZodObject<{
67
67
  /** Env var *name* holding the fill value (required for `fill`). */
68
68
  value_env: z.ZodOptional<z.ZodString>;
69
69
  }, "strict", z.ZodTypeAny, {
70
- action: "click" | "fill";
71
70
  selector: string;
71
+ action: "fill" | "click";
72
72
  value_env?: string | undefined;
73
73
  }, {
74
- action: "click" | "fill";
75
74
  selector: string;
75
+ action: "fill" | "click";
76
76
  value_env?: string | undefined;
77
77
  }>, "many">>;
78
78
  totp: z.ZodOptional<z.ZodObject<{
@@ -84,108 +84,108 @@ export declare const UiFormOptions: z.ZodEffects<z.ZodObject<{
84
84
  period: z.ZodDefault<z.ZodNumber>;
85
85
  algorithm: z.ZodDefault<z.ZodEnum<["sha1", "sha256"]>>;
86
86
  }, "strict", z.ZodTypeAny, {
87
+ digits: 8 | 6;
88
+ period: number;
89
+ algorithm: "sha1" | "sha256";
87
90
  secret_env: string;
88
91
  otp_selector: string;
89
92
  submit_selector?: string | undefined;
90
- digits: 6 | 8;
91
- period: number;
92
- algorithm: "sha1" | "sha256";
93
93
  }, {
94
94
  secret_env: string;
95
95
  otp_selector: string;
96
- submit_selector?: string | undefined;
97
- digits?: 6 | 8 | undefined;
96
+ digits?: 8 | 6 | undefined;
98
97
  period?: number | undefined;
99
98
  algorithm?: "sha1" | "sha256" | undefined;
99
+ submit_selector?: string | undefined;
100
100
  }>>;
101
101
  }, "strict", z.ZodTypeAny, {
102
+ timeout_ms: number;
102
103
  login_url: string;
104
+ ignore_https_errors: boolean;
105
+ submit_selector: string;
103
106
  username_selector: string;
104
107
  password_selector: string;
105
- submit_selector: string;
106
- success_selector?: string | undefined;
107
- url_matches?: string | undefined;
108
- timeout_ms: number;
109
- ignore_https_errors: boolean;
110
108
  pre_steps: {
111
- action: "click" | "fill";
112
109
  selector: string;
110
+ action: "fill" | "click";
113
111
  value_env?: string | undefined;
114
112
  }[];
113
+ url_matches?: string | undefined;
115
114
  totp?: {
115
+ digits: 8 | 6;
116
+ period: number;
117
+ algorithm: "sha1" | "sha256";
116
118
  secret_env: string;
117
119
  otp_selector: string;
118
120
  submit_selector?: string | undefined;
119
- digits: 6 | 8;
120
- period: number;
121
- algorithm: "sha1" | "sha256";
122
121
  } | undefined;
122
+ success_selector?: string | undefined;
123
123
  }, {
124
124
  login_url: string;
125
+ submit_selector: string;
125
126
  username_selector: string;
126
127
  password_selector: string;
127
- submit_selector: string;
128
- success_selector?: string | undefined;
129
- url_matches?: string | undefined;
130
128
  timeout_ms?: number | undefined;
131
- ignore_https_errors?: boolean | undefined;
132
- pre_steps?: {
133
- action: "click" | "fill";
134
- selector: string;
135
- value_env?: string | undefined;
136
- }[] | undefined;
129
+ url_matches?: string | undefined;
137
130
  totp?: {
138
131
  secret_env: string;
139
132
  otp_selector: string;
140
- submit_selector?: string | undefined;
141
- digits?: 6 | 8 | undefined;
133
+ digits?: 8 | 6 | undefined;
142
134
  period?: number | undefined;
143
135
  algorithm?: "sha1" | "sha256" | undefined;
136
+ submit_selector?: string | undefined;
144
137
  } | undefined;
138
+ ignore_https_errors?: boolean | undefined;
139
+ success_selector?: string | undefined;
140
+ pre_steps?: {
141
+ selector: string;
142
+ action: "fill" | "click";
143
+ value_env?: string | undefined;
144
+ }[] | undefined;
145
145
  }>, {
146
+ timeout_ms: number;
146
147
  login_url: string;
148
+ ignore_https_errors: boolean;
149
+ submit_selector: string;
147
150
  username_selector: string;
148
151
  password_selector: string;
149
- submit_selector: string;
150
- success_selector?: string | undefined;
151
- url_matches?: string | undefined;
152
- timeout_ms: number;
153
- ignore_https_errors: boolean;
154
152
  pre_steps: {
155
- action: "click" | "fill";
156
153
  selector: string;
154
+ action: "fill" | "click";
157
155
  value_env?: string | undefined;
158
156
  }[];
157
+ url_matches?: string | undefined;
159
158
  totp?: {
159
+ digits: 8 | 6;
160
+ period: number;
161
+ algorithm: "sha1" | "sha256";
160
162
  secret_env: string;
161
163
  otp_selector: string;
162
164
  submit_selector?: string | undefined;
163
- digits: 6 | 8;
164
- period: number;
165
- algorithm: "sha1" | "sha256";
166
165
  } | undefined;
166
+ success_selector?: string | undefined;
167
167
  }, {
168
168
  login_url: string;
169
+ submit_selector: string;
169
170
  username_selector: string;
170
171
  password_selector: string;
171
- submit_selector: string;
172
- success_selector?: string | undefined;
173
- url_matches?: string | undefined;
174
172
  timeout_ms?: number | undefined;
175
- ignore_https_errors?: boolean | undefined;
176
- pre_steps?: {
177
- action: "click" | "fill";
178
- selector: string;
179
- value_env?: string | undefined;
180
- }[] | undefined;
173
+ url_matches?: string | undefined;
181
174
  totp?: {
182
175
  secret_env: string;
183
176
  otp_selector: string;
184
- submit_selector?: string | undefined;
185
- digits?: 6 | 8 | undefined;
177
+ digits?: 8 | 6 | undefined;
186
178
  period?: number | undefined;
187
179
  algorithm?: "sha1" | "sha256" | undefined;
180
+ submit_selector?: string | undefined;
188
181
  } | undefined;
182
+ ignore_https_errors?: boolean | undefined;
183
+ success_selector?: string | undefined;
184
+ pre_steps?: {
185
+ selector: string;
186
+ action: "fill" | "click";
187
+ value_env?: string | undefined;
188
+ }[] | undefined;
189
189
  }>;
190
190
  export type UiFormOptions = z.infer<typeof UiFormOptions>;
191
191
  export declare class UiFormStrategy implements AuthStrategy {
@@ -17,64 +17,64 @@ export declare const WebauthnOptions: z.ZodEffects<z.ZodObject<{
17
17
  selector: z.ZodString;
18
18
  value_env: z.ZodOptional<z.ZodString>;
19
19
  }, "strict", z.ZodTypeAny, {
20
- action: "click" | "fill";
21
20
  selector: string;
21
+ action: "fill" | "click";
22
22
  value_env?: string | undefined;
23
23
  }, {
24
- action: "click" | "fill";
25
24
  selector: string;
25
+ action: "fill" | "click";
26
26
  value_env?: string | undefined;
27
27
  }>, "many">>;
28
28
  }, "strict", z.ZodTypeAny, {
29
- login_url: string;
30
- trigger_selector: string;
31
- username_selector?: string | undefined;
32
- success_selector?: string | undefined;
33
- url_matches?: string | undefined;
34
29
  timeout_ms: number;
30
+ login_url: string;
35
31
  ignore_https_errors: boolean;
36
32
  pre_steps: {
37
- action: "click" | "fill";
38
33
  selector: string;
34
+ action: "fill" | "click";
39
35
  value_env?: string | undefined;
40
36
  }[];
41
- }, {
42
- login_url: string;
43
37
  trigger_selector: string;
38
+ url_matches?: string | undefined;
44
39
  username_selector?: string | undefined;
45
40
  success_selector?: string | undefined;
46
- url_matches?: string | undefined;
41
+ }, {
42
+ login_url: string;
43
+ trigger_selector: string;
47
44
  timeout_ms?: number | undefined;
45
+ url_matches?: string | undefined;
48
46
  ignore_https_errors?: boolean | undefined;
47
+ username_selector?: string | undefined;
48
+ success_selector?: string | undefined;
49
49
  pre_steps?: {
50
- action: "click" | "fill";
51
50
  selector: string;
51
+ action: "fill" | "click";
52
52
  value_env?: string | undefined;
53
53
  }[] | undefined;
54
54
  }>, {
55
- login_url: string;
56
- trigger_selector: string;
57
- username_selector?: string | undefined;
58
- success_selector?: string | undefined;
59
- url_matches?: string | undefined;
60
55
  timeout_ms: number;
56
+ login_url: string;
61
57
  ignore_https_errors: boolean;
62
58
  pre_steps: {
63
- action: "click" | "fill";
64
59
  selector: string;
60
+ action: "fill" | "click";
65
61
  value_env?: string | undefined;
66
62
  }[];
67
- }, {
68
- login_url: string;
69
63
  trigger_selector: string;
64
+ url_matches?: string | undefined;
70
65
  username_selector?: string | undefined;
71
66
  success_selector?: string | undefined;
72
- url_matches?: string | undefined;
67
+ }, {
68
+ login_url: string;
69
+ trigger_selector: string;
73
70
  timeout_ms?: number | undefined;
71
+ url_matches?: string | undefined;
74
72
  ignore_https_errors?: boolean | undefined;
73
+ username_selector?: string | undefined;
74
+ success_selector?: string | undefined;
75
75
  pre_steps?: {
76
- action: "click" | "fill";
77
76
  selector: string;
77
+ action: "fill" | "click";
78
78
  value_env?: string | undefined;
79
79
  }[] | undefined;
80
80
  }>;
@@ -13,6 +13,8 @@ export interface Project {
13
13
  name: string;
14
14
  created_at: string;
15
15
  head_revision_id: string | null;
16
+ /** Base URL of the running app the project documents; webhook runs use it as the workspace `app_url`. */
17
+ app_url?: string;
16
18
  }
17
19
  export interface Revision {
18
20
  id: string;
@@ -41,8 +43,8 @@ export interface BlobRef {
41
43
  }
42
44
  export declare class BackendClientError extends Error {
43
45
  readonly status?: number | undefined;
44
- readonly body?: unknown;
45
- constructor(message: string, status?: number | undefined, body?: unknown);
46
+ readonly body?: unknown | undefined;
47
+ constructor(message: string, status?: number | undefined, body?: unknown | undefined);
46
48
  }
47
49
  export interface BackendClientOptions {
48
50
  baseUrl: string;
@@ -2,6 +2,7 @@
2
2
  // the resolution precedence (explicit → `DOCSX_TOKEN` → stored, with refresh-rotation), and the
3
3
  // load/save helpers. Re-exported from `./backend-client.js`.
4
4
  import { promises as fs } from "node:fs";
5
+ import { redactUrl, shellQuote } from "./cli-messages.js";
5
6
  import { resolveWorkspacePath, resolveWorkspacePathReal } from "./workspace.js";
6
7
  import { BackendClientError } from "./backend-client-contracts.js";
7
8
  const BACKEND_TOKEN_FILE = "backend-token.json";
@@ -53,7 +54,7 @@ export async function resolveBackendToken(opts) {
53
54
  return opts.token;
54
55
  if (process.env.DOCSX_TOKEN)
55
56
  return process.env.DOCSX_TOKEN;
56
- const reloginHint = `set DOCSX_TOKEN or run \`docsxai login --backend-url ${opts.baseUrl} --oauth <workspace-dir>\``;
57
+ const reloginHint = `set DOCSX_TOKEN or run \`docsxai login --backend-url ${shellQuote(redactUrl(opts.baseUrl))} --oauth <workspace-dir>\``;
57
58
  if (!opts.workspaceDir) {
58
59
  throw new BackendClientError(`no bearer token — ${reloginHint}`);
59
60
  }
@@ -1,7 +1,7 @@
1
1
  import { type FlowFile } from "./doc-pack.js";
2
2
  export declare class CalibrateError extends Error {
3
- readonly cause?: unknown;
4
- constructor(message: string, cause?: unknown);
3
+ readonly cause?: unknown | undefined;
4
+ constructor(message: string, cause?: unknown | undefined);
5
5
  }
6
6
  /**
7
7
  * Extract a flow-file from a structured flow-guide. Accepts: the YAML of a flow-file directly, or a Markdown
package/dist/calibrate.js CHANGED
@@ -10,6 +10,7 @@
10
10
  // that's the `/docsxai:calibrate` *skill* (see packages/plugin/skills/calibrate/SKILL.md); ambiguity
11
11
  // signalling lives at the MCP/skill layer. This module covers only the part that's deterministic.
12
12
  import { promises as fs } from "node:fs";
13
+ import { FlowName } from "./doc-pack.js";
13
14
  import { FlowFileError, parseFlowFile, serializeFlowFile } from "./flow-file.js";
14
15
  import { initStyleIfAbsent } from "./style.js";
15
16
  import { resolveWorkspacePath, resolveWorkspacePathReal } from "./workspace.js";
@@ -59,6 +60,10 @@ export function extractFlowFile(text, source = "<flow-guide>") {
59
60
  export async function calibrate(opts) {
60
61
  const flow = extractFlowFile(opts.fromText, opts.fromSource ?? "<flow-guide>");
61
62
  const name = opts.flowName ?? flow.name;
63
+ const checked = FlowName.safeParse(name);
64
+ if (!checked.success) {
65
+ throw new CalibrateError(`flow name "${name}" is not usable: ${checked.error.issues.map((i) => i.message).join("; ")}`);
66
+ }
62
67
  await fs.mkdir(resolveWorkspacePath(opts.workspaceDir, "flows"), { recursive: true });
63
68
  // The flow name is guide-supplied — resolve with the symlink-aware variant before writing.
64
69
  const flowFilePath = await resolveWorkspacePathReal(opts.workspaceDir, "flows", `${name}.flow.yaml`);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The message for a backend failure, or `undefined` when `e` is not one (the caller rethrows it).
3
+ * `login` is the command that signs in, so its own failures point at itself.
4
+ */
5
+ export declare function explainBackendFailure(e: unknown, backendUrl: string, workspaceDir?: string): string | undefined;
6
+ /** Why `.docsxai.json` did not load as a workspace config, as a phrase for parentheses. */
7
+ export declare function configProblem(workspaceDir: string): Promise<string>;
@@ -0,0 +1,65 @@
1
+ // Wording for backend failures in `login`, `push` and `pull`: what failed, why, and the next
2
+ // command. A refused connection reaches the CLI as a bare `TypeError: fetch failed` and a stack
3
+ // trace; this turns it into a line that names the backend and what to check. Backend URLs are
4
+ // printed without user:password, query or fragment, and text that came from the backend is stripped
5
+ // of terminal control characters.
6
+ import { promises as fs } from "node:fs";
7
+ import { BackendClientError } from "./backend-client.js";
8
+ import { redactUrl, sanitizeForTerminal, shellQuote, withNext } from "./cli-messages.js";
9
+ import { resolveWorkspacePath, WORKSPACE_CONFIG_FILE } from "./workspace.js";
10
+ /** The error code Node's fetch buries in `cause` (ECONNREFUSED, ENOTFOUND, ...), or the message when there is none. */
11
+ function networkReason(e) {
12
+ if (!(e instanceof Error))
13
+ return undefined;
14
+ const cause = e.cause;
15
+ const code = cause && typeof cause === "object" ? cause.code : undefined;
16
+ if (typeof code === "string")
17
+ return sanitizeForTerminal(code);
18
+ return e instanceof TypeError && /fetch failed/i.test(e.message) ? e.message : undefined;
19
+ }
20
+ /**
21
+ * The message for a backend failure, or `undefined` when `e` is not one (the caller rethrows it).
22
+ * `login` is the command that signs in, so its own failures point at itself.
23
+ */
24
+ export function explainBackendFailure(e, backendUrl, workspaceDir) {
25
+ const url = redactUrl(backendUrl);
26
+ const login = `docsxai login --backend-url ${shellQuote(url)}`;
27
+ const reason = networkReason(e);
28
+ if (reason !== undefined) {
29
+ return withNext(`cannot reach ${url} (${reason})`, `check backend_url in ${WORKSPACE_CONFIG_FILE} and that the backend is running, then ${login}`);
30
+ }
31
+ if (!(e instanceof BackendClientError))
32
+ return undefined;
33
+ // The message carries the start of the response body, which the backend controls.
34
+ const message = sanitizeForTerminal(e.message);
35
+ if (e.status === 401 || e.status === 403) {
36
+ const oauth = workspaceDir
37
+ ? ` (or add --oauth ${shellQuote(workspaceDir)} to sign in as a person)`
38
+ : "";
39
+ return withNext(`${message}\n why: ${url} rejected the token`, `${login}${oauth}`);
40
+ }
41
+ if (e.status === 404) {
42
+ return withNext(message, `check backend_workspace_id and backend_project_id in ${WORKSPACE_CONFIG_FILE}, or remove them and push again`);
43
+ }
44
+ if (e.status !== undefined && e.status >= 500) {
45
+ return withNext(`${message}\n why: ${url} failed on its side`, "check the backend's logs, then retry");
46
+ }
47
+ return message;
48
+ }
49
+ /** Why `.docsxai.json` did not load as a workspace config, as a phrase for parentheses. */
50
+ export async function configProblem(workspaceDir) {
51
+ let text;
52
+ try {
53
+ text = await fs.readFile(resolveWorkspacePath(workspaceDir, WORKSPACE_CONFIG_FILE), "utf8");
54
+ }
55
+ catch {
56
+ return "the file does not exist";
57
+ }
58
+ try {
59
+ JSON.parse(text);
60
+ }
61
+ catch (e) {
62
+ return `it is not valid JSON: ${e.message}`;
63
+ }
64
+ return 'its "schema" must be "docsxai/workspace@1"';
65
+ }