archidocs 1.2.0 → 1.3.0

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 (68) hide show
  1. package/README.md +62 -13
  2. package/dist/cli/commands.d.ts +225 -4
  3. package/dist/cli/commands.js +129 -4
  4. package/dist/cli/init.d.ts +1 -1
  5. package/dist/cli/init.js +2 -2
  6. package/dist/cli/main.js +9 -14
  7. package/dist/core/compare.d.ts +2 -13
  8. package/dist/core/compare.js +2 -35
  9. package/dist/core/index.d.ts +2 -5
  10. package/dist/core/index.js +2 -5
  11. package/dist/core/rules.d.ts +10 -0
  12. package/dist/core/rules.js +186 -7
  13. package/dist/core/views/compare.d.ts +12 -0
  14. package/dist/core/views/compare.js +37 -0
  15. package/dist/core/{deployment-views.d.ts → views/deployment.d.ts} +4 -5
  16. package/dist/core/{deployment-views.js → views/deployment.js} +5 -7
  17. package/dist/core/{dynamic-views.d.ts → views/dynamic.d.ts} +1 -3
  18. package/dist/core/{dynamic-views.js → views/dynamic.js} +4 -8
  19. package/dist/core/views/generated.d.ts +18 -0
  20. package/dist/core/views/generated.js +92 -0
  21. package/dist/core/views/ids.d.ts +36 -0
  22. package/dist/core/views/ids.js +51 -0
  23. package/dist/core/views/index.d.ts +13 -0
  24. package/dist/core/views/index.js +12 -0
  25. package/dist/core/views/lens.d.ts +27 -0
  26. package/dist/core/views/lens.js +112 -0
  27. package/dist/core/views/model.d.ts +21 -0
  28. package/dist/core/views/model.js +69 -0
  29. package/dist/core/views/resolve.d.ts +42 -0
  30. package/dist/core/views/resolve.js +81 -0
  31. package/dist/core/{save-as-view.d.ts → views/save-as-view.d.ts} +2 -2
  32. package/dist/core/{save-as-view.js → views/save-as-view.js} +13 -10
  33. package/dist/core/{saved-views.d.ts → views/saved.d.ts} +4 -18
  34. package/dist/core/{saved-views.js → views/saved.js} +8 -103
  35. package/dist/core/views/types.d.ts +91 -0
  36. package/dist/core/views/types.js +2 -0
  37. package/dist/mcp/errors.d.ts +37 -0
  38. package/dist/mcp/errors.js +35 -0
  39. package/dist/mcp/index.d.ts +2 -1
  40. package/dist/mcp/index.js +1 -0
  41. package/dist/mcp/server.d.ts +1 -2
  42. package/dist/mcp/server.js +12 -12
  43. package/dist/render/layout.d.ts +20 -3
  44. package/dist/render/layout.js +49 -12
  45. package/dist/render/sequence-svg.d.ts +1 -1
  46. package/dist/render/sequence.d.ts +1 -1
  47. package/dist/render/svg.d.ts +1 -1
  48. package/dist/render/svg.js +4 -4
  49. package/dist/schema/adr.js +18 -13
  50. package/dist/schema/workspace.js +226 -130
  51. package/dist/viewer/assets/index-BXa5R96a.js +138 -0
  52. package/dist/viewer/assets/index-YFA-pYjQ.css +1 -0
  53. package/dist/viewer/assets/{layout.worker-Bg-OaLVN.js → layout.worker-BRHAGJrD.js} +1 -1
  54. package/dist/viewer/assets/{png-BDKIXtm5.js → png-CAaXWR-k.js} +1 -1
  55. package/dist/viewer/assets/{svg-Bulv5YWn.js → svg-BPVHfD36.js} +2 -2
  56. package/dist/viewer/index.html +2 -2
  57. package/guide/SKILL.md +1 -1
  58. package/guide/topics/bootstrap.md +1 -1
  59. package/guide/topics/relationships.md +1 -1
  60. package/package.json +4 -3
  61. package/schemas/adr.schema.json +18 -15
  62. package/schemas/model.schema.json +637 -1144
  63. package/schemas/project.schema.json +8 -4
  64. package/schemas/workspace.schema.json +39 -20
  65. package/dist/core/views.d.ts +0 -126
  66. package/dist/core/views.js +0 -217
  67. package/dist/viewer/assets/index-DvKgCpBr.css +0 -1
  68. package/dist/viewer/assets/index-gucix3xm.js +0 -113
package/README.md CHANGED
@@ -32,29 +32,85 @@ The questions it's built to answer:
32
32
 
33
33
  ## Quick start
34
34
 
35
- Requires Node.js 22.18 or later.
35
+ From an empty repo to your first System in the viewer, in about five minutes. Archidocs needs Node.js 22.18 or later.
36
+
37
+ **1. Install the CLI.** With pnpm, use `pnpm add --global archidocs`. To install nothing, put `npx` before each command, as in `npx archidocs check`.
36
38
 
37
39
  ```bash
38
40
  npm install --global archidocs
39
41
  ```
40
42
 
41
- In the repo that will hold your Workspace:
43
+ **2. Create a Workspace.** In the repo that will hold it (a new, empty one is fine):
42
44
 
43
45
  ```bash
44
46
  archidocs init
45
47
  ```
46
48
 
