optivise
Version:
Optivise - The Ultimate Optimizely Development Assistant with AI-powered features, zero-config setup, and comprehensive development support
152 lines • 4.45 kB
TypeScript
/**
* Code Analyzer Tool (optidev_code_analyzer)
* Real-time code analysis for performance, security, and best practices
*/
import type { Logger, LLMRequest, PromptContext } from '../types/index.js';
import { z } from 'zod';
export declare const CodeAnalyzerRequestSchema: z.ZodObject<{
codeSnippet: z.ZodString;
language: z.ZodDefault<z.ZodEnum<["typescript", "javascript", "csharp"]>>;
analysisType: z.ZodDefault<z.ZodEnum<["performance", "security", "best-practices", "all"]>>;
userPrompt: z.ZodOptional<z.ZodString>;
promptContext: z.ZodOptional<z.ZodAny>;
projectPath: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
codeSnippet: string;
language: "typescript" | "csharp" | "javascript";
analysisType: "best-practices" | "performance" | "security" | "all";
projectPath?: string | undefined;
promptContext?: any;
userPrompt?: string | undefined;
}, {
codeSnippet: string;
projectPath?: string | undefined;
promptContext?: any;
userPrompt?: string | undefined;
language?: "typescript" | "csharp" | "javascript" | undefined;
analysisType?: "best-practices" | "performance" | "security" | "all" | undefined;
}>;
export interface CodeAnalyzerRequest {
codeSnippet: string;
language: string;
analysisType: 'performance' | 'security' | 'best-practices' | 'all';
userPrompt?: string;
promptContext?: PromptContext;
projectPath?: string;
}
export interface CodeIssue {
line: number;
column?: number;
severity: 'info' | 'warning' | 'error' | 'critical';
category: string;
message: string;
suggestion: string;
codeExample?: string;
}
export interface PerformanceAnalysis {
overallScore: number;
issues: CodeIssue[];
optimizations: Array<{
title: string;
description: string;
impact: 'low' | 'medium' | 'high';
effort: 'low' | 'medium' | 'high';
codeExample?: string;
}>;
}
export interface SecurityAnalysis {
riskLevel: 'low' | 'medium' | 'high' | 'critical';
vulnerabilities: CodeIssue[];
recommendations: string[];
}
export interface BestPracticesAnalysis {
complianceScore: number;
violations: CodeIssue[];
suggestions: Array<{
category: string;
description: string;
examples: string[];
}>;
}
export interface CodeAnalyzerResponse {
detectedProducts: string[];
language: string;
analysisType: string;
performance?: PerformanceAnalysis;
security?: SecurityAnalysis;
bestPractices?: BestPracticesAnalysis;
overallQuality: {
score: number;
grade: 'A' | 'B' | 'C' | 'D' | 'F';
summary: string;
};
refactoringOpportunities: Array<{
type: string;
description: string;
benefits: string[];
estimatedEffort: string;
}>;
llm_request?: LLMRequest;
}
export declare class CodeAnalyzerTool {
private productDetection;
private logger;
private ruleService;
private static readonly LANGUAGE_PATTERNS;
private static readonly OPTIMIZELY_PATTERNS;
constructor(logger: Logger);
initialize(): Promise<void>;
/**
* Analyze code snippet for various quality aspects
*/
analyzeCode(request: CodeAnalyzerRequest): Promise<CodeAnalyzerResponse>;
/**
* Detect Optimizely products in code
*/
private detectProductsInCode;
/**
* Analyze code performance
*/
private analyzePerformance;
/**
* Analyze code security
*/
private analyzeSecurity;
/**
* Analyze best practices compliance
*/
private analyzeBestPractices;
/**
* Find pattern matches in code
*/
private findPatternMatches;
/**
* Generate suggestion based on issue
*/
private generateSuggestion;
/**
* Generate optimization recommendation
*/
private generateOptimization;
/**
* Generate security recommendations
*/
private generateSecurityRecommendations;
/**
* Generate best practice suggestions
*/
private generateBestPracticeSuggestions;
/**
* Calculate overall code quality
*/
private calculateOverallQuality;
/**
* Generate quality summary
*/
private generateQualitySummary;
/**
* Identify refactoring opportunities
*/
private identifyRefactoringOpportunities;
}
//# sourceMappingURL=code-analyzer-tool.d.ts.map