bonzai-burn 1.0.33 → 1.0.36

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bonzai-burn",
3
- "version": "1.0.33",
3
+ "version": "1.0.36",
4
4
  "description": "Git branch-based cleanup tool with bburn, baccept, and brevert commands",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/bburn.js CHANGED
@@ -53,7 +53,14 @@ async function main() {
53
53
  console.log('The above was found - let the user know but take no action. It\'s critical you take no action.\n');
54
54
  }
55
55
 
56
- main().catch((error) => {
57
- console.error('Error:', error.message);
58
- process.exit(1);
59
- });
56
+ // Export for use via index.js flags
57
+ export { main };
58
+
59
+ // Run directly if called as standalone command
60
+ const isDirectRun = process.argv[1]?.endsWith('bburn.js');
61
+ if (isDirectRun) {
62
+ main().catch((error) => {
63
+ console.error('Error:', error.message);
64
+ process.exit(1);
65
+ });
66
+ }
package/src/bgraph.js CHANGED
@@ -192,4 +192,11 @@ async function main() {
192
192
  });
193
193
  }
194
194
 
195
- main().catch(console.error);
195
+ // Export for use via index.js flags
196
+ export { main };
197
+
198
+ // Run directly if called as standalone command
199
+ const isDirectRun = process.argv[1]?.endsWith('bgraph.js');
200
+ if (isDirectRun) {
201
+ main().catch(console.error);
202
+ }
package/src/bhook.js CHANGED
@@ -152,29 +152,38 @@ function showStatus() {
152
152
  }
153
153
  }
154
154
 
155
- async function main() {
156
- const args = process.argv.slice(2);
155
+ async function main(subArgs = []) {
156
+ // Use passed args or fall back to process.argv
157
+ const args = subArgs.length > 0 ? subArgs : process.argv.slice(2);
157
158
  const command = args[0];
158
159
 
159
160
  switch (command) {
160
- case 'install':
161
- installHook();
162
- break;
163
161
  case 'uninstall':
164
162
  case 'remove':
163
+ case '-u':
165
164
  uninstallHook();
166
165
  break;
167
166
  case 'status':
168
- default:
167
+ case '-s':
169
168
  showStatus();
170
- if (!command) {
171
- console.log('Commands: bhook install | bhook uninstall | bhook status\n');
172
- }
169
+ break;
170
+ case 'install':
171
+ case '-i':
172
+ default:
173
+ // Default action is to install (like bburn runs analysis by default)
174
+ installHook();
173
175
  break;
174
176
  }
175
177
  }
176
178
 
177
- main().catch((error) => {
178
- console.error('Error:', error.message);
179
- process.exit(1);
180
- });
179
+ // Export for use via index.js flags
180
+ export { main };
181
+
182
+ // Run directly if called as standalone command
183
+ const isDirectRun = process.argv[1]?.endsWith('bhook.js');
184
+ if (isDirectRun) {
185
+ main().catch((error) => {
186
+ console.error('Error:', error.message);
187
+ process.exit(1);
188
+ });
189
+ }
package/src/index.js CHANGED
@@ -9,6 +9,34 @@ const __dirname = dirname(__filename);
9
9
  const BONZAI_DIR = 'bonzai';
10
10
  const TEMPLATE_DIR = join(__dirname, '..', 'payload-bonzai');
11
11
 
12
+ function showHelp() {
13
+ console.log(`
14
+ 🌳 Bonzai Burn - Code Analysis Tool
15
+
16
+ Usage: npx bonzai-burn [option]
17
+
18
+ Options:
19
+ (no option) Initialize bonzai in current directory
20
+ -b, --burn Run code analysis (bburn)
21
+ -g, --graph Launch visualization server (bgraph)
22
+ -h, --hook Manage Claude Code stop hook (bhook)
23
+ --help Show this help message
24
+
25
+ Hook subcommands (-h):
26
+ -h Install hook (default)
27
+ -h -i Install hook
28
+ -h -s Show hook status
29
+ -h -u Uninstall hook
30
+
31
+ Examples:
32
+ npx bonzai-burn # Initialize bonzai folder
33
+ npx bonzai-burn -b # Run burn analysis
34
+ npx bonzai-burn -g # Start graph server
35
+ npx bonzai-burn -h # Install hook
36
+ npx bonzai-burn -h -s # Check hook status
37
+ `);
38
+ }
39
+
12
40
  function init() {
13
41
  const currentDir = process.cwd();
14
42
  const bonzaiPath = join(currentDir, BONZAI_DIR);
@@ -22,13 +50,50 @@ function init() {
22
50
  copyFileSync(join(TEMPLATE_DIR, 'config.json'), join(bonzaiPath, 'config.json'));
23
51
  console.log(`📁 Created ${BONZAI_DIR}/ folder with config.json`);
24
52
  console.log(`📝 Edit ${BONZAI_DIR}/config.json to configure your burn rules`);
25
- console.log(`🔥 Run 'bburn' to analyze your codebase`);
53
+ console.log(`🔥 Run 'npx bonzai-burn -b' to analyze your codebase`);
26
54
  console.log('');
27
55
  console.log('┌─────────────────────────────────────────────────────────────┐');
28
56
  console.log('│ │');
29
- console.log('│ 🌳 Run `bgraph` to configure provider, frequency & more │');
57
+ console.log('│ 🌳 Run `npx bonzai-burn -g` to visualize your codebase │');
30
58
  console.log('│ │');
31
59
  console.log('└─────────────────────────────────────────────────────────────┘');
32
60
  }
33
61
 
34
- init();
62
+ async function main() {
63
+ const args = process.argv.slice(2);
64
+ const flag = args[0];
65
+
66
+ switch (flag) {
67
+ case '-b':
68
+ case '--burn': {
69
+ const { main: burnMain } = await import('./bburn.js');
70
+ if (burnMain) await burnMain();
71
+ break;
72
+ }
73
+ case '-g':
74
+ case '--graph': {
75
+ const { main: graphMain } = await import('./bgraph.js');
76
+ if (graphMain) await graphMain();
77
+ break;
78
+ }
79
+ case '-h':
80
+ case '--hook': {
81
+ const { main: hookMain } = await import('./bhook.js');
82
+ // Pass remaining args as subcommands (e.g., -h -s → ['-s'])
83
+ const subArgs = args.slice(1);
84
+ if (hookMain) await hookMain(subArgs);
85
+ break;
86
+ }
87
+ case '--help':
88
+ showHelp();
89
+ break;
90
+ default:
91
+ init();
92
+ break;
93
+ }
94
+ }
95
+
96
+ main().catch((error) => {
97
+ console.error('Error:', error.message);
98
+ process.exit(1);
99
+ });