archgraph-argo-beta 0.27.0-beta.1 → 0.27.0-beta.10
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 +17 -0
- package/argo/schema/schema-bundle.config.json +2 -0
- package/argo/scripts/argo-mcp-server.js +9 -1
- package/argo/scripts/graph-semantics.js +97 -0
- package/argo/scripts/schema-bundle.js +369 -11
- package/argo/scripts/systemarchitecture-mcp-server.js +252 -8
- package/argo/scripts/validateSystemArchitecture.js +2 -0
- package/cordis.patch.yml +9 -0
- package/dsh-argo-workspace/index.js +100 -30
- package/install-argo.ps1 +27 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -88,6 +88,23 @@ After installing, open your project and start a coding agent. It will:
|
|
|
88
88
|
|
|
89
89
|
The intent architecture graph — modelled in **ArchiMate 3.2** — is the single source of truth.
|
|
90
90
|
|
|
91
|
+
## The federation model
|
|
92
|
+
|
|
93
|
+
ArchGraph is a **federated intent graph**, not one big distributed graph. Every project owns a
|
|
94
|
+
complete, **sovereign** canonical graph (`design/KG/SystemArchitecture.json`) and stays the single
|
|
95
|
+
source of truth for its own model — nothing is split, sharded, or merged into a central super-graph.
|
|
96
|
+
|
|
97
|
+
Projects **co-build** by federation: a member **self-registers** with the federation center, others
|
|
98
|
+
**discover** it, reads are **explicitly authorized and denied by default**, and a cross-project read
|
|
99
|
+
returns a **reference, not a copy**. The center holds only federation metadata — membership,
|
|
100
|
+
capabilities, interfaces, grants — plus a read-only mirror: it is a **registry + broker**, never the
|
|
101
|
+
content.
|
|
102
|
+
|
|
103
|
+
The pattern is **Registry–Broker Federation over sovereign knowledge graphs**: self-registration +
|
|
104
|
+
discovery + capability-based authorization + reference-not-copy, mediated by a broker. It is
|
|
105
|
+
*federated*, not "distributed" — a distributed model would mean one logical graph partitioned across
|
|
106
|
+
nodes, which is exactly what this design avoids.
|
|
107
|
+
|
|
91
108
|
## Community
|
|
92
109
|
|
|
93
110
|
ArchGraph runs on open co-building. Join the community hub to share, browse and reuse **architecture
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"title": "ArchiMate 3.2 default schema bundle descriptor",
|
|
4
4
|
"description": "Descriptor for the default ARGO schema bundle (ArchiMate 3.2 + ARGO extensions). A repository may override this bundle by placing its own SystemArchitecture.schema.json (plus an optional schema-bundle.config.json / schema-bundle.rules.json) under <workspace>/.argo/schema.",
|
|
5
|
+
"id": "default",
|
|
6
|
+
"aliases": ["archimate3.2", "archimate", "base"],
|
|
5
7
|
"language": "ArchiMate 3.2",
|
|
6
8
|
"elementTypeEnumKey": "archimateElementType",
|
|
7
9
|
"relationshipTypeEnumKey": "archimateRelationshipType",
|
|
@@ -420,6 +420,13 @@ async function callTool(name, args = {}, progressToken = null, dependencies = un
|
|
|
420
420
|
tool: name,
|
|
421
421
|
args,
|
|
422
422
|
});
|
|
423
|
+
// getSystemArchitecture declares an outputSchema, so its result MUST carry
|
|
424
|
+
// matching structuredContent even on the cross-project path (which bypasses
|
|
425
|
+
// the systemarchitecture module's own toolResult). A missing
|
|
426
|
+
// structuredContent makes the MCP client reject the call with -32600.
|
|
427
|
+
if (name === 'getSystemArchitecture') {
|
|
428
|
+
return toolResult(result, systemArchitectureMcp.buildGetSystemArchitectureStructuredContent(result));
|
|
429
|
+
}
|
|
423
430
|
return toolResult(result);
|
|
424
431
|
}
|
|
425
432
|
if (name === 'initializeWorkspace') {
|
|
@@ -678,7 +685,7 @@ function normalizeRelativePath(value) {
|
|
|
678
685
|
return String(value).replace(/\\/g, '/');
|
|
679
686
|
}
|
|
680
687
|
|
|
681
|
-
function toolResult(payload) {
|
|
688
|
+
function toolResult(payload, structuredContent = undefined) {
|
|
682
689
|
return {
|
|
683
690
|
content: [
|
|
684
691
|
{
|
|
@@ -686,6 +693,7 @@ function toolResult(payload) {
|
|
|
686
693
|
text: JSON.stringify(payload, null, 2),
|
|
687
694
|
},
|
|
688
695
|
],
|
|
696
|
+
...(structuredContent === undefined ? {} : { structuredContent }),
|
|
689
697
|
isError: payload.status === 'failed',
|
|
690
698
|
};
|
|
691
699
|
}
|
|
@@ -259,8 +259,105 @@ function validateViewElementLimits(document, errors, options = {}) {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
// Per-element-type attribute contract (issue #3): required attributes, a
|
|
263
|
+
// controlled vocabulary per attribute (enumByAttr) and uniqueness per attribute.
|
|
264
|
+
// Supplied by the active schema bundle's `attributesByElementType`; absent => no-op
|
|
265
|
+
// (fully backward compatible).
|
|
266
|
+
function attributeEntriesByName(element) {
|
|
267
|
+
const map = new Map();
|
|
268
|
+
const entries = Array.isArray(element && element.attributes) ? element.attributes : [];
|
|
269
|
+
for (const entry of entries) {
|
|
270
|
+
if (!entry || typeof entry !== 'object' || typeof entry.name !== 'string' || entry.name === '') {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (!map.has(entry.name)) {
|
|
274
|
+
map.set(entry.name, []);
|
|
275
|
+
}
|
|
276
|
+
map.get(entry.name).push(entry);
|
|
277
|
+
}
|
|
278
|
+
return map;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function attributeValueOf(entry) {
|
|
282
|
+
if (entry.value !== undefined && entry.value !== null) {
|
|
283
|
+
return entry.value;
|
|
284
|
+
}
|
|
285
|
+
if (entry.content !== undefined && entry.content !== null) {
|
|
286
|
+
return entry.content;
|
|
287
|
+
}
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function validateAttributeContracts(document, errors, ontology) {
|
|
292
|
+
const language = resolveOntology(ontology);
|
|
293
|
+
const contracts = language.attributesByElementType;
|
|
294
|
+
if (!contracts || typeof contracts !== 'object') {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const uniqueTrackers = new Map();
|
|
298
|
+
for (const type of Object.keys(contracts)) {
|
|
299
|
+
uniqueTrackers.set(type, new Map());
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
for (const element of document.elements || []) {
|
|
303
|
+
if (!element || typeof element !== 'object') {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
const contract = contracts[element.type];
|
|
307
|
+
if (!contract || typeof contract !== 'object') {
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
const byName = attributeEntriesByName(element);
|
|
311
|
+
|
|
312
|
+
for (const name of Array.isArray(contract.required) ? contract.required : []) {
|
|
313
|
+
const entries = byName.get(name);
|
|
314
|
+
const present = Array.isArray(entries) && entries.some((entry) => {
|
|
315
|
+
const value = attributeValueOf(entry);
|
|
316
|
+
return value !== undefined && value !== '';
|
|
317
|
+
});
|
|
318
|
+
if (!present) {
|
|
319
|
+
errors.push(`element '${element.id}' (type '${element.type}') is missing required attribute '${name}'`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const enumByAttr = contract.enumByAttr && typeof contract.enumByAttr === 'object' ? contract.enumByAttr : {};
|
|
324
|
+
for (const [attr, allowed] of Object.entries(enumByAttr)) {
|
|
325
|
+
if (!Array.isArray(allowed)) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
for (const entry of byName.get(attr) || []) {
|
|
329
|
+
const value = attributeValueOf(entry);
|
|
330
|
+
if (value === undefined) {
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
const matches = allowed.some((option) => option === value || JSON.stringify(option) === JSON.stringify(value));
|
|
334
|
+
if (!matches) {
|
|
335
|
+
errors.push(`element '${element.id}' (type '${element.type}') attribute '${attr}' value ${JSON.stringify(value)} is not one of: ${allowed.map((option) => JSON.stringify(option)).join(', ')}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
for (const attr of Array.isArray(contract.unique) ? contract.unique : []) {
|
|
341
|
+
const tracker = uniqueTrackers.get(element.type);
|
|
342
|
+
for (const entry of byName.get(attr) || []) {
|
|
343
|
+
const value = attributeValueOf(entry);
|
|
344
|
+
if (value === undefined) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
const key = JSON.stringify(value);
|
|
348
|
+
if (tracker.has(key) && tracker.get(key) !== element.id) {
|
|
349
|
+
errors.push(`element '${element.id}' (type '${element.type}') attribute '${attr}' value ${key} duplicates element '${tracker.get(key)}'`);
|
|
350
|
+
} else if (!tracker.has(key)) {
|
|
351
|
+
tracker.set(key, element.id);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
262
358
|
module.exports = {
|
|
263
359
|
validateGraphSemantics,
|
|
264
360
|
validateArchiMateEndpointMatrix,
|
|
265
361
|
validateViewElementLimits,
|
|
362
|
+
validateAttributeContracts,
|
|
266
363
|
};
|
|
@@ -99,7 +99,8 @@ function relativeLabel(workspaceRoot, absolutePath) {
|
|
|
99
99
|
|
|
100
100
|
function buildBundle(kind, dir, workspaceRoot) {
|
|
101
101
|
const schemaFile = path.join(dir, SCHEMA_BASENAME);
|
|
102
|
-
const
|
|
102
|
+
const schemaExists = isFile(schemaFile);
|
|
103
|
+
const schema = schemaExists ? readJsonFile(schemaFile) : null;
|
|
103
104
|
|
|
104
105
|
const configFile = path.join(dir, CONFIG_BASENAME);
|
|
105
106
|
const fileConfig = isFile(configFile) ? readJsonFile(configFile) : {};
|
|
@@ -135,10 +136,9 @@ function buildBundle(kind, dir, workspaceRoot) {
|
|
|
135
136
|
kind,
|
|
136
137
|
dir,
|
|
137
138
|
relativeDir: relativeLabel(workspaceRoot, dir),
|
|
138
|
-
schema:
|
|
139
|
-
absolutePath: schemaFile,
|
|
140
|
-
|
|
141
|
-
},
|
|
139
|
+
schema: schemaExists
|
|
140
|
+
? { absolutePath: schemaFile, relativePath: relativeLabel(workspaceRoot, schemaFile) }
|
|
141
|
+
: null,
|
|
142
142
|
schemaDocument: schema,
|
|
143
143
|
config: {
|
|
144
144
|
filePath: isFile(configFile) ? { absolutePath: configFile, relativePath: relativeLabel(workspaceRoot, configFile) } : null,
|
|
@@ -154,6 +154,262 @@ function buildBundle(kind, dir, workspaceRoot) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
// --- Bundle inheritance (issue #4) -----------------------------------------
|
|
158
|
+
// A bundle may declare `extends` to inherit a base bundle (the built-in default,
|
|
159
|
+
// or another bundle directory) and add/override on top of it instead of forking
|
|
160
|
+
// the whole rules file. `addElementTypes` / `addRelationships` / `overrideMatrix`
|
|
161
|
+
// are the delta; the effective element universe becomes base ∪ add (single
|
|
162
|
+
// source of truth), matrix/metadata merge by key.
|
|
163
|
+
|
|
164
|
+
function bundleConfig(dir) {
|
|
165
|
+
const configFile = path.join(dir, CONFIG_BASENAME);
|
|
166
|
+
if (!isFile(configFile)) {
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
return readJsonFile(configFile);
|
|
171
|
+
} catch {
|
|
172
|
+
return {};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function hasExtendsConfig(dir) {
|
|
177
|
+
const config = bundleConfig(dir);
|
|
178
|
+
return typeof config.extends === 'string' && config.extends.trim() !== '';
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Symbolic names a bundle declares about itself (`id` + `aliases`) in its config.
|
|
182
|
+
// The framework resolves an `extends` value against these DECLARED names — never a
|
|
183
|
+
// name hardcoded in framework logic — so a bundle's identity/aliases are data.
|
|
184
|
+
function bundleSymbolicNames(dir) {
|
|
185
|
+
const config = bundleConfig(dir);
|
|
186
|
+
const names = new Set();
|
|
187
|
+
if (typeof config.id === 'string' && config.id.trim() !== '') {
|
|
188
|
+
names.add(config.id.trim());
|
|
189
|
+
}
|
|
190
|
+
if (Array.isArray(config.aliases)) {
|
|
191
|
+
for (const alias of config.aliases) {
|
|
192
|
+
if (typeof alias === 'string' && alias.trim() !== '') {
|
|
193
|
+
names.add(alias.trim());
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return names;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function isPathLikeExt(value) {
|
|
201
|
+
return value.includes('/') || value.includes('\\') || value.startsWith('.') || value.startsWith('~')
|
|
202
|
+
|| /^[a-zA-Z]:/.test(value);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Bounded, general candidate list for symbolic bundle resolution: the built-in
|
|
206
|
+
// default bundle, any directory a bundle lists in its own `basePaths`, the bundle's
|
|
207
|
+
// own directory, and its immediate sub-directories. The framework matches a name
|
|
208
|
+
// against each candidate's SELF-DECLARED id/aliases (data) — it hardcodes no
|
|
209
|
+
// modeling-language name. A non-matching symbolic name falls back to a path, so
|
|
210
|
+
// bare relative directory references keep working.
|
|
211
|
+
function candidateBaseDirs(childDir, config) {
|
|
212
|
+
const dirs = [];
|
|
213
|
+
const seen = new Set();
|
|
214
|
+
const push = (dir) => {
|
|
215
|
+
if (!dir) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const resolved = path.resolve(dir);
|
|
219
|
+
const key = resolved.toLowerCase();
|
|
220
|
+
if (!seen.has(key)) {
|
|
221
|
+
seen.add(key);
|
|
222
|
+
dirs.push(resolved);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
push(path.join(getArgoRoot(), 'schema'));
|
|
226
|
+
const basePaths = config && Array.isArray(config.basePaths) ? config.basePaths : [];
|
|
227
|
+
for (const basePath of basePaths) {
|
|
228
|
+
if (typeof basePath === 'string' && basePath.trim() !== '') {
|
|
229
|
+
push(path.resolve(childDir, basePath.trim()));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
push(childDir);
|
|
233
|
+
let entries = [];
|
|
234
|
+
try {
|
|
235
|
+
entries = fs.readdirSync(childDir, { withFileTypes: true });
|
|
236
|
+
} catch {
|
|
237
|
+
entries = [];
|
|
238
|
+
}
|
|
239
|
+
for (const entry of entries) {
|
|
240
|
+
if (entry.isDirectory()) {
|
|
241
|
+
push(path.join(childDir, entry.name));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return dirs;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function resolveBaseBundleDir(ext, childDir, config) {
|
|
248
|
+
const value = String(ext).trim();
|
|
249
|
+
// `default` is the reserved, language-neutral name of the built-in bundle.
|
|
250
|
+
if (value === 'default') {
|
|
251
|
+
return path.join(getArgoRoot(), 'schema');
|
|
252
|
+
}
|
|
253
|
+
if (!isPathLikeExt(value)) {
|
|
254
|
+
for (const dir of candidateBaseDirs(childDir, config)) {
|
|
255
|
+
if (bundleSymbolicNames(dir).has(value)) {
|
|
256
|
+
return dir;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Not a symbolic hit: treat as a path relative to the bundle directory.
|
|
261
|
+
return path.resolve(childDir, value);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function deepCloneJson(value) {
|
|
265
|
+
return value === undefined ? undefined : JSON.parse(JSON.stringify(value));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function mergeMatrixInto(target, source) {
|
|
269
|
+
if (!source || typeof source !== 'object') {
|
|
270
|
+
return target;
|
|
271
|
+
}
|
|
272
|
+
for (const [relationshipType, bySource] of Object.entries(source)) {
|
|
273
|
+
if (!bySource || typeof bySource !== 'object') {
|
|
274
|
+
target[relationshipType] = deepCloneJson(bySource);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (!target[relationshipType] || typeof target[relationshipType] !== 'object') {
|
|
278
|
+
target[relationshipType] = {};
|
|
279
|
+
}
|
|
280
|
+
for (const [sourceType, targets] of Object.entries(bySource)) {
|
|
281
|
+
target[relationshipType][sourceType] = deepCloneJson(targets);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return target;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Append added types to a JSON-Schema enum def (the element/relationship type
|
|
288
|
+
// universe), so a schema-less inheriting Profile's own added types are structurally
|
|
289
|
+
// valid — not just present at the ontology level.
|
|
290
|
+
function extendSchemaEnum(schemaDocument, enumKeys, additions) {
|
|
291
|
+
const defs = schemaDocument && typeof schemaDocument.$defs === 'object' ? schemaDocument.$defs : null;
|
|
292
|
+
if (!defs) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
for (const key of enumKeys) {
|
|
296
|
+
const node = defs[key];
|
|
297
|
+
if (node && Array.isArray(node.enum)) {
|
|
298
|
+
for (const value of additions) {
|
|
299
|
+
if (typeof value === 'string' && value !== '' && !node.enum.includes(value)) {
|
|
300
|
+
node.enum.push(value);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function mergeExtendsBundle(base, child) {
|
|
309
|
+
const baseRules = base.rules || {};
|
|
310
|
+
const childRules = child.rules || {};
|
|
311
|
+
const config = { ...(base.config || {}), ...(child.config || {}) };
|
|
312
|
+
|
|
313
|
+
const elementTypeMetadata = { ...(baseRules.elementTypeMetadata || {}), ...(childRules.elementTypeMetadata || {}) };
|
|
314
|
+
const archimateClassByElementType = { ...(baseRules.archimateClassByElementType || {}), ...(childRules.archimateClassByElementType || {}) };
|
|
315
|
+
const relationshipCategoryByType = { ...(baseRules.relationshipCategoryByType || {}), ...(childRules.relationshipCategoryByType || {}) };
|
|
316
|
+
|
|
317
|
+
const addElementTypes = config.addElementTypes && typeof config.addElementTypes === 'object' ? config.addElementTypes : {};
|
|
318
|
+
for (const [type, meta] of Object.entries(addElementTypes)) {
|
|
319
|
+
if (!elementTypeMetadata[type]) {
|
|
320
|
+
elementTypeMetadata[type] = { layer: (meta && meta.layer) || null, aspect: (meta && meta.aspect) || null };
|
|
321
|
+
}
|
|
322
|
+
if (meta && typeof meta.class === 'string' && meta.class !== '') {
|
|
323
|
+
archimateClassByElementType[type] = meta.class;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const addRelationships = config.addRelationships && typeof config.addRelationships === 'object' ? config.addRelationships : {};
|
|
327
|
+
for (const [type, category] of Object.entries(addRelationships)) {
|
|
328
|
+
relationshipCategoryByType[type] = category;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Guarantee base ∪ add for the element/relationship universe regardless of the
|
|
332
|
+
// base dialect (class-matrix derives types from rules metadata, type-matrix from
|
|
333
|
+
// schema enums) — an inheriting Profile must never silently drop a base type.
|
|
334
|
+
const baseOntology = buildOntology(base);
|
|
335
|
+
for (const type of baseOntology.elementTypes) {
|
|
336
|
+
if (!elementTypeMetadata[type]) {
|
|
337
|
+
elementTypeMetadata[type] = { layer: null, aspect: null };
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
for (const type of baseOntology.relationshipTypes) {
|
|
341
|
+
if (!relationshipCategoryByType[type]) {
|
|
342
|
+
relationshipCategoryByType[type] = 'Custom';
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const relationshipTargetMatrix = deepCloneJson(baseRules.relationshipTargetMatrix || {}) || {};
|
|
347
|
+
mergeMatrixInto(relationshipTargetMatrix, childRules.relationshipTargetMatrix || {});
|
|
348
|
+
mergeMatrixInto(relationshipTargetMatrix, config.overrideMatrix || {});
|
|
349
|
+
|
|
350
|
+
// Inherit the base dialect as-is; never default to a specific dialect NAME here
|
|
351
|
+
// (that would couple the generic merge to one modeling language). When both are
|
|
352
|
+
// absent the ontology builder decides from the bundle's declared rules.
|
|
353
|
+
const dialect = childRules.dialect || baseRules.dialect;
|
|
354
|
+
const rules = {
|
|
355
|
+
...baseRules,
|
|
356
|
+
...childRules,
|
|
357
|
+
dialect,
|
|
358
|
+
elementTypeMetadata,
|
|
359
|
+
archimateClassByElementType,
|
|
360
|
+
relationshipCategoryByType,
|
|
361
|
+
relationshipTargetMatrix,
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// Structural schema: when the child has none, it inherits the base schema — but
|
|
365
|
+
// its added types must be valid against the base's $defs enum too, otherwise
|
|
366
|
+
// whole-graph validation (validateAgainstSchema) rejects elements of the added
|
|
367
|
+
// types. Extend the inherited schema enum in place (clone, never mutate base).
|
|
368
|
+
let schemaDocument = child.schemaDocument || base.schemaDocument;
|
|
369
|
+
if (!child.schemaDocument && base.schemaDocument) {
|
|
370
|
+
const extraElementTypes = Object.keys(addElementTypes).filter(Boolean);
|
|
371
|
+
const extraRelationshipTypes = Object.keys(addRelationships).filter(Boolean);
|
|
372
|
+
const extraFromConfigElements = Array.isArray(config.elementTypes) ? config.elementTypes : [];
|
|
373
|
+
const extraFromConfigRelationships = Array.isArray(config.relationshipTypes) ? config.relationshipTypes : [];
|
|
374
|
+
if (extraElementTypes.length || extraRelationshipTypes.length || extraFromConfigElements.length || extraFromConfigRelationships.length) {
|
|
375
|
+
schemaDocument = deepCloneJson(base.schemaDocument);
|
|
376
|
+
extendSchemaEnum(schemaDocument, ELEMENT_ENUM_KEYS, extraElementTypes.concat(extraFromConfigElements));
|
|
377
|
+
extendSchemaEnum(schemaDocument, RELATIONSHIP_ENUM_KEYS, extraRelationshipTypes.concat(extraFromConfigRelationships));
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return {
|
|
382
|
+
...child,
|
|
383
|
+
schema: child.schema || base.schema,
|
|
384
|
+
schemaDocument,
|
|
385
|
+
rules,
|
|
386
|
+
config,
|
|
387
|
+
inheritedFrom: base.dir,
|
|
388
|
+
chainDirs: Array.from(new Set([
|
|
389
|
+
...(Array.isArray(base.chainDirs) && base.chainDirs.length > 0 ? base.chainDirs : [path.resolve(base.dir).toLowerCase()]),
|
|
390
|
+
path.resolve(child.dir).toLowerCase(),
|
|
391
|
+
])),
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function applyExtends(bundle, workspaceRoot, seen = new Set()) {
|
|
396
|
+
const ext = bundle && bundle.config && typeof bundle.config.extends === 'string' ? bundle.config.extends.trim() : '';
|
|
397
|
+
if (!ext) {
|
|
398
|
+
return bundle;
|
|
399
|
+
}
|
|
400
|
+
seen.add(path.resolve(bundle.dir).toLowerCase());
|
|
401
|
+
const baseDir = resolveBaseBundleDir(ext, bundle.dir, bundle.config);
|
|
402
|
+
const baseKey = path.resolve(baseDir).toLowerCase();
|
|
403
|
+
if (seen.has(baseKey)) {
|
|
404
|
+
throw new Error(`schema bundle extends cycle detected at '${baseDir}'`);
|
|
405
|
+
}
|
|
406
|
+
if (!isFile(path.join(baseDir, SCHEMA_BASENAME)) && !hasExtendsConfig(baseDir)) {
|
|
407
|
+
throw new Error(`schema bundle extends '${ext}' could not be resolved: no schema bundle at '${baseDir}'`);
|
|
408
|
+
}
|
|
409
|
+
const baseBundle = applyExtends(buildBundle('extends', baseDir, workspaceRoot), workspaceRoot, seen);
|
|
410
|
+
return mergeExtendsBundle(baseBundle, bundle);
|
|
411
|
+
}
|
|
412
|
+
|
|
157
413
|
function resolveSchemaBundle(workspaceRoot, options = {}) {
|
|
158
414
|
const root = path.resolve(workspaceRoot || process.cwd());
|
|
159
415
|
const candidates = [];
|
|
@@ -172,8 +428,8 @@ function resolveSchemaBundle(workspaceRoot, options = {}) {
|
|
|
172
428
|
continue;
|
|
173
429
|
}
|
|
174
430
|
seen.add(key);
|
|
175
|
-
if (isFile(path.join(candidate.dir, SCHEMA_BASENAME))) {
|
|
176
|
-
return buildBundle(candidate.kind, candidate.dir, root);
|
|
431
|
+
if (isFile(path.join(candidate.dir, SCHEMA_BASENAME)) || hasExtendsConfig(candidate.dir)) {
|
|
432
|
+
return applyExtends(buildBundle(candidate.kind, candidate.dir, root), root);
|
|
177
433
|
}
|
|
178
434
|
}
|
|
179
435
|
|
|
@@ -258,7 +514,77 @@ function resolveActorElementType(config) {
|
|
|
258
514
|
return DEFAULT_ACTOR_ELEMENT_TYPE;
|
|
259
515
|
}
|
|
260
516
|
|
|
261
|
-
|
|
517
|
+
// Per-element-type attribute contract (issue #3): declare that an element type
|
|
518
|
+
// must carry certain attributes, that some attribute values are a controlled
|
|
519
|
+
// vocabulary, and that some attribute values are unique within the type.
|
|
520
|
+
// { "Rule": { "required": ["ruleId","normativity"], "unique": ["ruleId"],
|
|
521
|
+
// "enumByAttr": { "normativity": ["MUST","SHOULD","MAY","MUST_NOT"] } } }
|
|
522
|
+
// Absent => no per-type attribute contract (backward compatible).
|
|
523
|
+
function resolveAttributeContracts(config) {
|
|
524
|
+
const raw = config && typeof config.attributesByElementType === 'object' && config.attributesByElementType !== null
|
|
525
|
+
? config.attributesByElementType
|
|
526
|
+
: null;
|
|
527
|
+
if (!raw) {
|
|
528
|
+
return undefined;
|
|
529
|
+
}
|
|
530
|
+
const contracts = {};
|
|
531
|
+
for (const [type, contract] of Object.entries(raw)) {
|
|
532
|
+
if (!contract || typeof contract !== 'object') {
|
|
533
|
+
contracts[type] = {};
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
contracts[type] = {
|
|
537
|
+
required: Array.isArray(contract.required) ? contract.required.slice() : undefined,
|
|
538
|
+
unique: Array.isArray(contract.unique) ? contract.unique.slice() : undefined,
|
|
539
|
+
enumByAttr: contract.enumByAttr && typeof contract.enumByAttr === 'object' ? { ...contract.enumByAttr } : undefined,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
return contracts;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function validateAttributeContracts(language, elementTypeList, contracts) {
|
|
546
|
+
const errors = [];
|
|
547
|
+
if (!contracts || typeof contracts !== 'object') {
|
|
548
|
+
return errors;
|
|
549
|
+
}
|
|
550
|
+
for (const [type, contract] of Object.entries(contracts)) {
|
|
551
|
+
if (!elementTypeList.includes(type)) {
|
|
552
|
+
errors.push(`schema bundle '${language}' attributesByElementType references unknown element type '${type}'`);
|
|
553
|
+
}
|
|
554
|
+
if (!contract || typeof contract !== 'object') {
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
for (const key of ['required', 'unique']) {
|
|
558
|
+
const list = contract[key];
|
|
559
|
+
if (list === undefined) {
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
if (!Array.isArray(list)) {
|
|
563
|
+
errors.push(`schema bundle '${language}' attributesByElementType['${type}'].${key} must be an array`);
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
for (const name of list) {
|
|
567
|
+
if (typeof name !== 'string' || name === '') {
|
|
568
|
+
errors.push(`schema bundle '${language}' attributesByElementType['${type}'].${key} entries must be non-empty strings`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if (contract.enumByAttr !== undefined) {
|
|
573
|
+
if (!contract.enumByAttr || typeof contract.enumByAttr !== 'object') {
|
|
574
|
+
errors.push(`schema bundle '${language}' attributesByElementType['${type}'].enumByAttr must be an object`);
|
|
575
|
+
} else {
|
|
576
|
+
for (const [attr, allowed] of Object.entries(contract.enumByAttr)) {
|
|
577
|
+
if (!Array.isArray(allowed) || allowed.length === 0) {
|
|
578
|
+
errors.push(`schema bundle '${language}' attributesByElementType['${type}'].enumByAttr['${attr}'] must be a non-empty array`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return errors;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function validateBundle({ language, dialect, elementTypes, relationshipTypes, actorElementType, matrix, deliveryDependencies, attributesByElementType }) {
|
|
262
588
|
const errors = [];
|
|
263
589
|
const elementTypeList = Array.isArray(elementTypes) ? elementTypes : [];
|
|
264
590
|
const relationshipTypeList = Array.isArray(relationshipTypes) ? relationshipTypes : [];
|
|
@@ -304,6 +630,7 @@ function validateBundle({ language, dialect, elementTypes, relationshipTypes, ac
|
|
|
304
630
|
}
|
|
305
631
|
|
|
306
632
|
errors.push(...validateDeliveryDependencies(language, relationshipTypeList, deliveryDependencies));
|
|
633
|
+
errors.push(...validateAttributeContracts(language, elementTypeList, attributesByElementType));
|
|
307
634
|
|
|
308
635
|
return { status: errors.length === 0 ? 'passed' : 'failed', errors };
|
|
309
636
|
}
|
|
@@ -386,6 +713,7 @@ function buildClassMatrixOntology(bundle) {
|
|
|
386
713
|
const relationshipTypes = Array.from(relationshipCategoryByType.keys());
|
|
387
714
|
const actorElementType = resolveActorElementType(bundle.config);
|
|
388
715
|
const deliveryDependencies = resolveDeliveryDependencies(bundle.config, 'archimate-class-matrix');
|
|
716
|
+
const attributesByElementType = resolveAttributeContracts(bundle.config);
|
|
389
717
|
return finalizeOntology({
|
|
390
718
|
kind: bundle.kind,
|
|
391
719
|
dialect: 'archimate-class-matrix',
|
|
@@ -397,7 +725,8 @@ function buildClassMatrixOntology(bundle) {
|
|
|
397
725
|
relationshipTypes,
|
|
398
726
|
actorElementType,
|
|
399
727
|
deliveryDependencies,
|
|
400
|
-
|
|
728
|
+
attributesByElementType,
|
|
729
|
+
bundleValidation: validateBundle({ language, dialect: 'archimate-class-matrix', elementTypes, relationshipTypes, actorElementType, matrix: null, deliveryDependencies, attributesByElementType }),
|
|
401
730
|
elementTypeMetadata,
|
|
402
731
|
relationshipCategoryByType,
|
|
403
732
|
isSupportedElementType,
|
|
@@ -456,6 +785,7 @@ function buildTypeMatrixOntology(bundle) {
|
|
|
456
785
|
const elementTypes = Array.from(elementTypeMetadata.keys());
|
|
457
786
|
const relationshipTypes = Array.from(relationshipCategoryByType.keys());
|
|
458
787
|
const deliveryDependencies = resolveDeliveryDependencies(config, 'type-matrix');
|
|
788
|
+
const attributesByElementType = resolveAttributeContracts(config);
|
|
459
789
|
const getArchiMateClass = (elementOrType) => {
|
|
460
790
|
const type = typeof elementOrType === 'string' ? elementOrType : elementOrType && elementOrType.type;
|
|
461
791
|
return type;
|
|
@@ -494,7 +824,8 @@ function buildTypeMatrixOntology(bundle) {
|
|
|
494
824
|
relationshipTypes,
|
|
495
825
|
actorElementType,
|
|
496
826
|
deliveryDependencies,
|
|
497
|
-
|
|
827
|
+
attributesByElementType,
|
|
828
|
+
bundleValidation: validateBundle({ language, dialect: 'type-matrix', elementTypes, relationshipTypes, actorElementType, matrix, deliveryDependencies, attributesByElementType }),
|
|
498
829
|
elementTypeMetadata,
|
|
499
830
|
relationshipCategoryByType,
|
|
500
831
|
isSupportedElementType: (type) => elementTypeMetadata.has(type),
|
|
@@ -552,9 +883,36 @@ function buildOntology(bundle) {
|
|
|
552
883
|
return bundle.kind === 'default' ? buildClassMatrixOntology(bundle) : buildTypeMatrixOntology(bundle);
|
|
553
884
|
}
|
|
554
885
|
|
|
886
|
+
// Cheap on-disk fingerprint of a bundle (and its extends chain) so a running MCP
|
|
887
|
+
// picks up edits to the bundle files without a restart: the ontology cache key
|
|
888
|
+
// changes when any key file's mtime/size changes.
|
|
889
|
+
function bundleFingerprint(bundle) {
|
|
890
|
+
const dirs = Array.isArray(bundle.chainDirs) && bundle.chainDirs.length > 0
|
|
891
|
+
? bundle.chainDirs
|
|
892
|
+
: [path.resolve(bundle.dir).toLowerCase()];
|
|
893
|
+
const statFile = (absolutePath) => {
|
|
894
|
+
try {
|
|
895
|
+
const stat = fs.statSync(absolutePath);
|
|
896
|
+
return `${Math.round(stat.mtimeMs)}:${stat.size}`;
|
|
897
|
+
} catch {
|
|
898
|
+
return '-';
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
const parts = [];
|
|
902
|
+
for (const dir of dirs) {
|
|
903
|
+
for (const name of [SCHEMA_BASENAME, CONFIG_BASENAME, RULES_BASENAME]) {
|
|
904
|
+
parts.push(`${name}=${statFile(path.join(dir, name))}`);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
if (bundle.config && typeof bundle.config.rules === 'string' && bundle.config.rules.trim() !== '') {
|
|
908
|
+
parts.push(`rules=${statFile(path.resolve(bundle.dir, bundle.config.rules))}`);
|
|
909
|
+
}
|
|
910
|
+
return parts.join('|');
|
|
911
|
+
}
|
|
912
|
+
|
|
555
913
|
function loadSchemaBundleAndOntology(workspaceRoot, options = {}) {
|
|
556
914
|
const bundle = resolveSchemaBundle(workspaceRoot, options);
|
|
557
|
-
const cacheKey = `${bundle.kind}:${path.resolve(bundle.dir).toLowerCase()}`;
|
|
915
|
+
const cacheKey = `${bundle.kind}:${path.resolve(bundle.dir).toLowerCase()}:${bundleFingerprint(bundle)}`;
|
|
558
916
|
if (ontologyCache.has(cacheKey)) {
|
|
559
917
|
return { bundle, ontology: ontologyCache.get(cacheKey) };
|
|
560
918
|
}
|
|
@@ -130,6 +130,7 @@ const {
|
|
|
130
130
|
validateGraphSemantics,
|
|
131
131
|
validateArchiMateEndpointMatrix,
|
|
132
132
|
validateViewElementLimits,
|
|
133
|
+
validateAttributeContracts,
|
|
133
134
|
} = require('./graph-semantics.js');
|
|
134
135
|
const {
|
|
135
136
|
loadSchemaBundleAndOntology,
|
|
@@ -616,6 +617,7 @@ function validateDocument(document, schema, options = {}) {
|
|
|
616
617
|
}
|
|
617
618
|
validateAgainstSchema(document, schema, '#', errors, schema);
|
|
618
619
|
validateGraphSemantics(document, errors, ontology);
|
|
620
|
+
validateAttributeContracts(document, errors, ontology);
|
|
619
621
|
validateArchiMateEndpointMatrix(document, errors, {
|
|
620
622
|
ontology,
|
|
621
623
|
touchedRelationshipIds: options.touchedRelationshipIds,
|
|
@@ -1389,6 +1391,207 @@ function resolveDuplicateConflict(options, candidates) {
|
|
|
1389
1391
|
return { action: 'create', justification: options.justification };
|
|
1390
1392
|
}
|
|
1391
1393
|
|
|
1394
|
+
function mutationNodeId(mutation) {
|
|
1395
|
+
if (!mutation || typeof mutation !== 'object') {
|
|
1396
|
+
return '(invalid)';
|
|
1397
|
+
}
|
|
1398
|
+
if (mutation.type === 'addElement') {
|
|
1399
|
+
return (mutation.element && mutation.element.id) || '(addElement)';
|
|
1400
|
+
}
|
|
1401
|
+
if (mutation.type === 'addRelationship') {
|
|
1402
|
+
return (mutation.relationship && mutation.relationship.id) || '(addRelationship)';
|
|
1403
|
+
}
|
|
1404
|
+
if (mutation.type === 'addView') {
|
|
1405
|
+
return (mutation.view && mutation.view.view_id) || '(addView)';
|
|
1406
|
+
}
|
|
1407
|
+
if (mutation.type === 'updateView') {
|
|
1408
|
+
return mutation.view_id || mutation.id || '(updateView)';
|
|
1409
|
+
}
|
|
1410
|
+
return mutation.id || mutation.view_id || `(${mutation.type})`;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
// Order a batch so it is order-independent: a mutation that references an object
|
|
1414
|
+
// created later in the SAME batch is applied after its producer. Dependencies:
|
|
1415
|
+
// addElement -> views it joins (view_ids)
|
|
1416
|
+
// addRelationship-> views it joins + its source/target elements
|
|
1417
|
+
// addView -> its parent element + included elements/relationships
|
|
1418
|
+
// update*/remove*-> the object they target (when that object is produced here)
|
|
1419
|
+
// A genuine cycle is reported with the id chain so the caller can split the batch.
|
|
1420
|
+
function orderMutationsForApplication(mutations) {
|
|
1421
|
+
const n = mutations.length;
|
|
1422
|
+
const producers = new Map();
|
|
1423
|
+
const addProducer = (key, index) => {
|
|
1424
|
+
if (!key) {
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
if (!producers.has(key)) {
|
|
1428
|
+
producers.set(key, []);
|
|
1429
|
+
}
|
|
1430
|
+
producers.get(key).push(index);
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1433
|
+
mutations.forEach((mutation, index) => {
|
|
1434
|
+
if (!mutation || typeof mutation !== 'object') {
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
if (mutation.type === 'addElement' && mutation.element) {
|
|
1438
|
+
addProducer('element:' + mutation.element.id, index);
|
|
1439
|
+
}
|
|
1440
|
+
if (mutation.type === 'addRelationship' && mutation.relationship) {
|
|
1441
|
+
addProducer('relationship:' + mutation.relationship.id, index);
|
|
1442
|
+
}
|
|
1443
|
+
if (mutation.type === 'addView' && mutation.view) {
|
|
1444
|
+
addProducer('view:' + mutation.view.view_id, index);
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
|
|
1448
|
+
const dependencies = mutations.map(() => new Set());
|
|
1449
|
+
mutations.forEach((mutation, index) => {
|
|
1450
|
+
if (!mutation || typeof mutation !== 'object') {
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
const requireKey = (key) => {
|
|
1454
|
+
const matches = producers.get(key);
|
|
1455
|
+
if (!matches) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
for (const producerIndex of matches) {
|
|
1459
|
+
if (producerIndex !== index) {
|
|
1460
|
+
dependencies[index].add(producerIndex);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
|
|
1465
|
+
if (mutation.type === 'addElement') {
|
|
1466
|
+
for (const viewId of Array.isArray(mutation.view_ids) ? mutation.view_ids : []) {
|
|
1467
|
+
requireKey('view:' + viewId);
|
|
1468
|
+
}
|
|
1469
|
+
} else if (mutation.type === 'addRelationship') {
|
|
1470
|
+
for (const viewId of Array.isArray(mutation.view_ids) ? mutation.view_ids : []) {
|
|
1471
|
+
requireKey('view:' + viewId);
|
|
1472
|
+
}
|
|
1473
|
+
if (mutation.relationship) {
|
|
1474
|
+
requireKey('element:' + mutation.relationship.source_id);
|
|
1475
|
+
requireKey('element:' + mutation.relationship.target_id);
|
|
1476
|
+
}
|
|
1477
|
+
} else if (mutation.type === 'addView') {
|
|
1478
|
+
if (mutation.view) {
|
|
1479
|
+
requireKey('element:' + mutation.view.parent_element_id);
|
|
1480
|
+
for (const elementId of Array.isArray(mutation.view.included_elements) ? mutation.view.included_elements : []) {
|
|
1481
|
+
requireKey('element:' + elementId);
|
|
1482
|
+
}
|
|
1483
|
+
for (const relationshipId of Array.isArray(mutation.view.included_relationships) ? mutation.view.included_relationships : []) {
|
|
1484
|
+
requireKey('relationship:' + relationshipId);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
} else if (mutation.type === 'updateElement') {
|
|
1488
|
+
requireKey('element:' + mutation.id);
|
|
1489
|
+
} else if (mutation.type === 'updateRelationship') {
|
|
1490
|
+
requireKey('relationship:' + mutation.id);
|
|
1491
|
+
} else if (mutation.type === 'updateView') {
|
|
1492
|
+
requireKey('view:' + (mutation.view_id || mutation.id));
|
|
1493
|
+
} else if (mutation.type === 'removeView') {
|
|
1494
|
+
requireKey('view:' + mutation.view_id);
|
|
1495
|
+
} else if (mutation.type === 'removeElement') {
|
|
1496
|
+
requireKey('element:' + mutation.id);
|
|
1497
|
+
} else if (mutation.type === 'removeRelationship') {
|
|
1498
|
+
requireKey('relationship:' + mutation.id);
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
const indegree = mutations.map((_, index) => dependencies[index].size);
|
|
1503
|
+
const dependents = mutations.map(() => []);
|
|
1504
|
+
dependencies.forEach((set, index) => {
|
|
1505
|
+
for (const dependency of set) {
|
|
1506
|
+
dependents[dependency].push(index);
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
const remaining = new Set();
|
|
1511
|
+
for (let index = 0; index < n; index += 1) {
|
|
1512
|
+
remaining.add(index);
|
|
1513
|
+
}
|
|
1514
|
+
const ready = [];
|
|
1515
|
+
for (let index = 0; index < n; index += 1) {
|
|
1516
|
+
if (indegree[index] === 0) {
|
|
1517
|
+
ready.push(index);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
ready.sort((a, b) => a - b);
|
|
1521
|
+
|
|
1522
|
+
const ordered = [];
|
|
1523
|
+
while (ready.length > 0) {
|
|
1524
|
+
const index = ready.shift();
|
|
1525
|
+
if (!remaining.has(index)) {
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
remaining.delete(index);
|
|
1529
|
+
ordered.push(mutations[index]);
|
|
1530
|
+
for (const dependent of dependents[index]) {
|
|
1531
|
+
indegree[dependent] -= 1;
|
|
1532
|
+
if (indegree[dependent] === 0) {
|
|
1533
|
+
ready.push(dependent);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
ready.sort((a, b) => a - b);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
if (ordered.length !== n) {
|
|
1540
|
+
const chain = findMutationCycle(mutations, dependencies, remaining);
|
|
1541
|
+
throw new Error(
|
|
1542
|
+
`Cyclic mutation dependencies in batch: ${chain.join(' -> ')}. `
|
|
1543
|
+
+ 'Order the batch so each referenced object is created first, or split the mutually-dependent objects into separate calls.',
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
return ordered;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
function findMutationCycle(mutations, dependencies, remaining) {
|
|
1551
|
+
const visited = new Set();
|
|
1552
|
+
const inStack = new Set();
|
|
1553
|
+
const stack = [];
|
|
1554
|
+
let cycle = null;
|
|
1555
|
+
|
|
1556
|
+
const visit = (index) => {
|
|
1557
|
+
if (cycle) {
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
visited.add(index);
|
|
1561
|
+
inStack.add(index);
|
|
1562
|
+
stack.push(index);
|
|
1563
|
+
for (const dependency of dependencies[index]) {
|
|
1564
|
+
if (!remaining.has(dependency)) {
|
|
1565
|
+
continue;
|
|
1566
|
+
}
|
|
1567
|
+
if (inStack.has(dependency)) {
|
|
1568
|
+
cycle = stack.slice(stack.indexOf(dependency)).concat(dependency);
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
if (!visited.has(dependency)) {
|
|
1572
|
+
visit(dependency);
|
|
1573
|
+
}
|
|
1574
|
+
if (cycle) {
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
inStack.delete(index);
|
|
1579
|
+
stack.pop();
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
for (const index of remaining) {
|
|
1583
|
+
if (!visited.has(index)) {
|
|
1584
|
+
visit(index);
|
|
1585
|
+
}
|
|
1586
|
+
if (cycle) {
|
|
1587
|
+
break;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
const chain = cycle || [...remaining];
|
|
1592
|
+
return chain.map((index) => mutationNodeId(mutations[index]));
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1392
1595
|
function applyMutations(document, mutations, options = {}) {
|
|
1393
1596
|
const nextDocument = clone(document);
|
|
1394
1597
|
const touchedElementIds = new Set();
|
|
@@ -1401,7 +1604,11 @@ function applyMutations(document, mutations, options = {}) {
|
|
|
1401
1604
|
throw new Error('mutations must contain at least one mutation');
|
|
1402
1605
|
}
|
|
1403
1606
|
|
|
1404
|
-
|
|
1607
|
+
// Apply in dependency order so a batch is order-independent (see
|
|
1608
|
+
// orderMutationsForApplication); a genuine cycle throws with the id chain.
|
|
1609
|
+
const orderedMutations = orderMutationsForApplication(mutations);
|
|
1610
|
+
|
|
1611
|
+
for (const mutation of orderedMutations) {
|
|
1405
1612
|
if (!mutation || typeof mutation !== 'object' || !HANDLED_MUTATION_TYPES.has(mutation.type)) {
|
|
1406
1613
|
throw new Error(`Unsupported mutation type: ${mutation && mutation.type}`);
|
|
1407
1614
|
}
|
|
@@ -2699,15 +2906,51 @@ function compactMutationResponse(payload) {
|
|
|
2699
2906
|
return compact;
|
|
2700
2907
|
}
|
|
2701
2908
|
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2909
|
+
// The typed getSystemArchitecture output contract (see
|
|
2910
|
+
// GET_SYSTEM_ARCHITECTURE_OUTPUT_SCHEMA). The error variant allows only the
|
|
2911
|
+
// listed keys, so any error (local or mirrored from a cross-project read) is
|
|
2912
|
+
// projected onto that shape with category + message guaranteed. Exposed so the
|
|
2913
|
+
// argo MCP server can build the SAME structuredContent for a cross-project read
|
|
2914
|
+
// (which bypasses this module's callTool) instead of returning a result without
|
|
2915
|
+
// structuredContent — which violates the declared outputSchema (-32600).
|
|
2916
|
+
const GET_SYSTEM_ARCHITECTURE_ERROR_KEYS = Object.freeze([
|
|
2917
|
+
'category', 'message', 'action', 'fullSnapshotFallback', 'state',
|
|
2918
|
+
'canonicalVersion', 'contentVersion', 'indexVersion',
|
|
2919
|
+
'completedChannels', 'missingChannels', 'mismatchedChannels',
|
|
2920
|
+
]);
|
|
2921
|
+
|
|
2922
|
+
function normalizeGetSystemArchitectureError(error) {
|
|
2923
|
+
const source = error && typeof error === 'object' ? error : {};
|
|
2924
|
+
const normalized = {};
|
|
2925
|
+
for (const key of GET_SYSTEM_ARCHITECTURE_ERROR_KEYS) {
|
|
2926
|
+
if (Object.prototype.hasOwnProperty.call(source, key) && source[key] !== undefined) {
|
|
2927
|
+
normalized[key] = source[key];
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
if (typeof normalized.category !== 'string' || normalized.category === '') {
|
|
2931
|
+
normalized.category = 'GET_SYSTEM_ARCHITECTURE_ERROR';
|
|
2932
|
+
}
|
|
2933
|
+
if (typeof normalized.message !== 'string' || normalized.message === '') {
|
|
2934
|
+
normalized.message = typeof source.reason === 'string' && source.reason !== ''
|
|
2935
|
+
? source.reason
|
|
2936
|
+
: 'getSystemArchitecture failed';
|
|
2937
|
+
}
|
|
2938
|
+
return normalized;
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
function buildGetSystemArchitectureStructuredContent(payload) {
|
|
2942
|
+
const failed = Boolean(payload) && payload.status === 'failed';
|
|
2943
|
+
return {
|
|
2705
2944
|
version: '1.0',
|
|
2706
2945
|
mode: failed ? 'error' : 'semantic-query',
|
|
2707
|
-
document: failed ? null : (payload.document === undefined ? null : payload.document),
|
|
2708
|
-
query: failed ? null : (payload.query || null),
|
|
2709
|
-
error: failed ? payload.error : null,
|
|
2710
|
-
}
|
|
2946
|
+
document: failed ? null : (payload && payload.document === undefined ? null : payload.document),
|
|
2947
|
+
query: failed ? null : ((payload && payload.query) || null),
|
|
2948
|
+
error: failed ? normalizeGetSystemArchitectureError(payload.error) : null,
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
function getSystemArchitectureResult(payload) {
|
|
2953
|
+
return toolResult(payload, buildGetSystemArchitectureStructuredContent(payload));
|
|
2711
2954
|
}
|
|
2712
2955
|
|
|
2713
2956
|
async function callTool(name, args = {}, dependencies = undefined) {
|
|
@@ -4488,6 +4731,7 @@ if (require.main === module) {
|
|
|
4488
4731
|
|
|
4489
4732
|
module.exports = {
|
|
4490
4733
|
GET_SYSTEM_ARCHITECTURE_OUTPUT_SCHEMA,
|
|
4734
|
+
buildGetSystemArchitectureStructuredContent,
|
|
4491
4735
|
TOOLS,
|
|
4492
4736
|
applyMutations,
|
|
4493
4737
|
buildBusinessSemanticSummary,
|
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
validateGraphSemantics,
|
|
18
18
|
validateArchiMateEndpointMatrix,
|
|
19
19
|
validateViewElementLimits,
|
|
20
|
+
validateAttributeContracts,
|
|
20
21
|
} = require('./graph-semantics.js');
|
|
21
22
|
|
|
22
23
|
function main() {
|
|
@@ -43,6 +44,7 @@ function main() {
|
|
|
43
44
|
}
|
|
44
45
|
validateAgainstSchema(document, schema, '#', errors, schema);
|
|
45
46
|
validateGraphSemantics(document, errors, ontology);
|
|
47
|
+
validateAttributeContracts(document, errors, ontology);
|
|
46
48
|
validateArchiMateEndpointMatrix(document, errors, { ontology });
|
|
47
49
|
validateViewElementLimits(document, errors, { ontology });
|
|
48
50
|
|
package/cordis.patch.yml
CHANGED
|
@@ -2,5 +2,14 @@
|
|
|
2
2
|
- insert:
|
|
3
3
|
- id: argo-workspace
|
|
4
4
|
name: archgraph-argo/dsh-argo-workspace
|
|
5
|
+
config:
|
|
6
|
+
servers:
|
|
7
|
+
- id: argo
|
|
8
|
+
injectWorkspaceRoot: true
|
|
9
|
+
- id: graph-mcp
|
|
10
|
+
serverPath: '../argo/mcp-bridges/graph-mcp-stdio.js'
|
|
11
|
+
env:
|
|
12
|
+
GRAPH_MCP_URL: https://argo.derekworkspacev5.com/mcp
|
|
13
|
+
injectWorkspaceRoot: false
|
|
5
14
|
- id: argo-wakeup
|
|
6
15
|
name: archgraph-argo/dsh-argo-wakeup
|
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
// install-argo.ps1 copies this file verbatim into ~/.dsh/plugins, so the
|
|
3
3
|
// deployed plugin and this shipped bundle artifact are byte-identical.
|
|
4
4
|
//
|
|
5
|
-
// Direct MCP bridge
|
|
6
|
-
//
|
|
7
|
-
// directory (SessionHeader.cwd) as the per-call
|
|
8
|
-
// one dsh instance follows whichever workspace the
|
|
9
|
-
// model sees no extra parameters and no internal tool
|
|
10
|
-
// honors the injected workspaceRoot unconditionally.
|
|
5
|
+
// Direct MCP stdio bridge(es) for DeepSeek Harness. Registers every tool of each
|
|
6
|
+
// configured MCP server as mcp__<id>__* and, for the argo server, injects the
|
|
7
|
+
// current session's workspace directory (SessionHeader.cwd) as the per-call
|
|
8
|
+
// `workspaceRoot` argument, so one dsh instance follows whichever workspace the
|
|
9
|
+
// user switched to - the model sees no extra parameters and no internal tool
|
|
10
|
+
// names. The argo server honors the injected workspaceRoot unconditionally.
|
|
11
|
+
//
|
|
12
|
+
// Multiple servers are supported so a host that can only spawn local stdio
|
|
13
|
+
// children (DSH) can still mount the remote federation Graph MCP through the
|
|
14
|
+
// stdio bridge (GRAPH_MCP_URL). Configure via `config.servers` (a list); the
|
|
15
|
+
// legacy single-server shape (`config.serverPath`) is still honored.
|
|
11
16
|
//
|
|
12
17
|
// Zero dependencies on purpose: implements the minimal MCP stdio client
|
|
13
18
|
// (JSON-RPC 2.0, one JSON object per line) with Node built-ins only, so the
|
|
@@ -24,9 +29,70 @@ const DEFAULT_SERVER_PATH = fileURLToPath(
|
|
|
24
29
|
new URL('../argo/scripts/argo-mcp-server.js', import.meta.url),
|
|
25
30
|
)
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
// A `serverPath`/`args` entry that starts with ./ or ../ resolves relative to this
|
|
33
|
+
// plugin module (portable bundle references); an absolute path is used as-is.
|
|
34
|
+
function resolveMaybeRelative(value) {
|
|
35
|
+
if (typeof value === 'string' && /^[.][\\/]/.test(value)) {
|
|
36
|
+
try {
|
|
37
|
+
return fileURLToPath(new URL(value, import.meta.url))
|
|
38
|
+
} catch {
|
|
39
|
+
return value
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return value
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Normalize config into a list of server specs (backward compatible). */
|
|
46
|
+
function normalizeServerSpecs(config) {
|
|
47
|
+
const topWorkspaces = Array.isArray(config.workspaces) ? config.workspaces : []
|
|
48
|
+
const withCommon = (spec) => {
|
|
49
|
+
const env = { ...process.env, ...(spec.env || {}) }
|
|
50
|
+
if (spec.injectWorkspaceRoot && topWorkspaces.length > 0) {
|
|
51
|
+
env.ARGO_WORKSPACE_ROOTS = topWorkspaces.join(';')
|
|
52
|
+
}
|
|
53
|
+
return { ...spec, env, cwd: spec.cwd ?? (spec.injectWorkspaceRoot ? config.cwd : undefined) }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (Array.isArray(config.servers) && config.servers.length > 0) {
|
|
57
|
+
return config.servers.map((server) => {
|
|
58
|
+
const id = typeof server.id === 'string' && server.id !== '' ? server.id : 'server'
|
|
59
|
+
const injectWorkspaceRoot = server.injectWorkspaceRoot !== undefined
|
|
60
|
+
? server.injectWorkspaceRoot === true
|
|
61
|
+
: id === 'argo'
|
|
62
|
+
const serverPath = resolveMaybeRelative(server.serverPath)
|
|
63
|
+
?? (id === 'argo' ? DEFAULT_SERVER_PATH : undefined)
|
|
64
|
+
const args = Array.isArray(server.args)
|
|
65
|
+
? server.args.map(resolveMaybeRelative)
|
|
66
|
+
: (serverPath ? [serverPath] : [])
|
|
67
|
+
return withCommon({
|
|
68
|
+
id,
|
|
69
|
+
// mcp__<id>__ prefix mirrors the host's server-name convention.
|
|
70
|
+
prefix: typeof server.prefix === 'string' && server.prefix !== '' ? server.prefix : 'mcp__' + id + '__',
|
|
71
|
+
command: typeof server.command === 'string' && server.command !== '' ? server.command : 'node',
|
|
72
|
+
args,
|
|
73
|
+
env: server.env && typeof server.env === 'object' ? server.env : {},
|
|
74
|
+
cwd: server.cwd,
|
|
75
|
+
injectWorkspaceRoot,
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Legacy single-server shape: the argo workspace bridge.
|
|
81
|
+
const serverPath = config.serverPath ?? process.env.ARGO_SERVER_PATH ?? DEFAULT_SERVER_PATH
|
|
82
|
+
return [withCommon({
|
|
83
|
+
id: 'argo',
|
|
84
|
+
prefix: 'mcp__argo__',
|
|
85
|
+
command: 'node',
|
|
86
|
+
args: [serverPath],
|
|
87
|
+
env: {},
|
|
88
|
+
cwd: config.cwd,
|
|
89
|
+
injectWorkspaceRoot: true,
|
|
90
|
+
})]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Minimal MCP stdio client over one spawned server process. */
|
|
94
|
+
function createStdioClient(command, args, env, cwd) {
|
|
95
|
+
const child = spawn(command, args, {
|
|
30
96
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
31
97
|
env,
|
|
32
98
|
...(cwd ? { cwd } : {}),
|
|
@@ -43,7 +109,7 @@ function createArgoClient(serverPath, env, cwd) {
|
|
|
43
109
|
else resolve(message.result)
|
|
44
110
|
}
|
|
45
111
|
})
|
|
46
|
-
child.stderr.on('data', () => {}) // drain; the
|
|
112
|
+
child.stderr.on('data', () => {}) // drain; the server logs to stderr
|
|
47
113
|
const request = (method, params) => new Promise((resolve, reject) => {
|
|
48
114
|
const id = nextId++
|
|
49
115
|
pending.set(id, { resolve, reject })
|
|
@@ -58,16 +124,10 @@ function createArgoClient(serverPath, env, cwd) {
|
|
|
58
124
|
}
|
|
59
125
|
}
|
|
60
126
|
|
|
61
|
-
/** Connect, list tools, register them
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
?? DEFAULT_SERVER_PATH
|
|
66
|
-
const workspaces = Array.isArray(config.workspaces) ? config.workspaces : []
|
|
67
|
-
const env = { ...process.env }
|
|
68
|
-
if (workspaces.length > 0) env.ARGO_WORKSPACE_ROOTS = workspaces.join(';')
|
|
69
|
-
const client = createArgoClient(serverPath, env, config.cwd)
|
|
70
|
-
ctx.effect(() => () => client.close(), 'dsh-argo-workspace.dispose()')
|
|
127
|
+
/** Connect one server, list its tools, and register them under its prefix. */
|
|
128
|
+
async function mountServer(ctx, spec, registered) {
|
|
129
|
+
const client = createStdioClient(spec.command, spec.args, spec.env, spec.cwd)
|
|
130
|
+
ctx.effect(() => () => client.close(), `dsh-argo-workspace.dispose(${spec.id})`)
|
|
71
131
|
|
|
72
132
|
let tools = []
|
|
73
133
|
try {
|
|
@@ -80,14 +140,13 @@ export async function apply(ctx, config) {
|
|
|
80
140
|
const listed = await client.request('tools/list', {})
|
|
81
141
|
tools = (listed && Array.isArray(listed.tools)) ? listed.tools : []
|
|
82
142
|
} catch (error) {
|
|
83
|
-
console.warn(`[dsh-argo-workspace] failed to connect to
|
|
143
|
+
console.warn(`[dsh-argo-workspace] failed to connect to '${spec.id}' (${spec.args.join(' ')}): ${error && error.message ? error.message : error}`)
|
|
84
144
|
return
|
|
85
145
|
}
|
|
86
146
|
|
|
87
|
-
const disposers = []
|
|
88
147
|
for (const tool of tools) {
|
|
89
|
-
const publicName =
|
|
90
|
-
|
|
148
|
+
const publicName = spec.prefix + tool.name
|
|
149
|
+
registered.push(ctx.tools.register({
|
|
91
150
|
name: publicName,
|
|
92
151
|
description: tool.description ?? '',
|
|
93
152
|
parameters: tool.inputSchema,
|
|
@@ -107,12 +166,14 @@ export async function apply(ctx, config) {
|
|
|
107
166
|
// SessionHeader.cwd (the durable session workspace), NOT
|
|
108
167
|
// requestHeader() — that returns the request EpochHeader
|
|
109
168
|
// (config/system/tools) which has no cwd field.
|
|
110
|
-
const sessionCwd = exec && exec.agent && exec.agent.session
|
|
111
|
-
? exec.agent.session.header?.cwd
|
|
112
|
-
: undefined
|
|
113
169
|
const injected = { ...(args && typeof args === 'object' ? args : {}) }
|
|
114
|
-
if (
|
|
115
|
-
|
|
170
|
+
if (spec.injectWorkspaceRoot) {
|
|
171
|
+
const sessionCwd = exec && exec.agent && exec.agent.session
|
|
172
|
+
? exec.agent.session.header?.cwd
|
|
173
|
+
: undefined
|
|
174
|
+
if (typeof sessionCwd === 'string' && sessionCwd !== '') {
|
|
175
|
+
injected.workspaceRoot = sessionCwd
|
|
176
|
+
}
|
|
116
177
|
}
|
|
117
178
|
if (exec && exec.signal && exec.signal.aborted) {
|
|
118
179
|
throw new Error('aborted')
|
|
@@ -136,7 +197,16 @@ export async function apply(ctx, config) {
|
|
|
136
197
|
},
|
|
137
198
|
}))
|
|
138
199
|
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Connect every configured server, register its tools, keep clients until disposal. */
|
|
203
|
+
export async function apply(ctx, config) {
|
|
204
|
+
const specs = normalizeServerSpecs(config || {})
|
|
205
|
+
const registered = []
|
|
206
|
+
for (const spec of specs) {
|
|
207
|
+
await mountServer(ctx, spec, registered)
|
|
208
|
+
}
|
|
139
209
|
ctx.effect(() => () => {
|
|
140
|
-
for (const dispose of
|
|
210
|
+
for (const dispose of registered) dispose()
|
|
141
211
|
}, 'dsh-argo-workspace.tools')
|
|
142
212
|
}
|
package/install-argo.ps1
CHANGED
|
@@ -776,10 +776,9 @@ Write-Host "[4/22] argo\skills\argo-init -> $skillDest"
|
|
|
776
776
|
Copy-Tree -Source $skillSrc -Destination $skillDest
|
|
777
777
|
$reconcileSkillSrc = Join-Path (Join-Path $argoDir 'skills') 'ea-human-reconcile'
|
|
778
778
|
$diagSkillSrc = Join-Path (Join-Path $argoDir 'skills') 'agent-search-diagnosis'
|
|
779
|
-
Write-Host
|
|
779
|
+
Write-Host " argo\skills\ea-human-reconcile -> $SkillsRoot\ea-human-reconcile (EA human draft reconcile skill)"
|
|
780
780
|
Copy-Tree -Source $reconcileSkillSrc -Destination (Join-Path $SkillsRoot 'ea-human-reconcile')
|
|
781
|
-
|
|
782
|
-
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path $SkillsRoot 'agent-search-diagnosis')
|
|
781
|
+
# agent-search-diagnosis is OpenCode-only (it assumes `opencode` session export); not deployed to Copilot.
|
|
783
782
|
|
|
784
783
|
$ruleSrc = Join-Path (Join-Path $argoDir 'rules') 'archgraph.instructions.md'
|
|
785
784
|
$ruleDest = Join-Path $PromptsRoot 'archgraph.instructions.md'
|
|
@@ -795,10 +794,9 @@ Copy-Item -Force -Path $depsSrc -Destination $depsDest
|
|
|
795
794
|
$cursorSkillDest = Join-Path $CursorSkillsRoot 'argo-init'
|
|
796
795
|
Write-Host "[7/22] argo\skills\argo-init -> $cursorSkillDest (Cursor)"
|
|
797
796
|
Copy-Tree -Source $skillSrc -Destination $cursorSkillDest
|
|
798
|
-
Write-Host
|
|
797
|
+
Write-Host " argo\skills\ea-human-reconcile -> $CursorSkillsRoot\ea-human-reconcile (Cursor)"
|
|
799
798
|
Copy-Tree -Source $reconcileSkillSrc -Destination (Join-Path $CursorSkillsRoot 'ea-human-reconcile')
|
|
800
|
-
|
|
801
|
-
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path $CursorSkillsRoot 'agent-search-diagnosis')
|
|
799
|
+
# agent-search-diagnosis is OpenCode-only (it assumes `opencode` session export); not deployed to Cursor.
|
|
802
800
|
|
|
803
801
|
$mcpBridgeSrc = Join-Path $argoDir 'mcp-bridges'
|
|
804
802
|
$mcpBridgeDest = Join-Path $CursorMcpBridgesRoot ''
|
|
@@ -808,9 +806,9 @@ Copy-Tree -Source $mcpBridgeSrc -Destination $mcpBridgeDest
|
|
|
808
806
|
$openCodeSkillDest = Join-Path $OpenCodeSkillsRoot 'argo-init'
|
|
809
807
|
Write-Host "[8/22] argo\skills\argo-init -> $openCodeSkillDest (OpenCode)"
|
|
810
808
|
Copy-Tree -Source $skillSrc -Destination $openCodeSkillDest
|
|
811
|
-
Write-Host
|
|
809
|
+
Write-Host " argo\skills\ea-human-reconcile -> $OpenCodeSkillsRoot\ea-human-reconcile (OpenCode)"
|
|
812
810
|
Copy-Tree -Source $reconcileSkillSrc -Destination (Join-Path $OpenCodeSkillsRoot 'ea-human-reconcile')
|
|
813
|
-
Write-Host
|
|
811
|
+
Write-Host " argo\skills\agent-search-diagnosis -> $OpenCodeSkillsRoot\agent-search-diagnosis (OpenCode-only: assumes opencode session export)"
|
|
814
812
|
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path $OpenCodeSkillsRoot 'agent-search-diagnosis')
|
|
815
813
|
|
|
816
814
|
Write-Host "[9/22] argo\rules\archgraph.instructions.md -> $OpenCodeAgentsPath (OpenCode global AGENTS.md)"
|
|
@@ -849,15 +847,14 @@ if ($SkipDsh) {
|
|
|
849
847
|
|
|
850
848
|
Write-Host "[16/22] argo\skills\argo-init -> $dshSkillDest (DeepSeek Harness skill)"
|
|
851
849
|
Copy-Tree -Source (Join-Path $argoDir 'skills\argo-init') -Destination $dshSkillDest
|
|
852
|
-
Write-Host
|
|
850
|
+
Write-Host " argo\skills\ea-human-reconcile -> $DshHome\skills\ea-human-reconcile (DeepSeek Harness skill)"
|
|
853
851
|
Copy-Tree -Source (Join-Path $argoDir 'skills\ea-human-reconcile') -Destination (Join-Path (Join-Path $DshHome 'skills') 'ea-human-reconcile')
|
|
854
|
-
|
|
855
|
-
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path (Join-Path $DshHome 'skills') 'agent-search-diagnosis')
|
|
852
|
+
# agent-search-diagnosis is OpenCode-only (it assumes `opencode` session export); not deployed to DeepSeek Harness.
|
|
856
853
|
|
|
857
854
|
Write-Host "[17/22] dsh-argo-wakeup\index.js (single source; gate from argo\rules\archgraph.instructions.md <WakeupGuideline>) -> $DshHome\plugins\dsh-argo-wakeup\index.js (DeepSeek Harness wakeup plugin)"
|
|
858
855
|
$wakeupDshPath = New-DshWakeupPlugin -DshHome $DshHome
|
|
859
856
|
|
|
860
|
-
Write-Host "[18/22] argo-workspace + argo-wakeup rows -> $patchPath (DeepSeek Harness MCP
|
|
857
|
+
Write-Host "[18/22] argo-workspace (argo + graph-mcp) + argo-wakeup rows -> $patchPath (DeepSeek Harness MCP bridges + wakeup plugin)"
|
|
861
858
|
# The generated dsh-argo-workspace bridge connects directly to the argo
|
|
862
859
|
# server (no dsh-mcp-client row), registers every tool as mcp__argo__* and
|
|
863
860
|
# injects the current session's workspace (SessionHeader.cwd) as the
|
|
@@ -865,9 +862,20 @@ if ($SkipDsh) {
|
|
|
865
862
|
# user switched to. The server honors the injected workspaceRoot
|
|
866
863
|
# unconditionally.
|
|
867
864
|
$bridgeDshPath = New-DshWorkspaceBridge -DshHome $DshHome
|
|
865
|
+
# Deploy the federation Graph MCP stdio bridge next to the DSH plugins, so the
|
|
866
|
+
# remote graph-mcp (registry_*/mirror_*/graph_*) mounts as an ordinary local
|
|
867
|
+
# stdio server - the same bridge Cursor/Doubao already use.
|
|
868
|
+
$dshBridgeDir = Join-Path $DshHome 'mcp-bridges'
|
|
869
|
+
Copy-Tree -Source (Join-Path $argoDir 'mcp-bridges') -Destination $dshBridgeDir
|
|
870
|
+
$dshGraphBridgePath = (Join-Path $dshBridgeDir 'graph-mcp-stdio.js').Replace('\', '/')
|
|
868
871
|
if ($bridgeDshPath) {
|
|
869
872
|
$bridgeUrl = 'file:///' + (($bridgeDshPath -replace '\\', '/').TrimStart('/'))
|
|
870
|
-
|
|
873
|
+
# One bridge plugin mounts every server; the argo server follows the session
|
|
874
|
+
# workspace (workspaceRoot), graph-mcp does not inject workspaceRoot.
|
|
875
|
+
$serversYaml = " servers:`n"
|
|
876
|
+
$serversYaml += " - id: argo`n serverPath: '$argoServer'`n injectWorkspaceRoot: true`n"
|
|
877
|
+
$serversYaml += " - id: graph-mcp`n command: node`n args:`n - '$dshGraphBridgePath'`n env:`n GRAPH_MCP_URL: '$GraphMcpUrl'`n injectWorkspaceRoot: false`n"
|
|
878
|
+
$bridgeConfig = " config:`n" + $serversYaml
|
|
871
879
|
if ($DshWorkspaces) {
|
|
872
880
|
$wsList = @($DshWorkspaces.Replace('\', '/').Split(';') | ForEach-Object { " - $_" }) -join "`n"
|
|
873
881
|
$bridgeConfig += " workspaces:`n" + $wsList + "`n"
|
|
@@ -891,10 +899,8 @@ if ($SkipDsh) {
|
|
|
891
899
|
Write-Host "[19/22] argo\agents -> $DshHome\.agent-presets\<id> (DeepSeek Harness agent presets)"
|
|
892
900
|
New-DshAgentPresets -DshHome $DshHome -AgentsSrc (Join-Path $argoDir 'agents')
|
|
893
901
|
|
|
894
|
-
Write-Host "
|
|
895
|
-
Write-Host "
|
|
896
|
-
Write-Host " the local argo server); an HTTP remote MCP server has no equivalent cordis row here."
|
|
897
|
-
Write-Host " Restart `dsh web` to activate the MCP bridge and the wakeup plugin;"
|
|
902
|
+
Write-Host " graph-mcp registered for DeepSeek Harness as a stdio bridge -> $dshGraphBridgePath (GRAPH_MCP_URL=$GraphMcpUrl)"
|
|
903
|
+
Write-Host " Restart `dsh web` to activate the MCP bridges and the wakeup plugin;"
|
|
898
904
|
Write-Host ' new sessions pick up the global rule and the argo-init skill automatically.'
|
|
899
905
|
Write-Host ' The argo tools (mcp__argo__*) auto-follow the workspace the user switched to'
|
|
900
906
|
Write-Host ' in one dsh instance - no restart needed between workspaces (the server honors'
|
|
@@ -914,10 +920,9 @@ if ($SkipOpenClaw) {
|
|
|
914
920
|
|
|
915
921
|
Write-Host "[21/22] argo\skills\argo-init -> $openClawSkillDest (OpenClaw managed skill, all agents)"
|
|
916
922
|
Copy-Tree -Source (Join-Path $argoDir 'skills\argo-init') -Destination $openClawSkillDest
|
|
917
|
-
Write-Host
|
|
923
|
+
Write-Host " argo\skills\ea-human-reconcile -> $OpenClawHome\skills\ea-human-reconcile (OpenClaw managed skill, all agents)"
|
|
918
924
|
Copy-Tree -Source (Join-Path $argoDir 'skills\ea-human-reconcile') -Destination (Join-Path (Join-Path $OpenClawHome 'skills') 'ea-human-reconcile')
|
|
919
|
-
|
|
920
|
-
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path (Join-Path $OpenClawHome 'skills') 'agent-search-diagnosis')
|
|
925
|
+
# agent-search-diagnosis is OpenCode-only (it assumes `opencode` session export); not deployed to OpenClaw.
|
|
921
926
|
|
|
922
927
|
Write-Host ' OpenClaw injects AGENTS.md into Project Context on every session, so the wakeup'
|
|
923
928
|
Write-Host ' gate (UNCONDITIONAL STARTUP GATE) is active on the next OpenClaw session; restart'
|
|
@@ -937,7 +942,8 @@ if ($SkipDoubao) {
|
|
|
937
942
|
# fully ported surface). MCP servers are registered through Doubao's in-app
|
|
938
943
|
# custom connector UI (STDIO), not a config file, so the installer emits a
|
|
939
944
|
# copy-paste connector recipe instead of writing a config.
|
|
940
|
-
|
|
945
|
+
# agent-search-diagnosis is OpenCode-only (it assumes `opencode` session export); not deployed to Doubao.
|
|
946
|
+
$doubaoSkills = @('argo-init', 'ea-human-reconcile')
|
|
941
947
|
$doubaoSkillsSrc = Join-Path $argoDir 'skills'
|
|
942
948
|
Write-Host '==> Deploying Doubao (desktop agent mode) integration'
|
|
943
949
|
Copy-DoubaoSkills -Root (Join-Path $DoubaoWorkspace '.user_skills') -SourceSkillsRoot $doubaoSkillsSrc -SkillNames $doubaoSkills -Label 'workspace .user_skills'
|
package/package.json
CHANGED