UNPKG

mcp-adr-analysis-server

Version:

MCP server for analyzing Architectural Decision Records and project architecture

241 lines 7.7 kB
/** * File system utilities for MCP ADR Analysis Server * Uses fast-glob for efficient file discovery with .gitignore support * Enhanced with Smart Code Linking capabilities */ /** * Information about a file in the project */ export interface FileInfo { /** Full path to the file */ path: string; /** Filename with extension */ name: string; /** File extension */ extension: string; /** File size in bytes */ size: number; /** Directory containing the file */ directory: string; /** File content (optional) */ content?: string; } /** * Complete project structure information */ export interface ProjectStructure { /** Root path of the project */ rootPath: string; /** Array of files in the project */ files: FileInfo[]; /** Array of directory paths */ directories: string[]; /** Total number of files */ totalFiles: number; /** Total number of directories */ totalDirectories: number; } /** * Project analysis result with technologies and patterns */ export interface ProjectAnalysis { /** Root path of the project */ rootPath: string; /** Array of files analyzed */ files: FileInfo[]; /** Detected technologies */ technologies: string[]; /** Detected architectural patterns */ patterns: string[]; /** Summary of the analysis */ summary: string; /** Total files analyzed */ totalFiles: number; /** Total directories scanned */ totalDirectories: number; } /** * Result of finding related code for an ADR */ export interface RelatedCodeResult { /** Path to the ADR */ adrPath: string; /** Related source code files */ relatedFiles: FileInfo[]; /** Keywords extracted from ADR */ keywords: string[]; /** Search patterns used */ searchPatterns: string[]; /** Confidence score */ confidence: number; } /** * Find files using fast-glob with .gitignore support * * @param projectPath - Path to the project to search * @param patterns - Glob patterns to match files * @param options - Options for file discovery * @returns Promise resolving to file discovery results */ export declare function findFiles(projectPath: string, patterns: string[], options?: { includeContent?: boolean; limit?: number; }): Promise<{ files: FileInfo[]; totalFiles: number; searchPatterns: string[]; searchPath: string; }>; /** * Analyze project structure to detect technologies and patterns * Uses direct file analysis instead of AI prompts * * @param projectPath - Path to the project to analyze * @returns Promise resolving to project analysis results */ export declare function analyzeProjectStructure(projectPath: string): Promise<ProjectAnalysis>; /** * Read file content safely * * @param filePath - Path to the file to read * @returns Promise resolving to file content and metadata */ export declare function readFileContent(filePath: string): Promise<{ success: boolean; filePath: string; content?: string; error?: string; metadata?: { size: number; encoding: string; lastModified: string; }; }>; /** * Check if a file exists * * @param filePath - Path to check * @returns Promise resolving to existence check result */ export declare function fileExists(filePath: string): Promise<{ success: boolean; filePath: string; exists: boolean; metadata?: { type: 'file' | 'directory' | 'symlink' | null; accessible: boolean; lastChecked: string; }; }>; /** * Ensure a directory exists, creating it if necessary * * @param dirPath - Path to the directory * @returns Promise resolving when directory is ensured */ export declare function ensureDirectory(dirPath: string): Promise<{ success: boolean; dirPath: string; created: boolean; error?: string; }>; /** * Write content to a file, creating directories as needed * * @param filePath - Path to the file * @param content - Content to write * @returns Promise resolving when file is written */ export declare function writeFile(filePath: string, content: string): Promise<{ success: boolean; filePath: string; written: boolean; error?: string; metadata?: { size: number; directoryCreated: boolean; }; }>; /** * Find related code files for an ADR using Smart Code Linking * Uses AI for keyword extraction and ripgrep for efficient searching * * @param adrPath - Path to the ADR file * @param adrContent - Content of the ADR * @param projectPath - Root path of the project * @param options - Additional options for search customization * @returns Promise resolving to related code files */ export declare function findRelatedCode(adrPath: string, adrContent: string, projectPath: string, options?: { useAI?: boolean; useRipgrep?: boolean; maxFiles?: number; includeContent?: boolean; }): Promise<RelatedCodeResult>; /** * BACKWARD COMPATIBILITY SECTION * These functions and types provide compatibility with the old prompt-based API * They can be removed once all tools are updated to use the new direct API */ /** * AI prompt for project analysis (backward compatibility) */ export interface ProjectAnalysisPrompt { /** Generated prompt for AI analysis */ prompt: string; /** Instructions for the AI agent */ instructions: string; /** Context information for the analysis */ context: { /** Original project path */ projectPath: string; /** Absolute project path */ absoluteProjectPath: string; /** File patterns to analyze */ filePatterns: string[]; }; } /** * Generate backward-compatible prompt response for project analysis * This wraps the new analyzeProjectStructure to provide the old interface * @deprecated Use analyzeProjectStructure directly */ export declare function analyzeProjectStructureCompat(projectPath: string): Promise<ProjectAnalysisPrompt>; /** * Backward-compatible file exists wrapper * @deprecated Use fileExists directly */ export declare function fileExistsCompat(filePath: string): Promise<any>; /** * Backward-compatible ensure directory wrapper * @deprecated Use ensureDirectory directly */ export declare function ensureDirectoryCompat(dirPath: string): Promise<any>; /** * Backward-compatible write file wrapper * @deprecated Use writeFile directly */ export declare function writeFileCompat(filePath: string, content: string): Promise<any>; /** * Backward-compatible read file wrapper * @deprecated Use readFileContent directly */ export declare function readFileContentCompat(filePath: string): Promise<any>; /** * Get file extension patterns for different file types */ export declare const FILE_PATTERNS: { readonly config: readonly ["package.json", "tsconfig.json", "*.config.js", "*.config.ts", ".env*", "Dockerfile", "docker-compose.yml"]; readonly typescript: readonly ["**/*.ts", "**/*.tsx"]; readonly javascript: readonly ["**/*.js", "**/*.jsx"]; readonly python: readonly ["**/*.py"]; readonly java: readonly ["**/*.java"]; readonly csharp: readonly ["**/*.cs"]; readonly go: readonly ["**/*.go"]; readonly rust: readonly ["**/*.rs"]; readonly documentation: readonly ["**/*.md", "**/*.rst", "**/*.txt", "**/README*"]; readonly adrs: readonly ["docs/adrs/**/*.md", "adrs/**/*.md", "decisions/**/*.md"]; readonly build: readonly ["Makefile", "*.mk", "build.gradle", "pom.xml", "Cargo.toml"]; readonly ci: readonly [".github/workflows/**/*.yml", ".github/workflows/**/*.yaml", ".gitlab-ci.yml", "azure-pipelines.yml"]; }; //# sourceMappingURL=file-system.d.ts.map