cyber-sdd 0.7.0 → 0.7.2
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/.claude-plugin/plugin.json +1 -2
- package/.codex-plugin/plugin.json +1 -2
- package/CHANGELOG.md +320 -0
- package/agents/sdd-scanner.md +1 -1
- package/package.json +11 -12
- package/plugin.json +55 -0
- package/skills/align-spec/SKILL.md +1 -1
- package/skills/align-spec/scripts/align-spec.mjs +6755 -12
- package/skills/blast-estimate/README.md +3 -3
- package/skills/blast-estimate/scripts/blast-estimate.mjs +601 -12
- package/skills/check-field-mandates/scripts/check-field-mandates.mjs +253 -12
- package/skills/check-partition-quality/scripts/check-partition-quality.mjs +235 -12
- package/skills/check-plan-safety/SKILL.md +2 -3
- package/skills/check-plan-safety/scripts/check-plan-safety.mjs +109 -12
- package/skills/check-plugin-manifests/scripts/check-plugin-manifests.mjs +250 -12
- package/skills/check-project-specs/SKILL.md +1 -1
- package/skills/check-project-specs/scripts/check-project-specs.mjs +593 -12
- package/skills/check-retired-terms/SKILL.md +2 -3
- package/skills/check-retired-terms/scripts/check-retired-terms.mjs +186 -12
- package/skills/check-scenario-overlap/SKILL.md +1 -2
- package/skills/check-scenario-overlap/scripts/check-scenario-overlap.mjs +177 -12
- package/skills/check-spec-references/SKILL.md +2 -2
- package/skills/check-spec-references/scripts/check-spec-references.mjs +287 -12
- package/skills/check-spec-structure/SKILL.md +1 -2
- package/skills/check-spec-structure/scripts/check-spec-structure.mjs +243 -12
- package/skills/collision-ladder/README.md +2 -2
- package/skills/collision-ladder/scripts/collision-ladder.mjs +7047 -12
- package/skills/combat-log-governance/SKILL.md +1 -1
- package/skills/concept-index/SKILL.md +1 -1
- package/skills/concept-index/scripts/concept-index.mjs +183 -12
- package/skills/discover-plans/README.md +3 -3
- package/skills/discover-plans/SKILL.md +1 -1
- package/skills/discover-plans/scripts/discover-plans.mjs +137 -12
- package/skills/discover-specs/README.md +3 -3
- package/skills/discover-specs/SKILL.md +1 -1
- package/skills/discover-specs/scripts/discover-specs.mjs +321 -12
- package/skills/doctrine-loop/SKILL.md +1 -1
- package/skills/gate-validation-governance/SKILL.md +1 -1
- package/skills/init/README.md +2 -2
- package/skills/init/scripts/wire-statusline.mjs +168 -12
- package/skills/manage-ignore/README.md +3 -3
- package/skills/manage-ignore/SKILL.md +1 -2
- package/skills/manage-ignore/scripts/manage-ignore.mjs +285 -12
- package/skills/manage-scenario-bridge/README.md +3 -3
- package/skills/manage-scenario-bridge/SKILL.md +1 -1
- package/skills/manage-scenario-bridge/scripts/manage-scenario-bridge.mjs +239 -12
- package/skills/manage-spec-anchors/README.md +3 -3
- package/skills/manage-spec-anchors/SKILL.md +1 -1
- package/skills/manage-spec-anchors/scripts/manage-spec-anchors.mjs +310 -12
- package/skills/mission-graph/README.md +2 -2
- package/skills/mission-graph/SKILL.md +1 -1
- package/skills/mission-graph/scripts/mission-graph.mjs +1040 -12
- package/skills/pause-mission/SKILL.md +1 -1
- package/skills/place-node/SKILL.md +2 -2
- package/skills/place-node/scripts/place-node.mjs +117 -12
- package/skills/plan-retirement/README.md +2 -2
- package/skills/plan-retirement/scripts/retire-plans.mjs +123 -12
- package/skills/resolve-governances/README.md +3 -3
- package/skills/resolve-governances/SKILL.md +1 -1
- package/skills/resolve-governances/scripts/resolve-governances.mjs +352 -12
- package/skills/resolve-tracking/SKILL.md +1 -1
- package/skills/resolve-tracking/scripts/resolve-tracking.mjs +152 -12
- package/skills/scaffold-project-spec/SKILL.md +1 -1
- package/skills/spec-gate/README.md +12 -9
- package/skills/spec-gate/SKILL.md +2 -2
- package/skills/spec-gate/scripts/check-spec-state.mjs +422 -12
- package/skills/spec-gate/scripts/check-suite.mjs +6500 -12
- package/skills/spec-gate/scripts/classify-edit-class.mjs +6579 -12
- package/skills/spec-producer-governance/SKILL.md +2 -2
- package/skills/start-mission/SKILL.md +1 -1
- package/skills/suite-format-governance/README.md +1 -1
- package/skills/suite-format-governance/SKILL.md +1 -1
- package/skills/touch-set-correction/README.md +5 -5
- package/skills/touch-set-correction/SKILL.md +1 -1
- package/skills/touch-set-correction/scripts/touch-set-correction.mjs +6663 -12
- package/skills/verify-scenarios/README.md +6 -6
- package/skills/verify-scenarios/scripts/verify-scenarios.mjs +6539 -12
- package/.plugin/pins.json +0 -3
- package/.plugin/plugin.json +0 -19
- package/dist/align-spec/scripts/align-spec.js +0 -102
- package/dist/check-project-specs/scripts/check-project-specs.js +0 -312
- package/dist/check-scenario-overlap/scripts/check-scenario-overlap.js +0 -175
- package/dist/check-spec-references/scripts/check-spec-references.js +0 -285
- package/dist/check-spec-structure/scripts/check-spec-structure.js +0 -241
- package/dist/concept-index/scripts/concept-index.js +0 -181
- package/dist/discover-specs/scripts/discover-specs.js +0 -318
- package/dist/spec-gate/scripts/check-spec-state.js +0 -420
- package/dist/spec-gate/scripts/check-suite.js +0 -317
- package/dist/spec-gate/scripts/classify-edit-class.js +0 -263
- package/dist/spec-gate/vendor/gherkin-cli.js +0 -6369
- package/skills/align-spec/scripts/align-spec.bundle.mjs +0 -6753
- package/skills/align-spec/scripts/align-spec.mts +0 -188
- package/skills/blast-estimate/scripts/blast-estimate.bundle.mjs +0 -593
- package/skills/blast-estimate/scripts/blast-estimate.mts +0 -586
- package/skills/check-field-mandates/scripts/check-field-mandates.bundle.mjs +0 -251
- package/skills/check-field-mandates/scripts/check-field-mandates.mts +0 -337
- package/skills/check-partition-quality/scripts/check-partition-quality.bundle.mjs +0 -233
- package/skills/check-partition-quality/scripts/check-partition-quality.mts +0 -338
- package/skills/check-plan-safety/scripts/check-plan-safety.bundle.mjs +0 -107
- package/skills/check-plan-safety/scripts/check-plan-safety.mts +0 -148
- package/skills/check-plugin-manifests/scripts/check-plugin-manifests.bundle.mjs +0 -248
- package/skills/check-plugin-manifests/scripts/check-plugin-manifests.mts +0 -303
- package/skills/check-project-specs/scripts/check-project-specs.bundle.mjs +0 -584
- package/skills/check-project-specs/scripts/check-project-specs.mts +0 -370
- package/skills/check-retired-terms/scripts/check-retired-terms.bundle.mjs +0 -184
- package/skills/check-retired-terms/scripts/check-retired-terms.mts +0 -293
- package/skills/check-scenario-overlap/scripts/check-scenario-overlap.bundle.mjs +0 -175
- package/skills/check-scenario-overlap/scripts/check-scenario-overlap.mts +0 -250
- package/skills/check-spec-references/scripts/check-spec-references.bundle.mjs +0 -285
- package/skills/check-spec-references/scripts/check-spec-references.mts +0 -422
- package/skills/check-spec-structure/scripts/check-spec-structure.bundle.mjs +0 -241
- package/skills/check-spec-structure/scripts/check-spec-structure.mts +0 -347
- package/skills/collision-ladder/scripts/collision-ladder.bundle.mjs +0 -7041
- package/skills/collision-ladder/scripts/collision-ladder.mts +0 -662
- package/skills/concept-index/scripts/concept-index.bundle.mjs +0 -181
- package/skills/concept-index/scripts/concept-index.mts +0 -246
- package/skills/discover-plans/scripts/discover-plans.bundle.mjs +0 -135
- package/skills/discover-plans/scripts/discover-plans.mts +0 -215
- package/skills/discover-specs/scripts/discover-specs.bundle.mjs +0 -319
- package/skills/discover-specs/scripts/discover-specs.mts +0 -420
- package/skills/init/scripts/wire-statusline.bundle.mjs +0 -166
- package/skills/init/scripts/wire-statusline.mts +0 -279
- package/skills/manage-ignore/scripts/manage-ignore.bundle.mjs +0 -244
- package/skills/manage-ignore/scripts/manage-ignore.mts +0 -297
- package/skills/manage-scenario-bridge/scripts/manage-scenario-bridge.bundle.mjs +0 -237
- package/skills/manage-scenario-bridge/scripts/manage-scenario-bridge.mts +0 -159
- package/skills/manage-spec-anchors/scripts/manage-spec-anchors.bundle.mjs +0 -308
- package/skills/manage-spec-anchors/scripts/manage-spec-anchors.mts +0 -331
- package/skills/mission-graph/scripts/mission-graph.bundle.mjs +0 -1038
- package/skills/mission-graph/scripts/mission-graph.mts +0 -1333
- package/skills/place-node/scripts/place-node.bundle.mjs +0 -115
- package/skills/place-node/scripts/place-node.mts +0 -158
- package/skills/plan-retirement/scripts/retire-plans.bundle.mjs +0 -121
- package/skills/plan-retirement/scripts/retire-plans.mts +0 -205
- package/skills/resolve-governances/scripts/resolve-governances.bundle.mjs +0 -350
- package/skills/resolve-governances/scripts/resolve-governances.mts +0 -518
- package/skills/resolve-tracking/scripts/resolve-tracking.bundle.mjs +0 -150
- package/skills/resolve-tracking/scripts/resolve-tracking.mts +0 -214
- package/skills/spec-gate/scripts/check-spec-state.bundle.mjs +0 -420
- package/skills/spec-gate/scripts/check-spec-state.mts +0 -637
- package/skills/spec-gate/scripts/check-suite.bundle.mjs +0 -6498
- package/skills/spec-gate/scripts/check-suite.mts +0 -538
- package/skills/spec-gate/scripts/classify-edit-class.bundle.mjs +0 -6577
- package/skills/spec-gate/scripts/classify-edit-class.mts +0 -414
- package/skills/spec-gate/vendor/gherkin-cli.d.mts +0 -2
- package/skills/spec-gate/vendor/gherkin-cli.mjs +0 -6545
- package/skills/touch-set-correction/scripts/touch-set-correction.bundle.mjs +0 -6655
- package/skills/touch-set-correction/scripts/touch-set-correction.mts +0 -429
- package/skills/verify-scenarios/scripts/verify-scenarios.bundle.mjs +0 -6537
- package/skills/verify-scenarios/scripts/verify-scenarios.mts +0 -470
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
//#region skills/resolve-governances/scripts/resolve-governances.mts
|
|
6
|
-
const ROLE_KEYS = [
|
|
7
|
-
"spec-producer",
|
|
8
|
-
"solution-producer",
|
|
9
|
-
"spec-judge",
|
|
10
|
-
"impl-producer",
|
|
11
|
-
"impl-judge"
|
|
12
|
-
];
|
|
13
|
-
const BAR_KEYS = [
|
|
14
|
-
"oracle-spec",
|
|
15
|
-
"builder-spec",
|
|
16
|
-
"builder-impl",
|
|
17
|
-
"architect-spec",
|
|
18
|
-
"architect-impl"
|
|
19
|
-
];
|
|
20
|
-
const ACTORS = [
|
|
21
|
-
"oracle",
|
|
22
|
-
"builder",
|
|
23
|
-
"architect"
|
|
24
|
-
];
|
|
25
|
-
const GATES = ["spec", "impl"];
|
|
26
|
-
const ROLE_LOADOUT = {
|
|
27
|
-
"spec-producer": { bars: ["oracle-spec", "builder-spec"] },
|
|
28
|
-
"solution-producer": { bars: ["architect-spec"] },
|
|
29
|
-
"spec-judge": { bars: [
|
|
30
|
-
"oracle-spec",
|
|
31
|
-
"builder-spec",
|
|
32
|
-
"architect-spec"
|
|
33
|
-
] },
|
|
34
|
-
"impl-producer": { bars: ["builder-impl", "architect-impl"] },
|
|
35
|
-
"impl-judge": { bars: ["builder-impl", "architect-impl"] }
|
|
36
|
-
};
|
|
37
|
-
const SDD_DEFAULT_AGENT = {
|
|
38
|
-
"spec-producer": null,
|
|
39
|
-
"solution-producer": null,
|
|
40
|
-
"spec-judge": "sdd-spec-judge",
|
|
41
|
-
"impl-producer": null,
|
|
42
|
-
"impl-judge": "sdd-impl-judge"
|
|
43
|
-
};
|
|
44
|
-
function migrateRoles(rolesIn) {
|
|
45
|
-
const roles = { ...rolesIn ?? {} };
|
|
46
|
-
if ("plan-producer" in roles) {
|
|
47
|
-
const legacy = roles["plan-producer"];
|
|
48
|
-
if (!("solution-producer" in roles)) roles["solution-producer"] = legacy;
|
|
49
|
-
delete roles["plan-producer"];
|
|
50
|
-
}
|
|
51
|
-
return roles;
|
|
52
|
-
}
|
|
53
|
-
function migrateGovernances(gIn) {
|
|
54
|
-
const g = gIn ?? {};
|
|
55
|
-
return "oracle" in g || "builder" in g || "architect" in g ? {
|
|
56
|
-
"oracle-spec": g.oracle ?? null,
|
|
57
|
-
"builder-spec": g.builder ?? null,
|
|
58
|
-
"builder-impl": g.builder ?? null,
|
|
59
|
-
"architect-spec": g.architect ?? null,
|
|
60
|
-
"architect-impl": g.architect ?? null
|
|
61
|
-
} : { ...g };
|
|
62
|
-
}
|
|
63
|
-
function migrateSquad(sq) {
|
|
64
|
-
const types = sq["artifact-types"] ?? sq.domains ?? [];
|
|
65
|
-
return {
|
|
66
|
-
"artifact-types": Array.isArray(types) ? types : [],
|
|
67
|
-
roles: migrateRoles(sq.roles),
|
|
68
|
-
governances: migrateGovernances(sq.governances)
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function migrateEntry(entry) {
|
|
72
|
-
const squads = Array.isArray(entry.squads) ? entry.squads.map(migrateSquad) : [migrateSquad({
|
|
73
|
-
"artifact-types": entry.domains,
|
|
74
|
-
roles: entry.roles,
|
|
75
|
-
governances: entry.governances
|
|
76
|
-
})];
|
|
77
|
-
return {
|
|
78
|
-
name: entry.name,
|
|
79
|
-
version: entry.version,
|
|
80
|
-
squads
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function parseRegistry(text) {
|
|
84
|
-
let raw;
|
|
85
|
-
try {
|
|
86
|
-
raw = JSON.parse(text);
|
|
87
|
-
} catch (e) {
|
|
88
|
-
throw new Error(`registry is not valid JSON: ${e.message}`);
|
|
89
|
-
}
|
|
90
|
-
if (!raw || typeof raw !== "object" || !Array.isArray(raw["sdd-plugins"])) throw new Error("registry has no sdd-plugins array");
|
|
91
|
-
return { "sdd-plugins": raw["sdd-plugins"].map(migrateEntry) };
|
|
92
|
-
}
|
|
93
|
-
function loadRegistry(root) {
|
|
94
|
-
const path = join(root, ".agents", "universal-plugin.json");
|
|
95
|
-
if (!existsSync(path)) return { "sdd-plugins": [] };
|
|
96
|
-
return parseRegistry(readFileSync(path, "utf8"));
|
|
97
|
-
}
|
|
98
|
-
function parseArtifactTypeMap(text) {
|
|
99
|
-
const out = [];
|
|
100
|
-
for (const raw of text.split("\n")) {
|
|
101
|
-
const line = raw.trim();
|
|
102
|
-
if (!line || line.startsWith("#") || line.startsWith("[")) continue;
|
|
103
|
-
const m = /^(?:"([^"]+)"|'([^']+)'|(\S+))\s*=\s*(?:"([^"]+)"|'([^']+)')\s*(?:#.*)?$/.exec(line);
|
|
104
|
-
if (!m) continue;
|
|
105
|
-
const glob = m[1] ?? m[2] ?? m[3];
|
|
106
|
-
const type = m[4] ?? m[5];
|
|
107
|
-
if (glob && type) out.push({
|
|
108
|
-
glob,
|
|
109
|
-
type
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return out;
|
|
113
|
-
}
|
|
114
|
-
function globToRegExp(glob) {
|
|
115
|
-
const re = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*+/g, (m) => m.length > 1 ? ".*" : "[^/]*").replace(/\?/g, ".");
|
|
116
|
-
return new RegExp(`^${re}$`);
|
|
117
|
-
}
|
|
118
|
-
function resolveArtifactTypeFromMap(map, path) {
|
|
119
|
-
const matches = map.filter((b) => globToRegExp(b.glob).test(path));
|
|
120
|
-
if (matches.length === 0) return null;
|
|
121
|
-
const literal = (g) => g.replace(/[*?]/g, "").length;
|
|
122
|
-
matches.sort((a, b) => literal(b.glob) - literal(a.glob) || b.glob.length - a.glob.length);
|
|
123
|
-
return matches[0].type;
|
|
124
|
-
}
|
|
125
|
-
function loadArtifactTypeMap(root) {
|
|
126
|
-
const path = join(root, ".agents", "sdd", "artifact-types.toml");
|
|
127
|
-
if (!existsSync(path)) return [];
|
|
128
|
-
return parseArtifactTypeMap(readFileSync(path, "utf8"));
|
|
129
|
-
}
|
|
130
|
-
function frontmatter(text) {
|
|
131
|
-
const m = /^---\n([\s\S]*?)\n---/.exec(text);
|
|
132
|
-
return m ? m[1].split("\n") : [];
|
|
133
|
-
}
|
|
134
|
-
const unquote = (s) => s.trim().replace(/^["']|["']$/g, "");
|
|
135
|
-
function parseGovernanceFrontmatter(text) {
|
|
136
|
-
const lines = frontmatter(text);
|
|
137
|
-
let inMeta = false;
|
|
138
|
-
let artifactType = null;
|
|
139
|
-
let actor = null;
|
|
140
|
-
let gate = null;
|
|
141
|
-
let compose = "union";
|
|
142
|
-
for (const line of lines) {
|
|
143
|
-
if (/^metadata:\s*$/.test(line)) {
|
|
144
|
-
inMeta = true;
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
if (inMeta && /^\S/.test(line)) inMeta = false;
|
|
148
|
-
if (!inMeta) continue;
|
|
149
|
-
const at = /^\s+artifact-type:\s*(.+)$/.exec(line);
|
|
150
|
-
if (at) artifactType = unquote(at[1]);
|
|
151
|
-
const ac = /^\s+actor:\s*(.+)$/.exec(line);
|
|
152
|
-
if (ac) actor = unquote(ac[1]);
|
|
153
|
-
const ga = /^\s+gate:\s*(.+)$/.exec(line);
|
|
154
|
-
if (ga) gate = unquote(ga[1]);
|
|
155
|
-
const co = /^\s+compose:\s*(.+)$/.exec(line);
|
|
156
|
-
if (co) compose = unquote(co[1]) === "replace" ? "replace" : "union";
|
|
157
|
-
}
|
|
158
|
-
if (!actor || !gate) return null;
|
|
159
|
-
return {
|
|
160
|
-
artifactType,
|
|
161
|
-
actor,
|
|
162
|
-
gate,
|
|
163
|
-
compose
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function collectAnchorGovernances(anchors) {
|
|
167
|
-
const out = [];
|
|
168
|
-
for (const { tier, root } of anchors) {
|
|
169
|
-
const dir = join(root, ".agents", "governances");
|
|
170
|
-
let entries;
|
|
171
|
-
try {
|
|
172
|
-
entries = readdirSync(dir, { withFileTypes: true });
|
|
173
|
-
} catch {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
for (const e of entries) {
|
|
177
|
-
if (!e.isFile() || !e.name.endsWith(".md")) continue;
|
|
178
|
-
const meta = parseGovernanceFrontmatter(readFileSync(join(dir, e.name), "utf8"));
|
|
179
|
-
if (meta) out.push({
|
|
180
|
-
...meta,
|
|
181
|
-
tier,
|
|
182
|
-
path: join(root, ".agents", "governances", e.name)
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return out;
|
|
187
|
-
}
|
|
188
|
-
function matchSquad(registry, artifactType) {
|
|
189
|
-
if (!artifactType) return {
|
|
190
|
-
match: null,
|
|
191
|
-
ambiguous: []
|
|
192
|
-
};
|
|
193
|
-
const matches = [];
|
|
194
|
-
for (const p of registry["sdd-plugins"]) for (const sq of p.squads ?? []) if (sq["artifact-types"]?.includes(artifactType)) matches.push({
|
|
195
|
-
plugin: p.name,
|
|
196
|
-
squad: sq
|
|
197
|
-
});
|
|
198
|
-
if (matches.length === 0) return {
|
|
199
|
-
match: null,
|
|
200
|
-
ambiguous: []
|
|
201
|
-
};
|
|
202
|
-
if (matches.length === 1) return {
|
|
203
|
-
match: matches[0],
|
|
204
|
-
ambiguous: []
|
|
205
|
-
};
|
|
206
|
-
return {
|
|
207
|
-
match: null,
|
|
208
|
-
ambiguous: [...new Set(matches.map((m) => m.plugin))]
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function matchBar(artifactType, actor, gate, ctx) {
|
|
212
|
-
const key = `${actor}-${gate}`;
|
|
213
|
-
const bucket = (tier) => ctx.projectGovs.filter((c) => c.tier === tier && c.actor === actor && c.gate === gate).filter((c) => c.artifactType === artifactType || c.artifactType === null).map((c) => c.path);
|
|
214
|
-
const pluginBar = ctx.match?.squad.governances?.[key];
|
|
215
|
-
return {
|
|
216
|
-
key,
|
|
217
|
-
candidates: {
|
|
218
|
-
project: bucket("project"),
|
|
219
|
-
"project-root": bucket("project-root"),
|
|
220
|
-
plugin: ctx.match && pluginBar ? `${ctx.match.plugin}:${pluginBar}` : null,
|
|
221
|
-
sdd: `sdd:${key}-governance`
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function resolveAgent(role, match) {
|
|
226
|
-
if (!match) return {
|
|
227
|
-
source: "sdd",
|
|
228
|
-
ref: SDD_DEFAULT_AGENT[role]
|
|
229
|
-
};
|
|
230
|
-
if (role in match.squad.roles) {
|
|
231
|
-
const named = match.squad.roles[role];
|
|
232
|
-
if (named) return {
|
|
233
|
-
source: "plugin",
|
|
234
|
-
ref: named
|
|
235
|
-
};
|
|
236
|
-
return {
|
|
237
|
-
source: "sdd",
|
|
238
|
-
ref: SDD_DEFAULT_AGENT[role]
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
return {
|
|
242
|
-
source: "plugin",
|
|
243
|
-
ref: `${match.plugin}-${role}`
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
function resolveRole(role, artifactType, ctx) {
|
|
247
|
-
const bars = ROLE_LOADOUT[role].bars.map((b) => {
|
|
248
|
-
const [actor, gate] = b.split("-");
|
|
249
|
-
return matchBar(artifactType, actor, gate, ctx);
|
|
250
|
-
});
|
|
251
|
-
return {
|
|
252
|
-
role,
|
|
253
|
-
agent: resolveAgent(role, ctx.match),
|
|
254
|
-
bars
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
function buildLoadPlan(artifactType, registry, projectGovs) {
|
|
258
|
-
const { match, ambiguous } = matchSquad(registry, artifactType);
|
|
259
|
-
if (ambiguous.length > 0) return {
|
|
260
|
-
artifactType,
|
|
261
|
-
status: "needs-input",
|
|
262
|
-
plugin: null,
|
|
263
|
-
ambiguous,
|
|
264
|
-
roles: []
|
|
265
|
-
};
|
|
266
|
-
const ctx = {
|
|
267
|
-
match,
|
|
268
|
-
projectGovs
|
|
269
|
-
};
|
|
270
|
-
return {
|
|
271
|
-
artifactType,
|
|
272
|
-
status: "complete",
|
|
273
|
-
plugin: match?.plugin ?? null,
|
|
274
|
-
ambiguous: [],
|
|
275
|
-
roles: ROLE_KEYS.map((r) => resolveRole(r, artifactType, ctx))
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
function validateRegistry(registry) {
|
|
279
|
-
const v = [];
|
|
280
|
-
const typeOwners = /* @__PURE__ */ new Map();
|
|
281
|
-
for (const entry of registry["sdd-plugins"]) {
|
|
282
|
-
const where = entry.name || "<unnamed plugin>";
|
|
283
|
-
if (!entry.name) v.push("an sdd-plugins entry has no name");
|
|
284
|
-
if (!Array.isArray(entry.squads)) {
|
|
285
|
-
v.push(`${where}: squads is not an array`);
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
const seenTypes = /* @__PURE__ */ new Set();
|
|
289
|
-
for (const sq of entry.squads) {
|
|
290
|
-
if (!Array.isArray(sq["artifact-types"])) v.push(`${where}: a squad's artifact-types is not an array`);
|
|
291
|
-
for (const r of Object.keys(sq.roles ?? {})) if (!ROLE_KEYS.includes(r)) v.push(`${where}: unknown role key "${r}"`);
|
|
292
|
-
for (const k of Object.keys(sq.governances ?? {})) if (!BAR_KEYS.includes(k)) v.push(`${where}: unknown governance key "${k}"`);
|
|
293
|
-
for (const t of sq["artifact-types"] ?? []) {
|
|
294
|
-
if (seenTypes.has(t)) v.push(`${where}: artifact-type "${t}" appears in more than one squad`);
|
|
295
|
-
seenTypes.add(t);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
for (const t of seenTypes) typeOwners.set(t, [...typeOwners.get(t) ?? [], where]);
|
|
299
|
-
}
|
|
300
|
-
for (const [t, owners] of typeOwners) if (owners.length > 1) v.push(`artifact-type "${t}" is claimed by ${owners.length} plugins (${owners.join(", ")}) — ambiguous`);
|
|
301
|
-
return v;
|
|
302
|
-
}
|
|
303
|
-
function main(argv) {
|
|
304
|
-
const root = argv.includes("--root") ? argv[argv.indexOf("--root") + 1] : ".";
|
|
305
|
-
const explicitType = argv.includes("--artifact-type") ? argv[argv.indexOf("--artifact-type") + 1] : null;
|
|
306
|
-
const pathArg = argv.includes("--path") ? argv[argv.indexOf("--path") + 1] : null;
|
|
307
|
-
const projectArg = argv.includes("--project") ? argv[argv.indexOf("--project") + 1] : root;
|
|
308
|
-
const projectRootArg = argv.includes("--project-root") ? argv[argv.indexOf("--project-root") + 1] : null;
|
|
309
|
-
const anchors = [{
|
|
310
|
-
tier: "project",
|
|
311
|
-
root: projectArg
|
|
312
|
-
}];
|
|
313
|
-
if (projectRootArg) anchors.push({
|
|
314
|
-
tier: "project-root",
|
|
315
|
-
root: projectRootArg
|
|
316
|
-
});
|
|
317
|
-
let artifactType = explicitType;
|
|
318
|
-
if (!artifactType && pathArg) artifactType = resolveArtifactTypeFromMap(loadArtifactTypeMap(root), pathArg);
|
|
319
|
-
let registry;
|
|
320
|
-
try {
|
|
321
|
-
registry = loadRegistry(root);
|
|
322
|
-
} catch (e) {
|
|
323
|
-
console.error(`✗ ${e.message}`);
|
|
324
|
-
return 1;
|
|
325
|
-
}
|
|
326
|
-
if (!artifactType && pathArg) {
|
|
327
|
-
process.stdout.write(`${JSON.stringify({
|
|
328
|
-
path: pathArg,
|
|
329
|
-
artifactType: null,
|
|
330
|
-
note: "no tiebreaker match — classify by convention"
|
|
331
|
-
}, null, 2)}\n`);
|
|
332
|
-
return 0;
|
|
333
|
-
}
|
|
334
|
-
if (!artifactType) {
|
|
335
|
-
const violations = validateRegistry(registry);
|
|
336
|
-
if (violations.length) {
|
|
337
|
-
for (const line of violations) console.error(`✗ ${line}`);
|
|
338
|
-
return 1;
|
|
339
|
-
}
|
|
340
|
-
process.stdout.write("governance registry OK\n");
|
|
341
|
-
return 0;
|
|
342
|
-
}
|
|
343
|
-
const plan = buildLoadPlan(artifactType, registry, collectAnchorGovernances(anchors));
|
|
344
|
-
process.stdout.write(`${JSON.stringify(plan, null, 2)}\n`);
|
|
345
|
-
if (plan.status === "needs-input") console.error(`needs-input: artifact-type "${artifactType}" is claimed by ${plan.ambiguous.join(", ")}`);
|
|
346
|
-
return 0;
|
|
347
|
-
}
|
|
348
|
-
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) process.exit(main(process.argv.slice(2)));
|
|
349
|
-
//#endregion
|
|
350
|
-
export { ACTORS, BAR_KEYS, GATES, ROLE_KEYS, ROLE_LOADOUT, SDD_DEFAULT_AGENT, buildLoadPlan, collectAnchorGovernances, loadArtifactTypeMap, loadRegistry, main, matchBar, matchSquad, migrateEntry, parseArtifactTypeMap, parseGovernanceFrontmatter, parseRegistry, resolveAgent, resolveArtifactTypeFromMap, resolveRole, validateRegistry };
|