@loxia-labs/loxia-autopilot-one 1.0.1

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.
Files changed (80) hide show
  1. package/LICENSE +267 -0
  2. package/README.md +509 -0
  3. package/bin/cli.js +117 -0
  4. package/package.json +94 -0
  5. package/scripts/install-scanners.js +236 -0
  6. package/src/analyzers/CSSAnalyzer.js +297 -0
  7. package/src/analyzers/ConfigValidator.js +690 -0
  8. package/src/analyzers/ESLintAnalyzer.js +320 -0
  9. package/src/analyzers/JavaScriptAnalyzer.js +261 -0
  10. package/src/analyzers/PrettierFormatter.js +247 -0
  11. package/src/analyzers/PythonAnalyzer.js +266 -0
  12. package/src/analyzers/SecurityAnalyzer.js +729 -0
  13. package/src/analyzers/TypeScriptAnalyzer.js +247 -0
  14. package/src/analyzers/codeCloneDetector/analyzer.js +344 -0
  15. package/src/analyzers/codeCloneDetector/detector.js +203 -0
  16. package/src/analyzers/codeCloneDetector/index.js +160 -0
  17. package/src/analyzers/codeCloneDetector/parser.js +199 -0
  18. package/src/analyzers/codeCloneDetector/reporter.js +148 -0
  19. package/src/analyzers/codeCloneDetector/scanner.js +59 -0
  20. package/src/core/agentPool.js +1474 -0
  21. package/src/core/agentScheduler.js +2147 -0
  22. package/src/core/contextManager.js +709 -0
  23. package/src/core/messageProcessor.js +732 -0
  24. package/src/core/orchestrator.js +548 -0
  25. package/src/core/stateManager.js +877 -0
  26. package/src/index.js +631 -0
  27. package/src/interfaces/cli.js +549 -0
  28. package/src/interfaces/webServer.js +2162 -0
  29. package/src/modules/fileExplorer/controller.js +280 -0
  30. package/src/modules/fileExplorer/index.js +37 -0
  31. package/src/modules/fileExplorer/middleware.js +92 -0
  32. package/src/modules/fileExplorer/routes.js +125 -0
  33. package/src/modules/fileExplorer/types.js +44 -0
  34. package/src/services/aiService.js +1232 -0
  35. package/src/services/apiKeyManager.js +164 -0
  36. package/src/services/benchmarkService.js +366 -0
  37. package/src/services/budgetService.js +539 -0
  38. package/src/services/contextInjectionService.js +247 -0
  39. package/src/services/conversationCompactionService.js +637 -0
  40. package/src/services/errorHandler.js +810 -0
  41. package/src/services/fileAttachmentService.js +544 -0
  42. package/src/services/modelRouterService.js +366 -0
  43. package/src/services/modelsService.js +322 -0
  44. package/src/services/qualityInspector.js +796 -0
  45. package/src/services/tokenCountingService.js +536 -0
  46. package/src/tools/agentCommunicationTool.js +1344 -0
  47. package/src/tools/agentDelayTool.js +485 -0
  48. package/src/tools/asyncToolManager.js +604 -0
  49. package/src/tools/baseTool.js +800 -0
  50. package/src/tools/browserTool.js +920 -0
  51. package/src/tools/cloneDetectionTool.js +621 -0
  52. package/src/tools/dependencyResolverTool.js +1215 -0
  53. package/src/tools/fileContentReplaceTool.js +875 -0
  54. package/src/tools/fileSystemTool.js +1107 -0
  55. package/src/tools/fileTreeTool.js +853 -0
  56. package/src/tools/imageTool.js +901 -0
  57. package/src/tools/importAnalyzerTool.js +1060 -0
  58. package/src/tools/jobDoneTool.js +248 -0
  59. package/src/tools/seekTool.js +956 -0
  60. package/src/tools/staticAnalysisTool.js +1778 -0
  61. package/src/tools/taskManagerTool.js +2873 -0
  62. package/src/tools/terminalTool.js +2304 -0
  63. package/src/tools/webTool.js +1430 -0
  64. package/src/types/agent.js +519 -0
  65. package/src/types/contextReference.js +972 -0
  66. package/src/types/conversation.js +730 -0
  67. package/src/types/toolCommand.js +747 -0
  68. package/src/utilities/attachmentValidator.js +292 -0
  69. package/src/utilities/configManager.js +582 -0
  70. package/src/utilities/constants.js +722 -0
  71. package/src/utilities/directoryAccessManager.js +535 -0
  72. package/src/utilities/fileProcessor.js +307 -0
  73. package/src/utilities/logger.js +436 -0
  74. package/src/utilities/tagParser.js +1246 -0
  75. package/src/utilities/toolConstants.js +317 -0
  76. package/web-ui/build/index.html +15 -0
  77. package/web-ui/build/logo.png +0 -0
  78. package/web-ui/build/logo2.png +0 -0
  79. package/web-ui/build/static/index-CjkkcnFA.js +344 -0
  80. package/web-ui/build/static/index-Dy2bYbOa.css +1 -0
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@loxia-labs/loxia-autopilot-one",
3
+ "version": "1.0.1",
4
+ "description": "Loxia AI Agents System - No-code/vibe-code/companion-coder platform",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "bin": {
8
+ "loxia": "./bin/cli.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node src/index.js",
12
+ "dev": "node --inspect src/index.js",
13
+ "test": "jest",
14
+ "lint": "eslint src/",
15
+ "typecheck": "echo 'No TypeScript - skipping typecheck'",
16
+ "build": "npm run build:web-ui",
17
+ "build:web-ui": "cd web-ui && npm install && npm run build && cd ..",
18
+ "docs": "jsdoc -c jsdoc.config.json",
19
+ "postinstall": "node scripts/install-scanners.js",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "ai",
24
+ "agents",
25
+ "automation",
26
+ "coding-assistant",
27
+ "no-code",
28
+ "vibe-code"
29
+ ],
30
+ "author": "Loxia AI",
31
+ "license": "SEE LICENSE IN LICENSE",
32
+ "files": [
33
+ "bin/",
34
+ "src/",
35
+ "web-ui/build/",
36
+ "web-ui/dist/",
37
+ "scripts/",
38
+ "README.md",
39
+ "LICENSE"
40
+ ],
41
+ "engines": {
42
+ "node": ">=16.0.0"
43
+ },
44
+ "dependencies": {
45
+ "@babel/parser": "^7.28.5",
46
+ "@babel/traverse": "^7.28.5",
47
+ "express": "^4.18.2",
48
+ "glob": "^10.4.5",
49
+ "node-fetch": "^3.3.2",
50
+ "pdf-parse": "^2.2.2",
51
+ "postcss": "^8.5.6",
52
+ "postcss-less": "^6.0.0",
53
+ "postcss-scss": "^4.0.9",
54
+ "prettier": "^3.6.2",
55
+ "puppeteer": "^24.25.0",
56
+ "stylelint": "^16.25.0",
57
+ "stylelint-config-standard": "^39.0.1",
58
+ "tiktoken": "^1.0.15",
59
+ "typescript": "^5.9.3",
60
+ "ws": "^8.16.0"
61
+ },
62
+ "devDependencies": {
63
+ "ajv": "^8.17.1",
64
+ "ajv-formats": "^3.0.1",
65
+ "eslint": "^8.57.1",
66
+ "eslint-plugin-security": "^3.0.1",
67
+ "jest": "^29.7.0",
68
+ "jsdoc": "^4.0.2"
69
+ },
70
+ "jest": {
71
+ "testEnvironment": "node",
72
+ "collectCoverageFrom": [
73
+ "src/**/*.js",
74
+ "!src/**/*.test.js"
75
+ ]
76
+ },
77
+ "eslintConfig": {
78
+ "env": {
79
+ "node": true,
80
+ "es2022": true
81
+ },
82
+ "extends": [
83
+ "eslint:recommended"
84
+ ],
85
+ "parserOptions": {
86
+ "ecmaVersion": 2022,
87
+ "sourceType": "module"
88
+ },
89
+ "rules": {
90
+ "no-unused-vars": "warn",
91
+ "no-console": "off"
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,236 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Post-install script to set up security scanners
4
+ * Automatically installs required scanners for the platform
5
+ */
6
+
7
+ import { exec } from 'child_process';
8
+ import { promisify } from 'util';
9
+ import https from 'https';
10
+ import http from 'http';
11
+ import fs from 'fs';
12
+ import path from 'path';
13
+ import { fileURLToPath } from 'url';
14
+ import { createWriteStream } from 'fs';
15
+ import { pipeline } from 'stream/promises';
16
+
17
+ const execAsync = promisify(exec);
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = path.dirname(__filename);
20
+
21
+ const SCANNER_DIR = path.join(__dirname, '..', 'node_modules', '.scanners');
22
+ const SEMGREP_VERSION = 'v1.55.0';
23
+
24
+ console.log('═══════════════════════════════════════════════════════════');
25
+ console.log(' Installing Security Scanners');
26
+ console.log('═══════════════════════════════════════════════════════════\n');
27
+
28
+ /**
29
+ * Main installation function
30
+ */
31
+ async function installScanners() {
32
+ // Ensure scanner directory exists
33
+ await fs.promises.mkdir(SCANNER_DIR, { recursive: true });
34
+
35
+ // 1. Check ESLint Security Plugin (should be in package.json)
36
+ await checkESLintSecurity();
37
+
38
+ // 2. Install Semgrep standalone binary
39
+ await installSemgrep();
40
+
41
+ // 3. Optionally install Python scanners if Python is available
42
+ await installPythonScanners();
43
+
44
+ console.log('\n═══════════════════════════════════════════════════════════');
45
+ console.log(' Installation Complete');
46
+ console.log('═══════════════════════════════════════════════════════════\n');
47
+ }
48
+
49
+ /**
50
+ * Check if ESLint Security Plugin is installed
51
+ */
52
+ async function checkESLintSecurity() {
53
+ console.log('📦 Checking ESLint Security Plugin...');
54
+ try {
55
+ await import('eslint-plugin-security');
56
+ console.log(' ✅ eslint-plugin-security is installed\n');
57
+ } catch (error) {
58
+ console.log(' ⚠️ eslint-plugin-security not found');
59
+ console.log(' Run: npm install --save-dev eslint-plugin-security\n');
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Install Semgrep standalone binary for the current platform
65
+ */
66
+ async function installSemgrep() {
67
+ console.log('🔍 Installing Semgrep...');
68
+
69
+ const platform = process.platform;
70
+ const arch = process.arch;
71
+
72
+ // Check if semgrep is already installed globally
73
+ try {
74
+ const result = await execAsync('semgrep --version', { timeout: 5000 });
75
+ console.log(` ✅ Semgrep already installed: ${result.stdout.trim()}`);
76
+ console.log(' Using system-installed Semgrep\n');
77
+ return;
78
+ } catch (error) {
79
+ console.log(' Semgrep not found in PATH, installing standalone binary...');
80
+ }
81
+
82
+ // Determine download URL based on platform
83
+ const binaryInfo = getSemgrepBinaryInfo(platform, arch);
84
+
85
+ if (!binaryInfo) {
86
+ console.log(` ⚠️ No Semgrep binary available for ${platform}-${arch}`);
87
+ console.log(' Please install manually: https://semgrep.dev/docs/getting-started/\n');
88
+ return;
89
+ }
90
+
91
+ try {
92
+ const binaryPath = path.join(SCANNER_DIR, 'semgrep');
93
+
94
+ console.log(` Downloading from ${binaryInfo.url}...`);
95
+ await downloadFile(binaryInfo.url, binaryPath);
96
+
97
+ // Make executable
98
+ await fs.promises.chmod(binaryPath, 0o755);
99
+
100
+ console.log(' ✅ Semgrep installed successfully');
101
+ console.log(` Location: ${binaryPath}\n`);
102
+
103
+ // Add to PATH environment note
104
+ console.log(' Note: To use system-wide, add to PATH or install globally:');
105
+ console.log(' pip install semgrep\n');
106
+ } catch (error) {
107
+ console.log(` ⚠️ Failed to install Semgrep: ${error.message}`);
108
+ console.log(' You can install manually: pip install semgrep\n');
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Get Semgrep binary info for platform
114
+ */
115
+ function getSemgrepBinaryInfo(platform, arch) {
116
+ // Semgrep binary URLs (using latest stable release)
117
+ // Note: Semgrep doesn't provide standalone binaries anymore for all platforms
118
+ // They recommend using pip install or Docker
119
+
120
+ // For now, we'll provide instructions rather than downloading
121
+ // The actual implementation would use Semgrep's Python package
122
+
123
+ return null; // Will trigger manual installation message
124
+ }
125
+
126
+ /**
127
+ * Install Python-based scanners (Bandit, pip-audit) if Python is available
128
+ */
129
+ async function installPythonScanners() {
130
+ console.log('🐍 Checking Python scanners...');
131
+
132
+ // Check if Python is available
133
+ let pythonCommand = null;
134
+
135
+ try {
136
+ await execAsync('python3 --version', { timeout: 5000 });
137
+ pythonCommand = 'python3';
138
+ } catch (error) {
139
+ try {
140
+ await execAsync('python --version', { timeout: 5000 });
141
+ pythonCommand = 'python';
142
+ } catch (error2) {
143
+ console.log(' ⚠️ Python not found - skipping Python scanners');
144
+ console.log(' To enable Python scanning, install Python and run:');
145
+ console.log(' pip install semgrep bandit pip-audit checkov yamllint\n');
146
+ return;
147
+ }
148
+ }
149
+
150
+ console.log(` ✅ Python found: ${pythonCommand}`);
151
+
152
+ // Security scanners
153
+ await installViaPip('semgrep', pythonCommand);
154
+ await installViaPip('bandit', pythonCommand);
155
+ await installViaPip('pip-audit', pythonCommand);
156
+
157
+ // Config validation tools
158
+ await installViaPip('checkov', pythonCommand);
159
+ await installViaPip('yamllint', pythonCommand);
160
+
161
+ console.log('');
162
+ }
163
+
164
+ /**
165
+ * Install a Python package via pip
166
+ */
167
+ async function installViaPip(packageName, pythonCommand) {
168
+ try {
169
+ // Check if already installed
170
+ const checkResult = await execAsync(`${pythonCommand} -m pip show ${packageName}`, {
171
+ timeout: 5000
172
+ });
173
+ console.log(` ✅ ${packageName} already installed`);
174
+ return true;
175
+ } catch (error) {
176
+ // Not installed, try to install
177
+ console.log(` Installing ${packageName}...`);
178
+ try {
179
+ await execAsync(`${pythonCommand} -m pip install --user ${packageName}`, {
180
+ timeout: 60000
181
+ });
182
+ console.log(` ✅ ${packageName} installed successfully`);
183
+ return true;
184
+ } catch (installError) {
185
+ console.log(` ⚠️ Failed to install ${packageName}: ${installError.message}`);
186
+ console.log(` You can install manually: pip install ${packageName}`);
187
+ return false;
188
+ }
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Download a file from URL
194
+ */
195
+ async function downloadFile(url, outputPath) {
196
+ return new Promise((resolve, reject) => {
197
+ const client = url.startsWith('https') ? https : http;
198
+
199
+ client.get(url, (response) => {
200
+ if (response.statusCode === 302 || response.statusCode === 301) {
201
+ // Follow redirect
202
+ downloadFile(response.headers.location, outputPath)
203
+ .then(resolve)
204
+ .catch(reject);
205
+ return;
206
+ }
207
+
208
+ if (response.statusCode !== 200) {
209
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
210
+ return;
211
+ }
212
+
213
+ const fileStream = createWriteStream(outputPath);
214
+ response.pipe(fileStream);
215
+
216
+ fileStream.on('finish', () => {
217
+ fileStream.close();
218
+ resolve();
219
+ });
220
+
221
+ fileStream.on('error', (error) => {
222
+ fs.unlink(outputPath, () => {}); // Delete partial file
223
+ reject(error);
224
+ });
225
+ }).on('error', reject);
226
+ });
227
+ }
228
+
229
+ // Run installation
230
+ installScanners().catch((error) => {
231
+ console.error('❌ Installation failed:', error.message);
232
+ console.error('\nYou can manually install scanners:');
233
+ console.error(' npm install --save-dev eslint-plugin-security');
234
+ console.error(' pip install semgrep bandit pip-audit');
235
+ process.exit(0); // Don't fail npm install
236
+ });
@@ -0,0 +1,297 @@
1
+ /**
2
+ * CSSAnalyzer - CSS/SCSS/LESS code analysis using PostCSS and Stylelint
3
+ *
4
+ * Purpose:
5
+ * - Analyze CSS, SCSS, and LESS files for syntax errors
6
+ * - Validate style rules and properties
7
+ * - Detect common CSS issues and bad practices
8
+ * - Support preprocessor syntaxes (SCSS, LESS)
9
+ */
10
+
11
+ import { STATIC_ANALYSIS } from '../utilities/constants.js';
12
+
13
+ class CSSAnalyzer {
14
+ constructor(logger = null) {
15
+ this.logger = logger;
16
+ this.stylelint = null;
17
+ this.postcss = null;
18
+ this.postcssScss = null;
19
+ this.postcssLess = null;
20
+ }
21
+
22
+ /**
23
+ * Analyze CSS/SCSS/LESS code
24
+ * @param {string} filePath - Path to file
25
+ * @param {string} content - File content
26
+ * @param {Object} options - Analysis options
27
+ * @returns {Promise<Array>} Array of diagnostics
28
+ */
29
+ async analyze(filePath, content, options = {}) {
30
+ try {
31
+ const diagnostics = [];
32
+ const language = this.detectLanguage(filePath);
33
+
34
+ // Check syntax using PostCSS
35
+ const syntaxErrors = await this.checkSyntax(filePath, content, language);
36
+ diagnostics.push(...syntaxErrors);
37
+
38
+ // Only run style linting if no syntax errors
39
+ if (syntaxErrors.length === 0) {
40
+ const styleIssues = await this.lintStyles(filePath, content, language);
41
+ diagnostics.push(...styleIssues);
42
+ }
43
+
44
+ this.logger?.debug('CSS analysis completed', {
45
+ file: filePath,
46
+ language,
47
+ totalDiagnostics: diagnostics.length,
48
+ errors: diagnostics.filter(d => d.severity === STATIC_ANALYSIS.SEVERITY.ERROR).length,
49
+ warnings: diagnostics.filter(d => d.severity === STATIC_ANALYSIS.SEVERITY.WARNING).length
50
+ });
51
+
52
+ return diagnostics;
53
+
54
+ } catch (error) {
55
+ this.logger?.error('CSS analysis failed', {
56
+ file: filePath,
57
+ error: error.message
58
+ });
59
+
60
+ // Return empty array on error to allow other analysis to continue
61
+ return [];
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Check CSS syntax using PostCSS
67
+ * @private
68
+ */
69
+ async checkSyntax(filePath, content, language) {
70
+ const diagnostics = [];
71
+
72
+ try {
73
+ // Lazy load PostCSS and syntax parsers
74
+ if (!this.postcss) {
75
+ const postcssModule = await import('postcss');
76
+ this.postcss = postcssModule.default;
77
+ }
78
+
79
+ let syntax = null;
80
+
81
+ if (language === 'scss') {
82
+ if (!this.postcssScss) {
83
+ const scssModule = await import('postcss-scss');
84
+ this.postcssScss = scssModule.default;
85
+ }
86
+ syntax = this.postcssScss;
87
+ } else if (language === 'less') {
88
+ if (!this.postcssLess) {
89
+ const lessModule = await import('postcss-less');
90
+ this.postcssLess = lessModule.default;
91
+ }
92
+ syntax = this.postcssLess;
93
+ }
94
+
95
+ // Parse CSS with PostCSS
96
+ const result = this.postcss().process(content, {
97
+ from: filePath,
98
+ syntax
99
+ });
100
+
101
+ // PostCSS parsing is synchronous - accessing result.root will throw if syntax error
102
+ const root = result.root;
103
+
104
+ // If we get here, syntax is valid
105
+ this.logger?.debug('PostCSS syntax check passed', { file: filePath });
106
+
107
+ } catch (error) {
108
+ // PostCSS syntax error
109
+ const diagnostic = this.formatPostCSSError(error, filePath);
110
+ if (diagnostic) {
111
+ diagnostics.push(diagnostic);
112
+ }
113
+ }
114
+
115
+ return diagnostics;
116
+ }
117
+
118
+ /**
119
+ * Lint styles using Stylelint
120
+ * @private
121
+ */
122
+ async lintStyles(filePath, content, language) {
123
+ const diagnostics = [];
124
+
125
+ try {
126
+ // Lazy load Stylelint
127
+ if (!this.stylelint) {
128
+ const stylelintModule = await import('stylelint');
129
+ this.stylelint = stylelintModule.default;
130
+ }
131
+
132
+ // Configure Stylelint
133
+ const config = {
134
+ extends: ['stylelint-config-standard'],
135
+ rules: {
136
+ // Custom rules for better analysis
137
+ 'color-no-invalid-hex': true,
138
+ 'font-family-no-duplicate-names': true,
139
+ 'function-calc-no-invalid': true,
140
+ 'string-no-newline': true,
141
+ 'unit-no-unknown': true,
142
+ 'property-no-unknown': true,
143
+ 'declaration-block-no-duplicate-properties': true,
144
+ 'selector-pseudo-class-no-unknown': true,
145
+ 'selector-pseudo-element-no-unknown': true,
146
+ 'selector-type-no-unknown': [true, {
147
+ ignoreTypes: ['/^custom-/', 'ng-deep'] // Allow custom elements
148
+ }],
149
+ 'media-feature-name-no-unknown': true,
150
+ 'at-rule-no-unknown': language === 'scss' ? [true, {
151
+ ignoreAtRules: ['mixin', 'include', 'extend', 'if', 'else', 'for', 'each', 'while', 'function', 'return', 'content', 'use', 'forward']
152
+ }] : language === 'less' ? [true, {
153
+ ignoreAtRules: ['plugin']
154
+ }] : true,
155
+ 'comment-no-empty': true,
156
+ 'no-duplicate-selectors': true,
157
+ 'no-empty-source': null, // Allow empty files
158
+ 'block-no-empty': true,
159
+ 'declaration-block-no-shorthand-property-overrides': true,
160
+ 'font-family-no-missing-generic-family-keyword': true,
161
+ 'function-linear-gradient-no-nonstandard-direction': true,
162
+ 'no-descending-specificity': null, // Too strict for real projects
163
+ 'no-duplicate-at-import-rules': true,
164
+ 'no-extra-semicolons': true,
165
+ 'no-invalid-double-slash-comments': true,
166
+ 'selector-pseudo-element-colon-notation': 'double',
167
+ 'selector-type-case': 'lower'
168
+ },
169
+ customSyntax: language === 'scss' ? 'postcss-scss' :
170
+ language === 'less' ? 'postcss-less' : undefined
171
+ };
172
+
173
+ // Run Stylelint
174
+ const result = await this.stylelint.lint({
175
+ code: content,
176
+ codeFilename: filePath,
177
+ config
178
+ });
179
+
180
+ // Process results
181
+ if (result.results && result.results.length > 0) {
182
+ const fileResult = result.results[0];
183
+
184
+ if (fileResult.warnings) {
185
+ for (const warning of fileResult.warnings) {
186
+ diagnostics.push({
187
+ file: filePath,
188
+ line: warning.line || 1,
189
+ column: warning.column || 1,
190
+ severity: warning.severity === 'error'
191
+ ? STATIC_ANALYSIS.SEVERITY.ERROR
192
+ : STATIC_ANALYSIS.SEVERITY.WARNING,
193
+ rule: warning.rule || 'unknown',
194
+ message: warning.text,
195
+ category: this.categorizeStylelintRule(warning.rule),
196
+ fixable: false,
197
+ source: 'stylelint'
198
+ });
199
+ }
200
+ }
201
+ }
202
+
203
+ } catch (error) {
204
+ this.logger?.warn('Stylelint analysis failed', {
205
+ file: filePath,
206
+ error: error.message
207
+ });
208
+ // Don't fail the whole analysis if linting fails
209
+ }
210
+
211
+ return diagnostics;
212
+ }
213
+
214
+ /**
215
+ * Format PostCSS error into diagnostic
216
+ * @private
217
+ */
218
+ formatPostCSSError(error, filePath) {
219
+ return {
220
+ file: filePath,
221
+ line: error.line || 1,
222
+ column: error.column || 1,
223
+ severity: STATIC_ANALYSIS.SEVERITY.ERROR,
224
+ rule: error.name || 'CssSyntaxError',
225
+ message: error.reason || error.message,
226
+ category: STATIC_ANALYSIS.CATEGORY.SYNTAX,
227
+ fixable: false,
228
+ source: 'postcss',
229
+ code: error.source || undefined
230
+ };
231
+ }
232
+
233
+ /**
234
+ * Categorize Stylelint rule into analysis category
235
+ * @private
236
+ */
237
+ categorizeStylelintRule(rule) {
238
+ if (!rule) return STATIC_ANALYSIS.CATEGORY.STYLE;
239
+
240
+ const ruleLower = rule.toLowerCase();
241
+
242
+ if (ruleLower.includes('no-invalid') ||
243
+ ruleLower.includes('no-unknown') ||
244
+ ruleLower.includes('no-empty') ||
245
+ ruleLower.includes('syntax')) {
246
+ return STATIC_ANALYSIS.CATEGORY.SYNTAX;
247
+ }
248
+
249
+ if (ruleLower.includes('performance') ||
250
+ ruleLower.includes('optimize')) {
251
+ return STATIC_ANALYSIS.CATEGORY.PERFORMANCE;
252
+ }
253
+
254
+ if (ruleLower.includes('best-practice') ||
255
+ ruleLower.includes('recommended')) {
256
+ return STATIC_ANALYSIS.CATEGORY.BEST_PRACTICE;
257
+ }
258
+
259
+ return STATIC_ANALYSIS.CATEGORY.STYLE;
260
+ }
261
+
262
+ /**
263
+ * Detect language from file path
264
+ * @private
265
+ */
266
+ detectLanguage(filePath) {
267
+ const ext = filePath.toLowerCase();
268
+
269
+ if (ext.endsWith('.scss') || ext.endsWith('.sass')) {
270
+ return 'scss';
271
+ }
272
+
273
+ if (ext.endsWith('.less')) {
274
+ return 'less';
275
+ }
276
+
277
+ return 'css';
278
+ }
279
+
280
+ /**
281
+ * Get supported file extensions
282
+ * @returns {Array<string>} Array of supported extensions
283
+ */
284
+ getSupportedExtensions() {
285
+ return ['.css', '.scss', '.sass', '.less'];
286
+ }
287
+
288
+ /**
289
+ * Check if auto-fix is supported
290
+ * @returns {boolean} True if auto-fix is supported
291
+ */
292
+ supportsAutoFix() {
293
+ return false; // Auto-fix not implemented yet
294
+ }
295
+ }
296
+
297
+ export default CSSAnalyzer;