archgraph-argo-beta 0.27.0-beta.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.
Files changed (85) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +107 -0
  3. package/argo/.env.example +170 -0
  4. package/argo/defaults/EA-model-template.qea +0 -0
  5. package/argo/defaults/design/KG/SystemArchitecture.json +128 -0
  6. package/argo/mcp-bridges/graph-mcp-stdio.js +98 -0
  7. package/argo/package.json +8 -0
  8. package/argo/plugins/argo-cost-collector.js +35 -0
  9. package/argo/plugins/argo-wakeup.js +29 -0
  10. package/argo/rules/archgraph.instructions.md +189 -0
  11. package/argo/schema/ImplementationToCodingHandoff.schema.json +252 -0
  12. package/argo/schema/ImplementationToIntentTraceProposal.schema.json +180 -0
  13. package/argo/schema/IntentToImplementationHandoff.schema.json +75 -0
  14. package/argo/schema/SystemArchitecture.schema.json +378 -0
  15. package/argo/schema/archimate3.2.md +7153 -0
  16. package/argo/schema/argob-rules.json +12229 -0
  17. package/argo/schema/argob.config.json +20 -0
  18. package/argo/scripts/ARCHITECTURE.md +58 -0
  19. package/argo/scripts/agentSearchDiagnose.js +407 -0
  20. package/argo/scripts/archimate32-rules.js +12301 -0
  21. package/argo/scripts/argo-mcp-server.js +952 -0
  22. package/argo/scripts/argo-paths.js +168 -0
  23. package/argo/scripts/argob-schema.js +574 -0
  24. package/argo/scripts/ea-qea-sync-lib.js +1014 -0
  25. package/argo/scripts/ea-qea-sync.js +110 -0
  26. package/argo/scripts/ensureArgoHarnessEnvironment.js +451 -0
  27. package/argo/scripts/external-graph-query.js +162 -0
  28. package/argo/scripts/generateArchitectureDiffPlantuml.js +466 -0
  29. package/argo/scripts/graph-rag/ARCHITECTURE.md +192 -0
  30. package/argo/scripts/graph-rag/agentCostLog.js +179 -0
  31. package/argo/scripts/graph-rag/canonicalProjectionAuthority.js +45 -0
  32. package/argo/scripts/graph-rag/defaultSemanticRetrieval.js +1244 -0
  33. package/argo/scripts/graph-rag/embeddingProviderProfile.js +89 -0
  34. package/argo/scripts/graph-rag/embeddingQualificationGate.js +59 -0
  35. package/argo/scripts/graph-rag/externalProductionConfig.js +74 -0
  36. package/argo/scripts/graph-rag/hybridRetrieval.js +114 -0
  37. package/argo/scripts/graph-rag/liveEmbeddingIndexGate.js +128 -0
  38. package/argo/scripts/graph-rag/liveEmbeddingNeo4jBoundary.js +137 -0
  39. package/argo/scripts/graph-rag/liveEmbeddingProviderClient.js +49 -0
  40. package/argo/scripts/graph-rag/liveEmbeddingProviderConfig.js +571 -0
  41. package/argo/scripts/graph-rag/mcpCrashDiagnostics.js +137 -0
  42. package/argo/scripts/graph-rag/mutationEmbeddingVectorLifecycle.js +1266 -0
  43. package/argo/scripts/graph-rag/neo4jNativeRetrieval.js +37 -0
  44. package/argo/scripts/graph-rag/productionGraphRagRuntime.js +1633 -0
  45. package/argo/scripts/graph-rag/rerankRetrieval.js +201 -0
  46. package/argo/scripts/graph-rag/semantic-persistence/ARCHITECTURE.md +51 -0
  47. package/argo/scripts/graph-rag/semantic-persistence/productionSemanticBackfill.js +342 -0
  48. package/argo/scripts/graph-rag/semantic-persistence/productionSemanticCheckpointStore.js +99 -0
  49. package/argo/scripts/graph-rag/semantic-persistence/productionSemanticNeo4jAdapter.js +186 -0
  50. package/argo/scripts/graph-rag/semantic-persistence/productionSemanticProjectionStore.js +171 -0
  51. package/argo/scripts/graph-rag/semanticAlignmentLock.js +76 -0
  52. package/argo/scripts/graph-rag/semanticAlignmentRunner.js +131 -0
  53. package/argo/scripts/graph-rag/semanticInitConfiguration.js +24 -0
  54. package/argo/scripts/graph-rag/semanticOperatorError.js +38 -0
  55. package/argo/scripts/graph-rag/semanticOperatorJourney.js +459 -0
  56. package/argo/scripts/graph-rag/semanticReadinessAttestationStore.js +398 -0
  57. package/argo/scripts/graph-rag/semanticRecordText.js +75 -0
  58. package/argo/scripts/graph-rag/systemMetadataCommandAdapter.js +269 -0
  59. package/argo/scripts/graph-semantics.js +266 -0
  60. package/argo/scripts/lossless-write-gate.js +500 -0
  61. package/argo/scripts/neo4j-system-architecture-store.js +1066 -0
  62. package/argo/scripts/repair-subdiagram-views.js +288 -0
  63. package/argo/scripts/repositoryArgoEnvironment.js +101 -0
  64. package/argo/scripts/runArchitectureTests.js +591 -0
  65. package/argo/scripts/semanticOperatorJourneyCli.js +91 -0
  66. package/argo/scripts/syncSystemArchitectureToNeo4j.js +67 -0
  67. package/argo/scripts/systemarchitecture-mcp-server.js +4508 -0
  68. package/argo/scripts/test-executors/_template.js +58 -0
  69. package/argo/scripts/test-executors/default.js +199 -0
  70. package/argo/scripts/validateStageHandoff.js +459 -0
  71. package/argo/scripts/validateSystemArchitecture.js +261 -0
  72. package/argo/scripts/validateTraceProposal.js +181 -0
  73. package/argo/scripts/validator-mcp-server.js +347 -0
  74. package/argo/skills/agent-search-diagnosis/SKILL.md +60 -0
  75. package/argo/skills/argo-init/SKILL.md +86 -0
  76. package/argo/skills/ea-human-reconcile/SKILL.md +40 -0
  77. package/bin/argo-deploy.js +12 -0
  78. package/cordis.patch.yml +6 -0
  79. package/dsh-argo-wakeup/index.js +17 -0
  80. package/dsh-argo-wakeup/package.json +1 -0
  81. package/dsh-argo-workspace/index.js +142 -0
  82. package/dsh-argo-workspace/package.json +1 -0
  83. package/install-argo.ps1 +1162 -0
  84. package/package.json +56 -0
  85. package/vendor/neo4j-driver-6.2.0.tgz +0 -0
