ghagga-core 2.5.0 → 2.6.1

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 (154) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/consensus.d.ts +16 -0
  3. package/dist/agents/consensus.d.ts.map +1 -1
  4. package/dist/agents/consensus.js +57 -33
  5. package/dist/agents/consensus.js.map +1 -1
  6. package/dist/agents/diagnostic.d.ts +55 -0
  7. package/dist/agents/diagnostic.d.ts.map +1 -0
  8. package/dist/agents/diagnostic.js +143 -0
  9. package/dist/agents/diagnostic.js.map +1 -0
  10. package/dist/agents/prompts.d.ts +6 -4
  11. package/dist/agents/prompts.d.ts.map +1 -1
  12. package/dist/agents/prompts.js +110 -24
  13. package/dist/agents/prompts.js.map +1 -1
  14. package/dist/agents/simple.d.ts +7 -0
  15. package/dist/agents/simple.d.ts.map +1 -1
  16. package/dist/agents/simple.js +32 -18
  17. package/dist/agents/simple.js.map +1 -1
  18. package/dist/agents/workflow.d.ts +28 -1
  19. package/dist/agents/workflow.d.ts.map +1 -1
  20. package/dist/agents/workflow.js +112 -45
  21. package/dist/agents/workflow.js.map +1 -1
  22. package/dist/enhance/enhance.d.ts.map +1 -1
  23. package/dist/enhance/enhance.js +16 -4
  24. package/dist/enhance/enhance.js.map +1 -1
  25. package/dist/format.d.ts +47 -1
  26. package/dist/format.d.ts.map +1 -1
  27. package/dist/format.js +175 -3
  28. package/dist/format.js.map +1 -1
  29. package/dist/graph/blast-radius.d.ts +57 -0
  30. package/dist/graph/blast-radius.d.ts.map +1 -0
  31. package/dist/graph/blast-radius.js +145 -0
  32. package/dist/graph/blast-radius.js.map +1 -0
  33. package/dist/graph/builder.d.ts +50 -0
  34. package/dist/graph/builder.d.ts.map +1 -0
  35. package/dist/graph/builder.js +210 -0
  36. package/dist/graph/builder.js.map +1 -0
  37. package/dist/graph/extractors/go.d.ts +9 -0
  38. package/dist/graph/extractors/go.d.ts.map +1 -0
  39. package/dist/graph/extractors/go.js +78 -0
  40. package/dist/graph/extractors/go.js.map +1 -0
  41. package/dist/graph/extractors/index.d.ts +22 -0
  42. package/dist/graph/extractors/index.d.ts.map +1 -0
  43. package/dist/graph/extractors/index.js +37 -0
  44. package/dist/graph/extractors/index.js.map +1 -0
  45. package/dist/graph/extractors/java.d.ts +9 -0
  46. package/dist/graph/extractors/java.d.ts.map +1 -0
  47. package/dist/graph/extractors/java.js +80 -0
  48. package/dist/graph/extractors/java.js.map +1 -0
  49. package/dist/graph/extractors/javascript.d.ts +9 -0
  50. package/dist/graph/extractors/javascript.d.ts.map +1 -0
  51. package/dist/graph/extractors/javascript.js +204 -0
  52. package/dist/graph/extractors/javascript.js.map +1 -0
  53. package/dist/graph/extractors/python.d.ts +9 -0
  54. package/dist/graph/extractors/python.d.ts.map +1 -0
  55. package/dist/graph/extractors/python.js +103 -0
  56. package/dist/graph/extractors/python.js.map +1 -0
  57. package/dist/graph/extractors/rust.d.ts +9 -0
  58. package/dist/graph/extractors/rust.d.ts.map +1 -0
  59. package/dist/graph/extractors/rust.js +115 -0
  60. package/dist/graph/extractors/rust.js.map +1 -0
  61. package/dist/graph/extractors/types.d.ts +31 -0
  62. package/dist/graph/extractors/types.d.ts.map +1 -0
  63. package/dist/graph/extractors/types.js +9 -0
  64. package/dist/graph/extractors/types.js.map +1 -0
  65. package/dist/graph/extractors/typescript.d.ts +9 -0
  66. package/dist/graph/extractors/typescript.d.ts.map +1 -0
  67. package/dist/graph/extractors/typescript.js +151 -0
  68. package/dist/graph/extractors/typescript.js.map +1 -0
  69. package/dist/graph/index.d.ts +15 -0
  70. package/dist/graph/index.d.ts.map +1 -0
  71. package/dist/graph/index.js +14 -0
  72. package/dist/graph/index.js.map +1 -0
  73. package/dist/graph/loader.d.ts +43 -0
  74. package/dist/graph/loader.d.ts.map +1 -0
  75. package/dist/graph/loader.js +104 -0
  76. package/dist/graph/loader.js.map +1 -0
  77. package/dist/graph/schema.d.ts +113 -0
  78. package/dist/graph/schema.d.ts.map +1 -0
  79. package/dist/graph/schema.js +144 -0
  80. package/dist/graph/schema.js.map +1 -0
  81. package/dist/health/trends.js +1 -1
  82. package/dist/health/trends.js.map +1 -1
  83. package/dist/index.d.ts +20 -5
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +10 -4
  86. package/dist/index.js.map +1 -1
  87. package/dist/memory/sqlite.d.ts.map +1 -1
  88. package/dist/memory/sqlite.js +9 -5
  89. package/dist/memory/sqlite.js.map +1 -1
  90. package/dist/pipeline.d.ts.map +1 -1
  91. package/dist/pipeline.js +291 -42
  92. package/dist/pipeline.js.map +1 -1
  93. package/dist/providers/cli-bridge.d.ts +136 -0
  94. package/dist/providers/cli-bridge.d.ts.map +1 -0
  95. package/dist/providers/cli-bridge.js +457 -0
  96. package/dist/providers/cli-bridge.js.map +1 -0
  97. package/dist/providers/fallback.d.ts +8 -0
  98. package/dist/providers/fallback.d.ts.map +1 -1
  99. package/dist/providers/fallback.js +24 -8
  100. package/dist/providers/fallback.js.map +1 -1
  101. package/dist/providers/gateway.d.ts +40 -0
  102. package/dist/providers/gateway.d.ts.map +1 -0
  103. package/dist/providers/gateway.js +52 -0
  104. package/dist/providers/gateway.js.map +1 -0
  105. package/dist/providers/generate-fn.d.ts +62 -0
  106. package/dist/providers/generate-fn.d.ts.map +1 -0
  107. package/dist/providers/generate-fn.js +84 -0
  108. package/dist/providers/generate-fn.js.map +1 -0
  109. package/dist/providers/index.d.ts +5 -0
  110. package/dist/providers/index.d.ts.map +1 -1
  111. package/dist/providers/index.js +60 -2
  112. package/dist/providers/index.js.map +1 -1
  113. package/dist/tools/plugins/index.d.ts +2 -0
  114. package/dist/tools/plugins/index.d.ts.map +1 -1
  115. package/dist/tools/plugins/index.js +7 -0
  116. package/dist/tools/plugins/index.js.map +1 -1
  117. package/dist/tools/plugins/zizmor.d.ts +22 -0
  118. package/dist/tools/plugins/zizmor.d.ts.map +1 -0
  119. package/dist/tools/plugins/zizmor.js +112 -0
  120. package/dist/tools/plugins/zizmor.js.map +1 -0
  121. package/dist/tools/resolve.js +1 -1
  122. package/dist/tools/resolve.js.map +1 -1
  123. package/dist/tools/types.d.ts +1 -1
  124. package/dist/tools/types.d.ts.map +1 -1
  125. package/dist/types.d.ts +54 -3
  126. package/dist/types.d.ts.map +1 -1
  127. package/dist/types.js +21 -1
  128. package/dist/types.js.map +1 -1
  129. package/dist/utils/concurrency.d.ts +29 -0
  130. package/dist/utils/concurrency.d.ts.map +1 -0
  131. package/dist/utils/concurrency.js +40 -0
  132. package/dist/utils/concurrency.js.map +1 -0
  133. package/dist/utils/context-levels.d.ts +113 -0
  134. package/dist/utils/context-levels.d.ts.map +1 -0
  135. package/dist/utils/context-levels.js +255 -0
  136. package/dist/utils/context-levels.js.map +1 -0
  137. package/dist/utils/diff.d.ts +25 -0
  138. package/dist/utils/diff.d.ts.map +1 -1
  139. package/dist/utils/diff.js +28 -0
  140. package/dist/utils/diff.js.map +1 -1
  141. package/dist/utils/llm-timeout.d.ts +38 -0
  142. package/dist/utils/llm-timeout.d.ts.map +1 -0
  143. package/dist/utils/llm-timeout.js +76 -0
  144. package/dist/utils/llm-timeout.js.map +1 -0
  145. package/dist/utils/path-protection.d.ts +59 -0
  146. package/dist/utils/path-protection.d.ts.map +1 -0
  147. package/dist/utils/path-protection.js +136 -0
  148. package/dist/utils/path-protection.js.map +1 -0
  149. package/dist/utils/token-budget.d.ts +34 -1
  150. package/dist/utils/token-budget.d.ts.map +1 -1
  151. package/dist/utils/token-budget.js +108 -3
  152. package/dist/utils/token-budget.js.map +1 -1
  153. package/package.json +21 -19
  154. package/LICENSE +0 -21
