update_existing_documentation
Identify and update outdated or inaccurate documentation by comparing code and existing docs, with options to control aggressiveness and focus areas.
Instructions
Intelligently analyze and update existing documentation using memory insights and code comparison
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| analysisId | Yes | Repository analysis ID from analyze_repository tool | |
| docsPath | Yes | Path to existing documentation directory | |
| compareMode | No | Mode of comparison between code and documentation | comprehensive |
| updateStrategy | No | How aggressively to suggest updates | moderate |
| preserveStyle | No | Preserve existing documentation style and formatting | |
| focusAreas | No | Specific areas to focus updates on (e.g., "dependencies", "scripts", "api") |
Implementation Reference
- Core handler method 'updateExistingDocumentation' on the DocumentationUpdateEngine class. Orchestrates the update process: loads repository analysis & memory insights, analyzes existing docs, performs code-doc comparison, generates recommendations, calculates metrics, and returns the UpdateResult.
async updateExistingDocumentation( options: UpdateOptions, ): Promise<UpdateResult> { // 1. Load repository analysis and memory insights const analysis = await this.getRepositoryAnalysis(options.analysisId); this.codeAnalysis = analysis; // 2. Load memory insights for intelligent comparison await this.loadMemoryInsights(analysis, options); // 3. Analyze existing documentation structure and content const existingDocs = await this.analyzeExistingDocumentation( options.docsPath, ); this.existingDocs = existingDocs; // 4. Perform comprehensive code-documentation comparison const comparison = await this.performCodeDocumentationComparison( analysis, existingDocs, options, ); // 5. Generate memory-informed update recommendations const recommendations = await this.generateUpdateRecommendations( comparison, options, ); // 6. Calculate metrics and confidence scores const updateMetrics = this.calculateUpdateMetrics( comparison, recommendations, ); return { success: true, analysisPerformed: comparison, recommendations, memoryInsights: this.memoryInsights, updateMetrics, nextSteps: this.generateMemoryInformedNextSteps( comparison, recommendations, ), }; } - Exported async function 'handleUpdateExistingDocumentation' that instantiates DocumentationUpdateEngine and calls its updateExistingDocumentation method.
export async function handleUpdateExistingDocumentation( args: any, ): Promise<UpdateResult> { const engine = new DocumentationUpdateEngine(); return await engine.updateExistingDocumentation(args); } - Tool definition export 'updateExistingDocumentation' of type Tool from MCP SDK, with name 'update_existing_documentation', description, and inputSchema (analysisId, docsPath, compareMode, updateStrategy, preserveStyle, focusAreas).
export const updateExistingDocumentation: Tool = { name: "update_existing_documentation", description: "Intelligently analyze and update existing documentation using memory insights and code comparison", inputSchema: { type: "object", properties: { analysisId: { type: "string", description: "Repository analysis ID from analyze_repository tool", }, docsPath: { type: "string", description: "Path to existing documentation directory", }, compareMode: { type: "string", enum: ["comprehensive", "gap-detection", "accuracy-check"], default: "comprehensive", description: "Mode of comparison between code and documentation", }, updateStrategy: { type: "string", enum: ["conservative", "moderate", "aggressive"], default: "moderate", description: "How aggressively to suggest updates", }, preserveStyle: { type: "boolean", default: true, description: "Preserve existing documentation style and formatting", }, focusAreas: { type: "array", items: { type: "string" }, description: 'Specific areas to focus updates on (e.g., "dependencies", "scripts", "api")', }, }, required: ["analysisId", "docsPath"], }, }; - src/types/tool-metadata.ts:305-315 (registration)Tool metadata registration for 'update_existing_documentation' in the tool-metadata lookup, categorizing it as 'optimization' with complexity 'complex', dependencies on 'analyze_repository', and large-result return indicator.
update_existing_documentation: { category: "optimization", complexity: "complex", estimatedTokens: 460, suggestedUse: "Intelligently update existing documentation with memory insights", typicalExecutionMs: 2500, returnsLargeResults: true, dependencies: ["analyze_repository"], parallelizable: false, }, - Private helper 'loadMemoryInsights' that loads similar projects, update patterns, enhanced analysis, and enhanced recommendations from the memory system to inform documentation updates.
private async loadMemoryInsights( analysis: any, options: UpdateOptions, ): Promise<void> { try { // Get similar projects that had successful documentation updates const similarProjectsQuery = `${ analysis.metadata?.primaryLanguage || "" } ${analysis.metadata?.ecosystem || ""} documentation update`; const similarProjects = await handleMemoryRecall({ query: similarProjectsQuery, type: "recommendation", limit: 10, }); // Get patterns for successful documentation updates const updatePatternsQuery = "documentation update successful patterns gaps outdated"; const updatePatterns = await handleMemoryRecall({ query: updatePatternsQuery, type: "configuration", limit: 5, }); // Get memory-enhanced analysis for this specific update task const enhancedAnalysis = await handleMemoryIntelligentAnalysis({ projectPath: analysis.projectPath || "", baseAnalysis: analysis, }); // Get memory-enhanced recommendations for update strategy const enhancedRecommendations = await handleMemoryEnhancedRecommendation({ projectPath: analysis.projectPath || "", baseRecommendation: { updateStrategy: options.updateStrategy, compareMode: options.compareMode, focusAreas: options.focusAreas || [], }, projectFeatures: { ecosystem: analysis.metadata?.ecosystem || "unknown", primaryLanguage: analysis.metadata?.primaryLanguage || "unknown", complexity: analysis.complexity || "medium", hasTests: analysis.structure?.hasTests || false, hasCI: analysis.structure?.hasCI || false, docStructure: "existing", // Indicates we're updating existing docs }, }); this.memoryInsights = { similarProjects: similarProjects.memories || [], updatePatterns: updatePatterns.memories || [], enhancedAnalysis: enhancedAnalysis, enhancedRecommendations: enhancedRecommendations, successfulUpdatePatterns: this.extractUpdatePatterns( similarProjects.memories || [], ), commonGapTypes: this.extractCommonGapTypes( similarProjects.memories || [], ), };