bonzai-burn 1.0.0
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/dist/brevert.d.ts +2 -0
- package/dist/brevert.js +51 -0
- package/dist/btrim.d.ts +2 -0
- package/dist/btrim.js +88 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -0
- package/package.json +31 -0
package/dist/brevert.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
function exec(command) {
|
|
6
|
+
return (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
7
|
+
}
|
|
8
|
+
function execVisible(command) {
|
|
9
|
+
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
|
10
|
+
}
|
|
11
|
+
async function revert() {
|
|
12
|
+
try {
|
|
13
|
+
// Get saved metadata
|
|
14
|
+
let originalBranch;
|
|
15
|
+
let burnBranch;
|
|
16
|
+
let madeWipCommit;
|
|
17
|
+
try {
|
|
18
|
+
originalBranch = exec('git config bonzai.originalBranch');
|
|
19
|
+
burnBranch = exec('git config bonzai.burnBranch');
|
|
20
|
+
madeWipCommit = exec('git config bonzai.madeWipCommit') === 'true';
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
console.error('โ No burn to revert');
|
|
24
|
+
console.error('Run btrim first');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
console.log(`๐ Reverting burn...`);
|
|
28
|
+
console.log(` Discarding: ${burnBranch}\n`);
|
|
29
|
+
// Checkout original branch
|
|
30
|
+
execVisible(`git checkout ${originalBranch}`);
|
|
31
|
+
// Delete burn branch
|
|
32
|
+
execVisible(`git branch -D ${burnBranch}`);
|
|
33
|
+
// Undo WIP commit if we made one
|
|
34
|
+
if (madeWipCommit) {
|
|
35
|
+
console.log('โฉ๏ธ Undoing WIP commit...');
|
|
36
|
+
exec('git reset HEAD~1');
|
|
37
|
+
console.log('โ Back to uncommitted changes\n');
|
|
38
|
+
}
|
|
39
|
+
// Clean up metadata
|
|
40
|
+
exec('git config --unset bonzai.originalBranch');
|
|
41
|
+
exec('git config --unset bonzai.burnBranch');
|
|
42
|
+
exec('git config --unset bonzai.madeWipCommit');
|
|
43
|
+
console.log(`โ Burn fully reverted`);
|
|
44
|
+
console.log(`Back on: ${originalBranch}\n`);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error('โ Revert failed:', error.message);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
revert();
|
package/dist/btrim.d.ts
ADDED
package/dist/btrim.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
|
8
|
+
`;
|
|
9
|
+
function exec(command) {
|
|
10
|
+
return (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
11
|
+
}
|
|
12
|
+
function execVisible(command) {
|
|
13
|
+
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
|
14
|
+
}
|
|
15
|
+
async function burn() {
|
|
16
|
+
try {
|
|
17
|
+
// Check if Claude CLI exists
|
|
18
|
+
console.log('๐ Checking for Claude Code CLI...');
|
|
19
|
+
try {
|
|
20
|
+
exec('which claude');
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
console.error('โ Claude Code CLI not found');
|
|
24
|
+
console.error('Install: npm install -g @anthropic-ai/claude-code');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
// Check if in git repo
|
|
28
|
+
try {
|
|
29
|
+
exec('git rev-parse --git-dir');
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
console.error('โ Not a git repository');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
// Get current branch
|
|
36
|
+
const originalBranch = exec('git branch --show-current');
|
|
37
|
+
// Handle uncommitted changes - auto-commit to current branch
|
|
38
|
+
const hasChanges = exec('git status --porcelain') !== '';
|
|
39
|
+
let madeWipCommit = false;
|
|
40
|
+
if (hasChanges) {
|
|
41
|
+
const timestamp = Date.now();
|
|
42
|
+
console.log('๐พ Auto-committing your work...');
|
|
43
|
+
exec('git add -A');
|
|
44
|
+
exec(`git commit -m "WIP: pre-burn checkpoint ${timestamp}"`);
|
|
45
|
+
madeWipCommit = true;
|
|
46
|
+
console.log(`โ Work saved on ${originalBranch}\n`);
|
|
47
|
+
}
|
|
48
|
+
// Always use same burn branch name
|
|
49
|
+
const burnBranch = 'bonzai-burn';
|
|
50
|
+
// Delete existing burn branch if it exists
|
|
51
|
+
try {
|
|
52
|
+
exec(`git branch -D ${burnBranch}`);
|
|
53
|
+
console.log(`๐งน Cleaned up old ${burnBranch} branch\n`);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Branch doesn't exist, that's fine
|
|
57
|
+
}
|
|
58
|
+
console.log(`๐ Starting from: ${originalBranch}`);
|
|
59
|
+
console.log(`๐ฟ Creating: ${burnBranch}\n`);
|
|
60
|
+
// Create burn branch from current position
|
|
61
|
+
exec(`git checkout -b ${burnBranch}`);
|
|
62
|
+
// Save metadata for revert
|
|
63
|
+
exec(`git config bonzai.originalBranch ${originalBranch}`);
|
|
64
|
+
exec(`git config bonzai.burnBranch ${burnBranch}`);
|
|
65
|
+
exec(`git config bonzai.madeWipCommit ${madeWipCommit}`);
|
|
66
|
+
console.log('๐ฅ Running Bonzai burn...\n');
|
|
67
|
+
const startTime = Date.now();
|
|
68
|
+
// Execute Claude
|
|
69
|
+
execVisible(`claude -p "${CLEANUP_REQUIREMENTS}" --allowedTools "Read,Write,Edit,Bash" --permission-mode dontAsk`);
|
|
70
|
+
const duration = Math.round((Date.now() - startTime) / 1000);
|
|
71
|
+
console.log(`\nโ Burn complete (${duration}s)\n`);
|
|
72
|
+
// Commit burn changes
|
|
73
|
+
const burnTimestamp = Date.now();
|
|
74
|
+
exec('git add -A');
|
|
75
|
+
exec(`git commit -m "bonzai burn ${burnTimestamp}" --allow-empty`);
|
|
76
|
+
console.log('Files changed from original:');
|
|
77
|
+
execVisible(`git diff --stat ${originalBranch}..${burnBranch}`);
|
|
78
|
+
console.log(`\nโ
Changes applied on: ${burnBranch}`);
|
|
79
|
+
console.log(`๐ Full diff: git diff ${originalBranch}`);
|
|
80
|
+
console.log(`\nโ Keep changes: git checkout ${originalBranch} && git merge ${burnBranch}`);
|
|
81
|
+
console.log(`โ Discard: brevert\n`);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error('โ Burn failed:', error.message);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
burn();
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
const command = args[0];
|
|
5
|
+
if (command === 'trim' || command === 'btrim') {
|
|
6
|
+
require('./btrim');
|
|
7
|
+
}
|
|
8
|
+
else if (command === 'revert' || command === 'brevert') {
|
|
9
|
+
require('./brevert');
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
console.log(`
|
|
13
|
+
bonzai-burn - Git branch-based cleanup tool
|
|
14
|
+
|
|
15
|
+
Commands:
|
|
16
|
+
bonzai-burn trim Run btrim (create burn branch and cleanup)
|
|
17
|
+
bonzai-burn revert Run brevert (revert burn and return to original)
|
|
18
|
+
|
|
19
|
+
Or use directly:
|
|
20
|
+
btrim Create burn branch and run cleanup
|
|
21
|
+
brevert Revert burn and return to original branch
|
|
22
|
+
`);
|
|
23
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bonzai-burn",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Git branch-based cleanup tool with btrim and brevert commands",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"bonzai-burn": "./dist/index.js",
|
|
8
|
+
"btrim": "./dist/btrim.js",
|
|
9
|
+
"brevert": "./dist/brevert.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"git",
|
|
17
|
+
"cleanup",
|
|
18
|
+
"cli"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^20.0.0",
|
|
23
|
+
"typescript": "^5.0.0"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=16.0.0"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
]
|
|
31
|
+
}
|