package/README.md CHANGED
@@ -35,7 +35,7 @@ console.log(result.findings);
35
35
  |------|-----------|----------|
36
36
  | **simple** | 1 | Small PRs, quick feedback |
37
37
  | **workflow** | 6 | Thorough review with 5 specialist agents + synthesis |
38
- | **consensus** | 3 | Balanced review with for/against/neutral voting |
38
+ | **consensus** | 3 | Same model, three perspectives (for/against/neutral) + algorithmic vote |
39
39
 
40
40
  ## Providers
41
41
 
@@ -11,6 +11,7 @@
11
11
  * - 30% minimum confidence gap between approve and reject
12
12
  * - If thresholds not met → NEEDS_HUMAN_REVIEW
13
13
  */
14
+ import { type GenerateTextFn } from '../providers/generate-fn.js';
14
15
  import type { ConsensusStance, ConsensusVote, LLMProvider, ProgressCallback, ReviewLevel, ReviewResult, ReviewStatus } from '../types.js';
15
16
  export interface ConsensusModelConfig {
16
17
  provider: LLMProvider;
@@ -26,6 +27,21 @@ export interface ConsensusReviewInput {
26
27
  stackHints: string;
27
28
  reviewLevel: ReviewLevel;
28
29
  onProgress?: ProgressCallback;
30
+ /**
31
+ * Max concurrent votes (default: 1 — sequential for TPM safety).
32
+ * Set to 3 for full parallel (original behavior).
33
+ */
34
+ concurrency?: number;
35
+ /**
36
+ * Delay in ms between concurrency batches (default: 0).
37
+ */
38
+ delayMs?: number;
39
+ /**
40
+ * Backend-agnostic generation functions for votes (round-robin).
41
+ * When provided, each stance uses generateFns[index % generateFns.length].
42
+ * When omitted, functions are created from models config (backward compat).
43
+ */
44
+ generateFns?: GenerateTextFn[];
29
45
  }
30
46
  /**
31
47
  * Parse a single model's vote from its response text.
@@ -1 +1 @@
1
- {"version":3,"file":"consensus.d.ts","sourceRoot":"","sources":["../../src/agents/consensus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,YAAY,EACb,MAAM,aAAa,CAAC;AAYrB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,aAAa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AE,WAAW,CAAC;IACzB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAE9B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;CAChC;AAmBD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,eAAe,GACtB,aAAa,CAef;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG;IAC1D,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAuDA;AAID;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CAsI3F"}
@@ -11,9 +11,10 @@
11
11
  * - 30% minimum confidence gap between approve and reject
12
12
  * - If thresholds not met → NEEDS_HUMAN_REVIEW
13
13
  */
14
- import { generateText } from 'ai';
15
- import { createModel } from '../providers/index.js';
16
- import { buildMemoryContext, buildReviewLevelInstruction, CONSENSUS_AGAINST_SYSTEM, CONSENSUS_FOR_SYSTEM, CONSENSUS_NEUTRAL_SYSTEM, REVIEW_CALIBRATION, } from './prompts.js';
14
+ import { createAISDKGenerateFn } from '../providers/generate-fn.js';
15
+ import { runWithConcurrency } from '../utils/concurrency.js';
16
+ import { calculateRateSchedule } from '../utils/token-budget.js';
17
+ import { buildMemoryContext, buildReviewLevelInstruction, COMPACT_CALIBRATION, CONSENSUS_AGAINST_SYSTEM, CONSENSUS_FOR_SYSTEM, CONSENSUS_NEUTRAL_SYSTEM, REVIEW_CALIBRATION, } from './prompts.js';
17
18
  // ─── Constants ──────────────────────────────────────────────────
18
19
  /** Minimum percentage of weighted votes to decide approve/reject */
19
20
  const DECISION_THRESHOLD = 0.6;
@@ -127,40 +128,53 @@ export function calculateConsensus(votes) {
127
128
  export async function runConsensusReview(input) {
128
129
  const { diff, models, staticContext, memoryContext, stackHints, reviewLevel } = input;
129
130
  const emit = input.onProgress ?? (() => { });
131
+ // ── Resolve GenerateTextFn array ──────────────────────────
132
+ // When generateFns is provided, use them directly.
133
+ // Otherwise, build them from models config (backward compat).
134
+ const resolvedGenerateFns = input.generateFns ??
135
+ models.map((config) => createAISDKGenerateFn(config.provider, config.model, config.apiKey));
136
+ // Auto-calculate scheduling from primary model's TPM.
137
+ // For CLI bridge/gateway (single generateFn), force concurrency=1.
138
+ const primaryModel = models[0]?.model ?? 'gpt-4o-mini';
139
+ const rateSchedule = calculateRateSchedule(primaryModel);
140
+ const concurrency = resolvedGenerateFns.length === 1
141
+ ? Math.min(input.concurrency ?? rateSchedule.concurrency, 1)
142
+ : (input.concurrency ?? rateSchedule.concurrency);
143
+ const delayMs = input.delayMs ?? rateSchedule.delayMs;
130
144
  const startTime = Date.now();
131
145
  // Build the user prompt (same for all models)
132
146
  const userPrompt = `Review the following code changes:\n\n\`\`\`diff\n${diff}\n\`\`\``;
133
147
  emit({
134
148
  step: 'consensus-start',
135
- message: `Launching ${models.length} model votes in parallel`,
149
+ message: `Launching ${models.length} model votes (concurrency: ${concurrency}, delay: ${Math.round(delayMs / 1000)}s)`,
136
150
  detail: models.map((m) => ` → ${m.provider}/${m.model} (stance: ${m.stance})`).join('\n'),
137
151
  });
138
- // ── Step 1: Run all model votes in parallel ────────────────
139
- const votePromises = models.map(async (config) => {
140
- const system = [
141
- STANCE_PROMPTS[config.stance],
142
- staticContext,
143
- buildMemoryContext(memoryContext),
144
- stackHints,
145
- buildReviewLevelInstruction(reviewLevel),
146
- REVIEW_CALIBRATION,
147
- ]
148
- .filter(Boolean)
149
- .join('\n');
150
- const languageModel = createModel(config.provider, config.model, config.apiKey);
151
- const result = await generateText({
152
- model: languageModel,
153
- system,
154
- prompt: userPrompt,
155
- temperature: 0.3,
156
- });
157
- const tokensUsed = (result.usage?.inputTokens ?? 0) + (result.usage?.outputTokens ?? 0);
158
- return {
159
- vote: parseVote(result.text, config.provider, config.model, config.stance),
160
- tokensUsed,
152
+ // ── Step 1: Run model votes with bounded concurrency ───────
153
+ //
154
+ // First vote gets full context; subsequent votes get compact calibration.
155
+ const voteTasks = models.map((config, index) => {
156
+ return async () => {
157
+ // Round-robin assignment of generateFn
158
+ const generateFn = resolvedGenerateFns[index % resolvedGenerateFns.length];
159
+ const isFirst = index === 0;
160
+ const system = [
161
+ STANCE_PROMPTS[config.stance],
162
+ isFirst ? staticContext : '',
163
+ isFirst ? buildMemoryContext(memoryContext) : '',
164
+ isFirst ? stackHints : '',
165
+ buildReviewLevelInstruction(reviewLevel),
166
+ isFirst ? REVIEW_CALIBRATION : COMPACT_CALIBRATION,
167
+ ]
168
+ .filter(Boolean)
169
+ .join('\n');
170
+ const result = await generateFn(system, userPrompt);
171
+ return {
172
+ vote: parseVote(result.text, result.provider, result.model, config.stance),
173
+ tokensUsed: result.tokensUsed,
174
+ };
161
175
  };
162
176
  });
163
- const results = await Promise.allSettled(votePromises);
177
+ const results = await runWithConcurrency(voteTasks, { concurrency, delayMs });
164
178
  // ── Step 2: Collect votes and token usage ──────────────────
165
179
  const votes = [];
166
180
  let totalTokens = 0;
@@ -175,7 +189,7 @@ export async function runConsensusReview(input) {
175
189
  const v = result.value.vote;
176
190
  emit({
177
191
  step: `vote-${config.stance}`,
178
- message: `✓ ${config.stance} (${config.provider}/${config.model}) → ${v.decision} (${(v.confidence * 100).toFixed(0)}% confidence)`,
192
+ message: `✓ ${config.stance} (${v.provider}/${v.model}) → ${v.decision} (${(v.confidence * 100).toFixed(0)}% confidence)`,
179
193
  detail: v.reasoning,
180
194
  });
181
195
  }
@@ -192,13 +206,22 @@ export async function runConsensusReview(input) {
192
206
  // ── Step 3: Calculate consensus ────────────────────────────
193
207
  const { status, summary } = calculateConsensus(votes);
194
208
  const executionTimeMs = Date.now() - startTime;
195
- // Build detailed reasoning from all votes
209
+ // Build formatted vote details with visual distinction per stance
210
+ const STANCE_EMOJI = {
211
+ for: '🟢',
212
+ against: '🔴',
213
+ neutral: '🟡',
214
+ };
196
215
  const voteDetails = votes
197
- .map((v) => `[${v.provider}/${v.model}] Stance: ${v.stance} | Decision: ${v.decision} | Confidence: ${v.confidence}\n${v.reasoning}`)
198
- .join('\n\n---\n\n');
216
+ .map((v) => {
217
+ const emoji = STANCE_EMOJI[v.stance] ?? '';
218
+ const decisionLabel = v.decision.charAt(0).toUpperCase() + v.decision.slice(1);
219
+ return `### ${emoji} ${v.stance.charAt(0).toUpperCase() + v.stance.slice(1)} — ${decisionLabel} (confidence: ${v.confidence})\n${v.reasoning}`;
220
+ })
221
+ .join('\n\n');
199
222
  return {
200
223
  status,
201
- summary: `${summary}\n\n## Individual Votes\n\n${voteDetails}`,
224
+ summary: `${summary}\n### Individual Votes\n\n${voteDetails}`,
202
225
  findings: [], // Consensus mode produces votes, not individual findings
203
226
  staticAnalysis: {
204
227
  semgrep: { status: 'skipped', findings: [], executionTimeMs: 0 },
@@ -214,6 +237,7 @@ export async function runConsensusReview(input) {
214
237
  executionTimeMs,
215
238
  toolsRun: [],
216
239
  toolsSkipped: [],
240
+ modelsUsed: models.map((m) => `${m.stance}:${m.provider}/${m.model}`),
217
241
  },
218
242
  };
219
243
  }
@@ -1 +1 @@
1
- {"version":3,"file":"consensus.js","sourceRoot":"","sources":["../../src/agents/consensus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAUpD,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAqBtB,mEAAmE;AAEnE,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mode generates testable
5
+ * hypotheses about potential bugs and suggests how to verify each one.
6
+ * Best for debugging-oriented reviews where you want actionable
7
+ * investigation steps, not just "this is wrong".
8
+ *
9
+ * Output includes:
10
+ * - 1-5 ranked hypotheses (H1, H2, etc.)
11
+ * - Each with conditions, verification steps, and confidence
12
+ * - Standard FINDINGS block for compatibility with parseReviewResponse()
13
+ */
14
+ import type { Hypothesis, LLMProvider, ProgressCallback, ReviewLevel, ReviewResult } from '../types.js';
15
+ export interface DiagnosticReviewInput {
16
+ diff: string;
17
+ provider: LLMProvider;
18
+ model: string;
19
+ apiKey: string;
20
+ staticContext: string;
21
+ memoryContext: string | null;
22
+ stackHints: string;
23
+ reviewLevel: ReviewLevel;
24
+ onProgress?: ProgressCallback;
25
+ }
26
+ /**
27
+ * Parse hypothesis blocks from the LLM response text.
28
+ *
29
+ * Each hypothesis follows this format:
30
+ * HYPOTHESIS H1: [title]
31
+ * CONDITIONS: [when/why]
32
+ * VERIFICATION: [how to test]
33
+ * CONFIDENCE: high|medium|low
34
+ * FILES: file1.ts, file2.ts
35
+ *
36
+ * The parser is fault-tolerant:
37
+ * - Missing fields get sensible defaults
38
+ * - Malformed confidence values default to 'medium'
39
+ * - Partial hypotheses are still extracted if they have at least a title
40
+ */
41
+ export declare function parseHypotheses(text: string): Hypothesis[];
42
+ /**
43
+ * Run a diagnostic (hypothesis-driven) code review.
44
+ *
45
+ * Combines the diagnostic system prompt with all context layers
46
+ * and the diff into a single LLM call. The response is parsed
47
+ * for both standard findings AND structured hypotheses.
48
+ *
49
+ * Uses simple mode's token profile (single LLM call, same budget).
50
+ *
51
+ * @param input - Review input with diff, provider config, and context
52
+ * @returns Parsed ReviewResult with hypotheses attached
53
+ */
54
+ export declare function runDiagnosticReview(input: DiagnosticReviewInput): Promise<ReviewResult>;
55
+ //# sourceMappingURL=diagnostic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../../src/agents/diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,UAAU,EAEV,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,YAAY,EACb,MAAM,aAAa,CAAC;AAYrB,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAOD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAqD1D;AAID;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqF7F"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Diagnostic review agent (hypothesis-driven).
3
+ *
4
+ * Instead of just flagging issues, this mode generates testable
5
+ * hypotheses about potential bugs and suggests how to verify each one.
6
+ * Best for debugging-oriented reviews where you want actionable
7
+ * investigation steps, not just "this is wrong".
8
+ *
9
+ * Output includes:
10
+ * - 1-5 ranked hypotheses (H1, H2, etc.)
11
+ * - Each with conditions, verification steps, and confidence
12
+ * - Standard FINDINGS block for compatibility with parseReviewResponse()
13
+ */
14
+ import { createModel } from '../providers/index.js';
15
+ import { generateTextWithTimeout } from '../utils/llm-timeout.js';
16
+ import { buildMemoryContext, buildReviewLevelInstruction, DIAGNOSTIC_SYSTEM, REVIEW_CALIBRATION, } from './prompts.js';
17
+ import { parseReviewResponse } from './simple.js';
18
+ // ─── Hypothesis Parsing ─────────────────────────────────────────
19
+ /** Valid confidence values for type-safe parsing */
20
+ const VALID_CONFIDENCES = new Set(['high', 'medium', 'low']);
21
+ /**
22
+ * Parse hypothesis blocks from the LLM response text.
23
+ *
24
+ * Each hypothesis follows this format:
25
+ * HYPOTHESIS H1: [title]
26
+ * CONDITIONS: [when/why]
27
+ * VERIFICATION: [how to test]
28
+ * CONFIDENCE: high|medium|low
29
+ * FILES: file1.ts, file2.ts
30
+ *
31
+ * The parser is fault-tolerant:
32
+ * - Missing fields get sensible defaults
33
+ * - Malformed confidence values default to 'medium'
34
+ * - Partial hypotheses are still extracted if they have at least a title
35
+ */
36
+ export function parseHypotheses(text) {
37
+ const hypotheses = [];
38
+ // Match each HYPOTHESIS block — greedy capture up to next HYPOTHESIS or FINDINGS or end
39
+ const hypothesisPattern = /HYPOTHESIS\s+(H\d+):\s*(.+?)(?=\nHYPOTHESIS\s+H\d+:|\nFINDINGS:|\n*$)/gis;
40
+ let match = hypothesisPattern.exec(text);
41
+ while (match !== null) {
42
+ const id = match[1]?.trim() ?? 'H?';
43
+ const block = match[2]?.trim() ?? '';
44
+ // Extract title (first line of the block, before CONDITIONS:)
45
+ const titleMatch = /^(.+?)(?:\n|$)/i.exec(block);
46
+ const title = titleMatch?.[1]?.trim() ?? 'Unknown hypothesis';
47
+ // Extract CONDITIONS
48
+ const conditionsMatch = /CONDITIONS:\s*(.+?)(?=\nVERIFICATION:|\nCONFIDENCE:|\nFILES:|\n*$)/is.exec(block);
49
+ const conditions = conditionsMatch?.[1]?.trim() ?? 'Conditions not specified';
50
+ // Extract VERIFICATION
51
+ const verificationMatch = /VERIFICATION:\s*(.+?)(?=\nCONFIDENCE:|\nFILES:|\n*$)/is.exec(block);
52
+ const verification = verificationMatch?.[1]?.trim() ?? 'Verification steps not specified';
53
+ // Extract CONFIDENCE
54
+ const confidenceMatch = /CONFIDENCE:\s*(\S+)/i.exec(block);
55
+ const rawConfidence = confidenceMatch?.[1]?.toLowerCase();
56
+ const confidence = rawConfidence && VALID_CONFIDENCES.has(rawConfidence) ? rawConfidence : 'medium';
57
+ // Extract FILES
58
+ const filesMatch = /FILES:\s*(.+?)(?:\n|$)/i.exec(block);
59
+ const relatedFiles = filesMatch?.[1]
60
+ ? filesMatch[1]
61
+ .split(',')
62
+ .map((f) => f.trim())
63
+ .filter(Boolean)
64
+ : [];
65
+ hypotheses.push({
66
+ id,
67
+ title,
68
+ conditions,
69
+ verification,
70
+ confidence,
71
+ relatedFiles,
72
+ });
73
+ match = hypothesisPattern.exec(text);
74
+ }
75
+ return hypotheses;
76
+ }
77
+ // ─── Main Function ──────────────────────────────────────────────
78
+ /**
79
+ * Run a diagnostic (hypothesis-driven) code review.
80
+ *
81
+ * Combines the diagnostic system prompt with all context layers
82
+ * and the diff into a single LLM call. The response is parsed
83
+ * for both standard findings AND structured hypotheses.
84
+ *
85
+ * Uses simple mode's token profile (single LLM call, same budget).
86
+ *
87
+ * @param input - Review input with diff, provider config, and context
88
+ * @returns Parsed ReviewResult with hypotheses attached
89
+ */
90
+ export async function runDiagnosticReview(input) {
91
+ const { diff, provider, model, apiKey, staticContext, memoryContext, stackHints, reviewLevel } = input;
92
+ const emit = input.onProgress ?? (() => { });
93
+ const startTime = Date.now();
94
+ // Build the full system prompt with all context layers
95
+ const system = [
96
+ DIAGNOSTIC_SYSTEM,
97
+ staticContext,
98
+ buildMemoryContext(memoryContext),
99
+ stackHints,
100
+ buildReviewLevelInstruction(reviewLevel),
101
+ REVIEW_CALIBRATION,
102
+ ]
103
+ .filter(Boolean)
104
+ .join('\n');
105
+ // Build the user prompt with the diff
106
+ const prompt = `Please perform a diagnostic analysis of the following code changes. Generate testable hypotheses for any potential issues:\n\n\`\`\`diff\n${diff}\n\`\`\``;
107
+ const languageModel = createModel(provider, model, apiKey);
108
+ emit({
109
+ step: 'diagnostic-call',
110
+ message: `Calling ${provider}/${model} for diagnostic hypothesis analysis...`,
111
+ });
112
+ const result = await generateTextWithTimeout({
113
+ model: languageModel,
114
+ system,
115
+ prompt,
116
+ temperature: 0.3,
117
+ }, { provider, model });
118
+ const executionTimeMs = Date.now() - startTime;
119
+ // Timeout: fall back to empty AI result (static analysis still applies)
120
+ if (result === null) {
121
+ emit({
122
+ step: 'diagnostic-done',
123
+ message: `LLM timed out — falling back to static-analysis-only results`,
124
+ });
125
+ const reviewResult = parseReviewResponse('STATUS: NEEDS_HUMAN_REVIEW\nSUMMARY: LLM call timed out. Only static analysis results are available.\nFINDINGS:\n', provider, model, 0, executionTimeMs, memoryContext);
126
+ reviewResult.metadata.mode = 'diagnostic';
127
+ reviewResult.hypotheses = [];
128
+ return reviewResult;
129
+ }
130
+ const tokensUsed = (result.usage?.inputTokens ?? 0) + (result.usage?.outputTokens ?? 0);
131
+ emit({
132
+ step: 'diagnostic-done',
133
+ message: `Diagnostic analysis complete — ${tokensUsed} tokens, ${(executionTimeMs / 1000).toFixed(1)}s`,
134
+ });
135
+ // Parse the standard review response (STATUS, SUMMARY, FINDINGS)
136
+ const reviewResult = parseReviewResponse(result.text, provider, model, tokensUsed, executionTimeMs, memoryContext);
137
+ // Override mode in metadata
138
+ reviewResult.metadata.mode = 'diagnostic';
139
+ // Parse hypotheses from the response and attach to result
140
+ reviewResult.hypotheses = parseHypotheses(result.text);
141
+ return reviewResult;
142
+ }
143
+ //# sourceMappingURL=diagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../../src/agents/diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AASpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAgBlD,mEAAmE;AAEnE,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAuB,CAAC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iE;IACjE,MAAM,YAAY,GAAG,mBAAmB,CACtC,MAAM,CAAC,IAAI,EACX,QAAQ,EACR,KAAK,EACL,UAAU,EACV,eAAe,EACf,aAAa,CACd,CAAC;IAEF,4BAA4B;IAC5B,YAAY,CAAC,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC;IAE1C,0DAA0D;IAC1D,YAAY,CAAC,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEvD,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -3,16 +3,18 @@
3
3
  * Rescued and refined from GHAGGA v1.
4
4
  */
5
5
  import type { ReviewLevel } from '../types.js';
6
- export declare const SIMPLE_REVIEW_SYSTEM = "You are an expert code reviewer. Analyze the provided code changes and provide a thorough review.\n\n1. Check for bugs, logic errors, and potential runtime issues\n2. Verify proper error handling and edge cases\n3. Assess code quality, readability, and maintainability\n4. Identify security vulnerabilities (SQL injection, XSS, auth issues, etc.)\n5. Evaluate performance implications\n\nFormat your response EXACTLY as:\n\nSTATUS: [PASSED or FAILED]\nSUMMARY: [2-3 sentence summary of the review]\nFINDINGS:\n- SEVERITY: [critical|high|medium|low|info]\n CATEGORY: [security|performance|bug|style|error-handling|maintainability]\n FILE: [file path]\n LINE: [line number or \"N/A\"]\n MESSAGE: [clear description of the issue]\n SUGGESTION: [specific fix or improvement]\n\nIf there are no issues, return STATUS: PASSED with an empty FINDINGS section.\nFAILED if: Any critical issues, or 3+ high issues. PASSED otherwise.";
6
+ export declare const SIMPLE_REVIEW_SYSTEM = "You are an expert code reviewer performing a multi-perspective analysis in a single pass. Analyze the provided code changes from ALL 5 specialist perspectives below.\n\n## 1. Security Audit\n- SQL injection, XSS, CSRF vulnerabilities\n- Authentication/authorization flaws\n- Sensitive data exposure (API keys, tokens, PII in logs)\n- Insecure dependencies or patterns\n\n## 2. Bugs & Error Handling\n- Null/undefined safety \u2014 unchecked access, missing optional chaining\n- Logic errors, off-by-one bugs, incorrect conditions\n- Missing edge cases and boundary conditions\n- Try/catch correctness, error propagation, error message quality\n- Input validation gaps\n\n## 3. Performance\n- Algorithm complexity (O(n\u00B2) loops, unnecessary iterations)\n- N+1 query patterns, missing indexes, excessive DB calls\n- Memory leaks (unclosed resources, growing collections, missing cleanup)\n- Unnecessary computations or re-renders\n\n## 4. Code Quality & Maintainability\n- Naming conventions (variables, functions, types)\n- DRY violations (duplicated logic that should be extracted)\n- Code readability, proper documentation for complex logic\n- Import organization and module structure\n\n## 5. Scope & Impact\n- Which modules/components are affected by the changes\n- Potential side effects on untouched code paths\n- Breaking changes to public APIs or contracts\n\nFormat your response EXACTLY as:\n\nSTATUS: [PASSED or FAILED]\nSUMMARY: [2-3 sentence summary of the review]\nFINDINGS:\n- SEVERITY: [critical|high|medium|low|info]\n CATEGORY: [security|performance|bug|style|error-handling|maintainability]\n FILE: [file path]\n LINE: [line number or \"N/A\"]\n MESSAGE: [clear description of the issue]\n SUGGESTION: [specific fix or improvement]\n\nIf there are no issues, return STATUS: PASSED with an empty FINDINGS section.\nScale your review depth to the diff size: small changes need brief reviews, large changes need thorough analysis.\nOnly report ACTIONABLE findings \u2014 skip nitpicks and formatting preferences.\nFAILED if: Any critical issues, or 3+ high issues. PASSED otherwise.";
7
7
  export declare const WORKFLOW_SCOPE_SYSTEM = "You analyze code scope. Identify what files are changed, affected modules, and dependencies.\n\nYour task:\n1. List all modified files and their purposes\n2. Identify which modules/components are affected\n3. Map out dependencies that might be impacted\n4. Assess the overall scope (small, medium, large)\n\nOutput format:\n- Changed Files: [list files with brief descriptions]\n- Affected Modules: [list modules]\n- Dependencies: [list impacted dependencies]\n- Scope Assessment: [small/medium/large with reasoning]";
8
8
  export declare const WORKFLOW_STANDARDS_SYSTEM = "You enforce coding standards. Check naming conventions, formatting, and DRY violations.\n\nYour task:\n1. Check naming conventions (variables, functions, classes)\n2. Verify code formatting and consistency\n3. Identify DRY (Don't Repeat Yourself) violations\n4. Check for proper documentation/comments\n5. Verify import organization\n\nOutput format:\n- Naming Issues: [list any naming convention violations]\n- Formatting Issues: [list formatting problems]\n- DRY Violations: [list duplicated code/logic]\n- Documentation: [note missing or poor documentation]\n- Recommendations: [specific suggestions for improvement]";
9
9
  export declare const WORKFLOW_ERRORS_SYSTEM = "You are a defensive programming expert. Check null handling, edge cases, and error messages.\n\nYour task:\n1. Check for proper null/undefined handling\n2. Identify missing edge case handling\n3. Review error messages for clarity and usefulness\n4. Check try/catch usage and error propagation\n5. Verify input validation\n\nOutput format:\n- Null Safety Issues: [list potential null/undefined problems]\n- Edge Cases: [list unhandled edge cases]\n- Error Messages: [review of error message quality]\n- Exception Handling: [issues with try/catch or error propagation]\n- Input Validation: [missing or weak validation]";
10
10
  export declare const WORKFLOW_SECURITY_SYSTEM = "You are a security auditor. Check SQL injection, XSS, auth flaws, and data exposure.\n\nYour task:\n1. Check for SQL injection vulnerabilities\n2. Identify XSS (Cross-Site Scripting) risks\n3. Review authentication/authorization logic\n4. Check for sensitive data exposure\n5. Identify insecure dependencies or patterns\n\nOutput format:\n- SQL Injection: [any vulnerabilities found]\n- XSS Risks: [cross-site scripting issues]\n- Auth Issues: [authentication/authorization problems]\n- Data Exposure: [sensitive data handling issues]\n- Security Recommendations: [specific security improvements]\n\nSEVERITY LEVELS: CRITICAL, HIGH, MEDIUM, LOW";
11
11
  export declare const WORKFLOW_PERFORMANCE_SYSTEM = "You are a performance engineer. Check algorithm complexity, N+1 queries, memory leaks.\n\nYour task:\n1. Analyze algorithm complexity (time and space)\n2. Identify N+1 query problems\n3. Check for potential memory leaks\n4. Review resource usage patterns\n5. Identify unnecessary computations\n\nOutput format:\n- Complexity Issues: [O(n) analysis and concerns]\n- Database Issues: [N+1 queries, missing indexes]\n- Memory Concerns: [potential leaks or excessive usage]\n- Resource Usage: [inefficient patterns]\n- Performance Recommendations: [specific optimizations]";
12
12
  export declare const WORKFLOW_SYNTHESIS_SYSTEM = "Synthesize all findings into a final unified review. You received findings from 5 specialist reviewers: Scope Analysis, Coding Standards, Error Handling, Security Audit, and Performance Review.\n\nYour task:\n1. Combine all findings into a unified report\n2. Remove duplicate issues mentioned by multiple reviewers\n3. Prioritize by severity: CRITICAL > HIGH > MEDIUM > LOW\n4. Determine final status\n\nFormat your response EXACTLY as:\n\nSTATUS: [PASSED or FAILED]\nSUMMARY: [2-3 sentence overview]\nFINDINGS:\n- SEVERITY: [critical|high|medium|low|info]\n CATEGORY: [security|performance|bug|style|error-handling|maintainability]\n FILE: [file path]\n LINE: [line number or \"N/A\"]\n MESSAGE: [clear description]\n SUGGESTION: [specific fix]\n\nFAILED if: Any critical issues, or more than 3 high issues.\nPASSED if: No critical issues and 3 or fewer high issues.";
13
- export declare const CONSENSUS_FOR_SYSTEM = "You are reviewing code changes. Argue strongly IN FAVOR of approving this code.\n\nFocus on:\n- Benefits and improvements the code brings\n- Problems it solves correctly\n- Sound architectural decisions\n- Good practices followed\n\nProvide your assessment as:\nDECISION: [approve|reject|abstain]\nCONFIDENCE: [0.0 to 1.0]\nREASONING: [detailed reasoning for your stance]";
14
- export declare const CONSENSUS_AGAINST_SYSTEM = "You are reviewing code changes. Argue AGAINST approving this code.\n\nFocus on:\n- Potential bugs and logic errors\n- Security vulnerabilities\n- Performance concerns\n- Maintainability issues\n- Missing tests or edge cases\n\nProvide your assessment as:\nDECISION: [approve|reject|abstain]\nCONFIDENCE: [0.0 to 1.0]\nREASONING: [detailed reasoning for your stance]";
15
- export declare const CONSENSUS_NEUTRAL_SYSTEM = "You are reviewing code changes. Provide a BALANCED, neutral analysis.\n\nConsider both:\n- Benefits and improvements the code brings\n- Potential issues and risks\n\nProvide your assessment as:\nDECISION: [approve|reject|abstain]\nCONFIDENCE: [0.0 to 1.0]\nREASONING: [balanced analysis of pros and cons]";
13
+ export declare const CONSENSUS_FOR_SYSTEM = "You are reviewing code changes. Argue IN FAVOR of approving this code.\n\nFocus on: benefits, problems solved correctly, good practices followed.\n\nIMPORTANT: Scale your response to the diff size.\n- Small diffs (< 50 lines): 2-3 sentences max\n- Medium diffs (50-200 lines): 1 short paragraph\n- Large diffs (200+ lines): 2-3 short paragraphs max\n\nProvide your assessment as:\nDECISION: [approve|reject|abstain]\nCONFIDENCE: [0.0 to 1.0]\nREASONING: [concise reasoning \u2014 be brief and direct]";
14
+ export declare const CONSENSUS_AGAINST_SYSTEM = "You are reviewing code changes. Argue AGAINST approving this code.\n\nFocus on: potential bugs, security vulnerabilities, performance concerns, missing tests.\n\nIMPORTANT: Scale your response to the diff size.\n- Small diffs (< 50 lines): 2-3 sentences max\n- Medium diffs (50-200 lines): 1 short paragraph\n- Large diffs (200+ lines): 2-3 short paragraphs max\n\nOnly flag real, concrete issues \u2014 do not speculate about hypothetical problems.\n\nProvide your assessment as:\nDECISION: [approve|reject|abstain]\nCONFIDENCE: [0.0 to 1.0]\nREASONING: [concise reasoning \u2014 be brief and direct]";
15
+ export declare const CONSENSUS_NEUTRAL_SYSTEM = "You are reviewing code changes. Provide a BALANCED, neutral analysis.\n\nConsider both benefits and risks. Weigh trade-offs pragmatically.\n\nIMPORTANT: Scale your response to the diff size.\n- Small diffs (< 50 lines): 2-3 sentences max\n- Medium diffs (50-200 lines): 1 short paragraph\n- Large diffs (200+ lines): 2-3 short paragraphs max\n\nProvide your assessment as:\nDECISION: [approve|reject|abstain]\nCONFIDENCE: [0.0 to 1.0]\nREASONING: [concise reasoning \u2014 be brief and direct]";
16
+ export declare const DIAGNOSTIC_SYSTEM = "You are an expert software detective performing a hypothesis-driven diagnostic analysis of code changes. Instead of just reporting issues, you generate testable hypotheses about potential bugs and explain how to verify each one.\n\n## Your Approach\n1. Analyze the diff like a detective investigating potential bugs\n2. Generate 1-5 hypotheses ranked by severity and confidence\n3. For each hypothesis, explain the conditions that would trigger it and how to verify\n4. Only generate hypotheses you have real evidence for from the diff \u2014 do not speculate wildly\n\n## Hypothesis Format\nFor each potential issue, output a hypothesis block in this EXACT format:\n\nHYPOTHESIS H1: [short title describing what might be wrong]\nCONDITIONS: [when/why this would fail \u2014 be specific about inputs, states, or sequences]\nVERIFICATION: [concrete steps to test \u2014 a specific test case, reproduction steps, or command to run]\nCONFIDENCE: [high|medium|low]\nFILES: [comma-separated list of relevant file paths]\n\n## Confidence Levels\n- **high**: Clear evidence in the diff \u2014 the bug pattern is well-known and conditions are visible\n- **medium**: Likely issue based on the code pattern, but depends on runtime context not visible in the diff\n- **low**: Possible issue that requires further investigation \u2014 the pattern is suspicious but not conclusive\n\n## Response Format\nYour response MUST follow this exact structure:\n\nSTATUS: [PASSED or NEEDS_HUMAN_REVIEW]\nSUMMARY: [2-3 sentence summary of the diagnostic analysis]\n\n[hypothesis blocks \u2014 0 to 5 of them]\n\nFINDINGS:\n- SEVERITY: [critical|high|medium|low|info]\n CATEGORY: [security|performance|bug|style|error-handling|maintainability]\n FILE: [file path]\n LINE: [line number or \"N/A\"]\n MESSAGE: [H<n>: description linking to the hypothesis]\n SUGGESTION: [verification step from the hypothesis]\n\n## Rules\n- STATUS is PASSED only when you find zero hypotheses (the code looks clean)\n- STATUS is NEEDS_HUMAN_REVIEW when you have 1+ hypotheses\n- Each hypothesis MUST have a corresponding FINDING entry\n- In FINDINGS, prefix the MESSAGE with the hypothesis ID (e.g., \"H1: ...\")\n- Map hypothesis confidence to finding severity: high\u2192high, medium\u2192medium, low\u2192low\n- Scale analysis depth to diff size: small diffs get 1-2 hypotheses max, large diffs can have up to 5\n- Only report hypotheses you are 70%+ confident about based on the actual code shown";
17
+ export declare const COMPACT_CALIBRATION = "Focus only on your specialty area. Be concise. Report only actionable findings you are 80%+ confident about. Do not speculate.";
16
18
  export declare const REVIEW_CALIBRATION = "## Review Calibration\n- Only report findings you are 80%+ confident about based on the actual code shown.\n- Do NOT flag stylistic preferences unless they violate an explicitly provided rule.\n- Do NOT invent or assume coding standards that are not provided.\n- Do NOT flag hypothetical edge cases that are unlikely in practice.\n- If the diff is small and clean, it is OK to return STATUS: PASSED with zero findings.";
17
19
  /**
18
20
  * Build a review-level-specific calibration instruction.
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/agents/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,oBAAoB,m6BAqBoC,CAAC;AAItE,eAAO,MAAM,qBAAqB,ygBAYsB,CAAC;AAEzD,eAAO,MAAM,yBAAyB,gnBAcoB,CAAC;AAE3D,eAAO,MAAM,sBAAsB,6mBAcc,CAAC;AAElD,eAAO,MAAM,wBAAwB,yoBAgBQ,CAAC;AAE9C,eAAO,MAAM,2BAA2B,6jBAcgB,CAAC;AAEzD,eAAO,MAAM,yBAAyB,62BAqBoB,CAAC;AAI3D,eAAO,MAAM,oBAAoB,wXAWe,CAAC;AAEjD,eAAO,MAAM,wBAAwB,kXAYW,CAAC;AAEjD,eAAO,MAAM,wBAAwB,qTASW,CAAC;AAIjD,eAAO,MAAM,kBAAkB,uaAKyD,CAAC;AAEzF;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAStE;AAID,wBAAgB,0BAA0B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGvE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAkBxD"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/agents/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,oBAAoB,+jEA+CoC,CAAC;AAItE,eAAO,MAAM,qBAAqB,ygBAYsB,CAAC;AAEzD,eAAO,MAAM,yBAAyB,gnBAcoB,CAAC;AAE3D,eAAO,MAAM,sBAAsB,6mBAcc,CAAC;AAElD,eAAO,MAAM,wBAAw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