UNPKG

advanced-live-server-installer

Version:

Auto-installer for Advanced Live Server VS Code Extension

102 lines 4.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LocalAIService = void 0; const hyperserver_ai_model_1 = require("./hyperserver-ai-model"); class LocalAIService { constructor(context, outputChannel) { this.modelManager = new hyperserver_ai_model_1.HyperServerAIModelManager(context, outputChannel); this.outputChannel = outputChannel; } async analyzeCode(code, task) { this.outputChannel.appendLine('🔍 Starting local code analysis...'); // Use different tools based on the task let toolId = 'eslint'; // default if (task === 'code-improvements') { toolId = 'prettier'; // Use prettier for code improvements } else if (task === 'error-analysis') { toolId = 'eslint'; // Use eslint for error analysis } try { const result = await this.modelManager.analyzeCodeWithTool(toolId, code, task); this.outputChannel.appendLine('✅ Local code analysis completed'); return result; } catch (error) { this.outputChannel.appendLine(`❌ Local code analysis failed: ${error}`); return 'Local analysis failed. Please try again.'; } } async analyzeAccessibility(html) { this.outputChannel.appendLine('♿ Starting accessibility analysis...'); try { const result = await this.modelManager.analyzeCodeWithTool('axe-core', html, 'accessibility'); this.outputChannel.appendLine('✅ Accessibility analysis completed'); return result; } catch (error) { this.outputChannel.appendLine(`❌ Accessibility analysis failed: ${error}`); return 'Accessibility analysis failed. Please try again.'; } } async analyzePerformance(html) { this.outputChannel.appendLine('⚡ Starting performance analysis...'); try { const result = await this.modelManager.analyzeCodeWithTool('lighthouse', html, 'performance'); this.outputChannel.appendLine('✅ Performance analysis completed'); return result; } catch (error) { this.outputChannel.appendLine(`❌ Performance analysis failed: ${error}`); return 'Performance analysis failed. Please try again.'; } } async analyzeSEO(html) { this.outputChannel.appendLine('🔍 Starting SEO analysis...'); try { const result = await this.modelManager.analyzeCodeWithTool('seo-checker', html, 'seo'); this.outputChannel.appendLine('✅ SEO analysis completed'); return result; } catch (error) { this.outputChannel.appendLine(`❌ SEO analysis failed: ${error}`); return 'SEO analysis failed. Please try again.'; } } async securityScan(code) { this.outputChannel.appendLine('🔒 Starting security scan...'); try { const result = await this.modelManager.analyzeCodeWithTool('security-scanner', code, 'security'); this.outputChannel.appendLine('✅ Security scan completed'); return result; } catch (error) { this.outputChannel.appendLine(`❌ Security scan failed: ${error}`); return 'Security scan failed. Please try again.'; } } async formatCode(code) { this.outputChannel.appendLine('🎨 Starting code formatting...'); try { const result = await this.modelManager.analyzeCodeWithTool('prettier', code, 'formatting'); this.outputChannel.appendLine('✅ Code formatting completed'); return result; } catch (error) { this.outputChannel.appendLine(`❌ Code formatting failed: ${error}`); return 'Code formatting failed. Please try again.'; } } // Tool management methods async getAvailableTools() { return this.modelManager.getAvailableTools(); } async getToolStatus(toolId) { return this.modelManager.getToolStatus(toolId); } async ensureToolAvailable(toolId) { return this.modelManager.ensureToolAvailable(toolId); } } exports.LocalAIService = LocalAIService; //# sourceMappingURL=local-ai-service.js.map