47
- This writes `archidocs/workspace.yaml`, adds the `.archidocs/` cache to `.gitignore`, and installs an authoring skill for coding agents. Add a Project folder, then check it and open the viewer:
49
+ This writes a starter `archidocs/workspace.yaml`, adds the `.archidocs/` cache to `.gitignore`, and installs an authoring skill for coding agents.
50
+
51
+ **3. Add three files.** Replace `archidocs/workspace.yaml`, which defines Teams and Environments, with:
52
+
53
+ ```yaml
54
+ teams:
55
+ storefront:
56
+ name: Storefront
57
+ environments:
58
+ prod:
59
+ name: Production
60
+ ```
61
+
62
+ Give the Team a Project folder, marked by `archidocs/shop/project.yaml`:
63
+
64
+ ```yaml
65
+ id: shop
66
+ name: Shop
67
+ owner: storefront
68
+ ```
69
+
70
+ Declare a Person, and a System that holds two Services, in `archidocs/shop/model.yaml`:
71
+
72
+ ```yaml
73
+ people:
74
+ shopper:
75
+ name: Shopper
76
+ relationships:
77
+ - to: web
78
+ description: Browses and buys using
79
+ systems:
80
+ online-shop:
81
+ name: Online Shop
82
+ services:
83
+ web:
84
+ name: Web
85
+ technology: TypeScript, React
86
+ relationships:
87
+ - to: api
88
+ description: Places orders through
89
+ technology: JSON/HTTPS
90
+ api:
91
+ name: API
92
+ technology: Node.js
93
+ ```
94
+
95
+ **4. Check it.**
48
96
 
49
97
  ```bash
50
98
  archidocs check
51
99
  ```
52
100
 
101
+ ```text
102
+ 0 errors, 0 warnings
103
+ ```
104
+
105
+ **5. Open the viewer.**
106
+
53
107
  ```bash
54
108
  archidocs dev
55
109
  ```
56
110
 
57
- `archidocs dev` serves the viewer on <http://localhost:4321> and reloads as you edit.
111
+ Open <http://localhost:4321>. The viewer starts on the C2 Landscape, which shows the Shopper and the Online Shop; select the arrow button on the Online Shop box to see the two Services inside it. The viewer reloads as you edit the files.
112
+
113
+ The finished Workspace is in [examples/quick-start](examples/quick-start).
58
114
 
59
115
  ## The Model
60
116
 
@@ -167,15 +223,8 @@ archidocs mcp --workspace ./archidocs
167
223
 
168
224
  ## Development
169
225
 
170
- ```bash
171
- pnpm install
172
- ```
173
-
174
- ```bash
175
- pnpm dev
176
- ```
177
-
178
- `pnpm test` runs the unit tests, `pnpm test:e2e` the Playwright tests, and `pnpm typecheck` and `pnpm lint` the static checks. Design and product notes are in [PRODUCT.md](PRODUCT.md) and [DESIGN.md](DESIGN.md).
226
+ Run `pnpm install`, then `pnpm dev` to serve the viewer and `pnpm test` to run the tests.
227
+ To run the other checks, work on the docs site or open a pull request, see [CONTRIBUTING.md](CONTRIBUTING.md).
179
228
 
180
229
  ## License
181
230
 
@@ -1,11 +1,20 @@
1
1
  /**
2
2
  * The CLI's commands and flags, described once. The CLI parses each
3
3
  * command's arguments with these flags and prints its usage text from them;
4
- * the docs site generates its CLI reference from them and checks every
5
- * `archidocs …` line in a page with `parseCommandLine`. Importing this
6
- * module has no side effects and pulls in nothing but `node:util`.
4
+ * the docs site generates its CLI reference from them, examples and exit
5
+ * codes included, and checks every `archidocs …` line in a page with
6
+ * `parseCommandLine`. Importing this module has no side effects and pulls in
7
+ * nothing but `node:util`.
7
8
  */
8
9
  import { parseArgs } from "node:util";
10
+ /** The CLI's exit codes: 0 no errors, 1 errors found (or any warning with `check --strict`), 2 could not run. */
11
+ export declare const EXIT: {
12
+ readonly ok: 0;
13
+ readonly foundErrors: 1;
14
+ readonly couldNotRun: 2;
15
+ };
16
+ /** What a command that needs a Workspace says, exiting 2, when the search for one finds none. */
17
+ export declare const NO_WORKSPACE = "No workspace.yaml found in this folder, its archidocs/ folder, or any folder above.";
9
18
  /** One flag. Its key in `flags` is its name, without the leading `--`. */
