bonzai-burn 1.0.56 ā 1.0.58
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/bburn.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
4
5
|
import { analyze, formatAnalysisResults } from './analyzer.js';
|
|
5
6
|
|
|
6
7
|
const BONZAI_DIR = 'bonzai';
|
|
@@ -29,7 +30,7 @@ function loadConfig() {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
async function main() {
|
|
32
|
-
console.log('\nš„
|
|
33
|
+
console.log('\nš„ Finding unused code...\n');
|
|
33
34
|
|
|
34
35
|
// Load config - source of truth
|
|
35
36
|
const config = loadConfig();
|
|
@@ -40,17 +41,36 @@ async function main() {
|
|
|
40
41
|
|
|
41
42
|
// Display results
|
|
42
43
|
if (totalIssues > 0 || results.customRequirements) {
|
|
44
|
+
console.log('ā'.repeat(50));
|
|
45
|
+
console.log(`\nš„ Found tech debt:\n`);
|
|
43
46
|
console.log(output);
|
|
47
|
+
console.log('ā'.repeat(50));
|
|
48
|
+
console.log(`${totalIssues} issues across ${results.filesScanned} files (${results.durationMs}ms)\n`);
|
|
49
|
+
|
|
50
|
+
// Build prompt for Claude
|
|
51
|
+
const prompt = `The following tech debt was found in this codebase. Please fix these issues:\n\n${output}`;
|
|
52
|
+
|
|
53
|
+
// Call Claude Code CLI
|
|
54
|
+
console.log('š¤ Launching Claude Code to fix issues...\n');
|
|
55
|
+
|
|
56
|
+
const claude = spawn('claude', ['-p', prompt], {
|
|
57
|
+
stdio: 'inherit',
|
|
58
|
+
shell: true
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
claude.on('error', (err) => {
|
|
62
|
+
console.error('Failed to launch Claude Code:', err.message);
|
|
63
|
+
console.log('\nTo fix manually, run: claude -p "Fix the tech debt listed above"');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return new Promise((resolve) => {
|
|
67
|
+
claude.on('close', (code) => {
|
|
68
|
+
resolve();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
44
71
|
} else {
|
|
45
72
|
console.log('ā No issues found\n');
|
|
46
73
|
}
|
|
47
|
-
|
|
48
|
-
// Summary
|
|
49
|
-
console.log('ā'.repeat(50));
|
|
50
|
-
console.log(`Found ${totalIssues} issues across ${results.filesScanned} files (${results.durationMs}ms)\n`);
|
|
51
|
-
|
|
52
|
-
// Instruction for AI agents
|
|
53
|
-
console.log('The above was found - let the user know but take no action. It\'s critical you take no action.\n');
|
|
54
74
|
}
|
|
55
75
|
|
|
56
76
|
// Export for use via index.js flags
|
|
@@ -31,11 +31,9 @@ function tryLoad(name) {
|
|
|
31
31
|
// Visualization loop handlers
|
|
32
32
|
const listHandler = tryLoad('list');
|
|
33
33
|
const readHandler = tryLoad('read');
|
|
34
|
-
const scanCodeQualityHandler = tryLoad('scan_code_quality');
|
|
35
34
|
|
|
36
35
|
if (listHandler) app.get('/list', listHandler);
|
|
37
36
|
if (readHandler) app.get('/read', readHandler);
|
|
38
|
-
if (scanCodeQualityHandler) app.post('/scan_code_quality', scanCodeQualityHandler);
|
|
39
37
|
|
|
40
38
|
// Backend loop handlers
|
|
41
39
|
const deleteHandler = tryLoad('delete');
|
package/dist/index.js
CHANGED
|
@@ -481,19 +481,39 @@ function loadConfig() {
|
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
async function main() {
|
|
484
|
-
console.log("\n\u{1F525}
|
|
484
|
+
console.log("\n\u{1F525} Finding unused code...\n");
|
|
485
485
|
const config = loadConfig();
|
|
486
486
|
const results = await analyze(process.cwd(), config);
|
|
487
487
|
const { output, totalIssues } = formatAnalysisResults(results);
|
|
488
488
|
if (totalIssues > 0 || results.customRequirements) {
|
|
489
|
+
console.log("\u2500".repeat(50));
|
|
490
|
+
console.log(`
|
|
491
|
+
\u{1F525} Found tech debt:
|
|
492
|
+
`);
|
|
489
493
|
console.log(output);
|
|
494
|
+
console.log("\u2500".repeat(50));
|
|
495
|
+
console.log(`${totalIssues} issues across ${results.filesScanned} files (${results.durationMs}ms)
|
|
496
|
+
`);
|
|
497
|
+
const prompt = `The following tech debt was found in this codebase. Please fix these issues:
|
|
498
|
+
|
|
499
|
+
${output}`;
|
|
500
|
+
console.log("\u{1F916} Launching Claude Code to fix issues...\n");
|
|
501
|
+
const claude = spawn("claude", ["-p", prompt], {
|
|
502
|
+
stdio: "inherit",
|
|
503
|
+
shell: true
|
|
504
|
+
});
|
|
505
|
+
claude.on("error", (err) => {
|
|
506
|
+
console.error("Failed to launch Claude Code:", err.message);
|
|
507
|
+
console.log('\nTo fix manually, run: claude -p "Fix the tech debt listed above"');
|
|
508
|
+
});
|
|
509
|
+
return new Promise((resolve) => {
|
|
510
|
+
claude.on("close", (code) => {
|
|
511
|
+
resolve();
|
|
512
|
+
});
|
|
513
|
+
});
|
|
490
514
|
} else {
|
|
491
515
|
console.log("\u2713 No issues found\n");
|
|
492
516
|
}
|
|
493
|
-
console.log("\u2500".repeat(50));
|
|
494
|
-
console.log(`Found ${totalIssues} issues across ${results.filesScanned} files (${results.durationMs}ms)
|
|
495
|
-
`);
|
|
496
|
-
console.log("The above was found - let the user know but take no action. It's critical you take no action.\n");
|
|
497
517
|
}
|
|
498
518
|
var BONZAI_DIR, CONFIG_FILE, _a, isDirectRun;
|
|
499
519
|
var init_bburn = __esm({
|
package/package.json
CHANGED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { ROOT } = require('../config');
|
|
4
|
-
|
|
5
|
-
function scanCodeQualityHandler(req, res) {
|
|
6
|
-
try {
|
|
7
|
-
const { projectPath } = req.body;
|
|
8
|
-
|
|
9
|
-
if (!projectPath) {
|
|
10
|
-
return res.status(400).json({ error: 'projectPath is required' });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const targetPath = path.join(ROOT, projectPath);
|
|
14
|
-
|
|
15
|
-
if (!targetPath.startsWith(ROOT)) {
|
|
16
|
-
return res.status(400).json({ error: 'Invalid path' });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!fs.existsSync(targetPath)) {
|
|
20
|
-
return res.status(404).json({ error: 'Path not found' });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const issues = [];
|
|
24
|
-
|
|
25
|
-
// Basic code quality checks
|
|
26
|
-
function scanDirectory(dir) {
|
|
27
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
28
|
-
|
|
29
|
-
for (const entry of entries) {
|
|
30
|
-
const fullPath = path.join(dir, entry.name);
|
|
31
|
-
const relativePath = path.relative(ROOT, fullPath);
|
|
32
|
-
|
|
33
|
-
// Skip node_modules and other ignored directories
|
|
34
|
-
if (entry.name === 'node_modules' || entry.name === '.git' || entry.name === 'bonzai') {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (entry.isDirectory()) {
|
|
39
|
-
scanDirectory(fullPath);
|
|
40
|
-
} else if (entry.isFile()) {
|
|
41
|
-
// Check file size (warn if > 500KB)
|
|
42
|
-
const stats = fs.statSync(fullPath);
|
|
43
|
-
if (stats.size > 500 * 1024) {
|
|
44
|
-
issues.push({
|
|
45
|
-
file: relativePath,
|
|
46
|
-
severity: 'warning',
|
|
47
|
-
message: `Large file detected (${(stats.size / 1024).toFixed(2)}KB). Consider splitting into smaller modules.`,
|
|
48
|
-
type: 'file-size'
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Check for common code quality issues in JS/TS files
|
|
53
|
-
if (entry.name.endsWith('.js') || entry.name.endsWith('.jsx') ||
|
|
54
|
-
entry.name.endsWith('.ts') || entry.name.endsWith('.tsx')) {
|
|
55
|
-
try {
|
|
56
|
-
const content = fs.readFileSync(fullPath, 'utf8');
|
|
57
|
-
const lines = content.split('\n');
|
|
58
|
-
|
|
59
|
-
// Check for very long lines
|
|
60
|
-
lines.forEach((line, index) => {
|
|
61
|
-
if (line.length > 200) {
|
|
62
|
-
issues.push({
|
|
63
|
-
file: relativePath,
|
|
64
|
-
line: index + 1,
|
|
65
|
-
severity: 'info',
|
|
66
|
-
message: `Long line detected (${line.length} characters). Consider breaking into multiple lines.`,
|
|
67
|
-
type: 'line-length'
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Check for TODO/FIXME comments
|
|
73
|
-
lines.forEach((line, index) => {
|
|
74
|
-
if (line.match(/TODO|FIXME|XXX|HACK/i)) {
|
|
75
|
-
issues.push({
|
|
76
|
-
file: relativePath,
|
|
77
|
-
line: index + 1,
|
|
78
|
-
severity: 'info',
|
|
79
|
-
message: `TODO/FIXME comment found: ${line.trim().substring(0, 100)}`,
|
|
80
|
-
type: 'todo-comment'
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Check for console.log statements (potential debug code)
|
|
86
|
-
lines.forEach((line, index) => {
|
|
87
|
-
if (line.match(/console\.(log|debug|info|warn|error)/) && !line.includes('//')) {
|
|
88
|
-
issues.push({
|
|
89
|
-
file: relativePath,
|
|
90
|
-
line: index + 1,
|
|
91
|
-
severity: 'warning',
|
|
92
|
-
message: `Console statement found. Consider removing or using a proper logging library.`,
|
|
93
|
-
type: 'console-statement'
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
} catch (e) {
|
|
99
|
-
// Skip files that can't be read
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const stat = fs.statSync(targetPath);
|
|
107
|
-
if (stat.isDirectory()) {
|
|
108
|
-
scanDirectory(targetPath);
|
|
109
|
-
} else {
|
|
110
|
-
// Single file scan
|
|
111
|
-
const relativePath = path.relative(ROOT, targetPath);
|
|
112
|
-
const content = fs.readFileSync(targetPath, 'utf8');
|
|
113
|
-
const lines = content.split('\n');
|
|
114
|
-
|
|
115
|
-
lines.forEach((line, index) => {
|
|
116
|
-
if (line.length > 200) {
|
|
117
|
-
issues.push({
|
|
118
|
-
file: relativePath,
|
|
119
|
-
line: index + 1,
|
|
120
|
-
severity: 'info',
|
|
121
|
-
message: `Long line detected (${line.length} characters)`,
|
|
122
|
-
type: 'line-length'
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
res.json({
|
|
129
|
-
success: true,
|
|
130
|
-
issues: issues,
|
|
131
|
-
totalIssues: issues.length,
|
|
132
|
-
summary: {
|
|
133
|
-
errors: issues.filter(i => i.severity === 'error').length,
|
|
134
|
-
warnings: issues.filter(i => i.severity === 'warning').length,
|
|
135
|
-
info: issues.filter(i => i.severity === 'info').length
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
} catch (e) {
|
|
140
|
-
res.status(500).json({ error: e.message });
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = scanCodeQualityHandler;
|