@@ -0,0 +1,288 @@
1
+ 'use strict';
2
+
3
+ // Repair the parent->child side of the sub-diagram link.
4
+ //
5
+ // The ARGO MCP view-write path maintains `view.parent_element_id` (child -> parent)
6
+ // but historically never updated the mirror field `element.subdiagram_views`
7
+ // (parent -> child). This script rebuilds every element's `subdiagram_views`
8
+ // from the canonical source of truth — the views' `parent_element_id` — so the
9
+ // two sides agree again.
10
+ //
11
+ // Modes:
12
+ // --check (default) dry-run: print the per-element diff, exit 1 if any drift.
13
+ // --fix apply the corrections. For the intent graph
14
+ // (design/KG/SystemArchitecture.json) this writes THROUGH the ARGO MCP
15
+ // (applySystemArchitectureMutation), never touching the file directly.
16
+ // --direct (with --fix) write the JSON file directly with a .bak backup. Use for
17
+ // non-intent-graph copies (KGlibrary samples, defaults template, EA exports)
18
+ // that may not satisfy the intent-graph validation rules.
19
+ //
20
+ // Options:
21
+ // --path <p> Graph JSON path (default: design/KG/SystemArchitecture.json).
22
+ // Relative paths resolve against --workspaceRoot.
23
+ // --workspaceRoot <dir> Workspace root (default: the repository root).
24
+
25
+ const fs = require('node:fs');
26
+ const path = require('node:path');
27
+
28
+ const { applyMutations, callTool } = require('./systemarchitecture-mcp-server.js');
29
+
30
+ const DEFAULT_GRAPH_PATH = 'design/KG/SystemArchitecture.json';
31
+
32
+ function parseArgs(argv) {
33
+ const args = { check: true, fix: false, direct: false, graphPath: DEFAULT_GRAPH_PATH };
34
+ for (let i = 0; i < argv.length; i += 1) {
35
+ const arg = argv[i];
36
+ if (arg === '--check') {
37
+ args.check = true;
38
+ args.fix = false;
39
+ } else if (arg === '--fix') {
40
+ args.fix = true;
41
+ args.check = false;
42
+ } else if (arg === '--direct') {
43
+ args.direct = true;
44
+ } else if (arg === '--path' && i + 1 < argv.length) {
45
+ args.graphPath = argv[i + 1];
46
+ i += 1;
47
+ } else if (arg === '--workspaceRoot' && i + 1 < argv.length) {
48
+ args.workspaceRoot = argv[i + 1];
49
+ i += 1;
50
+ } else {
51
+ throw new Error(`Unknown argument: ${arg}`);
52
+ }
53
+ }
54
+ return args;
55
+ }
56
+
57
+ function resolveGraphPath(args) {
58
+ const workspaceRoot = path.resolve(args.workspaceRoot || path.resolve(__dirname, '..', '..'));
59
+ const resolved = path.isAbsolute(args.graphPath)
60
+ ? args.graphPath
61
+ : path.resolve(workspaceRoot, args.graphPath);
62
+ return { workspaceRoot, absolutePath: resolved, relativePath: path.relative(workspaceRoot, resolved) };
63
+ }
64
+
65
+ function readDocument(absolutePath, label) {
66
+ return JSON.parse(fs.readFileSync(absolutePath, 'utf8'));
67
+ }
68
+
69
+ function sortedEntries(entries) {
70
+ if (!Array.isArray(entries)) {
71
+ return [];
72
+ }
73
+ return entries
74
+ .filter(entry => entry && typeof entry.view_id === 'string' && entry.view_id.length > 0)
75
+ .map(entry => ({ view_id: entry.view_id, view_name: String(entry.view_name || '') }))
76
+ .sort((a, b) => a.view_id.localeCompare(b.view_id));
77
+ }
78
+
79
+ function entriesEqual(left, right) {
80
+ if (left.length !== right.length) {
81
+ return false;
82
+ }
83
+ for (let i = 0; i < left.length; i += 1) {
84
+ if (left[i].view_id !== right[i].view_id || left[i].view_name !== right[i].view_name) {
85
+ return false;
86
+ }
87
+ }
88
+ return true;
89
+ }
90
+
91
+ // Map element id -> canonical [{ view_id, view_name }] derived from view.parent_element_id.
92
+ function computeDesired(document) {
93
+ const desired = new Map();
94
+ for (const view of document.views || []) {
95
+ if (!view || !view.parent_element_id || !view.view_id) {
96
+ continue;
97
+ }
98
+ const list = desired.get(view.parent_element_id) || [];
99
+ if (!list.some(entry => entry.view_id === view.view_id)) {
100
+ list.push({ view_id: view.view_id, view_name: String(view.view_name || '') });
101
+ }
102
+ desired.set(view.parent_element_id, list);
103
+ }
104
+ return desired;
105
+ }
106
+
107
+ function computeMutations(document, desired) {
108
+ const mutations = [];
109
+ const reports = [];
110
+ for (const element of document.elements || []) {
111
+ if (!element || !element.id) {
112
+ continue;
113
+ }
114
+ const canonical = sortedEntries(desired.get(element.id) || []);
115
+ const current = sortedEntries(element.subdiagram_views || []);
116
+ if (entriesEqual(current, canonical)) {
117
+ continue;
118
+ }
119
+ reports.push({
120
+ elementId: element.id,
121
+ elementName: element.name,
122
+ current,
123
+ canonical,
124
+ });
125
+ mutations.push({
126
+ type: 'updateElement',
127
+ id: element.id,
128
+ patch: { subdiagram_views: canonical },
129
+ });
130
+ }
131
+ return { mutations, reports };
132
+ }
133
+
134
+ function describeEntry(entry) {
135
+ return `${entry.view_id}:${entry.view_name}`;
136
+ }
137
+
138
+ function printReports(reports) {
139
+ if (reports.length === 0) {
140
+ console.log('OK: all elements have subdiagram_views consistent with view.parent_element_id.');
141
+ return;
142
+ }
143
+ console.log(`Found ${reports.length} element(s) with drifted subdiagram_views:`);
144
+ for (const report of reports) {
145
+ console.log(`- ${report.elementId} (${report.elementName})`);
146
+ console.log(` current : [${report.current.map(describeEntry).join(', ')}]`);
147
+ console.log(` canonical: [${report.canonical.map(describeEntry).join(', ')}]`);
148
+ }
149
+ }
150
+
151
+ // Rebuild each element's subdiagram_views from view.parent_element_id, returning a
152
+ // structured report. Modes:
153
+ // 'check' dry-run: report drift, never write.
154
+ // 'fix-direct' apply corrections by writing the JSON directly with a .bak backup.
155
+ // 'fix-mcp' apply corrections through ARGO MCP applySystemArchitectureMutation
156
+ // (only for the intent graph, whose validation rules hold).
157
+ async function repairSubdiagramViews({
158
+ workspaceRoot,
159
+ architecturePath = DEFAULT_GRAPH_PATH,
160
+ mode = 'check',
161
+ } = {}) {
162
+ const { workspaceRoot: resolvedRoot, absolutePath, relativePath } = resolveGraphPath({
163
+ workspaceRoot,
164
+ graphPath: architecturePath,
165
+ });
166
+ const document = readDocument(absolutePath, relativePath);
167
+ const desired = computeDesired(document);
168
+ const { mutations, reports } = computeMutations(document, desired);
169
+
170
+ if (mode === 'check') {
171
+ return {
172
+ status: reports.length === 0 ? 'ok' : 'failed',
173
+ graphPath: relativePath,
174
+ driftCount: reports.length,
175
+ fixedCount: 0,
176
+ written: false,
177
+ reports,
178
+ };
179
+ }
180
+
181
+ if (reports.length === 0) {
182
+ return {
183
+ status: 'ok',
184
+ graphPath: relativePath,
185
+ driftCount: 0,
186
+ fixedCount: 0,
187
+ written: false,
188
+ reports: [],
189
+ };
190
+ }
191
+
192
+ if (mode === 'fix-direct') {
193
+ const { document: fixedDocument } = applyMutations(document, mutations);
194
+ const backupPath = `${absolutePath}.bak`;
195
+ fs.copyFileSync(absolutePath, backupPath);
196
+ fs.writeFileSync(absolutePath, `${JSON.stringify(fixedDocument, null, 2)}\n`, 'utf8');
197
+ return {
198
+ status: 'ok',
199
+ graphPath: relativePath,
200
+ driftCount: reports.length,
201
+ fixedCount: reports.length,
202
+ written: true,
203
+ backupPath,
204
+ reports,
205
+ };
206
+ }
207
+
208
+ if (mode === 'fix-mcp') {
209
+ const result = await callTool(
210
+ 'applySystemArchitectureMutation',
211
+ {
212
+ mutations,
213
+ workspaceRoot: resolvedRoot,
214
+ architecturePath: relativePath,
215
+ },
216
+ undefined,
217
+ );
218
+ if (result && result.status === 'passed' && result.written === true) {
219
+ return {
220
+ status: 'ok',
221
+ graphPath: relativePath,
222
+ driftCount: reports.length,
223
+ fixedCount: reports.length,
224
+ written: true,
225
+ reports,
226
+ };
227
+ }
228
+ return {
229
+ status: 'failed',
230
+ graphPath: relativePath,
231
+ driftCount: reports.length,
232
+ fixedCount: 0,
233
+ written: false,
234
+ reports,
235
+ error: result && Array.isArray(result.errors) ? result.errors : result,
236
+ };
237
+ }
238
+
239
+ throw new Error(`Unsupported repair mode: ${mode}`);
240
+ }
241
+
242
+ async function main() {
243
+ const args = parseArgs(process.argv.slice(2));
244
+ const mode = args.check ? 'check' : (args.direct ? 'fix-direct' : 'fix-mcp');
245
+ const result = await repairSubdiagramViews({
246
+ workspaceRoot: args.workspaceRoot,
247
+ architecturePath: args.graphPath,
248
+ mode,
249
+ });
250
+
251
+ if (mode === 'check') {
252
+ printReports(result.reports);
253
+ process.exitCode = result.driftCount === 0 ? 0 : 1;
254
+ return;
255
+ }
256
+
257
+ if (result.status !== 'ok') {
258
+ console.error(`Repair failed: ${JSON.stringify(result.error === undefined ? result : result.error, null, 2)}`);
259
+ process.exitCode = 1;
260
+ return;
261
+ }
262
+
263
+ if (result.driftCount === 0) {
264
+ console.log('Nothing to fix: subdiagram_views already consistent.');
265
+ return;
266
+ }
267
+
268
+ if (mode === 'fix-direct') {
269
+ console.log(`Fixed ${result.fixedCount} element(s) directly in ${result.graphPath} (backup: ${result.backupPath}).`);
270
+ } else {
271
+ console.log(`Fixed ${result.fixedCount} element(s) through ARGO MCP applySystemArchitectureMutation.`);
272
+ }
273
+ }
274
+
275
+ if (require.main === module) {
276
+ main().catch((error) => {
277
+ console.error(`Repair failed: ${String(error && error.stack ? error.stack : error)}`);
278
+ process.exitCode = 1;
279
+ });
280
+ }
281
+
282
+ module.exports = {
283
+ computeDesired,
284
+ computeMutations,
285
+ parseArgs,
286
+ repairSubdiagramViews,
287
+ sortedEntries,
288
+ };
@@ -0,0 +1,101 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+
4
+ const {
5
+ getArgoEnvPath,
6
+ } = require('./argo-paths.js');
7
+
8
+ function loadRepositoryArgoEnvironment(workspaceRoot) {
9
+ const argoEnvPath = getArgoEnvPath();
10
+ const workspaceEnvPath = path.join(workspaceRoot, '.argo', '.env');
11
+ const result = {
12
+ status: 'missing',
13
+ path: normalizeRelativePath(path.relative(workspaceRoot, argoEnvPath)),
14
+ loadedBeforeProjection: true,
15
+ assignedCount: 0,
16
+ preservedProcessCount: 0,
17
+ sourcePaths: [],
18
+ };
19
+
20
+ const candidatePaths = [argoEnvPath];
21
+ if (workspaceEnvPath !== argoEnvPath) {
22
+ candidatePaths.push(workspaceEnvPath);
23
+ }
24
+
25
+ const merged = new Map();
26
+ const loadedPaths = [];
27
+ for (const envPath of candidatePaths) {
28
+ if (!fs.existsSync(envPath)) {
29
+ continue;
30
+ }
31
+ for (const [key, value] of parseRepositoryEnvFile(fs.readFileSync(envPath, 'utf8'))) {
32
+ merged.set(key, value);
33
+ }
34
+ loadedPaths.push(envPath);
35
+ }
36
+
37
+ if (loadedPaths.length === 0) {
38
+ return result;
39
+ }
40
+
41
+ result.status = 'loaded';
42
+ result.sourcePaths = loadedPaths.map(
43
+ envPath => normalizeRelativePath(path.relative(workspaceRoot, envPath)),
44
+ );
45
+
46
+ for (const [key, value] of merged) {
47
+ if (process.env[key] === undefined) {
48
+ process.env[key] = value;
49
+ result.assignedCount += 1;
50
+ } else {
51
+ result.preservedProcessCount += 1;
52
+ }
53
+ }
54
+
55
+ return result;
56
+ }
57
+
58
+ function parseRepositoryEnvFile(content) {
59
+ const entries = [];
60
+ for (const rawLine of String(content).split(/\r?\n/)) {
61
+ const line = rawLine.trim();
62
+ if (!line || line.startsWith('#')) {
63
+ continue;
64
+ }
65
+
66
+ const separatorIndex = line.indexOf('=');
67
+ if (separatorIndex <= 0) {
68
+ continue;
69
+ }
70
+
71
+ const key = line.slice(0, separatorIndex).trim();
72
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
73
+ continue;
74
+ }
75
+
76
+ const value = parseRepositoryEnvValue(line.slice(separatorIndex + 1).trim());
77
+ entries.push([key, value]);
78
+ }
79
+ return entries;
80
+ }
81
+
82
+ function parseRepositoryEnvValue(value) {
83
+ if (value.length >= 2) {
84
+ const quote = value[0];
85
+ if ((quote === '"' || quote === "'") && value[value.length - 1] === quote) {
86
+ const inner = value.slice(1, -1);
87
+ return quote === '"' ? inner.replace(/\\n/g, '\n').replace(/\\r/g, '\r') : inner;
88
+ }
89
+ }
90
+ const commentIndex = value.search(/\s#/);
91
+ return commentIndex >= 0 ? value.slice(0, commentIndex).trimEnd() : value;
92
+ }
93
+
94
+ function normalizeRelativePath(value) {
95
+ return String(value).replace(/\\/g, '/');
96
+ }
97
+
98
+ module.exports = {
99
+ loadRepositoryArgoEnvironment,
100
+ parseRepositoryEnvFile,
101
+ };