mcp-probe-kit 3.6.9 → 3.6.11

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 (42) hide show
  1. package/README.md +13 -7
  2. package/build/index.js +16 -13
  3. package/build/lib/__tests__/gitnexus-bridge.unit.test.js +28 -1
  4. package/build/lib/__tests__/src8-guidance.unit.test.d.ts +1 -0
  5. package/build/lib/__tests__/src8-guidance.unit.test.js +62 -0
  6. package/build/lib/__tests__/task-defaults.unit.test.js +16 -2
  7. package/build/lib/code-review-input.d.ts +15 -0
  8. package/build/lib/code-review-input.js +47 -0
  9. package/build/lib/gitnexus-bridge.d.ts +1 -0
  10. package/build/lib/gitnexus-bridge.js +15 -6
  11. package/build/lib/src8-guidance.d.ts +178 -0
  12. package/build/lib/src8-guidance.js +633 -0
  13. package/build/lib/task-defaults.d.ts +2 -1
  14. package/build/lib/task-defaults.js +7 -4
  15. package/build/lib/tbp8-guidance.d.ts +4 -0
  16. package/build/lib/tbp8-guidance.js +4 -0
  17. package/build/schemas/code-analysis-tools.d.ts +49 -5
  18. package/build/schemas/code-analysis-tools.js +49 -5
  19. package/build/schemas/code-gen-tools.d.ts +9 -1
  20. package/build/schemas/code-gen-tools.js +9 -1
  21. package/build/schemas/index.d.ts +65 -9
  22. package/build/schemas/orchestration-tools.d.ts +7 -3
  23. package/build/schemas/orchestration-tools.js +7 -3
  24. package/build/schemas/output/core-tools.d.ts +238 -13
  25. package/build/schemas/output/core-tools.js +63 -13
  26. package/build/schemas/structured-output.d.ts +26 -8
  27. package/build/schemas/structured-output.js +17 -7
  28. package/build/tools/__tests__/code_review.unit.test.d.ts +1 -0
  29. package/build/tools/__tests__/code_review.unit.test.js +43 -0
  30. package/build/tools/__tests__/fix_bug.unit.test.js +54 -17
  31. package/build/tools/__tests__/gentest.unit.test.d.ts +1 -0
  32. package/build/tools/__tests__/gentest.unit.test.js +40 -0
  33. package/build/tools/__tests__/refactor.unit.test.d.ts +1 -0
  34. package/build/tools/__tests__/refactor.unit.test.js +40 -0
  35. package/build/tools/__tests__/start_bugfix.unit.test.js +31 -18
  36. package/build/tools/code_review.js +149 -164
  37. package/build/tools/fix_bug.d.ts +1 -9
  38. package/build/tools/fix_bug.js +137 -289
  39. package/build/tools/gentest.js +149 -186
  40. package/build/tools/refactor.js +132 -360
  41. package/build/tools/start_bugfix.js +258 -344
  42. package/package.json +1 -1
@@ -91,9 +91,109 @@ export declare const CodeReviewReportSchema: {
91
91
  };
92
92
  readonly required: readonly ["summary", "overallScore", "issues"];
93
93
  };
