triage-ai 1.0.2
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 +21 -0
- package/README.md +209 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +633 -0
- package/dist/cli.js.map +1 -0
- package/dist/mcp-server.d.ts +24 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +411 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/memory.d.ts +40 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +241 -0
- package/dist/memory.js.map +1 -0
- package/dist/merge.d.ts +32 -0
- package/dist/merge.d.ts.map +1 -0
- package/dist/merge.js +251 -0
- package/dist/merge.js.map +1 -0
- package/dist/models/base.d.ts +72 -0
- package/dist/models/base.d.ts.map +1 -0
- package/dist/models/base.js +342 -0
- package/dist/models/base.js.map +1 -0
- package/dist/models/claude.d.ts +23 -0
- package/dist/models/claude.d.ts.map +1 -0
- package/dist/models/claude.js +30 -0
- package/dist/models/claude.js.map +1 -0
- package/dist/models/codex.d.ts +25 -0
- package/dist/models/codex.d.ts.map +1 -0
- package/dist/models/codex.js +34 -0
- package/dist/models/codex.js.map +1 -0
- package/dist/models/gemini.d.ts +23 -0
- package/dist/models/gemini.d.ts.map +1 -0
- package/dist/models/gemini.js +32 -0
- package/dist/models/gemini.js.map +1 -0
- package/dist/patch.d.ts +40 -0
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +183 -0
- package/dist/patch.js.map +1 -0
- package/dist/progress.d.ts +71 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +268 -0
- package/dist/progress.js.map +1 -0
- package/dist/report.d.ts +19 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +245 -0
- package/dist/report.js.map +1 -0
- package/dist/scanner.d.ts +64 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +645 -0
- package/dist/scanner.js.map +1 -0
- package/dist/setup.d.ts +52 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +252 -0
- package/dist/setup.js.map +1 -0
- package/dist/types.d.ts +153 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +203 -0
- package/dist/types.js.map +1 -0
- package/examples/claude-code-skill.md +22 -0
- package/examples/mcp-config.json +9 -0
- package/package.json +77 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base model interface and subprocess runner.
|
|
3
|
+
*
|
|
4
|
+
* Ported from triage_cli/models/base.py
|
|
5
|
+
*/
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { writeFile, unlink } from 'node:fs/promises';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import { randomBytes } from 'node:crypto';
|
|
11
|
+
import { MODEL_PROMPT_TEMPLATE, modelResultFromDict, } from '../types.js';
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Auth / rate-limit error detection
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/** Patterns in stderr that indicate a CLI auth/quota problem. */
|
|
16
|
+
const AUTH_ERROR_PATTERNS = [
|
|
17
|
+
/not logged in/i,
|
|
18
|
+
/login required/i,
|
|
19
|
+
/please log in/i,
|
|
20
|
+
/authentication (failed|required|error)/i,
|
|
21
|
+
/unauthorized/i,
|
|
22
|
+
/api[_\s-]?key/i,
|
|
23
|
+
/invalid[_\s-]?key/i,
|
|
24
|
+
/missing[_\s-]?key/i,
|
|
25
|
+
/no credentials/i,
|
|
26
|
+
/rate[_\s-]?limit/i,
|
|
27
|
+
/quota exceeded/i,
|
|
28
|
+
/too many requests/i,
|
|
29
|
+
/billing/i,
|
|
30
|
+
/subscription required/i,
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Check collected stderr text for known auth/quota errors.
|
|
34
|
+
* Returns a human-readable error message if found, null otherwise.
|
|
35
|
+
*/
|
|
36
|
+
function detectAuthError(modelName, stderr) {
|
|
37
|
+
for (const pattern of AUTH_ERROR_PATTERNS) {
|
|
38
|
+
if (pattern.test(stderr)) {
|
|
39
|
+
return (`${modelName} CLI authentication/quota error — ` +
|
|
40
|
+
`please run \`${modelName}\` interactively to log in or check your API key.\n` +
|
|
41
|
+
`Stderr: ${stderr.slice(0, 500)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Abstract base
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
export class BaseModel {
|
|
50
|
+
name;
|
|
51
|
+
cmdEnvVar;
|
|
52
|
+
defaultCmd;
|
|
53
|
+
constructor() {
|
|
54
|
+
this.name = 'base';
|
|
55
|
+
this.cmdEnvVar = 'TRIAGE_BASE_CMD';
|
|
56
|
+
this.defaultCmd = ['echo'];
|
|
57
|
+
}
|
|
58
|
+
/** Get the command to use for this model (env override > default). */
|
|
59
|
+
get command() {
|
|
60
|
+
const envCmd = process.env[this.cmdEnvVar] ?? '';
|
|
61
|
+
if (envCmd)
|
|
62
|
+
return envCmd.split(/\s+/);
|
|
63
|
+
return this.defaultCmd;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Run analysis using this model.
|
|
67
|
+
*
|
|
68
|
+
* Builds prompt, saves it for debugging, calls _runModel, parses the
|
|
69
|
+
* result, saves parsed JSON to resultsDir, returns ModelResult.
|
|
70
|
+
*/
|
|
71
|
+
async analyze(prompt, context, resultsDir, timeout = 300, nice = 10) {
|
|
72
|
+
const fullPrompt = this.buildPrompt(prompt, context);
|
|
73
|
+
// Save prompt for debugging
|
|
74
|
+
const promptFile = join(resultsDir, `${this.name}_prompt.txt`);
|
|
75
|
+
await writeFile(promptFile, fullPrompt, 'utf8');
|
|
76
|
+
try {
|
|
77
|
+
const output = await this._runModel(fullPrompt, timeout, nice);
|
|
78
|
+
// Save raw output
|
|
79
|
+
const outputFile = join(resultsDir, `${this.name}_output.txt`);
|
|
80
|
+
await writeFile(outputFile, output, 'utf8');
|
|
81
|
+
// Parse the result
|
|
82
|
+
const result = this.parseOutput(output);
|
|
83
|
+
result.raw_output = output;
|
|
84
|
+
// Save parsed result
|
|
85
|
+
const resultFile = join(resultsDir, `${this.name}_result.json`);
|
|
86
|
+
const { writeFile: wf } = await import('node:fs/promises');
|
|
87
|
+
await wf(resultFile, JSON.stringify(this._resultToDict(result), null, 2), 'utf8');
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
92
|
+
return {
|
|
93
|
+
model: this.name,
|
|
94
|
+
summary: `Error running ${this.name}: ${msg}`,
|
|
95
|
+
findings: [],
|
|
96
|
+
inspected: [],
|
|
97
|
+
questions: [],
|
|
98
|
+
error: msg,
|
|
99
|
+
raw_output: '',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Build the full prompt string from the template and scan context. */
|
|
104
|
+
buildPrompt(prompt, context) {
|
|
105
|
+
// Tree context (directory structure), truncated at 3000 chars
|
|
106
|
+
let treeContext = '';
|
|
107
|
+
if (context.tree) {
|
|
108
|
+
treeContext = `Directory Structure:\n\`\`\`\n${context.tree.slice(0, 3000)}\n\`\`\`\n`;
|
|
109
|
+
}
|
|
110
|
+
// Git context
|
|
111
|
+
let gitContext = '';
|
|
112
|
+
if (context.git_log) {
|
|
113
|
+
gitContext += `Recent Commits:\n\`\`\`\n${context.git_log}\n\`\`\`\n`;
|
|
114
|
+
}
|
|
115
|
+
if (context.has_diff) {
|
|
116
|
+
// Truncate git_diff at 10000 chars
|
|
117
|
+
gitContext += `Git Diff:\n\`\`\`\n${context.git_diff.slice(0, 10000)}\n\`\`\`\n`;
|
|
118
|
+
}
|
|
119
|
+
if (context.git_status) {
|
|
120
|
+
gitContext += `Git Status:\n\`\`\`\n${context.git_status}\n\`\`\`\n`;
|
|
121
|
+
}
|
|
122
|
+
// Files context — each file content truncated at 5000 chars
|
|
123
|
+
let filesContext = '';
|
|
124
|
+
let totalChars = 0;
|
|
125
|
+
for (const f of context.files) {
|
|
126
|
+
const descStr = f.description ? ` - ${f.description}` : '';
|
|
127
|
+
filesContext += `\n--- ${f.path} (${f.reason})${descStr} ---\n`;
|
|
128
|
+
let content = f.content;
|
|
129
|
+
if (content.length > 5000) {
|
|
130
|
+
content = content.slice(0, 5000) + '\n... [truncated]';
|
|
131
|
+
}
|
|
132
|
+
filesContext += `\`\`\`\n${content}\n\`\`\`\n`;
|
|
133
|
+
totalChars += content.length;
|
|
134
|
+
}
|
|
135
|
+
const fileCount = context.files.length;
|
|
136
|
+
// Replace template placeholders — MODEL_PROMPT_TEMPLATE uses {key} syntax
|
|
137
|
+
// and doubled braces {{/}} for literal braces in the JSON schema example.
|
|
138
|
+
return MODEL_PROMPT_TEMPLATE
|
|
139
|
+
.replace('{prompt}', prompt)
|
|
140
|
+
.replace('{root}', context.root)
|
|
141
|
+
.replace('{is_git_repo}', String(context.is_git_repo))
|
|
142
|
+
.replace('{tree_context}', treeContext)
|
|
143
|
+
.replace('{git_context}', gitContext)
|
|
144
|
+
.replace('{files_context}', filesContext)
|
|
145
|
+
.replace('{file_count}', String(fileCount))
|
|
146
|
+
.replace('{total_chars}', String(totalChars))
|
|
147
|
+
.replace('{model_name}', this.name)
|
|
148
|
+
// Unescape the doubled braces that were literal in the template
|
|
149
|
+
.replace(/\{\{/g, '{')
|
|
150
|
+
.replace(/\}\}/g, '}');
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Parse raw model output into a ModelResult.
|
|
154
|
+
*
|
|
155
|
+
* Tries in order:
|
|
156
|
+
* 1. JSON inside ```json ... ``` blocks
|
|
157
|
+
* 2. JSON inside ``` ... ``` blocks
|
|
158
|
+
* 3. Raw JSON parse of entire output
|
|
159
|
+
* 4. First `{...}` match in the string
|
|
160
|
+
*/
|
|
161
|
+
parseOutput(output) {
|
|
162
|
+
const patterns = [
|
|
163
|
+
/```json\s*([\s\S]*?)\s*```/g,
|
|
164
|
+
/```\s*([\s\S]*?)\s*```/g,
|
|
165
|
+
/(\{[\s\S]*\})/g,
|
|
166
|
+
];
|
|
167
|
+
for (const pattern of patterns) {
|
|
168
|
+
pattern.lastIndex = 0; // reset global regex
|
|
169
|
+
let match;
|
|
170
|
+
while ((match = pattern.exec(output)) !== null) {
|
|
171
|
+
try {
|
|
172
|
+
const data = JSON.parse(match[1]);
|
|
173
|
+
if ('findings' in data || 'summary' in data) {
|
|
174
|
+
return modelResultFromDict(data);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// Not valid JSON — try next match
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Last resort: try parsing the whole output as JSON
|
|
183
|
+
try {
|
|
184
|
+
const data = JSON.parse(output);
|
|
185
|
+
return modelResultFromDict(data);
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
189
|
+
return {
|
|
190
|
+
model: this.name,
|
|
191
|
+
summary: `Failed to parse output: ${msg}`,
|
|
192
|
+
findings: [],
|
|
193
|
+
inspected: [],
|
|
194
|
+
questions: [],
|
|
195
|
+
error: `Parse error: ${msg}\nRaw output:\n${output.slice(0, 1000)}`,
|
|
196
|
+
raw_output: output,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** Serialize a ModelResult to a plain object for JSON saving. */
|
|
201
|
+
_resultToDict(result) {
|
|
202
|
+
return {
|
|
203
|
+
model: result.model,
|
|
204
|
+
summary: result.summary,
|
|
205
|
+
findings: result.findings,
|
|
206
|
+
inspected: result.inspected,
|
|
207
|
+
questions: result.questions,
|
|
208
|
+
error: result.error ?? null,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// ---------------------------------------------------------------------------
|
|
213
|
+
// Subprocess base
|
|
214
|
+
// ---------------------------------------------------------------------------
|
|
215
|
+
export class SubprocessModel extends BaseModel {
|
|
216
|
+
/**
|
|
217
|
+
* Run model via subprocess.
|
|
218
|
+
*
|
|
219
|
+
* - Writes prompt to a temp file (for debugging / codex adapter)
|
|
220
|
+
* - Builds command via _buildCommand()
|
|
221
|
+
* - Applies env overrides (undefined value = delete key)
|
|
222
|
+
* - Spawns with detached:true so we can kill the whole process group
|
|
223
|
+
* - Passes prompt via stdin
|
|
224
|
+
* - Detects auth/quota errors in stderr
|
|
225
|
+
* - Kills process group on error or cancellation
|
|
226
|
+
* - Cleans up temp file in finally
|
|
227
|
+
*/
|
|
228
|
+
async _runModel(prompt, timeout, nice) {
|
|
229
|
+
// Write prompt to a temp file for debugging / codex
|
|
230
|
+
const tmpPath = join(tmpdir(), `triage-${randomBytes(8).toString('hex')}.txt`);
|
|
231
|
+
await writeFile(tmpPath, prompt, 'utf8');
|
|
232
|
+
let proc = null;
|
|
233
|
+
let stderrChunks = [];
|
|
234
|
+
try {
|
|
235
|
+
const { cmd, env: envOverrides } = this._buildCommand(tmpPath);
|
|
236
|
+
// Build clean environment: copy process.env then apply overrides
|
|
237
|
+
const runEnv = {};
|
|
238
|
+
for (const [k, v] of Object.entries(process.env)) {
|
|
239
|
+
if (v !== undefined)
|
|
240
|
+
runEnv[k] = v;
|
|
241
|
+
}
|
|
242
|
+
for (const [k, v] of Object.entries(envOverrides)) {
|
|
243
|
+
if (v === undefined) {
|
|
244
|
+
delete runEnv[k];
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
runEnv[k] = v;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Prepend: nice -n <nice> timeout <timeout>
|
|
251
|
+
const fullCmd = ['nice', '-n', String(nice), 'timeout', String(timeout), ...cmd];
|
|
252
|
+
const [exe, ...args] = fullCmd;
|
|
253
|
+
proc = spawn(exe, args, {
|
|
254
|
+
env: runEnv,
|
|
255
|
+
cwd: process.cwd(),
|
|
256
|
+
detached: true, // New process group — PGID == proc.pid
|
|
257
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
258
|
+
});
|
|
259
|
+
const stdoutChunks = [];
|
|
260
|
+
stderrChunks = [];
|
|
261
|
+
proc.stdout?.on('data', (chunk) => stdoutChunks.push(chunk));
|
|
262
|
+
proc.stderr?.on('data', (chunk) => stderrChunks.push(chunk));
|
|
263
|
+
// Send prompt via stdin then close
|
|
264
|
+
proc.stdin?.write(prompt, 'utf8');
|
|
265
|
+
proc.stdin?.end();
|
|
266
|
+
// Wait for exit
|
|
267
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
268
|
+
proc.on('close', (code) => resolve(code));
|
|
269
|
+
proc.on('error', (err) => reject(err));
|
|
270
|
+
});
|
|
271
|
+
const stdout = Buffer.concat(stdoutChunks).toString('utf8');
|
|
272
|
+
const stderr = Buffer.concat(stderrChunks).toString('utf8');
|
|
273
|
+
if (exitCode !== 0) {
|
|
274
|
+
// Check for auth errors first — gives a clearer message than a raw dump
|
|
275
|
+
const authErr = detectAuthError(this.name, stderr);
|
|
276
|
+
if (authErr) {
|
|
277
|
+
throw new Error(authErr);
|
|
278
|
+
}
|
|
279
|
+
const errMsg = stderr || `Exit code ${exitCode}`;
|
|
280
|
+
throw new Error(`Model failed: ${errMsg}`);
|
|
281
|
+
}
|
|
282
|
+
// Even on success, warn about auth hints buried in stderr
|
|
283
|
+
if (stderr) {
|
|
284
|
+
const authErr = detectAuthError(this.name, stderr);
|
|
285
|
+
if (authErr) {
|
|
286
|
+
throw new Error(authErr);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return stdout;
|
|
290
|
+
}
|
|
291
|
+
catch (err) {
|
|
292
|
+
// Kill the entire process group we spawned
|
|
293
|
+
this._killProcessGroup(proc, 'SIGTERM');
|
|
294
|
+
if (proc) {
|
|
295
|
+
// Wait up to 3 s for graceful exit, then SIGKILL
|
|
296
|
+
await new Promise((resolve) => {
|
|
297
|
+
const timer = setTimeout(() => {
|
|
298
|
+
this._killProcessGroup(proc, 'SIGKILL');
|
|
299
|
+
resolve();
|
|
300
|
+
}, 3000);
|
|
301
|
+
proc.on('close', () => {
|
|
302
|
+
clearTimeout(timer);
|
|
303
|
+
resolve();
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
throw err;
|
|
308
|
+
}
|
|
309
|
+
finally {
|
|
310
|
+
// Clean up temp file — best-effort
|
|
311
|
+
try {
|
|
312
|
+
await unlink(tmpPath);
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
// Ignore — file may already be gone
|
|
316
|
+
}
|
|
317
|
+
// Final safety: reap zombie if still running
|
|
318
|
+
if (proc && proc.exitCode === null) {
|
|
319
|
+
this._killProcessGroup(proc, 'SIGKILL');
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Safely kill the process group that was created with detached:true.
|
|
325
|
+
* Because detached:true guarantees PGID == proc.pid, we negate the PID.
|
|
326
|
+
* Never targets PID <= 1 (init / our own group).
|
|
327
|
+
*/
|
|
328
|
+
_killProcessGroup(proc, signal) {
|
|
329
|
+
if (!proc || proc.exitCode !== null)
|
|
330
|
+
return;
|
|
331
|
+
const pgid = proc.pid;
|
|
332
|
+
if (!pgid || pgid <= 1)
|
|
333
|
+
return;
|
|
334
|
+
try {
|
|
335
|
+
process.kill(-pgid, signal);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// Process group already gone — ignore
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/models/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAA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CAAC,IAAI,IAAI,IAAI,IAAI,CAAC;YAAE,OAAO;QAC/B,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;QACxC,CAAC;IACH,CAAC;CAeF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude model adapter.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Claude CLI (claude command) for analysis.
|
|
5
|
+
* Prompt is passed via stdin in -p (print) mode.
|
|
6
|
+
*
|
|
7
|
+
* Ported from triage_cli/models/claude.py
|
|
8
|
+
*/
|
|
9
|
+
import { SubprocessModel } from './base.js';
|
|
10
|
+
export declare class ClaudeModel extends SubprocessModel {
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Build Claude CLI command.
|
|
14
|
+
*
|
|
15
|
+
* Claude -p (print mode) reads from stdin when no positional prompt is given.
|
|
16
|
+
* CLAUDECODE env var is unset so Claude can run from within Claude Code sessions.
|
|
17
|
+
*/
|
|
18
|
+
_buildCommand(_promptFile: string): {
|
|
19
|
+
cmd: string[];
|
|
20
|
+
env: Record<string, string | undefined>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=claude.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/models/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,qBAAa,WAAY,SAAQ,eAAe;;IAQ9C;;;;;OAKG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG;QAClC,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;KACzC;CAMF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude model adapter.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Claude CLI (claude command) for analysis.
|
|
5
|
+
* Prompt is passed via stdin in -p (print) mode.
|
|
6
|
+
*
|
|
7
|
+
* Ported from triage_cli/models/claude.py
|
|
8
|
+
*/
|
|
9
|
+
import { SubprocessModel } from './base.js';
|
|
10
|
+
export class ClaudeModel extends SubprocessModel {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.name = 'claude';
|
|
14
|
+
this.cmdEnvVar = 'TRIAGE_CLAUDE_CMD';
|
|
15
|
+
this.defaultCmd = ['claude'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build Claude CLI command.
|
|
19
|
+
*
|
|
20
|
+
* Claude -p (print mode) reads from stdin when no positional prompt is given.
|
|
21
|
+
* CLAUDECODE env var is unset so Claude can run from within Claude Code sessions.
|
|
22
|
+
*/
|
|
23
|
+
_buildCommand(_promptFile) {
|
|
24
|
+
return {
|
|
25
|
+
cmd: ['claude', '-p', '--output-format', 'text'],
|
|
26
|
+
env: { CLAUDECODE: undefined }, // Unset to allow nested sessions
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=claude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/models/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,OAAO,WAAY,SAAQ,eAAe;IAC9C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,mBAAmB,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,WAAmB;QAI/B,OAAO;YACL,GAAG,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,CAAC;YAChD,GAAG,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,iCAAiC;SAClE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex model adapter.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Codex CLI for analysis.
|
|
5
|
+
* Prompt is read from the temp file and passed as a positional argument —
|
|
6
|
+
* no shell expansion, no bash -c.
|
|
7
|
+
*
|
|
8
|
+
* Ported from triage_cli/models/codex.py
|
|
9
|
+
*/
|
|
10
|
+
import { SubprocessModel } from './base.js';
|
|
11
|
+
export declare class CodexModel extends SubprocessModel {
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Build Codex CLI command.
|
|
15
|
+
*
|
|
16
|
+
* Codex exec requires the prompt as a positional argument.
|
|
17
|
+
* We read the prompt file synchronously and pass the text directly —
|
|
18
|
+
* no shell expansion, no bash -c.
|
|
19
|
+
*/
|
|
20
|
+
_buildCommand(promptFile: string): {
|
|
21
|
+
cmd: string[];
|
|
22
|
+
env: Record<string, string | undefined>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=codex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/models/codex.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,qBAAa,UAAW,SAAQ,eAAe;;IAQ7C;;;;;;OAMG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG;QACjC,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;KACzC;CAOF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex model adapter.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Codex CLI for analysis.
|
|
5
|
+
* Prompt is read from the temp file and passed as a positional argument —
|
|
6
|
+
* no shell expansion, no bash -c.
|
|
7
|
+
*
|
|
8
|
+
* Ported from triage_cli/models/codex.py
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import { SubprocessModel } from './base.js';
|
|
12
|
+
export class CodexModel extends SubprocessModel {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.name = 'codex';
|
|
16
|
+
this.cmdEnvVar = 'TRIAGE_CODEX_CMD';
|
|
17
|
+
this.defaultCmd = ['codex'];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build Codex CLI command.
|
|
21
|
+
*
|
|
22
|
+
* Codex exec requires the prompt as a positional argument.
|
|
23
|
+
* We read the prompt file synchronously and pass the text directly —
|
|
24
|
+
* no shell expansion, no bash -c.
|
|
25
|
+
*/
|
|
26
|
+
_buildCommand(promptFile) {
|
|
27
|
+
const promptText = readFileSync(promptFile, 'utf8');
|
|
28
|
+
return {
|
|
29
|
+
cmd: ['codex', 'exec', '--skip-git-repo-check', promptText],
|
|
30
|
+
env: {},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/models/codex.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,OAAO,UAAW,SAAQ,eAAe;IAC7C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,kBAAkB,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,UAAkB;QAI9B,MAAM,UAAU,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO;YACL,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,UAAU,CAAC;YAC3D,GAAG,EAAE,EAAE;SACR,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini model adapter.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Gemini CLI for analysis.
|
|
5
|
+
* Prompt is passed via stdin.
|
|
6
|
+
*
|
|
7
|
+
* Ported from triage_cli/models/gemini.py
|
|
8
|
+
*/
|
|
9
|
+
import { SubprocessModel } from './base.js';
|
|
10
|
+
export declare class GeminiModel extends SubprocessModel {
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Build Gemini CLI command.
|
|
14
|
+
*
|
|
15
|
+
* Gemini reads from stdin when input is piped.
|
|
16
|
+
* Model selection via TRIAGE_GEMINI_MODEL env var (optional).
|
|
17
|
+
*/
|
|
18
|
+
_buildCommand(_promptFile: string): {
|
|
19
|
+
cmd: string[];
|
|
20
|
+
env: Record<string, string | undefined>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/models/gemini.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,qBAAa,WAAY,SAAQ,eAAe;;IAQ9C;;;;;OAKG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG;QAClC,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;KACzC;CAQF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini model adapter.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Gemini CLI for analysis.
|
|
5
|
+
* Prompt is passed via stdin.
|
|
6
|
+
*
|
|
7
|
+
* Ported from triage_cli/models/gemini.py
|
|
8
|
+
*/
|
|
9
|
+
import { SubprocessModel } from './base.js';
|
|
10
|
+
export class GeminiModel extends SubprocessModel {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.name = 'gemini';
|
|
14
|
+
this.cmdEnvVar = 'TRIAGE_GEMINI_CMD';
|
|
15
|
+
this.defaultCmd = ['gemini'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build Gemini CLI command.
|
|
19
|
+
*
|
|
20
|
+
* Gemini reads from stdin when input is piped.
|
|
21
|
+
* Model selection via TRIAGE_GEMINI_MODEL env var (optional).
|
|
22
|
+
*/
|
|
23
|
+
_buildCommand(_promptFile) {
|
|
24
|
+
const model = process.env['TRIAGE_GEMINI_MODEL'] ?? '';
|
|
25
|
+
const cmd = ['gemini'];
|
|
26
|
+
if (model) {
|
|
27
|
+
cmd.push('-m', model);
|
|
28
|
+
}
|
|
29
|
+
return { cmd, env: {} };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=gemini.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/models/gemini.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,OAAO,WAAY,SAAQ,eAAe;IAC9C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,mBAAmB,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,WAAmB;QAI/B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC;QACvD,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvB,IAAI,KAAK,EAAE,CAAC;YACV,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACxB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
package/dist/patch.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patch application with safety checks.
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - Creating git branches before applying
|
|
6
|
+
* - Validating patches apply cleanly (dry-run)
|
|
7
|
+
* - Limiting scope of changes
|
|
8
|
+
*/
|
|
9
|
+
import type { Patch } from './types.js';
|
|
10
|
+
export declare class PatchApplicator {
|
|
11
|
+
private maxFiles;
|
|
12
|
+
private allowedSeverities;
|
|
13
|
+
private appliedFiles;
|
|
14
|
+
constructor(maxFiles?: number, allowedSeverities?: Set<string>);
|
|
15
|
+
/**
|
|
16
|
+
* Apply patches to the repository.
|
|
17
|
+
*
|
|
18
|
+
* Returns the number of patches successfully applied.
|
|
19
|
+
*/
|
|
20
|
+
applyPatches(patches: Patch[], createBranch?: boolean, branchName?: string): number;
|
|
21
|
+
/** Create a new git branch before applying patches. */
|
|
22
|
+
_createBranch(branchName?: string): boolean;
|
|
23
|
+
/** Apply a single patch with validation. */
|
|
24
|
+
_applySinglePatch(patch: Patch): boolean;
|
|
25
|
+
/** Validate that the patch is a valid unified diff. */
|
|
26
|
+
_isValidPatch(patch: Patch): boolean;
|
|
27
|
+
/** Check if the patch applies cleanly via `patch --dry-run`. */
|
|
28
|
+
_patchAppliesCleanly(patch: Patch): boolean;
|
|
29
|
+
/** Apply the patch for real via `patch -p1`. */
|
|
30
|
+
_doApplyPatch(patch: Patch): boolean;
|
|
31
|
+
/** Write patch content to a temp file and return its path. */
|
|
32
|
+
private _writeTempPatch;
|
|
33
|
+
/** Remove a temp file, ignoring errors. */
|
|
34
|
+
private _removeTempFile;
|
|
35
|
+
/**
|
|
36
|
+
* Show patches without applying (dry-run display).
|
|
37
|
+
*/
|
|
38
|
+
showPatches(patches: Patch[]): string;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=patch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../src/patch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAMxC,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,iBAAiB,CAAc;IACvC,OAAO,CAAC,YAAY,CAAc;gBAGhC,QAAQ,SAAI,EACZ,iBAAiB,GAAE,GAAG,CAAC,MAAM,CAAyB;IAOxD;;;;OAIG;IACH,YAAY,CACV,OAAO,EAAE,KAAK,EAAE,EAChB,YAAY,UAAO,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM;IA4BT,uDAAuD;IACvD,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO;IA4B3C,4CAA4C;IAC5C,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAcxC,uDAAuD;IACvD,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAepC,gEAAgE;IAChE,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAiB3C,gDAAgD;IAChD,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAoBpC,8DAA8D;IAC9D,OAAO,CAAC,eAAe;IAevB,2CAA2C;IAC3C,OAAO,CAAC,eAAe;IAQvB;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM;CAetC"}
|