bonzai-burn 1.0.9 → 1.0.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.
package/README.md CHANGED
@@ -12,10 +12,10 @@ Requires: [Claude Code CLI](https://github.com/anthropics/claude-code)
12
12
 
13
13
  ## Usage
14
14
 
15
- ### 1. Run cleanup
15
+ ### 1. Run burn
16
16
 
17
17
  ```bash
18
- npx btrim
18
+ npx bburn
19
19
  ```
20
20
 
21
21
  Creates `bonzai/specs.md` on first run. Edit it to define your cleanup rules.
@@ -26,11 +26,11 @@ Creates `bonzai/specs.md` on first run. Edit it to define your cleanup rules.
26
26
  git diff main
27
27
  ```
28
28
 
29
- ### 3. Keep or discard
29
+ ### 3. Accept or discard
30
30
 
31
31
  ```bash
32
- # Keep
33
- git checkout main && git merge bonzai-burn
32
+ # Accept
33
+ baccept
34
34
 
35
35
  # Discard
36
36
  brevert
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "bonzai-burn",
3
- "version": "1.0.9",
4
- "description": "Git branch-based cleanup tool with btrim and brevert commands",
3
+ "version": "1.0.11",
4
+ "description": "Git branch-based cleanup tool with bburn, baccept, and brevert commands",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
8
  "bonzai-burn": "./src/index.js",
9
- "btrim": "./src/btrim.js",
9
+ "bburn": "./src/bburn.js",
10
+ "baccept": "./src/baccept.js",
10
11
  "brevert": "./src/brevert.js"
11
12
  },
12
13
  "keywords": [
@@ -1,4 +1,14 @@
1
1
  {
2
2
  "headlessClaude": true,
3
- "autoModeration": false
3
+ "autoBurn": false,
4
+ "lineLimit": {
5
+ "enabled": true,
6
+ "limit": 70,
7
+ "prompt": "Split any file with over {{ linelimit }} lines into smaller files."
8
+ },
9
+ "folderLimit": {
10
+ "enabled": true,
11
+ "limit": 10,
12
+ "prompt": "Split any folder with over {{ folderlimit }} items into smaller, compartmentalized folders."
13
+ }
4
14
  }
@@ -1,8 +1,9 @@
1
1
  # Bonzai Specs
2
2
 
3
- Define your cleanup requirements below. btrim will follow these instructions.
3
+ Define your cleanup requirements below. bburn will follow these instructions.
4
4
 
5
- ## Requirements:
6
- - Remove unused imports
7
- - Delete files matching pattern "*.tmp"
8
- - Clean up console.log statements
5
+ ## Custom Requirements:
6
+ - Remove unused imports and variables
7
+ - Remove all console log statements
8
+ - Split any file with over {{ linelimit }} lines into smaller files
9
+ - Split any folder with over {{ folderlimit }} items into smaller, compartmentalized folders
package/src/baccept.js ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ import { execSync } from 'child_process';
3
+
4
+ function exec(command) {
5
+ return execSync(command, { encoding: 'utf-8', stdio: 'pipe' }).trim();
6
+ }
7
+
8
+ function execVisible(command) {
9
+ execSync(command, { stdio: 'inherit' });
10
+ }
11
+
12
+ async function accept() {
13
+ try {
14
+ // Get saved metadata
15
+ let originalBranch;
16
+ let burnBranch;
17
+ let madeWipCommit;
18
+
19
+ try {
20
+ originalBranch = exec('git config bonzai.originalBranch');
21
+ burnBranch = exec('git config bonzai.burnBranch');
22
+ madeWipCommit = exec('git config bonzai.madeWipCommit') === 'true';
23
+ } catch {
24
+ console.error('❌ No burn to accept');
25
+ console.error('Run bburn first');
26
+ process.exit(1);
27
+ }
28
+
29
+ console.log(`✅ Accepting burn changes...`);
30
+ console.log(` Merging: ${burnBranch} → ${originalBranch}\n`);
31
+
32
+ // Checkout original branch
33
+ execVisible(`git checkout ${originalBranch}`);
34
+
35
+ // Merge burn branch into original
36
+ execVisible(`git merge ${burnBranch} -m "Accept bonzai burn from ${burnBranch}"`);
37
+
38
+ // Delete burn branch
39
+ execVisible(`git branch -D ${burnBranch}`);
40
+
41
+ // If we made a WIP commit, we need to handle it
42
+ // The merge already includes the burn changes on top of the WIP commit
43
+ // So we can optionally squash or leave as-is
44
+ if (madeWipCommit) {
45
+ console.log('\n💡 Note: Your pre-burn WIP commit was preserved in the history.');
46
+ }
47
+
48
+ // Clean up metadata
49
+ exec('git config --unset bonzai.originalBranch');
50
+ exec('git config --unset bonzai.burnBranch');
51
+ exec('git config --unset bonzai.madeWipCommit');
52
+
53
+ console.log(`\n✓ Burn accepted and merged`);
54
+ console.log(`Now on: ${originalBranch}\n`);
55
+
56
+ } catch (error) {
57
+ console.error('❌ Accept failed:', error.message);
58
+ process.exit(1);
59
+ }
60
+ }
61
+
62
+ accept();
@@ -36,7 +36,7 @@ function initializeBonzai() {
36
36
  if (!fs.existsSync(configPath)) {
37
37
  fs.copyFileSync(join(TEMPLATE_DIR, CONFIG_FILE), configPath);
38
38
  console.log(`⚙️ Created ${BONZAI_DIR}/${CONFIG_FILE}`);
39
- console.log(`\n⚠️ Please edit ${BONZAI_DIR}/${SPECS_FILE} to define your cleanup rules before running btrim.\n`);
39
+ console.log(`\n⚠️ Please edit ${BONZAI_DIR}/${SPECS_FILE} to define your cleanup rules before running bburn.\n`);
40
40
  process.exit(0);
41
41
  }
42
42
  }
@@ -73,8 +73,29 @@ function loadConfig(configPath) {
73
73
  }
74
74
  }
