bonzai-burn 1.0.13 ā 1.0.14
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/package.json +1 -1
- package/payload-bonzai/config.json +4 -3
- package/src/bburn.js +123 -7
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"provider": "cursor",
|
|
3
|
-
"
|
|
3
|
+
"headless": true,
|
|
4
4
|
"autoBurn": false,
|
|
5
|
+
"autoRun": false,
|
|
5
6
|
"lineLimit": {
|
|
6
|
-
"enabled":
|
|
7
|
+
"enabled": false,
|
|
7
8
|
"limit": 70,
|
|
8
9
|
"prompt": "Split any file with over {{ linelimit }} lines into smaller files."
|
|
9
10
|
},
|
|
10
11
|
"folderLimit": {
|
|
11
|
-
"enabled":
|
|
12
|
+
"enabled": false,
|
|
12
13
|
"limit": 10,
|
|
13
14
|
"prompt": "Split any folder with over {{ folderlimit }} items into smaller, compartmentalized folders."
|
|
14
15
|
}
|
package/src/bburn.js
CHANGED
|
@@ -99,7 +99,7 @@ function loadConfig(configPath) {
|
|
|
99
99
|
const content = fs.readFileSync(configPath, 'utf-8');
|
|
100
100
|
return JSON.parse(content);
|
|
101
101
|
} catch {
|
|
102
|
-
return {
|
|
102
|
+
return { headless: true };
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -148,7 +148,7 @@ function executeClaude(requirements, config) {
|
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
const headless = config.
|
|
151
|
+
const headless = config.headless !== false;
|
|
152
152
|
|
|
153
153
|
// Non-headless mode: run Claude interactively
|
|
154
154
|
if (!headless) {
|
|
@@ -282,8 +282,126 @@ function getToolIcon(toolName) {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
function executeCursor(requirements, config) {
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
// Check if cursor-agent CLI exists
|
|
286
|
+
try {
|
|
287
|
+
execSync('which cursor-agent', { encoding: 'utf-8', stdio: 'pipe' });
|
|
288
|
+
} catch (error) {
|
|
289
|
+
throw new Error(
|
|
290
|
+
'cursor-agent CLI not found.\n' +
|
|
291
|
+
'Install it with: npm install -g cursor-agent'
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const headless = config.headless !== false;
|
|
296
|
+
|
|
297
|
+
// Non-headless mode: run cursor-agent interactively
|
|
298
|
+
if (!headless) {
|
|
299
|
+
console.log('š„ļø Running in interactive mode...\n');
|
|
300
|
+
return new Promise((resolve, reject) => {
|
|
301
|
+
const args = ['-p', requirements];
|
|
302
|
+
|
|
303
|
+
const cursor = spawn('cursor-agent', args, {
|
|
304
|
+
stdio: 'inherit'
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
cursor.on('close', (code) => {
|
|
308
|
+
if (code === 0) {
|
|
309
|
+
resolve();
|
|
310
|
+
} else {
|
|
311
|
+
reject(new Error(`cursor-agent exited with code ${code}`));
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
cursor.on('error', (err) => {
|
|
316
|
+
reject(new Error(`Failed to execute cursor-agent: ${err.message}`));
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Headless mode with token tracking
|
|
322
|
+
let totalInputTokens = 0;
|
|
323
|
+
let totalOutputTokens = 0;
|
|
324
|
+
let lastToolName = '';
|
|
325
|
+
|
|
326
|
+
return new Promise((resolve, reject) => {
|
|
327
|
+
const args = [
|
|
328
|
+
'-p', requirements,
|
|
329
|
+
'--output-format', 'stream-json'
|
|
330
|
+
];
|
|
331
|
+
|
|
332
|
+
const cursor = spawn('cursor-agent', args, {
|
|
333
|
+
stdio: ['inherit', 'pipe', 'pipe']
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
let buffer = '';
|
|
337
|
+
|
|
338
|
+
cursor.stdout.on('data', (data) => {
|
|
339
|
+
buffer += data.toString();
|
|
340
|
+
|
|
341
|
+
// Process complete JSON lines
|
|
342
|
+
const lines = buffer.split('\n');
|
|
343
|
+
buffer = lines.pop(); // Keep incomplete line in buffer
|
|
344
|
+
|
|
345
|
+
for (const line of lines) {
|
|
346
|
+
if (!line.trim()) continue;
|
|
347
|
+
|
|
348
|
+
try {
|
|
349
|
+
const event = JSON.parse(line);
|
|
350
|
+
|
|
351
|
+
// Track tokens from assistant messages
|
|
352
|
+
if (event.type === 'assistant' && event.message?.usage) {
|
|
353
|
+
const usage = event.message.usage;
|
|
354
|
+
if (usage.input_tokens) totalInputTokens += usage.input_tokens;
|
|
355
|
+
if (usage.output_tokens) totalOutputTokens += usage.output_tokens;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Show tool usage updates
|
|
359
|
+
if (event.type === 'content_block_start' && event.content_block?.type === 'tool_use') {
|
|
360
|
+
lastToolName = event.content_block.name || '';
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (event.type === 'content_block_stop' && lastToolName) {
|
|
364
|
+
const icon = getToolIcon(lastToolName);
|
|
365
|
+
console.log(` ${icon} ${lastToolName}`);
|
|
366
|
+
lastToolName = '';
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Show result events with usage info
|
|
370
|
+
if (event.type === 'result') {
|
|
371
|
+
if (event.usage) {
|
|
372
|
+
totalInputTokens = event.usage.input_tokens || totalInputTokens;
|
|
373
|
+
totalOutputTokens = event.usage.output_tokens || totalOutputTokens;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
} catch (e) {
|
|
378
|
+
// Not valid JSON, skip
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
cursor.stderr.on('data', (data) => {
|
|
384
|
+
const msg = data.toString().trim();
|
|
385
|
+
if (msg && !msg.includes('ExperimentalWarning')) {
|
|
386
|
+
console.error(msg);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
cursor.on('close', (code) => {
|
|
391
|
+
// Print token summary
|
|
392
|
+
console.log(`\nš Tokens: ${totalInputTokens.toLocaleString()} in / ${totalOutputTokens.toLocaleString()} out`);
|
|
393
|
+
|
|
394
|
+
if (code === 0) {
|
|
395
|
+
resolve();
|
|
396
|
+
} else {
|
|
397
|
+
reject(new Error(`cursor-agent exited with code ${code}`));
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
cursor.on('error', (err) => {
|
|
402
|
+
reject(new Error(`Failed to execute cursor-agent: ${err.message}`));
|
|
403
|
+
});
|
|
404
|
+
});
|
|
287
405
|
}
|
|
288
406
|
|
|
289
407
|
async function burn() {
|
|
@@ -340,9 +458,7 @@ async function burn() {
|
|
|
340
458
|
|
|
341
459
|
console.log(`š Specs loaded from: ${BONZAI_DIR}/${SPECS_FILE}`);
|
|
342
460
|
console.log(`š¤ Provider: ${provider}`);
|
|
343
|
-
|
|
344
|
-
console.log(`āļø Headless mode: ${config.headlessClaude !== false ? 'on' : 'off'}`);
|
|
345
|
-
}
|
|
461
|
+
console.log(`āļø Headless mode: ${config.headless !== false ? 'on' : 'off'}`);
|
|
346
462
|
console.log('š„ Running Bonzai burn...\n');
|
|
347
463
|
|
|
348
464
|
const startTime = Date.now();
|