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,168 @@
1
+ const fs = require('node:fs');
2
+ const os = require('node:os');
3
+ const path = require('node:path');
4
+ const { fileURLToPath } = require('node:url');
5
+
6
+ /**
7
+ * Shared path resolution for the Argo toolchain.
8
+ *
9
+ * The Argo installation can live in one of two layouts:
10
+ * 1. Embedded — `<repository>/.argo` (the historical layout).
11
+ * 2. Global — `<user-home>/.argo` (a machine-wide MCP installation).
12
+ *
13
+ * Every path in the toolchain is therefore either:
14
+ * - an *installation asset* (scripts, schema, test-executors, .env): resolved
15
+ * relative to the Argo root (the `.argo` directory that contains this file), or
16
+ * - a *workspace asset* (design/KG, tests, .argo/temp, handoff files): resolved
17
+ * relative to the active workspace root.
18
+ *
19
+ * The workspace root is resolved from, in priority order:
20
+ * 1. ARGO_REPO_ROOT — explicit override (set by MCP client configs).
21
+ * 2. WORKSPACE_FOLDER — set by some hosts.
22
+ * 3. The MCP `roots` advertised by the client (a global server resolves the
23
+ * root that contains design/KG/SystemArchitecture.json when several roots
24
+ * are present, so it never operates on an unrelated folder).
25
+ * 4. The embedded repo root, when the Argo installation is still inside a repo
26
+ * (i.e. `<argoRoot>/../design/KG/SystemArchitecture.json` exists).
27
+ * 5. process.cwd() — last-resort fallback when no root is available.
28
+ */
29
+
30
+ function getArgoRoot() {
31
+ // This module lives at <argoRoot>/scripts/argo-paths.js.
32
+ return path.resolve(__dirname, '..');
33
+ }
34
+
35
+ let mcpWorkspaceRoots = [];
36
+
37
+ function setMcpWorkspaceRoots(roots) {
38
+ mcpWorkspaceRoots = Array.isArray(roots) ? roots : [];
39
+ }
40
+
41
+ function rootToPath(root) {
42
+ if (!root) {
43
+ return null;
44
+ }
45
+ const uri = typeof root === 'string' ? root : root.uri;
46
+ if (typeof uri !== 'string' || uri.trim() === '') {
47
+ return null;
48
+ }
49
+ if (uri.startsWith('file://')) {
50
+ try {
51
+ return fileURLToPath(uri);
52
+ } catch {
53
+ return null;
54
+ }
55
+ }
56
+ return uri;
57
+ }
58
+
59
+ function getWorkspaceRoot() {
60
+ const explicit = process.env.ARGO_REPO_ROOT || process.env.WORKSPACE_FOLDER;
61
+ if (explicit && String(explicit).trim() !== '') {
62
+ return path.resolve(explicit);
63
+ }
64
+
65
+ // The client may expose several roots (a multi-root workspace). Never
66
+ // silently operate on an unrelated folder: prefer the root that actually
67
+ // contains the ArchGraph marker before falling back to the first root.
68
+ const marker = path.join('design', 'KG', 'SystemArchitecture.json');
69
+ for (const root of mcpWorkspaceRoots) {
70
+ const rootPath = rootToPath(root);
71
+ if (rootPath && fs.existsSync(path.join(rootPath, marker))) {
72
+ return path.resolve(rootPath);
73
+ }
74
+ }
75
+
76
+ for (const root of mcpWorkspaceRoots) {
77
+ const rootPath = rootToPath(root);
78
+ if (rootPath) {
79
+ return path.resolve(rootPath);
80
+ }
81
+ }
82
+
83
+ const embedded = path.resolve(getArgoRoot(), '..');
84
+ if (fs.existsSync(path.join(embedded, marker))) {
85
+ return embedded;
86
+ }
87
+
88
+ return path.resolve(process.cwd());
89
+ }
90
+
91
+ function hasStaticWorkspace() {
92
+ const explicit = process.env.ARGO_REPO_ROOT || process.env.WORKSPACE_FOLDER;
93
+ if (explicit && String(explicit).trim() !== '') {
94
+ return true;
95
+ }
96
+ const embedded = path.resolve(getArgoRoot(), '..');
97
+ return fs.existsSync(path.join(embedded, 'design', 'KG', 'SystemArchitecture.json'));
98
+ }
99
+
100
+ function resolveArgoPath(...segments) {
101
+ return path.resolve(getArgoRoot(), ...segments);
102
+ }
103
+
104
+ function resolveWorkspacePath(...segments) {
105
+ return path.resolve(getWorkspaceRoot(), ...segments);
106
+ }
107
+
108
+ function getArgoEnvPath() {
109
+ if (process.env.ARGO_ENV_FILE && String(process.env.ARGO_ENV_FILE).trim() !== '') {
110
+ return path.resolve(process.env.ARGO_ENV_FILE);
111
+ }
112
+
113
+ // Prefer the global clean env (<user-home>/.argo/.env) when present, so a
114
+ // workspace-local env file (which may carry non-whitelisted keys, e.g.
115
+ // repo argo/.env with DEEPSEEK_* that fails the secret-ACL) never shadows the
116
+ // sanctioned global configuration for semantic/embedding lifecycle.
117
+ const homeEnvPath = path.join(os.homedir(), '.argo', '.env');
118
+ if (fs.existsSync(homeEnvPath)) {
119
+ return homeEnvPath;
120
+ }
121
+
122
+ const globalPath = path.join(getArgoRoot(), '.env');
123
+ if (fs.existsSync(globalPath)) {
124
+ return globalPath;
125
+ }
126
+
127
+ return path.join(getWorkspaceRoot(), '.argo', '.env');
128
+ }
129
+
130
+ function normalizeRelativePath(value) {
131
+ return String(value == null ? '' : value).replace(/\\/g, '/').replace(/^\/+/, '');
132
+ }
133
+
134
+ /**
135
+ * Resolve the workspace root for one tool call.
136
+ *
137
+ * Defaults to the launch-directory root (`getWorkspaceRoot()`). A per-call
138
+ * `workspaceRoot` argument (absolute path) is honored unconditionally when
139
+ * present, so the caller decides which workspace this call operates on. This
140
+ * powers the DeepSeek Harness bridge, which injects the current session's
141
+ * workspace directory into every call so one dsh instance can follow the
142
+ * workspace the user switched to.
143
+ *
144
+ * @param {object} [args] - tool call arguments (may carry `workspaceRoot`).
145
+ * @returns {string} resolved absolute workspace root.
146
+ */
147
+ function resolveCallWorkspaceRoot(args = {}) {
148
+ const requested =
149
+ typeof args === 'object' && args !== null && typeof args.workspaceRoot === 'string'
150
+ ? String(args.workspaceRoot).trim()
151
+ : '';
152
+ if (requested === '') {
153
+ return getWorkspaceRoot();
154
+ }
155
+ return path.resolve(requested);
156
+ }
157
+
158
+ module.exports = {
159
+ getArgoRoot,
160
+ getArgoEnvPath,
161
+ getWorkspaceRoot,
162
+ hasStaticWorkspace,
163
+ normalizeRelativePath,
164
+ resolveArgoPath,
165
+ resolveCallWorkspaceRoot,
166
+ resolveWorkspacePath,
167
+ setMcpWorkspaceRoots,
168
+ };