devbonzai 2.1.8 → 2.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devbonzai",
3
- "version": "2.1.8",
3
+ "version": "2.2.0",
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,76 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const glob = require('glob');
4
+ const { getIgnorePatterns, shouldIgnore } = require('../utils/ignore');
5
+
6
+ module.exports = async function scanCodeQuality(req, res) {
7
+ try {
8
+ const { projectPath, maxFileLines = 500, maxFolderFiles = 20 } = req.body;
9
+
10
+ if (!projectPath) {
11
+ return res.status(400).json({ error: 'projectPath required' });
12
+ }
13
+
14
+ // Get ignore patterns from .ignore file (same blacklist used throughout the codebase)
15
+ const ignorePatterns = getIgnorePatterns();
16
+
17
+ const issues = [];
18
+
19
+ // 1. Check file sizes
20
+ const allFiles = glob.sync('**/*.{js,ts,jsx,tsx,py,java,go}', {
21
+ cwd: projectPath,
22
+ nodir: true
23
+ });
24
+
25
+ // Filter out files that match ignore patterns
26
+ const files = allFiles.filter(file => !shouldIgnore(file, ignorePatterns));
27
+
28
+ files.forEach(file => {
29
+ const fullPath = path.join(projectPath, file);
30
+ const content = fs.readFileSync(fullPath, 'utf8');
31
+ const lines = content.split('\n').length;
32
+
33
+ if (lines > maxFileLines) {
34
+ issues.push({
35
+ type: 'large_file',
36
+ file: file,
37
+ lines: lines,
38
+ limit: maxFileLines
39
+ });
40
+ }
41
+ });
42
+
43
+ // 2. Check folder sizes
44
+ const allFolders = glob.sync('**/', {
45
+ cwd: projectPath
46
+ });
47
+
48
+ // Filter out folders that match ignore patterns
49
+ const folders = allFolders.filter(folder => !shouldIgnore(folder, ignorePatterns));
50
+
51
+ folders.forEach(folder => {
52
+ const fullPath = path.join(projectPath, folder);
53
+ const contents = fs.readdirSync(fullPath);
54
+ const fileCount = contents.filter(item => {
55
+ const itemPath = path.join(fullPath, item);
56
+ return fs.statSync(itemPath).isFile();
57
+ }).length;
58
+
59
+ if (fileCount > maxFolderFiles) {
60
+ issues.push({
61
+ type: 'crowded_folder',
62
+ folder: folder,
63
+ count: fileCount,
64
+ limit: maxFolderFiles
65
+ });
66
+ }
67
+ });
68
+
69
+ res.json({ issues });
70
+
71
+ } catch (error) {
72
+ console.error('Scan error:', error);
73
+ res.status(500).json({ error: error.message });
74
+ }
75
+ };
76
+
@@ -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, () => {