94
+ /** SRC-8 Step 4 真因工作表 — Agent 必须产出 */
95
+ export declare const RootCauseAnalysisSchema: {
96
+ readonly type: "object";
97
+ readonly description: "SRC-8 Step 4 把握真因:假设清单、排除矩阵、对比分叉、5 Why、因果陈述";
98
+ readonly properties: {
99
+ readonly mode: {
100
+ readonly type: "string";
101
+ readonly enum: readonly ["simple", "complex"];
102
+ };
103
+ readonly attributionLayer: {
104
+ readonly type: "string";
105
+ readonly enum: readonly ["code", "runtime", "data_contract", "integration", "agent_behavior", "environment"];
106
+ };
107
+ readonly hypotheses: {
108
+ readonly type: "array";
109
+ readonly items: {
110
+ readonly type: "object";
111
+ readonly properties: {
112
+ readonly id: {
113
+ readonly type: "string";
114
+ };
115
+ readonly statement: {
116
+ readonly type: "string";
117
+ };
118
+ readonly attributionLayer: {
119
+ readonly type: "string";
120
+ readonly enum: readonly ["code", "runtime", "data_contract", "integration", "agent_behavior", "environment"];
121
+ };
122
+ readonly status: {
123
+ readonly type: "string";
124
+ readonly enum: readonly ["ruled_out", "pending", "confirmed"];
125
+ };
126
+ readonly evidence: {
127
+ readonly type: "array";
128
+ readonly items: {
129
+ readonly type: "string";
130
+ };
131
+ };
132
+ readonly counterEvidence: {
133
+ readonly type: "array";
134
+ readonly items: {
135
+ readonly type: "string";
136
+ };
137
+ };
138
+ };
139
+ readonly required: readonly ["id", "statement", "status"];
140
+ };
141
+ };
142
+ readonly forkPoint: {
143
+ readonly type: "string";
144
+ readonly description: "成功/失败分叉点";
145
+ };
146
+ readonly whyChain: {
147
+ readonly type: "array";
148
+ readonly items: {
149
+ readonly type: "object";
150
+ readonly properties: {
151
+ readonly level: {
152
+ readonly type: "number";
153
+ };
154
+ readonly observation: {
155
+ readonly type: "string";
156
+ readonly description: "观察到的事实";
157
+ };
158
+ readonly why: {
159
+ readonly type: "string";
160
+ };
161
+ readonly because: {
162
+ readonly type: "string";
163
+ };
164
+ };
165
+ readonly required: readonly ["level", "observation", "why", "because"];
166
+ };
167
+ };
168
+ readonly primaryCause: {
169
+ readonly type: "string";
170
+ };
171
+ readonly contributingFactors: {
172
+ readonly type: "array";
173
+ readonly items: {
174
+ readonly type: "string";
175
+ };
176
+ };
177
+ readonly rootCauseStatement: {
178
+ readonly type: "string";
179
+ readonly description: "因果句:A + B 在 D 下导致 C";
180
+ };
181
+ readonly confidence: {
182
+ readonly type: "string";
183
+ readonly enum: readonly ["high", "medium", "low"];
184
+ };
185
+ readonly evidenceGaps: {
186
+ readonly type: "array";
187
+ readonly items: {
188
+ readonly type: "string";
189
+ };
190
+ };
191
+ };
192
+ readonly required: readonly ["mode", "hypotheses", "whyChain", "rootCauseStatement", "confidence"];
193
+ };
94
194
  /**
95
195
  * Bug Analysis Schema
96
- * 用于 fix_bug 工具的结构化输出
196
+ * 用于 fix_bug 工具的结构化输出(SRC-8,TBP-inspired)
97
197
  */
