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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -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();
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
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();
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ declare const args: string[];
3
+ declare const command: string;
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
+ }