10
19
  export interface FlagDefinition {
11
20
  readonly type: "string" | "boolean";
@@ -22,6 +31,19 @@ export interface ArgumentDefinition {
22
31
  readonly name: string;
23
32
  readonly description: string;
24
33
  }
34
+ /** One real command line for the reference, checked like any other with `parseCommandLine`. */
35
+ export interface ExampleDefinition {
36
+ /** The whole line as typed, starting with `archidocs`. */
37
+ readonly command: string;
38
+ /** One line on what it does. */
39
+ readonly description: string;
40
+ }
41
+ /** One exit code a command can end with. */
42
+ export interface ExitCodeDefinition {
43
+ readonly code: (typeof EXIT)[keyof typeof EXIT];
44
+ /** When the command ends with it. */
45
+ readonly meaning: string;
46
+ }
25
47
  export interface CommandDefinition {
26
48
  /** The words after `archidocs`: `check`, or `history build` for a subcommand. */
27
49
  readonly name: string;
@@ -31,6 +53,12 @@ export interface CommandDefinition {
31
53
  readonly description: string;
32
54
  readonly arguments: readonly ArgumentDefinition[];
33
55
  readonly flags: Readonly<Record<string, FlagDefinition>>;
56
+ /** At least one, the plainest first. */
57
+ readonly examples: readonly [ExampleDefinition, ...ExampleDefinition[]];
58
+ /** Every exit code the command itself ends with, lowest first. */
59
+ readonly exitCodes: readonly [ExitCodeDefinition, ...ExitCodeDefinition[]];
60
+ /** For a command that serves until it is stopped: how it ends, when no exit code is its own. */
61
+ readonly exitNote?: string;
34
62
  }
35
63
  export declare const commands: {
36
64
  readonly version: {
@@ -46,6 +74,20 @@ export declare const commands: {
46
74
  readonly description: "Print a line of text, or a JSON object with `version` and `schemaVersion`.";
47
75
  };
48
76
  };
77
+ readonly examples: readonly [{
78
+ readonly command: "archidocs version";
79
+ readonly description: "Print both versions as one line of text.";
80
+ }, {
81
+ readonly command: "archidocs version --format json";
82
+ readonly description: "Print them as JSON, for a CI cache key that changes when the Bundle schemaVersion does.";
83
+ }];
84
+ readonly exitCodes: readonly [{
85
+ readonly code: 0;
86
+ readonly meaning: "The version was printed.";
87
+ }, {
88
+ readonly code: 2;
89
+ readonly meaning: "It could not run: an unknown flag, a flag missing its value, or an unknown format.";
90
+ }];
49
91
  };
50
92
  readonly init: {
51
93
  readonly name: "init";
@@ -64,6 +106,20 @@ export declare const commands: {
64
106
  readonly description: "With `--skill`: the Workspace checkout that the printed MCP command points at.";
65
107
  };
66
108
  };
109
+ readonly examples: readonly [{
110
+ readonly command: "archidocs init";
111
+ readonly description: "Write `archidocs/workspace.yaml` if the repo has no Workspace yet, and install the agent skill.";
112
+ }, {
113
+ readonly command: "archidocs init --skill --workspace ../architecture/archidocs";
114
+ readonly description: "In a code repo, install only the agent skill, and print the MCP command for the Workspace checked out beside it.";
115
+ }];
116
+ readonly exitCodes: readonly [{
117
+ readonly code: 0;
118
+ readonly meaning: "The Workspace and the agent skill are set up, or already were. Each file written or updated is printed.";
119
+ }, {
120
+ readonly code: 2;
121
+ readonly meaning: "It could not run: an unknown flag, a flag missing its value, `--workspace` without `--skill`, or a file it could not write.";
122
+ }];
67
123
  };
68
124
  readonly guide: {
69
125
  readonly name: "guide";
@@ -74,11 +130,25 @@ export declare const commands: {
74
130
  readonly description: "A task topic; with none, the guide and the list of topics.";
75
131
  }];
76
132
  readonly flags: {};
133
+ readonly examples: readonly [{
134
+ readonly command: "archidocs guide";
135
+ readonly description: "Print the guide: the Model in brief, the edit loop and the list of task topics.";
136
+ }, {
137
+ readonly command: "archidocs guide add-service";
138
+ readonly description: "Print one task topic, here how to add a Service.";
139
+ }];
140
+ readonly exitCodes: readonly [{
141
+ readonly code: 0;
142
+ readonly meaning: "The guide or the topic was printed.";
143
+ }, {
144
+ readonly code: 2;
145
+ readonly meaning: "It could not run: an unknown topic (the message lists the topics there are), more than one topic, or any flag, since it takes none.";
146
+ }];
77
147
  };
