archidocs 1.4.0-beta.3 → 1.4.0-beta.5
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/guide/index.d.ts +78 -13
- package/dist/guide/index.js +65 -26
- package/dist/mcp/server.js +58 -15
- package/guide/SKILL.md +1 -1
- package/guide/describe/SKILL.md +111 -0
- package/guide/topics/relationships.md +24 -0
- package/package.json +1 -1
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/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.";
|
|
@@ -33,9 +31,72 @@ export declare const topics: readonly [{
|
|
|
33
31
|
readonly summary: "Every `check` rule id: what it means, a failing example and the fix.";
|
|
34
32
|
}];
|
|
35
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
|
+
readonly id: "describe";
|
|
89
|
+
readonly name: "archidocs-describe";
|
|
90
|
+
readonly description: "Build the Archidocs Model from the user's own explanation of their architecture, iteratively, with no code needed. Use when the user describes how their systems fit together in prose, wants to talk through or sketch an architecture, or is documenting something whose code isn't available.";
|
|
91
|
+
readonly dir: "describe/";
|
|
92
|
+
}];
|
|
93
|
+
export type SkillId = (typeof skills)[number]["id"];
|
|
94
|
+
/** The authoring skill's name, as its stub and the full SKILL.md both declare it. */
|
|
95
|
+
export declare const SKILL_NAME: "archidocs-authoring";
|
|
36
96
|
export type GuideResult = {
|
|
37
97
|
ok: true;
|
|
38
|
-
|
|
98
|
+
skill: string;
|
|
99
|
+
topic: string | null;
|
|
39
100
|
text: string;
|
|
40
101
|
} | {
|
|
41
102
|
ok: false;
|
|
@@ -43,15 +104,19 @@ export type GuideResult = {
|
|
|
43
104
|
suggestion?: string;
|
|
44
105
|
};
|
|
45
106
|
/**
|
|
46
|
-
*
|
|
47
|
-
* topic, SKILL.md followed by
|
|
48
|
-
* reference file.
|
|
107
|
+
* A skill's guide as `get_guide` and `archidocs guide --skill` serve it: with
|
|
108
|
+
* no topic, its SKILL.md, followed by its list of topics if it has any; with
|
|
109
|
+
* one, that topic's reference file. An unknown skill names the closest one.
|
|
49
110
|
*/
|
|
50
|
-
export declare function
|
|
111
|
+
export declare function guide(skill: string, topic?: string): Promise<GuideResult>;
|
|
112
|
+
/** One skill's guide, for `guide` once the skill is found. */
|
|
113
|
+
export declare function skillGuide(skill: Skill, topic?: string): Promise<GuideResult>;
|
|
114
|
+
/** The authoring guide, as `get_authoring_guide` and `archidocs guide` without `--skill` serve it. */
|
|
115
|
+
export declare const authoringGuide: (topic?: string) => Promise<GuideResult>;
|
|
51
116
|
/**
|
|
52
|
-
* The thin SKILL.md that `archidocs init` installs in a repo
|
|
53
|
-
* command that runs archidocs there (`runner`, such as `npx
|
|
54
|
-
* only points at the served guide, so it never goes stale, and
|
|
55
|
-
* portable frontmatter fields.
|
|
117
|
+
* The thin SKILL.md that `archidocs init` installs in a repo for one skill,
|
|
118
|
+
* naming the command that runs archidocs there (`runner`, such as `npx
|
|
119
|
+
* archidocs`). It only points at the served guide, so it never goes stale, and
|
|
120
|
+
* uses only the portable frontmatter fields.
|
|
56
121
|
*/
|
|
57
|
-
export declare
|
|
122
|
+
export declare function skillStub(id: SkillId, runner: string): string;
|
package/dist/guide/index.js
CHANGED
|
@@ -2,14 +2,12 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { ruleCatalogue } from "../core/catalogue.js";
|
|
3
3
|
import { suggest } from "../core/suggest.js";
|
|
4
4
|
/**
|
|
5
|
-
* The
|
|
5
|
+
* The skills' guides, as Markdown shipped beside the code in `guide/`. The
|
|
6
6
|
* module runs from dist/guide/ when installed and from src/guide/ in this
|
|
7
7
|
* repo; both sit two levels below the package root.
|
|
8
8
|
*/
|
|
9
9
|
const GUIDE_DIR = new URL("../../guide/", import.meta.url);
|
|
10
|
-
/** The
|
|
11
|
-
export const SKILL_NAME = "archidocs-authoring";
|
|
12
|
-
/** The guide's topics, in the order they are listed. `rules` is generated from the rule registry. */
|
|
10
|
+
/** The authoring guide's topics, in the order they are listed. `rules` is generated from the rule registry. */
|
|
13
11
|
export const topics = [
|
|
14
12
|
{ id: "bootstrap", summary: "Declare an existing codebase's Services, Relationships and Deployments in one pass, from an approved inventory." },
|
|
15
13
|
{ id: "add-service", summary: "Add one Service with its Components, Relationships and Deployments." },
|
|
@@ -22,38 +20,79 @@ export const topics = [
|
|
|
22
20
|
{ id: "change", summary: "Rename, move or remove, working through refused removals by their references." },
|
|
23
21
|
{ id: "rules", summary: "Every `check` rule id: what it means, a failing example and the fix." },
|
|
24
22
|
];
|
|
23
|
+
/** Every skill, authoring first. */
|
|
24
|
+
export const skills = [
|
|
25
|
+
{
|
|
26
|
+
id: "authoring",
|
|
27
|
+
name: "archidocs-authoring",
|
|
28
|
+
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.",
|
|
29
|
+
dir: "",
|
|
30
|
+
topics,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "describe",
|
|
34
|
+
name: "archidocs-describe",
|
|
35
|
+
description: "Build the Archidocs Model from the user's own explanation of their architecture, iteratively, with no code needed. Use when the user describes how their systems fit together in prose, wants to talk through or sketch an architecture, or is documenting something whose code isn't available.",
|
|
36
|
+
dir: "describe/",
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
/** The authoring skill's name, as its stub and the full SKILL.md both declare it. */
|
|
40
|
+
export const SKILL_NAME = skills[0].name;
|
|
25
41
|
/**
|
|
26
|
-
*
|
|
27
|
-
* topic, SKILL.md followed by
|
|
28
|
-
* reference file.
|
|
42
|
+
* A skill's guide as `get_guide` and `archidocs guide --skill` serve it: with
|
|
43
|
+
* no topic, its SKILL.md, followed by its list of topics if it has any; with
|
|
44
|
+
* one, that topic's reference file. An unknown skill names the closest one.
|
|
29
45
|
*/
|
|
30
|
-
export async function
|
|
46
|
+
export async function guide(skill, topic) {
|
|
47
|
+
const found = skills.find((s) => s.id === skill);
|
|
48
|
+
if (!found) {
|
|
49
|
+
const ids = skills.map((s) => s.id);
|
|
50
|
+
const suggestion = suggest(skill, ids);
|
|
51
|
+
return { ok: false, message: `Unknown skill "${skill}"${suggestion ? `; did you mean "${suggestion}"?` : ""} Skills: ${ids.join(", ")}.`, ...(suggestion ? { suggestion } : {}) };
|
|
52
|
+
}
|
|
53
|
+
return skillGuide(found, topic);
|
|
54
|
+
}
|
|
55
|
+
/** One skill's guide, for `guide` once the skill is found. */
|
|
56
|
+
export async function skillGuide(skill, topic) {
|
|
57
|
+
const own = skill.topics ?? [];
|
|
31
58
|
if (topic === undefined) {
|
|
32
|
-
const
|
|
33
|
-
const list = ["## Topics", "", ...
|
|
34
|
-
return { ok: true, topic: null, text: `${
|
|
59
|
+
const text = (await readFile(new URL(`${skill.dir}SKILL.md`, GUIDE_DIR), "utf8")).trimEnd();
|
|
60
|
+
const list = own.length ? ["", "", "## Topics", "", ...own.map((t) => `- \`${t.id}\`: ${t.summary}`)].join("\n") : "";
|
|
61
|
+
return { ok: true, skill: skill.id, topic: null, text: `${text}${list}\n` };
|
|
35
62
|
}
|
|
36
|
-
|
|
63
|
+
if (!own.length)
|
|
64
|
+
return { ok: false, message: `The skill "${skill.id}" has no topics; load it with no topic.` };
|
|
65
|
+
const found = own.find((t) => t.id === topic);
|
|
37
66
|
if (!found) {
|
|
38
|
-
const suggestion = suggest(topic,
|
|
39
|
-
return { ok: false, message: `Unknown topic "${topic}"${suggestion ? `; did you mean "${suggestion}"?` : ""} Topics: ${
|
|
67
|
+
const suggestion = suggest(topic, own.map((t) => t.id));
|
|
68
|
+
return { ok: false, message: `Unknown topic "${topic}"${suggestion ? `; did you mean "${suggestion}"?` : ""} Topics: ${own.map((t) => t.id).join(", ")}.`, ...(suggestion ? { suggestion } : {}) };
|
|
40
69
|
}
|
|
41
|
-
if (found.id === "rules")
|
|
42
|
-
return { ok: true, topic: found.id, text: ruleCatalogue() };
|
|
43
|
-
return { ok: true, topic: found.id, text: await readFile(new URL(
|
|
70
|
+
if (skill.id === "authoring" && found.id === "rules")
|
|
71
|
+
return { ok: true, skill: skill.id, topic: found.id, text: ruleCatalogue() };
|
|
72
|
+
return { ok: true, skill: skill.id, topic: found.id, text: await readFile(new URL(`${skill.dir}topics/${found.id}.md`, GUIDE_DIR), "utf8") };
|
|
44
73
|
}
|
|
74
|
+
/** The authoring guide, as `get_authoring_guide` and `archidocs guide` without `--skill` serve it. */
|
|
75
|
+
export const authoringGuide = (topic) => guide("authoring", topic);
|
|
76
|
+
const titleOf = (id) => `Archidocs ${id.replaceAll("-", " ")}`;
|
|
45
77
|
/**
|
|
46
|
-
* The thin SKILL.md that `archidocs init` installs in a repo
|
|
47
|
-
* command that runs archidocs there (`runner`, such as `npx
|
|
48
|
-
* only points at the served guide, so it never goes stale, and
|
|
49
|
-
* portable frontmatter fields.
|
|
78
|
+
* The thin SKILL.md that `archidocs init` installs in a repo for one skill,
|
|
79
|
+
* naming the command that runs archidocs there (`runner`, such as `npx
|
|
80
|
+
* archidocs`). It only points at the served guide, so it never goes stale, and
|
|
81
|
+
* uses only the portable frontmatter fields.
|
|
50
82
|
*/
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
83
|
+
export function skillStub(id, runner) {
|
|
84
|
+
const skill = skills.find((s) => s.id === id);
|
|
85
|
+
const cli = (args) => `\`${runner} guide ${args}\``;
|
|
86
|
+
const load = skill.id === "authoring"
|
|
87
|
+
? `Before editing the Model, load the full guide: call \`get_guide("authoring")\` on the Archidocs MCP server (\`get_authoring_guide\` on a server older than \`get_guide\`), or run ${cli("--skill authoring")} when no Archidocs MCP server is connected. It lists the topics; load the one for the task with \`get_guide("authoring", topic)\` or ${cli("<topic> --skill authoring")}, and follow it.`
|
|
88
|
+
: `Before you start, load the full guide: call \`get_guide("${skill.id}")\` on the Archidocs MCP server, or run ${cli(`--skill ${skill.id}`)} when no Archidocs MCP server is connected, and follow it.`;
|
|
89
|
+
return `---
|
|
90
|
+
name: ${skill.name}
|
|
91
|
+
description: ${skill.description}
|
|
54
92
|
---
|
|
55
93
|
|
|
56
|
-
#
|
|
94
|
+
# ${titleOf(skill.id)}
|
|
57
95
|
|
|
58
|
-
|
|
96
|
+
${load}${runner === "archidocs" ? "" : ` In this repo, run every \`archidocs\` command as \`${runner}\`.`}
|
|
59
97
|
`;
|
|
98
|
+
}
|
package/dist/mcp/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { getDeployments } from "../core/deployments.js";
|
|
4
4
|
import { withDocs } from "../core/rules.js";
|
|
5
5
|
import { search } from "../core/search.js";
|
|
6
|
-
import { changeKinds, countChanges, deriveEdges, diff, filterChanges, findPaths, getImpact, levelOf, listOwned, resolveScope, scopeMatcher, } from "../core/index.js";
|
|
6
|
+
import { changeKinds, countChanges, deriveEdges, diff, filterChanges, findPaths, formatGaps, gapNames, getImpact, listGaps, levelOf, listOwned, resolveScope, scopeMatcher, } from "../core/index.js";
|
|
7
7
|
import { suggest } from "../core/suggest.js";
|
|
8
8
|
import { describeLens, isScaled, listViews, resolveView } from "../core/views/index.js";
|
|
9
9
|
import { listAdrs } from "../core/adrs.js";
|
|
@@ -13,7 +13,7 @@ import { POINT_GRAMMAR, touching } from "../revisions/index.js";
|
|
|
13
13
|
import { pastOf } from "./history.js";
|
|
14
14
|
import { registerWriteTools } from "./writes.js";
|
|
15
15
|
import { callLine } from "./announce.js";
|
|
16
|
-
import { authoringGuide, topics } from "../guide/index.js";
|
|
16
|
+
import { authoringGuide, guide as skillGuide, skills, topics } from "../guide/index.js";
|
|
17
17
|
const ok = (data, text) => ({ ok: true, data, text });
|
|
18
18
|
const fail = (code, message, suggestions) => ({ ok: false, code, message, ...(suggestions ? { suggestions } : {}) });
|
|
19
19
|
/**
|
|
@@ -421,6 +421,30 @@ export function createServer(options) {
|
|
|
421
421
|
]),
|
|
422
422
|
].join("\n"));
|
|
423
423
|
});
|
|
424
|
+
tool("list_gaps", {
|
|
425
|
+
title: "List gaps",
|
|
426
|
+
description: "What the Model leaves empty, grouped by Project and Owner Team: an Element's `description`; a Service's or Component's `technology`; for a Service you run (`type: app`, not external) its `repository`, its `deployments` when it has none (any non-external Service), and `api-docs` when a non-Person calls it and no `links` label or Deployment `endpoints` name mentions api, openapi or swagger; a Relationship's `description` and `technology`, and an async one's `channel`; a Deployment `url` of a Service you run. Tags, links, metadata and Owners are never gaps. Use it to find what to fill.",
|
|
427
|
+
input: z.object({
|
|
428
|
+
project: z.string().min(1).optional().describe("Only this Project's gaps"),
|
|
429
|
+
owner: z.string().min(1).optional().describe("Only the gaps of items this Team owns"),
|
|
430
|
+
}),
|
|
431
|
+
output: z.object({
|
|
432
|
+
total: z.number(),
|
|
433
|
+
gaps: z.array(z.object({
|
|
434
|
+
project: z.string(),
|
|
435
|
+
owner: z.string(),
|
|
436
|
+
item: z.object({ kind: z.enum(["element", "relationship", "deployment"]), id: z.string() }),
|
|
437
|
+
missing: z.array(z.enum(gapNames)),
|
|
438
|
+
})),
|
|
439
|
+
}),
|
|
440
|
+
}, ({ project, owner }, { bundle }) => {
|
|
441
|
+
if (project !== undefined && !bundle.projects.some((p) => p.id === project))
|
|
442
|
+
return notFound("Project", project, bundle.projects.map((p) => p.id));
|
|
443
|
+
if (owner !== undefined && !bundle.teams.some((t) => t.id === owner))
|
|
444
|
+
return notFound("Team", owner, bundle.teams.map((t) => t.id));
|
|
445
|
+
const gaps = listGaps(bundle, { ...(project === undefined ? {} : { project }), ...(owner === undefined ? {} : { owner }) });
|
|
446
|
+
return ok({ total: gaps.length, gaps }, gaps.length ? `${count(gaps.length, "item")} with gaps.\n${formatGaps(gaps, bundle)}` : "No gaps.");
|
|
447
|
+
});
|
|
424
448
|
tool("list_owned", {
|
|
425
449
|
title: "List owned",
|
|
426
450
|
description: "The Elements and Deployment Targets a Team owns, grouped by kind, each with counts of the other Teams upstream (depending on it) and downstream (it depends on). An Element is listed under its own Owner, whoever owns its parent.",
|
|
@@ -636,27 +660,46 @@ export function createServer(options) {
|
|
|
636
660
|
...issues.map((i) => `- ${i.file}:${i.line} ${i.severity} ${i.rule}: ${i.message}`),
|
|
637
661
|
].join("\n"));
|
|
638
662
|
});
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
663
|
+
// Taken like every read tool's, but the guides ship with this Archidocs, so they are the same at every point.
|
|
664
|
+
const topicArg = (of) => z.string().min(1).optional().describe(`One topic's reference file${of}`);
|
|
665
|
+
const GuideOutput = z.object({ topic: z.string().nullable(), topics: z.array(z.object({ id: z.string(), summary: z.string() })), text: z.string() });
|
|
666
|
+
/** A guide as a tool result: the ids of what was served, the skill's topics and the text. */
|
|
667
|
+
const guideResult = (served, extra) => {
|
|
668
|
+
if (!served.ok)
|
|
669
|
+
return toResult(fail("not_found", served.message, served.suggestion ? [served.suggestion] : undefined));
|
|
670
|
+
return toResult(ok({ ...extra(served), topic: served.topic, topics: [...(skills.find((s) => s.id === served.skill)?.topics ?? [])].map((t) => ({ ...t })), text: served.text }, served.text));
|
|
671
|
+
};
|
|
672
|
+
const GetGuideInput = z.object({
|
|
673
|
+
skill: z.string().min(1).describe(`The skill: ${skills.map((s) => s.id).join(", ")}`),
|
|
674
|
+
topic: topicArg(`, for a skill that has topics; authoring's are ${topics.map((t) => t.id).join(", ")}`),
|
|
642
675
|
at: At.optional(),
|
|
643
676
|
});
|
|
644
|
-
server.registerTool("
|
|
645
|
-
title: "
|
|
646
|
-
description: "
|
|
647
|
-
inputSchema: advertise(
|
|
648
|
-
outputSchema:
|
|
677
|
+
server.registerTool("get_guide", {
|
|
678
|
+
title: "Skill guide",
|
|
679
|
+
description: "Load an Archidocs agent skill's full guide, from this version. With no topic: the skill's SKILL.md, and for `authoring` (the Model, the edit loop) its list of topics. With a topic: that flow's reference file; authoring's `rules` is the catalog of every check rule. Load `authoring` before writing.",
|
|
680
|
+
inputSchema: advertise(GetGuideInput),
|
|
681
|
+
outputSchema: GuideOutput.extend({ skill: z.string() }),
|
|
649
682
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
650
683
|
},
|
|
651
|
-
// The
|
|
684
|
+
// The guides ship with this version, so they answer whatever the state of the source.
|
|
652
685
|
async (raw) => {
|
|
686
|
+
const args = GetGuideInput.safeParse(raw ?? {});
|
|
687
|
+
if (!args.success)
|
|
688
|
+
return toResult(fail("invalid_input", z.prettifyError(args.error)));
|
|
689
|
+
return guideResult(await skillGuide(args.data.skill, args.data.topic), (g) => ({ skill: g.skill }));
|
|
690
|
+
});
|
|
691
|
+
const GuideInput = z.object({ topic: topicArg(`: ${topics.map((t) => t.id).join(", ")}`), at: At.optional() });
|
|
692
|
+
server.registerTool("get_authoring_guide", {
|
|
693
|
+
title: "Authoring guide (deprecated)",
|
|
694
|
+
description: "Deprecated in favour of `get_guide`, which serves every skill: this returns the same as `get_guide(\"authoring\", topic)`. With no topic: the archidocs-authoring skill (the Model, the edit loop) and its list of topics. With a topic: that flow's reference file; `rules` is the catalog of every check rule.",
|
|
695
|
+
inputSchema: advertise(GuideInput),
|
|
696
|
+
outputSchema: GuideOutput,
|
|
697
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
698
|
+
}, async (raw) => {
|
|
653
699
|
const args = GuideInput.safeParse(raw ?? {});
|
|
654
700
|
if (!args.success)
|
|
655
701
|
return toResult(fail("invalid_input", z.prettifyError(args.error)));
|
|
656
|
-
|
|
657
|
-
if (!guide.ok)
|
|
658
|
-
return toResult(fail("not_found", guide.message, guide.suggestion ? [guide.suggestion] : undefined));
|
|
659
|
-
return toResult(ok({ topic: guide.topic, topics: topics.map((t) => ({ ...t })), text: guide.text }, guide.text));
|
|
702
|
+
return guideResult(await authoringGuide(args.data.topic), () => ({}));
|
|
660
703
|
});
|
|
661
704
|
registerWriteTools(server, source, writesAllowed ? undefined : readOnlyReason, logged);
|
|
662
705
|
return server;
|
package/guide/SKILL.md
CHANGED
|
@@ -7,7 +7,7 @@ description: Edit the Archidocs architecture Model. Use when bootstrapping a Pro
|
|
|
7
7
|
|
|
8
8
|
The Model is YAML in a Workspace: `workspace.yaml` defines Teams and Environments, and each Project folder (marked by `project.yaml`) declares its Elements, Relationships, Deployment Targets, Deployments and Saved Views. You need two things: code you can read, and a writable Workspace checkout served by `archidocs mcp --workspace <path>`.
|
|
9
9
|
|
|
10
|
-
Load the topic for the task before you write: `
|
|
10
|
+
Load the topic for the task before you write: `get_guide("authoring", topic)`, or `archidocs guide <topic>` without MCP.
|
|
11
11
|
|
|
12
12
|
The CLI commands in this guide, such as `archidocs check`, assume a global install. When there is none, run them the way the repo's AGENTS.md says, such as `npx archidocs check`.
|
|
13
13
|
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: archidocs-describe
|
|
3
|
+
description: Build the Archidocs Model from the user's own explanation of their architecture, iteratively, with no code needed. Use when the user describes how their systems fit together in prose, wants to talk through or sketch an architecture, or is documenting something whose code isn't available.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Archidocs describe
|
|
7
|
+
|
|
8
|
+
Turn the user's explanation of their architecture into a Model, round by round. The user talks; you map what they said to Elements, Relationships, Deployment Targets and Deployments, play the whole draft back, and ask only what is ambiguous.
|
|
9
|
+
|
|
10
|
+
This skill writes the Model, so load `authoring` first: `get_guide("authoring")`, or `archidocs guide --skill authoring` without MCP. It holds the Model's rules and the edit loop this guide follows.
|
|
11
|
+
|
|
12
|
+
## Input
|
|
13
|
+
|
|
14
|
+
Use only what the user says. Never read code, even when it is in reach: the user is describing the architecture as they understand it, and that is what this skill records. Code is for `fill-gaps`, offered at the end.
|
|
15
|
+
|
|
16
|
+
Read the Model before the first round (`search_elements`, `list_teams`, `list_environments`), so a name the user mentions resolves to an Element that already exists instead of a duplicate.
|
|
17
|
+
|
|
18
|
+
## First round
|
|
19
|
+
|
|
20
|
+
Besides the round's own questions, ask once, in the first round only:
|
|
21
|
+
|
|
22
|
+
- **Project**: which Project this goes in. Propose one new Project, with an id and name drawn from the prose, unless an existing Project plainly fits.
|
|
23
|
+
- **Owner Team**: which Team owns it. Propose an existing Team if one fits; otherwise ask for the Team's name. Never make one up.
|
|
24
|
+
|
|
25
|
+
## Each round
|
|
26
|
+
|
|
27
|
+
1. **Map** the prose to the Model: Systems, Services, Components, Relationships (consumer `to` provider), Deployment Targets and Deployments. Keep every earlier answer; a round adds to the draft and corrects it, it never starts over.
|
|
28
|
+
2. **Play back the whole draft**, not only what changed, in two parts:
|
|
29
|
+
- an **outline**: each Element on one line with its id, kind and the fields the user gave (`technology`, `type`, `external`, parent), nested as it will be in YAML; then the Deployment Targets and Deployments;
|
|
30
|
+
- a **flow**: one line per path through the draft, arrows pointing from consumer to provider as Relationships do, such as `web → apigee → api → bigquery`. A provider with several consumers can be drawn with a reverse arrow on the same line: `api → bigquery ← etl`.
|
|
31
|
+
3. **Ask only the ambiguities**, as numbered questions, each with a proposed answer worded so "yes" accepts it. Don't ask what the user already said, and don't ask about fields they didn't mention: those stay gaps for `fill-gaps`. Keep a round to the questions that change the draft's shape, about five or fewer.
|
|
32
|
+
|
|
33
|
+
The user answers by number ("1 yes, 2 its own Service, 3 skip"), or keeps explaining. Fold both into the next round's draft.
|
|
34
|
+
|
|
35
|
+
## Mapping cues
|
|
36
|
+
|
|
37
|
+
| The user says | Map it to |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| A web app, an API, a worker | A Service, `technology` as named (`Next.js`). |
|
|
40
|
+
| A BFF (backend for frontend) | A Component of the web Service, or a Service of its own when it is deployed apart. Ask, proposing a Component. |
|
|
41
|
+
| A managed datastore (BigQuery, Cloud SQL, DynamoDB, S3) | A Service with `type: datastore` and `technology` as named. Ask whether it is `external`: propose not, when the organization owns the data in its own cloud account. |
|
|
42
|
+
| A broker or queue (Kafka, Pub/Sub, SQS) | A Service with `type: broker`; the Relationships through it follow authoring's `relationships` topic (`via`, `channel`). |
|
|
43
|
+
| A platform it runs on (Anthos, GKE, EKS, Cloud Run, a VM) | A Deployment Target with that `kind` (`kind: anthos`), and a Deployment of the Service on it once an Environment is known. |
|
|
44
|
+
| An ETL, a batch job, a cron job | A Service, with Relationships to what it reads and what it writes. |
|
|
45
|
+
| A black box | Always ask: run by a vendor, a System with `external: true`; or run inside the organization, a System with no Components, owned by the Team that runs it (asked, or left as a gap). The user's words about it go in `description`. |
|
|
46
|
+
| An API gateway or reverse proxy (Apigee, Kong, nginx) | A Service in the path, `technology` naming the product: `web → apigee → api`, owned by the Team that runs it. Mention the lighter option once: leave it out and write `HTTPS via Apigee` on the Relationship's `technology`. See authoring's `relationships` topic, "Gateways and proxies". |
|
|
47
|
+
|
|
48
|
+
## Never invent
|
|
49
|
+
|
|
50
|
+
- **Environments, URLs and Owners** come only from the user. A Deployment needs an Environment, so a named platform triggers one question: "Which Environments does this run in?". Until it is answered, draft the Deployment Target and leave the Deployments out.
|
|
51
|
+
- An Owner other than the Project's is set only when the user names the Team.
|
|
52
|
+
- Write what was said: `technology`, `type`, `external`, the platform's `kind`, and a `description` in the user's own words. Anything unsaid stays a gap.
|
|
53
|
+
|
|
54
|
+
## Writing
|
|
55
|
+
|
|
56
|
+
1. **Nothing is written until the user approves the first draft.** Approval covers the whole draft as played back; open questions they skipped stay out of it.
|
|
57
|
+
2. **First write**: follow authoring's `bootstrap` topic from step 5: `create_project` if the Project is new (`upsert_team` and `upsert_environment` first only for Teams and Environments the user named), then Systems, Services, Components (`upsert_element`), Deployment Targets (`upsert_target`), Deployments (`upsert_deployment`), then Relationships (`upsert_relationship`). Resolve refusals through the tools, as the edit loop says.
|
|
58
|
+
3. **Start the viewer**: after the first write, start `archidocs dev` in the background if you can, and give the user its URL. Otherwise print the command for them to run. Never wait on it.
|
|
59
|
+
4. **Each later round** writes its changes as soon as the user approves the round's draft, and shows the diffs.
|
|
60
|
+
|
|
61
|
+
## Cross-Project
|
|
62
|
+
|
|
63
|
+
When the prose clearly describes another Team's System ("the platform team runs Apigee for everyone"), propose it as its own Project owned by that Team, linked with `project:id` Relationships. If the user says to keep it all in one Project, do so, with `owner` set on those Elements when the Team was named.
|
|
64
|
+
|
|
65
|
+
## Finish
|
|
66
|
+
|
|
67
|
+
Finish as authoring's edit loop does: run `check`, then suggest a branch name, a PR title and a PR body listing what was written and the open gaps (fields left unsaid, Owners and Environments not given). Then offer `fill-gaps` (`get_guide("fill-gaps")`), which reads the code to propose the `technology`, `repository`, URLs and descriptions this conversation left open.
|
|
68
|
+
|
|
69
|
+
## Worked example
|
|
70
|
+
|
|
71
|
+
The user says:
|
|
72
|
+
|
|
73
|
+
> I have a next.js app that uses BFF to call an api that's running on anthos and is proxied through an apigee gateway. That API gets its data from BigQuery. The bigquery table is populated by an ETL from a black-boxed service
|
|
74
|
+
|
|
75
|
+
The Model has no Project for this yet. The first round plays back:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
Draft, Project `orders` (new)
|
|
79
|
+
|
|
80
|
+
Services
|
|
81
|
+
web Service technology: Next.js
|
|
82
|
+
bff Component (the BFF)
|
|
83
|
+
apigee Service technology: Apigee (API gateway)
|
|
84
|
+
api Service (the API)
|
|
85
|
+
bigquery Service, datastore technology: BigQuery
|
|
86
|
+
etl Service (the ETL)
|
|
87
|
+
source System (the black-boxed service)
|
|
88
|
+
|
|
89
|
+
Deployment Targets
|
|
90
|
+
anthos kind: anthos api runs here; no Deployments until Environments are known
|
|
91
|
+
|
|
92
|
+
Flow
|
|
93
|
+
web.bff → apigee → api → bigquery
|
|
94
|
+
bigquery ← etl → source
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
1. Project: put all of this in one new Project, `orders` ("Orders")?
|
|
99
|
+
2. Owner Team: which Team owns it? There is no Team in the Workspace that fits.
|
|
100
|
+
3. BFF: a Component of `web`, deployed with it? (Or its own Service, if it is deployed apart.)
|
|
101
|
+
4. Apigee: a Service in the path, `web → apigee → api`, owned by the Team that runs it?
|
|
102
|
+
(The lighter option leaves it out and writes `HTTPS via Apigee` on the Relationship.)
|
|
103
|
+
Who runs it: the same Team, or another (a platform Team, in its own Project)?
|
|
104
|
+
5. BigQuery: your own dataset in your Google Cloud project, so not `external`?
|
|
105
|
+
6. The black box: run by a vendor (`external: true`), or by a Team in the organization?
|
|
106
|
+
What does it hold or do, in a sentence?
|
|
107
|
+
7. ETL: does it pull from the black box (`etl → source`), as drawn?
|
|
108
|
+
8. Anthos: which Environments does the API run in (for example `dev` and `prod`)?
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Nothing is written yet. Say the user answers "1 yes, 2 checkout-team, 3 yes, 4 yes, platform-team runs it, 5 yes, 6 a vendor's CRM, 7 yes, 8 prod only". The second round plays back the full draft again: `apigee` proposed as a Service in a `platform` Project owned by `platform-team`, as Cross-Project above proposes, `source` as an External System described "A vendor's CRM", and a Deployment of `api` in `prod` on `anthos` with no `url`. Its only question is whether the `platform` Project is right, or to keep `apigee` in `orders` owned by `platform-team`. Once the user approves, write it, start `archidocs dev`, and carry on with whatever they explain next.
|
|
@@ -34,6 +34,30 @@ services:
|
|
|
34
34
|
|
|
35
35
|
Impact and path queries count the broker as a hop and as a dependency of both sides. An async Relationship with no broker (a webhook, a callback) leaves out `via`.
|
|
36
36
|
|
|
37
|
+
## Gateways and proxies
|
|
38
|
+
|
|
39
|
+
An API gateway or reverse proxy (Apigee, Kong, nginx) is a Service in the path by default, `technology` naming the product and `owner` the Team that runs it. The consumer points `to` the gateway, and the gateway `to` the API:
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
# web, in the shop Project
|
|
43
|
+
relationships:
|
|
44
|
+
- to: platform:apigee
|
|
45
|
+
description: Places orders through
|
|
46
|
+
technology: HTTPS
|
|
47
|
+
|
|
48
|
+
# apigee, in the platform Project
|
|
49
|
+
apigee:
|
|
50
|
+
name: API Gateway
|
|
51
|
+
technology: Apigee
|
|
52
|
+
owner: platform-team
|
|
53
|
+
relationships:
|
|
54
|
+
- to: shop:api
|
|
55
|
+
description: Routes order requests to
|
|
56
|
+
technology: HTTPS
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
When the gateway is shared infrastructure nobody needs to see, leave it out: `web` points `to` the API directly with `technology: HTTPS via Apigee`. Impact and paths then skip the hop. Either way, the gateway's URL is the API's consumer-facing Deployment `url`. See ADR 0005.
|
|
60
|
+
|
|
37
61
|
## Cross-Project
|
|
38
62
|
|
|
39
63
|
Declare only this Project's outbound Relationships. When the provider isn't in the Model, leave the Relationship out and tell the user it is a gap for the provider's Team; create Elements only in this Project. A provider outside the organization may be added here as an External Service.
|