bonzai-burn 1.0.0 ā 1.0.1
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 +37 -0
- package/dist/btrim.js +35 -5
- package/package.json +1 -1
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
|
|
6
|
-
|
|
7
|
-
|
|
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 "${
|
|
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
|