bonzai-burn 1.0.8 → 1.0.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/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.8",
4
- "description": "Git branch-based cleanup tool with btrim and brevert commands",
3
+ "version": "1.0.10",
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": [
@@ -20,6 +21,6 @@
20
21
  },
21
22
  "files": [
22
23
  "src",
23
- "bonzai"
24
+ "payload-bonzai"
24
25
  ]
25
26
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "headlessClaude": true,
3
- "autoModeration": false
3
+ "autoBurn": false
4
4
  }
@@ -0,0 +1,9 @@
1
+ # Bonzai Specs
2
+
3
+ Define your cleanup requirements below. bburn will follow these instructions.
4
+
5
+ ## Requirements:
6
+ - Remove unused imports and variables
7
+ - Split any folder with over 10 items into smaller, compartmentalized folders.
8
+ - Remove all console log statements
9
+ - Split any folder with over 100 lines into smaller files
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();
@@ -12,8 +12,8 @@ const BONZAI_DIR = 'bonzai';
12
12
  const SPECS_FILE = 'specs.md';
13
13
  const CONFIG_FILE = 'config.json';
14
14
 
15
- // Template folder in the package
16
- const TEMPLATE_DIR = join(__dirname, '..', 'bonzai');
15
+ // Template folder in the package (ships as payload-bonzai, copied as bonzai)
16
+ const TEMPLATE_DIR = join(__dirname, '..', 'payload-bonzai');
17
17
 
18
18
  function initializeBonzai() {
19
19
  const bonzaiPath = join(process.cwd(), BONZAI_DIR);
@@ -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
  }
@@ -233,7 +233,7 @@ async function burn() {
233
233
  try {
234
234
  // Initialize bonzai folder and specs.md on first execution
235
235
  initializeBonzai();
236
-
236
+
237
237
  // Ensure bonzai directory and specs file exist
238
238
  const { specsPath, configPath } = ensureBonzaiDir();
239
239
  const specs = loadSpecs(specsPath);
@@ -304,7 +304,7 @@ async function burn() {
304
304
 
305
305
  console.log(`\n✅ Changes applied on: ${burnBranch}`);
306
306
  console.log(`📊 Full diff: git diff ${originalBranch}`);
307
- console.log(`\n✓ Keep changes: git checkout ${originalBranch} && git merge ${burnBranch}`);
307
+ console.log(`\n✓ Keep changes: baccept`);
308
308
  console.log(`✗ Discard: brevert\n`);
309
309
 
310
310
  } 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
@@ -1,24 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
3
- import { join } from 'path';
2
+ import { existsSync, mkdirSync, copyFileSync } from 'fs';
3
+ import { join, dirname } from 'path';
4
+ import { fileURLToPath } from 'url';
4
5
 
5
- const BONZAI_DIR = 'bonzai';
6
- const SPECS_FILE = 'specs.md';
7
-
8
- const DEFAULT_SPECS = `# Bonzai Specs
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
9
8
 
10
- Define your cleanup requirements below. btrim will follow these instructions.
11
-
12
- ## Example:
13
- - Remove unused imports
14
- - Delete files matching pattern "*.tmp"
15
- - Clean up console.log statements
16
- `;
9
+ const BONZAI_DIR = 'bonzai';
10
+ const TEMPLATE_DIR = join(__dirname, '..', 'payload-bonzai');
17
11
 
18
12
  function init() {
19
13
  const currentDir = process.cwd();
20
14
  const bonzaiPath = join(currentDir, BONZAI_DIR);
21
- const specsPath = join(bonzaiPath, SPECS_FILE);
22
15
 
23
16
  if (existsSync(bonzaiPath)) {
24
17
  console.log(`📁 ${BONZAI_DIR}/ already exists`);
@@ -26,10 +19,11 @@ function init() {
26
19
  }
27
20
 
28
21
  mkdirSync(bonzaiPath, { recursive: true });
29
- writeFileSync(specsPath, DEFAULT_SPECS);
30
- console.log(`📁 Created ${BONZAI_DIR}/ folder with specs.md`);
22
+ copyFileSync(join(TEMPLATE_DIR, 'specs.md'), join(bonzaiPath, 'specs.md'));
23
+ copyFileSync(join(TEMPLATE_DIR, 'config.json'), join(bonzaiPath, 'config.json'));
24
+ console.log(`📁 Created ${BONZAI_DIR}/ folder with specs.md and config.json`);
31
25
  console.log(`📝 Edit ${BONZAI_DIR}/specs.md to define your cleanup rules`);
32
- console.log(`🔥 Run 'btrim' to start a cleanup session`);
26
+ console.log(`🔥 Run 'bburn' to start a burn session`);
33
27
  }
34
28
 
35
29
  init();
package/bonzai/specs.md DELETED
@@ -1,8 +0,0 @@
1
- # Bonzai Specs
2
-
3
- Define your cleanup requirements below. btrim will follow these instructions.
4
-
5
- ## Requirements:
6
- - Remove unused imports
7
- - Delete files matching pattern "*.tmp"
8
- - Clean up console.log statements