98
198
  export declare const BugAnalysisSchema: {
99
199
  readonly type: "object";
@@ -112,10 +212,111 @@ export declare const BugAnalysisSchema: {
112
212
  };
113
213
  readonly analysisMode: {
114
214
  readonly type: "string";
115
- readonly enum: readonly ["tbp8"];
215
+ readonly enum: readonly ["src8", "tbp8"];
216
+ readonly description: "分析方法:src8(推荐);tbp8 为兼容别名";
116
217
  };
117
218
  readonly rootCause: {
118
219
  readonly type: "string";
220
+ readonly description: "SRC-4 真因摘要";
221
+ };
222
+ readonly rootCauseAnalysis: {
223
+ readonly type: "object";
224
+ readonly description: "SRC-8 Step 4 把握真因:假设清单、排除矩阵、对比分叉、5 Why、因果陈述";
225
+ readonly properties: {
226
+ readonly mode: {
227
+ readonly type: "string";
228
+ readonly enum: readonly ["simple", "complex"];
229
+ };
230
+ readonly attributionLayer: {
231
+ readonly type: "string";
232
+ readonly enum: readonly ["code", "runtime", "data_contract", "integration", "agent_behavior", "environment"];
233
+ };
234
+ readonly hypotheses: {
235
+ readonly type: "array";
236
+ readonly items: {
237
+ readonly type: "object";
238
+ readonly properties: {
239
+ readonly id: {
240
+ readonly type: "string";
241
+ };
242
+ readonly statement: {
243
+ readonly type: "string";
244
+ };
245
+ readonly attributionLayer: {
246
+ readonly type: "string";
247
+ readonly enum: readonly ["code", "runtime", "data_contract", "integration", "agent_behavior", "environment"];
248
+ };
249
+ readonly status: {
250
+ readonly type: "string";
251
+ readonly enum: readonly ["ruled_out", "pending", "confirmed"];
252
+ };
253
+ readonly evidence: {
254
+ readonly type: "array";
255
+ readonly items: {
256
+ readonly type: "string";
257
+ };
258
+ };
259
+ readonly counterEvidence: {
260
+ readonly type: "array";
261
+ readonly items: {
262
+ readonly type: "string";
263
+ };
264
+ };
265
+ };
266
+ readonly required: readonly ["id", "statement", "status"];
267
+ };
268
+ };
269
+ readonly forkPoint: {
270
+ readonly type: "string";
271
+ readonly description: "成功/失败分叉点";
272
+ };
273
+ readonly whyChain: {
274
+ readonly type: "array";
275
+ readonly items: {
276
+ readonly type: "object";
277
+ readonly properties: {
278
+ readonly level: {
279
+ readonly type: "number";
280
+ };
281
+ readonly observation: {
282
+ readonly type: "string";
283
+ readonly description: "观察到的事实";
284
+ };
285
+ readonly why: {
286
+ readonly type: "string";
287
+ };
288
+ readonly because: {
289
+ readonly type: "string";
290
+ };
291
+ };
292
+ readonly required: readonly ["level", "observation", "why", "because"];
293
+ };
294
+ };
295
+ readonly primaryCause: {
296
+ readonly type: "string";
297
+ };
298
+ readonly contributingFactors: {
299
+ readonly type: "array";
300
+ readonly items: {
301
+ readonly type: "string";
302
+ };
303
+ };
304
+ readonly rootCauseStatement: {
305
+ readonly type: "string";
306
+ readonly description: "因果句:A + B 在 D 下导致 C";
307
+ };
308
+ readonly confidence: {
309
+ readonly type: "string";
310
+ readonly enum: readonly ["high", "medium", "low"];
311
+ };
312
+ readonly evidenceGaps: {
313
+ readonly type: "array";
314
+ readonly items: {
315
+ readonly type: "string";
316
+ };
317
+ };
318
+ };
319
+ readonly required: readonly ["mode", "hypotheses", "whyChain", "rootCauseStatement", "confidence"];
119
320
  };
120
321
  readonly affectedComponents: {
121
322
  readonly type: "array";
@@ -180,16 +381,16 @@ export declare const BugAnalysisSchema: {
180
381
  };
181
382
  };
182
383
  readonly tbp: {
183
- readonly description: "TBP 8 步法分析结果";
384
+ readonly description: "SRC-8 各步产出(字段名 tbp 为历史兼容)";
184
385
  readonly type: "object";
185
386
  readonly properties: {
186
387
  readonly phenomenon: {
187
388
  readonly type: "string";
188
- readonly description: "TBP-1 现象";
389
+ readonly description: "SRC-1 明确差距";
189
390
  };
190
391
  readonly timeline: {
191
392
  readonly type: "array";
192
- readonly description: "TBP-2 时间线";
393
+ readonly description: "SRC-2 时间线/分解";
193
394
  readonly items: {
194
395
  readonly type: "object";
195
396
  readonly properties: {
@@ -211,26 +412,26 @@ export declare const BugAnalysisSchema: {
211
412
  };
212
413
  readonly ruledOut: {
213
414
  readonly type: "array";
214
- readonly description: "TBP-3 已排除方向";
415
+ readonly description: "SRC-4 已排除假设";
215
416
  readonly items: {
216
417
  readonly type: "string";
217
418
  };
218
419
  };
219
420
  readonly commonPattern: {
220
421
  readonly type: "string";
221
- readonly description: "TBP-4 共同模式";
422
+ readonly description: "SRC-4 对比分叉";
222
423
  };
223
424
  readonly boundary: {
224
425
  readonly type: "string";
225
- readonly description: "TBP-5 问题边界";
426
+ readonly description: "SRC-2 问题边界/归因层";
226
427
  };
227
428
  readonly rootCauseStatement: {
228
429
  readonly type: "string";
229
- readonly description: "TBP-6 真因因果句";
430
+ readonly description: "SRC-4 真因因果句";
230
431
  };
231
432
  readonly evidence: {
232
433
  readonly type: "array";
233
- readonly description: "TBP-7 证据链";
434
+ readonly description: "SRC-4 证据链";
234
435
  readonly items: {
235
436
  readonly type: "object";
236
437
  readonly properties: {
@@ -253,7 +454,7 @@ export declare const BugAnalysisSchema: {
253
454
  };
254
455
  readonly repair: {
255
456
  readonly type: "array";
256
- readonly description: "TBP-8 修复设计";
457
+ readonly description: "SRC-5 对策设计";
257
458
  readonly items: {
258
459
  readonly type: "object";
259
460
  readonly properties: {
@@ -281,7 +482,7 @@ export declare const BugAnalysisSchema: {
281
482
  readonly required: readonly ["phenomenon", "timeline", "ruledOut", "commonPattern", "boundary", "rootCauseStatement", "evidence", "repair"];
282
483
  };
283
484
  };
284
- readonly required: readonly ["summary", "bugType", "severity", "analysisMode", "rootCause", "fixPlan", "testPlan", "tbp"];
485
+ readonly required: readonly ["summary", "bugType", "severity", "analysisMode", "rootCause", "rootCauseAnalysis", "fixPlan", "testPlan", "tbp"];
285
486
  };
286
487
  /**
287
488
  * Test Suite Schema
@@ -685,8 +886,32 @@ export interface BugAnalysis {
685
886
  summary: string;
686
887
  bugType: 'functional' | 'performance' | 'security' | 'ui' | 'data' | 'integration';
687
888
  severity: 'critical' | 'high' | 'medium' | 'low';
688
- analysisMode: 'tbp8';
889
+ analysisMode: 'src8' | 'tbp8';
689
890
  rootCause: string;
891
+ rootCauseAnalysis: {
892
+ mode: 'simple' | 'complex';
893
+ attributionLayer?: 'code' | 'runtime' | 'data_contract' | 'integration' | 'agent_behavior' | 'environment';
894
+ hypotheses: Array<{
895
+ id: string;
896
+ statement: string;
897
+ attributionLayer?: 'code' | 'runtime' | 'data_contract' | 'integration' | 'agent_behavior' | 'environment';
898
+ status: 'ruled_out' | 'pending' | 'confirmed';
899
+ evidence?: string[];
900
+ counterEvidence?: string[];
901
+ }>;
902
+ forkPoint?: string;
903
+ whyChain: Array<{
904
+ level: number;
905
+ observation: string;
906
+ why: string;
907
+ because: string;
908
+ }>;
909
+ primaryCause?: string;
910
+ contributingFactors?: string[];
911
+ rootCauseStatement: string;
912
+ confidence: 'high' | 'medium' | 'low';
913
+ evidenceGaps?: string[];
914
+ };
690
915
  affectedComponents?: string[];
691
916
  affectedFiles?: string[];
692
917
  fixPlan: {
@@ -98,31 +98,77 @@ const TbpRepairItemSchema = {
98
98
  },
99
99
  required: ['layer', 'action', 'verification'],
100
100
  };
101
+ const RootCauseHypothesisSchema = {
102
+ type: 'object',
103
+ properties: {
104
+ id: { type: 'string' },
105
+ statement: { type: 'string' },
106
+ attributionLayer: {
107
+ type: 'string',
108
+ enum: ['code', 'runtime', 'data_contract', 'integration', 'agent_behavior', 'environment'],
109
+ },
110
+ status: { type: 'string', enum: ['ruled_out', 'pending', 'confirmed'] },
111
+ evidence: { type: 'array', items: { type: 'string' } },
112
+ counterEvidence: { type: 'array', items: { type: 'string' } },
113
+ },
114
+ required: ['id', 'statement', 'status'],
115
+ };
116
+ const WhyChainItemSchema = {
117
+ type: 'object',
118
+ properties: {
119
+ level: { type: 'number' },
120
+ observation: { type: 'string', description: '观察到的事实' },
121
+ why: { type: 'string' },
122
+ because: { type: 'string' },
123
+ },
124
+ required: ['level', 'observation', 'why', 'because'],
125
+ };
126
+ /** SRC-8 Step 4 真因工作表 — Agent 必须产出 */
127
+ export const RootCauseAnalysisSchema = {
128
+ type: 'object',
129
+ description: 'SRC-8 Step 4 把握真因:假设清单、排除矩阵、对比分叉、5 Why、因果陈述',
130
+ properties: {
131
+ mode: { type: 'string', enum: ['simple', 'complex'] },
132
+ attributionLayer: {
133
+ type: 'string',
134
+ enum: ['code', 'runtime', 'data_contract', 'integration', 'agent_behavior', 'environment'],
135
+ },
136
+ hypotheses: { type: 'array', items: RootCauseHypothesisSchema },
137
+ forkPoint: { type: 'string', description: '成功/失败分叉点' },
138
+ whyChain: { type: 'array', items: WhyChainItemSchema },
139
+ primaryCause: { type: 'string' },
140
+ contributingFactors: { type: 'array', items: { type: 'string' } },
141
+ rootCauseStatement: { type: 'string', description: '因果句:A + B 在 D 下导致 C' },
142
+ confidence: { type: 'string', enum: ['high', 'medium', 'low'] },
143
+ evidenceGaps: { type: 'array', items: { type: 'string' } },
144
+ },
145
+ required: ['mode', 'hypotheses', 'whyChain', 'rootCauseStatement', 'confidence'],
146
+ };
101
147
  const TbpAnalysisSchema = {
102
148
  type: 'object',
103
149
  properties: {
104
- phenomenon: { type: 'string', description: 'TBP-1 现象' },
150
+ phenomenon: { type: 'string', description: 'SRC-1 明确差距' },
105
151
  timeline: {
106
152
  type: 'array',
107
- description: 'TBP-2 时间线',
153
+ description: 'SRC-2 时间线/分解',
108
154
  items: TbpTimelineEventSchema,
109
155
  },
110
156
  ruledOut: {
111
157
  type: 'array',
112
- description: 'TBP-3 已排除方向',
158
+ description: 'SRC-4 已排除假设',
113
159
  items: { type: 'string' },
114
160
  },
115
- commonPattern: { type: 'string', description: 'TBP-4 共同模式' },
116
- boundary: { type: 'string', description: 'TBP-5 问题边界' },
117
- rootCauseStatement: { type: 'string', description: 'TBP-6 真因因果句' },
161
+ commonPattern: { type: 'string', description: 'SRC-4 对比分叉' },
162
+ boundary: { type: 'string', description: 'SRC-2 问题边界/归因层' },
163
+ rootCauseStatement: { type: 'string', description: 'SRC-4 真因因果句' },
118
164
  evidence: {
119
165
  type: 'array',
120
- description: 'TBP-7 证据链',
166
+ description: 'SRC-4 证据链',
121
167
  items: TbpEvidenceItemSchema,
122
168
  },
123
169
  repair: {
124
170
  type: 'array',
125
- description: 'TBP-8 修复设计',
171
+ description: 'SRC-5 对策设计',
126
172
  items: TbpRepairItemSchema,
127
173
  },
128
174
  },
@@ -130,7 +176,7 @@ const TbpAnalysisSchema = {
130
176
  };
131
177
  /**
132
178
  * Bug Analysis Schema
133
- * 用于 fix_bug 工具的结构化输出
179
+ * 用于 fix_bug 工具的结构化输出(SRC-8,TBP-inspired)
134
180
  */
135
181
  export const BugAnalysisSchema = {
136
182
  type: 'object',
@@ -146,9 +192,13 @@ export const BugAnalysisSchema = {
146
192
  },
147
193
  analysisMode: {
148
194
  type: 'string',
149
- enum: ['tbp8'],
195
+ enum: ['src8', 'tbp8'],
196
+ description: '分析方法:src8(推荐);tbp8 为兼容别名',
197
+ },
198
+ rootCause: { type: 'string', description: 'SRC-4 真因摘要' },
199
+ rootCauseAnalysis: {
200
+ ...RootCauseAnalysisSchema,
150
201
  },
151
- rootCause: { type: 'string' },
152
202
  affectedComponents: {
153
203
  type: 'array',
154
204
  items: { type: 'string' },
@@ -180,10 +230,10 @@ export const BugAnalysisSchema = {
180
230
  },
181
231
  tbp: {
182
232
  ...TbpAnalysisSchema,
183
- description: 'TBP 8 步法分析结果',
233
+ description: 'SRC-8 各步产出(字段名 tbp 为历史兼容)',
184
234
  },
185
235
  },
186
- required: ['summary', 'bugType', 'severity', 'analysisMode', 'rootCause', 'fixPlan', 'testPlan', 'tbp'],
236
+ required: ['summary', 'bugType', 'severity', 'analysisMode', 'rootCause', 'rootCauseAnalysis', 'fixPlan', 'testPlan', 'tbp'],
187
237
  };
188
238
  /**
189
239
  * Test Suite Schema
@@ -317,8 +317,8 @@ export declare const BugFixReportSchema: {
317
317
  readonly properties: {
318
318
  readonly analysisMode: {
319
319
  readonly type: "string";
320
- readonly enum: readonly ["tbp8"];
321
- readonly description: "分析方法";
320
+ readonly enum: readonly ["src8", "tbp8"];
321
+ readonly description: "分析方法(src8 推荐;tbp8 兼容)";
322
322
  };
323
323
  readonly rootCause: {
324
324
  readonly type: "string";
@@ -344,7 +344,7 @@ export declare const BugFixReportSchema: {
344
344
  };
345
345
  };
346
346
  readonly tbp: {
347
- readonly description: "TBP 8 步法分析骨架";
347
+ readonly description: "SRC-8 分析骨架(字段名 tbp 为历史兼容)";
348
348
  readonly type: "object";
349
349
  readonly properties: {
350
350
  readonly phenomenon: {
@@ -1005,7 +1005,7 @@ export interface ExecutionPlan {
1005
1005
  steps: PlanStep[];
1006
1006
  }
1007
1007
  export interface BugFixReport extends WorkflowReport {
1008
- analysisMode: 'tbp8';
1008
+ analysisMode: 'src8' | 'tbp8';
1009
1009
  rootCause: string;
1010
1010
  fixPlan: string;
1011
1011
  testPlan: string;
@@ -1271,13 +1271,31 @@ export declare const BugAnalysisSchema: {
1271
1271
  };
1272
1272
  readonly analysisMode: {
1273
1273
  readonly type: "string";
1274
- readonly enum: readonly ["tbp8"];
1275
- readonly description: "分析方法";
1274
+ readonly enum: readonly ["src8", "tbp8"];
1275
+ readonly description: "分析方法(src8 推荐;tbp8 兼容)";
1276
1276
  };
1277
1277
  readonly rootCause: {
1278
1278
  readonly type: "string";
1279
1279
  readonly description: "根本原因";
1280
1280
  };
1281
+ readonly rootCauseAnalysis: {
1282
+ readonly type: "object";
1283
+ readonly description: "SRC-8 Step 4 真因工作表产出";
1284
+ readonly properties: {
1285
+ readonly mode: {
1286
+ readonly type: "string";
1287
+ readonly enum: readonly ["simple", "complex"];
1288
+ };
1289
+ readonly rootCauseStatement: {
1290
+ readonly type: "string";
1291
+ };
1292
+ readonly confidence: {
1293
+ readonly type: "string";
1294
+ readonly enum: readonly ["high", "medium", "low"];
1295
+ };
1296
+ };
1297
+ readonly required: readonly ["mode", "rootCauseStatement", "confidence"];
1298
+ };
1281
1299
  readonly affectedComponents: {
1282
1300
  readonly type: "array";
1283
1301
  readonly description: "受影响的组件";
@@ -1346,7 +1364,7 @@ export declare const BugAnalysisSchema: {
1346
1364
  };
1347
1365
  };
1348
1366
  readonly tbp: {
1349
- readonly description: "TBP 8 步法分析结果";
1367
+ readonly description: "SRC-8 各步产出(字段名 tbp 为历史兼容)";
1350
1368
  readonly type: "object";
1351
1369
  readonly properties: {
1352
1370
  readonly phenomenon: {
@@ -1447,7 +1465,7 @@ export declare const BugAnalysisSchema: {
1447
1465
  readonly required: readonly ["phenomenon", "timeline", "ruledOut", "commonPattern", "boundary", "rootCauseStatement", "evidence", "repair"];
1448
1466
  };
1449
1467
  };
1450
- readonly required: readonly ["summary", "bugType", "severity", "analysisMode", "rootCause", "fixPlan", "testPlan", "tbp"];
1468
+ readonly required: readonly ["summary", "bugType", "severity", "analysisMode", "rootCause", "rootCauseAnalysis", "fixPlan", "testPlan", "tbp"];
1451
1469
  };
1452
1470
  /**
1453
1471
  * Test Suite Schema
@@ -343,8 +343,8 @@ export const BugFixReportSchema = {
343
343
  properties: {
344
344
  analysisMode: {
345
345
  type: 'string',
346
- enum: ['tbp8'],
347
- description: '分析方法',
346
+ enum: ['src8', 'tbp8'],
347
+ description: '分析方法(src8 推荐;tbp8 兼容)',
348
348
  },
349
349
  rootCause: {
350
350
  type: 'string',
@@ -371,7 +371,7 @@ export const BugFixReportSchema = {
371
371
  },
372
372
  tbp: {
373
373
  ...TbpAnalysisSchema,
374
- description: 'TBP 8 步法分析骨架',
374
+ description: 'SRC-8 分析骨架(字段名 tbp 为历史兼容)',
375
375
  },
376
376
  },
377
377
  required: ['analysisMode', 'rootCause', 'fixPlan', 'testPlan', 'tbp'],
@@ -920,13 +920,23 @@ export const BugAnalysisSchema = {
920
920
  },
921
921
  analysisMode: {
922
922
  type: 'string',
923
- enum: ['tbp8'],
924
- description: '分析方法',
923
+ enum: ['src8', 'tbp8'],
924
+ description: '分析方法(src8 推荐;tbp8 兼容)',
925
925
  },
926
926
  rootCause: {
927
927
  type: 'string',
928
928
  description: '根本原因',
929
929
  },
930
+ rootCauseAnalysis: {
931
+ type: 'object',
932
+ description: 'SRC-8 Step 4 真因工作表产出',
933
+ properties: {
934
+ mode: { type: 'string', enum: ['simple', 'complex'] },
935
+ rootCauseStatement: { type: 'string' },
936
+ confidence: { type: 'string', enum: ['high', 'medium', 'low'] },
937
+ },
938
+ required: ['mode', 'rootCauseStatement', 'confidence'],
939
+ },
930
940
  affectedComponents: {
931
941
  type: 'array',
932
942
  description: '受影响的组件',
@@ -978,10 +988,10 @@ export const BugAnalysisSchema = {
978
988
  },
979
989
  tbp: {
980
990
  ...TbpAnalysisSchema,
981
- description: 'TBP 8 步法分析结果',
991
+ description: 'SRC-8 各步产出(字段名 tbp 为历史兼容)',
982
992
  },
983
993
  },
984
- required: ['summary', 'bugType', 'severity', 'analysisMode', 'rootCause', 'fixPlan', 'testPlan', 'tbp'],
994
+ required: ['summary', 'bugType', 'severity', 'analysisMode', 'rootCause', 'rootCauseAnalysis', 'fixPlan', 'testPlan', 'tbp'],
985
995
  };
986
996
  /**
987
997
  * Test Suite Schema
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import * as fs from "node:fs";
3
+ import * as os from "node:os";
4
+ import * as path from "node:path";
5
+ import { codeReview } from "../code_review.js";
6
+ describe("code_review 单元测试", () => {
7
+ test("传入 code 时注入待审内容,并标明由 Agent 生成 issues", async () => {
8
+ const sample = "const api_key = 'sk-live-abcdefgh';\n// TODO: fix\n";
9
+ const result = await codeReview({ code: sample, focus: "security" });
10
+ expect(result.isError).toBeFalsy();
11
+ const text = String(result.content[0].text);
12
+ expect(text).toContain("sk-live-abcdefgh");
13
+ expect(text).toContain("Agent 必须输出的 JSON");
14
+ expect(text).toMatch(/指南型|guidance/i);
15
+ expect(text).not.toMatch(/静态扫描结果/);
16
+ const meta = result._meta;
17
+ const structured = result.structuredContent;
18
+ expect(structured.mode).toBe("guidance");
19
+ expect(structured.reviewInput.received).toBe(true);
20
+ expect(structured.reviewInput.code).toContain("sk-live-abcdefgh");
21
+ expect(meta?.note).toMatch(/Agent/);
22
+ });
23
+ test("未传 code/file_path 时明确提示 Agent 需先获取代码", async () => {
24
+ const result = await codeReview({ focus: "quality" });
25
+ const text = String(result.content[0].text);
26
+ expect(text).toMatch(/未提供 code/);
27
+ expect(result.structuredContent.reviewInput.received).toBe(false);
28
+ });
29
+ test("file_path 可读时注入文件内容", async () => {
30
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "code-review-"));
31
+ const filePath = path.join(dir, "sample.ts");
32
+ fs.writeFileSync(filePath, "eval(input);\n", "utf-8");
33
+ try {
34
+ const result = await codeReview({ file_path: filePath, project_root: dir });
35
+ const text = String(result.content[0].text);
36
+ expect(text).toContain("eval(input)");
37
+ expect(result.structuredContent.reviewInput.file).toBe(filePath);
38
+ }
39
+ finally {
40
+ fs.rmSync(dir, { recursive: true, force: true });
41
+ }
42
+ });
43
+ });