erosolar-cli 2.1.226 → 2.1.228
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": "erosolar-cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.228",
|
|
4
4
|
"description": "Unified AI agent framework for the command line - Multi-provider support with schema-driven tools, code intelligence, and transparent reasoning",
|
|
5
5
|
"main": "dist/bin/erosolar.js",
|
|
6
6
|
"type": "module",
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
import { readFileSync, existsSync, readdirSync } from 'fs';
|
|
17
17
|
import { dirname, resolve, extname } from 'path';
|
|
18
18
|
import { fileURLToPath } from 'url';
|
|
19
|
+
import { createRequire } from 'module';
|
|
19
20
|
|
|
20
21
|
const __filename = fileURLToPath(import.meta.url);
|
|
21
22
|
const __dirname = dirname(__filename);
|
|
22
23
|
const PROJECT_ROOT = resolve(__dirname, '..');
|
|
24
|
+
const require = createRequire(import.meta.url);
|
|
23
25
|
|
|
24
26
|
// Complexity thresholds
|
|
25
27
|
const COMPLEXITY_THRESHOLDS = {
|
|
@@ -36,7 +38,8 @@ const ERROR_CATEGORIES = {
|
|
|
36
38
|
CONFIGURATION: 'Configuration',
|
|
37
39
|
COMPLEXITY: 'Complexity',
|
|
38
40
|
QUALITY: 'Quality',
|
|
39
|
-
SECURITY: 'Security'
|
|
41
|
+
SECURITY: 'Security',
|
|
42
|
+
ERROR_PREVENTION: 'Error Prevention'
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
// Severity levels
|
|
@@ -92,6 +95,19 @@ class ComplexityValidator {
|
|
|
92
95
|
return JSON.parse(cleaned);
|
|
93
96
|
}
|
|
94
97
|
|
|
98
|
+
loadEslintConfig(eslintPath) {
|
|
99
|
+
if (eslintPath.endsWith('.json') || eslintPath.endsWith('.eslintrc')) {
|
|
100
|
+
return JSON.parse(readFileSync(eslintPath, 'utf8'));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (eslintPath.endsWith('.cjs') || eslintPath.endsWith('.js')) {
|
|
104
|
+
const loaded = require(eslintPath);
|
|
105
|
+
return loaded?.default ?? loaded;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
95
111
|
analyzeConfiguration() {
|
|
96
112
|
this.log('Analyzing project configuration for complexity enforcement...', 'info');
|
|
97
113
|
|
|
@@ -145,9 +161,33 @@ class ComplexityValidator {
|
|
|
145
161
|
|
|
146
162
|
analyzeEslintConfiguration() {
|
|
147
163
|
try {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
164
|
+
const possibleConfigs = [
|
|
165
|
+
'.eslintrc.json',
|
|
166
|
+
'.eslintrc.cjs',
|
|
167
|
+
'.eslintrc.js',
|
|
168
|
+
'.eslintrc.yaml',
|
|
169
|
+
'.eslintrc.yml',
|
|
170
|
+
'.eslintrc'
|
|
171
|
+
];
|
|
172
|
+
let eslintPath = null;
|
|
173
|
+
for (const configFile of possibleConfigs) {
|
|
174
|
+
const candidate = resolve(PROJECT_ROOT, configFile);
|
|
175
|
+
if (existsSync(candidate)) {
|
|
176
|
+
eslintPath = candidate;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!eslintPath) {
|
|
181
|
+
this.log('No ESLint configuration file found', 'info');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const eslintConfig = this.loadEslintConfig(eslintPath);
|
|
186
|
+
if (!eslintConfig) {
|
|
187
|
+
this.log(`ESLint configuration found at ${eslintPath} (unsupported format), skipping detailed analysis`, 'info');
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
151
191
|
// Complexity rules
|
|
152
192
|
const complexityRules = {
|
|
153
193
|
'complexity': ['error', COMPLEXITY_THRESHOLDS.cyclomatic],
|
|
@@ -159,7 +199,7 @@ class ComplexityValidator {
|
|
|
159
199
|
};
|
|
160
200
|
|
|
161
201
|
Object.entries(complexityRules).forEach(([rule, expected]) => {
|
|
162
|
-
const current = eslintConfig.rules[rule];
|
|
202
|
+
const current = eslintConfig.rules?.[rule];
|
|
163
203
|
if (current && JSON.stringify(current) === JSON.stringify(expected)) {
|
|
164
204
|
this.log(`ESLint: ${rule} - Properly configured`, 'success');
|
|
165
205
|
} else {
|
|
@@ -180,7 +220,7 @@ class ComplexityValidator {
|
|
|
180
220
|
];
|
|
181
221
|
|
|
182
222
|
errorPreventionRules.forEach(rule => {
|
|
183
|
-
if (eslintConfig.rules[rule]) {
|
|
223
|
+
if (eslintConfig.rules?.[rule]) {
|
|
184
224
|
this.log(`ESLint: ${rule} - Error prevention enabled`, 'success');
|
|
185
225
|
} else {
|
|
186
226
|
this.addIssue(
|
|
@@ -190,7 +230,6 @@ class ComplexityValidator {
|
|
|
190
230
|
);
|
|
191
231
|
}
|
|
192
232
|
});
|
|
193
|
-
|
|
194
233
|
} catch (error) {
|
|
195
234
|
this.addIssue(
|
|
196
235
|
ERROR_CATEGORIES.CONFIGURATION,
|
|
@@ -437,4 +476,4 @@ class ComplexityValidator {
|
|
|
437
476
|
|
|
438
477
|
// Run the validator
|
|
439
478
|
const validator = new ComplexityValidator();
|
|
440
|
-
validator.run();
|
|
479
|
+
validator.run();
|