codecrucible-synth
Version:
Production-Ready AI Development Platform with Multi-Voice Synthesis, Smithery MCP Integration, Enterprise Security, and Zero-Timeout Reliability
409 lines • 11.6 kB
TypeScript
/**
* Project Intelligence System - Enhanced Context Awareness
* Iteration 3: Add enhanced context awareness and project intelligence
*/
import { EventEmitter } from 'events';
export interface ProjectIntelligence {
structure: ProjectStructure;
insights: ProjectInsights;
dependencies: DependencyGraph;
patterns: ArchitecturePatterns;
metadata: ProjectMetadata;
recommendations: IntelligentRecommendations;
}
export interface ProjectStructure {
rootPath: string;
directories: DirectoryNode[];
files: FileNode[];
packageFiles: PackageFile[];
configFiles: ConfigFile[];
documentationFiles: DocumentationFile[];
testFiles: TestFile[];
buildFiles: BuildFile[];
totalFiles: number;
totalDirectories: number;
codebaseSize: number;
}
export interface DirectoryNode {
path: string;
name: string;
depth: number;
fileCount: number;
childDirectories: string[];
purpose: DirectoryPurpose;
importance: 'high' | 'medium' | 'low';
}
export interface FileNode {
path: string;
name: string;
extension: string;
language: string;
size: number;
linesOfCode: number;
complexity: CodeComplexity;
dependencies: string[];
exports: string[];
imports: string[];
functions: FunctionSignature[];
classes: ClassSignature[];
interfaces: InterfaceSignature[];
purpose: FilePurpose;
lastModified: Date;
importance: 'critical' | 'high' | 'medium' | 'low';
}
export interface ProjectInsights {
primaryLanguage: string;
languageDistribution: Record<string, number>;
frameworksDetected: FrameworkInfo[];
architecturePattern: ArchitecturePattern;
projectType: ProjectType;
maturityLevel: 'prototype' | 'development' | 'production' | 'legacy';
codeQuality: CodeQualityMetrics;
technicalDebt: TechnicalDebtAnalysis;
securityConcerns: SecurityConcern[];
performanceIndicators: PerformanceIndicator[];
}
export interface DependencyGraph {
nodes: DependencyNode[];
edges: DependencyEdge[];
cycles: CircularDependency[];
criticalPath: string[];
modularity: ModularityMetrics;
externalDependencies: ExternalDependency[];
internalDependencies: InternalDependency[];
}
export interface ArchitecturePatterns {
primaryPattern: string;
secondaryPatterns: string[];
designPrinciples: string[];
antiPatterns: AntiPattern[];
refactoringOpportunities: RefactoringOpportunity[];
}
export interface IntelligentRecommendations {
codeImprovement: CodeRecommendation[];
architecture: ArchitectureRecommendation[];
performance: PerformanceRecommendation[];
security: SecurityRecommendation[];
testing: TestingRecommendation[];
documentation: DocumentationRecommendation[];
maintenance: MaintenanceRecommendation[];
}
export type DirectoryPurpose = 'source' | 'tests' | 'build' | 'config' | 'docs' | 'assets' | 'dependencies' | 'other';
export type FilePurpose = 'core' | 'utility' | 'test' | 'config' | 'documentation' | 'build' | 'assets' | 'entry';
export type ProjectType = 'library' | 'application' | 'service' | 'tool' | 'framework' | 'unknown';
export type ArchitecturePattern = 'mvc' | 'microservices' | 'layered' | 'hexagonal' | 'modular' | 'monolithic' | 'unknown';
export interface FrameworkInfo {
name: string;
version?: string;
confidence: number;
evidence: string[];
}
export interface CodeComplexity {
cyclomaticComplexity: number;
cognitiveComplexity: number;
nestingDepth: number;
functionCount: number;
classCount: number;
}
export interface FunctionSignature {
name: string;
parameters: string[];
returnType?: string;
complexity: number;
lineNumber: number;
}
export interface ClassSignature {
name: string;
methods: string[];
properties: string[];
inheritance: string[];
lineNumber: number;
}
export interface InterfaceSignature {
name: string;
methods: string[];
properties: string[];
lineNumber: number;
}
export interface CodeQualityMetrics {
maintainabilityIndex: number;
duplication: number;
testCoverage: number;
commentDensity: number;
naming: QualityScore;
structure: QualityScore;
consistency: QualityScore;
}
export interface TechnicalDebtAnalysis {
totalDebt: number;
debtItems: DebtItem[];
debtRatio: number;
prioritizedFixes: PrioritizedFix[];
}
export interface SecurityConcern {
type: string;
severity: 'critical' | 'high' | 'medium' | 'low';
description: string;
file: string;
lineNumber?: number;
recommendation: string;
}
export interface PerformanceIndicator {
metric: string;
value: number;
target: number;
status: 'good' | 'warning' | 'critical';
recommendation: string;
}
export interface PackageFile {
path: string;
type: 'package.json' | 'requirements.txt' | 'Cargo.toml' | 'pom.xml' | 'other';
dependencies: string[];
devDependencies: string[];
scripts: Record<string, string>;
}
export interface ConfigFile {
path: string;
type: string;
purpose: string;
settings: Record<string, any>;
}
export interface DocumentationFile {
path: string;
type: 'readme' | 'api' | 'tutorial' | 'changelog' | 'other';
quality: 'excellent' | 'good' | 'fair' | 'poor';
coverage: string[];
}
export interface TestFile {
path: string;
type: 'unit' | 'integration' | 'e2e' | 'other';
framework: string;
coverage: string[];
}
export interface BuildFile {
path: string;
type: string;
commands: string[];
targets: string[];
}
export interface QualityScore {
score: number;
issues: string[];
suggestions: string[];
}
export interface DebtItem {
type: string;
severity: number;
effort: number;
description: string;
location: string;
}
export interface PrioritizedFix {
priority: number;
impact: 'high' | 'medium' | 'low';
effort: 'small' | 'medium' | 'large';
description: string;
files: string[];
}
export interface DependencyNode {
id: string;
name: string;
type: 'internal' | 'external';
version?: string;
importance: number;
}
export interface DependencyEdge {
from: string;
to: string;
type: 'import' | 'require' | 'dependency';
strength: number;
}
export interface CircularDependency {
cycle: string[];
severity: 'high' | 'medium' | 'low';
recommendation: string;
}
export interface ModularityMetrics {
cohesion: number;
coupling: number;
modularity: number;
instability: number;
}
export interface ExternalDependency {
name: string;
version: string;
type: 'production' | 'development' | 'optional';
usage: string[];
risk: 'high' | 'medium' | 'low';
}
export interface InternalDependency {
from: string;
to: string;
relationship: 'depends-on' | 'extends' | 'implements' | 'uses';
strength: number;
}
export interface AntiPattern {
name: string;
description: string;
locations: string[];
severity: 'high' | 'medium' | 'low';
solution: string;
}
export interface RefactoringOpportunity {
type: string;
description: string;
files: string[];
effort: 'small' | 'medium' | 'large';
benefit: 'high' | 'medium' | 'low';
priority: number;
}
export interface CodeRecommendation {
category: 'refactoring' | 'optimization' | 'modernization' | 'cleanup';
priority: 'high' | 'medium' | 'low';
description: string;
files: string[];
effort: string;
benefit: string;
}
export interface ArchitectureRecommendation {
type: 'structural' | 'pattern' | 'design';
description: string;
rationale: string;
impact: 'high' | 'medium' | 'low';
effort: 'small' | 'medium' | 'large';
}
export interface PerformanceRecommendation {
metric: string;
current: number;
target: number;
improvement: string;
implementation: string;
}
export interface SecurityRecommendation {
category: string;
priority: 'critical' | 'high' | 'medium' | 'low';
description: string;
solution: string;
resources: string[];
}
export interface TestingRecommendation {
type: 'coverage' | 'strategy' | 'framework';
current: string;
recommended: string;
rationale: string;
implementation: string;
}
export interface DocumentationRecommendation {
type: 'api' | 'user' | 'developer' | 'architecture';
priority: 'high' | 'medium' | 'low';
description: string;
template?: string;
}
export interface MaintenanceRecommendation {
category: 'updates' | 'monitoring' | 'automation' | 'tooling';
description: string;
frequency: string;
automation: boolean;
tools: string[];
}
export interface ProjectMetadata {
name: string;
version?: string;
description?: string;
author?: string;
license?: string;
repository?: string;
homepage?: string;
keywords?: string[];
createdDate?: Date;
lastModified: Date;
contributors?: string[];
stats: ProjectStats;
}
export interface ProjectStats {
totalFiles: number;
totalLines: number;
codeLines: number;
commentLines: number;
blankLines: number;
testFiles: number;
configFiles: number;
documentFiles: number;
}
export declare class ProjectIntelligenceSystem extends EventEmitter {
private logger;
private analysisInProgress;
constructor();
/**
* Analyze project and generate comprehensive intelligence
*/
analyzeProject(rootPath: string, options?: AnalysisOptions): Promise<ProjectIntelligence>;
/**
* Analyze project structure and file organization
*/
private analyzeProjectStructure;
/**
* Generate comprehensive project insights
*/
private generateProjectInsights;
/**
* Analyze project dependencies and relationships
*/
private analyzeDependencies;
/**
* Identify architecture patterns and design principles
*/
private identifyArchitecturePatterns;
/**
* Extract project metadata
*/
private extractProjectMetadata;
/**
* Generate intelligent recommendations
*/
private generateRecommendations;
private shouldIgnoreFile;
private determineDirectoryPurpose;
private assessDirectoryImportance;
private analyzeFile;
private detectLanguage;
private isCodeFile;
private determineFilePurpose;
private assessFileImportance;
private analyzeCodeComplexity;
private categorizeSpecialFile;
private updateDirectoryFileCounts;
private analyzeLanguageDistribution;
private detectFrameworks;
private determineProjectType;
private identifyPrimaryArchitecture;
private assessProjectMaturity;
private assessCodeQuality;
private analyzeTechnicalDebt;
private identifySecurityConcerns;
private analyzePerformanceIndicators;
private calculateProjectStats;
/**
* Get cached analysis if available
*/
getCachedAnalysis(path: string): Promise<ProjectIntelligence | null>;
/**
* Clear analysis cache
*/
clearCache(path?: string): Promise<void>;
/**
* Get system metrics
*/
getSystemMetrics(): Promise<any>;
}
export interface AnalysisOptions {
force?: boolean;
maxDepth?: number;
includeTests?: boolean;
includeNodeModules?: boolean;
languages?: string[];
skipLargeFiles?: boolean;
maxFileSize?: number;
}
export default ProjectIntelligenceSystem;
//# sourceMappingURL=project-intelligence-system.d.ts.map