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.
- package/LICENSE +201 -0
- package/README.md +107 -0
- package/argo/.env.example +170 -0
- package/argo/defaults/EA-model-template.qea +0 -0
- package/argo/defaults/design/KG/SystemArchitecture.json +128 -0
- package/argo/mcp-bridges/graph-mcp-stdio.js +98 -0
- package/argo/package.json +8 -0
- package/argo/plugins/argo-cost-collector.js +35 -0
- package/argo/plugins/argo-wakeup.js +29 -0
- package/argo/rules/archgraph.instructions.md +189 -0
- package/argo/schema/ImplementationToCodingHandoff.schema.json +252 -0
- package/argo/schema/ImplementationToIntentTraceProposal.schema.json +180 -0
- package/argo/schema/IntentToImplementationHandoff.schema.json +75 -0
- package/argo/schema/SystemArchitecture.schema.json +378 -0
- package/argo/schema/archimate3.2.md +7153 -0
- package/argo/schema/argob-rules.json +12229 -0
- package/argo/schema/argob.config.json +20 -0
- package/argo/scripts/ARCHITECTURE.md +58 -0
- package/argo/scripts/agentSearchDiagnose.js +407 -0
- package/argo/scripts/archimate32-rules.js +12301 -0
- package/argo/scripts/argo-mcp-server.js +952 -0
- package/argo/scripts/argo-paths.js +168 -0
- package/argo/scripts/argob-schema.js +574 -0
- package/argo/scripts/ea-qea-sync-lib.js +1014 -0
- package/argo/scripts/ea-qea-sync.js +110 -0
- package/argo/scripts/ensureArgoHarnessEnvironment.js +451 -0
- package/argo/scripts/external-graph-query.js +162 -0
- package/argo/scripts/generateArchitectureDiffPlantuml.js +466 -0
- package/argo/scripts/graph-rag/ARCHITECTURE.md +192 -0
- package/argo/scripts/graph-rag/agentCostLog.js +179 -0
- package/argo/scripts/graph-rag/canonicalProjectionAuthority.js +45 -0
- package/argo/scripts/graph-rag/defaultSemanticRetrieval.js +1244 -0
- package/argo/scripts/graph-rag/embeddingProviderProfile.js +89 -0
- package/argo/scripts/graph-rag/embeddingQualificationGate.js +59 -0
- package/argo/scripts/graph-rag/externalProductionConfig.js +74 -0
- package/argo/scripts/graph-rag/hybridRetrieval.js +114 -0
- package/argo/scripts/graph-rag/liveEmbeddingIndexGate.js +128 -0
- package/argo/scripts/graph-rag/liveEmbeddingNeo4jBoundary.js +137 -0
- package/argo/scripts/graph-rag/liveEmbeddingProviderClient.js +49 -0
- package/argo/scripts/graph-rag/liveEmbeddingProviderConfig.js +571 -0
- package/argo/scripts/graph-rag/mcpCrashDiagnostics.js +137 -0
- package/argo/scripts/graph-rag/mutationEmbeddingVectorLifecycle.js +1266 -0
- package/argo/scripts/graph-rag/neo4jNativeRetrieval.js +37 -0
- package/argo/scripts/graph-rag/productionGraphRagRuntime.js +1633 -0
- package/argo/scripts/graph-rag/rerankRetrieval.js +201 -0
- package/argo/scripts/graph-rag/semantic-persistence/ARCHITECTURE.md +51 -0
- package/argo/scripts/graph-rag/semantic-persistence/productionSemanticBackfill.js +342 -0
- package/argo/scripts/graph-rag/semantic-persistence/productionSemanticCheckpointStore.js +99 -0
- package/argo/scripts/graph-rag/semantic-persistence/productionSemanticNeo4jAdapter.js +186 -0
- package/argo/scripts/graph-rag/semantic-persistence/productionSemanticProjectionStore.js +171 -0
- package/argo/scripts/graph-rag/semanticAlignmentLock.js +76 -0
- package/argo/scripts/graph-rag/semanticAlignmentRunner.js +131 -0
- package/argo/scripts/graph-rag/semanticInitConfiguration.js +24 -0
- package/argo/scripts/graph-rag/semanticOperatorError.js +38 -0
- package/argo/scripts/graph-rag/semanticOperatorJourney.js +459 -0
- package/argo/scripts/graph-rag/semanticReadinessAttestationStore.js +398 -0
- package/argo/scripts/graph-rag/semanticRecordText.js +75 -0
- package/argo/scripts/graph-rag/systemMetadataCommandAdapter.js +269 -0
- package/argo/scripts/graph-semantics.js +266 -0
- package/argo/scripts/lossless-write-gate.js +500 -0
- package/argo/scripts/neo4j-system-architecture-store.js +1066 -0
- package/argo/scripts/repair-subdiagram-views.js +288 -0
- package/argo/scripts/repositoryArgoEnvironment.js +101 -0
- package/argo/scripts/runArchitectureTests.js +591 -0
- package/argo/scripts/semanticOperatorJourneyCli.js +91 -0
- package/argo/scripts/syncSystemArchitectureToNeo4j.js +67 -0
- package/argo/scripts/systemarchitecture-mcp-server.js +4508 -0
- package/argo/scripts/test-executors/_template.js +58 -0
- package/argo/scripts/test-executors/default.js +199 -0
- package/argo/scripts/validateStageHandoff.js +459 -0
- package/argo/scripts/validateSystemArchitecture.js +261 -0
- package/argo/scripts/validateTraceProposal.js +181 -0
- package/argo/scripts/validator-mcp-server.js +347 -0
- package/argo/skills/agent-search-diagnosis/SKILL.md +60 -0
- package/argo/skills/argo-init/SKILL.md +86 -0
- package/argo/skills/ea-human-reconcile/SKILL.md +40 -0
- package/bin/argo-deploy.js +12 -0
- package/cordis.patch.yml +6 -0
- package/dsh-argo-wakeup/index.js +17 -0
- package/dsh-argo-wakeup/package.json +1 -0
- package/dsh-argo-workspace/index.js +142 -0
- package/dsh-argo-workspace/package.json +1 -0
- package/install-argo.ps1 +1162 -0
- package/package.json +56 -0
- package/vendor/neo4j-driver-6.2.0.tgz +0 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
const { execFile, spawn } = require('node:child_process');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const readline = require('node:readline');
|
|
5
|
+
const { promisify } = require('node:util');
|
|
6
|
+
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
getArgoRoot,
|
|
11
|
+
getWorkspaceRoot,
|
|
12
|
+
resolveCallWorkspaceRoot,
|
|
13
|
+
} = require('./argo-paths.js');
|
|
14
|
+
|
|
15
|
+
const DEFAULT_ARCHITECTURE_GRAPH_PATH = 'design/KG/SystemArchitecture.json';
|
|
16
|
+
|
|
17
|
+
const SCRIPT_CANDIDATES = {
|
|
18
|
+
validateSystemArchitecture: [
|
|
19
|
+
'scripts/validateSystemArchitecture.js',
|
|
20
|
+
],
|
|
21
|
+
runArchitectureTests: [
|
|
22
|
+
'scripts/runArchitectureTests.js',
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const TOOLS = [
|
|
27
|
+
{
|
|
28
|
+
name: 'validateSystemArchitecture',
|
|
29
|
+
description: 'Validate design/KG/SystemArchitecture.json against the workspace-resolved schema bundle (the default ArgoBument schema, or the repository\'s own .argo/schema) and Argo graph rules.',
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {},
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'runArchitectureTests',
|
|
38
|
+
description: 'Execute explicit architecture testcases from the intent graph and refresh design/KG/test-failure-records.json. This MCP call can exceed client timeouts; if it times out, run the same test runner directly with: node .argo/scripts/runArchitectureTests.js',
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
architecturePath: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: `Optional architecture graph path relative to workspace root. Default: ${DEFAULT_ARCHITECTURE_GRAPH_PATH}`,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
// Every tool accepts an optional per-call `workspaceRoot` (absolute path,
|
|
53
|
+
// honored unconditionally when provided). The DeepSeek Harness bridge injects
|
|
54
|
+
// the current session's workspace directory here automatically.
|
|
55
|
+
const WORKSPACE_ROOT_PARAM = Object.freeze({
|
|
56
|
+
type: 'string',
|
|
57
|
+
description:
|
|
58
|
+
'Optional absolute workspace root for this call. When provided it is used as-is; otherwise the server launch directory is used.',
|
|
59
|
+
});
|
|
60
|
+
for (const tool of TOOLS) {
|
|
61
|
+
const inputSchema = tool && tool.inputSchema;
|
|
62
|
+
if (inputSchema && inputSchema.type === 'object' && inputSchema.properties) {
|
|
63
|
+
if (!Object.prototype.hasOwnProperty.call(inputSchema.properties, 'workspaceRoot')) {
|
|
64
|
+
inputSchema.properties.workspaceRoot = WORKSPACE_ROOT_PARAM;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function resolveWorkspaceRoot(args) {
|
|
70
|
+
// Per-call workspaceRoot override, honored unconditionally when provided;
|
|
71
|
+
// defaults to the launch-directory root.
|
|
72
|
+
return resolveCallWorkspaceRoot(args);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function resolveScriptPath(workspaceRoot, candidates) {
|
|
76
|
+
const argoRoot = getArgoRoot();
|
|
77
|
+
for (const relativePath of candidates) {
|
|
78
|
+
const absolutePath = path.join(argoRoot, relativePath);
|
|
79
|
+
if (fs.existsSync(absolutePath)) {
|
|
80
|
+
return { absolutePath, relativePath };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
for (const relativePath of candidates) {
|
|
85
|
+
const absolutePath = path.join(workspaceRoot, '.argo', relativePath);
|
|
86
|
+
if (fs.existsSync(absolutePath)) {
|
|
87
|
+
return { absolutePath, relativePath };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
throw new Error(`Unable to locate validator script. Checked: ${candidates.join(', ')}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function runValidatorScriptStreaming(workspaceRoot, scriptKey, args, progressToken) {
|
|
95
|
+
const { absolutePath, relativePath } = resolveScriptPath(workspaceRoot, SCRIPT_CANDIDATES[scriptKey]);
|
|
96
|
+
const command = process.execPath;
|
|
97
|
+
const commandArgs = [absolutePath, ...args];
|
|
98
|
+
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
const child = spawn(command, commandArgs, {
|
|
101
|
+
cwd: workspaceRoot,
|
|
102
|
+
env: {
|
|
103
|
+
...process.env,
|
|
104
|
+
ARGO_REPO_ROOT: workspaceRoot,
|
|
105
|
+
},
|
|
106
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
let stdout = '';
|
|
110
|
+
let stderr = '';
|
|
111
|
+
|
|
112
|
+
const stdoutLines = readline.createInterface({ input: child.stdout, crlfDelay: Infinity });
|
|
113
|
+
|
|
114
|
+
stdoutLines.on('line', (line) => {
|
|
115
|
+
stdout += line + '\n';
|
|
116
|
+
|
|
117
|
+
const progressMatch = line.match(/^\[PROGRESS\]\s*(.+)$/);
|
|
118
|
+
if (progressMatch) {
|
|
119
|
+
try {
|
|
120
|
+
const payload = JSON.parse(progressMatch[1]);
|
|
121
|
+
send({
|
|
122
|
+
jsonrpc: '2.0',
|
|
123
|
+
method: 'notifications/progress',
|
|
124
|
+
params: {
|
|
125
|
+
progressToken,
|
|
126
|
+
progress: payload.passedCount !== undefined
|
|
127
|
+
? payload.passedCount
|
|
128
|
+
: payload.index + 1,
|
|
129
|
+
total: payload.total,
|
|
130
|
+
message: `${payload.testcaseName || '(unnamed)'}: ${payload.status}`,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
} catch (_) {
|
|
134
|
+
// ignore malformed progress lines
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
child.stderr.on('data', (data) => {
|
|
140
|
+
stderr += data.toString();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
child.on('error', (error) => {
|
|
144
|
+
reject(error);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
child.on('close', (exitCode) => {
|
|
148
|
+
const code = exitCode === null ? 1 : exitCode;
|
|
149
|
+
const passed = code === 0;
|
|
150
|
+
resolve({
|
|
151
|
+
status: passed ? 'passed' : 'failed',
|
|
152
|
+
exitCode: code,
|
|
153
|
+
workspaceRoot,
|
|
154
|
+
scriptPath: relativePath,
|
|
155
|
+
command: [command, ...commandArgs],
|
|
156
|
+
stdout: stdout.trim(),
|
|
157
|
+
stderr: stderr.trim(),
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function runValidatorScript(workspaceRoot, scriptKey, args = []) {
|
|
164
|
+
const { absolutePath, relativePath } = resolveScriptPath(workspaceRoot, SCRIPT_CANDIDATES[scriptKey]);
|
|
165
|
+
const command = process.execPath;
|
|
166
|
+
const commandArgs = [absolutePath, ...args];
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
const { stdout, stderr } = await execFileAsync(command, commandArgs, {
|
|
170
|
+
cwd: workspaceRoot,
|
|
171
|
+
env: {
|
|
172
|
+
...process.env,
|
|
173
|
+
ARGO_REPO_ROOT: workspaceRoot,
|
|
174
|
+
},
|
|
175
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
status: 'passed',
|
|
180
|
+
exitCode: 0,
|
|
181
|
+
workspaceRoot,
|
|
182
|
+
scriptPath: relativePath,
|
|
183
|
+
command: [command, ...commandArgs],
|
|
184
|
+
stdout: stdout.trim(),
|
|
185
|
+
stderr: stderr.trim(),
|
|
186
|
+
};
|
|
187
|
+
} catch (error) {
|
|
188
|
+
return {
|
|
189
|
+
status: 'failed',
|
|
190
|
+
exitCode: typeof error.code === 'number' ? error.code : 1,
|
|
191
|
+
workspaceRoot,
|
|
192
|
+
scriptPath: relativePath,
|
|
193
|
+
command: [command, ...commandArgs],
|
|
194
|
+
stdout: String(error.stdout || '').trim(),
|
|
195
|
+
stderr: String(error.stderr || error.message || error).trim(),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function send(message) {
|
|
201
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function toolResult(payload) {
|
|
205
|
+
return {
|
|
206
|
+
content: [
|
|
207
|
+
{
|
|
208
|
+
type: 'text',
|
|
209
|
+
text: JSON.stringify(payload, null, 2),
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
isError: payload.status === 'failed',
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async function callTool(name, args, progressToken = null) {
|
|
217
|
+
const workspaceRoot = resolveWorkspaceRoot(args);
|
|
218
|
+
|
|
219
|
+
if (name === 'validateSystemArchitecture') {
|
|
220
|
+
return toolResult(await runValidatorScript(workspaceRoot, 'validateSystemArchitecture'));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (name === 'runArchitectureTests') {
|
|
224
|
+
const architecturePath = (args && args.architecturePath) || DEFAULT_ARCHITECTURE_GRAPH_PATH;
|
|
225
|
+
if (progressToken) {
|
|
226
|
+
return toolResult(await runValidatorScriptStreaming(workspaceRoot, 'runArchitectureTests', [architecturePath], progressToken));
|
|
227
|
+
}
|
|
228
|
+
return toolResult(await runValidatorScript(workspaceRoot, 'runArchitectureTests', [architecturePath]));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async function handleRequest(request) {
|
|
235
|
+
const { id, method, params } = request;
|
|
236
|
+
|
|
237
|
+
if (method === 'initialize') {
|
|
238
|
+
return {
|
|
239
|
+
jsonrpc: '2.0',
|
|
240
|
+
id,
|
|
241
|
+
result: {
|
|
242
|
+
protocolVersion: '2024-11-05',
|
|
243
|
+
capabilities: {
|
|
244
|
+
tools: {},
|
|
245
|
+
},
|
|
246
|
+
serverInfo: {
|
|
247
|
+
name: 'argo',
|
|
248
|
+
version: '1.0.0',
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (method === 'notifications/initialized') {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (method === 'tools/list') {
|
|
259
|
+
return {
|
|
260
|
+
jsonrpc: '2.0',
|
|
261
|
+
id,
|
|
262
|
+
result: {
|
|
263
|
+
tools: TOOLS,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (method === 'tools/call') {
|
|
269
|
+
try {
|
|
270
|
+
const result = await callTool(params.name, params.arguments || {});
|
|
271
|
+
return {
|
|
272
|
+
jsonrpc: '2.0',
|
|
273
|
+
id,
|
|
274
|
+
result,
|
|
275
|
+
};
|
|
276
|
+
} catch (error) {
|
|
277
|
+
return {
|
|
278
|
+
jsonrpc: '2.0',
|
|
279
|
+
id,
|
|
280
|
+
result: {
|
|
281
|
+
content: [
|
|
282
|
+
{
|
|
283
|
+
type: 'text',
|
|
284
|
+
text: String(error && error.stack ? error.stack : error),
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
isError: true,
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (method === 'ping') {
|
|
294
|
+
return {
|
|
295
|
+
jsonrpc: '2.0',
|
|
296
|
+
id,
|
|
297
|
+
result: {},
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return {
|
|
302
|
+
jsonrpc: '2.0',
|
|
303
|
+
id,
|
|
304
|
+
error: {
|
|
305
|
+
code: -32601,
|
|
306
|
+
message: `Method not found: ${method}`,
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async function main() {
|
|
312
|
+
const rl = readline.createInterface({
|
|
313
|
+
input: process.stdin,
|
|
314
|
+
crlfDelay: Infinity,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
for await (const line of rl) {
|
|
318
|
+
if (!line.trim()) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
let request;
|
|
323
|
+
try {
|
|
324
|
+
request = JSON.parse(line);
|
|
325
|
+
} catch {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const response = await handleRequest(request);
|
|
330
|
+
if (response) {
|
|
331
|
+
send(response);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (require.main === module) {
|
|
337
|
+
main().catch((error) => {
|
|
338
|
+
console.error(error);
|
|
339
|
+
process.exit(1);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
module.exports = {
|
|
344
|
+
TOOLS,
|
|
345
|
+
callTool,
|
|
346
|
+
main,
|
|
347
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-search-diagnosis
|
|
3
|
+
description: "诊断一次 Agent 会话的检索/搜索行为(是否过度搜索、轮次/token/耗时花在哪、是否重复或空手、图↔仓往返),产出一份自包含的『诊断包』(diagnosis.md 总结 + metrics.json + 会话 NDJSON + 插件日志切片 + manifest.json),供人类伙伴打包回传以便进一步分析优化。Use when the user says an agent session searched too many rounds / wants to diagnose retrieval cost or over-search, or asks to produce a diagnostic bundle to send back. Keywords: 过度搜索, 诊断, over-search, search diagnosis, retrieval cost, diagnostic bundle, agent-search-diagnosis."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent Search Diagnosis
|
|
7
|
+
|
|
8
|
+
把**一次 Agent 会话**变成一份自包含的**诊断包**:现场出诊断总结 + 聚合关键数据到一个目录,用户打包回传即可。
|
|
9
|
+
|
|
10
|
+
## 数据来源
|
|
11
|
+
|
|
12
|
+
- **主**:宿主会话 NDJSON(含每个工具的**完整入参/输出**、时间戳、tokens)。
|
|
13
|
+
- **辅**:框架后台日志 `<workspace>/.argo/temp/agent-cost-log.ndjson`(跨会话成本形态)。
|
|
14
|
+
|
|
15
|
+
## 输出(固定目录)
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
<workspace>/.argo/temp/diagnosis/<session-id>/
|
|
19
|
+
├─ diagnosis.md # 人读诊断总结(含启发式建议,供 Agent 复核)
|
|
20
|
+
├─ metrics.json # 总结背后的数字
|
|
21
|
+
├─ session.ndjson # 原始会话(全保真)
|
|
22
|
+
├─ cost-log.slice.ndjson # 匹配该会话的后台日志切片
|
|
23
|
+
└─ manifest.json # 文件清单 + 大小 + 版本
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Workflow
|
|
27
|
+
|
|
28
|
+
### 1. 定位并导出会话
|
|
29
|
+
|
|
30
|
+
- 若用户给出了 sessionID:`opencode export <sessionID> > <tmp>.ndjson`。
|
|
31
|
+
- 若未给出:`opencode session list` 取最近会话,或请用户指定。
|
|
32
|
+
- 宿主不支持导出时:退化为**仅用后台日志**(`agent-cost-log.ndjson`,诊断能力受限,须在报告中注明)。
|
|
33
|
+
|
|
34
|
+
### 2. 运行诊断脚本(确定性)
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
node ~/.argo/scripts/agentSearchDiagnose.js --session <session.ndjson> \
|
|
38
|
+
[--session-id <id>] [--workspace .] [--cost-log <path>] [--json]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
脚本**只读**会话与日志,写出上面的 bundle 目录,输出概览与启发式 hints。
|
|
42
|
+
支持两种输入:`opencode export` 的会话 JSON(`{info, messages}`)与 `opencode run --format json` 的事件流 NDJSON。
|
|
43
|
+
|
|
44
|
+
### 3. 复核并补充诊断总结(Agent)
|
|
45
|
+
|
|
46
|
+
- 读 `diagnosis.md` 与 `metrics.json`。
|
|
47
|
+
- 在报告末尾追加一节 `## Agent 复核解读`:结合会话片段指出**最可能的过度搜索根因**与**建议的优化方向**(去重/缓存、查询构造、停止判据、上下文压缩、图↔仓往返合并等)。
|
|
48
|
+
- 不臆造:结论必须能从 metrics/会话片段找到依据。
|
|
49
|
+
|
|
50
|
+
### 4. 交付给用户
|
|
51
|
+
|
|
52
|
+
- 报告 bundle 目录路径,请用户**打包该目录**回传。
|
|
53
|
+
- 给一段简短结论(轮次/token/耗时拆分 + 主要信号)。
|
|
54
|
+
|
|
55
|
+
## Rules(MUST / MUST NOT)
|
|
56
|
+
|
|
57
|
+
- **MUST** 只用确定性脚本 + 会话/日志读取;**MUST NOT** 修改图谱、仓库或任何框架内容。
|
|
58
|
+
- **MUST NOT** 读取或打印 `.env`/凭据;若会话片段疑似含密钥,**MUST** 提醒用户回传前先审查 `session.ndjson`(其中是原始工具 I/O)。
|
|
59
|
+
- **MUST** 在结论中区分「事实(metrics)」与「推断(根因假设)」,推断须标注依据。
|
|
60
|
+
- 若无法导出会话或脚本不可用,**MUST** 如实说明并给出退化方案,不得臆测诊断结果。
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: argo-init
|
|
3
|
+
description: "通过 ARGO MCP 的 initializeWorkspace 接口完成工作区确定性的初始化(NEO4J 初始同步 + .qea 全量投影 + 语义生命周期 + canonical 校验 + subdiagram_views 一致性),无需执行 WORKSPACE 外脚本。Use when the user asks to verify Argo MCP readiness and perform or verify the canonical JSON-to-Neo4j initial sync, .qea full projection (target file must be this repo's own .qea), plus semantic lifecycle init. Keywords: ARGO INIT, harness init, initializeWorkspace, Neo4j initial sync, qea projection, semantic lifecycle."
|
|
4
|
+
argument-hint: scope-or-mode
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# ARGO INIT
|
|
9
|
+
|
|
10
|
+
`argo-init` 通过 ARGO MCP 的 `initializeWorkspace` 接口完成确定性初始化:工作区 bootstrap(缺 `SystemArchitecture.json` / EA 模型文件(`.qea`)自动生成)+ Neo4j 结构投影同步 + **.qea 全量投影(整库清空重建,逻辑同 Neo4j init)** + 语义生命周期初始化 + canonical 校验 + subdiagram_views 一致性,并返回完整报告。**不需要也不应执行任何 WORKSPACE 外脚本**——所有确定性步骤都在 MCP 进程内完成,避免扩大访问面。
|
|
11
|
+
|
|
12
|
+
- 工作区缺少 `design/KG/SystemArchitecture.json` 时自动从部署的 `defaults` 拷贝默认模板;缺 EA 模型文件(仓库根无 `.qea`/`.feap`/`.eap`)时以当前项目名拷贝默认 `.qea` 模板(不再补建遗留 `.feap`)。
|
|
13
|
+
- 本机 Neo4j 连接可用,canonical 意图图完成至少一次 JSON -> Neo4j 初始同步并通过一致性校验;**投影到的 Neo4j 数据库名称必须与本仓库名称一致**(如仓库 archgraph → 库 archgraph),不一致须报告为告警/失败。
|
|
14
|
+
- **.qea 投影**:init 对仓库 EA 文件(仓库根 `.qea`,经 `ARGO_EA_QEA` 或仓库根唯一 `*.qea` 解析)执行整库清空后全量重建;**必须确认投影目标是本仓库自己的 `.qea` 文件**,并报告投影成功/失败与耗时。
|
|
15
|
+
- 语义生命周期:双 gate 未开启时记录 skipped/disabled;开启时执行全量 embedding backfill 与 readiness 对齐。
|
|
16
|
+
|
|
17
|
+
## Rules
|
|
18
|
+
|
|
19
|
+
- **MUST** 调用 ARGO MCP 工具 `initializeWorkspace`(传当前工作区根)执行确定性初始化,并以其返回报告为最终判断依据。
|
|
20
|
+
- **MUST** 报告当前 schema:`initializeWorkspace` 返回的 `schema`(或 harness 的 `schemaBundle`)中的 `kind`(default=内置 ArgoBument / workspace=仓内自定义 / override)、`language`(名称)、`actorElementType`、`dir`、`guide`;输出形如 `schema: default / ArchiMate 3.2`。
|
|
21
|
+
- **MUST** 报告 `mcp` / `systemArchitecture` / `neo4j` / `qeaFullProjection` / `semanticLifecycle` / `subdiagramViews` 与整体 `status`。
|
|
22
|
+
- **MUST** 核验并报告:① `.qea` 投影是否成功(`qeaFullProjection.status`),且投影目标 `qeaFullProjection.qea` 是否为**本仓库自己的 .qea 文件**(解析自 `ARGO_EA_QEA` 或仓库根唯一 `*.qea`);目标不是本仓库文件或投影失败 → 报告为告警/失败,不得视为 init 成功。
|
|
23
|
+
- **MUST** 核验并报告:Neo4j 投影目标数据库名(`neo4j.database`)是否**与本仓库名一致**(仓库 basename == 数据库名);不一致 → 报告为告警/失败。
|
|
24
|
+
- **MUST NOT** 因 schema 是自定义的而跳过 `.qea` 投影:投影对任何 schema 都执行;只有确实没有 `.qea` 目标时才允许 `noop`。
|
|
25
|
+
- **MUST NOT** 读取、打印或复述 `.env` 中的 secret 值;排查时只允许报告 key 是否存在。
|
|
26
|
+
- **MUST NOT** 通过 shell 手工执行 WORKSPACE 外的初始化脚本或一组无关命令来替代 `initializeWorkspace`(除非报告显示底层脚本自身失败需要排查)。
|
|
27
|
+
|
|
28
|
+
## Workflow
|
|
29
|
+
|
|
30
|
+
### 1. Run Deterministic Init via initializeWorkspace
|
|
31
|
+
|
|
32
|
+
调用 ARGO MCP 工具 `initializeWorkspace`(传入当前工作区根 `workspaceRoot`)。该接口在 MCP 进程内完成全部确定性步骤并返回报告:
|
|
33
|
+
|
|
34
|
+
- `workspaceBootstrap`:缺 `SystemArchitecture.json` / EA 模型文件时自动生成 `.qea`(createdFiles / skippedSteps;仓库根已有 `.qea`/`.feap` 时不重复补建)
|
|
35
|
+
- `mcp`:ARGO MCP 健康(协议 / tools-list / ping)
|
|
36
|
+
- `systemArchitecture`:canonical 校验(元素/关系/视图计数)
|
|
37
|
+
- `subdiagramViews`:subdiagram_views 一致性检查/修复
|
|
38
|
+
- `neo4j`:Neo4j 连通 + 结构投影初始同步 + 一致性校验(initialSync / verification);**并核验投影目标数据库名 == 本仓库名**
|
|
39
|
+
- `qeaFullProjection`:仓库 EA(.qea)整库清空重建 + 一致性(status / qea 目标路径 / ms);**核验 qea 目标 == 本仓库自己的 .qea 文件**
|
|
40
|
+
- `semanticLifecycle`:语义生命周期初始化(state / alignment / readiness;未开 gate 时 skipped/disabled)
|
|
41
|
+
|
|
42
|
+
### 2. Interpret The Report
|
|
43
|
+
|
|
44
|
+
- 整体 `status=ok`:环境就绪。
|
|
45
|
+
- 任一 section `status=failed` → 整体 `status=failed`,指出失败阶段:`mcp` / `systemArchitecture` / `neo4j` / `qeaFullProjection` / `semanticLifecycle` / `subdiagramViews`。
|
|
46
|
+
- **目标一致性核验(在报告中明确给出)**:
|
|
47
|
+
- `qeaFullProjection.qea` 是否为**本仓库自己的 .qea 文件**(== 解析自 `ARGO_EA_QEA`/仓库根唯一 `*.qea` 的路径);投影成功且目标为本仓库文件才算该 section ok;投影失败或目标非本仓库文件 → 报告告警/失败。
|
|
48
|
+
- `neo4j.database` 是否**与本仓库名(仓库根目录名)一致**;不一致 → 报告告警/失败。
|
|
49
|
+
|
|
50
|
+
### 3. Handle Secret File Blockers(仅当报告含 secret 相关失败)
|
|
51
|
+
|
|
52
|
+
`semanticLifecycle` 或 `systemArchitecture` 失败可能源于 `.env` 预检。诊断(不打印 secret 值):
|
|
53
|
+
|
|
54
|
+
处理规则(env 文件不做 OS ACL / 权限加固;只保证不被提交):
|
|
55
|
+
|
|
56
|
+
- `SECRET_FILE_REPARSE_PROHIBITED`:将 `.env` 替换为普通文件(去掉符号链接/重解析点)。
|
|
57
|
+
- `SECRET_FILE_PATH_PROHIBITED`:修正 `ARGO_ENV_FILE` 与安装根 `.env` 不一致的路径。
|
|
58
|
+
- git 跟踪/忽略类错误(`SECRET_FILE_TRACKED` / `SECRET_FILE_NOT_IGNORED`):把 `.env` 加入 `.gitignore` 并 `git rm --cached`;全局 `.env` 位于仓库外时天然不适用。
|
|
59
|
+
|
|
60
|
+
修复后重跑 `initializeWorkspace`。
|
|
61
|
+
|
|
62
|
+
### 4. Report Concisely
|
|
63
|
+
|
|
64
|
+
输出应直接说明:`mcp` 是否正常、`SystemArchitecture.json` 是否正常、Neo4j 是否连通且**投影数据库名是否与本仓库名一致**、`.qea` 全量投影是否成功且**目标是否为本仓库 .qea 文件**、是否完成一次初始同步、语义生命周期状态与 alignment、报告路径(`.argo/temp/argo-harness-init-report.json`)。
|
|
65
|
+
|
|
66
|
+
## Output
|
|
67
|
+
|
|
68
|
+
输出必须包含:
|
|
69
|
+
|
|
70
|
+
### 1. Environment Status
|
|
71
|
+
- overall status: ok / failed
|
|
72
|
+
- **解析到的 schema:kind(default/workspace/override)+ language(名称)+ actorElementType + dir/guide**(默认 ArgoBument 还是仓内自定义 schema)
|
|
73
|
+
- whether mcp health passed
|
|
74
|
+
- whether neo4j health passed
|
|
75
|
+
- whether .qea full projection passed
|
|
76
|
+
|
|
77
|
+
### 2. Sync Status
|
|
78
|
+
- whether initial sync was executed
|
|
79
|
+
- whether verification matched JSON and Neo4j
|
|
80
|
+
- current counts summary when available
|
|
81
|
+
- **neo4j 投影数据库名 == 本仓库名?**(是/否,给出名称)
|
|
82
|
+
- **qea 投影目标文件 == 本仓库 .qea?**(是/否,给出路径);投影耗时 ms
|
|
83
|
+
|
|
84
|
+
### 3. Semantic Lifecycle Status
|
|
85
|
+
- whether semantic lifecycle init ran, skipped, or failed
|
|
86
|
+
- state/alignment/readiness summary when available
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ea-human-reconcile
|
|
3
|
+
description: "把人类从 EA 提取的 draft 提议(results/human-draft.md,内嵌 JSON 提议集)交给 Agent 后,Agent 结合当前全局(canonical 意图图 design/KG/SystemArchitecture.json + Neo4j 语义检索)逐条/整体分析并给出建议,最终由人类裁决是否写入。它是『人类 EA 草稿 → 语义 diff 提取 → 人类裁决写回』的最后一步:Agent 只做分析+建议,绝不自作主张 apply。Use when the user hands over an EA human-draft proposal set (human-draft.md) and wants the agent to analyze it against the whole architecture and propose, leaving the final decision to the human. Keywords: EA human draft, reconcile, EA 人类草稿裁决, draft review, 语义diff建议, ARGO preview/apply, 人类裁决."
|
|
4
|
+
argument-hint: human-draft
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# EA HUMAN DRAFT RECONCILE(EA 人类草稿 → Agent 分析建议 → 人类裁决)
|
|
9
|
+
|
|
10
|
+
Agent 的职责:结合全局分析 draft 中的每条提议、给出建议与理由、识别风险,把结论呈现给人类,由人类裁决。Agent 不自动执行写入。
|
|
11
|
+
|
|
12
|
+
## 前置
|
|
13
|
+
|
|
14
|
+
- [ ] 存在 `results/human-draft.md`(人类从 EA 提取的草稿提议集)。
|
|
15
|
+
- [ ] 工作区有 `design/KG/SystemArchitecture.json`(canonical 意图图)——分析全局的依据。
|
|
16
|
+
- [ ] ARGO MCP 可用。关键查询手段:
|
|
17
|
+
- 语义/上下文:`getSystemArchitecture`(带 query.purpose + query.intent)、`getIntentElementContext`(看单个元素/关系/视图的依赖与受影响对象)。
|
|
18
|
+
- 结构/类型:`queryNeo4jGraph`(只读 Cypher,如 `MATCH (e:Element {graphKey: $graphKey, type:'<element type>'}) ...`)。先 `{schema:true}` 取当前工作区的语言与类型枚举,类型名一律取自该结果,勿硬编码。
|
|
19
|
+
- 校验:`validateSystemArchitecture`;写图:`previewSystemArchitectureMutation` / `applySystemArchitectureMutation`。
|
|
20
|
+
|
|
21
|
+
## 原则
|
|
22
|
+
|
|
23
|
+
- **人类裁决**:Agent 只分析、给建议、识别风险;**MUST NOT 未经人类裁决就 `applySystemArchitectureMutation`(或任何写图)**。人类拍板(采纳/拒绝/修改)后才写。
|
|
24
|
+
- **全局优先**:不只对着 draft 字段,要用查询手段读 canonical 中相关对象及其依赖(被谁引用、级联影响谁、子视图是否悬空、命名/类型是否与全局一致、是否与既有元素重复冲突),再下判断。
|
|
25
|
+
- **删除/破坏性提议单独把关**:对 `removeElement` / `removeRelationship` / `removeView`,必须指出 canonical 里谁引用它、删除会级联影响谁,并给出「保留 / 改挂 / 确认删除」的建议,交由人类确认。
|
|
26
|
+
- **新增/更新提议**:核对 type / name / description / attributes 是否与全局命名与类型一致、是否与既有元素/关系重复冲突、应挂在哪个 parent / 视图下。
|
|
27
|
+
- **视图提议**:核对成员是否落在正确层级(parent_element_id 是否合理)、删视图会否使相关 subdiagram_views 悬空。
|
|
28
|
+
- **类型以工作区 schema 为准**:分析前先 `queryNeo4jGraph {schema:true}` 取 `schemaLanguage` 与元素/关系类型枚举;按该枚举判定类型,**勿硬编码 ArchiMate 类型**。
|
|
29
|
+
- **只读取、不泄露**:MUST NOT 读取/复述 `.env` 里的 secret 或推断敏感配置值。
|
|
30
|
+
|
|
31
|
+
## 目标
|
|
32
|
+
|
|
33
|
+
读 draft → 结合全局逐条分析 → 给出「逐条建议 + 整体结论 + 待人类裁决项」。具体产出:
|
|
34
|
+
|
|
35
|
+
1. **操作统计**:add/update/remove × element/relationship/view。
|
|
36
|
+
2. **逐条建议**:每条含 `提议`(op + id/名称)、`分析`(全局依赖/冲突/层级)、`建议`(采纳/拒绝/修改后采纳,附理由)、`风险`(若有)。
|
|
37
|
+
3. **整体结论**:这批草稿的整体风险等级、必人工确认的高风险项。
|
|
38
|
+
4. **待裁决**:明确列出需人类拍板的条目,并询问哪些采纳、哪些修改、哪些拒绝。
|
|
39
|
+
|
|
40
|
+
**等待人类答复之后**才进入写回;若人类同意,才经 `previewSystemArchitectureMutation` →(确认后)`applySystemArchitectureMutation`;拒绝/搁置的不写。
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require('node:child_process');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
|
|
7
|
+
const script = path.join(__dirname, '..', 'install-argo.ps1');
|
|
8
|
+
const shell = process.platform === 'win32' ? 'powershell' : 'pwsh';
|
|
9
|
+
const args = ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', script, ...process.argv.slice(2)];
|
|
10
|
+
|
|
11
|
+
const result = spawnSync(shell, args, { stdio: 'inherit' });
|
|
12
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// dsh-argo-wakeup - generated by scripts/gen-dsh-plugins.js from
|
|
2
|
+
// argo/rules/archgraph.instructions.md (single source of truth: the rule file;
|
|
3
|
+
// this file is a deployment artifact, do not edit by hand).
|
|
4
|
+
// DeepSeek Harness equivalent of the OpenCode hook argo/plugins/argo-wakeup.js:
|
|
5
|
+
// registers the unconditional wakeup gate as the first system-prompt section
|
|
6
|
+
// after the harness identity, so every session identifies its Business Actor
|
|
7
|
+
// through the argo MCP server before responding.
|
|
8
|
+
export const name = 'dsh-argo-wakeup'
|
|
9
|
+
export const inject = ['systemPrompt']
|
|
10
|
+
const WAKEUP_GATE = "STEP 0 — UNCONDITIONAL STARTUP GATE. Applies to the very first message of every session, greetings and chat included; never skip, defer, or treat it as optional.\n1. Your first tool call MUST resolve the workspace schema and list its Actors: `queryNeo4jGraph` with `{schema:true}` → read `actorElementType` (`null` = no Actor concept, skip Actor identification), then query that element type. Confirm which Actor you are; if unsure, ask your human partner before anything else.\n2. Restore memory: load ONLY the T1 working-memory digest — your T1 summary, the most recent/active memory cards, and any session hooks (unfinished items from the last session). Do NOT bulk-load the T2 long-term memory or T3 archive; recall them on demand via `memory_search`, then read full content with `getIntentElementContext`. T2 is a recall target, not as a bulk context load.\n3. If the Actor's `agent` attribute differs from your type, switch to it or delegate per `<CoperationGuideline>` item 2.\n4. If the ARGO MCP is unavailable or errors, say so before doing anything else."
|
|
11
|
+
export function apply(ctx) {
|
|
12
|
+
ctx.effect(() => ctx.systemPrompt.section({
|
|
13
|
+
name: 'argo:wakeup',
|
|
14
|
+
order: -90,
|
|
15
|
+
text: WAKEUP_GATE,
|
|
16
|
+
}), 'argo:wakeup.section()')
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|