archmantic 1.0.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/LICENSE +202 -0
- package/README.md +172 -0
- package/dist/agent.d.ts +20 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +239 -0
- package/dist/agent.js.map +1 -0
- package/dist/analyze/datamodel.d.ts +9 -0
- package/dist/analyze/datamodel.d.ts.map +1 -0
- package/dist/analyze/datamodel.js +19 -0
- package/dist/analyze/datamodel.js.map +1 -0
- package/dist/analyze/derive.d.ts +21 -0
- package/dist/analyze/derive.d.ts.map +1 -0
- package/dist/analyze/derive.js +211 -0
- package/dist/analyze/derive.js.map +1 -0
- package/dist/analyze/drizzle.d.ts +3 -0
- package/dist/analyze/drizzle.d.ts.map +1 -0
- package/dist/analyze/drizzle.js +83 -0
- package/dist/analyze/drizzle.js.map +1 -0
- package/dist/analyze/endpoints.d.ts +3 -0
- package/dist/analyze/endpoints.d.ts.map +1 -0
- package/dist/analyze/endpoints.js +167 -0
- package/dist/analyze/endpoints.js.map +1 -0
- package/dist/analyze/fs-util.d.ts +3 -0
- package/dist/analyze/fs-util.d.ts.map +1 -0
- package/dist/analyze/fs-util.js +44 -0
- package/dist/analyze/fs-util.js.map +1 -0
- package/dist/analyze/incremental.d.ts +12 -0
- package/dist/analyze/incremental.d.ts.map +1 -0
- package/dist/analyze/incremental.js +102 -0
- package/dist/analyze/incremental.js.map +1 -0
- package/dist/analyze/index.d.ts +5 -0
- package/dist/analyze/index.d.ts.map +1 -0
- package/dist/analyze/index.js +49 -0
- package/dist/analyze/index.js.map +1 -0
- package/dist/analyze/parse-util.d.ts +10 -0
- package/dist/analyze/parse-util.d.ts.map +1 -0
- package/dist/analyze/parse-util.js +47 -0
- package/dist/analyze/parse-util.js.map +1 -0
- package/dist/analyze/prisma.d.ts +4 -0
- package/dist/analyze/prisma.d.ts.map +1 -0
- package/dist/analyze/prisma.js +97 -0
- package/dist/analyze/prisma.js.map +1 -0
- package/dist/analyze/sql.d.ts +3 -0
- package/dist/analyze/sql.d.ts.map +1 -0
- package/dist/analyze/sql.js +110 -0
- package/dist/analyze/sql.js.map +1 -0
- package/dist/analyze/stack.d.ts +4 -0
- package/dist/analyze/stack.d.ts.map +1 -0
- package/dist/analyze/stack.js +94 -0
- package/dist/analyze/stack.js.map +1 -0
- package/dist/analyze/tier0.d.ts +7 -0
- package/dist/analyze/tier0.d.ts.map +1 -0
- package/dist/analyze/tier0.js +57 -0
- package/dist/analyze/tier0.js.map +1 -0
- package/dist/analyze/tier1.d.ts +13 -0
- package/dist/analyze/tier1.d.ts.map +1 -0
- package/dist/analyze/tier1.js +144 -0
- package/dist/analyze/tier1.js.map +1 -0
- package/dist/analyze/tier2.d.ts +14 -0
- package/dist/analyze/tier2.d.ts.map +1 -0
- package/dist/analyze/tier2.js +231 -0
- package/dist/analyze/tier2.js.map +1 -0
- package/dist/analyze/walk.d.ts +3 -0
- package/dist/analyze/walk.d.ts.map +1 -0
- package/dist/analyze/walk.js +50 -0
- package/dist/analyze/walk.js.map +1 -0
- package/dist/auth.d.ts +12 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +61 -0
- package/dist/auth.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +787 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud/api.d.ts +20 -0
- package/dist/cloud/api.d.ts.map +1 -0
- package/dist/cloud/api.js +81 -0
- package/dist/cloud/api.js.map +1 -0
- package/dist/cloud/index.d.ts +4 -0
- package/dist/cloud/index.d.ts.map +1 -0
- package/dist/cloud/index.js +20 -0
- package/dist/cloud/index.js.map +1 -0
- package/dist/cloud/store.d.ts +34 -0
- package/dist/cloud/store.d.ts.map +1 -0
- package/dist/cloud/store.js +137 -0
- package/dist/cloud/store.js.map +1 -0
- package/dist/diff/history.d.ts +9 -0
- package/dist/diff/history.d.ts.map +1 -0
- package/dist/diff/history.js +44 -0
- package/dist/diff/history.js.map +1 -0
- package/dist/diff/index.d.ts +5 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +26 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/diff/model-diff.d.ts +44 -0
- package/dist/diff/model-diff.d.ts.map +1 -0
- package/dist/diff/model-diff.js +153 -0
- package/dist/diff/model-diff.js.map +1 -0
- package/dist/diff/snapshot.d.ts +8 -0
- package/dist/diff/snapshot.d.ts.map +1 -0
- package/dist/diff/snapshot.js +50 -0
- package/dist/diff/snapshot.js.map +1 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +44 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/naming.d.ts +12 -0
- package/dist/ir/naming.d.ts.map +1 -0
- package/dist/ir/naming.js +31 -0
- package/dist/ir/naming.js.map +1 -0
- package/dist/ir/types.d.ts +149 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/ir/types.js +72 -0
- package/dist/ir/types.js.map +1 -0
- package/dist/mcp/bench.d.ts +25 -0
- package/dist/mcp/bench.d.ts.map +1 -0
- package/dist/mcp/bench.js +115 -0
- package/dist/mcp/bench.js.map +1 -0
- package/dist/mcp/queries.d.ts +22 -0
- package/dist/mcp/queries.d.ts.map +1 -0
- package/dist/mcp/queries.js +147 -0
- package/dist/mcp/queries.js.map +1 -0
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +147 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/usage.d.ts +23 -0
- package/dist/mcp/usage.d.ts.map +1 -0
- package/dist/mcp/usage.js +125 -0
- package/dist/mcp/usage.js.map +1 -0
- package/dist/project/bpmn-parse.d.ts +17 -0
- package/dist/project/bpmn-parse.d.ts.map +1 -0
- package/dist/project/bpmn-parse.js +60 -0
- package/dist/project/bpmn-parse.js.map +1 -0
- package/dist/project/bpmn.d.ts +11 -0
- package/dist/project/bpmn.d.ts.map +1 -0
- package/dist/project/bpmn.js +89 -0
- package/dist/project/bpmn.js.map +1 -0
- package/dist/project/capability.d.ts +16 -0
- package/dist/project/capability.d.ts.map +1 -0
- package/dist/project/capability.js +38 -0
- package/dist/project/capability.js.map +1 -0
- package/dist/project/erd.d.ts +17 -0
- package/dist/project/erd.d.ts.map +1 -0
- package/dist/project/erd.js +0 -0
- package/dist/project/erd.js.map +1 -0
- package/dist/project/html.d.ts +12 -0
- package/dist/project/html.d.ts.map +1 -0
- package/dist/project/html.js +166 -0
- package/dist/project/html.js.map +1 -0
- package/dist/project/index.d.ts +19 -0
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +113 -0
- package/dist/project/index.js.map +1 -0
- package/dist/project/mermaid.d.ts +20 -0
- package/dist/project/mermaid.d.ts.map +1 -0
- package/dist/project/mermaid.js +89 -0
- package/dist/project/mermaid.js.map +1 -0
- package/dist/project/spec.d.ts +69 -0
- package/dist/project/spec.d.ts.map +1 -0
- package/dist/project/spec.js +164 -0
- package/dist/project/spec.js.map +1 -0
- package/dist/project/trust.d.ts +35 -0
- package/dist/project/trust.d.ts.map +1 -0
- package/dist/project/trust.js +48 -0
- package/dist/project/trust.js.map +1 -0
- package/dist/system.d.ts +61 -0
- package/dist/system.d.ts.map +1 -0
- package/dist/system.js +161 -0
- package/dist/system.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.diffModels = diffModels;
|
|
4
|
+
exports.hasChanges = hasChanges;
|
|
5
|
+
exports.summarizeChange = summarizeChange;
|
|
6
|
+
exports.renderDiffText = renderDiffText;
|
|
7
|
+
exports.renderDiffMarkdown = renderDiffMarkdown;
|
|
8
|
+
const naming_js_1 = require("../ir/naming.js");
|
|
9
|
+
const firstRef = (el) => el.provenance[0]?.ref;
|
|
10
|
+
/** A short "from → to" label for a dependency relation. */
|
|
11
|
+
function relationLabel(r) {
|
|
12
|
+
const side = (id) => id.startsWith("comp:") ? (0, naming_js_1.componentLabel)(id) : id.startsWith("sys:ext:") ? id.slice("sys:ext:".length) : id;
|
|
13
|
+
return `${side(r.from)} → ${side(r.to)}`;
|
|
14
|
+
}
|
|
15
|
+
function group(model) {
|
|
16
|
+
const components = new Map();
|
|
17
|
+
for (const c of model.components) {
|
|
18
|
+
components.set(c.id, { id: c.id, label: (0, naming_js_1.componentLabel)(c.id), ref: firstRef(c) });
|
|
19
|
+
}
|
|
20
|
+
const dependencies = new Map();
|
|
21
|
+
for (const r of model.relations) {
|
|
22
|
+
dependencies.set(r.id, { id: r.id, label: relationLabel(r), ref: firstRef(r) });
|
|
23
|
+
}
|
|
24
|
+
const externalSystems = new Map();
|
|
25
|
+
for (const s of model.systems) {
|
|
26
|
+
if (s.kind === "external")
|
|
27
|
+
externalSystems.set(s.id, { id: s.id, label: s.name, ref: firstRef(s) });
|
|
28
|
+
}
|
|
29
|
+
const capabilities = new Map();
|
|
30
|
+
for (const cap of model.capabilities) {
|
|
31
|
+
capabilities.set(cap.id, { id: cap.id, label: cap.name, ref: firstRef(cap) });
|
|
32
|
+
}
|
|
33
|
+
return { components, dependencies, externalSystems, capabilities };
|
|
34
|
+
}
|
|
35
|
+
function categoryDiff(base, head) {
|
|
36
|
+
const added = [];
|
|
37
|
+
const removed = [];
|
|
38
|
+
for (const [id, el] of head)
|
|
39
|
+
if (!base.has(id))
|
|
40
|
+
added.push(el);
|
|
41
|
+
for (const [id, el] of base)
|
|
42
|
+
if (!head.has(id))
|
|
43
|
+
removed.push(el);
|
|
44
|
+
const byLabel = (a, b) => a.label.localeCompare(b.label);
|
|
45
|
+
return { added: added.sort(byLabel), removed: removed.sort(byLabel) };
|
|
46
|
+
}
|
|
47
|
+
function diffModels(base, head, baseLabel = "base", headLabel = "head") {
|
|
48
|
+
const b = group(base);
|
|
49
|
+
const h = group(head);
|
|
50
|
+
const components = categoryDiff(b.components, h.components);
|
|
51
|
+
const dependencies = categoryDiff(b.dependencies, h.dependencies);
|
|
52
|
+
const externalSystems = categoryDiff(b.externalSystems, h.externalSystems);
|
|
53
|
+
const capabilities = categoryDiff(b.capabilities, h.capabilities);
|
|
54
|
+
const cats = [components, dependencies, externalSystems, capabilities];
|
|
55
|
+
const changedCount = cats.reduce((n, c) => n + c.added.length + c.removed.length, 0);
|
|
56
|
+
const unionIds = new Set();
|
|
57
|
+
for (const m of [b, h]) {
|
|
58
|
+
for (const map of [m.components, m.dependencies, m.externalSystems, m.capabilities]) {
|
|
59
|
+
for (const id of map.keys())
|
|
60
|
+
unionIds.add(id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const totalCount = unionIds.size;
|
|
64
|
+
const driftPct = totalCount === 0 ? 0 : Math.round((changedCount / totalCount) * 1000) / 10;
|
|
65
|
+
return {
|
|
66
|
+
baseLabel,
|
|
67
|
+
headLabel,
|
|
68
|
+
components,
|
|
69
|
+
dependencies,
|
|
70
|
+
externalSystems,
|
|
71
|
+
capabilities,
|
|
72
|
+
changedCount,
|
|
73
|
+
totalCount,
|
|
74
|
+
driftPct,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function hasChanges(diff) {
|
|
78
|
+
return diff.changedCount > 0;
|
|
79
|
+
}
|
|
80
|
+
/** One-line summary like "+3 components, +12 deps, -1 capabilities". */
|
|
81
|
+
function summarizeChange(d) {
|
|
82
|
+
const parts = [];
|
|
83
|
+
const add = (cat, label) => {
|
|
84
|
+
if (d[cat].added.length)
|
|
85
|
+
parts.push(`+${d[cat].added.length} ${label}`);
|
|
86
|
+
if (d[cat].removed.length)
|
|
87
|
+
parts.push(`-${d[cat].removed.length} ${label}`);
|
|
88
|
+
};
|
|
89
|
+
add("components", "components");
|
|
90
|
+
add("dependencies", "deps");
|
|
91
|
+
add("externalSystems", "ext");
|
|
92
|
+
add("capabilities", "capabilities");
|
|
93
|
+
return parts.length ? parts.join(", ") : "no architecture change";
|
|
94
|
+
}
|
|
95
|
+
// ── Renderers ───────────────────────────────────────────────────────────────
|
|
96
|
+
const CATEGORY_TITLES = [
|
|
97
|
+
["components", "Components"],
|
|
98
|
+
["dependencies", "Dependencies"],
|
|
99
|
+
["externalSystems", "External systems"],
|
|
100
|
+
["capabilities", "Capabilities"],
|
|
101
|
+
];
|
|
102
|
+
const GREEN = "\x1b[32m";
|
|
103
|
+
const RED = "\x1b[31m";
|
|
104
|
+
const DIM = "\x1b[2m";
|
|
105
|
+
const BOLD = "\x1b[1m";
|
|
106
|
+
const RESET = "\x1b[0m";
|
|
107
|
+
/** Terminal-friendly diff report. */
|
|
108
|
+
function renderDiffText(diff) {
|
|
109
|
+
const out = [];
|
|
110
|
+
const verdict = diff.driftPct === 0 ? "in sync ✓" : `${diff.driftPct}% drift`;
|
|
111
|
+
out.push(`${BOLD}Architecture diff${RESET} ${DIM}${diff.baseLabel} → ${diff.headLabel}${RESET}`);
|
|
112
|
+
out.push(`${diff.changedCount} change${diff.changedCount === 1 ? "" : "s"} across ${diff.totalCount} elements — ${verdict}`);
|
|
113
|
+
for (const [key, title] of CATEGORY_TITLES) {
|
|
114
|
+
const cat = diff[key];
|
|
115
|
+
if (!cat.added.length && !cat.removed.length)
|
|
116
|
+
continue;
|
|
117
|
+
out.push(`\n${BOLD}${title}${RESET}`);
|
|
118
|
+
for (const el of cat.added)
|
|
119
|
+
out.push(` ${GREEN}+ ${el.label}${RESET}${el.ref ? ` ${DIM}(${el.ref})${RESET}` : ""}`);
|
|
120
|
+
for (const el of cat.removed)
|
|
121
|
+
out.push(` ${RED}- ${el.label}${RESET}${el.ref ? ` ${DIM}(${el.ref})${RESET}` : ""}`);
|
|
122
|
+
}
|
|
123
|
+
if (diff.changedCount === 0)
|
|
124
|
+
out.push(`\n${DIM}No architecture-level changes.${RESET}`);
|
|
125
|
+
return out.join("\n");
|
|
126
|
+
}
|
|
127
|
+
/** Markdown report — ready to post as a PR comment ("architecture code review"). */
|
|
128
|
+
function renderDiffMarkdown(diff) {
|
|
129
|
+
const out = [];
|
|
130
|
+
const verdict = diff.driftPct === 0 ? "**in sync** ✅" : `**${diff.driftPct}% architecture drift**`;
|
|
131
|
+
out.push(`## 🏛️ Architecture diff — \`${diff.baseLabel}\` → \`${diff.headLabel}\``);
|
|
132
|
+
out.push("");
|
|
133
|
+
out.push(`${diff.changedCount} change${diff.changedCount === 1 ? "" : "s"} across ${diff.totalCount} elements — ${verdict}`);
|
|
134
|
+
for (const [key, title] of CATEGORY_TITLES) {
|
|
135
|
+
const cat = diff[key];
|
|
136
|
+
if (!cat.added.length && !cat.removed.length)
|
|
137
|
+
continue;
|
|
138
|
+
out.push("");
|
|
139
|
+
out.push(`### ${title}`);
|
|
140
|
+
for (const el of cat.added)
|
|
141
|
+
out.push(`- 🟢 **added** ${el.label}${el.ref ? ` <sub>\`${el.ref}\`</sub>` : ""}`);
|
|
142
|
+
for (const el of cat.removed)
|
|
143
|
+
out.push(`- 🔴 **removed** ${el.label}${el.ref ? ` <sub>\`${el.ref}\`</sub>` : ""}`);
|
|
144
|
+
}
|
|
145
|
+
if (diff.changedCount === 0) {
|
|
146
|
+
out.push("");
|
|
147
|
+
out.push("_No architecture-level changes._");
|
|
148
|
+
}
|
|
149
|
+
out.push("");
|
|
150
|
+
out.push(`<sub>Generated by [Archmantic](https://github.com/mgionas/Archmantic) — diffs the grounded architecture model, not lines.</sub>`);
|
|
151
|
+
return out.join("\n");
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=model-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-diff.js","sourceRoot":"","sources":["../../src/diff/model-diff.ts"],"names":[],"mappings":";;AAqFA,gCAqCC;AAED,gCAEC;AAGD,0CAWC;AAkBD,wCAeC;AAGD,gDAsBC;AA5LD,+CAAiD;AA8BjD,MAAM,QAAQ,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IAAI,CAAC,EAAE,CAAC,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAC/C,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACb,GAAG,CAAC,IAAI,CAAC,iIAAiI,CAAC,CAAC;IAC5I,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ArchitectureModel } from "../ir/types.js";
|
|
2
|
+
export declare class GitRefError extends Error {
|
|
3
|
+
}
|
|
4
|
+
/** Resolve a ref to its commit sha, throwing a clear error if it doesn't exist. */
|
|
5
|
+
export declare function resolveRef(root: string, ref: string): string;
|
|
6
|
+
/** Analyze the repo tree at `ref` in isolation. Returns the derived model. */
|
|
7
|
+
export declare function analyzeAtRef(root: string, ref: string): ArchitectureModel;
|
|
8
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/diff/snapshot.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMxD,qBAAa,WAAY,SAAQ,KAAK;CAAG;AAEzC,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAS5D;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAUzE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitRefError = void 0;
|
|
4
|
+
exports.resolveRef = resolveRef;
|
|
5
|
+
exports.analyzeAtRef = analyzeAtRef;
|
|
6
|
+
/**
|
|
7
|
+
* Materialize and analyze the repo *as of a git ref*, without touching the
|
|
8
|
+
* working tree (no checkout/stash). Used by `archmantic diff <ref>` to compare a
|
|
9
|
+
* branch/PR base against the current code at the architecture level.
|
|
10
|
+
*
|
|
11
|
+
* Strategy: `git archive <ref>` streams the committed tree into a temp dir,
|
|
12
|
+
* which we analyze with the normal pipeline, then delete.
|
|
13
|
+
*/
|
|
14
|
+
const node_child_process_1 = require("node:child_process");
|
|
15
|
+
const node_fs_1 = require("node:fs");
|
|
16
|
+
const node_os_1 = require("node:os");
|
|
17
|
+
const node_path_1 = require("node:path");
|
|
18
|
+
const index_js_1 = require("../analyze/index.js");
|
|
19
|
+
/** Conservative allow-list so a ref can never inject into the shell pipe. */
|
|
20
|
+
const SAFE_REF = /^[\w./~^@-]+$/;
|
|
21
|
+
class GitRefError extends Error {
|
|
22
|
+
}
|
|
23
|
+
exports.GitRefError = GitRefError;
|
|
24
|
+
/** Resolve a ref to its commit sha, throwing a clear error if it doesn't exist. */
|
|
25
|
+
function resolveRef(root, ref) {
|
|
26
|
+
if (!SAFE_REF.test(ref))
|
|
27
|
+
throw new GitRefError(`Unsafe git ref: "${ref}"`);
|
|
28
|
+
try {
|
|
29
|
+
return (0, node_child_process_1.execFileSync)("git", ["-C", root, "rev-parse", "--verify", "--quiet", `${ref}^{commit}`], {
|
|
30
|
+
encoding: "utf8",
|
|
31
|
+
}).trim();
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
throw new GitRefError(`Unknown git ref: "${ref}" (no such commit/branch/tag).`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Analyze the repo tree at `ref` in isolation. Returns the derived model. */
|
|
38
|
+
function analyzeAtRef(root, ref) {
|
|
39
|
+
resolveRef(root, ref); // validates + ensures it exists
|
|
40
|
+
const tmp = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), "archmantic-"));
|
|
41
|
+
try {
|
|
42
|
+
// ref is validated against SAFE_REF; tmp comes from mkdtemp (no spaces).
|
|
43
|
+
(0, node_child_process_1.execSync)(`git -C "${root}" archive --format=tar ${ref} | tar -x -C "${tmp}"`, { stdio: "ignore" });
|
|
44
|
+
return (0, index_js_1.analyzeRepo)(tmp);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
(0, node_fs_1.rmSync)(tmp, { recursive: true, force: true });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/diff/snapshot.ts"],"names":[],"mappings":";;;AAqBA,gCASC;AAGD,oCAUC;AA3CD;;;;;;;GAOG;AACH,2DAA4D;AAC5D,qCAA8C;AAC9C,qCAAiC;AACjC,yCAAiC;AAEjC,kDAAkD;AAElD,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,eAAe,CAAC;AAEjC,MAAa,WAAY,SAAQ,KAAK;CAAG;AAAzC,kCAAyC;AAEzC,mFAAmF;AACnF,SAAgB,UAAU,CAAC,IAAY,EAAE,GAAW;IAClD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,oBAAoB,GAAG,GAAG,CAAC,CAAC;IAC3E,IAAI,CAAC;QACH,OAAO,IAAA,iCAAY,EAAC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,GAAG,WAAW,CAAC,EAAE;YAC9F,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,WAAW,CAAC,qBAAqB,GAAG,gCAAgC,CAAC,CAAC;IAClF,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,gCAAgC;IACvD,MAAM,GAAG,GAAG,IAAA,qBAAW,EAAC,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC;QACH,yEAAyE;QACzE,IAAA,6BAAQ,EAAC,WAAW,IAAI,0BAA0B,GAAG,iBAAiB,GAAG,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACnG,OAAO,IAAA,sBAAW,EAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;YAAS,CAAC;QACT,IAAA,gBAAM,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAWA,wBAAgB,OAAO,CAAC,IAAI,GAAE,MAAsB,GAAG,IAAI,CA0B1D"}
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadEnv = loadEnv;
|
|
4
|
+
/**
|
|
5
|
+
* Minimal, zero-dependency `.env` loader (BYOK). Reads `.env.local` then `.env`
|
|
6
|
+
* into `process.env` without overriding variables already set in the real
|
|
7
|
+
* environment. `.env.local` wins over `.env`; both lose to the actual shell env.
|
|
8
|
+
*
|
|
9
|
+
* Keeps the local CLI dependency-light — no `dotenv`. Secrets (ANTHROPIC_API_KEY,
|
|
10
|
+
* DATABASE_URL) live in the gitignored `.env.local`.
|
|
11
|
+
*/
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
|
+
function loadEnv(root = process.cwd()) {
|
|
15
|
+
for (const name of [".env.local", ".env"]) {
|
|
16
|
+
const path = (0, node_path_1.join)(root, name);
|
|
17
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
18
|
+
continue;
|
|
19
|
+
let text;
|
|
20
|
+
try {
|
|
21
|
+
text = (0, node_fs_1.readFileSync)(path, "utf8");
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
for (const raw of text.split("\n")) {
|
|
27
|
+
const line = raw.trim();
|
|
28
|
+
if (!line || line.startsWith("#"))
|
|
29
|
+
continue;
|
|
30
|
+
const eq = line.indexOf("=");
|
|
31
|
+
if (eq === -1)
|
|
32
|
+
continue;
|
|
33
|
+
const key = line.slice(0, eq).trim();
|
|
34
|
+
let val = line.slice(eq + 1).trim();
|
|
35
|
+
if ((val.startsWith('"') && val.endsWith('"')) ||
|
|
36
|
+
(val.startsWith("'") && val.endsWith("'"))) {
|
|
37
|
+
val = val.slice(1, -1);
|
|
38
|
+
}
|
|
39
|
+
if (!(key in process.env))
|
|
40
|
+
process.env[key] = val;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";;AAWA,0BA0BC;AArCD;;;;;;;GAOG;AACH,qCAAmD;AACnD,yCAAiC;AAEjC,SAAgB,OAAO,CAAC,OAAe,OAAO,CAAC,GAAG,EAAE;IAClD,KAAK,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAA,oBAAU,EAAC,IAAI,CAAC;YAAE,SAAS;QAChC,IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACH,IAAI,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,SAAS;YAC5C,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,EAAE,KAAK,CAAC,CAAC;gBAAE,SAAS;YACxB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACrC,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YACpC,IACE,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC1C,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAC1C,CAAC;gBACD,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACzB,CAAC;YACD,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QACpD,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Archmantic — library entry point.
|
|
3
|
+
* An always-on Solution Architect: a living, provenance-grounded architecture
|
|
4
|
+
* model that serves both humans (visual diagrams) and AI agents (via MCP).
|
|
5
|
+
*/
|
|
6
|
+
export * from "./ir/types";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Archmantic — library entry point.
|
|
19
|
+
* An always-on Solution Architect: a living, provenance-grounded architecture
|
|
20
|
+
* model that serves both humans (visual diagrams) and AI agents (via MCP).
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("./ir/types"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,6CAA2B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-name helpers, shared by analysis (derivation) and projection so the
|
|
3
|
+
* same element reads identically everywhere. Pure string functions, no deps.
|
|
4
|
+
*/
|
|
5
|
+
/** `analyzeRepo` → "Analyze repo", `tier1` → "Tier 1". */
|
|
6
|
+
export declare function humanize(raw: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* A readable label for a component id or repo-relative path. `index` files take
|
|
9
|
+
* their folder's name so `src/analyze/index.ts` reads "Analyze", not "Index".
|
|
10
|
+
*/
|
|
11
|
+
export declare function componentLabel(idOrRel: string): string;
|
|
12
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/ir/naming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ5C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMtD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Display-name helpers, shared by analysis (derivation) and projection so the
|
|
4
|
+
* same element reads identically everywhere. Pure string functions, no deps.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.humanize = humanize;
|
|
8
|
+
exports.componentLabel = componentLabel;
|
|
9
|
+
/** `analyzeRepo` → "Analyze repo", `tier1` → "Tier 1". */
|
|
10
|
+
function humanize(raw) {
|
|
11
|
+
const stem = raw.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/, "").split("/").pop() ?? raw;
|
|
12
|
+
const words = stem
|
|
13
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
14
|
+
.replace(/([A-Za-z])([0-9])/g, "$1 $2")
|
|
15
|
+
.replace(/[_-]+/g, " ")
|
|
16
|
+
.trim();
|
|
17
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A readable label for a component id or repo-relative path. `index` files take
|
|
21
|
+
* their folder's name so `src/analyze/index.ts` reads "Analyze", not "Index".
|
|
22
|
+
*/
|
|
23
|
+
function componentLabel(idOrRel) {
|
|
24
|
+
const rel = idOrRel.startsWith("comp:") ? idOrRel.slice("comp:".length) : idOrRel;
|
|
25
|
+
const parts = rel.split("/");
|
|
26
|
+
const stem = (parts[parts.length - 1] ?? rel).replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/, "");
|
|
27
|
+
if (stem === "index" && parts.length >= 2)
|
|
28
|
+
return humanize(parts[parts.length - 2]);
|
|
29
|
+
return humanize(stem);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../../src/ir/naming.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAGH,4BAQC;AAMD,wCAMC;AArBD,0DAA0D;AAC1D,SAAgB,QAAQ,CAAC,GAAW;IAClC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC;IACnF,MAAM,KAAK,GAAG,IAAI;SACf,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,IAAI,EAAE,CAAC;IACV,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,OAAe;IAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAClF,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;IACxF,IAAI,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,CAAC;IACrF,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Archmantic — the Architecture Model (IR).
|
|
3
|
+
*
|
|
4
|
+
* The IR is the product. Diagrams (context / sequence / BPMN) are *projections*
|
|
5
|
+
* of this model; the MCP server answers queries over it. See docs/ARCHITECTURE.md §2.
|
|
6
|
+
*
|
|
7
|
+
* Design invariant: every derived element carries `provenance` (where it came
|
|
8
|
+
* from) and `confidence` (how sure we are). Human-authored elements use
|
|
9
|
+
* provenance `{ source: "human" }`. Nothing derived is allowed in without a ref.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SCHEMA_VERSION: "0.1.0";
|
|
12
|
+
/** Where a piece of the model was derived from. */
|
|
13
|
+
export type SourceKind = "repo" | "code" | "runtime" | "docs" | "human";
|
|
14
|
+
/** A single grounding for an element: which source, which exact reference. */
|
|
15
|
+
export interface Provenance {
|
|
16
|
+
source: SourceKind;
|
|
17
|
+
/** e.g. "src/pay/charge.ts:42", a commit sha, a trace id, or "manual-edit". */
|
|
18
|
+
ref: string;
|
|
19
|
+
/** Confidence contributed by this specific source, 0..1. */
|
|
20
|
+
confidence?: number;
|
|
21
|
+
}
|
|
22
|
+
/** 0..1 — drives the trust surface and tier escalation (low → analyze deeper). */
|
|
23
|
+
export type Confidence = number;
|
|
24
|
+
interface ElementBase {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
/** Required on derived elements; `[{ source: "human" }]` for hand edits. */
|
|
29
|
+
provenance: Provenance[];
|
|
30
|
+
/** Aggregate confidence for the element, 0..1. */
|
|
31
|
+
confidence: Confidence;
|
|
32
|
+
}
|
|
33
|
+
export interface System extends ElementBase {
|
|
34
|
+
kind: "internal" | "external";
|
|
35
|
+
}
|
|
36
|
+
export interface Component extends ElementBase {
|
|
37
|
+
/** service | module | package | layer | etc. — kept open for now. */
|
|
38
|
+
kind: string;
|
|
39
|
+
/** id of the System this belongs to. */
|
|
40
|
+
systemId?: string;
|
|
41
|
+
/** One-line statement of what this component is responsible for. */
|
|
42
|
+
responsibility?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface Actor extends ElementBase {
|
|
45
|
+
kind: "user" | "external_system" | "scheduler" | "other";
|
|
46
|
+
}
|
|
47
|
+
export type RelationKind = "calls" | "depends_on" | "publishes_to" | "subscribes_to" | "reads" | "writes";
|
|
48
|
+
export interface Relation extends ElementBase {
|
|
49
|
+
from: string;
|
|
50
|
+
to: string;
|
|
51
|
+
kind: RelationKind;
|
|
52
|
+
}
|
|
53
|
+
export interface FlowStep {
|
|
54
|
+
/** participant element id (component/actor/system). */
|
|
55
|
+
participant: string;
|
|
56
|
+
/** what happens at this step. */
|
|
57
|
+
action: string;
|
|
58
|
+
/** optional target participant id (for a message/call). */
|
|
59
|
+
to?: string;
|
|
60
|
+
provenance: Provenance[];
|
|
61
|
+
}
|
|
62
|
+
/** An ordered sequence — projects to a sequence diagram. */
|
|
63
|
+
export interface Flow extends ElementBase {
|
|
64
|
+
participants: string[];
|
|
65
|
+
steps: FlowStep[];
|
|
66
|
+
}
|
|
67
|
+
/** A business process — projects to BPMN 2.0. */
|
|
68
|
+
export interface Process extends ElementBase {
|
|
69
|
+
/** kept loose for v0; will gain tasks/gateways/events/lanes. */
|
|
70
|
+
tasks: {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
provenance: Provenance[];
|
|
74
|
+
}[];
|
|
75
|
+
}
|
|
76
|
+
/** A plain-English feature/capability — the "what can this system do?" layer. */
|
|
77
|
+
export interface Capability extends ElementBase {
|
|
78
|
+
/** ids of components that implement this capability. */
|
|
79
|
+
componentIds: string[];
|
|
80
|
+
}
|
|
81
|
+
/** A detected technology/framework — the "what is this built with?" layer. */
|
|
82
|
+
export interface Technology extends ElementBase {
|
|
83
|
+
/** framework | ui | database | orm | auth | ai | testing | build | language | infra | library */
|
|
84
|
+
category: string;
|
|
85
|
+
}
|
|
86
|
+
/** One column/field on a DataEntity. */
|
|
87
|
+
export interface DataField {
|
|
88
|
+
name: string;
|
|
89
|
+
/** scalar type (String, Int, DateTime…), an enum name, or a related entity's name. */
|
|
90
|
+
type: string;
|
|
91
|
+
/** nullable. */
|
|
92
|
+
optional?: boolean;
|
|
93
|
+
/** to-many (array). */
|
|
94
|
+
list?: boolean;
|
|
95
|
+
/** part of the primary key. */
|
|
96
|
+
isId?: boolean;
|
|
97
|
+
/** has a uniqueness constraint. */
|
|
98
|
+
isUnique?: boolean;
|
|
99
|
+
/** set when this field is a relation to another entity — the target entity id. */
|
|
100
|
+
relationTo?: string;
|
|
101
|
+
/** scalar foreign-key column (named in a relation's `fields: [...]`). */
|
|
102
|
+
isForeignKey?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/** A persisted data model entity (DB table / ORM model) — projects to an ERD. */
|
|
105
|
+
export interface DataEntity extends ElementBase {
|
|
106
|
+
fields: DataField[];
|
|
107
|
+
}
|
|
108
|
+
/** An API endpoint — the contract layer (REST route, tRPC procedure, GraphQL field). */
|
|
109
|
+
export interface Endpoint extends ElementBase {
|
|
110
|
+
/** HTTP verb (GET/POST/PUT/PATCH/DELETE…) or QUERY/MUTATION/SUBSCRIPTION. */
|
|
111
|
+
method: string;
|
|
112
|
+
/** Route path (REST) or operation name (tRPC/GraphQL). */
|
|
113
|
+
path: string;
|
|
114
|
+
protocol: "rest" | "trpc" | "graphql";
|
|
115
|
+
}
|
|
116
|
+
/** The whole model for one project. */
|
|
117
|
+
export interface ArchitectureModel {
|
|
118
|
+
schemaVersion: typeof SCHEMA_VERSION;
|
|
119
|
+
project: string;
|
|
120
|
+
/** ISO timestamp; stamped by the caller (kept out of pure helpers). */
|
|
121
|
+
generatedAt?: string;
|
|
122
|
+
/** Optional: the multi-repo system this project belongs to (from config). */
|
|
123
|
+
system?: string;
|
|
124
|
+
/** Optional: sibling services this project calls (declared in config). */
|
|
125
|
+
consumes?: string[];
|
|
126
|
+
systems: System[];
|
|
127
|
+
components: Component[];
|
|
128
|
+
actors: Actor[];
|
|
129
|
+
relations: Relation[];
|
|
130
|
+
flows: Flow[];
|
|
131
|
+
processes: Process[];
|
|
132
|
+
capabilities: Capability[];
|
|
133
|
+
technologies: Technology[];
|
|
134
|
+
dataEntities: DataEntity[];
|
|
135
|
+
endpoints: Endpoint[];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Canonical ordering for serialization: sort element arrays by id so a full
|
|
139
|
+
* `analyze` and an incremental `update` produce byte-identical `model.json` for
|
|
140
|
+
* identical code — keeping the committed IR churn-free and PR diffs clean.
|
|
141
|
+
* Process/flow internal order (tasks, steps) is meaningful, so it's preserved.
|
|
142
|
+
*/
|
|
143
|
+
export declare function sortModel(m: ArchitectureModel): ArchitectureModel;
|
|
144
|
+
/** Canonical, byte-stable serialization of a model for writing to disk. */
|
|
145
|
+
export declare function serializeModel(m: ArchitectureModel): string;
|
|
146
|
+
/** A fresh, empty model for `archmantic init`. */
|
|
147
|
+
export declare function createEmptyModel(project: string): ArchitectureModel;
|
|
148
|
+
export {};
|
|
149
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ir/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC;AAE/C,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAExE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,CAAC;IACnB,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,kDAAkD;IAClD,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,MAAO,SAAQ,WAAW;IACzC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;CAC/B;AAED,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,KAAM,SAAQ,WAAW;IACxC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,WAAW,GAAG,OAAO,CAAC;CAC1D;AAED,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,YAAY,GACZ,cAAc,GACd,eAAe,GACf,OAAO,GAC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,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAenE"}
|
package/dist/ir/types.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Archmantic — the Architecture Model (IR).
|
|
4
|
+
*
|
|
5
|
+
* The IR is the product. Diagrams (context / sequence / BPMN) are *projections*
|
|
6
|
+
* of this model; the MCP server answers queries over it. See docs/ARCHITECTURE.md §2.
|
|
7
|
+
*
|
|
8
|
+
* Design invariant: every derived element carries `provenance` (where it came
|
|
9
|
+
* from) and `confidence` (how sure we are). Human-authored elements use
|
|
10
|
+
* provenance `{ source: "human" }`. Nothing derived is allowed in without a ref.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.SCHEMA_VERSION = void 0;
|
|
14
|
+
exports.sortModel = sortModel;
|
|
15
|
+
exports.serializeModel = serializeModel;
|
|
16
|
+
exports.createEmptyModel = createEmptyModel;
|
|
17
|
+
exports.SCHEMA_VERSION = "0.1.0";
|
|
18
|
+
/**
|
|
19
|
+
* Canonical ordering for serialization: sort element arrays by id so a full
|
|
20
|
+
* `analyze` and an incremental `update` produce byte-identical `model.json` for
|
|
21
|
+
* identical code — keeping the committed IR churn-free and PR diffs clean.
|
|
22
|
+
* Process/flow internal order (tasks, steps) is meaningful, so it's preserved.
|
|
23
|
+
*/
|
|
24
|
+
function sortModel(m) {
|
|
25
|
+
const byId = (a, b) => a.id.localeCompare(b.id);
|
|
26
|
+
return {
|
|
27
|
+
...m,
|
|
28
|
+
systems: [...m.systems].sort(byId),
|
|
29
|
+
components: [...m.components].sort(byId),
|
|
30
|
+
actors: [...m.actors].sort(byId),
|
|
31
|
+
relations: [...m.relations].sort(byId),
|
|
32
|
+
capabilities: [...m.capabilities].sort(byId),
|
|
33
|
+
technologies: [...m.technologies].sort(byId),
|
|
34
|
+
dataEntities: [...m.dataEntities].sort(byId),
|
|
35
|
+
endpoints: [...m.endpoints].sort(byId),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Recursively sort object keys so serialization is byte-stable regardless of
|
|
39
|
+
* source — a fresh analyze, an incremental patch, or a DB round-trip (Postgres
|
|
40
|
+
* JSONB reorders keys). Combined with sortModel's array ordering, this makes
|
|
41
|
+
* `model.json` deterministic → churn-free committed IR. */
|
|
42
|
+
function sortKeys(value) {
|
|
43
|
+
if (Array.isArray(value))
|
|
44
|
+
return value.map(sortKeys);
|
|
45
|
+
if (value && typeof value === "object") {
|
|
46
|
+
const obj = value;
|
|
47
|
+
return Object.fromEntries(Object.keys(obj).sort().map((k) => [k, sortKeys(obj[k])]));
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
/** Canonical, byte-stable serialization of a model for writing to disk. */
|
|
52
|
+
function serializeModel(m) {
|
|
53
|
+
return JSON.stringify(sortKeys(sortModel(m)), null, 2) + "\n";
|
|
54
|
+
}
|
|
55
|
+
/** A fresh, empty model for `archmantic init`. */
|
|
56
|
+
function createEmptyModel(project) {
|
|
57
|
+
return {
|
|
58
|
+
schemaVersion: exports.SCHEMA_VERSION,
|
|
59
|
+
project,
|
|
60
|
+
systems: [],
|
|
61
|
+
components: [],
|
|
62
|
+
actors: [],
|
|
63
|
+
relations: [],
|
|
64
|
+
flows: [],
|
|
65
|
+
processes: [],
|
|
66
|
+
capabilities: [],
|
|
67
|
+
technologies: [],
|
|
68
|
+
dataEntities: [],
|
|
69
|
+
endpoints: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ir/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA2JH,8BAaC;AAgBD,wCAEC;AAGD,4CAeC;AA1MY,QAAA,cAAc,GAAG,OAAgB,CAAC;AAmJ/C;;;;;GAKG;AACH,SAAgB,SAAS,C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