bonzai-burn 1.0.0 → 1.0.2

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 ADDED
@@ -0,0 +1,37 @@
1
+ # bonzai-burn
2
+
3
+ Automated code cleanup via Claude Code on a safe git branch.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npx bonzai-burn
9
+ ```
10
+
11
+ Requires: [Claude Code CLI](https://github.com/anthropics/claude-code)
12
+
13
+ ## Usage
14
+
15
+ ### 1. Run cleanup
16
+
17
+ ```bash
18
+ npx btrim
19
+ ```
20
+
21
+ Creates `bonzai/specs.md` on first run. Edit it to define your cleanup rules.
22
+
23
+ ### 2. Review changes
24
+
25
+ ```bash
26
+ git diff main
27
+ ```
28
+
29
+ ### 3. Keep or discard
30
+
31
+ ```bash
32
+ # Keep
33
+ git checkout main && git merge bonzai-burn
34
+
35
+ # Discard
36
+ brevert
37
+ ```
package/dist/btrim.js CHANGED
@@ -2,10 +2,36 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const child_process_1 = require("child_process");
5
- const CLEANUP_REQUIREMENTS = `
6
- You are a code cleanup assistant. Please:
7
- - find any jsx file called "removeme" and remove it
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const BONZAI_DIR = 'bonzai';
8
+ const SPECS_FILE = 'specs.md';
9
+ const DEFAULT_SPECS = `# Bonzai Specs
10
+
11
+ Define your cleanup requirements below. btrim will follow these instructions.
12
+
13
+ ## Example:
14
+ - Remove unused imports
15
+ - Delete files matching pattern "*.tmp"
16
+ - Clean up console.log statements
8
17
  `;
18
+ function ensureBonzaiDir() {
19
+ const bonzaiPath = (0, path_1.join)(process.cwd(), BONZAI_DIR);
20
+ const specsPath = (0, path_1.join)(bonzaiPath, SPECS_FILE);
21
+ if (!(0, fs_1.existsSync)(bonzaiPath)) {
22
+ (0, fs_1.mkdirSync)(bonzaiPath, { recursive: true });
23
+ console.log(`šŸ“ Created ${BONZAI_DIR}/ folder\n`);
24
+ }
25
+ if (!(0, fs_1.existsSync)(specsPath)) {
26
+ (0, fs_1.writeFileSync)(specsPath, DEFAULT_SPECS);
27
+ console.log(`šŸ“ Created ${BONZAI_DIR}/${SPECS_FILE} - edit this file to define your cleanup specs\n`);
28
+ }
29
+ return specsPath;
30
+ }
31
+ function loadSpecs(specsPath) {
32
+ const content = (0, fs_1.readFileSync)(specsPath, 'utf-8');
33
+ return `You are a code cleanup assistant. Follow these specifications:\n\n${content}`;
34
+ }
9
35
  function exec(command) {
10
36
  return (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: 'pipe' }).trim();
11
37
  }
@@ -14,6 +40,9 @@ function execVisible(command) {
14
40
  }
15
41
  async function burn() {
16
42
  try {
43
+ // Ensure bonzai directory and specs file exist
44
+ const specsPath = ensureBonzaiDir();
45
+ const specs = loadSpecs(specsPath);
17
46
  // Check if Claude CLI exists
18
47
  console.log('šŸ” Checking for Claude Code CLI...');
19
48
  try {
@@ -63,10 +92,11 @@ async function burn() {
63
92
  exec(`git config bonzai.originalBranch ${originalBranch}`);
64
93
  exec(`git config bonzai.burnBranch ${burnBranch}`);
65
94
  exec(`git config bonzai.madeWipCommit ${madeWipCommit}`);
95
+ console.log(`šŸ“‹ Specs loaded from: ${BONZAI_DIR}/${SPECS_FILE}`);
66
96
  console.log('šŸ”„ Running Bonzai burn...\n');
67
97
  const startTime = Date.now();
68
- // Execute Claude
69
- execVisible(`claude -p "${CLEANUP_REQUIREMENTS}" --allowedTools "Read,Write,Edit,Bash" --permission-mode dontAsk`);
98
+ // Execute Claude with specs from bonzai/specs.md
99
+ execVisible(`claude -p "${specs.replace(/"/g, '\\"')}" --allowedTools "Read,Write,Edit,Bash" --permission-mode dontAsk`);
70
100
  const duration = Math.round((Date.now() - startTime) / 1000);
71
101
  console.log(`\nāœ“ Burn complete (${duration}s)\n`);
72
102
  // Commit burn changes
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const BONZAI_DIR = 'bonzai';
7
+ const SPECS_FILE = 'specs.md';
8
+ const DEFAULT_SPECS = `# Bonzai Specs
9
+
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
+ `;
17
+ function findProjectRoot() {
18
+ // npm sets INIT_CWD to the directory where npm was invoked
19
+ const initCwd = process.env.INIT_CWD;
20
+ if (initCwd && (0, fs_1.existsSync)((0, path_1.join)(initCwd, 'package.json'))) {
21
+ return initCwd;
22
+ }
23
+ // Fallback: try to find project root from cwd
24
+ let current = process.cwd();
25
+ // If we're in node_modules, go up to find project root
26
+ if (current.includes('node_modules')) {
27
+ const nodeModulesIndex = current.lastIndexOf('node_modules');
28
+ const projectRoot = current.substring(0, nodeModulesIndex - 1);
29
+ if ((0, fs_1.existsSync)((0, path_1.join)(projectRoot, 'package.json'))) {
30
+ return projectRoot;
31
+ }
32
+ }
33
+ return null;
34
+ }
35
+ function postinstall() {
36
+ const projectRoot = findProjectRoot();
37
+ if (!projectRoot) {
38
+ // Silently exit if we can't find project root (e.g., global install)
39
+ return;
40
+ }
41
+ const bonzaiPath = (0, path_1.join)(projectRoot, BONZAI_DIR);
42
+ const specsPath = (0, path_1.join)(bonzaiPath, SPECS_FILE);
43
+ // Don't overwrite existing setup
44
+ if ((0, fs_1.existsSync)(bonzaiPath)) {
45
+ return;
46
+ }
47
+ try {
48
+ (0, fs_1.mkdirSync)(bonzaiPath, { recursive: true });
49
+ (0, fs_1.writeFileSync)(specsPath, DEFAULT_SPECS);
50
+ console.log(`\nšŸ“ Created ${BONZAI_DIR}/ folder with specs.md`);
51
+ console.log(`šŸ“ Edit ${BONZAI_DIR}/specs.md to define your cleanup rules`);
52
+ console.log(`šŸ”„ Run 'btrim' to start a cleanup session\n`);
53
+ }
54
+ catch (error) {
55
+ // Silently fail - don't break the install
56
+ }
57
+ }
58
+ postinstall();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bonzai-burn",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Git branch-based cleanup tool with btrim and brevert commands",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -10,7 +10,8 @@
10
10
  },
11
11
  "scripts": {
12
12
  "build": "tsc",
13
- "prepublishOnly": "npm run build"
13
+ "prepublishOnly": "npm run build",
14
+ "postinstall": "node dist/postinstall.js"
14
15
  },
15
16
  "keywords": [
16
17
  "git",