78
148
  readonly check: {
79
149
  readonly name: "check";
80
150
  readonly synopsis: readonly ["check [--format text|json|github] [--strict]"];
81
- readonly description: "Validate the Workspace found from the current folder. Exits 1 on errors, 2 if it could not run.";
151
+ readonly description: "Validate the Workspace found from the current folder and print each issue with its file, line and rule.";
82
152
  readonly arguments: readonly [];
83
153
  readonly flags: {
84
154
  readonly format: {
@@ -93,6 +163,29 @@ export declare const commands: {
93
163
  readonly description: "Exit 1 on warnings too, not only on errors.";
94
164
  };
95
165
  };
166
+ readonly examples: readonly [{
167
+ readonly command: "archidocs check";
168
+ readonly description: "Validate the Workspace and print its issues grouped by file, then a count and a link to each rule's page.";
169
+ }, {
170
+ readonly command: "archidocs check --strict";
171
+ readonly description: "Fail on warnings as well as errors, for a CI job that keeps the Workspace clean.";
172
+ }, {
173
+ readonly command: "archidocs check --format github";
174
+ readonly description: "Print each issue as a GitHub Actions annotation, which a pull request shows on the line the issue is about.";
175
+ }, {
176
+ readonly command: "archidocs check --format json";
177
+ readonly description: "Print the issues and a count of errors and warnings as JSON, for a script.";
178
+ }];
179
+ readonly exitCodes: readonly [{
180
+ readonly code: 0;
181
+ readonly meaning: "No errors. Warnings are printed and still exit 0, unless `--strict` is given.";
182
+ }, {
183
+ readonly code: 1;
184
+ readonly meaning: "The Workspace has at least one error; with `--strict`, at least one error or warning.";
185
+ }, {
186
+ readonly code: 2;
187
+ readonly meaning: "It could not run: an unknown flag, a flag missing its value, an unknown format, or no Workspace found.";
188
+ }];
96
189
  };
97
190
  readonly build: {
98
191
  readonly name: "build";
@@ -129,6 +222,29 @@ export declare const commands: {
129
222
  readonly description: "With `--preview`: the base branch, read from `origin/<branch>` without fetching.";
130
223
  };
131
224
  };
225
+ readonly examples: readonly [{
226
+ readonly command: "archidocs build --out site";
227
+ readonly description: "Write the viewer, the latest Bundle and the past Revisions' Bundles into `site/`, ready for any static host.";
228
+ }, {
229
+ readonly command: "archidocs build --out site --keep 50";
230
+ readonly description: "Keep Bundles for the latest 50 past Revisions only, and for every tagged one.";
231
+ }, {
232
+ readonly command: "archidocs build --bundle-only --out public";
233
+ readonly description: "Write only `public/workspace.bundle.json`, for `mcp --bundle` or a script to read.";
234
+ }, {
235
+ readonly command: "archidocs build --preview --base main --out preview";
236
+ readonly description: "Write a PR preview site that opens on Compare, from `origin/main` to the pull request checked out.";
237
+ }];
238
+ readonly exitCodes: readonly [{
239
+ readonly code: 0;
240
+ readonly meaning: "The site, the Bundle or the preview site was written.";
241
+ }, {
242
+ readonly code: 1;
243
+ readonly meaning: "The Workspace has errors. They are printed as `check` prints them, and nothing is written.";
244
+ }, {
245
+ readonly code: 2;
246
+ readonly meaning: "It could not run: an unknown flag, a flag missing its value, flags that don't go together, a `--keep` that is not a count or `all`, no Workspace found, or with `--preview` a Workspace outside git or a base branch that is not in the checkout.";
247
+ }];
132
248
  };
133
249
  readonly dev: {
134
250
  readonly name: "dev";
@@ -155,6 +271,24 @@ export declare const commands: {
155
271
  readonly description: "The address to listen on.";
156
272
  };
157
273
  };
274
+ readonly examples: readonly [{
275
+ readonly command: "archidocs dev";
276
+ readonly description: "Serve the viewer for the Workspace found from the current folder, and print its address.";
277
+ }, {
278
+ readonly command: "archidocs dev --port 4000";
279
+ readonly description: "Serve on another port, for when the default one is in use.";
280
+ }, {
281
+ readonly command: "archidocs dev --workspace ../architecture";
282
+ readonly description: "Serve the Workspace found from another folder, such as a checkout of the Workspace repo beside a code repo.";
283
+ }, {
284
+ readonly command: "archidocs dev --host 0.0.0.0";
285
+ readonly description: "Listen on every network interface, so that other machines can open the viewer.";
286
+ }];
287
+ readonly exitCodes: readonly [{
288
+ readonly code: 2;
289
+ readonly meaning: "It could not start: an unknown flag, a flag missing its value, a `--port` that is not a port or is in use, or no Workspace found.";
290
+ }];
291
+ readonly exitNote: "Once it is serving, `dev` runs until you stop it with Ctrl+C. A Workspace with errors does not stop it: it prints them and keeps serving. The interrupt ends the process, so the exit status is the shell's for an interrupted command (130 in most shells), not a code of its own.";
158
292
  };
159
293
  readonly export: {
160
294
  readonly name: "export";
@@ -201,6 +335,32 @@ export declare const commands: {
201
335
  readonly description: "The line under the title, such as `Big Bank · v1.2.0`, in place of the source line.";
202
336
  };
203
337
  };
338
+ readonly examples: readonly [{
339
+ readonly command: "archidocs export c2";
340
+ readonly description: "Write the C2 Generated View, every System and Service, to `c2.svg` in the current folder.";
341
+ }, {
342
+ readonly command: "archidocs export c2/digital:internet-banking --direction TB --theme dark";
343
+ readonly description: "Write one System's Services, the System named by its Qualified id, laid out top to bottom in the dark palette.";
344
+ }, {
345
+ readonly command: "archidocs export payments:make-a-payment --format png --out make-a-payment.png";
346
+ readonly description: "Write a Saved View, here a Dynamic View, as a PNG.";
347
+ }, {
348
+ readonly command: "archidocs export --all-saved --out views";
349
+ readonly description: "Write every Saved View into `views/`, one picture each, named by its id.";
350
+ }, {
351
+ readonly command: "archidocs export deployment/prod --label \"Big Bank · v1.2.0\"";
352
+ readonly description: "Write an Environment's Deployment View with a line of your own under the title, in place of the commit and date.";
353
+ }];
354
+ readonly exitCodes: readonly [{
355
+ readonly code: 0;
356
+ readonly meaning: "Each picture was written, and its path printed.";
357
+ }, {
358
+ readonly code: 1;
359
+ readonly meaning: "The Workspace has errors. They are printed as `check` prints them, and nothing is exported.";
360
+ }, {
361
+ readonly code: 2;
362
+ readonly meaning: "It could not run: an unknown flag, a flag missing its value, an unknown format, direction or theme, an unknown View, a View together with `--all-saved` or neither of them, `--all-saved` without `--out`, or no Workspace found.";
363
+ }];
204
364
  };
