bonzai-burn 1.0.13 → 1.0.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bonzai-burn",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Git branch-based cleanup tool with bburn, baccept, and brevert commands",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "provider": "cursor",
3
- "headlessClaude": true,
3
+ "debugMode": true,
4
4
  "autoBurn": false,
5
+ "autoRun": false,
5
6
  "lineLimit": {
6
- "enabled": true,
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": true,
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 { headlessClaude: true };
102
+ return { debugMode: false };
103
103
  }
104
104
  }
105
105
 
@@ -148,11 +148,11 @@ function executeClaude(requirements, config) {
148
148
  );
149
149
  }
150
150
 
151
- const headless = config.headlessClaude !== false;
151
+ const debugMode = config.debugMode === true || config.debugMode === 'true';
152
152
 
153
- // Non-headless mode: run Claude interactively
154
- if (!headless) {
155
- console.log('šŸ–„ļø Running in interactive mode...\n');
153
+ // Debug mode: run Claude with visible output
154
+ if (debugMode) {
155
+ console.log('šŸ› Running in debug mode...\n');
156
156
  return new Promise((resolve, reject) => {
157
157
  const args = [
158
158
  '-p', requirements,
@@ -282,8 +282,126 @@ function getToolIcon(toolName) {
282
282
  }
283
283
 
284
284
  function executeCursor(requirements, config) {
285
- console.log('šŸ”„ Burning through Cursor...');
286
- return Promise.resolve();
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 debugMode = config.debugMode === true || config.debugMode === 'true';
296
+
297
+ // Debug mode: run cursor-agent with verbose output
298
+ if (debugMode) {
299
+ console.log('šŸ› Running in debug 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
- if (provider === 'claude') {
344
- console.log(`āš™ļø Headless mode: ${config.headlessClaude !== false ? 'on' : 'off'}`);
345
- }
461
+ console.log(`šŸ› Debug mode: ${config.debugMode === true || config.debugMode === 'true' ? 'on' : 'off'}`);
346
462
  console.log('šŸ”„ Running Bonzai burn...\n');
347
463
 
348
464
  const startTime = Date.now();