@bradtaylorsf/alpha-loop 1.2.0 → 1.3.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 +60 -19
- package/dist/cli.js +4 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/auth.js +1 -1
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/init.d.ts +14 -0
- package/dist/commands/init.js +199 -30
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/resume.js +1 -0
- package/dist/commands/resume.js.map +1 -1
- package/dist/commands/run.js +31 -12
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/scan.d.ts +1 -1
- package/dist/commands/scan.js +12 -9
- package/dist/commands/scan.js.map +1 -1
- package/dist/commands/sync.d.ts +5 -0
- package/dist/commands/sync.js +24 -5
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/vision.js +5 -3
- package/dist/commands/vision.js.map +1 -1
- package/dist/engine/agents.d.ts +6 -1
- package/dist/engine/agents.js +14 -12
- package/dist/engine/agents.js.map +1 -1
- package/dist/engine/prerequisites.d.ts +4 -7
- package/dist/engine/prerequisites.js +12 -36
- package/dist/engine/prerequisites.js.map +1 -1
- package/dist/lib/agent.d.ts +10 -0
- package/dist/lib/agent.js +184 -28
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/config.d.ts +3 -2
- package/dist/lib/config.js +17 -7
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/learning.js +2 -2
- package/dist/lib/learning.js.map +1 -1
- package/dist/lib/pipeline.d.ts +35 -0
- package/dist/lib/pipeline.js +424 -131
- package/dist/lib/pipeline.js.map +1 -1
- package/dist/lib/prompts.d.ts +1 -0
- package/dist/lib/prompts.js +8 -5
- package/dist/lib/prompts.js.map +1 -1
- package/dist/lib/session.js +54 -19
- package/dist/lib/session.js.map +1 -1
- package/dist/lib/verify.d.ts +7 -1
- package/dist/lib/verify.js +109 -157
- package/dist/lib/verify.js.map +1 -1
- package/dist/lib/worktree.d.ts +1 -0
- package/dist/lib/worktree.js +9 -1
- package/dist/lib/worktree.js.map +1 -1
- package/package.json +1 -1
- package/templates/agents/implementer.md +1 -1
- package/templates/agents/reviewer.md +1 -1
- package/dist/engine/config.d.ts +0 -71
- package/dist/engine/config.js +0 -73
- package/dist/engine/config.js.map +0 -1
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
* Prerequisites Module
|
|
3
3
|
* ====================
|
|
4
4
|
*
|
|
5
|
-
* Verifies that
|
|
6
|
-
* Groups stages by agent for clear diagnostic output.
|
|
5
|
+
* Verifies that the configured AI CLI agent is installed before starting the pipeline.
|
|
7
6
|
*/
|
|
8
|
-
import {
|
|
7
|
+
import type { Config } from '../lib/config.js';
|
|
9
8
|
export interface AgentCheckResult {
|
|
10
9
|
agent: string;
|
|
11
10
|
installed: boolean;
|
|
12
|
-
stages: StageName[];
|
|
13
11
|
}
|
|
14
12
|
export interface PrerequisiteResult {
|
|
15
13
|
ok: boolean;
|
|
@@ -20,8 +18,7 @@ export interface PrerequisiteResult {
|
|
|
20
18
|
*/
|
|
21
19
|
export declare function isCommandAvailable(command: string): boolean;
|
|
22
20
|
/**
|
|
23
|
-
* Checks
|
|
24
|
-
* Returns structured results showing which agents are installed and which stages they serve.
|
|
21
|
+
* Checks that the configured agent CLI is installed.
|
|
25
22
|
*/
|
|
26
23
|
export declare function checkAgents(config: Config): PrerequisiteResult;
|
|
27
24
|
/**
|
|
@@ -29,6 +26,6 @@ export declare function checkAgents(config: Config): PrerequisiteResult;
|
|
|
29
26
|
*/
|
|
30
27
|
export declare function formatCheckResults(result: PrerequisiteResult): string;
|
|
31
28
|
/**
|
|
32
|
-
* Formats the pipeline startup summary
|
|
29
|
+
* Formats the pipeline startup summary.
|
|
33
30
|
*/
|
|
34
31
|
export declare function formatPipelineSummary(config: Config): string;
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* Prerequisites Module
|
|
3
3
|
* ====================
|
|
4
4
|
*
|
|
5
|
-
* Verifies that
|
|
6
|
-
* Groups stages by agent for clear diagnostic output.
|
|
5
|
+
* Verifies that the configured AI CLI agent is installed before starting the pipeline.
|
|
7
6
|
*/
|
|
8
7
|
import { execSync } from 'node:child_process';
|
|
9
|
-
import { STAGE_NAMES, resolveStageConfig } from './config.js';
|
|
10
8
|
// ============================================================================
|
|
11
9
|
// Agent Check
|
|
12
10
|
// ============================================================================
|
|
@@ -27,30 +25,16 @@ export function isCommandAvailable(command) {
|
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
30
|
-
* Checks
|
|
31
|
-
* Returns structured results showing which agents are installed and which stages they serve.
|
|
28
|
+
* Checks that the configured agent CLI is installed.
|
|
32
29
|
*/
|
|
33
30
|
export function checkAgents(config) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const stages = agentStages.get(agent) ?? [];
|
|
39
|
-
stages.push(stage);
|
|
40
|
-
agentStages.set(agent, stages);
|
|
41
|
-
}
|
|
42
|
-
// Check each unique agent
|
|
43
|
-
const results = [];
|
|
44
|
-
for (const [agent, stages] of agentStages) {
|
|
45
|
-
results.push({
|
|
46
|
-
agent,
|
|
47
|
-
installed: isCommandAvailable(agent),
|
|
48
|
-
stages,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
31
|
+
const result = {
|
|
32
|
+
agent: config.agent,
|
|
33
|
+
installed: isCommandAvailable(config.agent),
|
|
34
|
+
};
|
|
51
35
|
return {
|
|
52
|
-
ok:
|
|
53
|
-
results,
|
|
36
|
+
ok: result.installed,
|
|
37
|
+
results: [result],
|
|
54
38
|
};
|
|
55
39
|
}
|
|
56
40
|
// ============================================================================
|
|
@@ -63,28 +47,20 @@ export function formatCheckResults(result) {
|
|
|
63
47
|
const lines = ['Checking agents...'];
|
|
64
48
|
for (const r of result.results) {
|
|
65
49
|
const icon = r.installed ? '\u2713' : '\u2717';
|
|
66
|
-
|
|
67
|
-
lines.push(` ${icon} ${r.agent} (${stageList})`);
|
|
50
|
+
lines.push(` ${icon} ${r.agent}`);
|
|
68
51
|
}
|
|
69
52
|
if (!result.ok) {
|
|
70
53
|
const missing = result.results.filter(r => !r.installed);
|
|
71
54
|
for (const m of missing) {
|
|
72
|
-
lines.push(`\nError: "${m.agent}" is not installed
|
|
55
|
+
lines.push(`\nError: "${m.agent}" is not installed.`);
|
|
73
56
|
}
|
|
74
57
|
}
|
|
75
58
|
return lines.join('\n');
|
|
76
59
|
}
|
|
77
60
|
/**
|
|
78
|
-
* Formats the pipeline startup summary
|
|
61
|
+
* Formats the pipeline startup summary.
|
|
79
62
|
*/
|
|
80
63
|
export function formatPipelineSummary(config) {
|
|
81
|
-
|
|
82
|
-
for (const stage of STAGE_NAMES) {
|
|
83
|
-
const sc = resolveStageConfig(config, stage);
|
|
84
|
-
const turns = sc.maxTurns ? ` (${sc.maxTurns} turns)` : '';
|
|
85
|
-
const padded = `${stage}:`.padEnd(14);
|
|
86
|
-
lines.push(` ${padded}${sc.agent}/${sc.model}${turns}`);
|
|
87
|
-
}
|
|
88
|
-
return lines.join('\n');
|
|
64
|
+
return `Pipeline: ${config.agent}/${config.model}`;
|
|
89
65
|
}
|
|
90
66
|
//# sourceMappingURL=prerequisites.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerequisites.js","sourceRoot":"","sources":["../../src/engine/prerequisites.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prerequisites.js","sourceRoot":"","sources":["../../src/engine/prerequisites.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAiB9C,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,+EAA+E;IAC/E,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CA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,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,OAAO,aAAa,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;AACrD,CAAC"}
|
package/dist/lib/agent.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type AgentOptions = {
|
|
|
14
14
|
timeout?: number;
|
|
15
15
|
/** Max conversation turns for the agent. Only supported by claude. */
|
|
16
16
|
maxTurns?: number;
|
|
17
|
+
/** Resume the most recent agent session in the CWD instead of starting fresh. */
|
|
18
|
+
resume?: boolean;
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* Build CLI command and args for a given agent type.
|
|
@@ -22,8 +24,16 @@ export declare function buildAgentArgs(options: AgentOptions): {
|
|
|
22
24
|
command: string;
|
|
23
25
|
args: string[];
|
|
24
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Build a shell command string for one-shot agent prompts (scan, vision).
|
|
29
|
+
* Reads prompt from stdin. Returns the command to pipe into.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildOneShotCommand(agent: 'claude' | 'codex' | 'opencode', model: string): string;
|
|
25
32
|
/**
|
|
26
33
|
* Spawn an AI agent with a prompt.
|
|
27
34
|
* Streams output to terminal in real-time while capturing it.
|
|
35
|
+
*
|
|
36
|
+
* For Claude, uses stream-json format and parses it into readable log lines.
|
|
37
|
+
* For other agents, captures raw stdout/stderr directly.
|
|
28
38
|
*/
|
|
29
39
|
export declare function spawnAgent(options: AgentOptions): Promise<AgentResult>;
|
package/dist/lib/agent.js
CHANGED
|
@@ -4,6 +4,67 @@
|
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
5
|
import { createWriteStream } from 'node:fs';
|
|
6
6
|
import { log } from './logger.js';
|
|
7
|
+
/**
|
|
8
|
+
* Parse a Claude stream-json line into a human-readable log line.
|
|
9
|
+
* Returns null for lines that shouldn't be logged.
|
|
10
|
+
*/
|
|
11
|
+
function formatStreamJsonLine(line) {
|
|
12
|
+
try {
|
|
13
|
+
const obj = JSON.parse(line);
|
|
14
|
+
const type = obj.type;
|
|
15
|
+
if (type === 'assistant') {
|
|
16
|
+
const msg = obj.message;
|
|
17
|
+
const content = (msg?.content ?? []);
|
|
18
|
+
const parts = [];
|
|
19
|
+
for (const block of content) {
|
|
20
|
+
if (block.type === 'tool_use') {
|
|
21
|
+
const input = block.input;
|
|
22
|
+
const name = block.name;
|
|
23
|
+
// Show the most useful input field for common tools
|
|
24
|
+
if (name === 'Read' && input?.file_path) {
|
|
25
|
+
parts.push(`[${name}] ${input.file_path}`);
|
|
26
|
+
}
|
|
27
|
+
else if (name === 'Write' && input?.file_path) {
|
|
28
|
+
parts.push(`[${name}] ${input.file_path}`);
|
|
29
|
+
}
|
|
30
|
+
else if (name === 'Edit' && input?.file_path) {
|
|
31
|
+
parts.push(`[${name}] ${input.file_path}`);
|
|
32
|
+
}
|
|
33
|
+
else if (name === 'Bash' && input?.command) {
|
|
34
|
+
parts.push(`[${name}] ${String(input.command).slice(0, 200)}`);
|
|
35
|
+
}
|
|
36
|
+
else if (name === 'Glob' && input?.pattern) {
|
|
37
|
+
parts.push(`[${name}] ${input.pattern}`);
|
|
38
|
+
}
|
|
39
|
+
else if (name === 'Grep' && input?.pattern) {
|
|
40
|
+
parts.push(`[${name}] ${input.pattern}`);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
parts.push(`[${name}]`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (block.type === 'text') {
|
|
47
|
+
const text = String(block.text ?? '').trim();
|
|
48
|
+
if (text)
|
|
49
|
+
parts.push(text);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (parts.length > 0)
|
|
53
|
+
return parts.join('\n');
|
|
54
|
+
}
|
|
55
|
+
if (type === 'result') {
|
|
56
|
+
const result = String(obj.result ?? '').trim();
|
|
57
|
+
const cost = obj.total_cost_usd;
|
|
58
|
+
const costStr = cost ? ` ($${cost.toFixed(4)})` : '';
|
|
59
|
+
if (result)
|
|
60
|
+
return `\n--- RESULT${costStr} ---\n${result}`;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
7
68
|
/** Default agent timeout: 30 minutes */
|
|
8
69
|
const DEFAULT_AGENT_TIMEOUT_MS = 30 * 60 * 1000;
|
|
9
70
|
/**
|
|
@@ -12,43 +73,81 @@ const DEFAULT_AGENT_TIMEOUT_MS = 30 * 60 * 1000;
|
|
|
12
73
|
export function buildAgentArgs(options) {
|
|
13
74
|
switch (options.agent) {
|
|
14
75
|
case 'claude': {
|
|
15
|
-
const args = [
|
|
16
|
-
|
|
17
|
-
'--
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'--
|
|
21
|
-
|
|
76
|
+
const args = [];
|
|
77
|
+
if (options.resume)
|
|
78
|
+
args.push('--continue');
|
|
79
|
+
args.push('-p');
|
|
80
|
+
if (options.model)
|
|
81
|
+
args.push('--model', options.model);
|
|
82
|
+
args.push('--dangerously-skip-permissions', '--verbose', '--output-format', 'stream-json');
|
|
22
83
|
if (options.maxTurns) {
|
|
23
84
|
args.push('--max-turns', String(options.maxTurns));
|
|
24
85
|
}
|
|
25
86
|
return { command: 'claude', args };
|
|
26
87
|
}
|
|
27
88
|
case 'codex': {
|
|
28
|
-
const args = [
|
|
29
|
-
|
|
30
|
-
'
|
|
31
|
-
|
|
32
|
-
|
|
89
|
+
const args = [];
|
|
90
|
+
if (options.resume) {
|
|
91
|
+
args.push('exec', 'resume', '--last');
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
args.push('exec');
|
|
95
|
+
}
|
|
96
|
+
if (options.model)
|
|
97
|
+
args.push('--model', options.model);
|
|
98
|
+
args.push('--full-auto');
|
|
33
99
|
return { command: 'codex', args };
|
|
34
100
|
}
|
|
35
101
|
case 'opencode': {
|
|
36
|
-
const args = [
|
|
37
|
-
|
|
38
|
-
'--model', options.model
|
|
39
|
-
];
|
|
102
|
+
const args = ['run'];
|
|
103
|
+
if (options.model)
|
|
104
|
+
args.push('--model', options.model);
|
|
40
105
|
return { command: 'opencode', args };
|
|
41
106
|
}
|
|
42
107
|
default:
|
|
43
108
|
throw new Error(`Unknown agent type: ${options.agent}`);
|
|
44
109
|
}
|
|
45
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Build a shell command string for one-shot agent prompts (scan, vision).
|
|
113
|
+
* Reads prompt from stdin. Returns the command to pipe into.
|
|
114
|
+
*/
|
|
115
|
+
export function buildOneShotCommand(agent, model) {
|
|
116
|
+
switch (agent) {
|
|
117
|
+
case 'claude': {
|
|
118
|
+
const parts = ['claude', '-p'];
|
|
119
|
+
if (model)
|
|
120
|
+
parts.push('--model', model);
|
|
121
|
+
parts.push('--dangerously-skip-permissions', '--output-format', 'text');
|
|
122
|
+
return parts.join(' ');
|
|
123
|
+
}
|
|
124
|
+
case 'codex': {
|
|
125
|
+
const parts = ['codex', 'exec'];
|
|
126
|
+
if (model)
|
|
127
|
+
parts.push('--model', model);
|
|
128
|
+
parts.push('--full-auto');
|
|
129
|
+
return parts.join(' ');
|
|
130
|
+
}
|
|
131
|
+
case 'opencode': {
|
|
132
|
+
const parts = ['opencode', 'run'];
|
|
133
|
+
if (model)
|
|
134
|
+
parts.push('--model', model);
|
|
135
|
+
return parts.join(' ');
|
|
136
|
+
}
|
|
137
|
+
default:
|
|
138
|
+
throw new Error(`Unknown agent type: ${agent}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
46
141
|
/**
|
|
47
142
|
* Spawn an AI agent with a prompt.
|
|
48
143
|
* Streams output to terminal in real-time while capturing it.
|
|
144
|
+
*
|
|
145
|
+
* For Claude, uses stream-json format and parses it into readable log lines.
|
|
146
|
+
* For other agents, captures raw stdout/stderr directly.
|
|
49
147
|
*/
|
|
50
148
|
export async function spawnAgent(options) {
|
|
51
149
|
const { command, args } = buildAgentArgs(options);
|
|
150
|
+
const useStreamJson = options.agent === 'claude';
|
|
52
151
|
log.info(`Agent: ${options.agent} | Model: ${options.model} | CWD: ${options.cwd}`);
|
|
53
152
|
const startTime = Date.now();
|
|
54
153
|
const chunks = [];
|
|
@@ -63,29 +162,86 @@ export async function spawnAgent(options) {
|
|
|
63
162
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
64
163
|
});
|
|
65
164
|
let resolved = false;
|
|
165
|
+
// For stream-json: accumulate partial lines, extract final result text
|
|
166
|
+
let lineBuffer = '';
|
|
167
|
+
let finalResultText = '';
|
|
66
168
|
// Pipe prompt via stdin (like: echo "$prompt" | claude -p)
|
|
67
169
|
child.stdin.write(options.prompt);
|
|
68
170
|
child.stdin.end();
|
|
69
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Write a string to the log file, handling backpressure.
|
|
173
|
+
*/
|
|
174
|
+
const writeToLog = (stream, text) => {
|
|
175
|
+
if (!logStream)
|
|
176
|
+
return;
|
|
177
|
+
const ok = logStream.write(text);
|
|
178
|
+
if (!ok) {
|
|
179
|
+
stream.pause();
|
|
180
|
+
logStream.once('drain', () => stream.resume());
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Handle raw data for non-Claude agents (pass-through).
|
|
185
|
+
*/
|
|
186
|
+
const handleRawData = (stream) => (data) => {
|
|
70
187
|
chunks.push(data);
|
|
71
|
-
if (options.verbose)
|
|
188
|
+
if (options.verbose)
|
|
72
189
|
process.stderr.write(data);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
190
|
+
writeToLog(stream, data.toString());
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Handle stream-json data for Claude — parse JSON lines into readable output.
|
|
194
|
+
*/
|
|
195
|
+
const handleStreamJson = (stream) => (data) => {
|
|
196
|
+
chunks.push(data);
|
|
197
|
+
lineBuffer += data.toString();
|
|
198
|
+
// Process complete lines
|
|
199
|
+
let newlineIdx;
|
|
200
|
+
while ((newlineIdx = lineBuffer.indexOf('\n')) !== -1) {
|
|
201
|
+
const line = lineBuffer.slice(0, newlineIdx).trim();
|
|
202
|
+
lineBuffer = lineBuffer.slice(newlineIdx + 1);
|
|
203
|
+
if (!line)
|
|
204
|
+
continue;
|
|
205
|
+
// Extract the final result text for the return value
|
|
206
|
+
try {
|
|
207
|
+
const obj = JSON.parse(line);
|
|
208
|
+
if (obj.type === 'result') {
|
|
209
|
+
finalResultText = typeof obj.result === 'string' ? obj.result : '';
|
|
210
|
+
// Capture error info so transient error detection works
|
|
211
|
+
if (obj.is_error || obj.subtype === 'error') {
|
|
212
|
+
finalResultText = finalResultText || JSON.stringify(obj);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch { /* not valid JSON, ignore */ }
|
|
217
|
+
const formatted = formatStreamJsonLine(line);
|
|
218
|
+
if (formatted) {
|
|
219
|
+
const logLine = formatted + '\n';
|
|
220
|
+
if (options.verbose)
|
|
221
|
+
process.stderr.write(logLine);
|
|
222
|
+
writeToLog(stream, logLine);
|
|
80
223
|
}
|
|
81
224
|
}
|
|
82
225
|
};
|
|
83
|
-
|
|
84
|
-
|
|
226
|
+
if (useStreamJson) {
|
|
227
|
+
child.stdout.on('data', handleStreamJson(child.stdout));
|
|
228
|
+
// stderr from Claude in stream-json mode is typically empty, but capture it
|
|
229
|
+
child.stderr.on('data', handleRawData(child.stderr));
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
child.stdout.on('data', handleRawData(child.stdout));
|
|
233
|
+
child.stderr.on('data', handleRawData(child.stderr));
|
|
234
|
+
}
|
|
85
235
|
// Prevent unhandled stream errors from crashing the process
|
|
86
236
|
child.stdout.on('error', () => { });
|
|
87
237
|
child.stderr.on('error', () => { });
|
|
88
|
-
const getOutput = () =>
|
|
238
|
+
const getOutput = () => {
|
|
239
|
+
if (useStreamJson) {
|
|
240
|
+
// Return the parsed result text, not raw JSON
|
|
241
|
+
return finalResultText || Buffer.concat(chunks).toString();
|
|
242
|
+
}
|
|
243
|
+
return Buffer.concat(chunks).toString();
|
|
244
|
+
};
|
|
89
245
|
const finish = (exitCode, output) => {
|
|
90
246
|
if (resolved)
|
|
91
247
|
return;
|
package/dist/lib/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/lib/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAQlC,wCAAwC;AACxC,MAAM,wBAAwB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/lib/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAQlC;;;GAGG;AACH,SAAS,oBAAoB,CAAC,IAAY;IACxC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;QACxD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAc,CAAC;QAEhC,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,GAAG,CAAC,OAA8C,CAAC;YAC/D,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,OAAO,IAAI,EAAE,CAAmC,CAAC;YACvE,MAAM,KAAK,GAAa,EAAE,CAAC;YAE3B,KAAK,MAAM,KAAK,I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C;oBAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;gBACrD,UAAU,CAAC,GAAG,EAAE;oBACd,IAAI,CAAC;wBAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAAC,CAAC;oBAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;gBACvD,CAAC,EAAE,IAAI,CAAC,CAAC;gBACT,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,sDAAsD,CAAC,CAAC;YAClF,CAAC;QACH,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,MAAM,CAAC,IAAI,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,MAAM,CAAC,CAAC,EAAE,mBAAmB,OAAO,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type Config = {
|
|
|
2
2
|
repo: string;
|
|
3
3
|
repoOwner: string;
|
|
4
4
|
project: number;
|
|
5
|
+
agent: 'claude' | 'codex' | 'opencode';
|
|
5
6
|
model: string;
|
|
6
7
|
reviewModel: string;
|
|
7
8
|
pollInterval: number;
|
|
@@ -12,7 +13,6 @@ export type Config = {
|
|
|
12
13
|
maxTestRetries: number;
|
|
13
14
|
testCommand: string;
|
|
14
15
|
devCommand: string;
|
|
15
|
-
port: number;
|
|
16
16
|
skipTests: boolean;
|
|
17
17
|
skipReview: boolean;
|
|
18
18
|
skipInstall: boolean;
|
|
@@ -29,8 +29,9 @@ export type Config = {
|
|
|
29
29
|
runFull: boolean;
|
|
30
30
|
verbose: boolean;
|
|
31
31
|
harnesses: string[];
|
|
32
|
+
setupCommand: string;
|
|
32
33
|
};
|
|
33
|
-
/** Validate a string contains only safe shell characters. */
|
|
34
|
+
/** Validate a string contains only safe shell characters. Empty strings are allowed (model is optional). */
|
|
34
35
|
export declare function assertSafeShellArg(value: string, name: string): string;
|
|
35
36
|
export declare function detectRepo(): string | null;
|
|
36
37
|
export declare function loadConfig(overrides?: Partial<Config>): Config;
|
package/dist/lib/config.js
CHANGED
|
@@ -5,8 +5,9 @@ const DEFAULTS = {
|
|
|
5
5
|
repo: '',
|
|
6
6
|
repoOwner: '',
|
|
7
7
|
project: 2,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
agent: 'claude',
|
|
9
|
+
model: '',
|
|
10
|
+
reviewModel: '',
|
|
10
11
|
pollInterval: 60,
|
|
11
12
|
dryRun: false,
|
|
12
13
|
baseBranch: 'master',
|
|
@@ -15,7 +16,6 @@ const DEFAULTS = {
|
|
|
15
16
|
maxTestRetries: 3,
|
|
16
17
|
testCommand: 'pnpm test',
|
|
17
18
|
devCommand: 'pnpm dev',
|
|
18
|
-
port: 3000,
|
|
19
19
|
skipTests: false,
|
|
20
20
|
skipReview: false,
|
|
21
21
|
skipInstall: false,
|
|
@@ -32,12 +32,14 @@ const DEFAULTS = {
|
|
|
32
32
|
runFull: false,
|
|
33
33
|
verbose: false,
|
|
34
34
|
harnesses: [],
|
|
35
|
+
setupCommand: '',
|
|
35
36
|
};
|
|
36
37
|
/** Map from YAML key (snake_case) to Config key (camelCase). */
|
|
37
38
|
const YAML_KEY_MAP = {
|
|
38
39
|
harnesses: 'harnesses',
|
|
39
40
|
repo: 'repo',
|
|
40
41
|
project: 'project',
|
|
42
|
+
agent: 'agent',
|
|
41
43
|
model: 'model',
|
|
42
44
|
review_model: 'reviewModel',
|
|
43
45
|
poll_interval: 'pollInterval',
|
|
@@ -48,7 +50,6 @@ const YAML_KEY_MAP = {
|
|
|
48
50
|
max_test_retries: 'maxTestRetries',
|
|
49
51
|
test_command: 'testCommand',
|
|
50
52
|
dev_command: 'devCommand',
|
|
51
|
-
port: 'port',
|
|
52
53
|
skip_tests: 'skipTests',
|
|
53
54
|
skip_review: 'skipReview',
|
|
54
55
|
skip_install: 'skipInstall',
|
|
@@ -64,11 +65,13 @@ const YAML_KEY_MAP = {
|
|
|
64
65
|
auto_cleanup: 'autoCleanup',
|
|
65
66
|
run_full: 'runFull',
|
|
66
67
|
verbose: 'verbose',
|
|
68
|
+
setup_command: 'setupCommand',
|
|
67
69
|
};
|
|
68
70
|
/** Map from env var name to Config key. */
|
|
69
71
|
const ENV_KEY_MAP = {
|
|
70
72
|
REPO: 'repo',
|
|
71
|
-
|
|
73
|
+
PROJECT: 'project',
|
|
74
|
+
AGENT: 'agent',
|
|
72
75
|
MODEL: 'model',
|
|
73
76
|
REVIEW_MODEL: 'reviewModel',
|
|
74
77
|
POLL_INTERVAL: 'pollInterval',
|
|
@@ -79,7 +82,6 @@ const ENV_KEY_MAP = {
|
|
|
79
82
|
MAX_TEST_RETRIES: 'maxTestRetries',
|
|
80
83
|
TEST_COMMAND: 'testCommand',
|
|
81
84
|
DEV_COMMAND: 'devCommand',
|
|
82
|
-
PORT: 'port',
|
|
83
85
|
SKIP_TESTS: 'skipTests',
|
|
84
86
|
SKIP_REVIEW: 'skipReview',
|
|
85
87
|
SKIP_INSTALL: 'skipInstall',
|
|
@@ -95,6 +97,7 @@ const ENV_KEY_MAP = {
|
|
|
95
97
|
AUTO_CLEANUP: 'autoCleanup',
|
|
96
98
|
RUN_FULL: 'runFull',
|
|
97
99
|
VERBOSE: 'verbose',
|
|
100
|
+
SETUP_COMMAND: 'setupCommand',
|
|
98
101
|
};
|
|
99
102
|
function coerce(value, current) {
|
|
100
103
|
if (typeof current === 'number')
|
|
@@ -103,8 +106,10 @@ function coerce(value, current) {
|
|
|
103
106
|
return value === 'true' || value === '1';
|
|
104
107
|
return value;
|
|
105
108
|
}
|
|
106
|
-
/** Validate a string contains only safe shell characters. */
|
|
109
|
+
/** Validate a string contains only safe shell characters. Empty strings are allowed (model is optional). */
|
|
107
110
|
export function assertSafeShellArg(value, name) {
|
|
111
|
+
if (value === '')
|
|
112
|
+
return value;
|
|
108
113
|
if (!/^[a-zA-Z0-9._\-/]+$/.test(value)) {
|
|
109
114
|
throw new Error(`Invalid ${name}: contains unsafe characters: ${value}`);
|
|
110
115
|
}
|
|
@@ -172,6 +177,11 @@ export function loadConfig(overrides) {
|
|
|
172
177
|
...envConfig,
|
|
173
178
|
...overrides,
|
|
174
179
|
};
|
|
180
|
+
// Validate agent is a known value
|
|
181
|
+
const VALID_AGENTS = ['claude', 'codex', 'opencode'];
|
|
182
|
+
if (!VALID_AGENTS.includes(merged.agent)) {
|
|
183
|
+
throw new Error(`Invalid agent: "${merged.agent}". Supported agents: ${VALID_AGENTS.join(', ')}`);
|
|
184
|
+
}
|
|
175
185
|
// Derive repoOwner from repo
|
|
176
186
|
if (merged.repo) {
|
|
177
187
|
merged.repoOwner = merged.repo.split('/')[0] ?? '';
|
package/dist/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAoC1C,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AAsF;IACtF,MAAM,MAAM,GAAW;QACrB,GAAG,QAAQ;QACX,GAAG,UAAU;QACb,GAAG,UAAU;QACb,GAAG,SAAS;QACZ,GAAG,SAAS;KACb,CAAC;IAEF,kCAAkC;IAClC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;IAC9D,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAoC,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAC,KAAK,wBAAwB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,6BAA6B;IAC7B,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/lib/learning.js
CHANGED
|
@@ -39,7 +39,7 @@ export async function extractLearnings(options) {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
const result = await spawnAgent({
|
|
42
|
-
agent:
|
|
42
|
+
agent: config.agent,
|
|
43
43
|
model: config.reviewModel,
|
|
44
44
|
prompt,
|
|
45
45
|
cwd: process.cwd(),
|
|
@@ -189,7 +189,7 @@ Output ONLY this markdown structure:
|
|
|
189
189
|
| Avg duration | ${Math.round(totalDuration / results.length)}s |
|
|
190
190
|
| Total duration | ${Math.round(totalDuration / 60)} min |`;
|
|
191
191
|
const agentResult = await spawnAgent({
|
|
192
|
-
agent:
|
|
192
|
+
agent: config.agent,
|
|
193
193
|
model: config.reviewModel,
|
|
194
194
|
prompt,
|
|
195
195
|
cwd: process.cwd(),
|