205
365
  readonly diff: {
206
366
  readonly name: "diff";
@@ -221,6 +381,26 @@ export declare const commands: {
221
381
  readonly description: "Print the changes as text, JSON, or Markdown for a PR comment.";
222
382
  };
223
383
  };
384
+ readonly examples: readonly [{
385
+ readonly command: "archidocs diff HEAD";
386
+ readonly description: "Show what your uncommitted edits change, against the last commit.";
387
+ }, {
388
+ readonly command: "archidocs diff origin/main HEAD";
389
+ readonly description: "Show what a branch changes against the default branch, as a reviewer of its pull request will see it.";
390
+ }, {
391
+ readonly command: "archidocs diff 2026-01-01 2026-06-30";
392
+ readonly description: "Show the Changes between two dates; each date means the last default-branch commit at or before it.";
393
+ }, {
394
+ readonly command: "archidocs diff origin/main HEAD --format markdown";
395
+ readonly description: "Write the Changes as Markdown, to post as a pull request comment.";
396
+ }];
397
+ readonly exitCodes: readonly [{
398
+ readonly code: 0;
399
+ readonly meaning: "The Changes were printed. It exits 0 whether or not anything changed, so a script that asks whether the Model changed must read the output, not the exit code.";
400
+ }, {
401
+ readonly code: 2;
402
+ readonly meaning: "It could not run: an unknown flag, a flag missing its value, an unknown format, no point or more than two, an unknown ref or date, no Workspace found, or a Workspace outside git.";
403
+ }];
224
404
  };
225
405
  readonly "history build": {
226
406
  readonly name: "history build";
@@ -235,6 +415,23 @@ export declare const commands: {
235
415
  readonly description: "Only build Revisions at or after this ref's commit time or the start of this date.";
236
416
  };
237
417
  };
418
+ readonly examples: readonly [{
419
+ readonly command: "archidocs history build";
420
+ readonly description: "Build and cache the Bundle of every past Revision, so the next `build` or `diff` reads them from the cache.";
421
+ }, {
422
+ readonly command: "archidocs history build --since 2026-01-01";
423
+ readonly description: "Only build the Revisions from the start of that date on.";
424
+ }, {
425
+ readonly command: "archidocs history build --since v1.0.0";
426
+ readonly description: "Only build the Revisions at or after a tag's commit.";
427
+ }];
428
+ readonly exitCodes: readonly [{
429
+ readonly code: 0;
430
+ readonly meaning: "Every Revision asked for is in the cache. It prints how many it built and how many were already built.";
431
+ }, {
432
+ readonly code: 2;
433
+ readonly meaning: "It could not run: an unknown flag, a flag missing its value, an unknown `--since` ref or date, no Workspace found, or a Workspace outside git.";
434
+ }];
238
435
  };
239
436
  readonly mcp: {
240
437
  readonly name: "mcp";
@@ -281,6 +478,30 @@ export declare const commands: {
281
478
  readonly description: "With `--http`: allow the write tools, which are off over HTTP by default.";
282
479
  };
283
480
  };
481
+ readonly examples: readonly [{
482
+ readonly command: "archidocs mcp --workspace archidocs";
483
+ readonly description: "Serve a Workspace checkout over stdio, with the read and write tools. This is the command to register with a coding agent, which starts it from the repo root.";
484
+ }, {
485
+ readonly command: "archidocs mcp --bundle https://big-bank.archidocs.dev/workspace.bundle.json";
486
+ readonly description: "Serve a published Bundle, here the Big Bank demo's, with the read tools only.";
487
+ }, {
488
+ readonly command: "archidocs mcp --bundle https://architecture.example.com/workspace.bundle.json --viewer-url https://architecture.example.com/";
489
+ readonly description: "Serve your own published Bundle, with links to its viewer in the tool results.";
490
+ }, {
491
+ readonly command: "archidocs mcp --http --port 3737 --workspace archidocs";
492
+ readonly description: "Serve Streamable HTTP at `/mcp` on a loopback address, with the write tools off.";
493
+ }, {
494
+ readonly command: "archidocs mcp --http --allow-writes --workspace archidocs";
495
+ readonly description: "Serve over HTTP with the write tools on.";
496
+ }];
497
+ readonly exitCodes: readonly [{
498
+ readonly code: 0;
499
+ readonly meaning: "Over stdio, the client closed the connection.";
500
+ }, {
501
+ readonly code: 2;
502
+ readonly meaning: "It could not start: an unknown flag, a flag missing its value, flags that don't go together, a `--viewer-url` that is not a URL, a `--port` that is not a port or is in use, a `--host` that is not a loopback address, or no Workspace found when `--bundle` is not given.";
503
+ }];
504
+ readonly exitNote: "With `--http`, `mcp` runs until you stop it with Ctrl+C. The interrupt ends the process, so the exit status is the shell's for an interrupted command (130 in most shells), not a code of its own. A Bundle that can't be read does not stop the server: each tool call answers `source_unavailable`, and the next call tries again.";
284
505
  };
285
506
  };
286
507
  export type CommandName = keyof typeof commands;
