Skip to main content
Glama

evolution-pathway

Analyze and map code evolution pathways to achieve goals like modernizing architecture, improving performance, enhancing security, or reducing technical debt. Plan actionable steps by timeframe and context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeImplementationDetailsNo
repositoryUrlYes
targetGoalYes
timeframeYes

Implementation Reference

  • Registers the 'evolution-pathway' MCP tool with input schema validation using Zod and an async handler function that generates and returns the evolution plan as JSON.
    server.tool( "evolution-pathway", { repositoryUrl: z.string(), targetGoal: z.enum([ "modernize-architecture", "improve-performance", "enhance-security", "reduce-technical-debt" ]), timeframe: z.enum(["immediate", "sprint", "quarter", "year"]), includeImplementationDetails: z.boolean().default(true) }, async ({ repositoryUrl, targetGoal, timeframe, includeImplementationDetails }) => { try { const plan = await generateEvolutionPlan( repositoryUrl, targetGoal, timeframe, includeImplementationDetails ); return { content: [{ type: "text", text: JSON.stringify(plan, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error generating evolution pathway: ${(error as Error).message}` }], isError: true }; } } );
  • Core handler logic for generating evolution pathways: clones repo, analyzes files, builds knowledge graph, detects frameworks, analyzes structure, and generates tailored plans based on targetGoal (modernize-architecture, improve-performance, etc.). Dispatches to specific plan generators.
    export async function generateEvolutionPlan( repositoryUrl: string, targetGoal: | "modernize-architecture" | "improve-performance" | "enhance-security" | "reduce-technical-debt", timeframe: "immediate" | "sprint" | "quarter" | "year", includeImplementationDetails: boolean = true ): Promise<any> { console.log( `Generating ${targetGoal} evolution plan for ${repositoryUrl} (${timeframe} timeframe)` ); // Step 1: Clone/update the repository const repoPath = await getRepository(repositoryUrl); // Step 2: Analyze the codebase const files = listFiles(repoPath); const fileAnalyses: Record<string, any> = {}; // Analyze a subset of files to avoid performance issues with large repositories const filesToAnalyze = selectRepresentativeFiles(files, 50); console.log(`Analyzing ${filesToAnalyze.length} representative files...`); for (const file of filesToAnalyze) { try { const fullPath = path.join(repoPath, file); const code = fs.readFileSync(fullPath, "utf8"); const fileLanguage = path.extname(file).slice(1); const analysis = analyzeCode(code, fileLanguage); fileAnalyses[file] = analysis; } catch (error) { console.warn(`Error analyzing file ${file}: ${(error as Error).message}`); } } // Step 3: Build knowledge graph console.log(`Building knowledge graph...`); const { nodes, relationships } = await buildKnowledgeGraph( repositoryUrl, 2, false ); // Step 4: Retrieve insights from memory console.log(`Retrieving memories about this repository...`); const memories = await retrieveMemories({ repositoryUrl, limit: 10, }); // Step 5: Generate the evolution plan based on target goal and timeframe console.log(`Generating ${targetGoal} plan...`); // Analyze major frameworks and libraries used const frameworks = detectFrameworks(files, fileAnalyses); // Analyze project structure const projectStructure = analyzeProjectStructure(files); // Generate plan based on target goal let plan; switch (targetGoal) { case "modernize-architecture": plan = generateModernizeArchitecturePlan( repositoryUrl, frameworks, projectStructure, fileAnalyses, timeframe, includeImplementationDetails ); break; case "improve-performance": plan = generatePerformancePlan( repositoryUrl, frameworks, fileAnalyses, timeframe, includeImplementationDetails ); break; case "enhance-security": plan = generateSecurityPlan( repositoryUrl, frameworks, fileAnalyses, timeframe, includeImplementationDetails ); break; case "reduce-technical-debt": plan = generateTechnicalDebtPlan( repositoryUrl, frameworks, projectStructure, fileAnalyses, timeframe, includeImplementationDetails ); break; default: throw new Error(`Unknown target goal: ${targetGoal}`); } // Return the evolution plan return { repository: { url: repositoryUrl, summary: summarizeRepository( files, fileAnalyses, frameworks, projectStructure ), }, targetGoal, timeframe, plan, }; }
  • Zod schema defining input parameters for the evolution-pathway tool: repository URL, target goal enum, timeframe enum, and optional implementation details flag.
    { repositoryUrl: z.string(), targetGoal: z.enum([ "modernize-architecture", "improve-performance", "enhance-security", "reduce-technical-debt" ]), timeframe: z.enum(["immediate", "sprint", "quarter", "year"]), includeImplementationDetails: z.boolean().default(true)
  • Helper function generating specific evolution plan for 'modernize-architecture' goal, including framework upgrades, structure improvements, with timeframe filtering and implementation steps.
    function generateModernizeArchitecturePlan( repositoryUrl: string, frameworks: Record<string, any>, projectStructure: Record<string, any>, fileAnalyses: Record<string, any>, timeframe: "immediate" | "sprint" | "quarter" | "year", includeImplementationDetails: boolean ): any { const recommendations: any[] = []; // Check for outdated frameworks if (frameworks.react) { const version = frameworks.react.version; if ((version && version.startsWith("15.")) || version.startsWith("16.")) { recommendations.push({ title: "Upgrade React to the latest version", description: "The project is using an older version of React. Upgrading will provide access to the latest features, performance improvements, and security patches.", priority: "high", effort: "medium", impact: "high", }); } } // Check for component architecture const hasComponentDir = projectStructure.topLevelDirectories.some( (dir: string) => dir === "components" || dir === "Components" ); if ( !hasComponentDir && (frameworks.react || frameworks.vue || frameworks.angular) ) { recommendations.push({ title: "Implement a clear component architecture", description: "Organize components into a dedicated directory structure to improve code organization and reusability.", priority: "medium", effort: "medium", impact: "high", }); } // Check for TypeScript usage if ( !frameworks.typescript && (frameworks.react || frameworks.vue || frameworks.angular) ) { recommendations.push({ title: "Migrate to TypeScript", description: "Adding TypeScript will improve type safety, developer experience, and make the codebase more maintainable.", priority: "medium", effort: "high", impact: "high", }); } // Generate timeframe-specific recommendations const timeframeRecommendations = filterRecommendationsByTimeframe( recommendations, timeframe ); // Add implementation details if requested if (includeImplementationDetails) { for (const rec of timeframeRecommendations) { rec.implementationSteps = generateImplementationSteps( rec.title, frameworks ); } } return { summary: `The architecture modernization plan focuses on ${timeframeRecommendations.length} key areas to improve over the ${timeframe} timeframe.`, recommendations: timeframeRecommendations, suggestedArchitecture: generateSuggestedArchitecture( frameworks, projectStructure ), }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/0xjcf/MCP_CodeAnalysis'

If you have feedback or need assistance with the MCP directory API, please join our Discord server