archidocs 1.4.0-beta.1 → 1.4.0-beta.3
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/core/load.js +14 -4
- package/dist/core/rules.js +2 -2
- package/dist/core/views/deployment.d.ts +4 -0
- package/dist/core/views/deployment.js +15 -1
- package/dist/core/views/generated.d.ts +3 -1
- package/dist/core/views/generated.js +9 -2
- package/dist/core/views/index.d.ts +1 -0
- package/dist/core/views/index.js +1 -0
- package/dist/core/views/resolve.js +3 -3
- package/dist/core/views/save-as-view.d.ts +8 -3
- package/dist/core/views/save-as-view.js +16 -6
- package/dist/core/views/types.d.ts +9 -1
- package/dist/guide/index.d.ts +3 -0
- package/dist/guide/index.js +2 -1
- package/dist/mcp/server.js +10 -4
- package/dist/mcp/writes.js +4 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/layout.d.ts +3 -1
- package/dist/render/layout.js +6 -1
- package/dist/render/sequence-svg.js +2 -2
- package/dist/render/svg.d.ts +3 -1
- package/dist/render/svg.js +49 -11
- package/dist/render/tokens.d.ts +8 -0
- package/dist/render/tokens.js +12 -0
- package/dist/schema/bundle.d.ts +22 -0
- package/dist/schema/bundle.js +7 -3
- package/dist/schema/workspace.d.ts +52 -0
- package/dist/schema/workspace.js +29 -1
- package/dist/viewer/assets/index-BL2vQQ6T.css +1 -0
- package/dist/viewer/assets/index-Oy0Hpoqy.js +75 -0
- package/dist/viewer/assets/layout.worker-ueOYAv7N.js +63 -0
- package/dist/viewer/assets/rolldown-runtime-pP25SEvz.js +1 -0
- package/dist/viewer/assets/sequence-svg-DDwcPtpC.js +2 -0
- package/dist/viewer/assets/svg-Cboa7QX_.js +2 -0
- package/dist/viewer/assets/teams-N-WbqOXA.js +66 -0
- package/dist/viewer/index.html +4 -3
- package/dist/writer/document.js +22 -1
- package/guide/SKILL.md +3 -3
- package/guide/topics/add-service.md +2 -1
- package/guide/topics/deployments.md +17 -3
- package/guide/topics/fill-gaps.md +87 -0
- package/package.json +1 -1
- package/schemas/model.schema.json +110 -1
- package/dist/viewer/assets/index-CCJdHKHj.js +0 -100
- package/dist/viewer/assets/index-Dz5Vp7Pj.css +0 -1
- package/dist/viewer/assets/layout.worker-BRHAGJrD.js +0 -26
- package/dist/viewer/assets/sequence-svg-CVp2T653.js +0 -2
- package/dist/viewer/assets/svg-DBU_KIAN.js +0 -2
- package/dist/viewer/assets/teams-DOyxe29r.js +0 -41
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ npx archidocs check
|
|
|
102
102
|
npx archidocs dev
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
Open <http://localhost:4321>. The viewer starts on the
|
|
105
|
+
Open <http://localhost:4321>. The viewer starts on the C1 Landscape, which shows the Shopper and the Online Shop. Choose **Go deeper › C2 Landscape** and select the arrow button on the Online Shop box to see the two Services inside it. The viewer reloads as you edit the files.
|
|
106
106
|
|
|
107
107
|
The finished Workspace is in [examples/quick-start](examples/quick-start).
|
|
108
108
|
|
package/dist/core/load.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename, dirname, join, relative, sep } from "node:path";
|
|
2
2
|
import { Bundle, SCHEMA_VERSION } from "../schema/bundle.js";
|
|
3
|
-
import { DynamicView, ProjectFile, StructuralView, WorkspaceFile, childKindOf, collectionOf, kindOfCollection, lensSchemaFor, selectorSchemaFor, shallow, workspaceOnlyKeys } from "../schema/workspace.js";
|
|
3
|
+
import { DynamicView, Instances, ProjectFile, StructuralView, WorkspaceFile, childKindOf, collectionOf, kindOfCollection, lensSchemaFor, selectorSchemaFor, shallow, workspaceOnlyKeys } from "../schema/workspace.js";
|
|
4
4
|
import { indexByQualifiedId, qualified, qualify, referenceResolver } from "./refs.js";
|
|
5
5
|
import { rules } from "./rules.js";
|
|
6
6
|
import { checkSchema } from "./schema-check.js";
|
|
@@ -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;
|
|
@@ -376,6 +380,7 @@ function toBundle(ws, options) {
|
|
|
376
380
|
target: qualify(d.data.target, d.project) ?? String(d.data.target ?? ""),
|
|
377
381
|
url: str(d.data.url),
|
|
378
382
|
endpoints: Array.isArray(d.data.endpoints) ? d.data.endpoints.map(asRecord).map((e) => ({ name: String(e.name ?? ""), url: String(e.url ?? "") })) : [],
|
|
383
|
+
instances: instancesOf(d.data.instances),
|
|
379
384
|
owner: d.service ? ownerOf(d.service) : (d.project.owner ?? ""),
|
|
380
385
|
source: source(d),
|
|
381
386
|
}));
|
|
@@ -462,3 +467,8 @@ function toBundle(ws, options) {
|
|
|
462
467
|
}
|
|
463
468
|
const asRecord = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
464
469
|
const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
470
|
+
/** A Deployment's `instances` as the Bundle carries it: 1 when absent or invalid (Load has already reported an invalid one). */
|
|
471
|
+
function instancesOf(value) {
|
|
472
|
+
const parsed = Instances.safeParse(value);
|
|
473
|
+
return parsed.success ? parsed.data : 1;
|
|
474
|
+
}
|
package/dist/core/rules.js
CHANGED
|
@@ -756,11 +756,11 @@ export const rules = [
|
|
|
756
756
|
since: "1.0.0",
|
|
757
757
|
summary: `A View has more than ${MAX_VIEW_NODES} nodes, too many for a readable diagram. A Generated View is reported at its System or Service, or at \`workspace.yaml\` for the Landscapes; a Saved View at its id.`,
|
|
758
758
|
why: `A View is a diagram for people to read. With more than ${MAX_VIEW_NODES} nodes the boxes and lines are too many to follow, so the View answers no question at a glance.`,
|
|
759
|
-
fix: "Split the System, or group top-level Services and Systems, so each Generated View stays within the limit; narrow a Saved View's selectors or raise its `level`.",
|
|
759
|
+
fix: "Split the System, or group top-level Services and Systems, so each Generated View stays within the limit; narrow a Saved View's selectors or raise its `level`. The C2 Landscape opens every System, so it stays within the limit only while the Workspace's Systems, Services and Persons do.",
|
|
760
760
|
related: ["empty-view"],
|
|
761
761
|
example: {
|
|
762
762
|
failing: withServices(`systems:\n big:\n name: Big\n services:\n${numbered(MAX_VIEW_NODES, "s", 6)}`),
|
|
763
|
-
passing: withServices(`systems:\n big:\n name: Big\n services:\n${numbered(MAX_VIEW_NODES / 2, "s", 6)} more:\n name: More\n services:\n${numbered(MAX_VIEW_NODES / 2, "s", 6, MAX_VIEW_NODES / 2)}`),
|
|
763
|
+
passing: withServices(`systems:\n big:\n name: Big\n services:\n${numbered(MAX_VIEW_NODES / 2 - 1, "s", 6)} more:\n name: More\n services:\n${numbered(MAX_VIEW_NODES / 2 - 1, "s", 6, MAX_VIEW_NODES / 2)}`),
|
|
764
764
|
},
|
|
765
765
|
check: (ws, bundle) => {
|
|
766
766
|
const workspaceFile = ws.files.find((f) => f.role === "workspace");
|
|
@@ -8,6 +8,10 @@ export interface DeploymentScope {
|
|
|
8
8
|
/** A Service this rejects is left out, with its Relationships. */
|
|
9
9
|
keep?: (service: string) => boolean;
|
|
10
10
|
}
|
|
11
|
+
/** True when a Deployment runs, or may run, more than one instance. */
|
|
12
|
+
export declare const isScaled: (instances: BundleDeployment["instances"]) => boolean;
|
|
13
|
+
/** A scaled Deployment's chip text: `×3` for a fixed count, `2–10` for an autoscale range. */
|
|
14
|
+
export declare const instancesChip: (instances: BundleDeployment["instances"]) => string;
|
|
11
15
|
/**
|
|
12
16
|
* Resolves the Deployment View of one Environment:
|
|
13
17
|
* - every Target holding a drawn Deployment is a container, nested in its parent Targets;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { cmp, lifter } from "../query.js";
|
|
2
|
+
/** True when a Deployment runs, or may run, more than one instance. */
|
|
3
|
+
export const isScaled = (instances) => (typeof instances === "number" ? instances > 1 : instances.max > 1);
|
|
4
|
+
/** A scaled Deployment's chip text: `×3` for a fixed count, `2–10` for an autoscale range. */
|
|
5
|
+
export const instancesChip = (instances) => (typeof instances === "number" ? `×${instances}` : `${instances.min}–${instances.max}`);
|
|
2
6
|
/** A Deployment's node id: its Service and Target, as `<service>@<target>`. */
|
|
3
7
|
const deploymentNodeId = (d) => `${d.service}@${d.target}`;
|
|
4
8
|
/**
|
|
@@ -36,7 +40,17 @@ export function resolveDeployment(bundle, model, head, environment, scope = {})
|
|
|
36
40
|
nodes.set(parent, { id: parent, kind: "system", name: s.name, parent: d.target, element: system, collapsed: false, external: "external" in s && s.external });
|
|
37
41
|
}
|
|
38
42
|
const service = model.byId.get(d.service);
|
|
39
|
-
nodes.set(deploymentNodeId(d), {
|
|
43
|
+
nodes.set(deploymentNodeId(d), {
|
|
44
|
+
id: deploymentNodeId(d),
|
|
45
|
+
kind: "deployment",
|
|
46
|
+
name: service.name,
|
|
47
|
+
parent,
|
|
48
|
+
element: d.service,
|
|
49
|
+
target: d.target,
|
|
50
|
+
...(isScaled(d.instances) ? { instances: d.instances } : {}),
|
|
51
|
+
collapsed: false,
|
|
52
|
+
external: "external" in service && service.external,
|
|
53
|
+
});
|
|
40
54
|
byService.set(d.service, [...(byService.get(d.service) ?? []), { d, chain }]);
|
|
41
55
|
}
|
|
42
56
|
const lift = lifter(bundle, "service");
|
|
@@ -5,8 +5,10 @@ import type { ResolvedView, ViewKind, ViewSummary } from "./types.ts";
|
|
|
5
5
|
* Resolves a Generated View by id: `c1`, `c2`, `c2/<system>`, `c3/<service>`
|
|
6
6
|
* (only for a Service with Components) or `deployment/<env>`. Undefined for
|
|
7
7
|
* any other id, and for one naming an Element or Environment that isn't there.
|
|
8
|
+
* The C2 Landscape opens every System but those in `collapse`; `collapse`
|
|
9
|
+
* applies to no other View.
|
|
8
10
|
*/
|
|
9
|
-
export declare function resolveGenerated(bundle: Bundle, model: ModelIndex, id: string, expand: readonly string[]): ResolvedView | undefined;
|
|
11
|
+
export declare function resolveGenerated(bundle: Bundle, model: ModelIndex, id: string, expand: readonly string[], collapse?: readonly string[]): ResolvedView | undefined;
|
|
10
12
|
/**
|
|
11
13
|
* Every Generated View's id, in the order `c1`, `c2`, then `c2/<system>` and
|
|
12
14
|
* `c3/<service>` by id, then `deployment/<env>` by Environment id.
|
|
@@ -5,13 +5,15 @@ import { build } from "./model.js";
|
|
|
5
5
|
* Resolves a Generated View by id: `c1`, `c2`, `c2/<system>`, `c3/<service>`
|
|
6
6
|
* (only for a Service with Components) or `deployment/<env>`. Undefined for
|
|
7
7
|
* any other id, and for one naming an Element or Environment that isn't there.
|
|
8
|
+
* The C2 Landscape opens every System but those in `collapse`; `collapse`
|
|
9
|
+
* applies to no other View.
|
|
8
10
|
*/
|
|
9
|
-
export function resolveGenerated(bundle, model, id, expand) {
|
|
11
|
+
export function resolveGenerated(bundle, model, id, expand, collapse = []) {
|
|
10
12
|
const ref = parseViewId(id);
|
|
11
13
|
if (ref === undefined || ref.form === "saved")
|
|
12
14
|
return undefined;
|
|
13
15
|
if (ref.form === "landscape")
|
|
14
|
-
return
|
|
16
|
+
return ref.level === "c1" ? landscape(model, "c1", "C1 Landscape", []) : landscape(model, "c2", "C2 Landscape", [...systemsOpen(model, collapse), ...expand]);
|
|
15
17
|
if (ref.form === "deployment") {
|
|
16
18
|
const env = bundle.environments.find((e) => e.id === ref.environment);
|
|
17
19
|
return env ? resolveDeployment(bundle, model, { id, title: `${env.name} (Deployment)` }, env.id) : undefined;
|
|
@@ -46,6 +48,11 @@ export function summarise(id, bundle) {
|
|
|
46
48
|
throw new Error(`"${id}" is not a Generated View id`);
|
|
47
49
|
return { id, kind: ref.level, title: `${bundle.elements.find((e) => e.id === ref.element).name} (${ref.level.toUpperCase()})` };
|
|
48
50
|
}
|
|
51
|
+
/** Every System not in `collapse`: the boxes the C2 Landscape opens before its `expand`. */
|
|
52
|
+
function systemsOpen(model, collapse) {
|
|
53
|
+
const closed = new Set(collapse);
|
|
54
|
+
return model.elements.filter((e) => e.kind === "system" && !closed.has(e.id)).map((e) => e.id);
|
|
55
|
+
}
|
|
49
56
|
/** Every top-level Element, each standing for everything beneath it, with the `expand`ed boxes open. */
|
|
50
57
|
function landscape(model, kind, title, expand) {
|
|
51
58
|
const shown = new Set(model.elements.filter((e) => e.parent === null).map((e) => e.id));
|
|
@@ -8,6 +8,7 @@ export { compareView } from "./compare.ts";
|
|
|
8
8
|
export { saveAsView, type Screen, type SavedScreen, type SavedViewDefinition } from "./save-as-view.ts";
|
|
9
9
|
export { parseViewId, formatViewId, ownViewId, type ViewRef } from "./ids.ts";
|
|
10
10
|
export { describeLens } from "./lens.ts";
|
|
11
|
+
export { instancesChip, isScaled } from "./deployment.ts";
|
|
11
12
|
export { stepViews, dynamicViewsUsing, type DynamicResolution, type DynamicProblem, type ResolvedDynamicView, type ResolvedStep, type StepKind } from "./dynamic.ts";
|
|
12
13
|
export type { SavedResolution, BadExpand, UnresolvedPath } from "./saved.ts";
|
|
13
14
|
export { MAX_VIEW_NODES, type CompareMark, type ImpactSide, type LensChoice, type ListedKind, type NodeMark, type ResolveOptions, type ResolvedView, type ViewDirection, type ViewEdge, type ViewKind, type ViewNode, type ViewSummary, } from "./types.ts";
|
package/dist/core/views/index.js
CHANGED
|
@@ -8,5 +8,6 @@ export { compareView } from "./compare.js";
|
|
|
8
8
|
export { saveAsView } from "./save-as-view.js";
|
|
9
9
|
export { parseViewId, formatViewId, ownViewId } from "./ids.js";
|
|
10
10
|
export { describeLens } from "./lens.js";
|
|
11
|
+
export { instancesChip, isScaled } from "./deployment.js";
|
|
11
12
|
export { stepViews, dynamicViewsUsing } from "./dynamic.js";
|
|
12
13
|
export { MAX_VIEW_NODES, } from "./types.js";
|
|
@@ -19,17 +19,17 @@ export function resolveView(bundle, id, options = {}) {
|
|
|
19
19
|
/** Resolves a Structural View by id over an index of its Bundle; undefined for an unknown id or a Dynamic View's. */
|
|
20
20
|
export function resolveStructural(bundle, model, id, options = {}) {
|
|
21
21
|
const lens = options.lens ?? "own";
|
|
22
|
-
const view = unlensed(bundle, model, id, options
|
|
22
|
+
const view = unlensed(bundle, model, id, options, lens);
|
|
23
23
|
if (view && typeof lens === "object")
|
|
24
24
|
applyLens(bundle, model, view, lens);
|
|
25
25
|
return view;
|
|
26
26
|
}
|
|
27
27
|
/** A Structural View with no Lens, except a Saved View's own when the choice is `"own"`. */
|
|
28
|
-
function unlensed(bundle, model, id,
|
|
28
|
+
function unlensed(bundle, model, id, options, lens) {
|
|
29
29
|
const saved = bundle.views.find((v) => v.id === id);
|
|
30
30
|
if (saved)
|
|
31
31
|
return saved.kind === "structural" ? resolveSaved(bundle, model, lens === "own" ? saved : { ...saved, lens: null }).view : undefined;
|
|
32
|
-
return resolveGenerated(bundle, model, id, expand);
|
|
32
|
+
return resolveGenerated(bundle, model, id, options.expand ?? [], options.collapse ?? []);
|
|
33
33
|
}
|
|
34
34
|
export function checkView(bundle, def) {
|
|
35
35
|
return def.kind === "dynamic" ? resolveDynamic(bundle, def) : resolveSaved(bundle, new ModelIndex(bundle), def);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Bundle, BundleLens } from "../../schema/bundle.ts";
|
|
2
2
|
import type { ViewDirection } from "./types.ts";
|
|
3
|
-
/** What the viewer shows, as its URL holds it: the View, its open boxes, the Lens, the picks and a turned direction. */
|
|
3
|
+
/** What the viewer shows, as its URL holds it: the View, its open and closed boxes, the Lens, the picks and a turned direction. */
|
|
4
4
|
export interface Screen {
|
|
5
5
|
view: string;
|
|
6
6
|
open: readonly string[];
|
|
7
|
+
/** Systems closed on the C2 Landscape, which opens every other System. */
|
|
8
|
+
closed: readonly string[];
|
|
7
9
|
lens: BundleLens | null;
|
|
8
10
|
picks: readonly string[];
|
|
9
11
|
/** The direction the viewer turned the View to; null keeps the View's own. */
|
|
@@ -30,8 +32,11 @@ export interface SavedScreen {
|
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* Save as View: turns the screen into a Saved View definition that the core
|
|
33
|
-
* engine resolves to the same nodes. The
|
|
34
|
-
*
|
|
35
|
+
* engine resolves to the same nodes. The whole C2 Landscape, with no picks or
|
|
36
|
+
* Lens, is `level: c2` with no `include`, its closed Systems as `collapse`
|
|
37
|
+
* and its open boxes as `expand`. Otherwise the picks (with their open
|
|
38
|
+
* containers), or else every node, become ids; open boxes (on the C2
|
|
39
|
+
* Landscape, every System not closed too) whose children are all kept
|
|
35
40
|
* become `expand`; the Lens becomes an include selector (an Impact Lens
|
|
36
41
|
* `upstream`/`downstream: all`, a Team Lens `{team}`, Connect to… a path
|
|
37
42
|
* selector) and is kept as `lens:`. Nodes the Lens selector would add beyond
|
|
@@ -7,8 +7,11 @@ const kindLevel = { person: "c1", system: "c1", service: "c2", component: "c3" }
|
|
|
7
7
|
const levelDepth = { c1: 1, c2: 2, c3: 3 };
|
|
8
8
|
/**
|
|
9
9
|
* Save as View: turns the screen into a Saved View definition that the core
|
|
10
|
-
* engine resolves to the same nodes. The
|
|
11
|
-
*
|
|
10
|
+
* engine resolves to the same nodes. The whole C2 Landscape, with no picks or
|
|
11
|
+
* Lens, is `level: c2` with no `include`, its closed Systems as `collapse`
|
|
12
|
+
* and its open boxes as `expand`. Otherwise the picks (with their open
|
|
13
|
+
* containers), or else every node, become ids; open boxes (on the C2
|
|
14
|
+
* Landscape, every System not closed too) whose children are all kept
|
|
12
15
|
* become `expand`; the Lens becomes an include selector (an Impact Lens
|
|
13
16
|
* `upstream`/`downstream: all`, a Team Lens `{team}`, Connect to… a path
|
|
14
17
|
* selector) and is kept as `lens:`. Nodes the Lens selector would add beyond
|
|
@@ -17,7 +20,7 @@ const levelDepth = { c1: 1, c2: 2, c3: 3 };
|
|
|
17
20
|
*/
|
|
18
21
|
export function saveAsView(bundle, screen, target) {
|
|
19
22
|
const model = new ModelIndex(bundle);
|
|
20
|
-
const view = resolveStructural(bundle, model, screen.view, { expand: screen.open });
|
|
23
|
+
const view = resolveStructural(bundle, model, screen.view, { expand: screen.open, collapse: screen.closed });
|
|
21
24
|
if (!view)
|
|
22
25
|
throw new Error(`No View ${screen.view} to save.`);
|
|
23
26
|
const own = bundle.views.find((v) => v.id === screen.view && v.kind === "structural");
|
|
@@ -41,9 +44,11 @@ export function saveAsView(bundle, screen, target) {
|
|
|
41
44
|
else {
|
|
42
45
|
const kept = new Set((screen.picks.length === 0 ? view : pickedView(view, screen.picks)).nodes.map((n) => n.id));
|
|
43
46
|
const depthOf = (id) => model.ancestry(id).length;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
const opens = (id) => kept.has(id) && model.children(id).length > 0 && model.children(id).every((c) => kept.has(c.id));
|
|
48
|
+
// On the C2 Landscape every System is open unless closed, as `resolveGenerated` opens them.
|
|
49
|
+
const landscape = !own && view.id === "c2";
|
|
50
|
+
const systems = landscape ? model.elements.filter((e) => e.kind === "system" && !screen.closed.includes(e.id)).map((e) => e.id) : [];
|
|
51
|
+
const expand = [...new Set([...systems, ...screen.open])].filter(opens).sort((a, b) => depthOf(a) - depthOf(b));
|
|
47
52
|
const byExpand = new Set(expand.flatMap((id) => model.children(id).map((c) => c.id)));
|
|
48
53
|
const ids = [...kept].filter((id) => !byExpand.has(id)).sort();
|
|
49
54
|
const deepest = ids.reduce((d, id) => Math.max(d, levelDepth[kindLevel[model.byId.get(id).kind]]), levelDepth[view.kind]);
|
|
@@ -51,6 +56,11 @@ export function saveAsView(bundle, screen, target) {
|
|
|
51
56
|
const plain = { level, include: ids, ...nonEmpty({ expand }) };
|
|
52
57
|
const selector = screen.lens ? lensSelector(screen.lens) : undefined;
|
|
53
58
|
body = plain;
|
|
59
|
+
if (landscape && screen.picks.length === 0 && !selector) {
|
|
60
|
+
// The whole Landscape: every Element at `c2`, which opens every System, less those closed.
|
|
61
|
+
const collapse = screen.closed.filter((id) => kept.has(id) && model.children(id).length > 0 && !screen.open.includes(id));
|
|
62
|
+
body = { level: "c2", ...nonEmpty({ expand: expand.filter((id) => !systems.includes(id)), collapse }) };
|
|
63
|
+
}
|
|
54
64
|
if (selector) {
|
|
55
65
|
const reached = nodesOf(bundle, model, { level, include: [selector] });
|
|
56
66
|
const include = [selector, ...ids.filter((id) => !reached.has(id))];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BundleElement, BundleLens, BundleRelationship } from "../../schema/bundle.ts";
|
|
1
|
+
import type { BundleDeployment, BundleElement, BundleLens, BundleRelationship } from "../../schema/bundle.ts";
|
|
2
2
|
/** The most nodes a View may have before `oversized-view` warns. */
|
|
3
3
|
export declare const MAX_VIEW_NODES = 150;
|
|
4
4
|
/** The kinds of Structural View: the three levels, and the Deployment View. */
|
|
@@ -19,6 +19,8 @@ export interface ViewNode {
|
|
|
19
19
|
element?: string;
|
|
20
20
|
/** A Deployment's Deployment Target. */
|
|
21
21
|
target?: string;
|
|
22
|
+
/** A scaled Deployment's `instances` (a count above 1, or an autoscale range); absent for one instance. */
|
|
23
|
+
instances?: BundleDeployment["instances"];
|
|
22
24
|
/** The nearest ancestor that is itself a node of this View, else null. */
|
|
23
25
|
parent: string | null;
|
|
24
26
|
/** True when the Element has children in the Model that this View hides inside it. */
|
|
@@ -71,6 +73,12 @@ export interface ResolveOptions {
|
|
|
71
73
|
* stays shut inside a closed System. C1 opens nothing.
|
|
72
74
|
*/
|
|
73
75
|
expand?: readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* Systems the C2 Landscape shows closed; it opens every other System.
|
|
78
|
+
* Viewer state, like `expand`, and read by no other View. A System that is
|
|
79
|
+
* also in `expand` is open.
|
|
80
|
+
*/
|
|
81
|
+
collapse?: readonly string[];
|
|
74
82
|
/**
|
|
75
83
|
* The Lens over the View, which marks nodes and lights edges without
|
|
76
84
|
* changing which nodes the View holds: `"own"` (the default) is a Saved
|
package/dist/guide/index.d.ts
CHANGED
|
@@ -22,6 +22,9 @@ export declare const topics: readonly [{
|
|
|
22
22
|
}, {
|
|
23
23
|
readonly id: "propose-adr";
|
|
24
24
|
readonly summary: "Propose an ADR linked to the Elements and Views it affects.";
|
|
25
|
+
}, {
|
|
26
|
+
readonly id: "fill-gaps";
|
|
27
|
+
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
28
|
}, {
|
|
26
29
|
readonly id: "change";
|
|
27
30
|
readonly summary: "Rename, move or remove, working through refused removals by their references.";
|
package/dist/guide/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export const topics = [
|
|
|
18
18
|
{ id: "dynamic-view", summary: "Draft a scenario as Steps over existing Relationships, adding missing ones." },
|
|
19
19
|
{ id: "saved-view", summary: "Save a structural or Deployment View with selectors and a Lens." },
|
|
20
20
|
{ id: "propose-adr", summary: "Propose an ADR linked to the Elements and Views it affects." },
|
|
21
|
+
{ id: "fill-gaps", 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." },
|
|
21
22
|
{ id: "change", summary: "Rename, move or remove, working through refused removals by their references." },
|
|
22
23
|
{ id: "rules", summary: "Every `check` rule id: what it means, a failing example and the fix." },
|
|
23
24
|
];
|
|
@@ -49,7 +50,7 @@ export async function authoringGuide(topic) {
|
|
|
49
50
|
*/
|
|
50
51
|
export const skillStub = (runner) => `---
|
|
51
52
|
name: ${SKILL_NAME}
|
|
52
|
-
description: Edit the Archidocs architecture Model. Use when bootstrapping a Project from code, adding or changing Services, Relationships, Deployments or Views,
|
|
53
|
+
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.
|
|
53
54
|
---
|
|
54
55
|
|
|
55
56
|
# Archidocs authoring
|
package/dist/mcp/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { withDocs } from "../core/rules.js";
|
|
|
5
5
|
import { search } from "../core/search.js";
|
|
6
6
|
import { changeKinds, countChanges, deriveEdges, diff, filterChanges, findPaths, getImpact, levelOf, listOwned, resolveScope, scopeMatcher, } from "../core/index.js";
|
|
7
7
|
import { suggest } from "../core/suggest.js";
|
|
8
|
-
import { describeLens, listViews, resolveView } from "../core/views/index.js";
|
|
8
|
+
import { describeLens, isScaled, listViews, resolveView } from "../core/views/index.js";
|
|
9
9
|
import { listAdrs } from "../core/adrs.js";
|
|
10
10
|
import { AdrStatus } from "../schema/adr.js";
|
|
11
11
|
import { BundleAdr, BundleDeployment, BundleElement, BundleLens, BundleRelationship } from "../schema/bundle.js";
|
|
@@ -157,7 +157,9 @@ export function createServer(options) {
|
|
|
157
157
|
["technology", "technology" in element ? element.technology : null],
|
|
158
158
|
["external", "external" in element && element.external ? "yes" : null],
|
|
159
159
|
["tags", element.tags.join(", ")],
|
|
160
|
+
["repository", "repository" in element ? element.repository : null],
|
|
160
161
|
["links", element.links.map((l) => `[${l.label}](${l.url})`).join(", ")],
|
|
162
|
+
["metadata", Object.entries(element.metadata).map(([k, v]) => `${k}: ${v}`).join(", ")],
|
|
161
163
|
["children", children.map(label).join(", ")],
|
|
162
164
|
["deployments", deployments.map((d) => `${d.environment} on ${d.target}${d.url ? ` (${d.url})` : ""}`).join(", ")],
|
|
163
165
|
["uses", relationships.out.map((r) => `${r.to}${r.description ? ` (${r.description})` : ""}`).join(", ")],
|
|
@@ -214,7 +216,7 @@ export function createServer(options) {
|
|
|
214
216
|
});
|
|
215
217
|
tool("get_deployments", {
|
|
216
218
|
title: "Get Deployments",
|
|
217
|
-
description: "Where a Service runs: each Deployment's Environment, its full Deployment Target chain (outermost first), main url and
|
|
219
|
+
description: "Where a Service runs: each Deployment's Environment, its full Deployment Target chain (outermost first), main url, named endpoints and `instances` (a count, or {min, max} for autoscale). Pass `environment` for one Environment, e.g. a Service's URL in staging.",
|
|
218
220
|
input: z.object({
|
|
219
221
|
service: QualifiedId.describe("The Service's qualified id, project:id"),
|
|
220
222
|
environment: z.string().min(1).optional().describe("An Environment id, such as prod or staging"),
|
|
@@ -245,7 +247,7 @@ export function createServer(options) {
|
|
|
245
247
|
...items.map((d) => {
|
|
246
248
|
const chain = d.targetPath.length ? d.targetPath.map((t) => t.id).join(" › ") : d.target;
|
|
247
249
|
const urls = [d.url ?? "no URL", ...d.endpoints.map((e) => `${e.name}: ${e.url}`)].join("; ");
|
|
248
|
-
return `- ${d.environment} on ${chain}: ${urls}`;
|
|
250
|
+
return `- ${d.environment} on ${chain}${instancesLabel(d.instances)}: ${urls}`;
|
|
249
251
|
}),
|
|
250
252
|
].join("\n"));
|
|
251
253
|
});
|
|
@@ -310,6 +312,7 @@ export function createServer(options) {
|
|
|
310
312
|
name: z.string(),
|
|
311
313
|
element: z.string().optional(),
|
|
312
314
|
target: z.string().optional(),
|
|
315
|
+
instances: BundleDeployment.shape.instances.optional(),
|
|
313
316
|
parent: z.string().nullable(),
|
|
314
317
|
collapsed: z.boolean(),
|
|
315
318
|
external: z.boolean(),
|
|
@@ -711,7 +714,7 @@ const ElementKind = z.enum(["person", "system", "service", "component"]);
|
|
|
711
714
|
const ViewKind = z.enum(["c1", "c2", "c3", "deployment", "dynamic"]);
|
|
712
715
|
const ViewSummary = z.object({ id: z.string(), kind: ViewKind, title: z.string() });
|
|
713
716
|
const nodeKind = (n) => (n.kind === "deployment" ? `Deployment of ${n.element}` : n.kind === "target" ? "Deployment Target" : kindName[n.kind]);
|
|
714
|
-
const nodeLine = (n) => `- ${label(n)}: ${nodeKind(n)}${n.external ? ", external" : ""}${n.parent ? ` in ${n.parent}` : ""}${n.collapsed ? ", collapsed" : ""}${n.mark?.hit ? `, hit${n.mark.distance === undefined ? "" : ` at distance ${n.mark.distance}`}${n.mark.side === undefined || n.mark.side === "origin" ? "" : ` ${n.mark.side}`}` : ""}`;
|
|
717
|
+
const nodeLine = (n) => `- ${label(n)}: ${nodeKind(n)}${n.instances === undefined ? "" : instancesLabel(n.instances)}${n.external ? ", external" : ""}${n.parent ? ` in ${n.parent}` : ""}${n.collapsed ? ", collapsed" : ""}${n.mark?.hit ? `, hit${n.mark.distance === undefined ? "" : ` at distance ${n.mark.distance}`}${n.mark.side === undefined || n.mark.side === "origin" ? "" : ` ${n.mark.side}`}` : ""}`;
|
|
715
718
|
/** A Step as one line: a return drawn dashed (⇠), an event with its broker and channel. */
|
|
716
719
|
const stepLine = (s) => {
|
|
717
720
|
const how = s.kind === "event" ? ` (event${s.via ? ` via ${s.via}` : ""}${s.channel ? ` · ${s.channel}` : ""})` : s.kind === "return" ? " (return)" : s.interaction === "async" ? " (async)" : "";
|
|
@@ -735,9 +738,12 @@ const deploymentResult = (d) => ({
|
|
|
735
738
|
targetPath: d.targetPath,
|
|
736
739
|
url: d.url,
|
|
737
740
|
endpoints: d.endpoints,
|
|
741
|
+
instances: d.instances,
|
|
738
742
|
owner: d.owner,
|
|
739
743
|
source: d.source,
|
|
740
744
|
});
|
|
745
|
+
/** ` (×3)` or ` (2–10 instances)`; empty for a single instance. */
|
|
746
|
+
const instancesLabel = (i) => (!isScaled(i) ? "" : typeof i === "number" ? ` (×${i})` : ` (${i.min}–${i.max} instances)`);
|
|
741
747
|
const summary = (e) => ({ id: e.id, kind: e.kind, name: e.name });
|
|
742
748
|
const label = (e) => `${e.id} (${e.name})`;
|
|
743
749
|
const kindName = { person: "Person", system: "System", service: "Service", component: "Component" };
|
package/dist/mcp/writes.js
CHANGED
|
@@ -106,6 +106,7 @@ export function registerWriteTools(server, source, readOnly, logged) {
|
|
|
106
106
|
description: [
|
|
107
107
|
"Adds a Deployment Target, or updates the fields of an existing one (name, kind, description, owner, tags, links); comments and formatting are kept.",
|
|
108
108
|
"A new Target nests under `parent` in the parent's file. A new top-level one goes into `file` (relative to the Project's folder), else `model.yaml`.",
|
|
109
|
+
"`kind` is free text printed as written in the Target's header, so keep it short: `region`, `az`, `vnet`, `snet`, `vm`, `aks`, `ns`, `asp`, not `availability-zone` or `subnet`.",
|
|
109
110
|
].join(" "),
|
|
110
111
|
input: z.object({
|
|
111
112
|
project: Project,
|
|
@@ -130,7 +131,9 @@ export function registerWriteTools(server, source, readOnly, logged) {
|
|
|
130
131
|
writeTool("upsert_deployment", {
|
|
131
132
|
title: "Add or update a Deployment",
|
|
132
133
|
description: [
|
|
133
|
-
"Adds a Deployment, or updates the fields (url, endpoints) of the one its (service, environment, target) triple names, in this Project's YAML; comments and formatting are kept.",
|
|
134
|
+
"Adds a Deployment, or updates the fields (url, endpoints, instances) of the one its (service, environment, target) triple names, in this Project's YAML; comments and formatting are kept.",
|
|
135
|
+
"`instances` is a whole number for a fixed count, such as 3, or {min, max} for an autoscale range, such as {min: 2, max: 10}; leave it out for one instance.",
|
|
136
|
+
"Use it for interchangeable copies on one Target (an App Service plan running N workers); when placement matters (one per availability zone or VM), add separate Deployments on separate Targets instead.",
|
|
134
137
|
"A new one goes into `file` (relative to the Project's folder), else beside the Project's other Deployments, else into `model.yaml`.",
|
|
135
138
|
].join(" "),
|
|
136
139
|
input: z.object({
|
package/dist/render/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { renderPng, type PngOptions } from "./png.ts";
|
|
|
5
5
|
export { layoutSequence, sequenceMessages, sequenceParticipants, viaLine, SEQUENCE, type SequenceLayout, type SequenceMessage, type SequenceColumn, type SequenceRow, type Activation, type MessageStyle, type SequenceOptions } from "./sequence.ts";
|
|
6
6
|
export { textWidth, cut } from "./text.ts";
|
|
7
7
|
export { renderSequenceSvg, type SequenceRenderInput } from "./sequence-svg.ts";
|
|
8
|
-
export { PALETTES, themes, type Palette, type Theme } from "./tokens.ts";
|
|
8
|
+
export { PALETTES, themes, targetStep, TARGET_STEPS, type Palette, type Theme } from "./tokens.ts";
|
package/dist/render/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { renderPng } from "./png.js";
|
|
|
5
5
|
export { layoutSequence, sequenceMessages, sequenceParticipants, viaLine, SEQUENCE } from "./sequence.js";
|
|
6
6
|
export { textWidth, cut } from "./text.js";
|
|
7
7
|
export { renderSequenceSvg } from "./sequence-svg.js";
|
|
8
|
-
export { PALETTES, themes } from "./tokens.js";
|
|
8
|
+
export { PALETTES, themes, targetStep, TARGET_STEPS } from "./tokens.js";
|
package/dist/render/layout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ELK } from "elkjs/lib/elk-api.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ResolvedView, type ViewNode } from "../core/views/index.ts";
|
|
3
3
|
/** Which way a View's edges flow: top to bottom, bottom to top, left to right or right to left. */
|
|
4
4
|
export type Direction = "TB" | "BT" | "LR" | "RL";
|
|
5
5
|
export declare const directions: readonly Direction[];
|
|
@@ -44,6 +44,8 @@ export declare const NODE_SIZES: Record<ViewNode["kind"], {
|
|
|
44
44
|
export declare const NODE_MAX_WIDTH = 360;
|
|
45
45
|
/** The extra height a box gets for a second line of name. */
|
|
46
46
|
export declare const NAME_LINE = 18;
|
|
47
|
+
/** A scaled Deployment's count chip, `×3` or `2–10`, as wide as the viewer and the SVG draw it. */
|
|
48
|
+
export declare function chipWidth(chip: string): number;
|
|
47
49
|
/** The width a box of `width` leaves for its name. */
|
|
48
50
|
export declare function nameRoom(n: ViewNode, width: number): number;
|
|
49
51
|
/**
|
package/dist/render/layout.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ElkBundled from "elkjs/lib/elk.bundled.js";
|
|
2
|
+
import { instancesChip } from "../core/views/index.js";
|
|
2
3
|
import { textWidth } from "./text.js";
|
|
3
4
|
export const directions = ["TB", "BT", "LR", "RL"];
|
|
4
5
|
/** The least size of a node per kind; `nodeSize` widens it for a long name. Containers are sized by their contents. */
|
|
@@ -23,7 +24,11 @@ const WAY_IN_CHROME = 30;
|
|
|
23
24
|
/** The room a box of this kind and state needs beside its name. */
|
|
24
25
|
function headChrome(n) {
|
|
25
26
|
const opens = n.kind === "system" || (n.kind === "service" && n.collapsed);
|
|
26
|
-
return HEAD_CHROME + (n.collapsed && opens ? TOGGLE_CHROME : 0) + (n.kind === "person" ? 12 : 0);
|
|
27
|
+
return HEAD_CHROME + (n.collapsed && opens ? TOGGLE_CHROME : 0) + (n.kind === "person" ? 12 : 0) + (n.instances === undefined ? 0 : chipWidth(instancesChip(n.instances)) + 8);
|
|
28
|
+
}
|
|
29
|
+
/** A scaled Deployment's count chip, `×3` or `2–10`, as wide as the viewer and the SVG draw it. */
|
|
30
|
+
export function chipWidth(chip) {
|
|
31
|
+
return Math.ceil(textWidth(chip, 10, 700)) + 12;
|
|
27
32
|
}
|
|
28
33
|
/** The width a box of `width` leaves for its name. */
|
|
29
34
|
export function nameRoom(n, width) {
|
|
@@ -51,8 +51,8 @@ export function renderSequenceSvg({ bundle, view, source, brokers = false, theme
|
|
|
51
51
|
].join("\n");
|
|
52
52
|
}
|
|
53
53
|
/** Arrowheads: filled for sync calls, open for async and returns. */
|
|
54
|
-
export const heads = (fill) => `<marker id="head-filled" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto
|
|
55
|
-
`<marker id="head-open" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto
|
|
54
|
+
export const heads = (fill) => `<marker id="head-filled" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="${fill}"/></marker>` +
|
|
55
|
+
`<marker id="head-open" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto"><path d="M0,0 L10,5 L0,10" fill="none" stroke="${fill}" stroke-width="1.5"/></marker>`;
|
|
56
56
|
const lifeline = (c, x, layout) => `<path d="M${fmt(x)},${HEADER_BOX} L${fmt(x)},${fmt(layout.height - 10)}" fill="none" stroke="${c.faint}" stroke-dasharray="3 4"/>`;
|
|
57
57
|
function header(c, id, x, w, element, team) {
|
|
58
58
|
const left = x - w / 2;
|
package/dist/render/svg.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ResolvedView } from "../core/views/index.ts";
|
|
2
2
|
import type { Bundle } from "../schema/bundle.ts";
|
|
3
|
-
import type
|
|
3
|
+
import { type Layout } from "./layout.ts";
|
|
4
4
|
import { type TeamStyle } from "./teams.ts";
|
|
5
5
|
import { type Palette, type Theme } from "./tokens.ts";
|
|
6
6
|
/** Where a picture comes from, for its source line: the Workspace's name, the commit and its date (both null before the first commit). */
|
|
@@ -34,3 +34,5 @@ export declare const opening: (width: number, height: number, ground: string, de
|
|
|
34
34
|
export declare function renderSvg({ bundle, view, layout, source, theme, label }: RenderInput): string;
|
|
35
35
|
/** A reversed Team code tile with the Team colour as its leading band, its right edge at `right`. */
|
|
36
36
|
export declare function codeTile(c: Palette, team: TeamStyle, right: number, top: number): string;
|
|
37
|
+
/** How far each copy behind a scaled Deployment sits from the one in front, down and to the right. */
|
|
38
|
+
export declare const STACK_OFFSET = 5;
|