75
75
 
76
- function loadSpecs(specsPath) {
77
- const content = fs.readFileSync(specsPath, 'utf-8');
76
+ function loadSpecs(specsPath, config) {
77
+ let content = fs.readFileSync(specsPath, 'utf-8');
78
+
79
+ // Process lineLimit if enabled
80
+ if (config.lineLimit?.enabled) {
81
+ content = content.replace(/\{\{\s*linelimit\s*\}\}/gi, config.lineLimit.limit);
82
+ } else {
83
+ // Remove lines containing {{ linelimit }} if disabled
84
+ content = content.split('\n')
85
+ .filter(line => !/\{\{\s*linelimit\s*\}\}/i.test(line))
86
+ .join('\n');
87
+ }
88
+
89
+ // Process folderLimit if enabled
90
+ if (config.folderLimit?.enabled) {
91
+ content = content.replace(/\{\{\s*folderlimit\s*\}\}/gi, config.folderLimit.limit);
92
+ } else {
93
+ // Remove lines containing {{ folderlimit }} if disabled
94
+ content = content.split('\n')
95
+ .filter(line => !/\{\{\s*folderlimit\s*\}\}/i.test(line))
96
+ .join('\n');
97
+ }
98
+
78
99
  return `You are a code cleanup assistant. Follow these specifications:\n\n${content}`;
79
100
  }
80
101
 
@@ -233,11 +254,11 @@ async function burn() {
233
254
  try {
234
255
  // Initialize bonzai folder and specs.md on first execution
235
256
  initializeBonzai();
236
-
257
+
237
258
  // Ensure bonzai directory and specs file exist
238
259
  const { specsPath, configPath } = ensureBonzaiDir();
239
- const specs = loadSpecs(specsPath);
240
260
  const config = loadConfig(configPath);
261
+ const specs = loadSpecs(specsPath, config);
241
262
 
242
263
  // Check if Claude CLI exists and execute
243
264
  console.log('🔍 Checking for Claude Code CLI...');
@@ -304,7 +325,7 @@ async function burn() {
304
325
 
305
326
  console.log(`\n✅ Changes applied on: ${burnBranch}`);
306
327
  console.log(`📊 Full diff: git diff ${originalBranch}`);
307
- console.log(`\n✓ Keep changes: git checkout ${originalBranch} && git merge ${burnBranch}`);
328
+ console.log(`\n✓ Keep changes: baccept`);
308
329
  console.log(`✗ Discard: brevert\n`);
309
330
 
310
331
  } catch (error) {
package/src/brevert.js CHANGED
@@ -22,7 +22,7 @@ async function revert() {
22
22
  madeWipCommit = exec('git config bonzai.madeWipCommit') === 'true';
23
23
  } catch {
24
24
  console.error('❌ No burn to revert');
25
- console.error('Run btrim first');
25
+ console.error('Run bburn first');
26
26
  process.exit(1);
27
27
  }
28
28
 
package/src/index.js CHANGED
@@ -23,7 +23,7 @@ function init() {
23
23
  copyFileSync(join(TEMPLATE_DIR, 'config.json'), join(bonzaiPath, 'config.json'));
24
24
  console.log(`📁 Created ${BONZAI_DIR}/ folder with specs.md and config.json`);
25
25
  console.log(`📝 Edit ${BONZAI_DIR}/specs.md to define your cleanup rules`);
26
- console.log(`🔥 Run 'btrim' to start a cleanup session`);
26
+ console.log(`🔥 Run 'bburn' to start a burn session`);
27
27
  }
28
28
 
29
29
  init();