archidocs 1.4.0-beta.2 → 1.4.0-beta.4
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 +1 -1
- package/dist/cli/commands.d.ts +59 -6
- package/dist/cli/commands.js +30 -6
- package/dist/cli/init.js +1 -1
- package/dist/cli/run.js +27 -4
- package/dist/commands/gaps.d.ts +24 -0
- package/dist/commands/gaps.js +14 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/core/gaps.d.ts +53 -0
- package/dist/core/gaps.js +96 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/load.js +7 -3
- package/dist/guide/index.d.ts +76 -13
- package/dist/guide/index.js +60 -26
- package/dist/mcp/server.js +60 -15
- package/dist/render/sequence-svg.js +2 -2
- package/dist/render/svg.js +1 -1
- package/dist/schema/bundle.d.ts +14 -0
- package/dist/schema/bundle.js +5 -3
- package/dist/schema/workspace.d.ts +35 -0
- package/dist/schema/workspace.js +10 -0
- package/dist/viewer/assets/{index-CzXU8F_3.css → index-BL2vQQ6T.css} +1 -1
- package/dist/viewer/assets/{index-DmVLe9LK.js → index-Oy0Hpoqy.js} +8 -8
- package/dist/viewer/assets/sequence-svg-DDwcPtpC.js +2 -0
- package/dist/viewer/assets/svg-Cboa7QX_.js +2 -0
- package/dist/viewer/index.html +2 -2
- package/dist/writer/document.js +22 -1
- package/guide/SKILL.md +4 -4
- package/guide/topics/add-service.md +2 -1
- package/guide/topics/fill-gaps.md +87 -0
- package/guide/topics/relationships.md +24 -0
- package/package.json +1 -1
- package/schemas/model.schema.json +75 -0
- package/dist/viewer/assets/sequence-svg-BtEmwvN4.js +0 -2
- package/dist/viewer/assets/svg-DXIkkkSu.js +0 -2
package/README.md
CHANGED
|
@@ -163,7 +163,7 @@ The terms (Workspace, Project, Element, Relationship, Team, Environment, Deploym
|
|
|
163
163
|
| `archidocs export <view-id>` | Render a View to SVG or PNG, styled like the viewer; `--all-saved` renders every Saved View, `--theme dark` draws it in the viewer's dark palette and `--label <text>` replaces the source line. |
|
|
164
164
|
| `archidocs diff <from> [<to>]` | Show what changed in the Model between two refs. |
|
|
165
165
|
| `archidocs mcp` | Run the MCP server over a Workspace checkout or a published Bundle. |
|
|
166
|
-
| `archidocs guide [topic]` | Print
|
|
166
|
+
| `archidocs guide [topic] [--skill <id>]` | Print an agent skill's guide; `--skill` defaults to `authoring`. |
|
|
167
167
|
| `archidocs version` | Print the CLI and Bundle schema versions. |
|
|
168
168
|
|
|
169
169
|
## Publishing
|
package/dist/cli/commands.d.ts
CHANGED
|
@@ -123,26 +123,36 @@ export declare const commands: {
|
|
|
123
123
|
};
|
|
124
124
|
readonly guide: {
|
|
125
125
|
readonly name: "guide";
|
|
126
|
-
readonly synopsis: readonly ["guide [topic]"];
|
|
127
|
-
readonly description: "Print
|
|
126
|
+
readonly synopsis: readonly ["guide [topic] [--skill <id>]"];
|
|
127
|
+
readonly description: "Print an agent skill's full guide, or one of its task topics. With no `--skill`, the authoring guide.";
|
|
128
128
|
readonly arguments: readonly [{
|
|
129
129
|
readonly name: "[topic]";
|
|
130
|
-
readonly description: "A task topic; with none, the guide and
|
|
130
|
+
readonly description: "A task topic of the skill; with none, the guide and its list of topics.";
|
|
131
131
|
}];
|
|
132
|
-
readonly flags: {
|
|
132
|
+
readonly flags: {
|
|
133
|
+
readonly skill: {
|
|
134
|
+
readonly type: "string";
|
|
135
|
+
readonly value: "<id>";
|
|
136
|
+
readonly default: "authoring";
|
|
137
|
+
readonly description: "The skill whose guide to print. `authoring` is the one there is today.";
|
|
138
|
+
};
|
|
139
|
+
};
|
|
133
140
|
readonly examples: readonly [{
|
|
134
141
|
readonly command: "archidocs guide";
|
|
135
|
-
readonly description: "Print the guide: the Model in brief, the edit loop and the list of task topics.";
|
|
142
|
+
readonly description: "Print the authoring guide: the Model in brief, the edit loop and the list of task topics.";
|
|
136
143
|
}, {
|
|
137
144
|
readonly command: "archidocs guide add-service";
|
|
138
145
|
readonly description: "Print one task topic, here how to add a Service.";
|
|
146
|
+
}, {
|
|
147
|
+
readonly command: "archidocs guide --skill authoring";
|
|
148
|
+
readonly description: "Name the skill, as a skill's stub does: the same as `archidocs guide`.";
|
|
139
149
|
}];
|
|
140
150
|
readonly exitCodes: readonly [{
|
|
141
151
|
readonly code: 0;
|
|
142
152
|
readonly meaning: "The guide or the topic was printed.";
|
|
143
153
|
}, {
|
|
144
154
|
readonly code: 2;
|
|
145
|
-
readonly meaning: "It could not run: an unknown topic (the message
|
|
155
|
+
readonly meaning: "It could not run: an unknown skill or topic (the message names the closest one and lists them all), a topic on a skill without topics, more than one topic, or an unknown flag.";
|
|
146
156
|
}];
|
|
147
157
|
};
|
|
148
158
|
readonly check: {
|
|
@@ -187,6 +197,49 @@ export declare const commands: {
|
|
|
187
197
|
readonly meaning: "It could not run: an unknown flag, a flag missing its value, an unknown format, or no Workspace found.";
|
|
188
198
|
}];
|
|
189
199
|
};
|
|
200
|
+
readonly gaps: {
|
|
201
|
+
readonly name: "gaps";
|
|
202
|
+
readonly synopsis: readonly ["gaps [--project <id>] [--owner <team>] [--json]"];
|
|
203
|
+
readonly description: "List what the Model leaves empty, grouped by Project and Owner Team: the gaps an agent's fill-gaps interview works through.";
|
|
204
|
+
readonly arguments: readonly [];
|
|
205
|
+
readonly flags: {
|
|
206
|
+
readonly project: {
|
|
207
|
+
readonly type: "string";
|
|
208
|
+
readonly value: "<id>";
|
|
209
|
+
readonly description: "Only this Project's gaps.";
|
|
210
|
+
};
|
|
211
|
+
readonly owner: {
|
|
212
|
+
readonly type: "string";
|
|
213
|
+
readonly value: "<team>";
|
|
214
|
+
readonly description: "Only the gaps of items this Team owns.";
|
|
215
|
+
};
|
|
216
|
+
readonly json: {
|
|
217
|
+
readonly type: "boolean";
|
|
218
|
+
readonly default: false;
|
|
219
|
+
readonly description: "Print the gaps as JSON, in the shape the `list_gaps` MCP tool returns, instead of Markdown.";
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
readonly examples: readonly [{
|
|
223
|
+
readonly command: "archidocs gaps";
|
|
224
|
+
readonly description: "Print every gap as Markdown: a heading per Project and Owner Team, then a line per Element, Relationship or Deployment naming its empty fields.";
|
|
225
|
+
}, {
|
|
226
|
+
readonly command: "archidocs gaps --owner payments-team";
|
|
227
|
+
readonly description: "Print only the gaps of what one Team owns, as a backlog to hand to that Team.";
|
|
228
|
+
}, {
|
|
229
|
+
readonly command: "archidocs gaps --project shop --json";
|
|
230
|
+
readonly description: "Print one Project's gaps as JSON, for a script.";
|
|
231
|
+
}];
|
|
232
|
+
readonly exitCodes: readonly [{
|
|
233
|
+
readonly code: 0;
|
|
234
|
+
readonly meaning: "The gaps were printed, or none were found. It exits 0 either way: a gap is incompleteness, not an error, and `check` never reports one.";
|
|
235
|
+
}, {
|
|
236
|
+
readonly code: 1;
|
|
237
|
+
readonly meaning: "The Workspace has errors. They are printed as `check` prints them, and no gaps are listed.";
|
|
238
|
+
}, {
|
|
239
|
+
readonly code: 2;
|
|
240
|
+
readonly meaning: "It could not run: an unknown flag, a flag missing its value, an unknown Project or Team, or no Workspace found.";
|
|
241
|
+
}];
|
|
242
|
+
};
|
|
190
243
|
readonly build: {
|
|
191
244
|
readonly name: "build";
|
|
192
245
|
readonly synopsis: readonly ["build [--out <dir>] [--bundle-only] [--keep <n|all>]", "build --preview [--base <branch>] [--out <dir>]"];
|
package/dist/cli/commands.js
CHANGED
|
@@ -54,17 +54,20 @@ export const commands = {
|
|
|
54
54
|
},
|
|
55
55
|
guide: {
|
|
56
56
|
name: "guide",
|
|
57
|
-
synopsis: ["guide [topic]"],
|
|
58
|
-
description: "Print
|
|
59
|
-
arguments: [{ name: "[topic]", description: "A task topic; with none, the guide and
|
|
60
|
-
flags: {
|
|
57
|
+
synopsis: ["guide [topic] [--skill <id>]"],
|
|
58
|
+
description: "Print an agent skill's full guide, or one of its task topics. With no `--skill`, the authoring guide.",
|
|
59
|
+
arguments: [{ name: "[topic]", description: "A task topic of the skill; with none, the guide and its list of topics." }],
|
|
60
|
+
flags: {
|
|
61
|
+
skill: { type: "string", value: "<id>", default: "authoring", description: "The skill whose guide to print. `authoring` is the one there is today." },
|
|
62
|
+
},
|
|
61
63
|
examples: [
|
|
62
|
-
{ command: "archidocs guide", description: "Print the guide: the Model in brief, the edit loop and the list of task topics." },
|
|
64
|
+
{ command: "archidocs guide", description: "Print the authoring guide: the Model in brief, the edit loop and the list of task topics." },
|
|
63
65
|
{ command: "archidocs guide add-service", description: "Print one task topic, here how to add a Service." },
|
|
66
|
+
{ command: "archidocs guide --skill authoring", description: "Name the skill, as a skill's stub does: the same as `archidocs guide`." },
|
|
64
67
|
],
|
|
65
68
|
exitCodes: [
|
|
66
69
|
{ 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
|
|
70
|
+
{ code: EXIT.couldNotRun, meaning: "It could not run: an unknown skill or topic (the message names the closest one and lists them all), a topic on a skill without topics, more than one topic, or an unknown flag." },
|
|
68
71
|
],
|
|
69
72
|
},
|
|
70
73
|
check: {
|
|
@@ -88,6 +91,27 @@ export const commands = {
|
|
|
88
91
|
{ code: EXIT.couldNotRun, meaning: `It could not run: ${USAGE_ERROR}, an unknown format, or no Workspace found.` },
|
|
89
92
|
],
|
|
90
93
|
},
|
|
94
|
+
gaps: {
|
|
95
|
+
name: "gaps",
|
|
96
|
+
synopsis: ["gaps [--project <id>] [--owner <team>] [--json]"],
|
|
97
|
+
description: "List what the Model leaves empty, grouped by Project and Owner Team: the gaps an agent's fill-gaps interview works through.",
|
|
98
|
+
arguments: [],
|
|
99
|
+
flags: {
|
|
100
|
+
project: { type: "string", value: "<id>", description: "Only this Project's gaps." },
|
|
101
|
+
owner: { type: "string", value: "<team>", description: "Only the gaps of items this Team owns." },
|
|
102
|
+
json: { type: "boolean", default: false, description: "Print the gaps as JSON, in the shape the `list_gaps` MCP tool returns, instead of Markdown." },
|
|
103
|
+
},
|
|
104
|
+
examples: [
|
|
105
|
+
{ command: "archidocs gaps", description: "Print every gap as Markdown: a heading per Project and Owner Team, then a line per Element, Relationship or Deployment naming its empty fields." },
|
|
106
|
+
{ command: "archidocs gaps --owner payments-team", description: "Print only the gaps of what one Team owns, as a backlog to hand to that Team." },
|
|
107
|
+
{ command: "archidocs gaps --project shop --json", description: "Print one Project's gaps as JSON, for a script." },
|
|
108
|
+
],
|
|
109
|
+
exitCodes: [
|
|
110
|
+
{ code: EXIT.ok, meaning: "The gaps were printed, or none were found. It exits 0 either way: a gap is incompleteness, not an error, and `check` never reports one." },
|
|
111
|
+
{ code: EXIT.foundErrors, meaning: "The Workspace has errors. They are printed as `check` prints them, and no gaps are listed." },
|
|
112
|
+
{ code: EXIT.couldNotRun, meaning: `It could not run: ${USAGE_ERROR}, an unknown Project or Team, or no Workspace found.` },
|
|
113
|
+
],
|
|
114
|
+
},
|
|
91
115
|
build: {
|
|
92
116
|
name: "build",
|
|
93
117
|
synopsis: ["build [--out <dir>] [--bundle-only] [--keep <n|all>]", "build --preview [--base <branch>] [--out <dir>]"],
|
package/dist/cli/init.js
CHANGED
|
@@ -46,7 +46,7 @@ async function listsArchidocs(path) {
|
|
|
46
46
|
export async function init({ repoRoot, cwd, skillOnly, workspace, env, version }) {
|
|
47
47
|
const out = [];
|
|
48
48
|
const runner = await archidocsCommand(repoRoot, env, version);
|
|
49
|
-
const stub = skillStub(runner);
|
|
49
|
+
const stub = skillStub("authoring", runner);
|
|
50
50
|
const wrote = (path, what) => out.push(`${what} ${posix(relative(repoRoot, path))}`);
|
|
51
51
|
let workspaceDir;
|
|
52
52
|
if (!skillOnly) {
|
package/dist/cli/run.js
CHANGED
|
@@ -7,14 +7,16 @@ import { themes } from "../render/tokens.js";
|
|
|
7
7
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
8
8
|
import { gitTopLevel } from "../git.js";
|
|
9
9
|
import { findCheckout } from "../workspace/index.js";
|
|
10
|
-
import { build, buildHistory, check, diff, exportViews } from "../commands/index.js";
|
|
10
|
+
import { build, buildHistory, check, diff, exportViews, gaps } from "../commands/index.js";
|
|
11
11
|
import { bundleSource, checkoutSource, checkServer, createServer, DEFAULT_PORT, serveHttp, startupLine } from "../mcp/index.js";
|
|
12
|
-
import {
|
|
12
|
+
import { guide as skillGuide } from "../guide/index.js";
|
|
13
13
|
import { EXIT, NO_WORKSPACE, parseCommand, usageText } from "./commands.js";
|
|
14
14
|
import { init } from "./init.js";
|
|
15
15
|
import { DEFAULT_DEV_PORT, serveDev } from "./dev.js";
|
|
16
16
|
import { exitCodeFor, formatIssues, formats, formatText } from "./format.js";
|
|
17
17
|
import { DEFAULT_KEEP, pointMessage } from "../history/index.js";
|
|
18
|
+
import { formatGaps } from "../core/index.js";
|
|
19
|
+
import { didYouMean } from "../core/suggest.js";
|
|
18
20
|
import { LATEST_BUNDLE_PATH } from "../revisions/index.js";
|
|
19
21
|
import { SCHEMA_VERSION } from "../schema/bundle.js";
|
|
20
22
|
import { diffFormats, formatDiff } from "./diff-format.js";
|
|
@@ -72,10 +74,10 @@ async function main(argv, io) {
|
|
|
72
74
|
return OK;
|
|
73
75
|
}
|
|
74
76
|
if (command === "guide") {
|
|
75
|
-
const { positionals } = parseCommand("guide", rest);
|
|
77
|
+
const { positionals, values } = parseCommand("guide", rest);
|
|
76
78
|
if (positionals.length > 1)
|
|
77
79
|
throw new UsageError(`Give one topic at a time; got ${positionals.join(", ")}.`);
|
|
78
|
-
const guide = await
|
|
80
|
+
const guide = await skillGuide(values.skill, positionals[0]);
|
|
79
81
|
if (!guide.ok)
|
|
80
82
|
throw new UsageError(guide.message);
|
|
81
83
|
io.stdout.write(guide.text);
|
|
@@ -90,6 +92,27 @@ async function main(argv, io) {
|
|
|
90
92
|
io.stdout.write(formatIssues(issues, format, { color: useColor(io) }));
|
|
91
93
|
return exitCodeFor(issues, { strict: values.strict });
|
|
92
94
|
}
|
|
95
|
+
if (command === "gaps") {
|
|
96
|
+
const { values } = parseCommand("gaps", rest);
|
|
97
|
+
const result = await gaps(await checkoutFrom(io.cwd), {
|
|
98
|
+
...(values.project === undefined ? {} : { project: values.project }),
|
|
99
|
+
...(values.owner === undefined ? {} : { owner: values.owner }),
|
|
100
|
+
});
|
|
101
|
+
switch (result.kind) {
|
|
102
|
+
case "errors":
|
|
103
|
+
io.stdout.write(formatText(result.issues, { color: useColor(io) }));
|
|
104
|
+
io.stderr.write("Not listing gaps: the Workspace has errors.\n");
|
|
105
|
+
return FOUND_ERRORS;
|
|
106
|
+
case "unknown":
|
|
107
|
+
throw new UsageError(`Unknown ${result.what} "${result.id}"${didYouMean(result.id, result.known) || "."}`);
|
|
108
|
+
case "gaps":
|
|
109
|
+
if (values.json)
|
|
110
|
+
io.stdout.write(JSON.stringify({ total: result.gaps.length, gaps: result.gaps }, null, 2) + "\n");
|
|
111
|
+
else
|
|
112
|
+
io.stdout.write(result.gaps.length ? formatGaps(result.gaps, result.bundle) : "No gaps.\n");
|
|
113
|
+
return OK;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
93
116
|
if (command === "build") {
|
|
94
117
|
const { values } = parseCommand("build", rest);
|
|
95
118
|
if (values.preview && values.keep !== undefined)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Gap, type GapFilter, type Issue } from "../core/index.ts";
|
|
2
|
+
import type { Bundle } from "../schema/bundle.ts";
|
|
3
|
+
import type { Checkout } from "../workspace/index.ts";
|
|
4
|
+
export type GapsResult =
|
|
5
|
+
/** The Workspace has errors, so it has no Bundle to scan. */
|
|
6
|
+
{
|
|
7
|
+
kind: "errors";
|
|
8
|
+
issues: Issue[];
|
|
9
|
+
}
|
|
10
|
+
/** The filter names a Project or Team the Workspace doesn't have. */
|
|
11
|
+
| {
|
|
12
|
+
kind: "unknown";
|
|
13
|
+
what: "Project" | "Team";
|
|
14
|
+
id: string;
|
|
15
|
+
known: string[];
|
|
16
|
+
}
|
|
17
|
+
/** The gaps, possibly none, with the Bundle they were found in. */
|
|
18
|
+
| {
|
|
19
|
+
kind: "gaps";
|
|
20
|
+
gaps: Gap[];
|
|
21
|
+
bundle: Bundle;
|
|
22
|
+
};
|
|
23
|
+
/** What the Workspace's Model leaves empty, optionally for one Project or Owner Team. */
|
|
24
|
+
export declare function gaps(checkout: Checkout, filter?: GapFilter): Promise<GapsResult>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { listGaps } from "../core/index.js";
|
|
2
|
+
/** What the Workspace's Model leaves empty, optionally for one Project or Owner Team. */
|
|
3
|
+
export async function gaps(checkout, filter = {}) {
|
|
4
|
+
const { bundle, issues } = await checkout.load();
|
|
5
|
+
if (issues.some((i) => i.severity === "error"))
|
|
6
|
+
return { kind: "errors", issues };
|
|
7
|
+
const projects = bundle.projects.map((p) => p.id);
|
|
8
|
+
if (filter.project !== undefined && !projects.includes(filter.project))
|
|
9
|
+
return { kind: "unknown", what: "Project", id: filter.project, known: projects };
|
|
10
|
+
const teams = bundle.teams.map((t) => t.id);
|
|
11
|
+
if (filter.owner !== undefined && !teams.includes(filter.owner))
|
|
12
|
+
return { kind: "unknown", what: "Team", id: filter.owner, known: teams };
|
|
13
|
+
return { kind: "gaps", gaps: listGaps(bundle, filter), bundle };
|
|
14
|
+
}
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -9,3 +9,4 @@ export { build, type BuildOptions, type BuildResult } from "./build.ts";
|
|
|
9
9
|
export { exportViews, type ExportOptions, type ExportResult, type ExportedFile } from "./export.ts";
|
|
10
10
|
export { diff, type DiffResult, type DiffSide } from "./diff.ts";
|
|
11
11
|
export { buildHistory, type BuildHistoryOptions, type BuildHistoryResult } from "./history.ts";
|
|
12
|
+
export { gaps, type GapsResult } from "./gaps.ts";
|
package/dist/commands/index.js
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Bundle } from "../schema/bundle.ts";
|
|
2
|
+
/** The fields a gap can name. `api-docs` and `deployments` are not fields but what the Model lacks. */
|
|
3
|
+
export declare const gapNames: readonly ["description", "technology", "repository", "deployments", "api-docs", "channel", "url"];
|
|
4
|
+
export type GapName = (typeof gapNames)[number];
|
|
5
|
+
export type GapItemKind = "element" | "relationship" | "deployment";
|
|
6
|
+
/**
|
|
7
|
+
* One item the Model leaves incomplete. `item.id` is the Element's id, a
|
|
8
|
+
* Relationship as `<from> -> <to>`, or a Deployment as
|
|
9
|
+
* `<service> in <environment> on <target>`.
|
|
10
|
+
*/
|
|
11
|
+
export interface Gap {
|
|
12
|
+
project: string;
|
|
13
|
+
owner: string;
|
|
14
|
+
item: {
|
|
15
|
+
kind: GapItemKind;
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
missing: GapName[];
|
|
19
|
+
}
|
|
20
|
+
export interface GapFilter {
|
|
21
|
+
/** Only this Project's gaps. */
|
|
22
|
+
project?: string;
|
|
23
|
+
/** Only the gaps of items this Team owns. */
|
|
24
|
+
owner?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every gap in the Model: the fields a reader would expect filled and finds
|
|
28
|
+
* empty, as the table under "What counts as a gap" in the fill-gaps guide
|
|
29
|
+
* sets them out.
|
|
30
|
+
*
|
|
31
|
+
* - Every Element: `description`.
|
|
32
|
+
* - A Service or Component: `technology`.
|
|
33
|
+
* - A Service you run (`type: app`, not External): `repository`.
|
|
34
|
+
* - A Service not External: `deployments` when it has none.
|
|
35
|
+
* - A Service you run that a non-Person calls: `api-docs` when no `links`
|
|
36
|
+
* label and no Deployment `endpoints` name matches api, openapi or swagger.
|
|
37
|
+
* - A Relationship: `description`, `technology`; an async one also `channel`.
|
|
38
|
+
* - A Deployment of a Service you run: `url`.
|
|
39
|
+
*
|
|
40
|
+
* Ordered by Project, then Owner Team; within a Team, Elements, then
|
|
41
|
+
* Relationships, then Deployments, each in Bundle order. A Gap names its
|
|
42
|
+
* Project by the item's id (a Relationship by its consumer's, a Deployment by
|
|
43
|
+
* its Service's) and its Owner as the item's effective Owner. Gaps are never
|
|
44
|
+
* part of `check`: a gap is incompleteness, not an error.
|
|
45
|
+
*/
|
|
46
|
+
export declare function listGaps(bundle: Bundle, filter?: GapFilter): Gap[];
|
|
47
|
+
/**
|
|
48
|
+
* Gaps as Markdown: a `##` heading per Project, a `###` heading per Owner
|
|
49
|
+
* Team, and one line per item naming its empty fields. An Element is named
|
|
50
|
+
* by its kind and id, `service shop:web`, so `bundle` is the one the gaps
|
|
51
|
+
* came from. No gaps print nothing.
|
|
52
|
+
*/
|
|
53
|
+
export declare function formatGaps(gaps: Gap[], bundle: Pick<Bundle, "elements">): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { cmp } from "./query.js";
|
|
2
|
+
/** The fields a gap can name. `api-docs` and `deployments` are not fields but what the Model lacks. */
|
|
3
|
+
export const gapNames = ["description", "technology", "repository", "deployments", "api-docs", "channel", "url"];
|
|
4
|
+
const API_DOCS = /api|openapi|swagger/i;
|
|
5
|
+
const projectOf = (id) => id.split(":")[0];
|
|
6
|
+
/** A Service the organization runs: not External, and an application rather than a datastore or broker. */
|
|
7
|
+
const isApp = (e) => e?.kind === "service" && !e.external && e.type === "app";
|
|
8
|
+
/** Empty: unset, or set to nothing. */
|
|
9
|
+
const empty = (value) => value === null || value === undefined || value === "";
|
|
10
|
+
/**
|
|
11
|
+
* Every gap in the Model: the fields a reader would expect filled and finds
|
|
12
|
+
* empty, as the table under "What counts as a gap" in the fill-gaps guide
|
|
13
|
+
* sets them out.
|
|
14
|
+
*
|
|
15
|
+
* - Every Element: `description`.
|
|
16
|
+
* - A Service or Component: `technology`.
|
|
17
|
+
* - A Service you run (`type: app`, not External): `repository`.
|
|
18
|
+
* - A Service not External: `deployments` when it has none.
|
|
19
|
+
* - A Service you run that a non-Person calls: `api-docs` when no `links`
|
|
20
|
+
* label and no Deployment `endpoints` name matches api, openapi or swagger.
|
|
21
|
+
* - A Relationship: `description`, `technology`; an async one also `channel`.
|
|
22
|
+
* - A Deployment of a Service you run: `url`.
|
|
23
|
+
*
|
|
24
|
+
* Ordered by Project, then Owner Team; within a Team, Elements, then
|
|
25
|
+
* Relationships, then Deployments, each in Bundle order. A Gap names its
|
|
26
|
+
* Project by the item's id (a Relationship by its consumer's, a Deployment by
|
|
27
|
+
* its Service's) and its Owner as the item's effective Owner. Gaps are never
|
|
28
|
+
* part of `check`: a gap is incompleteness, not an error.
|
|
29
|
+
*/
|
|
30
|
+
export function listGaps(bundle, filter = {}) {
|
|
31
|
+
const byId = new Map(bundle.elements.map((e) => [e.id, e]));
|
|
32
|
+
const deploymentsOf = new Map();
|
|
33
|
+
for (const d of bundle.deployments)
|
|
34
|
+
deploymentsOf.set(d.service, [...(deploymentsOf.get(d.service) ?? []), d]);
|
|
35
|
+
const called = new Set(bundle.relationships.filter((r) => byId.get(r.from)?.kind !== "person").map((r) => r.to));
|
|
36
|
+
const gaps = [];
|
|
37
|
+
const add = (project, owner, kind, id, missing) => {
|
|
38
|
+
const names = missing.filter((m) => m !== false);
|
|
39
|
+
if (names.length)
|
|
40
|
+
gaps.push({ project, owner, item: { kind, id }, missing: names });
|
|
41
|
+
};
|
|
42
|
+
for (const e of bundle.elements) {
|
|
43
|
+
const runs = deploymentsOf.get(e.id) ?? [];
|
|
44
|
+
const app = isApp(e);
|
|
45
|
+
const documented = () => [...e.links.map((l) => l.label), ...runs.flatMap((d) => d.endpoints.map((p) => p.name))].some((name) => API_DOCS.test(name));
|
|
46
|
+
add(projectOf(e.id), e.owner, "element", e.id, [
|
|
47
|
+
empty(e.description) && "description",
|
|
48
|
+
(e.kind === "service" || e.kind === "component") && empty(e.technology) && "technology",
|
|
49
|
+
app && e.kind === "service" && empty(e.repository) && "repository",
|
|
50
|
+
e.kind === "service" && !e.external && runs.length === 0 && "deployments",
|
|
51
|
+
app && called.has(e.id) && !documented() && "api-docs",
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
for (const r of bundle.relationships) {
|
|
55
|
+
add(projectOf(r.from), byId.get(r.from)?.owner ?? "", "relationship", `${r.from} -> ${r.to}`, [
|
|
56
|
+
empty(r.description) && "description",
|
|
57
|
+
empty(r.technology) && "technology",
|
|
58
|
+
r.interaction === "async" && empty(r.channel) && "channel",
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
for (const d of bundle.deployments) {
|
|
62
|
+
if (!isApp(byId.get(d.service)))
|
|
63
|
+
continue;
|
|
64
|
+
add(projectOf(d.service), d.owner, "deployment", `${d.service} in ${d.environment} on ${d.target}`, [empty(d.url) && "url"]);
|
|
65
|
+
}
|
|
66
|
+
// A stable sort keeps each Team's items in the order above.
|
|
67
|
+
return gaps
|
|
68
|
+
.filter((g) => (filter.project === undefined || g.project === filter.project) && (filter.owner === undefined || g.owner === filter.owner))
|
|
69
|
+
.sort((a, b) => cmp(a.project, b.project) || cmp(a.owner, b.owner));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gaps as Markdown: a `##` heading per Project, a `###` heading per Owner
|
|
73
|
+
* Team, and one line per item naming its empty fields. An Element is named
|
|
74
|
+
* by its kind and id, `service shop:web`, so `bundle` is the one the gaps
|
|
75
|
+
* came from. No gaps print nothing.
|
|
76
|
+
*/
|
|
77
|
+
export function formatGaps(gaps, bundle) {
|
|
78
|
+
const kindOf = new Map(bundle.elements.map((e) => [e.id, e.kind]));
|
|
79
|
+
const lines = [];
|
|
80
|
+
let project;
|
|
81
|
+
let owner;
|
|
82
|
+
for (const g of gaps) {
|
|
83
|
+
if (g.project !== project) {
|
|
84
|
+
lines.push(`## ${g.project}`);
|
|
85
|
+
project = g.project;
|
|
86
|
+
owner = undefined;
|
|
87
|
+
}
|
|
88
|
+
if (g.owner !== owner) {
|
|
89
|
+
lines.push(`### ${g.owner}`);
|
|
90
|
+
owner = g.owner;
|
|
91
|
+
}
|
|
92
|
+
const name = g.item.kind === "element" ? `${kindOf.get(g.item.id) ?? "element"} ${g.item.id}` : `${g.item.kind} ${g.item.id}`;
|
|
93
|
+
lines.push(`- ${name}: ${g.missing.join(", ")}`);
|
|
94
|
+
}
|
|
95
|
+
return lines.length ? lines.join("\n") + "\n" : "";
|
|
96
|
+
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { listAdrs, adrsFor, type ListAdrsOptions, type ListedAdr } from "./adrs.
|
|
|
15
15
|
export { diff, countChanges, changedIds, changeKinds, type Change, type ChangeKind, type ChangeType, type ChangeItem, type ChangeCounts } from "./diff.ts";
|
|
16
16
|
export { unionBundle } from "./compare.ts";
|
|
17
17
|
export { resolveScope, scopeMatcher, filterChanges, type HistoryScope, type ScopeResolution } from "./history-scope.ts";
|
|
18
|
+
export { listGaps, formatGaps, gapNames, type Gap, type GapName, type GapItemKind, type GapFilter } from "./gaps.ts";
|
package/dist/core/index.js
CHANGED
|
@@ -13,3 +13,4 @@ export { listAdrs, adrsFor } from "./adrs.js";
|
|
|
13
13
|
export { diff, countChanges, changedIds, changeKinds } from "./diff.js";
|
|
14
14
|
export { unionBundle } from "./compare.js";
|
|
15
15
|
export { resolveScope, scopeMatcher, filterChanges } from "./history-scope.js";
|
|
16
|
+
export { listGaps, formatGaps, gapNames } from "./gaps.js";
|
package/dist/core/load.js
CHANGED
|
@@ -304,6 +304,8 @@ function toBundle(ws, options) {
|
|
|
304
304
|
const source = (l) => ({ file: l.file.path, line: l.line });
|
|
305
305
|
const str = (v) => (typeof v === "string" ? v : null);
|
|
306
306
|
const links = (v) => Array.isArray(v) ? v.map(asRecord).map((l) => ({ label: String(l.label ?? ""), url: String(l.url ?? "") })) : [];
|
|
307
|
+
// Scalars only, as strings; a nested value is a schema finding and is left out here.
|
|
308
|
+
const metadata = (v) => Object.fromEntries(Object.entries(asRecord(v)).flatMap(([k, x]) => (["string", "number", "boolean"].includes(typeof x) ? [[k, String(x)]] : [])));
|
|
307
309
|
const byId = (a, b) => cmp(a.id, b.id);
|
|
308
310
|
const projects = ws.projects.filter((p) => p.id !== undefined && !p.duplicateOf);
|
|
309
311
|
const elements = ws.elements
|
|
@@ -318,19 +320,21 @@ function toBundle(ws, options) {
|
|
|
318
320
|
owner: str(d.owner) ?? e.project.owner ?? "",
|
|
319
321
|
tags: Array.isArray(d.tags) ? d.tags.map(String) : [],
|
|
320
322
|
links: links(d.links),
|
|
323
|
+
metadata: metadata(d.metadata),
|
|
321
324
|
source: source(e),
|
|
322
325
|
};
|
|
323
326
|
const external = d.external === true;
|
|
324
327
|
const technology = str(d.technology);
|
|
328
|
+
const repository = str(d.repository);
|
|
325
329
|
switch (e.kind) {
|
|
326
330
|
case "person":
|
|
327
331
|
return { ...common, kind: e.kind };
|
|
328
332
|
case "system":
|
|
329
|
-
return { ...common, kind: e.kind, external };
|
|
333
|
+
return { ...common, kind: e.kind, external, repository };
|
|
330
334
|
case "service":
|
|
331
|
-
return { ...common, kind: e.kind, type: ["app", "datastore", "broker"].find((t) => t === d.type) ?? "app", technology, external };
|
|
335
|
+
return { ...common, kind: e.kind, type: ["app", "datastore", "broker"].find((t) => t === d.type) ?? "app", technology, external, repository };
|
|
332
336
|
case "component":
|
|
333
|
-
return { ...common, kind: e.kind, technology };
|
|
337
|
+
return { ...common, kind: e.kind, technology, repository };
|
|
334
338
|
}
|
|
335
339
|
});
|
|
336
340
|
const inBundle = (p) => p.id !== undefined && !p.duplicateOf;
|
package/dist/guide/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/** The
|
|
2
|
-
export declare const SKILL_NAME = "archidocs-authoring";
|
|
3
|
-
/** The guide's topics, in the order they are listed. `rules` is generated from the rule registry. */
|
|
1
|
+
/** The authoring guide's topics, in the order they are listed. `rules` is generated from the rule registry. */
|
|
4
2
|
export declare const topics: readonly [{
|
|
5
3
|
readonly id: "bootstrap";
|
|
6
4
|
readonly summary: "Declare an existing codebase's Services, Relationships and Deployments in one pass, from an approved inventory.";
|
|
@@ -22,6 +20,9 @@ export declare const topics: readonly [{
|
|
|
22
20
|
}, {
|
|
23
21
|
readonly id: "propose-adr";
|
|
24
22
|
readonly summary: "Propose an ADR linked to the Elements and Views it affects.";
|
|
23
|
+
}, {
|
|
24
|
+
readonly id: "fill-gaps";
|
|
25
|
+
readonly summary: "Interview the user about the fields the Model leaves empty, proposing each value from evidence in the code and writing it as it is confirmed.";
|
|
25
26
|
}, {
|
|
26
27
|
readonly id: "change";
|
|
27
28
|
readonly summary: "Rename, move or remove, working through refused removals by their references.";
|
|
@@ -30,9 +31,67 @@ export declare const topics: readonly [{
|
|
|
30
31
|
readonly summary: "Every `check` rule id: what it means, a failing example and the fix.";
|
|
31
32
|
}];
|
|
32
33
|
export type TopicId = (typeof topics)[number]["id"];
|
|
34
|
+
/** A skill's topic: a reference file under its guide folder's `topics/`, or a generated one. */
|
|
35
|
+
export interface Topic {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly summary: string;
|
|
38
|
+
}
|
|
39
|
+
/** One agent skill: the stub `init` installs, and the guide `get_guide` serves. */
|
|
40
|
+
export interface Skill {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
/** The stub's frontmatter `name`: `archidocs-<id>`, since `.agents/skills/` has no namespace. */
|
|
43
|
+
readonly name: string;
|
|
44
|
+
/** The stub's frontmatter `description`, which decides when the skill fires. */
|
|
45
|
+
readonly description: string;
|
|
46
|
+
/** The folder under `guide/` that holds its SKILL.md (and `topics/`), with a trailing slash; `""` for authoring. */
|
|
47
|
+
readonly dir: string;
|
|
48
|
+
readonly topics?: readonly Topic[];
|
|
49
|
+
}
|
|
50
|
+
/** Every skill, authoring first. */
|
|
51
|
+
export declare const skills: readonly [{
|
|
52
|
+
readonly id: "authoring";
|
|
53
|
+
readonly name: "archidocs-authoring";
|
|
54
|
+
readonly description: "Edit the Archidocs architecture Model. Use when bootstrapping a Project from code, adding or changing Services, Relationships, Deployments or Views, proposing an ADR, or finding and filling documentation gaps.";
|
|
55
|
+
readonly dir: "";
|
|
56
|
+
readonly topics: readonly [{
|
|
57
|
+
readonly id: "bootstrap";
|
|
58
|
+
readonly summary: "Declare an existing codebase's Services, Relationships and Deployments in one pass, from an approved inventory.";
|
|
59
|
+
}, {
|
|
60
|
+
readonly id: "add-service";
|
|
61
|
+
readonly summary: "Add one Service with its Components, Relationships and Deployments.";
|
|
62
|
+
}, {
|
|
63
|
+
readonly id: "relationships";
|
|
64
|
+
readonly summary: "Declare a dependency, including async ones through a broker (`via`, `channel`) and cross-Project ones.";
|
|
65
|
+
}, {
|
|
66
|
+
readonly id: "deployments";
|
|
67
|
+
readonly summary: "Add Deployment Targets and Deployments, with their URLs, per Environment.";
|
|
68
|
+
}, {
|
|
69
|
+
readonly id: "dynamic-view";
|
|
70
|
+
readonly summary: "Draft a scenario as Steps over existing Relationships, adding missing ones.";
|
|
71
|
+
}, {
|
|
72
|
+
readonly id: "saved-view";
|
|
73
|
+
readonly summary: "Save a structural or Deployment View with selectors and a Lens.";
|
|
74
|
+
}, {
|
|
75
|
+
readonly id: "propose-adr";
|
|
76
|
+
readonly summary: "Propose an ADR linked to the Elements and Views it affects.";
|
|
77
|
+
}, {
|
|
78
|
+
readonly id: "fill-gaps";
|
|
79
|
+
readonly summary: "Interview the user about the fields the Model leaves empty, proposing each value from evidence in the code and writing it as it is confirmed.";
|
|
80
|
+
}, {
|
|
81
|
+
readonly id: "change";
|
|
82
|
+
readonly summary: "Rename, move or remove, working through refused removals by their references.";
|
|
83
|
+
}, {
|
|
84
|
+
readonly id: "rules";
|
|
85
|
+
readonly summary: "Every `check` rule id: what it means, a failing example and the fix.";
|
|
86
|
+
}];
|
|
87
|
+
}];
|
|
88
|
+
export type SkillId = (typeof skills)[number]["id"];
|
|
89
|
+
/** The authoring skill's name, as its stub and the full SKILL.md both declare it. */
|
|
90
|
+
export declare const SKILL_NAME: "archidocs-authoring";
|
|
33
91
|
export type GuideResult = {
|
|
34
92
|
ok: true;
|
|
35
|
-
|
|
93
|
+
skill: string;
|
|
94
|
+
topic: string | null;
|
|
36
95
|
text: string;
|
|
37
96
|
} | {
|
|
38
97
|
ok: false;
|
|
@@ -40,15 +99,19 @@ export type GuideResult = {
|
|
|
40
99
|
suggestion?: string;
|
|
41
100
|
};
|
|
42
101
|
/**
|
|
43
|
-
*
|
|
44
|
-
* topic, SKILL.md followed by
|
|
45
|
-
* reference file.
|
|
102
|
+
* A skill's guide as `get_guide` and `archidocs guide --skill` serve it: with
|
|
103
|
+
* no topic, its SKILL.md, followed by its list of topics if it has any; with
|
|
104
|
+
* one, that topic's reference file. An unknown skill names the closest one.
|
|
46
105
|
*/
|
|
47
|
-
export declare function
|
|
106
|
+
export declare function guide(skill: string, topic?: string): Promise<GuideResult>;
|
|
107
|
+
/** One skill's guide, for `guide` once the skill is found. */
|
|
108
|
+
export declare function skillGuide(skill: Skill, topic?: string): Promise<GuideResult>;
|
|
109
|
+
/** The authoring guide, as `get_authoring_guide` and `archidocs guide` without `--skill` serve it. */
|
|
110
|
+
export declare const authoringGuide: (topic?: string) => Promise<GuideResult>;
|
|
48
111
|
/**
|
|
49
|
-
* The thin SKILL.md that `archidocs init` installs in a repo
|
|
50
|
-
* command that runs archidocs there (`runner`, such as `npx
|
|
51
|
-
* only points at the served guide, so it never goes stale, and
|
|
52
|
-
* portable frontmatter fields.
|
|
112
|
+
* The thin SKILL.md that `archidocs init` installs in a repo for one skill,
|
|
113
|
+
* naming the command that runs archidocs there (`runner`, such as `npx
|
|
114
|
+
* archidocs`). It only points at the served guide, so it never goes stale, and
|
|
115
|
+
* uses only the portable frontmatter fields.
|
|
53
116
|
*/
|
|
54
|
-
export declare
|
|
117
|
+
export declare function skillStub(id: SkillId, runner: string): string;
|