archidocs 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -13
- package/dist/cli/commands.d.ts +225 -4
- package/dist/cli/commands.js +129 -4
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.js +2 -2
- package/dist/cli/main.js +9 -14
- package/dist/core/compare.d.ts +2 -13
- package/dist/core/compare.js +2 -35
- package/dist/core/index.d.ts +2 -5
- package/dist/core/index.js +2 -5
- package/dist/core/rules.d.ts +10 -0
- package/dist/core/rules.js +186 -7
- package/dist/core/views/compare.d.ts +12 -0
- package/dist/core/views/compare.js +37 -0
- package/dist/core/{deployment-views.d.ts → views/deployment.d.ts} +4 -5
- package/dist/core/{deployment-views.js → views/deployment.js} +5 -7
- package/dist/core/{dynamic-views.d.ts → views/dynamic.d.ts} +1 -3
- package/dist/core/{dynamic-views.js → views/dynamic.js} +4 -8
- package/dist/core/views/generated.d.ts +18 -0
- package/dist/core/views/generated.js +92 -0
- package/dist/core/views/ids.d.ts +36 -0
- package/dist/core/views/ids.js +51 -0
- package/dist/core/views/index.d.ts +13 -0
- package/dist/core/views/index.js +12 -0
- package/dist/core/views/lens.d.ts +27 -0
- package/dist/core/views/lens.js +112 -0
- package/dist/core/views/model.d.ts +21 -0
- package/dist/core/views/model.js +69 -0
- package/dist/core/views/resolve.d.ts +42 -0
- package/dist/core/views/resolve.js +81 -0
- package/dist/core/{save-as-view.d.ts → views/save-as-view.d.ts} +2 -2
- package/dist/core/{save-as-view.js → views/save-as-view.js} +13 -10
- package/dist/core/{saved-views.d.ts → views/saved.d.ts} +4 -18
- package/dist/core/{saved-views.js → views/saved.js} +8 -103
- package/dist/core/views/types.d.ts +91 -0
- package/dist/core/views/types.js +2 -0
- package/dist/mcp/errors.d.ts +37 -0
- package/dist/mcp/errors.js +35 -0
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/server.d.ts +1 -2
- package/dist/mcp/server.js +12 -12
- package/dist/render/layout.d.ts +20 -3
- package/dist/render/layout.js +49 -12
- package/dist/render/sequence-svg.d.ts +1 -1
- package/dist/render/sequence.d.ts +1 -1
- package/dist/render/svg.d.ts +1 -1
- package/dist/render/svg.js +4 -4
- package/dist/schema/adr.js +18 -13
- package/dist/schema/workspace.js +226 -130
- package/dist/viewer/assets/index-BXa5R96a.js +138 -0
- package/dist/viewer/assets/index-YFA-pYjQ.css +1 -0
- package/dist/viewer/assets/{layout.worker-Bg-OaLVN.js → layout.worker-BRHAGJrD.js} +1 -1
- package/dist/viewer/assets/{png-BDKIXtm5.js → png-CAaXWR-k.js} +1 -1
- package/dist/viewer/assets/{svg-Bulv5YWn.js → svg-BPVHfD36.js} +2 -2
- package/dist/viewer/index.html +2 -2
- package/guide/SKILL.md +1 -1
- package/guide/topics/bootstrap.md +1 -1
- package/guide/topics/relationships.md +1 -1
- package/package.json +4 -3
- package/schemas/adr.schema.json +18 -15
- package/schemas/model.schema.json +637 -1144
- package/schemas/project.schema.json +8 -4
- package/schemas/workspace.schema.json +39 -20
- package/dist/core/views.d.ts +0 -126
- package/dist/core/views.js +0 -217
- package/dist/viewer/assets/index-DvKgCpBr.css +0 -1
- package/dist/viewer/assets/index-gucix3xm.js +0 -113
package/dist/cli/init.js
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { dirname, join, relative, sep } from "node:path";
|
|
4
4
|
import { findWorkspaceRoot, nodeFileSystem } from "../core/index.js";
|
|
5
5
|
import { SKILL_NAME, skillStub } from "../guide/index.js";
|
|
6
|
-
/** Where
|
|
6
|
+
/** Where coding agents look for skills; the stub goes into each. */
|
|
7
7
|
export const SKILL_DIRS = [".agents/skills", ".claude/skills", ".github/skills"];
|
|
8
8
|
const STARTER_WORKSPACE = `# The Archidocs Workspace root: Teams and Environments are defined here only.
|
|
9
9
|
# Each Project is a folder below this one holding a project.yaml.
|
|
@@ -58,7 +58,7 @@ export async function init({ repoRoot, cwd, skillOnly, workspace }) {
|
|
|
58
58
|
if (await appendOnce(join(repoRoot, "CLAUDE.md"), pointer, hasPointer, { create: false }))
|
|
59
59
|
wrote(join(repoRoot, "CLAUDE.md"), "Updated");
|
|
60
60
|
const mcpPath = workspace ?? where ?? "<path-to-workspace-checkout>";
|
|
61
|
-
out.push("", "Register the Archidocs MCP server with your agent
|
|
61
|
+
out.push("", "Register the Archidocs MCP server with your coding agent, started from the repo root:", "", ` archidocs mcp --workspace ${mcpPath}`, "", ...(workspaceDir === undefined ? ["Point --workspace at a local checkout of the Workspace repo, relative to where the coding agent starts the server."] : []));
|
|
62
62
|
return out;
|
|
63
63
|
}
|
|
64
64
|
/**
|
package/dist/cli/main.js
CHANGED
|
@@ -3,14 +3,14 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import { cp, mkdir, readFile, realpath, writeFile } from "node:fs/promises";
|
|
4
4
|
import { basename, join, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { findWorkspaceRoot, load, nodeFileSystem,
|
|
6
|
+
import { findWorkspaceRoot, load, nodeFileSystem, resolveView, serializeBundle } from "../core/index.js";
|
|
7
7
|
import { directions, layoutView, renderSequenceSvg, renderSvg, themes } from "../render/index.js";
|
|
8
8
|
import { renderPngInNode } from "../render/node.js";
|
|
9
9
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
10
10
|
import { gitHead, gitTopLevel } from "../git.js";
|
|
11
11
|
import { bundleSource, checkoutSource, createServer, DEFAULT_PORT, serveHttp } from "../mcp/index.js";
|
|
12
12
|
import { authoringGuide } from "../guide/index.js";
|
|
13
|
-
import { parseCommand, usageText } from "./commands.js";
|
|
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";
|
|
@@ -18,10 +18,8 @@ import { diff } from "../core/index.js";
|
|
|
18
18
|
import { bundleAt, buildHistory, DEFAULT_KEEP, defaultBaseBranch, history, previewSides, publishHistory, publishPreview, resolvePoint } from "../history/index.js";
|
|
19
19
|
import { SCHEMA_VERSION } from "../schema/bundle.js";
|
|
20
20
|
import { diffFormats, formatDiff } from "./diff-format.js";
|
|
21
|
-
/** Exit codes: 0 no errors, 1 errors found (or any warning with `--strict`), 2 could not run. */
|
|
22
|
-
const OK =
|
|
23
|
-
const FOUND_ERRORS = 1;
|
|
24
|
-
const COULD_NOT_RUN = 2;
|
|
21
|
+
/** Exit codes, shared with the command definitions that document them: 0 no errors, 1 errors found (or any warning with `--strict`), 2 could not run. */
|
|
22
|
+
const { ok: OK, foundErrors: FOUND_ERRORS, couldNotRun: COULD_NOT_RUN } = EXIT;
|
|
25
23
|
class UsageError extends Error {
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
@@ -181,31 +179,28 @@ async function main(argv) {
|
|
|
181
179
|
}
|
|
182
180
|
const workspace = await workspaceName(root);
|
|
183
181
|
const fileName = (id) => `${id.replace(/[/:]/g, "-")}.${format}`;
|
|
184
|
-
/** Lays out and draws one View; `--direction` wins over a Saved View's own. */
|
|
185
182
|
const source = { workspace, commit: bundle.commit, date: bundle.builtAt };
|
|
186
183
|
const write = async (svg, out) => {
|
|
187
184
|
await writeFile(resolve(out), format === "svg" ? svg : await renderPngInNode(svg));
|
|
188
185
|
process.stdout.write(`Wrote ${out}\n`);
|
|
189
186
|
};
|
|
190
|
-
/** Lays out and draws one View: a Dynamic View as a sequence chart, any other as a diagram. */
|
|
187
|
+
/** Lays out and draws one View: a Dynamic View as a sequence chart, any other as a diagram; `--direction` wins over the View's own. */
|
|
191
188
|
const draw = async (view, out) => {
|
|
192
189
|
if (view.kind === "dynamic")
|
|
193
190
|
return write(renderSequenceSvg({ bundle, view, source, theme, label }), out);
|
|
194
|
-
const
|
|
195
|
-
const layout = await layoutView(view, chosen === undefined ? {} : { direction: chosen });
|
|
191
|
+
const layout = await layoutView(view, direction === undefined ? {} : { direction });
|
|
196
192
|
await write(renderSvg({ bundle, view, layout, source, theme, label }), out);
|
|
197
193
|
};
|
|
198
|
-
const resolveAny = (id) => resolveDynamicView(bundle, id) ?? resolveView(bundle, id);
|
|
199
194
|
if (allSaved) {
|
|
200
195
|
await mkdir(resolve(values.out), { recursive: true });
|
|
201
196
|
for (const saved of bundle.views) {
|
|
202
|
-
const view =
|
|
197
|
+
const view = resolveView(bundle, saved.id);
|
|
203
198
|
if (view)
|
|
204
199
|
await draw(view, join(values.out, fileName(saved.id)));
|
|
205
200
|
}
|
|
206
201
|
return OK;
|
|
207
202
|
}
|
|
208
|
-
const view =
|
|
203
|
+
const view = resolveView(bundle, viewId);
|
|
209
204
|
if (!view)
|
|
210
205
|
throw new UsageError(`Unknown View "${viewId}"; Views are c1, c2, c2/<system>, c3/<service with Components>, deployment/<environment> and Saved Views (project:view-id).`);
|
|
211
206
|
await draw(view, values.out ?? fileName(viewId));
|
|
@@ -292,7 +287,7 @@ async function workspaceName(root) {
|
|
|
292
287
|
async function workspaceRoot(start) {
|
|
293
288
|
const root = await findWorkspaceRoot(nodeFileSystem(), start);
|
|
294
289
|
if (!root)
|
|
295
|
-
throw new UsageError(
|
|
290
|
+
throw new UsageError(NO_WORKSPACE);
|
|
296
291
|
return root;
|
|
297
292
|
}
|
|
298
293
|
/** The history of the Workspace found from the current folder; it must be in a git repo. */
|
package/dist/core/compare.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Bundle } from "../schema/bundle.ts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type CompareMark = "added" | "removed" | "changed" | "unchanged";
|
|
2
|
+
/** An item as text, leaving out where it was written. */
|
|
3
|
+
export declare const withoutSource: (item: object) => string;
|
|
5
4
|
/**
|
|
6
5
|
* One Bundle holding everything either side holds, the later side's version
|
|
7
6
|
* where both do, so a View drawn from it keeps removed things in place.
|
|
@@ -9,13 +8,3 @@ export type CompareMark = "added" | "removed" | "changed" | "unchanged";
|
|
|
9
8
|
* at both sides; each lands on the same edge.
|
|
10
9
|
*/
|
|
11
10
|
export declare function unionBundle(before: Bundle, after: Bundle): Bundle;
|
|
12
|
-
/**
|
|
13
|
-
* A View for Compare: laid out over the union of both sides, with every node
|
|
14
|
-
* and edge marked. A node or edge only the later side's View shows is
|
|
15
|
-
* added, one only the earlier side's shows is removed. One both show is
|
|
16
|
-
* changed when its Element changed, or for a collapsed box when anything
|
|
17
|
-
* inside it was added, removed or changed; an edge when its Relationships
|
|
18
|
-
* did. A View that exists at one side only is drawn from that side.
|
|
19
|
-
* Undefined when neither side has the View.
|
|
20
|
-
*/
|
|
21
|
-
export declare function compareView(before: Bundle, after: Bundle, id: string, options?: Pick<ResolveOptions, "expand">): ResolvedView | undefined;
|
package/dist/core/compare.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const withoutSource = (item) => JSON.stringify({ ...item, source: undefined });
|
|
1
|
+
/** An item as text, leaving out where it was written. */
|
|
2
|
+
export const withoutSource = (item) => JSON.stringify({ ...item, source: undefined });
|
|
4
3
|
/** Items of both sides, each once: the later side's where both have it. */
|
|
5
4
|
function union(before, after, key) {
|
|
6
5
|
const keys = new Set(after.map(key));
|
|
@@ -28,35 +27,3 @@ export function unionBundle(before, after) {
|
|
|
28
27
|
adrs: union(before.adrs, after.adrs, byId),
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
|
-
/**
|
|
32
|
-
* A View for Compare: laid out over the union of both sides, with every node
|
|
33
|
-
* and edge marked. A node or edge only the later side's View shows is
|
|
34
|
-
* added, one only the earlier side's shows is removed. One both show is
|
|
35
|
-
* changed when its Element changed, or for a collapsed box when anything
|
|
36
|
-
* inside it was added, removed or changed; an edge when its Relationships
|
|
37
|
-
* did. A View that exists at one side only is drawn from that side.
|
|
38
|
-
* Undefined when neither side has the View.
|
|
39
|
-
*/
|
|
40
|
-
export function compareView(before, after, id, options = {}) {
|
|
41
|
-
const view = resolveView(unionBundle(before, after), id, options);
|
|
42
|
-
if (!view)
|
|
43
|
-
return undefined;
|
|
44
|
-
const [b, a] = [resolveView(before, id, options), resolveView(after, id, options)];
|
|
45
|
-
const changed = new Set(diff(before, after).filter((c) => c.kind === "element").map((c) => c.id));
|
|
46
|
-
const model = new ModelIndex(unionBundle(before, after));
|
|
47
|
-
const holdsChange = (nodeId) => [...changed].some((c) => c !== nodeId && model.ancestry(c).includes(nodeId));
|
|
48
|
-
const sides = (list, key) => [b, a].map((v) => new Map((v ? list(v) : []).map((x) => [key(x), x])));
|
|
49
|
-
const [bNodes, aNodes] = sides((v) => v.nodes, (n) => n.id);
|
|
50
|
-
const edgeKey = (e) => `${e.from}\0${e.to}`;
|
|
51
|
-
const [bEdges, aEdges] = sides((v) => v.edges, edgeKey);
|
|
52
|
-
const mark = (inBefore, inAfter, isChanged) => inAfter && !inBefore ? "added" : inBefore && !inAfter ? "removed" : isChanged() ? "changed" : "unchanged";
|
|
53
|
-
for (const node of view.nodes) {
|
|
54
|
-
node.change = mark(bNodes.has(node.id), aNodes.has(node.id), () => changed.has(node.id) || (node.collapsed && holdsChange(node.id)));
|
|
55
|
-
}
|
|
56
|
-
const relationships = (e) => (e?.relationships.map(withoutSource).sort() ?? []).join("\n");
|
|
57
|
-
for (const edge of view.edges) {
|
|
58
|
-
const key = edgeKey(edge);
|
|
59
|
-
edge.change = mark(bEdges.has(key), aEdges.has(key), () => relationships(bEdges.get(key)) !== relationships(aEdges.get(key)));
|
|
60
|
-
}
|
|
61
|
-
return view;
|
|
62
|
-
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -7,14 +7,11 @@ export { ruleCatalogue } from "./catalogue.ts";
|
|
|
7
7
|
export { deriveEdges, levelOf, type DerivedEdge, type Level } from "./query.ts";
|
|
8
8
|
export { getDeployments, type DeploymentDetail, type TargetStep } from "./deployments.ts";
|
|
9
9
|
export { search, type SearchMatch, type SearchOptions, type MatchRank } from "./search.ts";
|
|
10
|
-
export {
|
|
11
|
-
export { resolveSaved, type SavedResolution, type BadExpand, type UnresolvedPath } from "./saved-views.ts";
|
|
10
|
+
export { resolveView, listViews, pickedView, compareView, saveAsView, stepViews, dynamicViewsUsing, parseViewId, formatViewId, ownViewId, describeLens, type AnyView, type ViewRef, type ViewSummary, type LensChoice, type ResolveOptions, type ResolvedView, type ViewKind, type ListedKind, type ViewNode, type ViewEdge, type NodeMark, type ImpactSide, type ViewDirection, type CompareMark, type SavedResolution, type BadExpand, type UnresolvedPath, type DynamicResolution, type DynamicProblem, type ResolvedDynamicView, type ResolvedStep, type StepKind, type Screen, type SavedScreen, type SavedViewDefinition, } from "./views/index.ts";
|
|
12
11
|
export { findPaths, type PathsResult, type Path, type Hop, type DirectEdge } from "./paths.ts";
|
|
13
12
|
export { getImpact, type ImpactResult, type ImpactRing, type ImpactedElement, type Direction } from "./impact.ts";
|
|
14
13
|
export { listOwned, type OwnedResult, type OwnedGroup, type OwnedItem, type OwnedKind } from "./ownership.ts";
|
|
15
14
|
export { listAdrs, adrsFor, type ListAdrsOptions, type ListedAdr } from "./adrs.ts";
|
|
16
|
-
export { resolveDynamic, resolveDynamicView, takesPart, stepViews, dynamicViewsUsing, type DynamicResolution, type DynamicProblem, type ResolvedDynamicView, type ResolvedStep, type StepKind } from "./dynamic-views.ts";
|
|
17
15
|
export { diff, countChanges, changedIds, changeKinds, type Change, type ChangeKind, type ChangeType, type ChangeItem, type ChangeCounts } from "./diff.ts";
|
|
18
|
-
export {
|
|
19
|
-
export { compareView, unionBundle, type CompareMark } from "./compare.ts";
|
|
16
|
+
export { unionBundle } from "./compare.ts";
|
|
20
17
|
export { resolveScope, scopeMatcher, filterChanges, type HistoryScope, type ScopeResolution } from "./history-scope.ts";
|
package/dist/core/index.js
CHANGED
|
@@ -5,14 +5,11 @@ export { ruleCatalogue } from "./catalogue.js";
|
|
|
5
5
|
export { deriveEdges, levelOf } from "./query.js";
|
|
6
6
|
export { getDeployments } from "./deployments.js";
|
|
7
7
|
export { search } from "./search.js";
|
|
8
|
-
export {
|
|
9
|
-
export { resolveSaved } from "./saved-views.js";
|
|
8
|
+
export { resolveView, listViews, pickedView, compareView, saveAsView, stepViews, dynamicViewsUsing, parseViewId, formatViewId, ownViewId, describeLens, } from "./views/index.js";
|
|
10
9
|
export { findPaths } from "./paths.js";
|
|
11
10
|
export { getImpact } from "./impact.js";
|
|
12
11
|
export { listOwned } from "./ownership.js";
|
|
13
12
|
export { listAdrs, adrsFor } from "./adrs.js";
|
|
14
|
-
export { resolveDynamic, resolveDynamicView, takesPart, stepViews, dynamicViewsUsing } from "./dynamic-views.js";
|
|
15
13
|
export { diff, countChanges, changedIds, changeKinds } from "./diff.js";
|
|
16
|
-
export {
|
|
17
|
-
export { compareView, unionBundle } from "./compare.js";
|
|
14
|
+
export { unionBundle } from "./compare.js";
|
|
18
15
|
export { resolveScope, scopeMatcher, filterChanges } from "./history-scope.js";
|
package/dist/core/rules.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Bundle } from "../schema/bundle.ts";
|
|
2
2
|
import type { Files } from "./files.ts";
|
|
3
3
|
import type { IssueDraft, LoadedWorkspace, Severity } from "./model.ts";
|
|
4
|
+
/** The part of the Model a rule is about, in the order the docs list them. Every rule is in exactly one. */
|
|
5
|
+
export declare const ruleAreas: readonly ["workspace", "elements", "relationships", "deployments", "views", "decisions"];
|
|
6
|
+
export type RuleArea = (typeof ruleAreas)[number];
|
|
4
7
|
/**
|
|
5
8
|
* A check rule. Its examples are small Workspaces (paths relative to the
|
|
6
9
|
* Workspace root): `failing` triggers the rule, `passing` is the same
|
|
@@ -9,8 +12,15 @@ import type { IssueDraft, LoadedWorkspace, Severity } from "./model.ts";
|
|
|
9
12
|
export interface RuleDefinition {
|
|
10
13
|
id: string;
|
|
11
14
|
severity: Severity;
|
|
15
|
+
area: RuleArea;
|
|
16
|
+
/** The release that first shipped the rule, such as `"1.0.0"`. */
|
|
17
|
+
since: `${number}.${number}.${number}`;
|
|
12
18
|
summary: string;
|
|
19
|
+
/** What goes wrong for a reader of the Model without the rule, in one or two sentences. */
|
|
20
|
+
why: string;
|
|
13
21
|
fix: string;
|
|
22
|
+
/** Other rules worth reading with this one, by id. */
|
|
23
|
+
related?: readonly string[];
|
|
14
24
|
example: {
|
|
15
25
|
failing: Files;
|
|
16
26
|
passing: Files;
|