woaru
Version:
Universal Project Setup Autopilot - Analyze and automatically configure development tools for ANY programming language
124 lines • 4.88 kB
TypeScript
import { AIReviewConfig, PromptTemplate as AIPromptTemplate } from '../types/ai-review';
export interface DocumentationResult {
filePath: string;
originalContent: string;
generatedDoc: string;
insertionPoint: number;
functionName: string;
documentationType: 'nopro' | 'pro' | 'forai';
}
export interface CodeFunction {
name: string;
startLine: number;
endLine: number;
content: string;
hasExistingDoc: boolean;
existingDocType?: 'nopro' | 'pro' | 'forai';
}
export declare class DocumentationAgent {
private aiReviewAgent;
private promptTemplates;
constructor(aiConfig: AIReviewConfig, promptTemplates: Record<string, AIPromptTemplate>);
/**
* Generate documentation for a list of files using AI analysis
*
* @param fileList - Array of file paths to process for documentation
* @param projectPath - Root path of the project for context
* @param documentationType - Type of documentation to generate ('nopro' for human-friendly, 'pro' for technical, 'forai' for machine-readable)
* @returns Promise resolving to array of documentation results with file modifications
*/
generateDocumentation(fileList: string[], projectPath: string, documentationType: 'nopro' | 'pro' | 'forai'): Promise<DocumentationResult[]>;
/**
* Process a single file for documentation generation
*
* @param filePath - Path to the file to process
* @param projectPath - Root project path for context
* @param documentationType - Type of documentation to generate
* @returns Promise resolving to array of documentation results for this file
*/
private processFile;
/**
* Process a file for AI context header generation (file-level documentation)
*
* @param filePath - Path to the file to process
* @param projectPath - Root project path for context
* @param content - File content to analyze
* @param language - Programming language of the file
* @returns Promise resolving to array with single documentation result for file header
*/
private processFileForAIContext;
/**
* Check if file already has woaru_context header at the beginning
*
* @param lines - Array of file lines to check
* @returns True if woaru_context header exists, false otherwise
*/
private checkExistingAIDocumentation;
/**
* Format AI context header as appropriate comment block for the language
*
* @param aiContext - Raw AI-generated YAML context content
* @param language - Programming language for comment syntax selection
* @returns Formatted comment block with YAML content
*/
private formatAIContextHeader;
/**
* Generate documentation for a specific code element using AI
*
* @param element - Code element (function/class) to document
* @param filePath - Path to the file containing the element
* @param projectPath - Root project path for context
* @param language - Programming language of the file
* @param documentationType - Type of documentation to generate
* @returns Promise resolving to generated documentation string or null if failed
*/
private generateDocumentationForElement;
/**
* Extract the best documentation from AI results
*
* @param aiResult - Results from AI analysis containing provider responses
* @param documentationType - Type of documentation requested
* @returns Best documentation string from available results or null if none found
*/
private extractBestDocumentation;
/**
* Apply documentation changes to files
*/
applyDocumentation(results: DocumentationResult[]): Promise<void>;
/**
* Apply documentation to a single file
*/
private applyDocumentationToFile;
/**
* Group results by file path
*/
private groupResultsByFile;
/**
* Extract code elements (functions, classes, methods) from source code
*
* Uses regex patterns to identify code constructs that should be documented.
* Why regex instead of AST parsing: Balance between complexity and reliability across languages.
*
* @param content - Source code content to analyze
* @param language - Programming language for pattern selection
* @returns Array of detected code elements with metadata
*/
private extractCodeElements;
/**
* Get regex patterns for different languages
*/
private getPatterns;
/**
* Check if a function already has documentation
*/
private checkExistingDocumentation;
/**
* Detect programming language from file extension
*/
private detectLanguage;
/**
* Check if file is a code file that should be documented
*/
private isCodeFile;
}
//# sourceMappingURL=DocumentationAgent.d.ts.map