devbonzai 2.1.7 → 2.1.9

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/cli.js CHANGED
@@ -11,6 +11,29 @@ const IGNORE_FILE_CONTENT = fs.readFileSync(
11
11
  const RECEIVER_JS_CONTENT = fs.readFileSync(
12
12
  path.join(__dirname, 'templates', 'receiver.js'), 'utf8'
13
13
  );
14
+ const CONFIG_JS_CONTENT = fs.readFileSync(
15
+ path.join(__dirname, 'templates', 'config.js'), 'utf8'
16
+ );
17
+
18
+ // Helper function to recursively copy directory
19
+ function copyDirectory(src, dest) {
20
+ if (!fs.existsSync(dest)) {
21
+ fs.mkdirSync(dest, { recursive: true });
22
+ }
23
+
24
+ const entries = fs.readdirSync(src, { withFileTypes: true });
25
+
26
+ for (const entry of entries) {
27
+ const srcPath = path.join(src, entry.name);
28
+ const destPath = path.join(dest, entry.name);
29
+
30
+ if (entry.isDirectory()) {
31
+ copyDirectory(srcPath, destPath);
32
+ } else {
33
+ fs.copyFileSync(srcPath, destPath);
34
+ }
35
+ }
36
+ }
14
37
 
15
38
  async function main() {
16
39
  const currentDir = process.cwd();
@@ -32,6 +55,23 @@ async function main() {
32
55
  // Make it executable
33
56
  fs.chmodSync(receiverPath, '755');
34
57
 
58
+ // Write config.js
59
+ console.log('📝 Writing config.js...');
60
+ const configPath = path.join(bonzaiDir, 'config.js');
61
+ fs.writeFileSync(configPath, CONFIG_JS_CONTENT);
62
+
63
+ // Copy handlers directory
64
+ console.log('📝 Copying handlers directory...');
65
+ const handlersSrc = path.join(__dirname, 'templates', 'handlers');
66
+ const handlersDest = path.join(bonzaiDir, 'handlers');
67
+ copyDirectory(handlersSrc, handlersDest);
68
+
69
+ // Copy utils directory
70
+ console.log('📝 Copying utils directory...');
71
+ const utilsSrc = path.join(__dirname, 'templates', 'utils');
72
+ const utilsDest = path.join(bonzaiDir, 'utils');
73
+ copyDirectory(utilsSrc, utilsDest);
74
+
35
75
  // Write .ignore file in bonzai directory
36
76
  const ignoreTargetPath = path.join(bonzaiDir, '.ignore');
37
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devbonzai",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "Quickly set up a local file server in any repository for browser-based file access",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -25,6 +25,7 @@
25
25
  "express": "^4.18.2",
26
26
  "cors": "^2.8.5",
27
27
  "body-parser": "^1.20.2",
28
- "raw-body": "^2.5.2"
28
+ "raw-body": "^2.5.2",
29
+ "glob": "^10.0.0"
29
30
  }
30
31
  }
@@ -0,0 +1,68 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const glob = require('glob');
4
+
5
+ module.exports = async function scanCodeQuality(req, res) {
6
+ try {
7
+ const { projectPath, maxFileLines = 500, maxFolderFiles = 20 } = req.body;
8
+
9
+ if (!projectPath) {
10
+ return res.status(400).json({ error: 'projectPath required' });
11
+ }
12
+
13
+ const issues = [];
14
+
15
+ // 1. Check file sizes
16
+ const files = glob.sync('**/*.{js,ts,jsx,tsx,py,java,go}', {
17
+ cwd: projectPath,
18
+ nodir: true,
19
+ ignore: ['node_modules/**', 'dist/**', 'build/**', '.git/**']
20
+ });
21
+
22
+ files.forEach(file => {
23
+ const fullPath = path.join(projectPath, file);
24
+ const content = fs.readFileSync(fullPath, 'utf8');
25
+ const lines = content.split('\n').length;
26
+
27
+ if (lines > maxFileLines) {
28
+ issues.push({
29
+ type: 'large_file',
30
+ file: file,
31
+ lines: lines,
32
+ limit: maxFileLines
33
+ });
34
+ }
35
+ });
36
+
37
+ // 2. Check folder sizes
38
+ const folders = glob.sync('**/', {
39
+ cwd: projectPath,
40
+ ignore: ['node_modules/**', 'dist/**', 'build/**', '.git/**']
41
+ });
42
+
43
+ folders.forEach(folder => {
44
+ const fullPath = path.join(projectPath, folder);
45
+ const contents = fs.readdirSync(fullPath);
46
+ const fileCount = contents.filter(item => {
47
+ const itemPath = path.join(fullPath, item);
48
+ return fs.statSync(itemPath).isFile();
49
+ }).length;
50
+
51
+ if (fileCount > maxFolderFiles) {
52
+ issues.push({
53
+ type: 'crowded_folder',
54
+ folder: folder,
55
+ count: fileCount,
56
+ limit: maxFolderFiles
57
+ });
58
+ }
59
+ });
60
+
61
+ res.json({ issues });
62
+
63
+ } catch (error) {
64
+ console.error('Scan error:', error);
65
+ res.status(500).json({ error: error.message });
66
+ }
67
+ };
68
+
@@ -18,6 +18,7 @@ const promptAgentHandler = require('./handlers/prompt_agent');
18
18
  const promptAgentStreamHandler = require('./handlers/prompt_agent_stream');
19
19
  const revertJobHandler = require('./handlers/revert_job');
20
20
  const shutdownHandler = require('./handlers/shutdown');
21
+ const scanCodeQualityHandler = require('./handlers/scan_code_quality');
21
22
 
22
23
  const app = express();
23
24
 
@@ -39,6 +40,7 @@ app.post('/prompt_agent', promptAgentHandler);
39
40
  app.post('/prompt_agent_stream', promptAgentStreamHandler);
40
41
  app.post('/revert_job', revertJobHandler);
41
42
  app.post('/shutdown', shutdownHandler);
43
+ app.post('/scan_code_quality', scanCodeQualityHandler);
42
44
 
43
45
  const port = 3001;
44
46
  app.listen(port, () => {