@@ -1,11 +1,18 @@
1
1
  /**
2
2
  * The CLI's commands and flags, described once. The CLI parses each
3
3
  * command's arguments with these flags and prints its usage text from them;
4
- * the docs site generates its CLI reference from them and checks every
5
- * `archidocs …` line in a page with `parseCommandLine`. Importing this
6
- * module has no side effects and pulls in nothing but `node:util`.
4
+ * the docs site generates its CLI reference from them, examples and exit
5
+ * codes included, and checks every `archidocs …` line in a page with
6
+ * `parseCommandLine`. Importing this module has no side effects and pulls in
7
+ * nothing but `node:util`.
7
8
  */
8
9
  import { parseArgs } from "node:util";
10
+ /** The CLI's exit codes: 0 no errors, 1 errors found (or any warning with `check --strict`), 2 could not run. */
11
+ export const EXIT = { ok: 0, foundErrors: 1, couldNotRun: 2 };
12
+ /** What a command that needs a Workspace says, exiting 2, when the search for one finds none. */
13
+ export const NO_WORKSPACE = "No workspace.yaml found in this folder, its archidocs/ folder, or any folder above.";
14
+ /** How every command's exit 2 starts: the command line itself was refused. */
15
+ const USAGE_ERROR = "an unknown flag, a flag missing its value";
9
16
  export const commands = {
10
17
  version: {
11
18
  name: "version",
@@ -15,6 +22,14 @@ export const commands = {
15
22
  flags: {
16
23
  format: { type: "string", value: "text|json", default: "text", description: "Print a line of text, or a JSON object with `version` and `schemaVersion`." },
17
24
  },
25
+ examples: [
26
+ { command: "archidocs version", description: "Print both versions as one line of text." },
27
+ { command: "archidocs version --format json", description: "Print them as JSON, for a CI cache key that changes when the Bundle schemaVersion does." },
28
+ ],
29
+ exitCodes: [
30
+ { code: EXIT.ok, meaning: "The version was printed." },
31
+ { code: EXIT.couldNotRun, meaning: `It could not run: ${USAGE_ERROR}, or an unknown format.` },
32
+ ],
18
33
  },
19
34
  init: {
20
35
  name: "init",
@@ -25,6 +40,17 @@ export const commands = {
25
40
  skill: { type: "boolean", default: false, description: "Install only the agent skill and its pointers, for a code repo that has no Workspace of its own." },
26
41
  workspace: { type: "string", value: "<dir>", description: "With `--skill`: the Workspace checkout that the printed MCP command points at." },
27
42
  },
43
+ examples: [
44
+ { command: "archidocs init", description: "Write `archidocs/workspace.yaml` if the repo has no Workspace yet, and install the agent skill." },
45
+ {
46
+ command: "archidocs init --skill --workspace ../architecture/archidocs",
47
+ description: "In a code repo, install only the agent skill, and print the MCP command for the Workspace checked out beside it.",
48
+ },
49
+ ],
50
+ exitCodes: [
51
+ { code: EXIT.ok, meaning: "The Workspace and the agent skill are set up, or already were. Each file written or updated is printed." },
52
+ { code: EXIT.couldNotRun, meaning: `It could not run: ${USAGE_ERROR}, \`--workspace\` without \`--skill\`, or a file it could not write.` },
53
+ ],
28
54
  },
29
55
  guide: {
30
56
  name: "guide",
@@ -32,16 +58,35 @@ export const commands = {
32
58
  description: "Print the authoring guide for agents, or one of its task topics.",
33
59
  arguments: [{ name: "[topic]", description: "A task topic; with none, the guide and the list of topics." }],
34
60
  flags: {},
61
+ examples: [
62
+ { command: "archidocs guide", description: "Print the guide: the Model in brief, the edit loop and the list of task topics." },
63
+ { command: "archidocs guide add-service", description: "Print one task topic, here how to add a Service." },
64
+ ],
65
+ exitCodes: [
66
+ { code: EXIT.ok, meaning: "The guide or the topic was printed." },
67
+ { code: EXIT.couldNotRun, meaning: "It could not run: an unknown topic (the message lists the topics there are), more than one topic, or any flag, since it takes none." },
68
+ ],
35
69
  },
36
70
  check: {
37
71
  name: "check",
38
72
  synopsis: ["check [--format text|json|github] [--strict]"],
39
- description: "Validate the Workspace found from the current folder. Exits 1 on errors, 2 if it could not run.",
73
+ description: "Validate the Workspace found from the current folder and print each issue with its file, line and rule.",
40
74
  arguments: [],
41
75
  flags: {
42
76
  format: { type: "string", value: "text|json|github", default: "text", description: "Print issues as text, as JSON, or as GitHub Actions annotations." },
43
77
  strict: { type: "boolean", default: false, description: "Exit 1 on warnings too, not only on errors." },
44
78
  },
79
+ examples: [
80
+ { command: "archidocs check", description: "Validate the Workspace and print its issues grouped by file, then a count and a link to each rule's page." },
81
+ { command: "archidocs check --strict", description: "Fail on warnings as well as errors, for a CI job that keeps the Workspace clean." },
82
+ { command: "archidocs check --format github", description: "Print each issue as a GitHub Actions annotation, which a pull request shows on the line the issue is about." },
83
+ { command: "archidocs check --format json", description: "Print the issues and a count of errors and warnings as JSON, for a script." },
84
+ ],
85
+ exitCodes: [
86
+ { code: EXIT.ok, meaning: "No errors. Warnings are printed and still exit 0, unless `--strict` is given." },
87
+ { code: EXIT.foundErrors, meaning: "The Workspace has at least one error; with `--strict`, at least one error or warning." },
88
+ { code: EXIT.couldNotRun, meaning: `It could not run: ${USAGE_ERROR}, an unknown format, or no Workspace found.` },
89
+ ],
45
90
  },
46
91
  build: {
47
92
  name: "build",
@@ -55,6 +100,20 @@ export const commands = {
55
100
  preview: { type: "boolean", default: false, description: "Build a PR preview site holding just the PR head and the base branch's latest Revision, for Compare." },
56
101
  base: { type: "string", value: "<branch>", defaultText: "the branch origin/HEAD points at", description: "With `--preview`: the base branch, read from `origin/<branch>` without fetching." },
57
102
  },
103
+ examples: [
104
+ { command: "archidocs build --out site", description: "Write the viewer, the latest Bundle and the past Revisions' Bundles into `site/`, ready for any static host." },
105
+ { command: "archidocs build --out site --keep 50", description: "Keep Bundles for the latest 50 past Revisions only, and for every tagged one." },
106
+ { command: "archidocs build --bundle-only --out public", description: "Write only `public/workspace.bundle.json`, for `mcp --bundle` or a script to read." },
107
+ { command: "archidocs build --preview --base main --out preview", description: "Write a PR preview site that opens on Compare, from `origin/main` to the pull request checked out." },
108
+ ],
109
+ exitCodes: [
110
+ { code: EXIT.ok, meaning: "The site, the Bundle or the preview site was written." },
111
+ { code: EXIT.foundErrors, meaning: "The Workspace has errors. They are printed as `check` prints them, and nothing is written." },
112
+ {
113
+ code: EXIT.couldNotRun,
114
+ meaning: `It could not run: ${USAGE_ERROR}, flags that don't go together, a \`--keep\` that is not a count or \`all\`, no Workspace found, or with \`--preview\` a Workspace outside git or a base branch that is not in the checkout.`,
115
+ },
116
+ ],
58
117
  },
59
118
  dev: {
60
119
  name: "dev",
@@ -66,6 +125,14 @@ export const commands = {
66
125
  port: { type: "string", value: "<n>", default: "4321", description: "The port to serve on." },
67
126
  host: { type: "string", value: "<host>", default: "127.0.0.1", description: "The address to listen on." },
68
127
  },
128
+ examples: [
129
+ { command: "archidocs dev", description: "Serve the viewer for the Workspace found from the current folder, and print its address." },
130
+ { command: "archidocs dev --port 4000", description: "Serve on another port, for when the default one is in use." },
131
+ { command: "archidocs dev --workspace ../architecture", description: "Serve the Workspace found from another folder, such as a checkout of the Workspace repo beside a code repo." },
132
+ { command: "archidocs dev --host 0.0.0.0", description: "Listen on every network interface, so that other machines can open the viewer." },
133
+ ],
134
+ exitCodes: [{ code: EXIT.couldNotRun, meaning: `It could not start: ${USAGE_ERROR}, a \`--port\` that is not a port or is in use, or no Workspace found.` }],
135
+ exitNote: "Once it is serving, `dev` runs until you stop it with Ctrl+C. A Workspace with errors does not stop it: it prints them and keeps serving. The interrupt ends the process, so the exit status is the shell's for an interrupted command (130 in most shells), not a code of its own.",
69
136
  },
70
137
  export: {
71
138
  name: "export",
@@ -83,6 +150,24 @@ export const commands = {
83
150
  theme: { type: "string", value: "light|dark", default: "light", description: "The palette: the viewer's light tokens, or its Night shift dark ones." },
84
151
  label: { type: "string", value: "<text>", defaultText: "the Workspace, short commit and date", description: "The line under the title, such as `Big Bank · v1.2.0`, in place of the source line." },
85
152
  },
153
+ examples: [
154
+ { command: "archidocs export c2", description: "Write the C2 Generated View, every System and Service, to `c2.svg` in the current folder." },
155
+ {
156
+ command: "archidocs export c2/digital:internet-banking --direction TB --theme dark",
157
+ description: "Write one System's Services, the System named by its Qualified id, laid out top to bottom in the dark palette.",
158
+ },
159
+ { command: "archidocs export payments:make-a-payment --format png --out make-a-payment.png", description: "Write a Saved View, here a Dynamic View, as a PNG." },
160
+ { command: "archidocs export --all-saved --out views", description: "Write every Saved View into `views/`, one picture each, named by its id." },
161
+ { command: 'archidocs export deployment/prod --label "Big Bank · v1.2.0"', description: "Write an Environment's Deployment View with a line of your own under the title, in place of the commit and date." },
162
+ ],
163
+ exitCodes: [
164
+ { code: EXIT.ok, meaning: "Each picture was written, and its path printed." },
165
+ { code: EXIT.foundErrors, meaning: "The Workspace has errors. They are printed as `check` prints them, and nothing is exported." },
166
+ {
167
+ code: EXIT.couldNotRun,
168
+ meaning: `It could not run: ${USAGE_ERROR}, an unknown format, direction or theme, an unknown View, a View together with \`--all-saved\` or neither of them, \`--all-saved\` without \`--out\`, or no Workspace found.`,
169
+ },
170
+ ],
86
171
  },
87
172
  diff: {
88
173
  name: "diff",
@@ -95,6 +180,16 @@ export const commands = {
95
180
  flags: {
96
181
  format: { type: "string", value: "text|json|markdown", default: "text", description: "Print the changes as text, JSON, or Markdown for a PR comment." },
97
182
  },
183
+ examples: [
184
+ { command: "archidocs diff HEAD", description: "Show what your uncommitted edits change, against the last commit." },
185
+ { command: "archidocs diff origin/main HEAD", description: "Show what a branch changes against the default branch, as a reviewer of its pull request will see it." },
186
+ { command: "archidocs diff 2026-01-01 2026-06-30", description: "Show the Changes between two dates; each date means the last default-branch commit at or before it." },
187
+ { command: "archidocs diff origin/main HEAD --format markdown", description: "Write the Changes as Markdown, to post as a pull request comment." },
188
+ ],
189
+ exitCodes: [
190
+ { code: EXIT.ok, meaning: "The Changes were printed. It exits 0 whether or not anything changed, so a script that asks whether the Model changed must read the output, not the exit code." },
191
+ { code: EXIT.couldNotRun, meaning: `It could not run: ${USAGE_ERROR}, an unknown format, no point or more than two, an unknown ref or date, no Workspace found, or a Workspace outside git.` },
192
+ ],
98
193
  },
99
194
  "history build": {
100
195
  name: "history build",
@@ -104,6 +199,15 @@ export const commands = {
104
199
  flags: {
105
200
  since: { type: "string", value: "<ref|date>", defaultText: "every Revision", description: "Only build Revisions at or after this ref's commit time or the start of this date." },
106
201
  },
202
+ examples: [
203
+ { command: "archidocs history build", description: "Build and cache the Bundle of every past Revision, so the next `build` or `diff` reads them from the cache." },
204
+ { command: "archidocs history build --since 2026-01-01", description: "Only build the Revisions from the start of that date on." },
205
+ { command: "archidocs history build --since v1.0.0", description: "Only build the Revisions at or after a tag's commit." },
206
+ ],
207
+ exitCodes: [
208
+ { code: EXIT.ok, meaning: "Every Revision asked for is in the cache. It prints how many it built and how many were already built." },
209
+ { code: EXIT.couldNotRun, meaning: `It could not run: ${USAGE_ERROR}, an unknown \`--since\` ref or date, no Workspace found, or a Workspace outside git.` },
210
+ ],
107
211
  },
108
212
  mcp: {
109
213
  name: "mcp",
@@ -119,6 +223,27 @@ export const commands = {
119
223
  port: { type: "string", value: "<n>", defaultText: "3737", description: "With `--http`: the port to serve on." },
120
224
  "allow-writes": { type: "boolean", default: false, description: "With `--http`: allow the write tools, which are off over HTTP by default." },
121
225
  },
226
+ examples: [
227
+ {
228
+ command: "archidocs mcp --workspace archidocs",
229
+ description: "Serve a Workspace checkout over stdio, with the read and write tools. This is the command to register with a coding agent, which starts it from the repo root.",
230
+ },
231
+ { command: "archidocs mcp --bundle https://big-bank.archidocs.dev/workspace.bundle.json", description: "Serve a published Bundle, here the Big Bank demo's, with the read tools only." },
232
+ {
233
+ command: "archidocs mcp --bundle https://architecture.example.com/workspace.bundle.json --viewer-url https://architecture.example.com/",
234
+ description: "Serve your own published Bundle, with links to its viewer in the tool results.",
235
+ },
236
+ { command: "archidocs mcp --http --port 3737 --workspace archidocs", description: "Serve Streamable HTTP at `/mcp` on a loopback address, with the write tools off." },
237
+ { command: "archidocs mcp --http --allow-writes --workspace archidocs", description: "Serve over HTTP with the write tools on." },
238
+ ],
239
+ exitCodes: [
240
+ { code: EXIT.ok, meaning: "Over stdio, the client closed the connection." },
241
+ {
242
+ code: EXIT.couldNotRun,
243
+ meaning: `It could not start: ${USAGE_ERROR}, flags that don't go together, a \`--viewer-url\` that is not a URL, a \`--port\` that is not a port or is in use, a \`--host\` that is not a loopback address, or no Workspace found when \`--bundle\` is not given.`,
244
+ },
245
+ ],
246
+ exitNote: "With `--http`, `mcp` runs until you stop it with Ctrl+C. The interrupt ends the process, so the exit status is the shell's for an interrupted command (130 in most shells), not a code of its own. A Bundle that can't be read does not stop the server: each tool call answers `source_unavailable`, and the next call tries again.",
122
247
  },
123
248
  };
124
249
  /** Every command, in the order the usage lists them. */
@@ -1,4 +1,4 @@
1
- /** Where harnesses look for skills; the stub goes into each. */
1
+ /** Where coding agents look for skills; the stub goes into each. */
2
2
  export declare const SKILL_DIRS: readonly [".agents/skills", ".claude/skills", ".github/skills"];
3
3
  export interface InitOptions {
4
4
  /** The repo being set up: its git top level, or the current folder outside git. */