bonzai-burn 1.0.2 โ 1.0.3
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/package.json +7 -15
- package/src/brevert.js +59 -0
- package/src/btrim.js +142 -0
- package/src/index.js +35 -0
- package/dist/brevert.d.ts +0 -2
- package/dist/brevert.js +0 -51
- package/dist/btrim.d.ts +0 -2
- package/dist/btrim.js +0 -118
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -23
- package/dist/postinstall.d.ts +0 -2
- package/dist/postinstall.js +0 -58
package/package.json
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bonzai-burn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Git branch-based cleanup tool with btrim and brevert commands",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
6
7
|
"bin": {
|
|
7
|
-
"bonzai-burn": "./
|
|
8
|
-
"btrim": "./
|
|
9
|
-
"brevert": "./
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"prepublishOnly": "npm run build",
|
|
14
|
-
"postinstall": "node dist/postinstall.js"
|
|
8
|
+
"bonzai-burn": "./src/index.js",
|
|
9
|
+
"btrim": "./src/btrim.js",
|
|
10
|
+
"brevert": "./src/brevert.js"
|
|
15
11
|
},
|
|
16
12
|
"keywords": [
|
|
17
13
|
"git",
|
|
@@ -19,14 +15,10 @@
|
|
|
19
15
|
"cli"
|
|
20
16
|
],
|
|
21
17
|
"license": "MIT",
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@types/node": "^20.0.0",
|
|
24
|
-
"typescript": "^5.0.0"
|
|
25
|
-
},
|
|
26
18
|
"engines": {
|
|
27
19
|
"node": ">=16.0.0"
|
|
28
20
|
},
|
|
29
21
|
"files": [
|
|
30
|
-
"
|
|
22
|
+
"src"
|
|
31
23
|
]
|
|
32
24
|
}
|
package/src/brevert.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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 revert() {
|
|
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 revert');
|
|
25
|
+
console.error('Run btrim first');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log(`๐ Reverting burn...`);
|
|
30
|
+
console.log(` Discarding: ${burnBranch}\n`);
|
|
31
|
+
|
|
32
|
+
// Checkout original branch
|
|
33
|
+
execVisible(`git checkout ${originalBranch}`);
|
|
34
|
+
|
|
35
|
+
// Delete burn branch
|
|
36
|
+
execVisible(`git branch -D ${burnBranch}`);
|
|
37
|
+
|
|
38
|
+
// Undo WIP commit if we made one
|
|
39
|
+
if (madeWipCommit) {
|
|
40
|
+
console.log('โฉ๏ธ Undoing WIP commit...');
|
|
41
|
+
exec('git reset HEAD~1');
|
|
42
|
+
console.log('โ Back to uncommitted changes\n');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Clean up metadata
|
|
46
|
+
exec('git config --unset bonzai.originalBranch');
|
|
47
|
+
exec('git config --unset bonzai.burnBranch');
|
|
48
|
+
exec('git config --unset bonzai.madeWipCommit');
|
|
49
|
+
|
|
50
|
+
console.log(`โ Burn fully reverted`);
|
|
51
|
+
console.log(`Back on: ${originalBranch}\n`);
|
|
52
|
+
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('โ Revert failed:', error.message);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
revert();
|
package/src/btrim.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
const BONZAI_DIR = 'bonzai';
|
|
7
|
+
const SPECS_FILE = 'specs.md';
|
|
8
|
+
|
|
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
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
function ensureBonzaiDir() {
|
|
20
|
+
const bonzaiPath = join(process.cwd(), BONZAI_DIR);
|
|
21
|
+
const specsPath = join(bonzaiPath, SPECS_FILE);
|
|
22
|
+
|
|
23
|
+
if (!existsSync(bonzaiPath)) {
|
|
24
|
+
mkdirSync(bonzaiPath, { recursive: true });
|
|
25
|
+
console.log(`๐ Created ${BONZAI_DIR}/ folder\n`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!existsSync(specsPath)) {
|
|
29
|
+
writeFileSync(specsPath, DEFAULT_SPECS);
|
|
30
|
+
console.log(`๐ Created ${BONZAI_DIR}/${SPECS_FILE} - edit this file to define your cleanup specs\n`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return specsPath;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function loadSpecs(specsPath) {
|
|
37
|
+
const content = readFileSync(specsPath, 'utf-8');
|
|
38
|
+
return `You are a code cleanup assistant. Follow these specifications:\n\n${content}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function exec(command) {
|
|
42
|
+
return execSync(command, { encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function execVisible(command) {
|
|
46
|
+
execSync(command, { stdio: 'inherit' });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function burn() {
|
|
50
|
+
try {
|
|
51
|
+
// Ensure bonzai directory and specs file exist
|
|
52
|
+
const specsPath = ensureBonzaiDir();
|
|
53
|
+
const specs = loadSpecs(specsPath);
|
|
54
|
+
|
|
55
|
+
// Check if Claude CLI exists
|
|
56
|
+
console.log('๐ Checking for Claude Code CLI...');
|
|
57
|
+
try {
|
|
58
|
+
exec('which claude');
|
|
59
|
+
} catch {
|
|
60
|
+
console.error('โ Claude Code CLI not found');
|
|
61
|
+
console.error('Install: npm install -g @anthropic-ai/claude-code');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Check if in git repo
|
|
66
|
+
try {
|
|
67
|
+
exec('git rev-parse --git-dir');
|
|
68
|
+
} catch {
|
|
69
|
+
console.error('โ Not a git repository');
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Get current branch
|
|
74
|
+
const originalBranch = exec('git branch --show-current');
|
|
75
|
+
|
|
76
|
+
// Handle uncommitted changes - auto-commit to current branch
|
|
77
|
+
const hasChanges = exec('git status --porcelain') !== '';
|
|
78
|
+
let madeWipCommit = false;
|
|
79
|
+
|
|
80
|
+
if (hasChanges) {
|
|
81
|
+
const timestamp = Date.now();
|
|
82
|
+
console.log('๐พ Auto-committing your work...');
|
|
83
|
+
exec('git add -A');
|
|
84
|
+
exec(`git commit -m "WIP: pre-burn checkpoint ${timestamp}"`);
|
|
85
|
+
madeWipCommit = true;
|
|
86
|
+
console.log(`โ Work saved on ${originalBranch}\n`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Always use same burn branch name
|
|
90
|
+
const burnBranch = 'bonzai-burn';
|
|
91
|
+
|
|
92
|
+
// Delete existing burn branch if it exists
|
|
93
|
+
try {
|
|
94
|
+
exec(`git branch -D ${burnBranch}`);
|
|
95
|
+
console.log(`๐งน Cleaned up old ${burnBranch} branch\n`);
|
|
96
|
+
} catch {
|
|
97
|
+
// Branch doesn't exist, that's fine
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log(`๐ Starting from: ${originalBranch}`);
|
|
101
|
+
console.log(`๐ฟ Creating: ${burnBranch}\n`);
|
|
102
|
+
|
|
103
|
+
// Create burn branch from current position
|
|
104
|
+
exec(`git checkout -b ${burnBranch}`);
|
|
105
|
+
|
|
106
|
+
// Save metadata for revert
|
|
107
|
+
exec(`git config bonzai.originalBranch ${originalBranch}`);
|
|
108
|
+
exec(`git config bonzai.burnBranch ${burnBranch}`);
|
|
109
|
+
exec(`git config bonzai.madeWipCommit ${madeWipCommit}`);
|
|
110
|
+
|
|
111
|
+
console.log(`๐ Specs loaded from: ${BONZAI_DIR}/${SPECS_FILE}`);
|
|
112
|
+
console.log('๐ฅ Running Bonzai burn...\n');
|
|
113
|
+
|
|
114
|
+
const startTime = Date.now();
|
|
115
|
+
|
|
116
|
+
// Execute Claude with specs from bonzai/specs.md
|
|
117
|
+
execVisible(`claude -p "${specs.replace(/"/g, '\\"')}" --allowedTools "Read,Write,Edit,Bash" --permission-mode dontAsk`);
|
|
118
|
+
|
|
119
|
+
const duration = Math.round((Date.now() - startTime) / 1000);
|
|
120
|
+
|
|
121
|
+
console.log(`\nโ Burn complete (${duration}s)\n`);
|
|
122
|
+
|
|
123
|
+
// Commit burn changes
|
|
124
|
+
const burnTimestamp = Date.now();
|
|
125
|
+
exec('git add -A');
|
|
126
|
+
exec(`git commit -m "bonzai burn ${burnTimestamp}" --allow-empty`);
|
|
127
|
+
|
|
128
|
+
console.log('Files changed from original:');
|
|
129
|
+
execVisible(`git diff --stat ${originalBranch}..${burnBranch}`);
|
|
130
|
+
|
|
131
|
+
console.log(`\nโ
Changes applied on: ${burnBranch}`);
|
|
132
|
+
console.log(`๐ Full diff: git diff ${originalBranch}`);
|
|
133
|
+
console.log(`\nโ Keep changes: git checkout ${originalBranch} && git merge ${burnBranch}`);
|
|
134
|
+
console.log(`โ Discard: brevert\n`);
|
|
135
|
+
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error('โ Burn failed:', error.message);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
burn();
|
package/src/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
|
|
5
|
+
const BONZAI_DIR = 'bonzai';
|
|
6
|
+
const SPECS_FILE = 'specs.md';
|
|
7
|
+
|
|
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
|
+
|
|
18
|
+
function init() {
|
|
19
|
+
const currentDir = process.cwd();
|
|
20
|
+
const bonzaiPath = join(currentDir, BONZAI_DIR);
|
|
21
|
+
const specsPath = join(bonzaiPath, SPECS_FILE);
|
|
22
|
+
|
|
23
|
+
if (existsSync(bonzaiPath)) {
|
|
24
|
+
console.log(`๐ ${BONZAI_DIR}/ already exists`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
mkdirSync(bonzaiPath, { recursive: true });
|
|
29
|
+
writeFileSync(specsPath, DEFAULT_SPECS);
|
|
30
|
+
console.log(`๐ Created ${BONZAI_DIR}/ folder with specs.md`);
|
|
31
|
+
console.log(`๐ Edit ${BONZAI_DIR}/specs.md to define your cleanup rules`);
|
|
32
|
+
console.log(`๐ฅ Run 'btrim' to start a cleanup session`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
init();
|
package/dist/brevert.d.ts
DELETED
package/dist/brevert.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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
DELETED
package/dist/btrim.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
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 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
|
|
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
|
-
}
|
|
35
|
-
function exec(command) {
|
|
36
|
-
return (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
37
|
-
}
|
|
38
|
-
function execVisible(command) {
|
|
39
|
-
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
|
40
|
-
}
|
|
41
|
-
async function burn() {
|
|
42
|
-
try {
|
|
43
|
-
// Ensure bonzai directory and specs file exist
|
|
44
|
-
const specsPath = ensureBonzaiDir();
|
|
45
|
-
const specs = loadSpecs(specsPath);
|
|
46
|
-
// Check if Claude CLI exists
|
|
47
|
-
console.log('๐ Checking for Claude Code CLI...');
|
|
48
|
-
try {
|
|
49
|
-
exec('which claude');
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
console.error('โ Claude Code CLI not found');
|
|
53
|
-
console.error('Install: npm install -g @anthropic-ai/claude-code');
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
// Check if in git repo
|
|
57
|
-
try {
|
|
58
|
-
exec('git rev-parse --git-dir');
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
console.error('โ Not a git repository');
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
// Get current branch
|
|
65
|
-
const originalBranch = exec('git branch --show-current');
|
|
66
|
-
// Handle uncommitted changes - auto-commit to current branch
|
|
67
|
-
const hasChanges = exec('git status --porcelain') !== '';
|
|
68
|
-
let madeWipCommit = false;
|
|
69
|
-
if (hasChanges) {
|
|
70
|
-
const timestamp = Date.now();
|
|
71
|
-
console.log('๐พ Auto-committing your work...');
|
|
72
|
-
exec('git add -A');
|
|
73
|
-
exec(`git commit -m "WIP: pre-burn checkpoint ${timestamp}"`);
|
|
74
|
-
madeWipCommit = true;
|
|
75
|
-
console.log(`โ Work saved on ${originalBranch}\n`);
|
|
76
|
-
}
|
|
77
|
-
// Always use same burn branch name
|
|
78
|
-
const burnBranch = 'bonzai-burn';
|
|
79
|
-
// Delete existing burn branch if it exists
|
|
80
|
-
try {
|
|
81
|
-
exec(`git branch -D ${burnBranch}`);
|
|
82
|
-
console.log(`๐งน Cleaned up old ${burnBranch} branch\n`);
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
// Branch doesn't exist, that's fine
|
|
86
|
-
}
|
|
87
|
-
console.log(`๐ Starting from: ${originalBranch}`);
|
|
88
|
-
console.log(`๐ฟ Creating: ${burnBranch}\n`);
|
|
89
|
-
// Create burn branch from current position
|
|
90
|
-
exec(`git checkout -b ${burnBranch}`);
|
|
91
|
-
// Save metadata for revert
|
|
92
|
-
exec(`git config bonzai.originalBranch ${originalBranch}`);
|
|
93
|
-
exec(`git config bonzai.burnBranch ${burnBranch}`);
|
|
94
|
-
exec(`git config bonzai.madeWipCommit ${madeWipCommit}`);
|
|
95
|
-
console.log(`๐ Specs loaded from: ${BONZAI_DIR}/${SPECS_FILE}`);
|
|
96
|
-
console.log('๐ฅ Running Bonzai burn...\n');
|
|
97
|
-
const startTime = Date.now();
|
|
98
|
-
// Execute Claude with specs from bonzai/specs.md
|
|
99
|
-
execVisible(`claude -p "${specs.replace(/"/g, '\\"')}" --allowedTools "Read,Write,Edit,Bash" --permission-mode dontAsk`);
|
|
100
|
-
const duration = Math.round((Date.now() - startTime) / 1000);
|
|
101
|
-
console.log(`\nโ Burn complete (${duration}s)\n`);
|
|
102
|
-
// Commit burn changes
|
|
103
|
-
const burnTimestamp = Date.now();
|
|
104
|
-
exec('git add -A');
|
|
105
|
-
exec(`git commit -m "bonzai burn ${burnTimestamp}" --allow-empty`);
|
|
106
|
-
console.log('Files changed from original:');
|
|
107
|
-
execVisible(`git diff --stat ${originalBranch}..${burnBranch}`);
|
|
108
|
-
console.log(`\nโ
Changes applied on: ${burnBranch}`);
|
|
109
|
-
console.log(`๐ Full diff: git diff ${originalBranch}`);
|
|
110
|
-
console.log(`\nโ Keep changes: git checkout ${originalBranch} && git merge ${burnBranch}`);
|
|
111
|
-
console.log(`โ Discard: brevert\n`);
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
console.error('โ Burn failed:', error.message);
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
burn();
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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/dist/postinstall.d.ts
DELETED
package/dist/postinstall.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
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();
|