create-claude-workspace 1.1.9 → 1.1.11
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.
|
@@ -36,12 +36,10 @@ Options:
|
|
|
36
36
|
--cooldown <ms> Wait after error in ms (default: 60000)
|
|
37
37
|
--project-dir <path> Target project directory (default: cwd)
|
|
38
38
|
--skip-permissions Run claude with --dangerously-skip-permissions
|
|
39
|
-
--verbose Show live Claude activity (tool calls, file edits, text)
|
|
40
39
|
--help Show this message
|
|
41
40
|
|
|
42
41
|
Examples:
|
|
43
42
|
node .claude/scripts/autonomous.mjs --skip-permissions
|
|
44
|
-
node .claude/scripts/autonomous.mjs --skip-permissions --verbose
|
|
45
43
|
node .claude/scripts/autonomous.mjs --skip-permissions --max-iterations 20 --delay 10000
|
|
46
44
|
`);
|
|
47
45
|
}
|
|
@@ -55,7 +53,6 @@ function parseArgs() {
|
|
|
55
53
|
cooldown: 60_000,
|
|
56
54
|
projectDir: process.cwd(),
|
|
57
55
|
skipPermissions: false,
|
|
58
|
-
verbose: false,
|
|
59
56
|
};
|
|
60
57
|
|
|
61
58
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -84,9 +81,6 @@ function parseArgs() {
|
|
|
84
81
|
case '--skip-permissions':
|
|
85
82
|
opts.skipPermissions = true;
|
|
86
83
|
break;
|
|
87
|
-
case '--verbose':
|
|
88
|
-
opts.verbose = true;
|
|
89
|
-
break;
|
|
90
84
|
default:
|
|
91
85
|
if (args[i].startsWith('--')) {
|
|
92
86
|
console.error(`Unknown option: ${args[i]}`);
|
|
@@ -194,78 +188,20 @@ process.on('SIGTERM', () => {
|
|
|
194
188
|
stopping = true;
|
|
195
189
|
});
|
|
196
190
|
|
|
197
|
-
// ─── Verbose output formatting ───
|
|
198
|
-
|
|
199
|
-
const VC = {
|
|
200
|
-
dim: '\x1b[2m', bold: '\x1b[1m', reset: '\x1b[0m',
|
|
201
|
-
cyan: '\x1b[36m', yellow: '\x1b[33m', green: '\x1b[32m', magenta: '\x1b[35m',
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
function formatVerboseEvent(event) {
|
|
205
|
-
switch (event.type) {
|
|
206
|
-
case 'assistant': {
|
|
207
|
-
const msg = event.message;
|
|
208
|
-
if (!msg) return null;
|
|
209
|
-
// Text content
|
|
210
|
-
if (msg.type === 'text' || (typeof msg.content === 'string' && msg.content)) {
|
|
211
|
-
const text = msg.content ?? msg.text ?? '';
|
|
212
|
-
if (text) return `${VC.bold}${text}${VC.reset}`;
|
|
213
|
-
}
|
|
214
|
-
// Tool use
|
|
215
|
-
if (msg.type === 'tool_use' || msg.tool) {
|
|
216
|
-
const name = msg.name ?? msg.tool ?? 'tool';
|
|
217
|
-
const input = msg.input ?? {};
|
|
218
|
-
const detail = input.command ?? input.file_path ?? input.pattern ?? input.query ?? '';
|
|
219
|
-
const short = typeof detail === 'string' ? detail.slice(0, 120) : '';
|
|
220
|
-
return `${VC.cyan}▶ ${name}${VC.reset}${short ? ` ${VC.dim}${short}${VC.reset}` : ''}`;
|
|
221
|
-
}
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
case 'result': {
|
|
225
|
-
const msg = event.message;
|
|
226
|
-
if (msg?.type === 'tool_result') {
|
|
227
|
-
const status = msg.is_error ? `${VC.yellow}✗` : `${VC.green}✓`;
|
|
228
|
-
const content = typeof msg.content === 'string' ? msg.content : '';
|
|
229
|
-
const preview = content.slice(0, 150).replace(/\n/g, ' ');
|
|
230
|
-
return `${status} ${VC.dim}${preview}${VC.reset}`;
|
|
231
|
-
}
|
|
232
|
-
// Final text result
|
|
233
|
-
if (typeof event.result === 'string' && event.result) {
|
|
234
|
-
return `\n${VC.bold}${event.result}${VC.reset}`;
|
|
235
|
-
}
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
default:
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function processStreamLine(line) {
|
|
244
|
-
if (!line.trim()) return null;
|
|
245
|
-
try {
|
|
246
|
-
const event = JSON.parse(line);
|
|
247
|
-
return formatVerboseEvent(event);
|
|
248
|
-
} catch {
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
191
|
// ─── Run Claude ───
|
|
254
192
|
|
|
255
193
|
function runClaude(projectDir, opts) {
|
|
256
194
|
return new Promise((resolvePromise) => {
|
|
257
195
|
let child;
|
|
258
196
|
const isWin = process.platform === 'win32';
|
|
259
|
-
const useStreamJson = opts.verbose;
|
|
260
197
|
|
|
261
198
|
if (isWin) {
|
|
262
199
|
// Windows: claude is a .cmd shim requiring shell execution.
|
|
263
200
|
// cmd.exe mangles quoted arguments, so pipe prompt via stdin instead.
|
|
264
201
|
const permFlag = opts.skipPermissions ? ' --dangerously-skip-permissions' : '';
|
|
265
|
-
|
|
266
|
-
child = spawn(`claude -p --agent orchestrator --max-turns ${opts.maxTurns}${permFlag}${outputFlag}`, [], {
|
|
202
|
+
child = spawn(`claude -p --agent orchestrator --max-turns ${opts.maxTurns}${permFlag}`, [], {
|
|
267
203
|
cwd: projectDir,
|
|
268
|
-
stdio: ['pipe', '
|
|
204
|
+
stdio: ['pipe', 'inherit', 'pipe'],
|
|
269
205
|
shell: true,
|
|
270
206
|
});
|
|
271
207
|
child.stdin.write(PROMPT);
|
|
@@ -273,34 +209,14 @@ function runClaude(projectDir, opts) {
|
|
|
273
209
|
} else {
|
|
274
210
|
const args = ['-p', PROMPT, '--agent', 'orchestrator', '--max-turns', String(opts.maxTurns)];
|
|
275
211
|
if (opts.skipPermissions) args.push('--dangerously-skip-permissions');
|
|
276
|
-
if (useStreamJson) args.push('--output-format', 'stream-json');
|
|
277
212
|
child = spawn('claude', args, {
|
|
278
213
|
cwd: projectDir,
|
|
279
|
-
stdio: ['ignore', '
|
|
214
|
+
stdio: ['ignore', 'inherit', 'pipe'],
|
|
280
215
|
});
|
|
281
216
|
}
|
|
282
217
|
|
|
283
218
|
currentChild = child;
|
|
284
|
-
let stdout = '';
|
|
285
219
|
let stderr = '';
|
|
286
|
-
let lineBuf = '';
|
|
287
|
-
|
|
288
|
-
child.stdout.on('data', chunk => {
|
|
289
|
-
const text = chunk.toString();
|
|
290
|
-
stdout += text;
|
|
291
|
-
|
|
292
|
-
if (useStreamJson) {
|
|
293
|
-
lineBuf += text;
|
|
294
|
-
const lines = lineBuf.split('\n');
|
|
295
|
-
lineBuf = lines.pop(); // keep incomplete last line in buffer
|
|
296
|
-
for (const line of lines) {
|
|
297
|
-
const formatted = processStreamLine(line);
|
|
298
|
-
if (formatted) console.log(formatted);
|
|
299
|
-
}
|
|
300
|
-
} else {
|
|
301
|
-
process.stdout.write(text);
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
220
|
|
|
305
221
|
child.stderr.on('data', chunk => {
|
|
306
222
|
const text = chunk.toString();
|
|
@@ -309,18 +225,13 @@ function runClaude(projectDir, opts) {
|
|
|
309
225
|
});
|
|
310
226
|
|
|
311
227
|
child.on('close', code => {
|
|
312
|
-
// flush remaining buffer
|
|
313
|
-
if (useStreamJson && lineBuf.trim()) {
|
|
314
|
-
const formatted = processStreamLine(lineBuf);
|
|
315
|
-
if (formatted) console.log(formatted);
|
|
316
|
-
}
|
|
317
228
|
currentChild = null;
|
|
318
|
-
resolvePromise({ code,
|
|
229
|
+
resolvePromise({ code, stderr });
|
|
319
230
|
});
|
|
320
231
|
|
|
321
232
|
child.on('error', err => {
|
|
322
233
|
currentChild = null;
|
|
323
|
-
resolvePromise({ code: 1,
|
|
234
|
+
resolvePromise({ code: 1, stderr: err.message });
|
|
324
235
|
});
|
|
325
236
|
});
|
|
326
237
|
}
|
|
@@ -351,7 +262,6 @@ async function main() {
|
|
|
351
262
|
log(`Max iterations: ${opts.maxIterations} | Max turns/iteration: ${opts.maxTurns}`);
|
|
352
263
|
log(`Delay: ${opts.delay}ms | Cooldown: ${opts.cooldown}ms`);
|
|
353
264
|
if (opts.skipPermissions) log('Permissions: skipped (--dangerously-skip-permissions)');
|
|
354
|
-
if (opts.verbose) log('Verbose: streaming live activity');
|
|
355
265
|
log('---');
|
|
356
266
|
|
|
357
267
|
for (let i = 1; i <= opts.maxIterations; i++) {
|