@cluesmith/codev 2.0.0-rc.1 → 2.0.0-rc.10
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/bin/porch.js +9 -4
- package/dist/agent-farm/cli.d.ts.map +1 -1
- package/dist/agent-farm/cli.js +2 -14
- package/dist/agent-farm/cli.js.map +1 -1
- package/dist/agent-farm/commands/kickoff.d.ts +1 -0
- package/dist/agent-farm/commands/kickoff.d.ts.map +1 -1
- package/dist/agent-farm/commands/kickoff.js +82 -78
- package/dist/agent-farm/commands/kickoff.js.map +1 -1
- package/dist/agent-farm/commands/spawn.d.ts.map +1 -1
- package/dist/agent-farm/commands/spawn.js +30 -54
- package/dist/agent-farm/commands/spawn.js.map +1 -1
- package/dist/agent-farm/commands/start.d.ts.map +1 -1
- package/dist/agent-farm/commands/start.js +8 -50
- package/dist/agent-farm/commands/start.js.map +1 -1
- package/dist/agent-farm/servers/dashboard-server.js +0 -14
- package/dist/agent-farm/servers/dashboard-server.js.map +1 -1
- package/dist/agent-farm/state.d.ts +0 -10
- package/dist/agent-farm/state.d.ts.map +1 -1
- package/dist/agent-farm/state.js +0 -24
- package/dist/agent-farm/state.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -17
- package/dist/cli.js.map +1 -1
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +17 -1
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/consult/index.d.ts.map +1 -1
- package/dist/commands/consult/index.js +2 -1
- package/dist/commands/consult/index.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +17 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/porch/checks.d.ts +16 -29
- package/dist/commands/porch/checks.d.ts.map +1 -1
- package/dist/commands/porch/checks.js +90 -144
- package/dist/commands/porch/checks.js.map +1 -1
- package/dist/commands/porch/claude.d.ts +29 -0
- package/dist/commands/porch/claude.d.ts.map +1 -0
- package/dist/commands/porch/claude.js +79 -0
- package/dist/commands/porch/claude.js.map +1 -0
- package/dist/commands/porch/index.d.ts +21 -43
- package/dist/commands/porch/index.d.ts.map +1 -1
- package/dist/commands/porch/index.js +449 -753
- package/dist/commands/porch/index.js.map +1 -1
- package/dist/commands/porch/plan.d.ts +60 -0
- package/dist/commands/porch/plan.d.ts.map +1 -0
- package/dist/commands/porch/plan.js +162 -0
- package/dist/commands/porch/plan.js.map +1 -0
- package/dist/commands/porch/prompts.d.ts +19 -0
- package/dist/commands/porch/prompts.d.ts.map +1 -0
- package/dist/commands/porch/prompts.js +259 -0
- package/dist/commands/porch/prompts.js.map +1 -0
- package/dist/commands/porch/protocol.d.ts +57 -0
- package/dist/commands/porch/protocol.d.ts.map +1 -0
- package/dist/commands/porch/protocol.js +250 -0
- package/dist/commands/porch/protocol.js.map +1 -0
- package/dist/commands/porch/repl.d.ts +33 -0
- package/dist/commands/porch/repl.d.ts.map +1 -0
- package/dist/commands/porch/repl.js +206 -0
- package/dist/commands/porch/repl.js.map +1 -0
- package/dist/commands/porch/run.d.ts +15 -0
- package/dist/commands/porch/run.d.ts.map +1 -0
- package/dist/commands/porch/run.js +551 -0
- package/dist/commands/porch/run.js.map +1 -0
- package/dist/commands/porch/signals.d.ts +35 -0
- package/dist/commands/porch/signals.d.ts.map +1 -0
- package/dist/commands/porch/signals.js +76 -0
- package/dist/commands/porch/signals.js.map +1 -0
- package/dist/commands/porch/state.d.ts +19 -112
- package/dist/commands/porch/state.d.ts.map +1 -1
- package/dist/commands/porch/state.js +78 -685
- package/dist/commands/porch/state.js.map +1 -1
- package/dist/commands/porch/types.d.ts +65 -173
- package/dist/commands/porch/types.d.ts.map +1 -1
- package/dist/commands/porch/types.js +2 -1
- package/dist/commands/porch/types.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +19 -0
- package/dist/commands/update.js.map +1 -1
- package/dist/lib/scaffold.d.ts +24 -0
- package/dist/lib/scaffold.d.ts.map +1 -1
- package/dist/lib/scaffold.js +78 -0
- package/dist/lib/scaffold.js.map +1 -1
- package/package.json +5 -2
- package/skeleton/protocols/spider/prompts/defend.md +215 -0
- package/skeleton/protocols/spider/prompts/evaluate.md +241 -0
- package/skeleton/protocols/spider/prompts/implement.md +149 -0
- package/skeleton/protocols/spider/prompts/plan.md +214 -0
- package/skeleton/protocols/spider/prompts/review.md +217 -0
- package/skeleton/protocols/spider/prompts/specify.md +174 -0
- package/skeleton/protocols/spider/protocol.json +79 -147
- package/skeleton/protocols/spider/templates/plan.md +14 -0
- package/skeleton/roles/architect.md +40 -48
- package/skeleton/roles/builder.md +152 -29
- package/templates/dashboard/index.html +0 -27
- package/templates/dashboard/js/utils.js +0 -86
- package/dist/agent-farm/commands/rename.d.ts +0 -13
- package/dist/agent-farm/commands/rename.d.ts.map +0 -1
- package/dist/agent-farm/commands/rename.js +0 -33
- package/dist/agent-farm/commands/rename.js.map +0 -1
- package/dist/commands/pcheck/cache.d.ts +0 -48
- package/dist/commands/pcheck/cache.d.ts.map +0 -1
- package/dist/commands/pcheck/cache.js +0 -170
- package/dist/commands/pcheck/cache.js.map +0 -1
- package/dist/commands/pcheck/evaluator.d.ts +0 -15
- package/dist/commands/pcheck/evaluator.d.ts.map +0 -1
- package/dist/commands/pcheck/evaluator.js +0 -246
- package/dist/commands/pcheck/evaluator.js.map +0 -1
- package/dist/commands/pcheck/index.d.ts +0 -12
- package/dist/commands/pcheck/index.d.ts.map +0 -1
- package/dist/commands/pcheck/index.js +0 -249
- package/dist/commands/pcheck/index.js.map +0 -1
- package/dist/commands/pcheck/parser.d.ts +0 -39
- package/dist/commands/pcheck/parser.d.ts.map +0 -1
- package/dist/commands/pcheck/parser.js +0 -155
- package/dist/commands/pcheck/parser.js.map +0 -1
- package/dist/commands/pcheck/types.d.ts +0 -82
- package/dist/commands/pcheck/types.d.ts.map +0 -1
- package/dist/commands/pcheck/types.js +0 -5
- package/dist/commands/pcheck/types.js.map +0 -1
- package/dist/commands/porch/consultation.d.ts +0 -56
- package/dist/commands/porch/consultation.d.ts.map +0 -1
- package/dist/commands/porch/consultation.js +0 -330
- package/dist/commands/porch/consultation.js.map +0 -1
- package/dist/commands/porch/notifications.d.ts +0 -99
- package/dist/commands/porch/notifications.d.ts.map +0 -1
- package/dist/commands/porch/notifications.js +0 -223
- package/dist/commands/porch/notifications.js.map +0 -1
- package/dist/commands/porch/plan-parser.d.ts +0 -38
- package/dist/commands/porch/plan-parser.d.ts.map +0 -1
- package/dist/commands/porch/plan-parser.js +0 -166
- package/dist/commands/porch/plan-parser.js.map +0 -1
- package/dist/commands/porch/protocol-loader.d.ts +0 -46
- package/dist/commands/porch/protocol-loader.d.ts.map +0 -1
- package/dist/commands/porch/protocol-loader.js +0 -249
- package/dist/commands/porch/protocol-loader.js.map +0 -1
- package/dist/commands/porch/signal-parser.d.ts +0 -88
- package/dist/commands/porch/signal-parser.d.ts.map +0 -1
- package/dist/commands/porch/signal-parser.js +0 -148
- package/dist/commands/porch/signal-parser.js.map +0 -1
- package/skeleton/porch/protocols/bugfix.json +0 -85
- package/skeleton/porch/protocols/spider.json +0 -135
- package/skeleton/porch/protocols/tick.json +0 -76
- package/templates/dashboard/css/activity.css +0 -151
- package/templates/dashboard/js/activity.js +0 -112
|
@@ -1,195 +1,141 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Porch Check Runner
|
|
3
3
|
*
|
|
4
|
-
* Runs
|
|
5
|
-
*
|
|
4
|
+
* Runs check commands (npm test, npm run build, etc.)
|
|
5
|
+
* with timeout support.
|
|
6
6
|
*/
|
|
7
7
|
import { spawn } from 'node:child_process';
|
|
8
|
-
|
|
8
|
+
/** Default timeout for checks: 5 minutes */
|
|
9
|
+
const DEFAULT_TIMEOUT_MS = 5 * 60 * 1000;
|
|
9
10
|
/**
|
|
10
|
-
* Run a single command
|
|
11
|
+
* Run a single check command
|
|
11
12
|
*/
|
|
12
|
-
async function
|
|
13
|
+
export async function runCheck(name, command, cwd, env, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
13
14
|
const startTime = Date.now();
|
|
14
|
-
const timeout = options.timeout || 300000; // 5 minutes default
|
|
15
15
|
return new Promise((resolve) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
let stdout = '';
|
|
17
|
+
let stderr = '';
|
|
18
|
+
let killed = false;
|
|
19
|
+
// Parse command into executable and args
|
|
20
|
+
const parts = command.split(/\s+/);
|
|
21
|
+
const executable = parts[0];
|
|
22
|
+
const args = parts.slice(1);
|
|
23
|
+
const proc = spawn(executable, args, {
|
|
24
|
+
cwd,
|
|
19
25
|
shell: true,
|
|
20
26
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
27
|
+
env: {
|
|
28
|
+
...process.env,
|
|
29
|
+
PROJECT_ID: env.PROJECT_ID,
|
|
30
|
+
PROJECT_TITLE: env.PROJECT_TITLE,
|
|
31
|
+
},
|
|
21
32
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const timeoutId = setTimeout(() => {
|
|
26
|
-
timedOut = true;
|
|
33
|
+
// Set up timeout
|
|
34
|
+
const timeout = setTimeout(() => {
|
|
35
|
+
killed = true;
|
|
27
36
|
proc.kill('SIGTERM');
|
|
28
|
-
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
if (!proc.killed) {
|
|
39
|
+
proc.kill('SIGKILL');
|
|
40
|
+
}
|
|
41
|
+
}, 5000);
|
|
42
|
+
}, timeoutMs);
|
|
29
43
|
proc.stdout.on('data', (data) => {
|
|
30
|
-
|
|
44
|
+
stdout += data.toString();
|
|
31
45
|
});
|
|
32
46
|
proc.stderr.on('data', (data) => {
|
|
33
47
|
stderr += data.toString();
|
|
34
48
|
});
|
|
35
49
|
proc.on('close', (code) => {
|
|
36
|
-
clearTimeout(
|
|
50
|
+
clearTimeout(timeout);
|
|
37
51
|
const duration = Date.now() - startTime;
|
|
38
|
-
if (
|
|
52
|
+
if (killed) {
|
|
39
53
|
resolve({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
name,
|
|
55
|
+
command,
|
|
56
|
+
passed: false,
|
|
57
|
+
error: `Timed out after ${timeoutMs / 1000}s`,
|
|
58
|
+
duration_ms: duration,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else if (code === 0) {
|
|
62
|
+
resolve({
|
|
63
|
+
name,
|
|
64
|
+
command,
|
|
65
|
+
passed: true,
|
|
66
|
+
output: stdout.trim(),
|
|
67
|
+
duration_ms: duration,
|
|
44
68
|
});
|
|
45
69
|
}
|
|
46
70
|
else {
|
|
47
71
|
resolve({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
name,
|
|
73
|
+
command,
|
|
74
|
+
passed: false,
|
|
75
|
+
output: stdout.trim(),
|
|
76
|
+
error: stderr.trim() || `Exit code ${code}`,
|
|
77
|
+
duration_ms: duration,
|
|
52
78
|
});
|
|
53
79
|
}
|
|
54
80
|
});
|
|
55
81
|
proc.on('error', (err) => {
|
|
56
|
-
clearTimeout(
|
|
82
|
+
clearTimeout(timeout);
|
|
57
83
|
resolve({
|
|
58
|
-
|
|
59
|
-
|
|
84
|
+
name,
|
|
85
|
+
command,
|
|
86
|
+
passed: false,
|
|
60
87
|
error: err.message,
|
|
61
|
-
|
|
88
|
+
duration_ms: Date.now() - startTime,
|
|
62
89
|
});
|
|
63
90
|
});
|
|
64
91
|
});
|
|
65
92
|
}
|
|
66
93
|
/**
|
|
67
|
-
* Run
|
|
94
|
+
* Run multiple checks for a phase
|
|
68
95
|
*/
|
|
69
|
-
async function
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log(chalk.blue(`[check] Running ${name} (attempt ${attempts}/${maxRetries}): ${check.command}`));
|
|
77
|
-
lastResult = await runCommand(check.command, options);
|
|
78
|
-
if (lastResult.success) {
|
|
79
|
-
console.log(chalk.green(`[check] ${name} passed (${lastResult.duration}ms)`));
|
|
80
|
-
return {
|
|
81
|
-
name,
|
|
82
|
-
success: true,
|
|
83
|
-
output: lastResult.output,
|
|
84
|
-
attempts,
|
|
85
|
-
duration: lastResult.duration,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
console.log(chalk.yellow(`[check] ${name} failed: ${lastResult.error}`));
|
|
89
|
-
// Only retry if on_fail is 'retry'
|
|
90
|
-
if (check.on_fail !== 'retry' || attempts >= maxRetries) {
|
|
96
|
+
export async function runPhaseChecks(checks, cwd, env, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
97
|
+
const results = [];
|
|
98
|
+
for (const [name, command] of Object.entries(checks)) {
|
|
99
|
+
const result = await runCheck(name, command, cwd, env, timeoutMs);
|
|
100
|
+
results.push(result);
|
|
101
|
+
// Stop on first failure
|
|
102
|
+
if (!result.passed) {
|
|
91
103
|
break;
|
|
92
104
|
}
|
|
93
|
-
console.log(chalk.blue(`[check] Retrying in ${retryDelay}s...`));
|
|
94
|
-
await new Promise(r => setTimeout(r, retryDelay * 1000));
|
|
95
105
|
}
|
|
96
|
-
return
|
|
97
|
-
name,
|
|
98
|
-
success: false,
|
|
99
|
-
output: lastResult?.output || '',
|
|
100
|
-
error: lastResult?.error,
|
|
101
|
-
attempts,
|
|
102
|
-
duration: lastResult?.duration || 0,
|
|
103
|
-
};
|
|
106
|
+
return results;
|
|
104
107
|
}
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// Result Formatting
|
|
110
|
+
// ============================================================================
|
|
105
111
|
/**
|
|
106
|
-
*
|
|
112
|
+
* Format check results for terminal output
|
|
107
113
|
*/
|
|
108
|
-
export
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
for (const [name, check] of Object.entries(phase.checks)) {
|
|
122
|
-
const result = await runCheckWithRetry(name, check, { cwd: options.cwd });
|
|
123
|
-
results.push(result);
|
|
124
|
-
if (!result.success) {
|
|
125
|
-
console.log(chalk.red(`[check] ${name} failed after ${result.attempts} attempts`));
|
|
126
|
-
// Determine failure action
|
|
127
|
-
if (check.on_fail === 'retry') {
|
|
128
|
-
// Already retried, now fail
|
|
129
|
-
returnTo = undefined;
|
|
114
|
+
export function formatCheckResults(results) {
|
|
115
|
+
const lines = [];
|
|
116
|
+
for (const result of results) {
|
|
117
|
+
const status = result.passed ? '✓' : '✗';
|
|
118
|
+
const duration = result.duration_ms
|
|
119
|
+
? ` (${(result.duration_ms / 1000).toFixed(1)}s)`
|
|
120
|
+
: '';
|
|
121
|
+
lines.push(` ${status} ${result.name}${duration}`);
|
|
122
|
+
if (!result.passed && result.error) {
|
|
123
|
+
// Indent error message
|
|
124
|
+
const errorLines = result.error.split('\n').slice(0, 5);
|
|
125
|
+
for (const line of errorLines) {
|
|
126
|
+
lines.push(` ${line}`);
|
|
130
127
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
returnTo = check.on_fail;
|
|
128
|
+
if (result.error.split('\n').length > 5) {
|
|
129
|
+
lines.push(' ...');
|
|
134
130
|
}
|
|
135
|
-
return {
|
|
136
|
-
success: false,
|
|
137
|
-
checks: results,
|
|
138
|
-
returnTo,
|
|
139
|
-
};
|
|
140
131
|
}
|
|
141
132
|
}
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
success: true,
|
|
145
|
-
checks: results,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Create default checks for common phases
|
|
150
|
-
*/
|
|
151
|
-
export function getDefaultChecks(phaseName) {
|
|
152
|
-
switch (phaseName.toLowerCase()) {
|
|
153
|
-
case 'implement':
|
|
154
|
-
return {
|
|
155
|
-
build: {
|
|
156
|
-
command: 'npm run build',
|
|
157
|
-
on_fail: 'retry',
|
|
158
|
-
max_retries: 2,
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
case 'defend':
|
|
162
|
-
return {
|
|
163
|
-
tests: {
|
|
164
|
-
command: 'npm test',
|
|
165
|
-
on_fail: 'implement', // Return to implement on test failure
|
|
166
|
-
max_retries: 1,
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
default:
|
|
170
|
-
return {};
|
|
171
|
-
}
|
|
133
|
+
return lines.join('\n');
|
|
172
134
|
}
|
|
173
135
|
/**
|
|
174
|
-
*
|
|
136
|
+
* Check if all results passed
|
|
175
137
|
*/
|
|
176
|
-
export function
|
|
177
|
-
|
|
178
|
-
return 'No checks ran';
|
|
179
|
-
}
|
|
180
|
-
const lines = ['Check Results:'];
|
|
181
|
-
for (const check of results.checks) {
|
|
182
|
-
const status = check.success ? '✓' : '✗';
|
|
183
|
-
const duration = `(${check.duration}ms)`;
|
|
184
|
-
const attempts = check.attempts > 1 ? ` [${check.attempts} attempts]` : '';
|
|
185
|
-
lines.push(` ${status} ${check.name} ${duration}${attempts}`);
|
|
186
|
-
if (!check.success && check.error) {
|
|
187
|
-
lines.push(` Error: ${check.error}`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (results.returnTo) {
|
|
191
|
-
lines.push(` → Returning to phase: ${results.returnTo}`);
|
|
192
|
-
}
|
|
193
|
-
return lines.join('\n');
|
|
138
|
+
export function allChecksPassed(results) {
|
|
139
|
+
return results.every(r => r.passed);
|
|
194
140
|
}
|
|
195
141
|
//# sourceMappingURL=checks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../../src/commands/porch/checks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../../src/commands/porch/checks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,O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AK,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;YACjD,CAAC,CAAC,EAAE,CAAC;QAEP,KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAC,CAAC;QAEpD,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACnC,uBAAuB;YACvB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACxD,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;gBAC9B,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YAC5B,CAAC;YACD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAAsB;IACpD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude process management for Porch
|
|
3
|
+
*
|
|
4
|
+
* Spawns Claude with output to a file for monitoring.
|
|
5
|
+
*/
|
|
6
|
+
export interface ClaudeProcess {
|
|
7
|
+
/**
|
|
8
|
+
* Kill the Claude process.
|
|
9
|
+
*/
|
|
10
|
+
kill(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Check if Claude is still running.
|
|
13
|
+
*/
|
|
14
|
+
isRunning(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Get the exit code (null if still running).
|
|
17
|
+
*/
|
|
18
|
+
getExitCode(): number | null;
|
|
19
|
+
/**
|
|
20
|
+
* Register a callback for when Claude exits.
|
|
21
|
+
*/
|
|
22
|
+
onExit(callback: (code: number) => void): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Spawn Claude with the given prompt.
|
|
26
|
+
* Output goes to the specified file.
|
|
27
|
+
*/
|
|
28
|
+
export declare function spawnClaude(prompt: string, outputPath: string, cwd: string): ClaudeProcess;
|
|
29
|
+
//# sourceMappingURL=claude.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../../src/commands/porch/claude.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,IAAI,IAAI,CAAC;IAEb;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC;IAErB;;OAEG;IACH,WAAW,IAAI,MAAM,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;CAChD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,GACV,aAAa,CA2Ef"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude process management for Porch
|
|
3
|
+
*
|
|
4
|
+
* Spawns Claude with output to a file for monitoring.
|
|
5
|
+
*/
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import * as fs from 'node:fs';
|
|
8
|
+
/**
|
|
9
|
+
* Spawn Claude with the given prompt.
|
|
10
|
+
* Output goes to the specified file.
|
|
11
|
+
*/
|
|
12
|
+
export function spawnClaude(prompt, outputPath, cwd) {
|
|
13
|
+
// Open file for writing
|
|
14
|
+
const outputFd = fs.openSync(outputPath, 'w');
|
|
15
|
+
// Save prompt to file for reference
|
|
16
|
+
const promptFile = outputPath.replace(/\.txt$/, '-prompt.txt');
|
|
17
|
+
fs.writeFileSync(promptFile, prompt);
|
|
18
|
+
// Spawn Claude with prompt as command-line argument
|
|
19
|
+
// Node's spawn handles escaping correctly for long prompts
|
|
20
|
+
// Using --dangerously-skip-permissions so Claude can write files without prompts
|
|
21
|
+
const proc = spawn('claude', [
|
|
22
|
+
'--dangerously-skip-permissions',
|
|
23
|
+
'-p',
|
|
24
|
+
prompt, // Pass prompt directly as argument
|
|
25
|
+
], {
|
|
26
|
+
cwd,
|
|
27
|
+
stdio: ['ignore', outputFd, outputFd],
|
|
28
|
+
env: {
|
|
29
|
+
...process.env,
|
|
30
|
+
// Ensure Claude doesn't try to use interactive features
|
|
31
|
+
CI: '1',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
let exitCode = null;
|
|
35
|
+
let running = true;
|
|
36
|
+
const exitCallbacks = [];
|
|
37
|
+
proc.on('close', (code) => {
|
|
38
|
+
exitCode = code ?? 1;
|
|
39
|
+
running = false;
|
|
40
|
+
fs.closeSync(outputFd);
|
|
41
|
+
for (const callback of exitCallbacks) {
|
|
42
|
+
callback(exitCode);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
proc.on('error', (err) => {
|
|
46
|
+
console.error('Claude spawn error:', err.message);
|
|
47
|
+
running = false;
|
|
48
|
+
fs.closeSync(outputFd);
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
kill() {
|
|
52
|
+
if (running) {
|
|
53
|
+
proc.kill('SIGTERM');
|
|
54
|
+
// Give it a moment, then force kill if needed
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
if (running) {
|
|
57
|
+
proc.kill('SIGKILL');
|
|
58
|
+
}
|
|
59
|
+
}, 3000);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
isRunning() {
|
|
63
|
+
return running;
|
|
64
|
+
},
|
|
65
|
+
getExitCode() {
|
|
66
|
+
return exitCode;
|
|
67
|
+
},
|
|
68
|
+
onExit(callback) {
|
|
69
|
+
if (!running && exitCode !== null) {
|
|
70
|
+
// Already exited, call immediately
|
|
71
|
+
callback(exitCode);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
exitCallbacks.push(callback);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=claude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../../src/commands/porch/claude.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAwB9B;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,UAAkB,EAClB,GAAW;IAEX,wBAAwB;IACxB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAE9C,oCAAoC;IACpC,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAC/D,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAErC,oDAAoD;IACpD,2DAA2D;IAC3D,iFAAiF;IACjF,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE;QAC3B,gCAAgC;QAChC,IAAI;QACJ,MAAM,EAAG,mCAAmC;KAC7C,EAAE;QACD,GAAG;QACH,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;QACrC,GAAG,EAAE;YACH,GAAG,OAAO,CAAC,GAAG;YACd,wDAAwD;YACxD,EAAE,EAAE,GAAG;SACR;K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AM,CAAC;gBACN,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,60 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Porch - Protocol Orchestrator
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* context per iteration with state persisted to files.
|
|
4
|
+
* Claude calls porch as a tool; porch returns prescriptive instructions.
|
|
5
|
+
* All commands produce clear, actionable output.
|
|
7
6
|
*/
|
|
8
|
-
import type { Protocol, PorchRunOptions, PorchInitOptions } from './types.js';
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* porch status <id>
|
|
9
|
+
* Shows current state and prescriptive next steps.
|
|
12
10
|
*/
|
|
13
|
-
export declare function
|
|
11
|
+
export declare function status(projectRoot: string, projectId: string): Promise<void>;
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* porch check <id>
|
|
14
|
+
* Runs the phase checks and reports results.
|
|
17
15
|
*/
|
|
18
|
-
export declare function
|
|
16
|
+
export declare function check(projectRoot: string, projectId: string): Promise<void>;
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
18
|
+
* porch done <id>
|
|
19
|
+
* Advances to next phase if checks pass. Refuses if checks fail.
|
|
21
20
|
*/
|
|
22
|
-
export declare function
|
|
21
|
+
export declare function done(projectRoot: string, projectId: string): Promise<void>;
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
23
|
+
* porch gate <id>
|
|
24
|
+
* Requests human approval for current gate.
|
|
25
25
|
*/
|
|
26
|
-
export declare function
|
|
26
|
+
export declare function gate(projectRoot: string, projectId: string): Promise<void>;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* porch approve <id> <gate> --a-human-explicitly-approved-this
|
|
29
|
+
* Human approves a gate. Requires explicit flag to prevent automated approvals.
|
|
29
30
|
*/
|
|
30
|
-
export declare function approve(projectId: string,
|
|
31
|
+
export declare function approve(projectRoot: string, projectId: string, gateName: string, hasHumanFlag: boolean): Promise<void>;
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
+
* porch init <protocol> <id> <name>
|
|
34
|
+
* Initialize a new project.
|
|
33
35
|
*/
|
|
34
|
-
export declare function
|
|
35
|
-
|
|
36
|
-
* List available protocols
|
|
37
|
-
*/
|
|
38
|
-
export declare function list(): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Show protocol definition
|
|
41
|
-
*/
|
|
42
|
-
export declare function show(protocolName: string): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Show pending gates across all projects
|
|
45
|
-
*/
|
|
46
|
-
export declare function pending(): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Main porch entry point - handles subcommands
|
|
49
|
-
*/
|
|
50
|
-
export interface PorchOptions {
|
|
51
|
-
subcommand: string;
|
|
52
|
-
args: string[];
|
|
53
|
-
dryRun?: boolean;
|
|
54
|
-
noClaude?: boolean;
|
|
55
|
-
pollInterval?: number;
|
|
56
|
-
description?: string;
|
|
57
|
-
worktree?: string;
|
|
58
|
-
}
|
|
59
|
-
export declare function porch(options: PorchOptions): Promise<void>;
|
|
36
|
+
export declare function init(projectRoot: string, protocolName: string, projectId: string, projectName: string): Promise<void>;
|
|
37
|
+
export declare function cli(args: string[]): Promise<void>;
|
|
60
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/porch/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/porch/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyDH;;;GAGG;AACH,wBAAsB,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA6FlF;AAED;;;GAGG;AACH,wBAAsB,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCjF;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuGhF;AAiED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDhF;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,IAAI,CAAC,CA2Df;AAED;;;GAGG;AACH,wBAAsB,IAAI,CACxB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAkBf;AA2DD,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuEvD"}
|