@impetik/xeer-mcp 0.2.5 → 0.2.6
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 +4 -1
- package/dist/dev-session.d.ts +1 -1
- package/dist/network-policy.js +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +4 -4
- package/dist/test-run.d.ts +1 -1
- package/dist/xeer-cli.d.ts +1 -1
- package/package.json +8 -5
- package/vendor/spec/actions.d.ts +1250 -0
- package/vendor/spec/actions.js +805 -0
- package/vendor/spec/admin-sql.d.ts +59 -0
- package/vendor/spec/admin-sql.js +147 -0
- package/vendor/spec/admin.d.ts +110 -0
- package/vendor/spec/admin.js +58 -0
- package/vendor/spec/canonical.d.ts +3 -0
- package/vendor/spec/canonical.js +36 -0
- package/vendor/spec/diagnostics.d.ts +49 -0
- package/vendor/spec/diagnostics.js +500 -0
- package/vendor/spec/docs.d.ts +21 -0
- package/vendor/spec/docs.js +57 -0
- package/vendor/spec/events.d.ts +8 -0
- package/vendor/spec/events.js +21 -0
- package/vendor/spec/identity-keys.d.ts +36 -0
- package/vendor/spec/identity-keys.js +72 -0
- package/vendor/spec/index.d.ts +20 -0
- package/vendor/spec/index.js +20 -0
- package/vendor/spec/local-identity.d.ts +69 -0
- package/vendor/spec/local-identity.js +132 -0
- package/vendor/spec/network-policy.d.ts +16 -0
- package/vendor/spec/network-policy.js +50 -0
- package/vendor/spec/public-assets.d.ts +153 -0
- package/vendor/spec/public-assets.js +166 -0
- package/vendor/spec/review.d.ts +82 -0
- package/vendor/spec/review.js +175 -0
- package/vendor/spec/route.d.ts +43 -0
- package/vendor/spec/route.js +87 -0
- package/vendor/spec/schema-lifecycle.d.ts +6 -0
- package/vendor/spec/schema-lifecycle.js +59 -0
- package/vendor/spec/schema-plan.d.ts +98 -0
- package/vendor/spec/schema-plan.js +194 -0
- package/vendor/spec/schema.d.ts +166 -0
- package/vendor/spec/schema.js +409 -0
- package/vendor/spec/sql-expression.d.ts +91 -0
- package/vendor/spec/sql-expression.js +650 -0
- package/vendor/spec/state-export.d.ts +143 -0
- package/vendor/spec/state-export.js +341 -0
- package/vendor/spec/storage.d.ts +61 -0
- package/vendor/spec/storage.js +120 -0
- package/vendor/spec/table-ddl.d.ts +162 -0
- package/vendor/spec/table-ddl.js +508 -0
- package/vendor/spec/types.d.ts +275 -0
- package/vendor/spec/types.js +11 -0
- package/vendor/spec/value.d.ts +22 -0
- package/vendor/spec/value.js +72 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The diagnostic catalogue.
|
|
3
|
+
*
|
|
4
|
+
* Xeer's primary user is a coding agent, so a diagnostic code is a stable API:
|
|
5
|
+
* an agent dispatches on `code`, not on wording. This module is the single
|
|
6
|
+
* declaration of what each code means and which edit closes it, and the agent
|
|
7
|
+
* reference shipped with the skill is rendered from it by
|
|
8
|
+
* `renderDiagnosticsReference()` rather than written by hand.
|
|
9
|
+
*
|
|
10
|
+
* `packages/spec/src/diagnostics.test.ts` scans every non-test source file in
|
|
11
|
+
* the workspace for `XE####` literals and fails when the emitted set and this
|
|
12
|
+
* catalogue disagree in either direction, so a new code cannot ship
|
|
13
|
+
* undocumented and a retired code cannot linger here.
|
|
14
|
+
*/
|
|
15
|
+
export const DIAGNOSTIC_FAMILIES = [
|
|
16
|
+
{
|
|
17
|
+
prefix: 'XE00',
|
|
18
|
+
title: 'CLI',
|
|
19
|
+
summary: 'The command itself failed. Not an application defect.',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
prefix: 'XE10',
|
|
23
|
+
title: 'Manifest',
|
|
24
|
+
summary: 'xeer.app.json is missing, unparseable, or violates the application-source schema — '
|
|
25
|
+
+ 'including the database schema, indexes, capabilities, and budgets it declares.',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
prefix: 'XE11',
|
|
29
|
+
title: 'Manifest paths',
|
|
30
|
+
summary: 'A manifest path does not resolve to a file inside the project root.',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
prefix: 'XE12',
|
|
34
|
+
title: 'Module graph and zones',
|
|
35
|
+
summary: 'The client and server graphs are walked separately. Each zone has its own package '
|
|
36
|
+
+ 'allowlist, every import must be a static literal resolving inside the project, and shared '
|
|
37
|
+
+ 'code lives under src/shared/. Type errors in the reachable graph land here too.',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
prefix: 'XE13',
|
|
41
|
+
title: 'Operations',
|
|
42
|
+
summary: 'The default defineServer({...}) export is read statically, so operation and endpoint '
|
|
43
|
+
+ 'registration must be a literal object with valid, unambiguous names.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
prefix: 'XE14',
|
|
47
|
+
title: 'Budgets and assets',
|
|
48
|
+
summary: 'A module or public asset breaks a v0 size limit, collides with generated output, or '
|
|
49
|
+
+ 'claims a platform-reserved path.',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
prefix: 'XE15',
|
|
53
|
+
title: 'Bundling',
|
|
54
|
+
summary: 'The client or server bundle failed after analysis passed.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
prefix: 'XE16',
|
|
58
|
+
title: 'Development loop',
|
|
59
|
+
summary: 'A watch rebuild failed. The last-good preview stays active and is rolled back to; '
|
|
60
|
+
+ 'these codes arrive as compile.diagnostic events, never as a dead server.',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
prefix: 'XE17',
|
|
64
|
+
title: 'Artifact preview',
|
|
65
|
+
summary: 'xeer preview verifies the content-addressed artifact and its blobs before booting. '
|
|
66
|
+
+ 'These codes mean the build output is missing, malformed, or does not match its own identity.',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
prefix: 'XE18',
|
|
70
|
+
title: 'Local state and state transfer',
|
|
71
|
+
summary: 'Local dev/preview/test state is leased per project and mode, destructive resets are '
|
|
72
|
+
+ 'confirmed by exact application name, and `xeer export`/`xeer import` move it as a versioned '
|
|
73
|
+
+ 'xeer.state-export.v0 document that must fit the schema currently in force.',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
prefix: 'XE19',
|
|
77
|
+
title: 'Tests',
|
|
78
|
+
summary: 'xeer test builds the project, type-checks tests/**/*.test.ts against the generated '
|
|
79
|
+
+ 'contract, and runs each test against a fresh isolated state. A failure carries the standard '
|
|
80
|
+
+ 'Diagnostic fields plus kind, matcher, expected, and actual, so the same parser handles it.',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
prefix: 'XE20',
|
|
84
|
+
title: 'Inspector',
|
|
85
|
+
summary: 'An inspector request failed. Locally the target is a preview URL; for a deployed app the '
|
|
86
|
+
+ 'request is routed through the control plane and requires builder ownership.',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
prefix: 'XE30',
|
|
90
|
+
title: 'Scaffold',
|
|
91
|
+
summary: 'xeer new could not create the project.',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
prefix: 'XE31',
|
|
95
|
+
title: 'Agent setup',
|
|
96
|
+
summary: 'xeer agent setup found missing, stale, invalid, or user-owned adapter files.',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
prefix: 'XE40',
|
|
100
|
+
title: 'Environment',
|
|
101
|
+
summary: 'xeer doctor found a broken toolchain or generated-file state. The failing check id and '
|
|
102
|
+
+ 'details are in result.checks.',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
prefix: 'XE50',
|
|
106
|
+
title: 'Builder authentication',
|
|
107
|
+
summary: 'Builder sign-in against the control plane. Sign-in is a human step; an agent reads '
|
|
108
|
+
+ 'these codes and asks for it.',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
prefix: 'XE51',
|
|
112
|
+
title: 'Deployment, project identity, environment variables, and service tokens',
|
|
113
|
+
summary: 'The deployment itself; the checked-in xeer.project.json appId that decides which hosted '
|
|
114
|
+
+ 'app a checkout deploys to, where the repair is always xeer link rather than a new appId; the '
|
|
115
|
+
+ 'per-project encrypted environment store behind xeer env; and the deployment history behind '
|
|
116
|
+
+ 'xeer deployments; plus the hidden service-token lifecycle behind xeer token.',
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
// dev, build, and test all run the same compiler, so anything check reports can
|
|
120
|
+
// also arrive from them. That is the property that makes check the cheap
|
|
121
|
+
// pre-flight for the other three.
|
|
122
|
+
const CHECKED_BY_EVERY_COMPILE = ['check', 'build', 'dev', 'test'];
|
|
123
|
+
const BUILT_BY_EVERY_BUILD = ['build', 'dev', 'test'];
|
|
124
|
+
function define(code, means, repair, surfaces) {
|
|
125
|
+
return { code, prefix: code.slice(0, 4), means, repair, surfaces };
|
|
126
|
+
}
|
|
127
|
+
export const DIAGNOSTIC_DEFINITIONS = [
|
|
128
|
+
define('XE0000', 'The CLI crashed before it could report a structured result. Written to stderr, so it '
|
|
129
|
+
+ 'is the one code that can arrive outside a JSON envelope.', 'Report it: an internal error is a platform bug, not a project defect. stderr carries the stack.', ['any']),
|
|
130
|
+
define('XE0001', 'Unknown or unimplemented command.', 'Read `xeer --help` and use a documented command.', ['any']),
|
|
131
|
+
define('XE0002', 'A CLI option is unknown, lacks its required value, or assigns a value to a boolean flag.', 'Use an option shown by `xeer --help`; preview deployment is `xeer deploy --environment preview`.', ['any']),
|
|
132
|
+
define('XE1001', 'xeer.app.json was not found in the target directory.', 'Run `xeer new <directory>`, or point the command at the project root that holds the manifest.', CHECKED_BY_EVERY_COMPILE),
|
|
133
|
+
define('XE1002', 'A manifest value is invalid: bad JSON, a failed schema rule, or an entrypoint that '
|
|
134
|
+
+ 'does not exist. Also covers the declared database schema — unknown field types, an index naming '
|
|
135
|
+
+ 'a field the table does not declare, reserved field names, and tables declared without the '
|
|
136
|
+
+ '"database" capability — and every capability declaration: an unknown capability name, one '
|
|
137
|
+
+ 'declared twice, a config block whose capability is not in `capabilities` (or the reverse), and a '
|
|
138
|
+
+ 'declared limit above the platform ceiling.', 'Read the message: it names the failing manifest path (for example database.tables.notes.indexes.by_owner) '
|
|
139
|
+
+ 'and the rule. Correct that one value. A capability and its config block are one declaration in two '
|
|
140
|
+
+ 'halves — `"capabilities": ["storage"]` and a `"storage": {}` block — so either add the missing half '
|
|
141
|
+
+ 'or remove the present one.', CHECKED_BY_EVERY_COMPILE),
|
|
142
|
+
define('XE1003', 'The manifest carries a property the application-source schema does not define.', 'Remove the property, or fix its spelling. The manifest is closed: unknown keys are never ignored.', CHECKED_BY_EVERY_COMPILE),
|
|
143
|
+
define('XE1101', 'An entrypoint path is absolute or escapes the project root.', 'Use a forward-slash path relative to xeer.app.json that stays inside the project.', CHECKED_BY_EVERY_COMPILE),
|
|
144
|
+
define('XE1201', 'A source import breaks the zone boundary: it is absolute, leaves the project root, '
|
|
145
|
+
+ 'reaches the opposite entrypoint, or the module is reachable from both graphs while living outside '
|
|
146
|
+
+ 'src/shared/.', 'Keep imports relative and inside the project. Move genuinely shared code to src/shared/ and update '
|
|
147
|
+
+ 'both importers; never import one entrypoint from the other.', CHECKED_BY_EVERY_COMPILE),
|
|
148
|
+
define('XE1202', 'A package import is not on the allowlist for that zone.', 'The client zone may import @impetik/xeer/client, /shared, the JSX runtimes, and preact; the server '
|
|
149
|
+
+ 'zone may import @impetik/xeer/server and /shared. Node builtins are never importable. Move the code '
|
|
150
|
+
+ 'to the zone that owns it instead of widening the import.', CHECKED_BY_EVERY_COMPILE),
|
|
151
|
+
define('XE1203', 'A dynamic import() specifier is not a string literal.', 'Use a literal specifier so the module graph stays statically knowable, or a static import.', CHECKED_BY_EVERY_COMPILE),
|
|
152
|
+
define('XE1204', 'A relative source import does not resolve to a file.', 'Write the specifier without an extension, or with the file\'s real one: the resolver appends '
|
|
153
|
+
+ 'candidate extensions rather than rewriting them, so ./shared/title.js does not find '
|
|
154
|
+
+ 'shared/title.ts. Directory imports resolve to index.*.', CHECKED_BY_EVERY_COMPILE),
|
|
155
|
+
define('XE1205', 'TypeScript reported an error in a file reachable from an entrypoint. The message '
|
|
156
|
+
+ 'starts with the TS#### code and span points at the exact position.', 'Fix the type error. Operation input and result types come from the generated contract, so a mismatch '
|
|
157
|
+
+ 'between a client call and its server handler surfaces here.', CHECKED_BY_EVERY_COMPILE),
|
|
158
|
+
define('XE1206', 'A stylesheet is imported outside the client graph.', 'Import .css only from client modules; the server bundle has no styling stage.', CHECKED_BY_EVERY_COMPILE),
|
|
159
|
+
define('XE1300', 'The default server export is not a statically inspectable defineServer({...}) call, '
|
|
160
|
+
+ 'or an operation group is not a literal object.', 'Export `default defineServer({ queries: {...}, mutations: {...}, endpoints: {...} })` with literal '
|
|
161
|
+
+ 'object members: no spreads, shorthand, computed keys, or wrappers.', CHECKED_BY_EVERY_COMPILE),
|
|
162
|
+
define('XE1301', 'Two operations in the same group share a name.', 'Rename one of them, or delete the duplicate registration if it was a copy-paste.', CHECKED_BY_EVERY_COMPILE),
|
|
163
|
+
define('XE1302', 'An endpoint key is not `METHOD /api/path`.', 'Use an uppercase HTTP method, one space, and a literal /api path; dynamic segments are :name.', CHECKED_BY_EVERY_COMPILE),
|
|
164
|
+
define('XE1303', 'A query or mutation name is not namespaced.', 'Use a dotted lowercase name such as notes.list.', CHECKED_BY_EVERY_COMPILE),
|
|
165
|
+
define('XE1304', 'Two endpoints reduce to the same route shape, so dispatch would be ambiguous.', 'Change the method or a static path segment. Parameter names do not distinguish routes: '
|
|
166
|
+
+ 'GET /api/notes/:id and GET /api/notes/:slug are the same route.', CHECKED_BY_EVERY_COMPILE),
|
|
167
|
+
define('XE1401', 'A compiled module (10 MiB) or an asset (25 MiB) exceeds the v0 limit.', 'Shrink the module or asset. There is no flag that raises a v0 limit.', BUILT_BY_EVERY_BUILD),
|
|
168
|
+
define('XE1402', 'A file in public/ collides with generated output.', 'Rename the public file; the platform generates the application document at /index.html.', BUILT_BY_EVERY_BUILD),
|
|
169
|
+
define('XE1403', 'A file in public/ claims a platform-reserved path.', 'Move it: /_xeer/*, /__xeer/* and /_xa/* belong to the platform.', BUILT_BY_EVERY_BUILD),
|
|
170
|
+
define('XE1404', 'The manifest declares a favicon the project does not ship in public/.', 'Add the file under public/, or drop app.favicon. Emitting the reference anyway would put a '
|
|
171
|
+
+ 'link that 404s into every document the application serves.', BUILT_BY_EVERY_BUILD),
|
|
172
|
+
define('XE1501', 'Bundling failed after the module graph and types were accepted.', 'Read the bundler message in `message`. It usually names a syntax construct the target does not '
|
|
173
|
+
+ 'support, rather than a Xeer rule.', BUILT_BY_EVERY_BUILD),
|
|
174
|
+
define('XE1602', 'A watch rebuild failed. The previously accepted generation is still serving.', 'Fix the edit named by `file`. The next quiet-window rebuild promotes automatically; no restart.', ['dev']),
|
|
175
|
+
define('XE1603', 'A rebuilt candidate compiled but failed to take over — usually a manifest or schema '
|
|
176
|
+
+ 'change the running state cannot accept — and the last-good generation was restored.', 'Fix the manifest or schema change. To adopt an incompatible schema locally, stop dev and run '
|
|
177
|
+
+ '`xeer state reset . --state dev --confirm <application>`.', ['dev']),
|
|
178
|
+
define('XE1604', 'The manifest could not be watched for changes, so edits to it will not rebuild the '
|
|
179
|
+
+ 'preview. Everything already serving keeps serving.', 'On Linux this is normally an exhausted inotify allowance: raise `fs.inotify.max_user_watches` and '
|
|
180
|
+
+ '`fs.inotify.max_user_instances`. Restart `xeer dev` afterwards.', ['dev']),
|
|
181
|
+
// `xeer build` runs the same verification `preview`, `test` and `deploy` gate on, against the
|
|
182
|
+
// artifact it has just written, so these four codes are build surfaces too: a build that cannot
|
|
183
|
+
// be previewed is reported as a failed build rather than a success (issue #56).
|
|
184
|
+
define('XE1700', 'No verifiable build artifact was found for preview.', 'Run `xeer build` first; preview never compiles.', ['build', 'preview', 'test', 'deploy', 'state']),
|
|
185
|
+
define('XE1701', 'The artifact, its latest pointer, or its server source map is malformed.', 'Rebuild with `xeer build`. Do not hand-edit anything under .xeer/build/. If a fresh build '
|
|
186
|
+
+ 'reports this itself, it is a compiler defect: report it with the diagnostic.', ['build', 'preview', 'test', 'deploy', 'state']),
|
|
187
|
+
define('XE1702', 'The artifact does not match its own content-addressed identity or schema identity.', 'Rebuild. A mismatch means the output was mutated after it was written.', ['build', 'preview', 'test', 'deploy', 'state']),
|
|
188
|
+
define('XE1703', 'An artifact blob is missing, the wrong size, or hashes differently than its receipt.', 'Rebuild. The build output is incomplete or corrupted.', ['build', 'preview', 'test', 'deploy', 'state']),
|
|
189
|
+
define('XE1704', 'The artifact preview server failed to start or crashed.', 'Read `message`. Re-run `xeer build`, then preview again.', ['preview']),
|
|
190
|
+
define('XE1705', 'The latest build is stale: source files recorded in the artifact have changed on '
|
|
191
|
+
+ 'disk since it was made, so running it would run code the project no longer has. Compared by '
|
|
192
|
+
+ 'content hash, never by timestamp. `message` names the changed files.', 'Run `xeer build`. `xeer deploy` and `xeer test` build for you, so this means the build is older '
|
|
193
|
+
+ 'than the edit — most often `xeer preview`, which runs the last verified artifact and never '
|
|
194
|
+
+ 'compiles.', ['build', 'preview', 'test', 'deploy']),
|
|
195
|
+
define('XE1801', 'A state command was invoked without a valid --state selector.', 'Pass `--state dev`, `--state preview`, or `--state test`. The three modes never share a root.', ['state']),
|
|
196
|
+
define('XE1810', 'A destructive state command was invoked without --confirm.', 'Pass `--confirm <application>` using the manifest `name` exactly.', ['state']),
|
|
197
|
+
define('XE1811', 'The --confirm value does not match the application name.', 'Use the manifest `name` verbatim; the guard is exact-match by design.', ['state']),
|
|
198
|
+
define('XE1812', 'The local state lease for that project and mode could not be acquired, or is held by '
|
|
199
|
+
+ 'a live process. Two concurrent `xeer test` runs in one project report this rather than racing.', 'Stop the other `xeer dev`/`xeer preview`/`xeer test` for this project and retry.', ['dev', 'preview', 'test', 'state']),
|
|
200
|
+
define('XE1813', 'The resolved state directory escapes its Xeer-owned project or local-data container, '
|
|
201
|
+
+ 'or traverses a link.', 'Remove the link under .xeer/ (or the Xeer/state local-data directory on an overlong Windows path) and retry.', ['dev', 'preview', 'test', 'state']),
|
|
202
|
+
define('XE1814', 'A local state operation failed for an underlying filesystem reason.', 'Read `message`. Usually permissions or a partially removed .xeer/ directory.', ['dev', 'preview', 'test', 'state']),
|
|
203
|
+
define('XE1820', 'No `xeer dev`/`xeer preview` server owns that mode\'s state in that directory, or it '
|
|
204
|
+
+ 'has not published its address yet. Local state lives in a Durable Object, so only the running '
|
|
205
|
+
+ 'runtime can read or write it.', 'Start `xeer dev` (or `xeer preview`) in that directory and re-run, or pass a deployed application '
|
|
206
|
+
+ 'name, appId, or URL instead.', ['export', 'import']),
|
|
207
|
+
define('XE1840', 'No `xeer dev`/`xeer preview` server is running for that directory, so its database '
|
|
208
|
+
+ 'cannot be reached. The database lives inside a Durable Object; the running runtime is the only '
|
|
209
|
+
+ 'thing that can read it consistently.', 'Start `xeer dev` (or `xeer preview`) in that directory and re-run.', ['db']),
|
|
210
|
+
define('XE1841', 'The running server published no admin session secret, so its database surface is '
|
|
211
|
+
+ 'not reachable. The secret is minted per run and shared through the state lease.', 'Restart the server with a build that publishes one; a server older than this CLI does not.', ['db']),
|
|
212
|
+
define('XE1842', 'The server answered the database request with a protocol this CLI does not know.', 'The CLI and the running server are different versions. Restart the server from this checkout.', ['db']),
|
|
213
|
+
define('XE1821', 'The export file could not be read or written.', 'Read `message`: usually a missing path or permissions. `--out` creates parent directories.', ['export', 'import']),
|
|
214
|
+
define('XE1822', 'The document is not a usable xeer.state-export.v0 export: wrong protocol, or it '
|
|
215
|
+
+ 'contradicts itself (counts, schema, or an encoded value).', 'Import the unmodified file `xeer export --out` produced. `detail.code` names the exact defect.', ['export', 'import']),
|
|
216
|
+
define('XE1823', '`xeer import` was pointed at a deployed application. It writes local dev and '
|
|
217
|
+
+ 'preview state only; a deployed import needs a write-scoped grant and a pre-import snapshot.', 'Import into `xeer dev`/`xeer preview` state (`--state dev`), verify there, and `xeer deploy`.', ['import']),
|
|
218
|
+
define('XE1824', 'The runtime refused the transfer. `detail.code` is the reason: '
|
|
219
|
+
+ 'state_import_schema_mismatch, state_import_application_mismatch, state_import_record_invalid, '
|
|
220
|
+
+ 'or state_export_too_large.', 'For a schema mismatch, `detail.expected` and `detail.found` carry both schema identities: check '
|
|
221
|
+
+ 'out the schema the export came from, import there, and let the compatible-change path carry the '
|
|
222
|
+
+ 'data forward, or re-export from the current schema. There is no forced import.', ['export', 'import']),
|
|
223
|
+
define('XE1825', 'The command was invoked without a usable target, without the export file, or with a '
|
|
224
|
+
+ '--state value other than dev or preview.', 'Pass `<preview-url|app>` or `--state dev|preview [directory]`; `xeer import` also needs the file.', ['export', 'import']),
|
|
225
|
+
define('XE1900', 'xeer test found no test files.', 'Create tests/<name>.test.ts importing test, as, and expect from @impetik/xeer/test. '
|
|
226
|
+
+ '`xeer new` scaffolds a passing suite to copy.', ['test']),
|
|
227
|
+
define('XE1901', 'A test file could not be compiled.', 'Read `message`: it is the bundler error for that file. Test files may import '
|
|
228
|
+
+ '@impetik/xeer/test, @impetik/xeer/shared, and project-relative modules.', ['test']),
|
|
229
|
+
define('XE1902', 'The test runtime failed to start.', 'Not a test failure. Run `xeer build` and `xeer doctor` — the artifact or the local workerd '
|
|
230
|
+
+ 'toolchain is the problem.', ['test']),
|
|
231
|
+
define('XE1903', 'A test file threw while loading, so none of its tests ran. Other files still run.', 'Move work out of module scope and into a test body; only test registration belongs at the top level.', ['test']),
|
|
232
|
+
define('XE1904', 'An assertion failed. The failure carries `matcher`, `expected`, `actual`, and the '
|
|
233
|
+
+ 'project-relative test location.', 'Decide which side is wrong. If the application is wrong, fix it and re-run; if the expectation is '
|
|
234
|
+
+ 'wrong, fix the test. Never delete the assertion to go green.', ['test']),
|
|
235
|
+
define('XE1905', 'A test threw, including a call that was refused when the test did not expect it. '
|
|
236
|
+
+ '`operation` names the persona, operation, status, and runtime error code.', 'When the refusal is the point, wrap the call in expectFailure(). A refused workspace-scoped call '
|
|
237
|
+
+ "usually means the persona's declared membership does not contain the workspace the operation "
|
|
238
|
+
+ "names: pass it with as({ name, workspaceIds }).", ['test']),
|
|
239
|
+
define('XE1906', 'A test exceeded its 20 second budget. The remaining tests still run.', 'Remove the wait: tests run against a local runtime, so a timeout means an unresolved promise or an '
|
|
240
|
+
+ 'operation that never returns, not a slow machine.', ['test']),
|
|
241
|
+
define('XE2001', 'An inspector command was invoked without a target.', 'Pass the preview URL from the dev/preview `preview.ready` event, or a deployed application name, '
|
|
242
|
+
+ 'appId, or URL.', ['inspect', 'state']),
|
|
243
|
+
define('XE2002', 'The inspector request itself failed: a local dev/preview inspector that answered '
|
|
244
|
+
+ 'a non-2xx status or no JSON, or a control plane that refused the proxied read, in which case '
|
|
245
|
+
+ 'the read never reached the application. An application that refused the read is XE2004.', 'Confirm the preview is still running and the URL matches the current `preview.ready` event. For a '
|
|
246
|
+
+ 'deployed read, `message` carries the control plane\'s own refusal.', ['inspect', 'state']),
|
|
247
|
+
define('XE2003', 'No deployed application matched the inspector target for the signed-in builder.', 'Pass the application name from xeer.app.json, its appId, or its deployed URL, and confirm with '
|
|
248
|
+
+ '`xeer auth status` that you are signed in as its owner.', ['inspect', 'state']),
|
|
249
|
+
define('XE2004', 'The deployed application refused the read itself, and the control plane forwarded '
|
|
250
|
+
+ "its answer. The application's own runtime code, its errorId, and the cause are in `message`, "
|
|
251
|
+
+ 'and in `detail` as `code`, `errorId`, and `appId`.', 'Dispatch on `detail.code`, not on the wording. `state_bootstrap_failed` means the application '
|
|
252
|
+
+ 'state never bootstrapped, so the read never ran: fix the cause named in `message` and redeploy. '
|
|
253
|
+
+ '`state_unavailable` means the read never reached the state object at all — most often a '
|
|
254
|
+
+ 'brand-new application whose state namespace is not dispatchable yet — so there is nothing to '
|
|
255
|
+
+ 'fix: wait out the advertised retry and read again. '
|
|
256
|
+
+ "Quote `detail.errorId` when correlating with the Worker's console output.", ['inspect', 'state', 'export']),
|
|
257
|
+
define('XE3001', 'xeer new could not scaffold the project — most often a non-empty target directory.', 'Choose an empty or non-existent directory.', ['new']),
|
|
258
|
+
define('XE3002', '`--template` named a scaffold that does not exist. Refused before the target '
|
|
259
|
+
+ 'directory is read, so nothing was written.', 'Use one of the names the message lists, or omit --template for the default. `xeer --help` '
|
|
260
|
+
+ 'describes each template.', ['new']),
|
|
261
|
+
define('XE3101', 'Agent setup check found one or more generated files missing or stale. No files were written.', 'Run `xeer agent setup`, then repeat `xeer agent setup --check --json`.', ['agent']),
|
|
262
|
+
define('XE3102', 'Agent setup found a path owned by the user or another tool. The entire write was refused.', 'Move, rename, or deliberately remove the conflicting path; setup never overwrites an unowned file.', ['agent']),
|
|
263
|
+
define('XE3103', '`--target` named an agent adapter that Xeer does not support.', 'Use auto, agents, claude, codex, cursor, vscode, or mcp.', ['agent']),
|
|
264
|
+
define('XE4001', 'A doctor check failed. `hint` carries the check details as JSON, and result.checks '
|
|
265
|
+
+ 'lists every check with its id and status.', 'Fix the environment problem the failing check names. Doctor never edits the project.', ['doctor']),
|
|
266
|
+
define('XE5000', 'An auth subcommand was invoked with wrong arguments.', 'Use `xeer auth <login|status|logout|as|clear>`; `auth as` takes alice or bob.', ['auth']),
|
|
267
|
+
define('XE5001', 'The --control-url value is not an exact HTTP(S) origin, or is plain HTTP off localhost.', 'Pass an origin such as https://control.example.com with no path.', ['auth', 'deploy']),
|
|
268
|
+
define('XE5002', 'No valid builder credential is stored.', 'A human must run `xeer auth login` and approve the shown code. An agent cannot complete sign-in.', ['auth', 'deploy']),
|
|
269
|
+
define('XE5004', 'The control plane returned a response the CLI will not trust.', 'Retry; if it persists the control plane is misconfigured or unreachable. Not a project defect.', ['auth']),
|
|
270
|
+
define('XE5005', 'The device authorization expired before sign-in completed.', 'Run `xeer auth login` again and approve promptly.', ['auth']),
|
|
271
|
+
define('XE5008', 'The stored CLI credential file is unreadable or invalid.', 'Run `xeer auth logout` and sign in again.', ['auth', 'deploy']),
|
|
272
|
+
define('XE5009', 'An auth command failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['auth']),
|
|
273
|
+
define('XE5101', 'The deployment Worker module could not be constructed from the artifact.', 'Re-run `xeer build` and inspect the artifact; the build output is incomplete.', ['deploy']),
|
|
274
|
+
define('XE5102', 'The control plane rejected the deployment or answered without a usable JSON envelope.', 'Read `message`: it carries the control-plane error. Check sign-in and that the project name is claimable.', ['deploy']),
|
|
275
|
+
define('XE5103', 'The deployment was accepted but the deployed runtime never became ready.', 'The upload succeeded; the runtime did not. Retry, then report it — the artifact is already recorded.', ['deploy']),
|
|
276
|
+
define('XE5104', 'The deployment serves assets but authenticated requests fail.', 'A platform identity problem, not an application one. Report it with the diagnostic message.', ['deploy']),
|
|
277
|
+
define('XE5105', 'The --environment value is not a deployable scope.', 'Pass prod, production, or preview. `dev` is a local-only scope that `xeer env pull` writes to a '
|
|
278
|
+
+ 'gitignored file; no deployment ever injects it.', ['deploy']),
|
|
279
|
+
define('XE5106', 'A capability the manifest declares could not be provisioned. Either the control '
|
|
280
|
+
+ 'plane could not create or adopt the backing resource (a per-app R2 bucket for "storage"), it is '
|
|
281
|
+
+ 'not configured to provision at all, or it does not support that capability name. Nothing was '
|
|
282
|
+
+ 'activated: the previous version is still serving.', 'Retry the deployment — provisioning is adopt-or-create, so a half-finished attempt heals on the '
|
|
283
|
+
+ 'next one. A capability the control plane does not recognise is not retryable: remove it from '
|
|
284
|
+
+ '`capabilities` in xeer.app.json, or deploy against a control plane that supports it. `message` '
|
|
285
|
+
+ 'carries the control plane\'s own reason.', ['deploy', 'promote', 'rollback']),
|
|
286
|
+
define('XE5107', 'The build `xeer deploy` runs before uploading failed, so nothing was deployed and '
|
|
287
|
+
+ 'the previously deployed version is still serving. The compiler\'s own diagnostics follow this '
|
|
288
|
+
+ 'one in `diagnostics`.', 'Repair the diagnostics that follow — they are exactly what `xeer build` reports — and deploy '
|
|
289
|
+
+ 'again. Deploy never falls back to the last successful build.', ['deploy']),
|
|
290
|
+
define('XE5109', 'Deployment failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['deploy']),
|
|
291
|
+
define('XE5111', 'The appId declared in xeer.project.json is owned by a different builder, so the '
|
|
292
|
+
+ 'control plane refused the deployment.', 'Run `xeer link --new` to fork this checkout into a new app you own, or `xeer link` to attach it to '
|
|
293
|
+
+ 'one of yours. A clone of someone else\'s project cannot silently take over their app.', ['deploy']),
|
|
294
|
+
define('XE5112', 'The builder is at their apps-per-builder quota, so the control plane refused to '
|
|
295
|
+
+ 'create the app this deployment would have claimed.', 'This quota is a standing cap and does not lift on its own. Run `xeer link` to deploy into an app '
|
|
296
|
+
+ 'you already own, or ask the Xeer team to raise it. `message` states the quota and your usage.', ['deploy']),
|
|
297
|
+
define('XE5113', 'The builder has spent their hourly or daily deploy quota.', 'Retry after the reset `message` states — it is the exact moment a slot frees, not a fixed backoff. '
|
|
298
|
+
+ 'Failed deployments count toward the quota, so a fix-and-retry loop spends it too.', ['deploy']),
|
|
299
|
+
define('XE5120', 'xeer.project.json exists but is unusable: not JSON, not an object, the wrong '
|
|
300
|
+
+ '`format`, or without a valid `appId`.', 'Run `xeer link --app <appId>` to rewrite it, or `xeer link --new` to mint a fresh identity. A '
|
|
301
|
+
+ 'present-but-broken file is never repaired by guessing, because that would fork the app.', ['deploy', 'link', 'dev', 'preview', 'test', 'doctor']),
|
|
302
|
+
define('XE5121', 'The checked-in xeer.project.json and the local .xeer/project.json cache name '
|
|
303
|
+
+ 'different appIds.', 'The checked-in file wins. `xeer link --app <declared appId>` re-points the cache, or '
|
|
304
|
+
+ '`xeer link --new` deliberately forks this checkout.', ['deploy', 'link', 'dev', 'preview', 'test', 'doctor']),
|
|
305
|
+
define('XE5122', 'An appId is malformed, or `xeer link` was given both --app and --new.', 'Run `xeer link` with no flags to list the appIds you own, then pass exactly one of --app or --new.', ['link', 'deploy']),
|
|
306
|
+
define('XE5123', 'The signed-in builder does not own a project with that appId.', 'Run `xeer link` to list your projects, or `xeer link --new` to create a new app for this checkout.', ['link']),
|
|
307
|
+
define('XE5124', 'The control plane returned an invalid project or project list.', 'Retry; if it persists the control plane is unreachable or misconfigured. Not a project defect.', ['link']),
|
|
308
|
+
define('XE5129', 'xeer link failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['link']),
|
|
309
|
+
define('XE5130', 'An `xeer env` invocation is wrong: an unknown --environment, a missing name or '
|
|
310
|
+
+ 'value, or no usable xeer.app.json in the target directory.', 'Read `message` and the usage it quotes. --environment takes prod, preview, or dev, and the command '
|
|
311
|
+
+ 'must run inside a Xeer project.', ['env']),
|
|
312
|
+
define('XE5131', 'The control plane rejected the environment-variable request.', 'Read `message`: it carries the control-plane error and hint. Check sign-in and that you own the '
|
|
313
|
+
+ 'project.', ['env']),
|
|
314
|
+
define('XE5132', 'The control plane returned an environment payload the CLI will not trust.', 'Retry; if it persists the control plane is misconfigured or unreachable. Not a project defect.', ['env']),
|
|
315
|
+
define('XE5133', 'A closed-beta quota refused the environment-variable request: `xeer env set` claims '
|
|
316
|
+
+ 'the project on first use, so it is capped by the same apps-per-builder quota as `xeer deploy`.', 'Set the value on an app you already own — `xeer link` lists them — or ask the Xeer team to raise the '
|
|
317
|
+
+ 'quota. `message` states the quota, your usage, and any reset.', ['env']),
|
|
318
|
+
define('XE5139', 'xeer env failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['env']),
|
|
319
|
+
define('XE5140', 'An `xeer deployments` invocation is wrong: an unusable --limit, or a directory that '
|
|
320
|
+
+ 'declares no app identity.', 'Read `message`. --limit takes a positive integer up to 200. In a directory with no appId, run '
|
|
321
|
+
+ '`xeer deploy` or `xeer link` first, or name the app: `xeer deployments <app>`.', ['deployments']),
|
|
322
|
+
define('XE5141', 'The control plane rejected the deployment-history request.', 'Read `message`: it carries the control-plane error and hint. Check sign-in and that you own the app.', ['deployments']),
|
|
323
|
+
define('XE5142', 'The control plane returned a deployment listing the CLI will not trust.', 'Retry; if it persists the control plane is misconfigured or unreachable. Not a project defect.', ['deployments']),
|
|
324
|
+
define('XE5143', 'No app matched the reference for the signed-in builder.', 'Pass the application name from xeer.app.json, its appId, or its deployed URL, and confirm with '
|
|
325
|
+
+ '`xeer auth status` that you are signed in as its owner.', ['deployments']),
|
|
326
|
+
define('XE5149', 'xeer deployments failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['deployments']),
|
|
327
|
+
define('XE5160', 'An `xeer rollback` invocation is wrong: a missing or malformed artifact id, an '
|
|
328
|
+
+ 'unknown --environment, or a directory that declares no app identity.', 'An artifact id is `sha256:` followed by 64 hex characters — copy it from the ARTIFACT column of '
|
|
329
|
+
+ '`xeer deployments <app>`. --environment takes prod or preview; `dev` is never deployed.', ['rollback']),
|
|
330
|
+
define('XE5161', 'The control plane refused the rollback.', 'Read `message` and `hint`: they carry the control-plane error verbatim. A rollback is a deployment, '
|
|
331
|
+
+ 'so it can also be refused by the deploy quota.', ['rollback']),
|
|
332
|
+
define('XE5162', 'The control plane returned a rollback result the CLI will not trust.', 'Retry; if it persists the control plane is misconfigured or unreachable. Not a project defect.', ['rollback']),
|
|
333
|
+
define('XE5163', 'No app matched the reference for the signed-in builder, or it has already been '
|
|
334
|
+
+ 'deleted.', 'Pass the application name from xeer.app.json, its appId, or its deployed URL, and confirm with '
|
|
335
|
+
+ '`xeer auth status` that you are signed in as its owner.', ['rollback']),
|
|
336
|
+
define('XE5164', 'This application has no completed deployment of that artifact — it belongs to '
|
|
337
|
+
+ 'another project, was never deployed here, or its deployment failed.', 'Run `xeer deployments <app>` and roll back to an artifact listed there. Only a deployment that '
|
|
338
|
+
+ 'completed can be rolled back to.', ['rollback']),
|
|
339
|
+
define('XE5169', 'xeer rollback failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['rollback']),
|
|
340
|
+
define('XE5170', 'The --from-artifact value is not an artifact id.', 'An artifact id is `sha256:` followed by 64 hex characters — copy it from the ARTIFACT column of '
|
|
341
|
+
+ '`xeer deployments <app>`. Omit the flag to promote whatever preview is currently serving.', ['promote']),
|
|
342
|
+
define('XE5171', 'The control plane refused the promotion.', 'Read `message` and `hint`: they carry the control-plane error verbatim. A promotion is a production '
|
|
343
|
+
+ 'deployment, so it can also be refused by the deploy quota.', ['promote']),
|
|
344
|
+
define('XE5172', 'The control plane returned a promotion result the CLI will not trust.', 'Retry; if it persists the control plane is misconfigured or unreachable. Not a project defect.', ['promote']),
|
|
345
|
+
define('XE5173', 'No app matched the reference for the signed-in builder, or it has already been '
|
|
346
|
+
+ 'deleted.', 'Pass the application name from xeer.app.json, its appId, or its deployed URL, and confirm with '
|
|
347
|
+
+ '`xeer auth status` that you are signed in as its owner.', ['promote']),
|
|
348
|
+
define('XE5174', 'This application has no completed deployment of that artifact — it belongs to '
|
|
349
|
+
+ 'another project, was never deployed here, or its deployment failed.', 'Run `xeer deployments <app>` and promote an artifact listed there. Only a deployment that '
|
|
350
|
+
+ 'completed can be promoted.', ['promote']),
|
|
351
|
+
define('XE5175', 'The application has no completed preview deployment, so there is nothing to promote.', 'Run `xeer deploy --environment preview` to put a version on the preview origin first, or name the '
|
|
352
|
+
+ 'version explicitly with `--from-artifact sha256:…`.', ['promote']),
|
|
353
|
+
define('XE5176', 'The --receipt value is not a complete review receipt id.', 'Run `xeer test`, deploy the unchanged project with `--environment preview`, and copy the complete '
|
|
354
|
+
+ '`review_…` id printed by that deployment.', ['promote']),
|
|
355
|
+
define('XE5177', '--receipt and --from-artifact were supplied together.', 'Use --receipt for the reviewed path, or --from-artifact for the separate direct human override.', ['promote']),
|
|
356
|
+
define('XE5179', 'xeer promote failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['promote']),
|
|
357
|
+
define('XE5150', 'A lifecycle invocation is wrong: `xeer delete` without --confirm, or a directory '
|
|
358
|
+
+ 'that declares no app identity.', 'Deleting an application is permanent, so it requires its exact name: `xeer delete <app> --confirm '
|
|
359
|
+
+ '<app>`. In a directory with no appId, name the app instead of relying on the directory.', ['disable', 'enable', 'delete']),
|
|
360
|
+
define('XE5151', 'The control plane refused the lifecycle change — most often because --confirm does '
|
|
361
|
+
+ 'not match the application name, or because it cannot delete the deployed Worker.', 'Read `message` and `hint`: they carry the control-plane error verbatim. A confirmation must equal '
|
|
362
|
+
+ 'the name in xeer.app.json exactly.', ['disable', 'enable', 'delete']),
|
|
363
|
+
define('XE5152', 'The control plane returned a lifecycle result the CLI will not trust.', 'Retry; if it persists the control plane is misconfigured or unreachable. Not a project defect.', ['disable', 'enable', 'delete']),
|
|
364
|
+
define('XE5153', 'No app matched the reference for the signed-in builder, or it has already been '
|
|
365
|
+
+ 'deleted.', 'Pass the application name from xeer.app.json, its appId, or its deployed URL, and confirm with '
|
|
366
|
+
+ '`xeer auth status` that you are signed in as its owner. A deleted app never resolves again.', ['disable', 'enable', 'delete']),
|
|
367
|
+
define('XE5159', 'A lifecycle command failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['disable', 'enable', 'delete']),
|
|
368
|
+
// `xeer token` — service tokens (#62). Builder-facing but deliberately absent from the quickstart
|
|
369
|
+
// command list: only a service builder ever issues one.
|
|
370
|
+
define('XE5180', 'An `xeer token` invocation is wrong: an unknown action, a missing or unusable --name, '
|
|
371
|
+
+ 'a token id that is not an `xstid_` value, or no interactively signed-in builder.', 'Issuing a service token requires `xeer auth login` first — the browser approval is the root of every '
|
|
372
|
+
+ 'credential an account holds, so a service token cannot mint another. Take ids from `xeer token ls`; '
|
|
373
|
+
+ 'the id is the `xstid_` value, never the secret.', ['token']),
|
|
374
|
+
define('XE5181', 'The control plane refused the service-token request.', 'Read `message` and `hint`: they carry the control-plane error verbatim. A service token cannot issue '
|
|
375
|
+
+ 'another one, and a disabled builder is refused every credential they hold.', ['token']),
|
|
376
|
+
define('XE5182', 'The control plane returned a service-token response the CLI will not trust.', 'Retry; if it persists the control plane is misconfigured or unreachable. Not a project defect.', ['token']),
|
|
377
|
+
define('XE5189', 'xeer token failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['token']),
|
|
378
|
+
define('XE5190', 'An `xeer domains` invocation has a missing or invalid hostname or subcommand.', 'Use `xeer domains add|ls|status|remove`. A hostname is fully qualified ASCII without a scheme, '
|
|
379
|
+
+ 'port, path, or wildcard, for example `app.example.com`.', ['domains']),
|
|
380
|
+
define('XE5191', 'The control plane refused a custom-domain request.', 'Read `message` and `hint`; they carry the owner-scoped control-plane refusal.', ['domains']),
|
|
381
|
+
define('XE5192', 'The control plane returned a domains payload the CLI will not trust.', 'Retry; if it persists, the control plane and CLI versions are incompatible or the service is misconfigured.', ['domains']),
|
|
382
|
+
define('XE5193', 'No application or attached domain matched the owner-scoped reference.', 'Check the application reference and hostname, then confirm `xeer auth status` shows its owner.', ['domains']),
|
|
383
|
+
define('XE5194', 'The hostname is unavailable, reserved, at the user quota, or awaiting earlier cleanup.', 'Read `message` and `hint`. Remove an unused hostname, finish cleanup, or choose a hostname you control.', ['domains']),
|
|
384
|
+
define('XE5195', 'The application has no successful production deployment.', 'Run `xeer deploy` first. A custom hostname is never attached to an application with no production Worker.', ['domains']),
|
|
385
|
+
define('XE5196', 'Cloudflare for SaaS is unavailable or rejected the provider operation.', 'Retry. If it persists, the operator must check the SaaS zone, fallback origin, runtime token, and provider status.', ['domains']),
|
|
386
|
+
define('XE5197', 'Routing is detached, but Cloudflare hostname or certificate cleanup remains pending.', 'Run the same `xeer domains remove` command again. Reattachment stays blocked until cleanup is confirmed.', ['domains']),
|
|
387
|
+
define('XE5199', 'xeer domains failed without a more specific code.', 'Read `message`; it is the underlying error verbatim.', ['domains']),
|
|
388
|
+
];
|
|
389
|
+
function indexDefinitions(definitions) {
|
|
390
|
+
const indexed = {};
|
|
391
|
+
for (const definition of definitions) {
|
|
392
|
+
if (Object.hasOwn(indexed, definition.code)) {
|
|
393
|
+
throw new Error(`Duplicate diagnostic code: ${definition.code}`);
|
|
394
|
+
}
|
|
395
|
+
indexed[definition.code] = definition;
|
|
396
|
+
}
|
|
397
|
+
return indexed;
|
|
398
|
+
}
|
|
399
|
+
// Index imperatively instead of using Object.fromEntries: duplicate codes are a contract violation,
|
|
400
|
+
// never a last-definition-wins overwrite. Keeping the ordered source list exported also lets the
|
|
401
|
+
// conformance suite prove uniqueness before any generated reference consumes the index.
|
|
402
|
+
export const DIAGNOSTICS = Object.freeze(indexDefinitions(DIAGNOSTIC_DEFINITIONS));
|
|
403
|
+
/** Every documented code, ascending. */
|
|
404
|
+
export const DIAGNOSTIC_CODES = Object.freeze(Object.keys(DIAGNOSTICS).sort());
|
|
405
|
+
export function diagnosticDefinition(code) {
|
|
406
|
+
return DIAGNOSTICS[code];
|
|
407
|
+
}
|
|
408
|
+
/** The family a code belongs to, matched on its numeric prefix. */
|
|
409
|
+
export function diagnosticFamily(code) {
|
|
410
|
+
return DIAGNOSTIC_FAMILIES.find((family) => code.startsWith(family.prefix));
|
|
411
|
+
}
|
|
412
|
+
function escapeCell(text) {
|
|
413
|
+
return text.replaceAll('|', '\\|');
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Renders the agent-facing diagnostics reference. The checked-in copy under
|
|
417
|
+
* `.agents/skills/xeer/references/` is this function's canonical output; a test fails when
|
|
418
|
+
* the two diverge, so the reference cannot drift from the catalogue.
|
|
419
|
+
*/
|
|
420
|
+
export function renderDiagnosticsReference() {
|
|
421
|
+
const lines = [
|
|
422
|
+
'# Xeer diagnostic codes',
|
|
423
|
+
'',
|
|
424
|
+
'<!-- Generated from packages/spec/src/diagnostics.ts by `pnpm generate:agent-reference`. Do not edit. -->',
|
|
425
|
+
'',
|
|
426
|
+
'Codes are stable; messages are not. Dispatch on `code`, read `message` and `span` for the location,',
|
|
427
|
+
'and treat `hint` as the platform\'s own suggested edit. Every code below is emitted by the compiler or',
|
|
428
|
+
'CLI in this repository.',
|
|
429
|
+
'',
|
|
430
|
+
'A diagnostic is always:',
|
|
431
|
+
'',
|
|
432
|
+
'```ts',
|
|
433
|
+
'interface Diagnostic {',
|
|
434
|
+
' code: string; // XE####, stable',
|
|
435
|
+
' severity: \'error\' | \'warning\' | \'info\';',
|
|
436
|
+
' message: string; // human wording, free to change',
|
|
437
|
+
' file?: string; // project-relative POSIX path, never absolute',
|
|
438
|
+
' span?: { line: number; column: number; length?: number }; // 1-based',
|
|
439
|
+
' hint?: string; // suggested edit',
|
|
440
|
+
'}',
|
|
441
|
+
'```',
|
|
442
|
+
'',
|
|
443
|
+
'The "Seen in" column lists the commands whose JSON can carry the code. `check` diagnostics also appear',
|
|
444
|
+
'in `build` and `dev`, because both run the same manifest and analysis stages first.',
|
|
445
|
+
];
|
|
446
|
+
for (const family of DIAGNOSTIC_FAMILIES) {
|
|
447
|
+
const members = DIAGNOSTIC_DEFINITIONS.filter((definition) => definition.prefix === family.prefix);
|
|
448
|
+
if (!members.length)
|
|
449
|
+
continue;
|
|
450
|
+
lines.push('', `## ${family.title} (${family.prefix}xx)`, '', family.summary, '');
|
|
451
|
+
lines.push('| Code | Seen in | Means | Repair |', '| --- | --- | --- | --- |');
|
|
452
|
+
for (const member of members) {
|
|
453
|
+
lines.push(`| \`${member.code}\` | ${member.surfaces.join(', ')} `
|
|
454
|
+
+ `| ${escapeCell(member.means)} | ${escapeCell(member.repair)} |`);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
lines.push('');
|
|
458
|
+
return lines.join('\n');
|
|
459
|
+
}
|
|
460
|
+
/** Markdown used by the public docs page and the installed offline docs bundle. */
|
|
461
|
+
export function renderDiagnosticsDocsPage() {
|
|
462
|
+
const definitions = Object.values(DIAGNOSTICS);
|
|
463
|
+
const lines = [
|
|
464
|
+
'# Diagnostics reference',
|
|
465
|
+
'',
|
|
466
|
+
`Every diagnostic Xeer emits carries a stable \`XE####\` code. There are ${definitions.length} of them, and`,
|
|
467
|
+
'this page is generated from the same catalogue the compiler and CLI emit from, so it cannot fall behind.',
|
|
468
|
+
'',
|
|
469
|
+
'**Codes are stable; messages are not.** Dispatch on `code`, read `message` and `span` for the location,',
|
|
470
|
+
'and treat `hint` as the platform\'s own suggested edit.',
|
|
471
|
+
'',
|
|
472
|
+
'```ts',
|
|
473
|
+
'interface Diagnostic {',
|
|
474
|
+
' code: string; // XE####, stable',
|
|
475
|
+
" severity: 'error' | 'warning' | 'info';",
|
|
476
|
+
' message: string; // human wording, free to change',
|
|
477
|
+
' file?: string; // project-relative POSIX path, never absolute',
|
|
478
|
+
' span?: { line: number; column: number; length?: number }; // 1-based',
|
|
479
|
+
' hint?: string; // suggested edit',
|
|
480
|
+
'}',
|
|
481
|
+
'```',
|
|
482
|
+
'',
|
|
483
|
+
'Every command prints these as JSON with `--json`; see [Building with AI agents](/guides/agents).',
|
|
484
|
+
'The "Seen in" column lists the commands whose output can carry the code. `check` diagnostics also',
|
|
485
|
+
'appear in `build` and `dev`, because both run the same manifest and analysis stages first.',
|
|
486
|
+
];
|
|
487
|
+
const escapeCell = (text) => text.replaceAll('|', '\\|');
|
|
488
|
+
for (const family of DIAGNOSTIC_FAMILIES) {
|
|
489
|
+
const members = definitions.filter((definition) => definition.prefix === family.prefix);
|
|
490
|
+
if (members.length === 0)
|
|
491
|
+
continue;
|
|
492
|
+
lines.push('', `## ${family.title} (${family.prefix}xx)`, '', family.summary, '');
|
|
493
|
+
lines.push('| Code | Seen in | Means | Repair |', '| --- | --- | --- | --- |');
|
|
494
|
+
for (const member of members) {
|
|
495
|
+
lines.push(`| \`${member.code}\` | ${member.surfaces.join(', ')} `
|
|
496
|
+
+ `| ${escapeCell(member.means)} | ${escapeCell(member.repair)} |`);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return `${lines.join('\n')}\n`;
|
|
500
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const XEER_DOCS_PROTOCOL: "xeer.docs.v0";
|
|
2
|
+
export declare const XEER_DOCS_ORIGIN: "https://docs.xeer.run";
|
|
3
|
+
export interface XeerDocsPageDefinition {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly source: string | null;
|
|
6
|
+
readonly generate?: 'diagnostics';
|
|
7
|
+
readonly layout?: 'home';
|
|
8
|
+
readonly title: string;
|
|
9
|
+
readonly heading?: string;
|
|
10
|
+
readonly description: string;
|
|
11
|
+
}
|
|
12
|
+
export interface XeerDocsSectionDefinition {
|
|
13
|
+
readonly title: string | null;
|
|
14
|
+
readonly pages: readonly XeerDocsPageDefinition[];
|
|
15
|
+
}
|
|
16
|
+
/** Canonical page registry shared by the site, packaged Markdown, search, and MCP resources. */
|
|
17
|
+
export declare const XEER_DOCS_SECTIONS: readonly XeerDocsSectionDefinition[];
|
|
18
|
+
export declare const XEER_DOCS_PAGES: XeerDocsPageDefinition[];
|
|
19
|
+
export declare function xeerDocsMarkdownPath(page: Pick<XeerDocsPageDefinition, 'path'>): string;
|
|
20
|
+
/** Small deterministic heading index; fenced examples never become accidental headings. */
|
|
21
|
+
export declare function xeerDocsHeadings(markdown: string): string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const XEER_DOCS_PROTOCOL = 'xeer.docs.v0';
|
|
2
|
+
export const XEER_DOCS_ORIGIN = 'https://docs.xeer.run';
|
|
3
|
+
/** Canonical page registry shared by the site, packaged Markdown, search, and MCP resources. */
|
|
4
|
+
export const XEER_DOCS_SECTIONS = [
|
|
5
|
+
{ title: null, pages: [
|
|
6
|
+
{ path: '/', source: 'index.md', layout: 'home', title: 'Xeer', heading: 'Overview',
|
|
7
|
+
description: 'Xeer is a framework for building and shipping full-stack apps. A typed server, a reactive client, a built-in test runner, and one command to deploy.' },
|
|
8
|
+
] },
|
|
9
|
+
{ title: 'Start here', pages: [
|
|
10
|
+
{ path: '/quickstart', source: 'quickstart.md', title: 'Quickstart', description: 'Create, run, test, and deploy a Xeer app in five minutes.' },
|
|
11
|
+
{ path: '/guides/project-structure', source: 'guides/project-structure.md', title: 'Project structure', description: 'What `xeer new` writes, and what each file is for.' },
|
|
12
|
+
] },
|
|
13
|
+
{ title: 'Guides', pages: [
|
|
14
|
+
{ path: '/guides/capabilities', source: 'guides/capabilities.md', title: 'Capabilities', description: 'The powers an app declares, and why an undeclared one does not exist.' },
|
|
15
|
+
{ path: '/guides/server', source: 'guides/server.md', title: 'Server functions and the database', description: 'Queries, mutations, endpoints, and the typed table API.' },
|
|
16
|
+
{ path: '/guides/storage', source: 'guides/storage.md', title: 'Storage', description: 'Private file storage per app: the `ctx.storage` surface, keys, browser uploads, limits, and what happens on deploy.' },
|
|
17
|
+
{ path: '/guides/client', source: 'guides/client.md', title: 'The client', description: 'Reading data with hooks, writing it with mutations, and staying in sync.' },
|
|
18
|
+
{ path: '/guides/live-updates', source: 'guides/live-updates.md', title: 'Live updates', description: 'How every open client sees a change the moment it lands.' },
|
|
19
|
+
{ path: '/guides/auth', source: 'guides/auth.md', title: 'Auth', description: 'Two separate identities: your builder account, and your app\'s own users.' },
|
|
20
|
+
{ path: '/guides/local-development', source: 'guides/local-development.md', title: 'Local development', description: 'The dev server, local data, and the personas that make authorization exercisable offline.' },
|
|
21
|
+
{ path: '/guides/testing', source: 'guides/testing.md', title: 'Testing', description: 'The built-in test runner, and asserting authorization instead of assuming it.' },
|
|
22
|
+
{ path: '/guides/env', source: 'guides/env.md', title: 'Environment variables and secrets', description: 'Storing configuration per environment, and reading it from `ctx.env`.' },
|
|
23
|
+
{ path: '/guides/deploy', source: 'guides/deploy.md', title: 'Deploy, preview, promote, roll back', description: 'Shipping to a real URL, and the levers for changing what is live.' },
|
|
24
|
+
{ path: '/guides/custom-domains', source: 'guides/custom-domains.md', title: 'Custom domains', description: 'Attach, validate, monitor, and safely remove a customer-owned hostname.' },
|
|
25
|
+
{ path: '/guides/agents', source: 'guides/agents.md', title: 'Building with AI agents', description: 'The machine-readable surface: `--json` on every command, and the MCP server.' },
|
|
26
|
+
] },
|
|
27
|
+
{ title: 'Reference', pages: [
|
|
28
|
+
{ path: '/reference/cli', source: 'reference/cli.md', title: 'CLI reference', description: 'Every `xeer` command, its options, and what it does.' },
|
|
29
|
+
{ path: '/reference/manifest', source: 'reference/manifest.md', title: 'Manifest reference', description: 'Every field of `xeer.app.json`, with its exact rules.' },
|
|
30
|
+
{ path: '/reference/diagnostics', source: null, generate: 'diagnostics', title: 'Diagnostics reference', description: 'Every stable `XE####` code the compiler and CLI emit, what it means, and how to repair it.' },
|
|
31
|
+
] },
|
|
32
|
+
{ title: null, pages: [
|
|
33
|
+
{ path: '/faq', source: 'faq.md', title: 'FAQ', description: 'Access, infrastructure, limits, and the questions that come up first.' },
|
|
34
|
+
] },
|
|
35
|
+
];
|
|
36
|
+
export const XEER_DOCS_PAGES = XEER_DOCS_SECTIONS.flatMap((section) => section.pages);
|
|
37
|
+
export function xeerDocsMarkdownPath(page) {
|
|
38
|
+
return page.path === '/' ? '/index.md' : `${page.path}.md`;
|
|
39
|
+
}
|
|
40
|
+
/** Small deterministic heading index; fenced examples never become accidental headings. */
|
|
41
|
+
export function xeerDocsHeadings(markdown) {
|
|
42
|
+
const headings = [];
|
|
43
|
+
let fenced = false;
|
|
44
|
+
for (const line of markdown.split(/\r?\n/u)) {
|
|
45
|
+
if (/^\s*```/u.test(line)) {
|
|
46
|
+
fenced = !fenced;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (fenced)
|
|
50
|
+
continue;
|
|
51
|
+
const match = /^(#{1,3})\s+(.+?)\s*#*\s*$/u.exec(line);
|
|
52
|
+
if (!match || match[1] === '#')
|
|
53
|
+
continue;
|
|
54
|
+
headings.push(match[2].replace(/[`*_]/gu, '').trim());
|
|
55
|
+
}
|
|
56
|
+
return headings;
|
|
57
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DevEvent } from './types.js';
|
|
2
|
+
export declare class DevEventWriter {
|
|
3
|
+
#private;
|
|
4
|
+
private readonly writeLine;
|
|
5
|
+
private readonly now;
|
|
6
|
+
constructor(writeLine: (line: string) => void, now?: () => Date);
|
|
7
|
+
emit<T>(type: string, data: T): DevEvent<T>;
|
|
8
|
+
}
|