// ============================================================================ // AI Testing Suite - Type Definitions // Multi-Agent LangGraph Orchestration // ============================================================================ // --- Project Analysis Types --- export interface ProjectFile { path: string; relativePath: string; name: string; extension: string; size: number; language: 'typescript' | 'javascript' | 'json' | 'yaml' | 'other'; type: 'source' | 'config' | 'test' | 'asset' | 'documentation'; } export interface FunctionInfo { name: string; filePath: string; line: number; params: ParameterInfo[]; returnType: string; isAsync: boolean; isExported: boolean; complexity: number; dependencies: string[]; jsdoc?: string; } export interface ClassInfo { name: string; filePath: string; line: number; methods: FunctionInfo[]; properties: PropertyInfo[]; isExported: boolean; extends?: string; implements?: string[]; dependencies: string[]; } export interface ParameterInfo { name: string; type: string; optional: boolean; defaultValue?: string; } export interface PropertyInfo { name: string; type: string; visibility: 'public' | 'private' | 'protected'; isStatic: boolean; isReadonly: boolean; } export interface ModuleInfo { filePath: string; imports: ImportInfo[]; exports: ExportInfo[]; functions: FunctionInfo[]; classes: ClassInfo[]; interfaces: InterfaceInfo[]; variables: VariableInfo[]; dependencies: string[]; hasDefaultExport: boolean; } export interface ImportInfo { moduleName: string; importedNames: string[]; isDefault: boolean; isNamespace: boolean; isExternal: boolean; } export interface ExportInfo { name: string; type: 'function' | 'class' | 'interface' | 'variable' | 'type' | 'enum'; isDefault: boolean; } export interface InterfaceInfo { name: string; filePath: string; properties: PropertyInfo[]; isExported: boolean; } export interface VariableInfo { name: string; type: string; isConst: boolean; isExported: boolean; value?: string; } // --- Project Structure Types --- export interface ProjectStructure { rootPath: string; name: string; framework: FrameworkInfo; packageManager: 'npm' | 'yarn' | 'pnpm'; files: ProjectFile[]; directories: string[]; entryPoints: string[]; configFiles: string[]; totalFiles: number; totalLines: number; languages: Record; } export interface FrameworkInfo { name: string; version: string; type: 'frontend' | 'backend' | 'fullstack' | 'library' | 'cli' | 'unknown'; testFramework?: string; testRunner?: TestRunner; e2eRunner?: E2ERunner; coverageTool?: CoverageTool; buildTool?: string; features: string[]; } export interface DependencyGraph { nodes: DependencyNode[]; edges: DependencyEdge[]; circularDependencies: string[][]; externalDependencies: string[]; } export interface DependencyNode { id: string; filePath: string; type: 'source' | 'external'; } export interface DependencyEdge { from: string; to: string; type: 'import' | 'require' | 'dynamic'; } // --- Code Analysis Types --- export interface CodeAnalysis { modules: ModuleInfo[]; dependencyGraph: DependencyGraph; patterns: CodePattern[]; metrics: CodeMetrics; apiEndpoints: ApiEndpoint[]; databaseOperations: DatabaseOperation[]; environmentVariables: string[]; errorHandlingPatterns: ErrorPattern[]; } export interface CodePattern { type: 'singleton' | 'factory' | 'observer' | 'middleware' | 'decorator' | 'repository' | 'service' | 'controller' | 'other'; filePath: string; name: string; description: string; } export interface CodeMetrics { totalFunctions: number; totalClasses: number; totalInterfaces: number; totalLines: number; averageComplexity: number; maxComplexity: number; testableUnits: number; coverageEstimate: number; } export interface ApiEndpoint { method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS'; path: string; handler: string; filePath: string; middleware: string[]; params: ParameterInfo[]; requestBody?: string; responseType?: string; authentication: boolean; } export interface DatabaseOperation { type: 'query' | 'insert' | 'update' | 'delete' | 'transaction'; model: string; filePath: string; line: number; raw: boolean; } export interface ErrorPattern { type: 'try-catch' | 'promise-catch' | 'error-middleware' | 'global-handler'; filePath: string; line: number; handlesSpecificErrors: boolean; rethrows: boolean; } // --- Test Strategy Types --- export interface TestStrategy { unitTests: TestPlan[]; integrationTests: TestPlan[]; e2eTests: TestPlan[]; securityTests: TestPlan[]; performanceTests: TestPlan[]; priority: TestPriority[]; estimatedCoverage: number; } export interface TestPlan { targetFile: string; targetFunction?: string; targetClass?: string; testType: TestType; testCases: TestCaseDefinition[]; dependencies: string[]; mocks: MockDefinition[]; priority: 'critical' | 'high' | 'medium' | 'low'; description: string; } export interface TestCaseDefinition { name: string; description: string; input: string; expectedOutput: string; category: TestCategory; edgeCases: string[]; } export interface MockDefinition { name: string; module: string; type: 'full' | 'partial' | 'spy'; returnValue?: string; } export interface TestPriority { file: string; score: number; reason: string; } export type TestType = 'unit' | 'integration' | 'e2e' | 'security' | 'performance' | 'snapshot' | 'api'; export type TestRunner = 'jest' | 'vitest' | 'node'; export type E2ERunner = 'supertest' | 'playwright' | 'none'; export type CoverageTool = 'istanbul' | 'c8' | 'v8'; export type TestCategory = | 'happy-path' | 'edge-case' | 'error-handling' | 'boundary' | 'null-undefined' | 'type-safety' | 'concurrency' | 'security' | 'performance' | 'regression'; // --- Test Generation Types --- export interface GeneratedTest { filePath: string; content: string; targetFile: string; testType: TestType; testCount: number; categories: TestCategory[]; mocks: string[]; } // --- Test Review Types --- export interface TestReview { testFile: string; score: number; passed: boolean; issues: ReviewIssue[]; suggestions: string[]; coverageGaps: string[]; qualityMetrics: QualityMetrics; } export interface ReviewIssue { severity: 'error' | 'warning' | 'info'; message: string; line?: number; fix?: string; } export interface QualityMetrics { assertions: number; edgeCases: number; errorHandling: number; mockUsage: number; readability: number; maintainability: number; overallScore: number; } // --- Test Execution Types --- export interface TestResult { testFile: string; totalTests: number; passed: number; failed: number; skipped: number; duration: number; errors: TestError[]; coverage?: CoverageInfo; } export interface TestError { testName: string; message: string; stack?: string; expected?: string; actual?: string; } export interface CoverageInfo { statements: number; branches: number; functions: number; lines: number; uncoveredLines: number[]; } // --- Security Types --- export interface SecurityReport { vulnerabilities: Vulnerability[]; dependencyAudit: DependencyVulnerability[]; codeSmells: CodeSmell[]; owaspChecks: OwaspCheck[]; overallRisk: 'critical' | 'high' | 'medium' | 'low' | 'none'; score: number; } export interface Vulnerability { id: string; type: VulnerabilityType; severity: 'critical' | 'high' | 'medium' | 'low'; filePath: string; line: number; code: string; description: string; recommendation: string; cwe?: string; owasp?: string; } export type VulnerabilityType = | 'sql-injection' | 'xss' | 'command-injection' | 'path-traversal' | 'insecure-deserialization' | 'broken-auth' | 'sensitive-data-exposure' | 'xxe' | 'broken-access-control' | 'security-misconfiguration' | 'csrf' | 'ssrf' | 'prototype-pollution' | 'regex-dos' | 'insecure-randomness' | 'hardcoded-credentials' | 'missing-rate-limiting' | 'information-disclosure' | 'zero-day-pattern'; export interface DependencyVulnerability { package: string; version: string; severity: 'critical' | 'high' | 'medium' | 'low'; advisory: string; fixVersion?: string; } export interface CodeSmell { type: string; filePath: string; line: number; description: string; suggestion: string; } export interface OwaspCheck { category: string; passed: boolean; findings: string[]; recommendations: string[]; } // --- Report Types --- export interface TestSuiteReport { projectName: string; timestamp: string; duration: number; structure: ProjectStructure; analysis: CodeAnalysis; strategy: TestStrategy; generatedTests: GeneratedTest[]; reviews: TestReview[]; results: TestResult[]; security: SecurityReport; summary: ReportSummary; } export interface ReportSummary { totalTests: number; totalPassed: number; totalFailed: number; totalSkipped: number; coveragePercentage: number; securityScore: number; qualityScore: number; productionReady: boolean; recommendations: string[]; } // --- LangGraph State Types --- export interface AgentState { projectPath: string; config: SuiteConfig; projectStructure?: ProjectStructure; codeAnalysis?: CodeAnalysis; testStrategy?: TestStrategy; generatedTests: GeneratedTest[]; testReviews: TestReview[]; testResults: TestResult[]; securityReport?: SecurityReport; report?: TestSuiteReport; currentAgent: AgentName; agentLog: AgentLogEntry[]; errors: string[]; status: 'idle' | 'running' | 'completed' | 'failed'; } export type AgentName = | 'scanner' | 'analyzer' | 'strategist' | 'writer' | 'reviewer' | 'runner' | 'security' | 'reporter'; export interface AgentLogEntry { agent: AgentName; timestamp: string; action: string; details: string; duration?: number; status: 'start' | 'progress' | 'complete' | 'error'; } // --- Testing Protocol Types --- export interface TestingProtocolEntry { version: string; date: string; time: string; timestamp: string; project: string; mode: string; agents: AgentName[]; results: { totalTests: number; passed: number; failed: number; skipped: number; }; security: { score: number; risk: string; vulnerabilities: number; critical: number; }; quality: { score: number; generatedTests: number; reviewed: number; passed: number; }; productionReady: boolean; details: string[]; errors: string[]; duration: string; } // --- Configuration Types --- export interface SuiteConfig { projectPath: string; outputDir: string; reportsDir: string; llmProvider: 'openai' | 'anthropic' | 'openai_compatible' | 'ollama'; llmModel: string; apiKey: string; temperature: number; maxTokens: number; testTypes: TestType[]; testRunner: TestRunner; e2eRunner: E2ERunner; coverageTool: CoverageTool; securityScanDepth: 'basic' | 'standard' | 'deep'; checkZeroDay: boolean; checkOwaspTop10: boolean; checkDependencies: boolean; maxAgentIterations: number; verbose: boolean; parallel: boolean; } // --- CLI Types --- export type CliMode = 'full' | 'analyze' | 'generate' | 'run' | 'security' | 'report' | 'interactive'; export interface CliOptions { mode: CliMode; projectPath: string; config?: string; verbose: boolean; output?: string; }