@simonren/quorum 0.9.0 → 0.11.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/README.md +91 -48
- package/commands/multi-consult.md +47 -72
- package/commands/multi-review.md +68 -99
- package/dist/adapters/base.d.ts +53 -70
- package/dist/adapters/base.js +21 -79
- package/dist/adapters/claude.d.ts +38 -17
- package/dist/adapters/claude.js +93 -185
- package/dist/adapters/cli-adapter.d.ts +78 -0
- package/dist/adapters/cli-adapter.js +217 -0
- package/dist/adapters/codex.d.ts +18 -13
- package/dist/adapters/codex.js +64 -200
- package/dist/adapters/gemini.d.ts +30 -20
- package/dist/adapters/gemini.js +56 -148
- package/dist/adapters/index.d.ts +8 -5
- package/dist/adapters/index.js +7 -8
- package/dist/config.d.ts +116 -28
- package/dist/config.js +50 -28
- package/dist/consult-prompt.d.ts +6 -5
- package/dist/consult-prompt.js +48 -23
- package/dist/decoders/claude.d.ts +6 -0
- package/dist/decoders/claude.js +10 -1
- package/dist/doctor.d.ts +20 -0
- package/dist/doctor.js +91 -0
- package/dist/executor.d.ts +58 -46
- package/dist/executor.js +218 -129
- package/dist/guards.d.ts +29 -0
- package/dist/guards.js +72 -0
- package/dist/handoff.d.ts +79 -229
- package/dist/handoff.js +411 -402
- package/dist/index.d.ts +8 -12
- package/dist/index.js +81 -106
- package/dist/integrity.d.ts +16 -0
- package/dist/integrity.js +49 -0
- package/dist/sections.d.ts +22 -0
- package/dist/sections.js +31 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.js +36 -0
- package/dist/tools/consult.d.ts +17 -76
- package/dist/tools/consult.js +72 -188
- package/dist/tools/format.d.ts +35 -0
- package/dist/tools/format.js +85 -0
- package/dist/tools/review.d.ts +55 -0
- package/dist/tools/review.js +120 -0
- package/dist/types.d.ts +20 -103
- package/dist/types.js +18 -29
- package/package.json +7 -4
- package/dist/cli/check.d.ts +0 -20
- package/dist/cli/check.js +0 -78
- package/dist/cli/codex.d.ts +0 -11
- package/dist/cli/codex.js +0 -255
- package/dist/cli/gemini.d.ts +0 -12
- package/dist/cli/gemini.js +0 -253
- package/dist/context.d.ts +0 -1538
- package/dist/context.js +0 -383
- package/dist/decoders/gemini.d.ts +0 -33
- package/dist/decoders/gemini.js +0 -58
- package/dist/errors.d.ts +0 -46
- package/dist/errors.js +0 -198
- package/dist/pipeline.d.ts +0 -135
- package/dist/pipeline.js +0 -462
- package/dist/prompt-v2.d.ts +0 -38
- package/dist/prompt-v2.js +0 -391
- package/dist/prompt.d.ts +0 -71
- package/dist/prompt.js +0 -309
- package/dist/schema.d.ts +0 -660
- package/dist/schema.js +0 -536
- package/dist/tools/feedback.d.ts +0 -91
- package/dist/tools/feedback.js +0 -117
package/dist/errors.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Handling for AI Reviewer MCP Server
|
|
3
|
-
*/
|
|
4
|
-
// CLI installation commands
|
|
5
|
-
// Codex: https://developers.openai.com/codex/cli/
|
|
6
|
-
// Gemini: now ships as `agy` (Antigravity CLI) — https://antigravity.google/download
|
|
7
|
-
const INSTALL_COMMANDS = {
|
|
8
|
-
codex: 'npm install -g @openai/codex-cli',
|
|
9
|
-
gemini: 'curl -fsSL https://antigravity.google/cli/install.sh | bash',
|
|
10
|
-
claude: 'https://docs.anthropic.com/en/docs/claude-code'
|
|
11
|
-
};
|
|
12
|
-
// Environment variables for API keys.
|
|
13
|
-
// agy uses Google OAuth and has no env var — null surfaces "no key needed".
|
|
14
|
-
const ENV_VARS = {
|
|
15
|
-
codex: 'OPENAI_API_KEY',
|
|
16
|
-
gemini: null,
|
|
17
|
-
claude: 'ANTHROPIC_API_KEY'
|
|
18
|
-
};
|
|
19
|
-
// Authentication commands
|
|
20
|
-
const AUTH_COMMANDS = {
|
|
21
|
-
codex: 'codex login',
|
|
22
|
-
gemini: 'agy (complete Google OAuth)',
|
|
23
|
-
claude: 'claude auth'
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Create a CLI not found error
|
|
27
|
-
*/
|
|
28
|
-
export function createCliNotFoundError(cli) {
|
|
29
|
-
return {
|
|
30
|
-
type: 'cli_not_found',
|
|
31
|
-
cli,
|
|
32
|
-
installCmd: INSTALL_COMMANDS[cli]
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Create a timeout error
|
|
37
|
-
*/
|
|
38
|
-
export function createTimeoutError(cli, durationMs) {
|
|
39
|
-
return {
|
|
40
|
-
type: 'timeout',
|
|
41
|
-
cli,
|
|
42
|
-
durationMs
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Create a rate limit error
|
|
47
|
-
*/
|
|
48
|
-
export function createRateLimitError(cli, retryAfterMs) {
|
|
49
|
-
return {
|
|
50
|
-
type: 'rate_limit',
|
|
51
|
-
cli,
|
|
52
|
-
retryAfterMs
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create an auth error
|
|
57
|
-
*/
|
|
58
|
-
export function createAuthError(cli, message) {
|
|
59
|
-
return {
|
|
60
|
-
type: 'auth_error',
|
|
61
|
-
cli,
|
|
62
|
-
message
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Create an invalid response error
|
|
67
|
-
*/
|
|
68
|
-
export function createInvalidResponseError(cli, rawOutput) {
|
|
69
|
-
return {
|
|
70
|
-
type: 'invalid_response',
|
|
71
|
-
cli,
|
|
72
|
-
rawOutput
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Create a CLI crash error
|
|
77
|
-
*/
|
|
78
|
-
export function createCliError(cli, exitCode, stderr) {
|
|
79
|
-
return {
|
|
80
|
-
type: 'cli_error',
|
|
81
|
-
cli,
|
|
82
|
-
exitCode,
|
|
83
|
-
stderr
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Format an error for user display
|
|
88
|
-
*/
|
|
89
|
-
export function formatErrorForUser(error) {
|
|
90
|
-
const others = ['codex', 'gemini', 'claude'].filter(c => c !== error.cli);
|
|
91
|
-
const otherCli = others[0];
|
|
92
|
-
switch (error.type) {
|
|
93
|
-
case 'cli_not_found':
|
|
94
|
-
return `❌ ${error.cli} CLI not found.
|
|
95
|
-
|
|
96
|
-
Install with: ${error.installCmd}
|
|
97
|
-
|
|
98
|
-
Alternative: Use /${otherCli}-review instead`;
|
|
99
|
-
case 'timeout':
|
|
100
|
-
return `⏱️ ${error.cli} timed out after ${Math.round(error.durationMs / 1000)}s.
|
|
101
|
-
|
|
102
|
-
This might happen with complex reviews. Try:
|
|
103
|
-
• Reviewing a smaller scope
|
|
104
|
-
• Using --focus to narrow the review`;
|
|
105
|
-
case 'rate_limit':
|
|
106
|
-
const retryMsg = error.retryAfterMs
|
|
107
|
-
? `Try again in ${Math.ceil(error.retryAfterMs / 1000)}s`
|
|
108
|
-
: 'Wait a moment and try again';
|
|
109
|
-
return `🚫 ${error.cli} rate limit hit.
|
|
110
|
-
|
|
111
|
-
${retryMsg}
|
|
112
|
-
|
|
113
|
-
Alternative: Use /${otherCli}-review instead`;
|
|
114
|
-
case 'auth_error': {
|
|
115
|
-
const envVar = ENV_VARS[error.cli];
|
|
116
|
-
const keyLine = envVar ? `\nCheck your API key: ${envVar}` : '';
|
|
117
|
-
return `🔐 ${error.cli} authentication failed.
|
|
118
|
-
|
|
119
|
-
${error.message}${keyLine}
|
|
120
|
-
Run: ${AUTH_COMMANDS[error.cli]}`;
|
|
121
|
-
}
|
|
122
|
-
case 'invalid_response':
|
|
123
|
-
return `⚠️ ${error.cli} returned an unusable response.
|
|
124
|
-
|
|
125
|
-
The output couldn't be parsed as valid feedback.
|
|
126
|
-
Raw output (truncated): ${error.rawOutput.slice(0, 200)}...`;
|
|
127
|
-
case 'cli_error':
|
|
128
|
-
return `❌ ${error.cli} crashed (exit code ${error.exitCode}).
|
|
129
|
-
|
|
130
|
-
${error.stderr}`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Detect error type from CLI output and error messages
|
|
135
|
-
*/
|
|
136
|
-
export function detectErrorType(cli, error, stdout, stderr, exitCode) {
|
|
137
|
-
// CLI not found
|
|
138
|
-
if (error.code === 'ENOENT') {
|
|
139
|
-
return createCliNotFoundError(cli);
|
|
140
|
-
}
|
|
141
|
-
// Rate limit
|
|
142
|
-
if (stderr.toLowerCase().includes('rate limit') ||
|
|
143
|
-
stdout.toLowerCase().includes('rate limit')) {
|
|
144
|
-
const retryAfterMatch = stderr.match(/retry after (\d+)/i);
|
|
145
|
-
const retryAfterMs = retryAfterMatch ? parseInt(retryAfterMatch[1]) * 1000 : undefined;
|
|
146
|
-
return createRateLimitError(cli, retryAfterMs);
|
|
147
|
-
}
|
|
148
|
-
// Auth error
|
|
149
|
-
if (stderr.toLowerCase().includes('unauthorized') ||
|
|
150
|
-
stderr.toLowerCase().includes('authentication') ||
|
|
151
|
-
stderr.toLowerCase().includes('401') ||
|
|
152
|
-
stderr.toLowerCase().includes('403')) {
|
|
153
|
-
return createAuthError(cli, stderr);
|
|
154
|
-
}
|
|
155
|
-
// Generic CLI error
|
|
156
|
-
if (exitCode !== null && exitCode !== 0) {
|
|
157
|
-
return createCliError(cli, exitCode, stderr);
|
|
158
|
-
}
|
|
159
|
-
// Invalid response (fallback)
|
|
160
|
-
return createInvalidResponseError(cli, stdout);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Parse retry-after from error response
|
|
164
|
-
*/
|
|
165
|
-
export function parseRetryAfter(errorMessage) {
|
|
166
|
-
const match = errorMessage.match(/retry[- ]?after[:\s]+(\d+)/i);
|
|
167
|
-
if (match) {
|
|
168
|
-
return parseInt(match[1]) * 1000; // Convert to ms
|
|
169
|
-
}
|
|
170
|
-
return undefined;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Generate suggestion based on error type
|
|
174
|
-
*/
|
|
175
|
-
export function getSuggestion(error) {
|
|
176
|
-
switch (error.type) {
|
|
177
|
-
case 'cli_not_found':
|
|
178
|
-
return `Install ${error.cli} CLI or use the other model`;
|
|
179
|
-
case 'timeout':
|
|
180
|
-
return 'Try reviewing a smaller scope or using --focus';
|
|
181
|
-
case 'rate_limit':
|
|
182
|
-
return error.retryAfterMs
|
|
183
|
-
? `Wait ${Math.ceil(error.retryAfterMs / 1000)}s and retry`
|
|
184
|
-
: 'Wait a moment and retry';
|
|
185
|
-
case 'auth_error': {
|
|
186
|
-
const envVar = ENV_VARS[error.cli];
|
|
187
|
-
return envVar
|
|
188
|
-
? `Check your ${envVar} environment variable`
|
|
189
|
-
: `Re-run \`${AUTH_COMMANDS[error.cli]}\` to refresh credentials`;
|
|
190
|
-
}
|
|
191
|
-
case 'invalid_response':
|
|
192
|
-
return 'Retry with a more specific focus area';
|
|
193
|
-
case 'cli_error':
|
|
194
|
-
return 'Check the CLI documentation for troubleshooting';
|
|
195
|
-
default:
|
|
196
|
-
return undefined;
|
|
197
|
-
}
|
|
198
|
-
}
|
package/dist/pipeline.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Review Response Processing Pipeline
|
|
3
|
-
*
|
|
4
|
-
* Processes reviewer output through multiple stages:
|
|
5
|
-
* 1. Parse - Extract structured data
|
|
6
|
-
* 2. Verify - Check file/line references exist
|
|
7
|
-
* 3. Cross-check - Compare with CC's knowledge
|
|
8
|
-
* 4. Prioritize - Rank by impact and confidence
|
|
9
|
-
* 5. Plan - Generate actionable next steps
|
|
10
|
-
*/
|
|
11
|
-
import { ReviewOutput, ReviewFinding } from './schema.js';
|
|
12
|
-
import { ReviewContext, VerificationData } from './context.js';
|
|
13
|
-
export interface PipelineStage<TInput, TOutput> {
|
|
14
|
-
name: string;
|
|
15
|
-
process(input: TInput, context: PipelineContext): Promise<TOutput>;
|
|
16
|
-
}
|
|
17
|
-
export interface PipelineContext {
|
|
18
|
-
workingDir: string;
|
|
19
|
-
reviewContext: ReviewContext;
|
|
20
|
-
verificationData?: VerificationData;
|
|
21
|
-
}
|
|
22
|
-
export interface VerifiedFinding extends ReviewFinding {
|
|
23
|
-
verification: {
|
|
24
|
-
fileExists: boolean;
|
|
25
|
-
lineValid: boolean;
|
|
26
|
-
codeSnippetMatches?: boolean;
|
|
27
|
-
verificationNotes?: string;
|
|
28
|
-
};
|
|
29
|
-
crossCheck: {
|
|
30
|
-
alreadyAddressedByCC: boolean;
|
|
31
|
-
conflictsWithCC: boolean;
|
|
32
|
-
ccMentioned: boolean;
|
|
33
|
-
};
|
|
34
|
-
adjustedConfidence: number;
|
|
35
|
-
}
|
|
36
|
-
export interface ActionItem {
|
|
37
|
-
finding: VerifiedFinding;
|
|
38
|
-
action: 'fix_now' | 'investigate' | 'defer' | 'reject';
|
|
39
|
-
priority: number;
|
|
40
|
-
suggestedFix?: string;
|
|
41
|
-
reason: string;
|
|
42
|
-
}
|
|
43
|
-
export interface ProcessedReview {
|
|
44
|
-
original: ReviewOutput;
|
|
45
|
-
verified: VerifiedFinding[];
|
|
46
|
-
rejected: {
|
|
47
|
-
finding: ReviewFinding;
|
|
48
|
-
reason: string;
|
|
49
|
-
}[];
|
|
50
|
-
actionPlan: ActionItem[];
|
|
51
|
-
summary: {
|
|
52
|
-
totalFindings: number;
|
|
53
|
-
verifiedCount: number;
|
|
54
|
-
rejectedCount: number;
|
|
55
|
-
actionableCount: number;
|
|
56
|
-
topPriority: ActionItem[];
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Simple file cache to avoid re-reading files for each finding
|
|
61
|
-
*/
|
|
62
|
-
export declare class FileCache {
|
|
63
|
-
private workingDir;
|
|
64
|
-
private contentCache;
|
|
65
|
-
private lineCountCache;
|
|
66
|
-
private linesCache;
|
|
67
|
-
constructor(workingDir: string);
|
|
68
|
-
/**
|
|
69
|
-
* Check if file exists (cached)
|
|
70
|
-
*/
|
|
71
|
-
exists(relativePath: string): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Get file content (cached, lazy-loaded)
|
|
74
|
-
*/
|
|
75
|
-
getContent(relativePath: string): string | null;
|
|
76
|
-
/**
|
|
77
|
-
* Get lines array (cached)
|
|
78
|
-
*/
|
|
79
|
-
getLines(relativePath: string): string[] | null;
|
|
80
|
-
/**
|
|
81
|
-
* Get line count (cached)
|
|
82
|
-
*/
|
|
83
|
-
getLineCount(relativePath: string): number | null;
|
|
84
|
-
/**
|
|
85
|
-
* Get stats about cache usage
|
|
86
|
-
*/
|
|
87
|
-
getStats(): {
|
|
88
|
-
filesChecked: number;
|
|
89
|
-
filesLoaded: number;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Build verification data by scanning the filesystem
|
|
94
|
-
*/
|
|
95
|
-
export declare function buildVerificationData(workingDir: string): Promise<VerificationData>;
|
|
96
|
-
/**
|
|
97
|
-
* Verify a single finding's references
|
|
98
|
-
* @param finding The finding to verify
|
|
99
|
-
* @param workingDir Working directory for path resolution
|
|
100
|
-
* @param cache Optional file cache for performance (recommended for multiple findings)
|
|
101
|
-
*/
|
|
102
|
-
export declare function verifyFinding(finding: ReviewFinding, workingDir: string, cache?: FileCache): Promise<VerifiedFinding>;
|
|
103
|
-
/**
|
|
104
|
-
* Cross-check findings against CC's analysis
|
|
105
|
-
*/
|
|
106
|
-
export declare function crossCheckWithCC(finding: VerifiedFinding, ccAnalysis: ReviewContext['analysis']): VerifiedFinding;
|
|
107
|
-
/**
|
|
108
|
-
* Calculate priority score for a finding
|
|
109
|
-
*/
|
|
110
|
-
export declare function calculatePriority(finding: VerifiedFinding): number;
|
|
111
|
-
/**
|
|
112
|
-
* Determine action for a finding
|
|
113
|
-
*/
|
|
114
|
-
export declare function determineAction(finding: VerifiedFinding, priority: number): {
|
|
115
|
-
action: ActionItem['action'];
|
|
116
|
-
reason: string;
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Process a review output through the full verification pipeline
|
|
120
|
-
*/
|
|
121
|
-
export declare function processReviewOutput(output: ReviewOutput, context: ReviewContext): Promise<ProcessedReview>;
|
|
122
|
-
/**
|
|
123
|
-
* Format processed review for display
|
|
124
|
-
*/
|
|
125
|
-
export declare function formatProcessedReview(processed: ProcessedReview): string;
|
|
126
|
-
export interface FollowUpQuestion {
|
|
127
|
-
topic: string;
|
|
128
|
-
question: string;
|
|
129
|
-
relatedFindings: string[];
|
|
130
|
-
context: string;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Generate follow-up questions for uncertain findings
|
|
134
|
-
*/
|
|
135
|
-
export declare function generateFollowUpQuestions(processed: ProcessedReview): FollowUpQuestion[];
|