@ai-coders/context 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -68
- package/dist/commands/export.d.ts +4 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +39 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/fill.d.ts +13 -0
- package/dist/commands/fill.d.ts.map +1 -0
- package/dist/commands/fill.js +65 -0
- package/dist/commands/fill.js.map +1 -0
- package/dist/commands/index.d.ts +29 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +74 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +12 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +64 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +4 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +92 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/plan.d.ts +9 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +126 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/report.d.ts +4 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +36 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/serve.d.ts +4 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +29 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/skill.d.ts +4 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +217 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/start.d.ts +4 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +56 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/sync.d.ts +9 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +134 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/types.d.ts +17 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +3 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/update.d.ts +4 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +111 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/workflow.d.ts +4 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +171 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/generators/agents/agentGenerator.d.ts +2 -0
- package/dist/generators/agents/agentGenerator.d.ts.map +1 -1
- package/dist/generators/agents/agentGenerator.js +46 -2
- package/dist/generators/agents/agentGenerator.js.map +1 -1
- package/dist/generators/agents/templates/index.d.ts +0 -1
- package/dist/generators/agents/templates/index.d.ts.map +1 -1
- package/dist/generators/agents/templates/index.js +1 -3
- package/dist/generators/agents/templates/index.js.map +1 -1
- package/dist/generators/agents/templates/playbookTemplate.d.ts.map +1 -1
- package/dist/generators/agents/templates/playbookTemplate.js +11 -0
- package/dist/generators/agents/templates/playbookTemplate.js.map +1 -1
- package/dist/generators/documentation/documentationGenerator.d.ts +2 -1
- package/dist/generators/documentation/documentationGenerator.d.ts.map +1 -1
- package/dist/generators/documentation/documentationGenerator.js +53 -34
- package/dist/generators/documentation/documentationGenerator.js.map +1 -1
- package/dist/generators/documentation/templates/apiReferenceTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/apiReferenceTemplate.js +11 -0
- package/dist/generators/documentation/templates/apiReferenceTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/architectureTemplate.d.ts +11 -0
- package/dist/generators/documentation/templates/architectureTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/architectureTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/dataFlowTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/dataFlowTemplate.js +11 -0
- package/dist/generators/documentation/templates/dataFlowTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/developmentWorkflowTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/developmentWorkflowTemplate.js +11 -0
- package/dist/generators/documentation/templates/developmentWorkflowTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/glossaryTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/glossaryTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/index.d.ts +0 -12
- package/dist/generators/documentation/templates/index.d.ts.map +1 -1
- package/dist/generators/documentation/templates/index.js +1 -25
- package/dist/generators/documentation/templates/index.js.map +1 -1
- package/dist/generators/documentation/templates/migrationTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/migrationTemplate.js +11 -0
- package/dist/generators/documentation/templates/migrationTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/onboardingTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/onboardingTemplate.js +11 -0
- package/dist/generators/documentation/templates/onboardingTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/projectOverviewTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/projectOverviewTemplate.js +11 -0
- package/dist/generators/documentation/templates/projectOverviewTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/securityTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/securityTemplate.js +11 -0
- package/dist/generators/documentation/templates/securityTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/testingTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/testingTemplate.js +11 -0
- package/dist/generators/documentation/templates/testingTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/toolingTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/toolingTemplate.js +11 -0
- package/dist/generators/documentation/templates/toolingTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/troubleshootingTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/troubleshootingTemplate.js +11 -0
- package/dist/generators/documentation/templates/troubleshootingTemplate.js.map +1 -1
- package/dist/generators/plans/templates/planTemplate.d.ts +11 -0
- package/dist/generators/plans/templates/planTemplate.d.ts.map +1 -1
- package/dist/generators/plans/templates/planTemplate.js.map +1 -1
- package/dist/generators/shared/index.d.ts +1 -0
- package/dist/generators/shared/index.d.ts.map +1 -1
- package/dist/generators/shared/index.js +16 -0
- package/dist/generators/shared/index.js.map +1 -1
- package/dist/generators/shared/scaffoldStructures.d.ts +13 -0
- package/dist/generators/shared/scaffoldStructures.d.ts.map +1 -0
- package/dist/generators/shared/scaffoldStructures.js +30 -0
- package/dist/generators/shared/scaffoldStructures.js.map +1 -0
- package/dist/generators/shared/structures/agents/definitions.d.ts +18 -0
- package/dist/generators/shared/structures/agents/definitions.d.ts.map +1 -0
- package/dist/generators/shared/structures/agents/definitions.js +22 -0
- package/dist/generators/shared/structures/agents/definitions.js.map +1 -0
- package/dist/generators/shared/structures/agents/factory.d.ts +9 -0
- package/dist/generators/shared/structures/agents/factory.d.ts.map +1 -0
- package/dist/generators/shared/structures/agents/factory.js +112 -0
- package/dist/generators/shared/structures/agents/factory.js.map +1 -0
- package/dist/generators/shared/structures/agents/index.d.ts +6 -0
- package/dist/generators/shared/structures/agents/index.d.ts.map +1 -0
- package/dist/generators/shared/structures/agents/index.js +24 -0
- package/dist/generators/shared/structures/agents/index.js.map +1 -0
- package/dist/generators/shared/structures/documentation/apiReference.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/apiReference.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/apiReference.js +100 -0
- package/dist/generators/shared/structures/documentation/apiReference.js.map +1 -0
- package/dist/generators/shared/structures/documentation/architecture.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/architecture.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/architecture.js +121 -0
- package/dist/generators/shared/structures/documentation/architecture.js.map +1 -0
- package/dist/generators/shared/structures/documentation/dataFlow.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/dataFlow.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/dataFlow.js +72 -0
- package/dist/generators/shared/structures/documentation/dataFlow.js.map +1 -0
- package/dist/generators/shared/structures/documentation/glossary.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/glossary.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/glossary.js +71 -0
- package/dist/generators/shared/structures/documentation/glossary.js.map +1 -0
- package/dist/generators/shared/structures/documentation/index.d.ts +16 -0
- package/dist/generators/shared/structures/documentation/index.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/index.js +31 -0
- package/dist/generators/shared/structures/documentation/index.js.map +1 -0
- package/dist/generators/shared/structures/documentation/migration.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/migration.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/migration.js +113 -0
- package/dist/generators/shared/structures/documentation/migration.js.map +1 -0
- package/dist/generators/shared/structures/documentation/onboarding.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/onboarding.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/onboarding.js +99 -0
- package/dist/generators/shared/structures/documentation/onboarding.js.map +1 -0
- package/dist/generators/shared/structures/documentation/projectOverview.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/projectOverview.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/projectOverview.js +115 -0
- package/dist/generators/shared/structures/documentation/projectOverview.js.map +1 -0
- package/dist/generators/shared/structures/documentation/security.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/security.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/security.js +55 -0
- package/dist/generators/shared/structures/documentation/security.js.map +1 -0
- package/dist/generators/shared/structures/documentation/testing.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/testing.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/testing.js +57 -0
- package/dist/generators/shared/structures/documentation/testing.js.map +1 -0
- package/dist/generators/shared/structures/documentation/tooling.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/tooling.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/tooling.js +55 -0
- package/dist/generators/shared/structures/documentation/tooling.js.map +1 -0
- package/dist/generators/shared/structures/documentation/troubleshooting.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/troubleshooting.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/troubleshooting.js +91 -0
- package/dist/generators/shared/structures/documentation/troubleshooting.js.map +1 -0
- package/dist/generators/shared/structures/documentation/workflow.d.ts +3 -0
- package/dist/generators/shared/structures/documentation/workflow.d.ts.map +1 -0
- package/dist/generators/shared/structures/documentation/workflow.js +56 -0
- package/dist/generators/shared/structures/documentation/workflow.js.map +1 -0
- package/dist/generators/shared/structures/index.d.ts +15 -0
- package/dist/generators/shared/structures/index.d.ts.map +1 -0
- package/dist/generators/shared/structures/index.js +37 -0
- package/dist/generators/shared/structures/index.js.map +1 -0
- package/dist/generators/shared/structures/plans/index.d.ts +5 -0
- package/dist/generators/shared/structures/plans/index.d.ts.map +1 -0
- package/dist/generators/shared/structures/plans/index.js +9 -0
- package/dist/generators/shared/structures/plans/index.js.map +1 -0
- package/dist/generators/shared/structures/plans/planStructure.d.ts +6 -0
- package/dist/generators/shared/structures/plans/planStructure.d.ts.map +1 -0
- package/dist/generators/shared/structures/plans/planStructure.js +65 -0
- package/dist/generators/shared/structures/plans/planStructure.js.map +1 -0
- package/dist/generators/shared/structures/registry.d.ts +18 -0
- package/dist/generators/shared/structures/registry.d.ts.map +1 -0
- package/dist/generators/shared/structures/registry.js +104 -0
- package/dist/generators/shared/structures/registry.js.map +1 -0
- package/dist/generators/shared/structures/serialization.d.ts +15 -0
- package/dist/generators/shared/structures/serialization.d.ts.map +1 -0
- package/dist/generators/shared/structures/serialization.js +119 -0
- package/dist/generators/shared/structures/serialization.js.map +1 -0
- package/dist/generators/shared/structures/skills/definitions.d.ts +14 -0
- package/dist/generators/shared/structures/skills/definitions.d.ts.map +1 -0
- package/dist/generators/shared/structures/skills/definitions.js +18 -0
- package/dist/generators/shared/structures/skills/definitions.js.map +1 -0
- package/dist/generators/shared/structures/skills/factory.d.ts +9 -0
- package/dist/generators/shared/structures/skills/factory.d.ts.map +1 -0
- package/dist/generators/shared/structures/skills/factory.js +56 -0
- package/dist/generators/shared/structures/skills/factory.js.map +1 -0
- package/dist/generators/shared/structures/skills/index.d.ts +6 -0
- package/dist/generators/shared/structures/skills/index.d.ts.map +1 -0
- package/dist/generators/shared/structures/skills/index.js +20 -0
- package/dist/generators/shared/structures/skills/index.js.map +1 -0
- package/dist/generators/shared/structures/types.d.ts +59 -0
- package/dist/generators/shared/structures/types.d.ts.map +1 -0
- package/dist/generators/shared/structures/types.js +6 -0
- package/dist/generators/shared/structures/types.js.map +1 -0
- package/dist/generators/shared/structures/validation.d.ts +13 -0
- package/dist/generators/shared/structures/validation.d.ts.map +1 -0
- package/dist/generators/shared/structures/validation.js +51 -0
- package/dist/generators/shared/structures/validation.js.map +1 -0
- package/dist/generators/skills/skillGenerator.d.ts +5 -0
- package/dist/generators/skills/skillGenerator.d.ts.map +1 -1
- package/dist/generators/skills/skillGenerator.js +26 -17
- package/dist/generators/skills/skillGenerator.js.map +1 -1
- package/dist/generators/skills/templates/skillTemplate.d.ts +10 -0
- package/dist/generators/skills/templates/skillTemplate.d.ts.map +1 -1
- package/dist/generators/skills/templates/skillTemplate.js +10 -0
- package/dist/generators/skills/templates/skillTemplate.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +203 -5
- package/dist/index.js.map +1 -1
- package/dist/prompts/defaults.d.ts +5 -0
- package/dist/prompts/defaults.d.ts.map +1 -1
- package/dist/prompts/defaults.js +44 -1
- package/dist/prompts/defaults.js.map +1 -1
- package/dist/services/ai/agents/documentationAgent.d.ts +2 -0
- package/dist/services/ai/agents/documentationAgent.d.ts.map +1 -1
- package/dist/services/ai/agents/documentationAgent.js +33 -9
- package/dist/services/ai/agents/documentationAgent.js.map +1 -1
- package/dist/services/ai/agents/playbookAgent.d.ts +2 -0
- package/dist/services/ai/agents/playbookAgent.d.ts.map +1 -1
- package/dist/services/ai/agents/playbookAgent.js +44 -19
- package/dist/services/ai/agents/playbookAgent.js.map +1 -1
- package/dist/services/ai/agents/skillAgent.d.ts +2 -0
- package/dist/services/ai/agents/skillAgent.d.ts.map +1 -1
- package/dist/services/ai/agents/skillAgent.js +54 -22
- package/dist/services/ai/agents/skillAgent.js.map +1 -1
- package/dist/services/ai/schemas.d.ts +136 -9
- package/dist/services/ai/schemas.d.ts.map +1 -1
- package/dist/services/ai/schemas.js +65 -4
- package/dist/services/ai/schemas.js.map +1 -1
- package/dist/services/ai/toolRegistry.d.ts.map +1 -1
- package/dist/services/ai/toolRegistry.js +25 -17
- package/dist/services/ai/toolRegistry.js.map +1 -1
- package/dist/services/ai/tools/checkScaffoldingTool.d.ts.map +1 -1
- package/dist/services/ai/tools/checkScaffoldingTool.js +4 -1
- package/dist/services/ai/tools/checkScaffoldingTool.js.map +1 -1
- package/dist/services/ai/tools/fillScaffoldingTool.d.ts +19 -21
- package/dist/services/ai/tools/fillScaffoldingTool.d.ts.map +1 -1
- package/dist/services/ai/tools/fillScaffoldingTool.js +41 -142
- package/dist/services/ai/tools/fillScaffoldingTool.js.map +1 -1
- package/dist/services/ai/tools/getCodebaseMapTool.d.ts +1 -1
- package/dist/services/ai/tools/getCodebaseMapTool.d.ts.map +1 -1
- package/dist/services/ai/tools/getCodebaseMapTool.js +4 -1
- package/dist/services/ai/tools/getCodebaseMapTool.js.map +1 -1
- package/dist/services/ai/tools/index.d.ts +1 -1
- package/dist/services/ai/tools/index.d.ts.map +1 -1
- package/dist/services/ai/tools/index.js +1 -3
- package/dist/services/ai/tools/index.js.map +1 -1
- package/dist/services/ai/tools/initializeContextTool.d.ts +108 -16
- package/dist/services/ai/tools/initializeContextTool.d.ts.map +1 -1
- package/dist/services/ai/tools/initializeContextTool.js +177 -67
- package/dist/services/ai/tools/initializeContextTool.js.map +1 -1
- package/dist/services/ai/tools/scaffoldPlanTool.d.ts +14 -3
- package/dist/services/ai/tools/scaffoldPlanTool.d.ts.map +1 -1
- package/dist/services/ai/tools/scaffoldPlanTool.js +34 -4
- package/dist/services/ai/tools/scaffoldPlanTool.js.map +1 -1
- package/dist/services/ai/tools/toolFactory.d.ts +35 -0
- package/dist/services/ai/tools/toolFactory.d.ts.map +1 -0
- package/dist/services/ai/tools/toolFactory.js +20 -0
- package/dist/services/ai/tools/toolFactory.js.map +1 -0
- package/dist/services/export/contextExportService.d.ts +45 -0
- package/dist/services/export/contextExportService.d.ts.map +1 -0
- package/dist/services/export/contextExportService.js +161 -0
- package/dist/services/export/contextExportService.js.map +1 -0
- package/dist/services/export/exportRulesService.d.ts +15 -1
- package/dist/services/export/exportRulesService.d.ts.map +1 -1
- package/dist/services/export/exportRulesService.js +100 -36
- package/dist/services/export/exportRulesService.js.map +1 -1
- package/dist/services/export/index.d.ts +2 -0
- package/dist/services/export/index.d.ts.map +1 -1
- package/dist/services/export/index.js +3 -1
- package/dist/services/export/index.js.map +1 -1
- package/dist/services/export/skillExportService.d.ts +6 -1
- package/dist/services/export/skillExportService.d.ts.map +1 -1
- package/dist/services/export/skillExportService.js +46 -22
- package/dist/services/export/skillExportService.js.map +1 -1
- package/dist/services/fill/fillService.d.ts.map +1 -1
- package/dist/services/fill/fillService.js +30 -3
- package/dist/services/fill/fillService.js.map +1 -1
- package/dist/services/fill/skillFillService.d.ts.map +1 -1
- package/dist/services/fill/skillFillService.js +8 -1
- package/dist/services/fill/skillFillService.js.map +1 -1
- package/dist/services/import/presets.d.ts +12 -0
- package/dist/services/import/presets.d.ts.map +1 -1
- package/dist/services/import/presets.js +32 -152
- package/dist/services/import/presets.js.map +1 -1
- package/dist/services/init/initService.d.ts +1 -0
- package/dist/services/init/initService.d.ts.map +1 -1
- package/dist/services/init/initService.js +42 -9
- package/dist/services/init/initService.js.map +1 -1
- package/dist/services/mcp/actionLogger.d.ts +19 -0
- package/dist/services/mcp/actionLogger.d.ts.map +1 -0
- package/dist/services/mcp/actionLogger.js +128 -0
- package/dist/services/mcp/actionLogger.js.map +1 -0
- package/dist/services/mcp/gateway/agent.d.ts +17 -0
- package/dist/services/mcp/gateway/agent.d.ts.map +1 -0
- package/dist/services/mcp/gateway/agent.js +147 -0
- package/dist/services/mcp/gateway/agent.js.map +1 -0
- package/dist/services/mcp/gateway/context.d.ts +21 -0
- package/dist/services/mcp/gateway/context.d.ts.map +1 -0
- package/dist/services/mcp/gateway/context.js +249 -0
- package/dist/services/mcp/gateway/context.js.map +1 -0
- package/dist/services/mcp/gateway/explore.d.ts +16 -0
- package/dist/services/mcp/gateway/explore.d.ts.map +1 -0
- package/dist/services/mcp/gateway/explore.js +60 -0
- package/dist/services/mcp/gateway/explore.js.map +1 -0
- package/dist/services/mcp/gateway/index.d.ts +24 -0
- package/dist/services/mcp/gateway/index.d.ts.map +1 -0
- package/dist/services/mcp/gateway/index.js +53 -0
- package/dist/services/mcp/gateway/index.js.map +1 -0
- package/dist/services/mcp/gateway/metrics.d.ts +56 -0
- package/dist/services/mcp/gateway/metrics.d.ts.map +1 -0
- package/dist/services/mcp/gateway/metrics.js +153 -0
- package/dist/services/mcp/gateway/metrics.js.map +1 -0
- package/dist/services/mcp/gateway/plan.d.ts +18 -0
- package/dist/services/mcp/gateway/plan.d.ts.map +1 -0
- package/dist/services/mcp/gateway/plan.js +273 -0
- package/dist/services/mcp/gateway/plan.js.map +1 -0
- package/dist/services/mcp/gateway/project.d.ts +16 -0
- package/dist/services/mcp/gateway/project.d.ts.map +1 -0
- package/dist/services/mcp/gateway/project.js +149 -0
- package/dist/services/mcp/gateway/project.js.map +1 -0
- package/dist/services/mcp/gateway/projectReport.d.ts +20 -0
- package/dist/services/mcp/gateway/projectReport.d.ts.map +1 -0
- package/dist/services/mcp/gateway/projectReport.js +61 -0
- package/dist/services/mcp/gateway/projectReport.js.map +1 -0
- package/dist/services/mcp/gateway/projectSetup.d.ts +29 -0
- package/dist/services/mcp/gateway/projectSetup.d.ts.map +1 -0
- package/dist/services/mcp/gateway/projectSetup.js +141 -0
- package/dist/services/mcp/gateway/projectSetup.js.map +1 -0
- package/dist/services/mcp/gateway/response.d.ts +45 -0
- package/dist/services/mcp/gateway/response.d.ts.map +1 -0
- package/dist/services/mcp/gateway/response.js +111 -0
- package/dist/services/mcp/gateway/response.js.map +1 -0
- package/dist/services/mcp/gateway/shared.d.ts +38 -0
- package/dist/services/mcp/gateway/shared.d.ts.map +1 -0
- package/dist/services/mcp/gateway/shared.js +39 -0
- package/dist/services/mcp/gateway/shared.js.map +1 -0
- package/dist/services/mcp/gateway/skill.d.ts +17 -0
- package/dist/services/mcp/gateway/skill.d.ts.map +1 -0
- package/dist/services/mcp/gateway/skill.js +323 -0
- package/dist/services/mcp/gateway/skill.js.map +1 -0
- package/dist/services/mcp/gateway/sync.d.ts +17 -0
- package/dist/services/mcp/gateway/sync.d.ts.map +1 -0
- package/dist/services/mcp/gateway/sync.js +219 -0
- package/dist/services/mcp/gateway/sync.js.map +1 -0
- package/dist/services/mcp/gateway/types.d.ts +116 -0
- package/dist/services/mcp/gateway/types.d.ts.map +1 -0
- package/dist/services/mcp/gateway/types.js +12 -0
- package/dist/services/mcp/gateway/types.js.map +1 -0
- package/dist/services/mcp/gateway/workflow.d.ts +18 -0
- package/dist/services/mcp/gateway/workflow.d.ts.map +1 -0
- package/dist/services/mcp/gateway/workflow.js +317 -0
- package/dist/services/mcp/gateway/workflow.js.map +1 -0
- package/dist/services/mcp/gateway/workflowAdvance.d.ts +25 -0
- package/dist/services/mcp/gateway/workflowAdvance.d.ts.map +1 -0
- package/dist/services/mcp/gateway/workflowAdvance.js +133 -0
- package/dist/services/mcp/gateway/workflowAdvance.js.map +1 -0
- package/dist/services/mcp/gateway/workflowInit.d.ts +28 -0
- package/dist/services/mcp/gateway/workflowInit.d.ts.map +1 -0
- package/dist/services/mcp/gateway/workflowInit.js +213 -0
- package/dist/services/mcp/gateway/workflowInit.js.map +1 -0
- package/dist/services/mcp/gateway/workflowManage.d.ts +31 -0
- package/dist/services/mcp/gateway/workflowManage.d.ts.map +1 -0
- package/dist/services/mcp/gateway/workflowManage.js +222 -0
- package/dist/services/mcp/gateway/workflowManage.js.map +1 -0
- package/dist/services/mcp/gateway/workflowStatus.d.ts +17 -0
- package/dist/services/mcp/gateway/workflowStatus.d.ts.map +1 -0
- package/dist/services/mcp/gateway/workflowStatus.js +91 -0
- package/dist/services/mcp/gateway/workflowStatus.js.map +1 -0
- package/dist/services/mcp/gatewayTools.d.ts +15 -0
- package/dist/services/mcp/gatewayTools.d.ts.map +1 -0
- package/dist/services/mcp/gatewayTools.js +38 -0
- package/dist/services/mcp/gatewayTools.js.map +1 -0
- package/dist/services/mcp/index.d.ts +7 -0
- package/dist/services/mcp/index.d.ts.map +1 -1
- package/dist/services/mcp/index.js +22 -1
- package/dist/services/mcp/index.js.map +1 -1
- package/dist/services/mcp/mcpInstallService.d.ts +56 -0
- package/dist/services/mcp/mcpInstallService.d.ts.map +1 -0
- package/dist/services/mcp/mcpInstallService.js +549 -0
- package/dist/services/mcp/mcpInstallService.js.map +1 -0
- package/dist/services/mcp/mcpServer.d.ts +45 -19
- package/dist/services/mcp/mcpServer.d.ts.map +1 -1
- package/dist/services/mcp/mcpServer.js +592 -1845
- package/dist/services/mcp/mcpServer.js.map +1 -1
- package/dist/services/passthrough/protocol.d.ts +4 -4
- package/dist/services/qa/index.d.ts +9 -0
- package/dist/services/qa/index.d.ts.map +1 -0
- package/dist/services/qa/index.js +15 -0
- package/dist/services/qa/index.js.map +1 -0
- package/dist/services/qa/patternInferer.d.ts +41 -0
- package/dist/services/qa/patternInferer.d.ts.map +1 -0
- package/dist/services/qa/patternInferer.js +366 -0
- package/dist/services/qa/patternInferer.js.map +1 -0
- package/dist/services/qa/qaService.d.ts +107 -0
- package/dist/services/qa/qaService.d.ts.map +1 -0
- package/dist/services/qa/qaService.js +874 -0
- package/dist/services/qa/qaService.js.map +1 -0
- package/dist/services/qa/topicDetector.d.ts +54 -0
- package/dist/services/qa/topicDetector.d.ts.map +1 -0
- package/dist/services/qa/topicDetector.js +306 -0
- package/dist/services/qa/topicDetector.js.map +1 -0
- package/dist/services/quickSync/quickSyncService.d.ts.map +1 -1
- package/dist/services/quickSync/quickSyncService.js +6 -10
- package/dist/services/quickSync/quickSyncService.js.map +1 -1
- package/dist/services/reverseSync/importSkillsService.d.ts +47 -0
- package/dist/services/reverseSync/importSkillsService.d.ts.map +1 -0
- package/dist/services/reverseSync/importSkillsService.js +362 -0
- package/dist/services/reverseSync/importSkillsService.js.map +1 -0
- package/dist/services/reverseSync/index.d.ts +12 -0
- package/dist/services/reverseSync/index.d.ts.map +1 -0
- package/dist/services/reverseSync/index.js +49 -0
- package/dist/services/reverseSync/index.js.map +1 -0
- package/dist/services/reverseSync/presets.d.ts +51 -0
- package/dist/services/reverseSync/presets.d.ts.map +1 -0
- package/dist/services/reverseSync/presets.js +77 -0
- package/dist/services/reverseSync/presets.js.map +1 -0
- package/dist/services/reverseSync/reverseQuickSyncService.d.ts +37 -0
- package/dist/services/reverseSync/reverseQuickSyncService.d.ts.map +1 -0
- package/dist/services/reverseSync/reverseQuickSyncService.js +265 -0
- package/dist/services/reverseSync/reverseQuickSyncService.js.map +1 -0
- package/dist/services/reverseSync/skillsDetector.d.ts +36 -0
- package/dist/services/reverseSync/skillsDetector.d.ts.map +1 -0
- package/dist/services/reverseSync/skillsDetector.js +287 -0
- package/dist/services/reverseSync/skillsDetector.js.map +1 -0
- package/dist/services/reverseSync/toolDetector.d.ts +36 -0
- package/dist/services/reverseSync/toolDetector.d.ts.map +1 -0
- package/dist/services/reverseSync/toolDetector.js +174 -0
- package/dist/services/reverseSync/toolDetector.js.map +1 -0
- package/dist/services/reverseSync/types.d.ts +203 -0
- package/dist/services/reverseSync/types.d.ts.map +1 -0
- package/dist/services/reverseSync/types.js +9 -0
- package/dist/services/reverseSync/types.js.map +1 -0
- package/dist/services/semantic/codebaseAnalyzer.d.ts +23 -1
- package/dist/services/semantic/codebaseAnalyzer.d.ts.map +1 -1
- package/dist/services/semantic/codebaseAnalyzer.js +531 -0
- package/dist/services/semantic/codebaseAnalyzer.js.map +1 -1
- package/dist/services/semantic/contextBuilder.d.ts.map +1 -1
- package/dist/services/semantic/contextBuilder.js +23 -8
- package/dist/services/semantic/contextBuilder.js.map +1 -1
- package/dist/services/semantic/types.d.ts +50 -0
- package/dist/services/semantic/types.d.ts.map +1 -1
- package/dist/services/semantic/types.js.map +1 -1
- package/dist/services/shared/contentTypeRegistry.d.ts +66 -0
- package/dist/services/shared/contentTypeRegistry.d.ts.map +1 -0
- package/dist/services/shared/contentTypeRegistry.js +113 -0
- package/dist/services/shared/contentTypeRegistry.js.map +1 -0
- package/dist/services/shared/contextRootResolver.d.ts +57 -0
- package/dist/services/shared/contextRootResolver.d.ts.map +1 -0
- package/dist/services/shared/contextRootResolver.js +102 -0
- package/dist/services/shared/contextRootResolver.js.map +1 -0
- package/dist/services/shared/index.d.ts +4 -1
- package/dist/services/shared/index.d.ts.map +1 -1
- package/dist/services/shared/index.js +39 -1
- package/dist/services/shared/index.js.map +1 -1
- package/dist/services/shared/pathHelpers.d.ts +15 -1
- package/dist/services/shared/pathHelpers.d.ts.map +1 -1
- package/dist/services/shared/pathHelpers.js +26 -1
- package/dist/services/shared/pathHelpers.js.map +1 -1
- package/dist/services/shared/toolRegistry.d.ts +135 -0
- package/dist/services/shared/toolRegistry.d.ts.map +1 -0
- package/dist/services/shared/toolRegistry.js +515 -0
- package/dist/services/shared/toolRegistry.js.map +1 -0
- package/dist/services/stack/scaffoldFilter.d.ts +1 -1
- package/dist/services/sync/presets.d.ts +3 -0
- package/dist/services/sync/presets.d.ts.map +1 -1
- package/dist/services/sync/presets.js +20 -32
- package/dist/services/sync/presets.js.map +1 -1
- package/dist/services/sync/syncService.d.ts +8 -0
- package/dist/services/sync/syncService.d.ts.map +1 -1
- package/dist/services/sync/syncService.js +21 -2
- package/dist/services/sync/syncService.js.map +1 -1
- package/dist/services/sync/types.d.ts +1 -1
- package/dist/services/sync/types.d.ts.map +1 -1
- package/dist/services/tools/index.d.ts +95 -0
- package/dist/services/tools/index.d.ts.map +1 -0
- package/dist/services/tools/index.js +236 -0
- package/dist/services/tools/index.js.map +1 -0
- package/dist/services/workflow/workflowService.d.ts +57 -4
- package/dist/services/workflow/workflowService.d.ts.map +1 -1
- package/dist/services/workflow/workflowService.js +79 -6
- package/dist/services/workflow/workflowService.js.map +1 -1
- package/dist/types/scaffoldFrontmatter.d.ts +145 -0
- package/dist/types/scaffoldFrontmatter.d.ts.map +1 -0
- package/dist/types/scaffoldFrontmatter.js +172 -0
- package/dist/types/scaffoldFrontmatter.js.map +1 -0
- package/dist/utils/cliUI.d.ts +1 -1
- package/dist/utils/cliUI.d.ts.map +1 -1
- package/dist/utils/cliUI.js +4 -1
- package/dist/utils/cliUI.js.map +1 -1
- package/dist/utils/frontMatter.d.ts +48 -0
- package/dist/utils/frontMatter.d.ts.map +1 -1
- package/dist/utils/frontMatter.js +135 -0
- package/dist/utils/frontMatter.js.map +1 -1
- package/dist/utils/gitService.d.ts +26 -0
- package/dist/utils/gitService.d.ts.map +1 -1
- package/dist/utils/gitService.js +96 -0
- package/dist/utils/gitService.js.map +1 -1
- package/dist/utils/i18n.d.ts +43 -2
- package/dist/utils/i18n.d.ts.map +1 -1
- package/dist/utils/i18n.js +96 -6
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/prompts/index.d.ts +4 -0
- package/dist/utils/prompts/index.d.ts.map +1 -1
- package/dist/utils/prompts/index.js +15 -0
- package/dist/utils/prompts/index.js.map +1 -1
- package/dist/workflow/errors.d.ts +48 -0
- package/dist/workflow/errors.d.ts.map +1 -0
- package/dist/workflow/errors.js +52 -0
- package/dist/workflow/errors.js.map +1 -0
- package/dist/workflow/gates/gateChecker.d.ts +93 -0
- package/dist/workflow/gates/gateChecker.d.ts.map +1 -0
- package/dist/workflow/gates/gateChecker.js +197 -0
- package/dist/workflow/gates/gateChecker.js.map +1 -0
- package/dist/workflow/gates/index.d.ts +7 -0
- package/dist/workflow/gates/index.d.ts.map +1 -0
- package/dist/workflow/gates/index.js +13 -0
- package/dist/workflow/gates/index.js.map +1 -0
- package/dist/workflow/index.d.ts +4 -2
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +14 -3
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/orchestrator.d.ts +94 -5
- package/dist/workflow/orchestrator.d.ts.map +1 -1
- package/dist/workflow/orchestrator.js +300 -11
- package/dist/workflow/orchestrator.js.map +1 -1
- package/dist/workflow/plans/planLinker.d.ts +79 -3
- package/dist/workflow/plans/planLinker.d.ts.map +1 -1
- package/dist/workflow/plans/planLinker.js +522 -3
- package/dist/workflow/plans/planLinker.js.map +1 -1
- package/dist/workflow/plans/types.d.ts +64 -0
- package/dist/workflow/plans/types.d.ts.map +1 -1
- package/dist/workflow/roles.d.ts +6 -0
- package/dist/workflow/roles.d.ts.map +1 -1
- package/dist/workflow/roles.js +6 -0
- package/dist/workflow/roles.js.map +1 -1
- package/dist/workflow/scaling.d.ts +1 -0
- package/dist/workflow/scaling.d.ts.map +1 -1
- package/dist/workflow/scaling.js +8 -17
- package/dist/workflow/scaling.js.map +1 -1
- package/dist/workflow/status/statusManager.d.ts +54 -1
- package/dist/workflow/status/statusManager.d.ts.map +1 -1
- package/dist/workflow/status/statusManager.js +539 -9
- package/dist/workflow/status/statusManager.js.map +1 -1
- package/dist/workflow/status/templates.d.ts +14 -5
- package/dist/workflow/status/templates.d.ts.map +1 -1
- package/dist/workflow/status/templates.js +55 -41
- package/dist/workflow/status/templates.js.map +1 -1
- package/dist/workflow/types.d.ts +138 -2
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workflow/types.js +0 -1
- package/dist/workflow/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* MCP Server - Model Context Protocol server for Claude Code integration
|
|
4
4
|
*
|
|
5
|
-
* Exposes
|
|
5
|
+
* Exposes 9 tools (5 consolidated gateways + 4 dedicated workflow tools) for
|
|
6
|
+
* reduced context and simpler tool selection for AI agents.
|
|
7
|
+
*
|
|
8
|
+
* Simplified workflow: context init → fillSingle → workflow-init
|
|
6
9
|
*/
|
|
7
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
11
|
if (k2 === undefined) k2 = k;
|
|
@@ -44,1214 +47,459 @@ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
|
44
47
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
45
48
|
const zod_1 = require("zod");
|
|
46
49
|
const path = __importStar(require("path"));
|
|
50
|
+
const fs = __importStar(require("fs-extra"));
|
|
47
51
|
const tools_1 = require("../ai/tools");
|
|
48
|
-
const toolRegistry_1 = require("../ai/toolRegistry");
|
|
49
52
|
const contextBuilder_1 = require("../semantic/contextBuilder");
|
|
50
53
|
const version_1 = require("../../version");
|
|
51
|
-
const providerFactory_1 = require("../ai/providerFactory");
|
|
52
54
|
const workflow_1 = require("../workflow");
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
name: this.options.name,
|
|
70
|
-
version: version_1.VERSION
|
|
71
|
-
});
|
|
72
|
-
this.contextBuilder = new contextBuilder_1.SemanticContextBuilder();
|
|
73
|
-
this.registerTools();
|
|
74
|
-
this.registerResources();
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Register code analysis tools
|
|
78
|
-
*/
|
|
79
|
-
registerTools() {
|
|
80
|
-
// readFile tool
|
|
81
|
-
this.server.registerTool('readFile', {
|
|
82
|
-
description: (0, toolRegistry_1.getToolDescription)('readFile'),
|
|
83
|
-
inputSchema: {
|
|
84
|
-
filePath: zod_1.z.string().describe('Absolute or relative path to the file to read'),
|
|
85
|
-
encoding: zod_1.z.enum(['utf-8', 'ascii', 'binary']).default('utf-8').optional()
|
|
86
|
-
}
|
|
87
|
-
}, async ({ filePath, encoding }) => {
|
|
88
|
-
const result = await tools_1.readFileTool.execute({ filePath, encoding }, { toolCallId: '', messages: [] });
|
|
89
|
-
return {
|
|
90
|
-
content: [{
|
|
91
|
-
type: 'text',
|
|
92
|
-
text: JSON.stringify(result, null, 2)
|
|
93
|
-
}]
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
// listFiles tool
|
|
97
|
-
this.server.registerTool('listFiles', {
|
|
98
|
-
description: (0, toolRegistry_1.getToolDescription)('listFiles'),
|
|
99
|
-
inputSchema: {
|
|
100
|
-
pattern: zod_1.z.string().describe('Glob pattern to match files (e.g., "**/*.ts")'),
|
|
101
|
-
cwd: zod_1.z.string().optional().describe('Working directory for the glob pattern'),
|
|
102
|
-
ignore: zod_1.z.array(zod_1.z.string()).optional().describe('Patterns to ignore')
|
|
103
|
-
}
|
|
104
|
-
}, async ({ pattern, cwd, ignore }) => {
|
|
105
|
-
const result = await tools_1.listFilesTool.execute({ pattern, cwd: cwd || this.options.repoPath, ignore }, { toolCallId: '', messages: [] });
|
|
106
|
-
return {
|
|
107
|
-
content: [{
|
|
108
|
-
type: 'text',
|
|
109
|
-
text: JSON.stringify(result, null, 2)
|
|
110
|
-
}]
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
// analyzeSymbols tool
|
|
114
|
-
this.server.registerTool('analyzeSymbols', {
|
|
115
|
-
description: (0, toolRegistry_1.getToolDescription)('analyzeSymbols'),
|
|
116
|
-
inputSchema: {
|
|
117
|
-
filePath: zod_1.z.string().describe('Path to the file to analyze'),
|
|
118
|
-
symbolTypes: zod_1.z.array(zod_1.z.enum(['class', 'interface', 'function', 'type', 'enum']))
|
|
119
|
-
.optional()
|
|
120
|
-
.describe('Types of symbols to extract')
|
|
121
|
-
}
|
|
122
|
-
}, async ({ filePath, symbolTypes }) => {
|
|
123
|
-
const result = await tools_1.analyzeSymbolsTool.execute({ filePath, symbolTypes }, { toolCallId: '', messages: [] });
|
|
124
|
-
return {
|
|
125
|
-
content: [{
|
|
126
|
-
type: 'text',
|
|
127
|
-
text: JSON.stringify(result, null, 2)
|
|
128
|
-
}]
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
// getFileStructure tool
|
|
132
|
-
this.server.registerTool('getFileStructure', {
|
|
133
|
-
description: (0, toolRegistry_1.getToolDescription)('getFileStructure'),
|
|
134
|
-
inputSchema: {
|
|
135
|
-
rootPath: zod_1.z.string().describe('Root path of the repository'),
|
|
136
|
-
maxDepth: zod_1.z.number().optional().default(3).describe('Maximum directory depth'),
|
|
137
|
-
includePatterns: zod_1.z.array(zod_1.z.string()).optional()
|
|
138
|
-
}
|
|
139
|
-
}, async ({ rootPath, maxDepth, includePatterns }) => {
|
|
140
|
-
const result = await tools_1.getFileStructureTool.execute({ rootPath: rootPath || this.options.repoPath || '.', maxDepth, includePatterns }, { toolCallId: '', messages: [] });
|
|
141
|
-
return {
|
|
142
|
-
content: [{
|
|
143
|
-
type: 'text',
|
|
144
|
-
text: JSON.stringify(result, null, 2)
|
|
145
|
-
}]
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
// searchCode tool
|
|
149
|
-
this.server.registerTool('searchCode', {
|
|
150
|
-
description: (0, toolRegistry_1.getToolDescription)('searchCode'),
|
|
151
|
-
inputSchema: {
|
|
152
|
-
pattern: zod_1.z.string().describe('Regex pattern to search for'),
|
|
153
|
-
fileGlob: zod_1.z.string().optional().describe('Glob pattern to filter files'),
|
|
154
|
-
maxResults: zod_1.z.number().optional().default(50),
|
|
155
|
-
cwd: zod_1.z.string().optional().describe('Working directory for the search')
|
|
156
|
-
}
|
|
157
|
-
}, async ({ pattern, fileGlob, maxResults, cwd }) => {
|
|
158
|
-
const result = await tools_1.searchCodeTool.execute({
|
|
159
|
-
pattern,
|
|
160
|
-
fileGlob,
|
|
161
|
-
maxResults,
|
|
162
|
-
cwd: cwd || this.options.repoPath
|
|
163
|
-
}, { toolCallId: '', messages: [] });
|
|
164
|
-
return {
|
|
165
|
-
content: [{
|
|
166
|
-
type: 'text',
|
|
167
|
-
text: JSON.stringify(result, null, 2)
|
|
168
|
-
}]
|
|
169
|
-
};
|
|
170
|
-
});
|
|
171
|
-
// buildSemanticContext tool - higher-level context building
|
|
172
|
-
this.server.registerTool('buildSemanticContext', {
|
|
173
|
-
description: (0, toolRegistry_1.getToolDescription)('buildSemanticContext'),
|
|
174
|
-
inputSchema: {
|
|
175
|
-
repoPath: zod_1.z.string().describe('Path to the repository'),
|
|
176
|
-
contextType: zod_1.z.enum(['documentation', 'playbook', 'plan', 'compact'])
|
|
177
|
-
.default('compact')
|
|
178
|
-
.describe('Type of context to build'),
|
|
179
|
-
targetFile: zod_1.z.string().optional().describe('Optional target file for focused context'),
|
|
180
|
-
options: zod_1.z.object({
|
|
181
|
-
useLSP: zod_1.z.boolean().optional(),
|
|
182
|
-
maxContextLength: zod_1.z.number().optional(),
|
|
183
|
-
includeDocumentation: zod_1.z.boolean().optional(),
|
|
184
|
-
includeSignatures: zod_1.z.boolean().optional()
|
|
185
|
-
}).optional()
|
|
186
|
-
}
|
|
187
|
-
}, async ({ repoPath, contextType, targetFile, options }) => {
|
|
188
|
-
const isLocalBuilder = !!options;
|
|
189
|
-
const builder = isLocalBuilder
|
|
190
|
-
? new contextBuilder_1.SemanticContextBuilder(options)
|
|
191
|
-
: this.contextBuilder;
|
|
192
|
-
try {
|
|
193
|
-
let context;
|
|
194
|
-
const resolvedPath = repoPath || this.options.repoPath || '.';
|
|
195
|
-
switch (contextType) {
|
|
196
|
-
case 'documentation':
|
|
197
|
-
context = await builder.buildDocumentationContext(resolvedPath, targetFile);
|
|
198
|
-
break;
|
|
199
|
-
case 'playbook':
|
|
200
|
-
context = await builder.buildPlaybookContext(resolvedPath, targetFile || 'generic');
|
|
201
|
-
break;
|
|
202
|
-
case 'plan':
|
|
203
|
-
context = await builder.buildPlanContext(resolvedPath, targetFile);
|
|
204
|
-
break;
|
|
205
|
-
case 'compact':
|
|
206
|
-
default:
|
|
207
|
-
context = await builder.buildCompactContext(resolvedPath);
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
content: [{
|
|
212
|
-
type: 'text',
|
|
213
|
-
text: context
|
|
214
|
-
}]
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
finally {
|
|
218
|
-
if (isLocalBuilder) {
|
|
219
|
-
await builder.shutdown();
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
// checkScaffolding tool
|
|
224
|
-
this.server.registerTool('checkScaffolding', {
|
|
225
|
-
description: (0, toolRegistry_1.getToolDescription)('checkScaffolding'),
|
|
226
|
-
inputSchema: {
|
|
227
|
-
repoPath: zod_1.z.string().optional().describe('Repository path to check (defaults to cwd)')
|
|
228
|
-
}
|
|
229
|
-
}, async ({ repoPath }) => {
|
|
230
|
-
const result = await tools_1.checkScaffoldingTool.execute({ repoPath: repoPath || this.options.repoPath }, { toolCallId: '', messages: [] });
|
|
231
|
-
return {
|
|
232
|
-
content: [{
|
|
233
|
-
type: 'text',
|
|
234
|
-
text: JSON.stringify(result, null, 2)
|
|
235
|
-
}]
|
|
236
|
-
};
|
|
237
|
-
});
|
|
238
|
-
// initializeContext tool
|
|
239
|
-
this.server.registerTool('initializeContext', {
|
|
240
|
-
description: (0, toolRegistry_1.getToolDescription)('initializeContext', true),
|
|
241
|
-
inputSchema: {
|
|
242
|
-
repoPath: zod_1.z.string().describe('Repository path to initialize'),
|
|
243
|
-
type: zod_1.z.enum(['docs', 'agents', 'both']).default('both').optional()
|
|
244
|
-
.describe('Type of scaffolding to create'),
|
|
245
|
-
outputDir: zod_1.z.string().optional().describe('Output directory (default: ./.context)'),
|
|
246
|
-
semantic: zod_1.z.boolean().default(true).optional()
|
|
247
|
-
.describe('Enable semantic analysis for richer templates'),
|
|
248
|
-
include: zod_1.z.array(zod_1.z.string()).optional().describe('Include patterns'),
|
|
249
|
-
exclude: zod_1.z.array(zod_1.z.string()).optional().describe('Exclude patterns'),
|
|
250
|
-
autoFill: zod_1.z.boolean().default(true).optional()
|
|
251
|
-
.describe('Automatically fill scaffolding with codebase-aware content (default: true)')
|
|
252
|
-
}
|
|
253
|
-
}, async ({ repoPath, type, outputDir, semantic, include, exclude, autoFill }) => {
|
|
254
|
-
const result = await tools_1.initializeContextTool.execute({
|
|
255
|
-
repoPath: repoPath || this.options.repoPath || process.cwd(),
|
|
256
|
-
type,
|
|
257
|
-
outputDir,
|
|
258
|
-
semantic,
|
|
259
|
-
include,
|
|
260
|
-
exclude,
|
|
261
|
-
autoFill
|
|
262
|
-
}, { toolCallId: '', messages: [] });
|
|
263
|
-
return {
|
|
264
|
-
content: [{
|
|
265
|
-
type: 'text',
|
|
266
|
-
text: JSON.stringify(result, null, 2)
|
|
267
|
-
}]
|
|
268
|
-
};
|
|
269
|
-
});
|
|
270
|
-
// scaffoldPlan tool
|
|
271
|
-
this.server.registerTool('scaffoldPlan', {
|
|
272
|
-
description: (0, toolRegistry_1.getToolDescription)('scaffoldPlan'),
|
|
273
|
-
inputSchema: {
|
|
274
|
-
planName: zod_1.z.string().describe('Name of the plan (will be slugified)'),
|
|
275
|
-
repoPath: zod_1.z.string().optional().describe('Repository path'),
|
|
276
|
-
outputDir: zod_1.z.string().optional().describe('Output directory'),
|
|
277
|
-
title: zod_1.z.string().optional().describe('Plan title (defaults to formatted planName)'),
|
|
278
|
-
summary: zod_1.z.string().optional().describe('Plan summary/goal'),
|
|
279
|
-
semantic: zod_1.z.boolean().default(true).optional().describe('Enable semantic analysis'),
|
|
280
|
-
autoFill: zod_1.z.boolean().default(true).optional()
|
|
281
|
-
.describe('Automatically fill plan with codebase-aware content (default: true)')
|
|
282
|
-
}
|
|
283
|
-
}, async ({ planName, repoPath, outputDir, title, summary, semantic, autoFill }) => {
|
|
284
|
-
const result = await tools_1.scaffoldPlanTool.execute({
|
|
285
|
-
planName,
|
|
286
|
-
repoPath: repoPath || this.options.repoPath || process.cwd(),
|
|
287
|
-
outputDir,
|
|
288
|
-
title,
|
|
289
|
-
summary,
|
|
290
|
-
semantic,
|
|
291
|
-
autoFill
|
|
292
|
-
}, { toolCallId: '', messages: [] });
|
|
293
|
-
return {
|
|
294
|
-
content: [{
|
|
295
|
-
type: 'text',
|
|
296
|
-
text: JSON.stringify(result, null, 2)
|
|
297
|
-
}]
|
|
298
|
-
};
|
|
299
|
-
});
|
|
300
|
-
// fillScaffolding tool (with pagination)
|
|
301
|
-
this.server.registerTool('fillScaffolding', {
|
|
302
|
-
description: (0, toolRegistry_1.getToolDescription)('fillScaffolding', true),
|
|
303
|
-
inputSchema: {
|
|
304
|
-
repoPath: zod_1.z.string().describe('Repository path'),
|
|
305
|
-
outputDir: zod_1.z.string().optional().describe('Scaffold directory (default: ./.context)'),
|
|
306
|
-
target: zod_1.z.enum(['docs', 'agents', 'plans', 'all']).default('all').optional()
|
|
307
|
-
.describe('Which scaffolding to fill'),
|
|
308
|
-
offset: zod_1.z.number().optional().describe('Skip first N files (for pagination)'),
|
|
309
|
-
limit: zod_1.z.number().optional().describe('Max files to return (default: 3, use 0 for all)')
|
|
310
|
-
}
|
|
311
|
-
}, async ({ repoPath, outputDir, target, offset, limit }) => {
|
|
312
|
-
const result = await tools_1.fillScaffoldingTool.execute({
|
|
313
|
-
repoPath: repoPath || this.options.repoPath || process.cwd(),
|
|
314
|
-
outputDir,
|
|
315
|
-
target,
|
|
316
|
-
offset,
|
|
317
|
-
limit
|
|
318
|
-
}, { toolCallId: '', messages: [] });
|
|
319
|
-
return {
|
|
320
|
-
content: [{
|
|
321
|
-
type: 'text',
|
|
322
|
-
text: JSON.stringify(result, null, 2)
|
|
323
|
-
}]
|
|
324
|
-
};
|
|
325
|
-
});
|
|
326
|
-
// listFilesToFill tool - lightweight listing without content
|
|
327
|
-
this.server.registerTool('listFilesToFill', {
|
|
328
|
-
description: (0, toolRegistry_1.getToolDescription)('listFilesToFill', true),
|
|
329
|
-
inputSchema: {
|
|
330
|
-
repoPath: zod_1.z.string().describe('Repository path'),
|
|
331
|
-
outputDir: zod_1.z.string().optional().describe('Scaffold directory (default: ./.context)'),
|
|
332
|
-
target: zod_1.z.enum(['docs', 'agents', 'plans', 'all']).default('all').optional()
|
|
333
|
-
.describe('Which scaffolding to list')
|
|
334
|
-
}
|
|
335
|
-
}, async ({ repoPath, outputDir, target }) => {
|
|
336
|
-
const result = await tools_1.listFilesToFillTool.execute({
|
|
337
|
-
repoPath: repoPath || this.options.repoPath || process.cwd(),
|
|
338
|
-
outputDir,
|
|
339
|
-
target
|
|
340
|
-
}, { toolCallId: '', messages: [] });
|
|
341
|
-
return {
|
|
342
|
-
content: [{
|
|
343
|
-
type: 'text',
|
|
344
|
-
text: JSON.stringify(result, null, 2)
|
|
345
|
-
}]
|
|
346
|
-
};
|
|
347
|
-
});
|
|
348
|
-
// fillSingleFile tool - process one file at a time
|
|
349
|
-
this.server.registerTool('fillSingleFile', {
|
|
350
|
-
description: (0, toolRegistry_1.getToolDescription)('fillSingleFile', true),
|
|
351
|
-
inputSchema: {
|
|
352
|
-
repoPath: zod_1.z.string().describe('Repository path'),
|
|
353
|
-
filePath: zod_1.z.string().describe('Absolute path to the scaffold file to fill')
|
|
354
|
-
}
|
|
355
|
-
}, async ({ repoPath, filePath }) => {
|
|
356
|
-
const result = await tools_1.fillSingleFileTool.execute({
|
|
357
|
-
repoPath: repoPath || this.options.repoPath || process.cwd(),
|
|
358
|
-
filePath
|
|
359
|
-
}, { toolCallId: '', messages: [] });
|
|
360
|
-
return {
|
|
361
|
-
content: [{
|
|
362
|
-
type: 'text',
|
|
363
|
-
text: JSON.stringify(result, null, 2)
|
|
364
|
-
}]
|
|
365
|
-
};
|
|
366
|
-
});
|
|
367
|
-
// getCodebaseMap tool - retrieve sections of the codebase map JSON
|
|
368
|
-
this.server.registerTool('getCodebaseMap', {
|
|
369
|
-
description: (0, toolRegistry_1.getToolDescription)('getCodebaseMap', true),
|
|
370
|
-
inputSchema: {
|
|
371
|
-
repoPath: zod_1.z.string().optional().describe('Repository path (defaults to cwd)'),
|
|
372
|
-
section: zod_1.z.enum([
|
|
373
|
-
'all',
|
|
374
|
-
'stack',
|
|
375
|
-
'structure',
|
|
376
|
-
'architecture',
|
|
377
|
-
'symbols',
|
|
378
|
-
'symbols.classes',
|
|
379
|
-
'symbols.interfaces',
|
|
380
|
-
'symbols.functions',
|
|
381
|
-
'symbols.types',
|
|
382
|
-
'symbols.enums',
|
|
383
|
-
'publicAPI',
|
|
384
|
-
'dependencies',
|
|
385
|
-
'stats'
|
|
386
|
-
]).default('all').optional()
|
|
387
|
-
.describe('Section of the codebase map to retrieve. Use specific sections to reduce token usage.')
|
|
388
|
-
}
|
|
389
|
-
}, async ({ repoPath, section }) => {
|
|
390
|
-
const result = await tools_1.getCodebaseMapTool.execute({
|
|
391
|
-
repoPath: repoPath || this.options.repoPath || process.cwd(),
|
|
392
|
-
section
|
|
393
|
-
}, { toolCallId: '', messages: [] });
|
|
394
|
-
return {
|
|
395
|
-
content: [{
|
|
396
|
-
type: 'text',
|
|
397
|
-
text: JSON.stringify(result, null, 2)
|
|
398
|
-
}]
|
|
399
|
-
};
|
|
400
|
-
});
|
|
401
|
-
this.log('Registered 13 tools');
|
|
402
|
-
// Register PREVC workflow tools
|
|
403
|
-
this.registerWorkflowTools();
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Register PREVC workflow tools
|
|
407
|
-
*/
|
|
408
|
-
registerWorkflowTools() {
|
|
409
|
-
const repoPath = this.options.repoPath || process.cwd();
|
|
410
|
-
// workflowInit - Initialize a PREVC workflow
|
|
411
|
-
this.server.registerTool('workflowInit', {
|
|
412
|
-
description: 'Initialize a PREVC workflow with automatic scale detection. PREVC = Planejamento, Revisão, Execução, Validação, Confirmação.',
|
|
413
|
-
inputSchema: {
|
|
414
|
-
name: zod_1.z.string().describe('Name of the project/feature'),
|
|
415
|
-
description: zod_1.z.string().optional().describe('Description for scale detection'),
|
|
416
|
-
scale: zod_1.z.enum(['QUICK', 'SMALL', 'MEDIUM', 'LARGE', 'ENTERPRISE']).optional()
|
|
417
|
-
.describe('Project scale (auto-detected if not provided)')
|
|
418
|
-
}
|
|
419
|
-
}, async ({ name, description, scale }) => {
|
|
420
|
-
try {
|
|
421
|
-
const resolvedRepoPath = path.resolve(repoPath);
|
|
422
|
-
const service = new workflow_1.WorkflowService(resolvedRepoPath);
|
|
423
|
-
const status = await service.init({
|
|
424
|
-
name,
|
|
425
|
-
description,
|
|
426
|
-
scale: scale,
|
|
427
|
-
});
|
|
428
|
-
// Include file paths for visibility
|
|
429
|
-
const contextPath = path.join(resolvedRepoPath, '.context');
|
|
430
|
-
const statusFilePath = path.join(contextPath, 'workflow', 'status.yaml');
|
|
431
|
-
return {
|
|
432
|
-
content: [{
|
|
433
|
-
type: 'text',
|
|
434
|
-
text: JSON.stringify({
|
|
435
|
-
success: true,
|
|
436
|
-
message: `Workflow initialized: ${name}`,
|
|
437
|
-
scale: (0, workflow_2.getScaleName)(status.project.scale),
|
|
438
|
-
currentPhase: status.project.current_phase,
|
|
439
|
-
phases: Object.keys(status.phases).filter((p) => status.phases[p].status !== 'skipped'),
|
|
440
|
-
statusFilePath,
|
|
441
|
-
contextPath,
|
|
442
|
-
}, null, 2)
|
|
443
|
-
}]
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
catch (error) {
|
|
447
|
-
return {
|
|
448
|
-
content: [{
|
|
449
|
-
type: 'text',
|
|
450
|
-
text: JSON.stringify({
|
|
451
|
-
success: false,
|
|
452
|
-
error: error instanceof Error ? error.message : String(error)
|
|
453
|
-
}, null, 2)
|
|
454
|
-
}]
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
// workflowStatus - Get current workflow status
|
|
459
|
-
this.server.registerTool('workflowStatus', {
|
|
460
|
-
description: 'Get the current status of the PREVC workflow including phases, roles, and progress.',
|
|
461
|
-
inputSchema: {}
|
|
462
|
-
}, async () => {
|
|
463
|
-
try {
|
|
464
|
-
const resolvedRepoPath = path.resolve(repoPath);
|
|
465
|
-
const service = new workflow_1.WorkflowService(resolvedRepoPath);
|
|
466
|
-
if (!(await service.hasWorkflow())) {
|
|
467
|
-
return {
|
|
468
|
-
content: [{
|
|
469
|
-
type: 'text',
|
|
470
|
-
text: JSON.stringify({
|
|
471
|
-
success: false,
|
|
472
|
-
error: 'No workflow found. Run workflowInit first.',
|
|
473
|
-
statusFilePath: path.join(resolvedRepoPath, '.context', 'workflow', 'status.yaml')
|
|
474
|
-
}, null, 2)
|
|
475
|
-
}]
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
const summary = await service.getSummary();
|
|
479
|
-
const status = await service.getStatus();
|
|
480
|
-
const statusFilePath = path.join(resolvedRepoPath, '.context', 'workflow', 'status.yaml');
|
|
481
|
-
return {
|
|
482
|
-
content: [{
|
|
483
|
-
type: 'text',
|
|
484
|
-
text: JSON.stringify({
|
|
485
|
-
success: true,
|
|
486
|
-
name: summary.name,
|
|
487
|
-
scale: (0, workflow_2.getScaleName)(summary.scale),
|
|
488
|
-
currentPhase: {
|
|
489
|
-
code: summary.currentPhase,
|
|
490
|
-
name: workflow_2.PHASE_NAMES_EN[summary.currentPhase],
|
|
491
|
-
},
|
|
492
|
-
progress: summary.progress,
|
|
493
|
-
isComplete: summary.isComplete,
|
|
494
|
-
phases: status.phases,
|
|
495
|
-
roles: status.roles,
|
|
496
|
-
statusFilePath,
|
|
497
|
-
}, null, 2)
|
|
498
|
-
}]
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
catch (error) {
|
|
502
|
-
return {
|
|
503
|
-
content: [{
|
|
504
|
-
type: 'text',
|
|
505
|
-
text: JSON.stringify({
|
|
506
|
-
success: false,
|
|
507
|
-
error: error instanceof Error ? error.message : String(error)
|
|
508
|
-
}, null, 2)
|
|
509
|
-
}]
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
// workflowAdvance - Advance to the next phase
|
|
514
|
-
this.server.registerTool('workflowAdvance', {
|
|
515
|
-
description: 'Complete the current phase and advance to the next phase in the PREVC workflow.',
|
|
516
|
-
inputSchema: {
|
|
517
|
-
outputs: zod_1.z.array(zod_1.z.string()).optional()
|
|
518
|
-
.describe('List of artifact paths generated in the current phase')
|
|
519
|
-
}
|
|
520
|
-
}, async ({ outputs }) => {
|
|
521
|
-
try {
|
|
522
|
-
const service = new workflow_1.WorkflowService(repoPath);
|
|
523
|
-
if (!(await service.hasWorkflow())) {
|
|
524
|
-
return {
|
|
525
|
-
content: [{
|
|
526
|
-
type: 'text',
|
|
527
|
-
text: JSON.stringify({
|
|
528
|
-
success: false,
|
|
529
|
-
error: 'No workflow found. Run workflowInit first.'
|
|
530
|
-
}, null, 2)
|
|
531
|
-
}]
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
const nextPhase = await service.advance(outputs);
|
|
535
|
-
if (nextPhase) {
|
|
536
|
-
return {
|
|
537
|
-
content: [{
|
|
538
|
-
type: 'text',
|
|
539
|
-
text: JSON.stringify({
|
|
540
|
-
success: true,
|
|
541
|
-
message: `Advanced to ${workflow_2.PHASE_NAMES_EN[nextPhase]} phase`,
|
|
542
|
-
nextPhase: {
|
|
543
|
-
code: nextPhase,
|
|
544
|
-
name: workflow_2.PHASE_NAMES_EN[nextPhase],
|
|
545
|
-
}
|
|
546
|
-
}, null, 2)
|
|
547
|
-
}]
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
551
|
-
return {
|
|
552
|
-
content: [{
|
|
553
|
-
type: 'text',
|
|
554
|
-
text: JSON.stringify({
|
|
555
|
-
success: true,
|
|
556
|
-
message: 'Workflow completed!',
|
|
557
|
-
isComplete: true
|
|
558
|
-
}, null, 2)
|
|
559
|
-
}]
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
catch (error) {
|
|
564
|
-
return {
|
|
565
|
-
content: [{
|
|
566
|
-
type: 'text',
|
|
567
|
-
text: JSON.stringify({
|
|
568
|
-
success: false,
|
|
569
|
-
error: error instanceof Error ? error.message : String(error)
|
|
570
|
-
}, null, 2)
|
|
571
|
-
}]
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
// workflowHandoff - Handoff between roles
|
|
576
|
-
this.server.registerTool('workflowHandoff', {
|
|
577
|
-
description: 'Perform a handoff from one role to another within the PREVC workflow.',
|
|
578
|
-
inputSchema: {
|
|
579
|
-
from: zod_1.z.enum(workflow_2.PREVC_ROLES)
|
|
580
|
-
.describe('Role handing off'),
|
|
581
|
-
to: zod_1.z.enum(workflow_2.PREVC_ROLES)
|
|
582
|
-
.describe('Role receiving handoff'),
|
|
583
|
-
artifacts: zod_1.z.array(zod_1.z.string()).describe('Artifacts being handed off')
|
|
584
|
-
}
|
|
585
|
-
}, async ({ from, to, artifacts }) => {
|
|
586
|
-
try {
|
|
587
|
-
const service = new workflow_1.WorkflowService(repoPath);
|
|
588
|
-
if (!(await service.hasWorkflow())) {
|
|
589
|
-
return {
|
|
590
|
-
content: [{
|
|
591
|
-
type: 'text',
|
|
592
|
-
text: JSON.stringify({
|
|
593
|
-
success: false,
|
|
594
|
-
error: 'No workflow found. Run workflowInit first.'
|
|
595
|
-
}, null, 2)
|
|
596
|
-
}]
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
await service.handoff(from, to, artifacts);
|
|
600
|
-
return {
|
|
601
|
-
content: [{
|
|
602
|
-
type: 'text',
|
|
603
|
-
text: JSON.stringify({
|
|
604
|
-
success: true,
|
|
605
|
-
message: `Handoff complete: ${workflow_2.ROLE_DISPLAY_NAMES[from]} → ${workflow_2.ROLE_DISPLAY_NAMES[to]}`,
|
|
606
|
-
from: { role: from, displayName: workflow_2.ROLE_DISPLAY_NAMES[from] },
|
|
607
|
-
to: { role: to, displayName: workflow_2.ROLE_DISPLAY_NAMES[to] },
|
|
608
|
-
artifacts
|
|
609
|
-
}, null, 2)
|
|
610
|
-
}]
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
catch (error) {
|
|
614
|
-
return {
|
|
615
|
-
content: [{
|
|
616
|
-
type: 'text',
|
|
617
|
-
text: JSON.stringify({
|
|
618
|
-
success: false,
|
|
619
|
-
error: error instanceof Error ? error.message : String(error)
|
|
620
|
-
}, null, 2)
|
|
621
|
-
}]
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
// workflowCollaborate - Start a collaboration session
|
|
626
|
-
this.server.registerTool('workflowCollaborate', {
|
|
627
|
-
description: 'Start a multi-role collaboration session for complex decisions or brainstorming.',
|
|
628
|
-
inputSchema: {
|
|
629
|
-
topic: zod_1.z.string().describe('Topic for the collaboration session'),
|
|
630
|
-
participants: zod_1.z.array(zod_1.z.enum(workflow_2.PREVC_ROLES))
|
|
631
|
-
.optional()
|
|
632
|
-
.describe('Roles to participate (auto-selected if not provided)')
|
|
633
|
-
}
|
|
634
|
-
}, async ({ topic, participants }) => {
|
|
635
|
-
try {
|
|
636
|
-
const service = new workflow_1.WorkflowService(repoPath);
|
|
637
|
-
const session = await service.startCollaboration(topic, participants);
|
|
638
|
-
const status = session.getStatus();
|
|
639
|
-
return {
|
|
640
|
-
content: [{
|
|
641
|
-
type: 'text',
|
|
642
|
-
text: JSON.stringify({
|
|
643
|
-
success: true,
|
|
644
|
-
message: `Collaboration session started: ${topic}`,
|
|
645
|
-
sessionId: status.id,
|
|
646
|
-
topic: status.topic,
|
|
647
|
-
participants: status.participants.map((p) => ({
|
|
648
|
-
role: p,
|
|
649
|
-
displayName: workflow_2.ROLE_DISPLAY_NAMES[p],
|
|
650
|
-
})),
|
|
651
|
-
}, null, 2)
|
|
652
|
-
}]
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
catch (error) {
|
|
656
|
-
return {
|
|
657
|
-
content: [{
|
|
658
|
-
type: 'text',
|
|
659
|
-
text: JSON.stringify({
|
|
660
|
-
success: false,
|
|
661
|
-
error: error instanceof Error ? error.message : String(error)
|
|
662
|
-
}, null, 2)
|
|
663
|
-
}]
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
// workflowCreateDoc - Create a document for the current phase
|
|
668
|
-
this.server.registerTool('workflowCreateDoc', {
|
|
669
|
-
description: 'Create a document template for the current phase of the PREVC workflow.',
|
|
670
|
-
inputSchema: {
|
|
671
|
-
type: zod_1.z.enum(['prd', 'tech-spec', 'architecture', 'adr', 'test-plan', 'changelog'])
|
|
672
|
-
.describe('Type of document to create'),
|
|
673
|
-
name: zod_1.z.string().describe('Name/title for the document')
|
|
674
|
-
}
|
|
675
|
-
}, async ({ type, name }) => {
|
|
676
|
-
try {
|
|
677
|
-
const service = new workflow_1.WorkflowService(repoPath);
|
|
678
|
-
if (!(await service.hasWorkflow())) {
|
|
679
|
-
return {
|
|
680
|
-
content: [{
|
|
681
|
-
type: 'text',
|
|
682
|
-
text: JSON.stringify({
|
|
683
|
-
success: false,
|
|
684
|
-
error: 'No workflow found. Run workflowInit first.'
|
|
685
|
-
}, null, 2)
|
|
686
|
-
}]
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
// For now, return the document path that should be created
|
|
690
|
-
const docPath = `.context/workflow/docs/${type}-${name.toLowerCase().replace(/\s+/g, '-')}.md`;
|
|
691
|
-
return {
|
|
692
|
-
content: [{
|
|
693
|
-
type: 'text',
|
|
694
|
-
text: JSON.stringify({
|
|
695
|
-
success: true,
|
|
696
|
-
message: `Document template ready: ${type}`,
|
|
697
|
-
documentType: type,
|
|
698
|
-
suggestedPath: docPath,
|
|
699
|
-
name,
|
|
700
|
-
}, null, 2)
|
|
701
|
-
}]
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
catch (error) {
|
|
705
|
-
return {
|
|
706
|
-
content: [{
|
|
707
|
-
type: 'text',
|
|
708
|
-
text: JSON.stringify({
|
|
709
|
-
success: false,
|
|
710
|
-
error: error instanceof Error ? error.message : String(error)
|
|
711
|
-
}, null, 2)
|
|
712
|
-
}]
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
this.log('Registered 6 workflow tools');
|
|
717
|
-
// Register extended workflow tools (start, report, export, stack detection)
|
|
718
|
-
this.registerExtendedWorkflowTools();
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Register extended workflow tools (start, report, export, stack detection)
|
|
722
|
-
*/
|
|
723
|
-
registerExtendedWorkflowTools() {
|
|
724
|
-
const repoPath = this.options.repoPath || process.cwd();
|
|
725
|
-
// projectStart - Unified start command
|
|
726
|
-
this.server.registerTool('projectStart', {
|
|
727
|
-
description: 'Start a new project with unified setup: scaffolding + context fill + workflow initialization. Supports workflow templates (hotfix, feature, mvp).',
|
|
728
|
-
inputSchema: {
|
|
729
|
-
featureName: zod_1.z.string().describe('Feature/project name'),
|
|
730
|
-
template: zod_1.z.enum(['hotfix', 'feature', 'mvp', 'auto']).optional()
|
|
731
|
-
.describe('Workflow template (hotfix=quick fix, feature=standard, mvp=complete)'),
|
|
732
|
-
skipFill: zod_1.z.boolean().optional().describe('Skip AI-assisted context filling'),
|
|
733
|
-
skipWorkflow: zod_1.z.boolean().optional().describe('Skip workflow initialization'),
|
|
734
|
-
}
|
|
735
|
-
}, async ({ featureName, template, skipFill, skipWorkflow }) => {
|
|
736
|
-
try {
|
|
737
|
-
const startService = new start_1.StartService({
|
|
738
|
-
ui: {
|
|
739
|
-
displayOutput: () => { },
|
|
740
|
-
displaySuccess: () => { },
|
|
741
|
-
displayError: () => { },
|
|
742
|
-
displayInfo: () => { },
|
|
743
|
-
displayWarning: () => { },
|
|
744
|
-
startSpinner: () => { },
|
|
745
|
-
stopSpinner: () => { },
|
|
746
|
-
updateSpinner: () => { },
|
|
747
|
-
prompt: async () => '',
|
|
748
|
-
confirm: async () => true,
|
|
749
|
-
},
|
|
750
|
-
t: (key) => key,
|
|
751
|
-
version: version_1.VERSION,
|
|
752
|
-
defaultModel: 'claude-3-5-sonnet-20241022',
|
|
753
|
-
});
|
|
754
|
-
const result = await startService.run(repoPath, {
|
|
755
|
-
featureName,
|
|
756
|
-
template: template,
|
|
757
|
-
skipFill,
|
|
758
|
-
skipWorkflow,
|
|
759
|
-
});
|
|
760
|
-
return {
|
|
761
|
-
content: [{
|
|
762
|
-
type: 'text',
|
|
763
|
-
text: JSON.stringify({
|
|
764
|
-
success: result.workflowStarted || result.initialized,
|
|
765
|
-
initialized: result.initialized,
|
|
766
|
-
filled: result.filled,
|
|
767
|
-
workflowStarted: result.workflowStarted,
|
|
768
|
-
scale: result.scale ? (0, workflow_2.getScaleName)(result.scale) : null,
|
|
769
|
-
featureName: result.featureName,
|
|
770
|
-
stack: result.stackDetected ? {
|
|
771
|
-
primaryLanguage: result.stackDetected.primaryLanguage,
|
|
772
|
-
frameworks: result.stackDetected.frameworks,
|
|
773
|
-
} : null,
|
|
774
|
-
}, null, 2)
|
|
775
|
-
}]
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
catch (error) {
|
|
779
|
-
return {
|
|
780
|
-
content: [{
|
|
781
|
-
type: 'text',
|
|
782
|
-
text: JSON.stringify({
|
|
783
|
-
success: false,
|
|
784
|
-
error: error instanceof Error ? error.message : String(error)
|
|
785
|
-
}, null, 2)
|
|
786
|
-
}]
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
// projectReport - Generate visual reports
|
|
791
|
-
this.server.registerTool('projectReport', {
|
|
792
|
-
description: 'Generate a visual progress report for the current PREVC workflow. Shows phases, roles, deliverables, and a visual dashboard.',
|
|
793
|
-
inputSchema: {
|
|
794
|
-
format: zod_1.z.enum(['json', 'markdown', 'dashboard']).default('dashboard').optional()
|
|
795
|
-
.describe('Output format: json (raw data), markdown (formatted), dashboard (visual)'),
|
|
796
|
-
includeStack: zod_1.z.boolean().optional().describe('Include technology stack info'),
|
|
797
|
-
}
|
|
798
|
-
}, async ({ format, includeStack }) => {
|
|
799
|
-
try {
|
|
800
|
-
const reportService = new report_1.ReportService({
|
|
801
|
-
ui: {
|
|
802
|
-
displayOutput: () => { },
|
|
803
|
-
displaySuccess: () => { },
|
|
804
|
-
displayError: () => { },
|
|
805
|
-
displayInfo: () => { },
|
|
806
|
-
displayWarning: () => { },
|
|
807
|
-
startSpinner: () => { },
|
|
808
|
-
stopSpinner: () => { },
|
|
809
|
-
updateSpinner: () => { },
|
|
810
|
-
},
|
|
811
|
-
t: (key) => key,
|
|
812
|
-
version: version_1.VERSION,
|
|
813
|
-
});
|
|
814
|
-
const report = await reportService.generate(repoPath, { includeStack });
|
|
815
|
-
let output;
|
|
816
|
-
if (format === 'json') {
|
|
817
|
-
output = JSON.stringify(report, null, 2);
|
|
818
|
-
}
|
|
819
|
-
else if (format === 'dashboard') {
|
|
820
|
-
output = reportService.generateVisualDashboard(report);
|
|
821
|
-
}
|
|
822
|
-
else {
|
|
823
|
-
// Markdown format - use visual dashboard as fallback
|
|
824
|
-
output = reportService.generateVisualDashboard(report);
|
|
825
|
-
}
|
|
826
|
-
return {
|
|
827
|
-
content: [{
|
|
828
|
-
type: 'text',
|
|
829
|
-
text: output
|
|
830
|
-
}]
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
catch (error) {
|
|
834
|
-
return {
|
|
835
|
-
content: [{
|
|
836
|
-
type: 'text',
|
|
837
|
-
text: JSON.stringify({
|
|
838
|
-
success: false,
|
|
839
|
-
error: error instanceof Error ? error.message : String(error)
|
|
840
|
-
}, null, 2)
|
|
841
|
-
}]
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
});
|
|
845
|
-
// exportRules - Export rules to AI tools
|
|
846
|
-
this.server.registerTool('exportRules', {
|
|
847
|
-
description: 'Export context rules to AI tool directories (Cursor, Claude, GitHub Copilot, Windsurf, Cline, Aider, Codex). Bidirectional rules sync.',
|
|
848
|
-
inputSchema: {
|
|
849
|
-
preset: zod_1.z.enum(['cursor', 'claude', 'github', 'windsurf', 'cline', 'aider', 'codex', 'all']).default('all')
|
|
850
|
-
.describe('Target AI tool preset or "all" for all supported tools'),
|
|
851
|
-
force: zod_1.z.boolean().optional().describe('Overwrite existing files'),
|
|
852
|
-
dryRun: zod_1.z.boolean().optional().describe('Preview changes without writing'),
|
|
853
|
-
}
|
|
854
|
-
}, async ({ preset, force, dryRun }) => {
|
|
855
|
-
try {
|
|
856
|
-
const exportService = new export_1.ExportRulesService({
|
|
857
|
-
ui: {
|
|
858
|
-
displayOutput: () => { },
|
|
859
|
-
displaySuccess: () => { },
|
|
860
|
-
displayError: () => { },
|
|
861
|
-
displayInfo: () => { },
|
|
862
|
-
displayWarning: () => { },
|
|
863
|
-
startSpinner: () => { },
|
|
864
|
-
stopSpinner: () => { },
|
|
865
|
-
updateSpinner: () => { },
|
|
866
|
-
},
|
|
867
|
-
t: (key) => key,
|
|
868
|
-
version: version_1.VERSION,
|
|
869
|
-
});
|
|
870
|
-
const result = await exportService.run(repoPath, { preset, force, dryRun });
|
|
871
|
-
return {
|
|
872
|
-
content: [{
|
|
873
|
-
type: 'text',
|
|
874
|
-
text: JSON.stringify({
|
|
875
|
-
success: true,
|
|
876
|
-
filesCreated: result.filesCreated,
|
|
877
|
-
filesSkipped: result.filesSkipped,
|
|
878
|
-
filesFailed: result.filesFailed,
|
|
879
|
-
targets: result.targets,
|
|
880
|
-
errors: result.errors,
|
|
881
|
-
dryRun: dryRun || false,
|
|
882
|
-
}, null, 2)
|
|
883
|
-
}]
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
catch (error) {
|
|
887
|
-
return {
|
|
888
|
-
content: [{
|
|
889
|
-
type: 'text',
|
|
890
|
-
text: JSON.stringify({
|
|
891
|
-
success: false,
|
|
892
|
-
error: error instanceof Error ? error.message : String(error)
|
|
893
|
-
}, null, 2)
|
|
894
|
-
}]
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
// detectStack - Detect project technology stack
|
|
899
|
-
this.server.registerTool('detectStack', {
|
|
900
|
-
description: 'Detect the project technology stack including languages, frameworks, build tools, and test frameworks. Useful for intelligent defaults.',
|
|
901
|
-
inputSchema: {}
|
|
902
|
-
}, async () => {
|
|
903
|
-
try {
|
|
904
|
-
const detector = new stack_1.StackDetector();
|
|
905
|
-
const stackInfo = await detector.detect(repoPath);
|
|
906
|
-
return {
|
|
907
|
-
content: [{
|
|
908
|
-
type: 'text',
|
|
909
|
-
text: JSON.stringify({
|
|
910
|
-
success: true,
|
|
911
|
-
stack: stackInfo,
|
|
912
|
-
}, null, 2)
|
|
913
|
-
}]
|
|
914
|
-
};
|
|
915
|
-
}
|
|
916
|
-
catch (error) {
|
|
917
|
-
return {
|
|
918
|
-
content: [{
|
|
919
|
-
type: 'text',
|
|
920
|
-
text: JSON.stringify({
|
|
921
|
-
success: false,
|
|
922
|
-
error: error instanceof Error ? error.message : String(error)
|
|
923
|
-
}, null, 2)
|
|
924
|
-
}]
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
this.log('Registered 4 extended workflow tools');
|
|
929
|
-
// Register plan-workflow integration tools
|
|
930
|
-
this.registerPlanTools();
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* Register plan-workflow integration tools
|
|
934
|
-
*/
|
|
935
|
-
registerPlanTools() {
|
|
936
|
-
const repoPath = this.options.repoPath || process.cwd();
|
|
937
|
-
// linkPlan - Link a plan to the current workflow
|
|
938
|
-
this.server.registerTool('linkPlan', {
|
|
939
|
-
description: 'Link an implementation plan to the current PREVC workflow. Plans provide detailed steps mapped to workflow phases.',
|
|
940
|
-
inputSchema: {
|
|
941
|
-
planSlug: zod_1.z.string().describe('Plan slug/identifier (filename without .md)'),
|
|
942
|
-
}
|
|
943
|
-
}, async ({ planSlug }) => {
|
|
944
|
-
try {
|
|
945
|
-
const linker = (0, workflow_2.createPlanLinker)(repoPath);
|
|
946
|
-
const ref = await linker.linkPlan(planSlug);
|
|
947
|
-
if (!ref) {
|
|
948
|
-
return {
|
|
949
|
-
content: [{
|
|
950
|
-
type: 'text',
|
|
951
|
-
text: JSON.stringify({
|
|
952
|
-
success: false,
|
|
953
|
-
error: `Plan not found: ${planSlug}`,
|
|
954
|
-
}, null, 2)
|
|
955
|
-
}]
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
return {
|
|
959
|
-
content: [{
|
|
960
|
-
type: 'text',
|
|
961
|
-
text: JSON.stringify({
|
|
962
|
-
success: true,
|
|
963
|
-
plan: ref,
|
|
964
|
-
}, null, 2)
|
|
965
|
-
}]
|
|
966
|
-
};
|
|
967
|
-
}
|
|
968
|
-
catch (error) {
|
|
969
|
-
return {
|
|
970
|
-
content: [{
|
|
971
|
-
type: 'text',
|
|
972
|
-
text: JSON.stringify({
|
|
973
|
-
success: false,
|
|
974
|
-
error: error instanceof Error ? error.message : String(error)
|
|
975
|
-
}, null, 2)
|
|
976
|
-
}]
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
// getLinkedPlans - Get all plans linked to the workflow
|
|
981
|
-
this.server.registerTool('getLinkedPlans', {
|
|
982
|
-
description: 'Get all implementation plans linked to the current PREVC workflow.',
|
|
983
|
-
inputSchema: {}
|
|
984
|
-
}, async () => {
|
|
985
|
-
try {
|
|
986
|
-
const linker = (0, workflow_2.createPlanLinker)(repoPath);
|
|
987
|
-
const plans = await linker.getLinkedPlans();
|
|
988
|
-
return {
|
|
989
|
-
content: [{
|
|
990
|
-
type: 'text',
|
|
991
|
-
text: JSON.stringify({
|
|
992
|
-
success: true,
|
|
993
|
-
plans,
|
|
994
|
-
}, null, 2)
|
|
995
|
-
}]
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
catch (error) {
|
|
999
|
-
return {
|
|
1000
|
-
content: [{
|
|
1001
|
-
type: 'text',
|
|
1002
|
-
text: JSON.stringify({
|
|
1003
|
-
success: false,
|
|
1004
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1005
|
-
}, null, 2)
|
|
1006
|
-
}]
|
|
1007
|
-
};
|
|
1008
|
-
}
|
|
1009
|
-
});
|
|
1010
|
-
// getPlanDetails - Get detailed plan with PREVC mapping
|
|
1011
|
-
this.server.registerTool('getPlanDetails', {
|
|
1012
|
-
description: 'Get detailed plan information including phases mapped to PREVC, agents, and documentation.',
|
|
1013
|
-
inputSchema: {
|
|
1014
|
-
planSlug: zod_1.z.string().describe('Plan slug/identifier'),
|
|
1015
|
-
}
|
|
1016
|
-
}, async ({ planSlug }) => {
|
|
1017
|
-
try {
|
|
1018
|
-
const linker = (0, workflow_2.createPlanLinker)(repoPath);
|
|
1019
|
-
const plan = await linker.getLinkedPlan(planSlug);
|
|
1020
|
-
if (!plan) {
|
|
1021
|
-
return {
|
|
1022
|
-
content: [{
|
|
1023
|
-
type: 'text',
|
|
1024
|
-
text: JSON.stringify({
|
|
1025
|
-
success: false,
|
|
1026
|
-
error: `Plan not found or not linked: ${planSlug}`,
|
|
1027
|
-
}, null, 2)
|
|
1028
|
-
}]
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
return {
|
|
1032
|
-
content: [{
|
|
1033
|
-
type: 'text',
|
|
1034
|
-
text: JSON.stringify({
|
|
1035
|
-
success: true,
|
|
1036
|
-
plan: {
|
|
1037
|
-
...plan,
|
|
1038
|
-
phasesWithPrevc: plan.phases.map(p => ({
|
|
1039
|
-
...p,
|
|
1040
|
-
prevcPhaseName: workflow_2.PHASE_NAMES_EN[p.prevcPhase],
|
|
1041
|
-
})),
|
|
1042
|
-
},
|
|
1043
|
-
}, null, 2)
|
|
1044
|
-
}]
|
|
1045
|
-
};
|
|
1046
|
-
}
|
|
1047
|
-
catch (error) {
|
|
1048
|
-
return {
|
|
1049
|
-
content: [{
|
|
1050
|
-
type: 'text',
|
|
1051
|
-
text: JSON.stringify({
|
|
1052
|
-
success: false,
|
|
1053
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1054
|
-
}, null, 2)
|
|
1055
|
-
}]
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
// getPlansForPhase - Get plans relevant to current PREVC phase
|
|
1060
|
-
this.server.registerTool('getPlansForPhase', {
|
|
1061
|
-
description: 'Get all plans that have work items for a specific PREVC phase.',
|
|
1062
|
-
inputSchema: {
|
|
1063
|
-
phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).describe('PREVC phase'),
|
|
1064
|
-
}
|
|
1065
|
-
}, async ({ phase }) => {
|
|
1066
|
-
try {
|
|
1067
|
-
const linker = (0, workflow_2.createPlanLinker)(repoPath);
|
|
1068
|
-
const plans = await linker.getPlansForPhase(phase);
|
|
1069
|
-
return {
|
|
1070
|
-
content: [{
|
|
1071
|
-
type: 'text',
|
|
1072
|
-
text: JSON.stringify({
|
|
1073
|
-
success: true,
|
|
1074
|
-
phase,
|
|
1075
|
-
phaseName: workflow_2.PHASE_NAMES_EN[phase],
|
|
1076
|
-
plans: plans.map(p => ({
|
|
1077
|
-
slug: p.ref.slug,
|
|
1078
|
-
title: p.ref.title,
|
|
1079
|
-
phasesInThisPrevc: p.phases
|
|
1080
|
-
.filter(ph => ph.prevcPhase === phase)
|
|
1081
|
-
.map(ph => ({ id: ph.id, name: ph.name, status: ph.status })),
|
|
1082
|
-
hasPendingWork: linker.hasPendingWorkForPhase(p, phase),
|
|
1083
|
-
})),
|
|
1084
|
-
}, null, 2)
|
|
1085
|
-
}]
|
|
1086
|
-
};
|
|
1087
|
-
}
|
|
1088
|
-
catch (error) {
|
|
1089
|
-
return {
|
|
1090
|
-
content: [{
|
|
1091
|
-
type: 'text',
|
|
1092
|
-
text: JSON.stringify({
|
|
1093
|
-
success: false,
|
|
1094
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1095
|
-
}, null, 2)
|
|
1096
|
-
}]
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1100
|
-
// updatePlanPhase - Update plan phase status
|
|
1101
|
-
this.server.registerTool('updatePlanPhase', {
|
|
1102
|
-
description: 'Update the status of a plan phase (syncs with PREVC workflow tracking).',
|
|
1103
|
-
inputSchema: {
|
|
1104
|
-
planSlug: zod_1.z.string().describe('Plan slug/identifier'),
|
|
1105
|
-
phaseId: zod_1.z.string().describe('Phase ID within the plan (e.g., "phase-1")'),
|
|
1106
|
-
status: zod_1.z.enum(['pending', 'in_progress', 'completed', 'skipped']).describe('New status'),
|
|
1107
|
-
}
|
|
1108
|
-
}, async ({ planSlug, phaseId, status }) => {
|
|
1109
|
-
try {
|
|
1110
|
-
const linker = (0, workflow_2.createPlanLinker)(repoPath);
|
|
1111
|
-
const success = await linker.updatePlanPhase(planSlug, phaseId, status);
|
|
1112
|
-
return {
|
|
1113
|
-
content: [{
|
|
1114
|
-
type: 'text',
|
|
1115
|
-
text: JSON.stringify({
|
|
1116
|
-
success,
|
|
1117
|
-
planSlug,
|
|
1118
|
-
phaseId,
|
|
1119
|
-
status,
|
|
1120
|
-
}, null, 2)
|
|
1121
|
-
}]
|
|
1122
|
-
};
|
|
1123
|
-
}
|
|
1124
|
-
catch (error) {
|
|
1125
|
-
return {
|
|
1126
|
-
content: [{
|
|
1127
|
-
type: 'text',
|
|
1128
|
-
text: JSON.stringify({
|
|
1129
|
-
success: false,
|
|
1130
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1131
|
-
}, null, 2)
|
|
1132
|
-
}]
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
// recordDecision - Record a decision in a plan
|
|
1137
|
-
this.server.registerTool('recordDecision', {
|
|
1138
|
-
description: 'Record a decision made during plan execution. Decisions are tracked and can be referenced later.',
|
|
1139
|
-
inputSchema: {
|
|
1140
|
-
planSlug: zod_1.z.string().describe('Plan slug/identifier'),
|
|
1141
|
-
title: zod_1.z.string().describe('Decision title'),
|
|
1142
|
-
description: zod_1.z.string().describe('Decision description and rationale'),
|
|
1143
|
-
phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).optional().describe('Related PREVC phase'),
|
|
1144
|
-
alternatives: zod_1.z.array(zod_1.z.string()).optional().describe('Alternatives that were considered'),
|
|
1145
|
-
}
|
|
1146
|
-
}, async ({ planSlug, title, description, phase, alternatives }) => {
|
|
1147
|
-
try {
|
|
1148
|
-
const linker = (0, workflow_2.createPlanLinker)(repoPath);
|
|
1149
|
-
const decision = await linker.recordDecision(planSlug, {
|
|
1150
|
-
title,
|
|
1151
|
-
description,
|
|
1152
|
-
phase: phase,
|
|
1153
|
-
alternatives,
|
|
1154
|
-
status: 'accepted',
|
|
1155
|
-
});
|
|
1156
|
-
return {
|
|
1157
|
-
content: [{
|
|
1158
|
-
type: 'text',
|
|
1159
|
-
text: JSON.stringify({
|
|
1160
|
-
success: true,
|
|
1161
|
-
decision,
|
|
1162
|
-
}, null, 2)
|
|
1163
|
-
}]
|
|
1164
|
-
};
|
|
1165
|
-
}
|
|
1166
|
-
catch (error) {
|
|
1167
|
-
return {
|
|
1168
|
-
content: [{
|
|
1169
|
-
type: 'text',
|
|
1170
|
-
text: JSON.stringify({
|
|
1171
|
-
success: false,
|
|
1172
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1173
|
-
}, null, 2)
|
|
1174
|
-
}]
|
|
1175
|
-
};
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
1178
|
-
// discoverAgents - Discover all available agents (built-in + custom)
|
|
1179
|
-
this.server.registerTool('discoverAgents', {
|
|
1180
|
-
description: 'Discover all available agents including custom ones. Scans .context/agents/ for custom agent playbooks.',
|
|
1181
|
-
inputSchema: {}
|
|
1182
|
-
}, async () => {
|
|
1183
|
-
try {
|
|
1184
|
-
const linker = (0, workflow_2.createPlanLinker)(repoPath);
|
|
1185
|
-
const agents = await linker.discoverAgents();
|
|
1186
|
-
const builtIn = agents.filter(a => !a.isCustom);
|
|
1187
|
-
const custom = agents.filter(a => a.isCustom);
|
|
1188
|
-
return {
|
|
1189
|
-
content: [{
|
|
1190
|
-
type: 'text',
|
|
1191
|
-
text: JSON.stringify({
|
|
1192
|
-
success: true,
|
|
1193
|
-
totalAgents: agents.length,
|
|
1194
|
-
builtInCount: builtIn.length,
|
|
1195
|
-
customCount: custom.length,
|
|
1196
|
-
agents: {
|
|
1197
|
-
builtIn: builtIn.map(a => a.type),
|
|
1198
|
-
custom: custom.map(a => ({ type: a.type, path: a.path })),
|
|
1199
|
-
},
|
|
1200
|
-
}, null, 2)
|
|
1201
|
-
}]
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
catch (error) {
|
|
1205
|
-
return {
|
|
1206
|
-
content: [{
|
|
1207
|
-
type: 'text',
|
|
1208
|
-
text: JSON.stringify({
|
|
1209
|
-
success: false,
|
|
1210
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1211
|
-
}, null, 2)
|
|
1212
|
-
}]
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
55
|
+
const actionLogger_1 = require("./actionLogger");
|
|
56
|
+
const workflow_2 = require("../../workflow");
|
|
57
|
+
const gatewayTools_1 = require("./gatewayTools");
|
|
58
|
+
class AIContextMCPServer {
|
|
59
|
+
constructor(options = {}) {
|
|
60
|
+
this.transport = null;
|
|
61
|
+
this.initialRepoPath = null;
|
|
62
|
+
this.cachedRepoPath = null;
|
|
63
|
+
this.options = {
|
|
64
|
+
name: 'ai-context',
|
|
65
|
+
verbose: false,
|
|
66
|
+
...options
|
|
67
|
+
};
|
|
68
|
+
this.server = new mcp_js_1.McpServer({
|
|
69
|
+
name: this.options.name,
|
|
70
|
+
version: version_1.VERSION
|
|
1215
71
|
});
|
|
1216
|
-
//
|
|
1217
|
-
this.
|
|
1218
|
-
|
|
72
|
+
// Support dependency injection for testing, with default fallback
|
|
73
|
+
this.contextBuilder = options.contextBuilder ?? new contextBuilder_1.SemanticContextBuilder();
|
|
74
|
+
// Initialize and cache the correct repo path
|
|
75
|
+
void this.initializeRepoPath();
|
|
76
|
+
this.registerGatewayTools();
|
|
77
|
+
this.registerResources();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Register tools: 5 consolidated gateways + 4 dedicated workflow tools
|
|
81
|
+
* Total: 9 tools for clear entry points and reduced AI cognitive load
|
|
82
|
+
*
|
|
83
|
+
* Project tools removed - use context({ action: "init" }) + workflow-init instead
|
|
84
|
+
*
|
|
85
|
+
* NOTE: repoPath is now determined dynamically via getRepoPath() at runtime,
|
|
86
|
+
* which uses smart initialization and client path caching.
|
|
87
|
+
*/
|
|
88
|
+
registerGatewayTools() {
|
|
89
|
+
const wrap = (toolName, handler) => this.wrapWithActionLogging(toolName, handler);
|
|
90
|
+
// Gateway 1: explore - File and code exploration
|
|
91
|
+
this.server.registerTool('explore', {
|
|
92
|
+
description: `File and code exploration. Actions:
|
|
93
|
+
- read: Read file contents (params: filePath, encoding?)
|
|
94
|
+
- list: List files matching pattern (params: pattern, cwd?, ignore?)
|
|
95
|
+
- analyze: Analyze symbols in a file (params: filePath, symbolTypes?)
|
|
96
|
+
- search: Search code with regex (params: pattern, fileGlob?, maxResults?, cwd?)
|
|
97
|
+
- getStructure: Get directory structure (params: rootPath?, maxDepth?, includePatterns?)`,
|
|
98
|
+
inputSchema: {
|
|
99
|
+
action: zod_1.z.enum(['read', 'list', 'analyze', 'search', 'getStructure'])
|
|
100
|
+
.describe('Action to perform'),
|
|
101
|
+
filePath: zod_1.z.string().optional()
|
|
102
|
+
.describe('(read, analyze) File path to read or analyze'),
|
|
103
|
+
pattern: zod_1.z.string().optional()
|
|
104
|
+
.describe('(list, search) Glob pattern for list, regex pattern for search'),
|
|
105
|
+
cwd: zod_1.z.string().optional()
|
|
106
|
+
.describe('(list, search) Working directory'),
|
|
107
|
+
encoding: zod_1.z.enum(['utf-8', 'ascii', 'binary']).optional()
|
|
108
|
+
.describe('(read) File encoding'),
|
|
109
|
+
ignore: zod_1.z.array(zod_1.z.string()).optional()
|
|
110
|
+
.describe('(list) Patterns to ignore'),
|
|
111
|
+
symbolTypes: zod_1.z.array(zod_1.z.enum(['class', 'interface', 'function', 'type', 'enum'])).optional()
|
|
112
|
+
.describe('(analyze) Types of symbols to extract'),
|
|
113
|
+
fileGlob: zod_1.z.string().optional()
|
|
114
|
+
.describe('(search) Glob pattern to filter files'),
|
|
115
|
+
maxResults: zod_1.z.number().optional()
|
|
116
|
+
.describe('(search) Maximum results to return'),
|
|
117
|
+
rootPath: zod_1.z.string().optional()
|
|
118
|
+
.describe('(getStructure) Root path for structure'),
|
|
119
|
+
maxDepth: zod_1.z.number().optional()
|
|
120
|
+
.describe('(getStructure) Maximum directory depth'),
|
|
121
|
+
includePatterns: zod_1.z.array(zod_1.z.string()).optional()
|
|
122
|
+
.describe('(getStructure) Include patterns'),
|
|
123
|
+
}
|
|
124
|
+
}, wrap('explore', async (params) => {
|
|
125
|
+
// explore uses cwd for file operations, not repoPath for context resolution
|
|
126
|
+
return (0, gatewayTools_1.handleExplore)(params, { repoPath: this.getRepoPath() });
|
|
127
|
+
}));
|
|
128
|
+
// Gateway 2: context - Context scaffolding and semantic context
|
|
129
|
+
this.server.registerTool('context', {
|
|
130
|
+
description: `Context scaffolding and semantic context. Actions:
|
|
131
|
+
- check: Check if .context scaffolding exists (params: repoPath?)
|
|
132
|
+
- init: Initialize .context scaffolding (params: repoPath?, type?, outputDir?, semantic?, autoFill?, skipContentGeneration?)
|
|
133
|
+
- fill: Fill scaffolding with AI content (params: repoPath?, outputDir?, target?, offset?, limit?)
|
|
134
|
+
- fillSingle: Fill a single scaffold file (params: repoPath?, filePath)
|
|
135
|
+
- listToFill: List files that need filling (params: repoPath?, outputDir?, target?)
|
|
136
|
+
- getMap: Get codebase map section (params: repoPath?, section?)
|
|
137
|
+
- buildSemantic: Build semantic context (params: repoPath?, contextType?, targetFile?, options?)
|
|
138
|
+
- scaffoldPlan: Create a plan template (params: planName, repoPath?, title?, summary?, autoFill?)
|
|
139
|
+
|
|
140
|
+
**Important:** Agents should provide repoPath on the FIRST call, then it will be cached:
|
|
141
|
+
1. First call: context({ action: "check", repoPath: "/path/to/project" })
|
|
142
|
+
2. Subsequent calls can omit repoPath - it will use cached value from step 1
|
|
143
|
+
3. After context init, call fillSingle for each pending file
|
|
144
|
+
4. Call workflow-init to enable PREVC workflow (unless trivial change)`,
|
|
145
|
+
inputSchema: {
|
|
146
|
+
action: zod_1.z.enum(['check', 'init', 'fill', 'fillSingle', 'listToFill', 'getMap', 'buildSemantic', 'scaffoldPlan'])
|
|
147
|
+
.describe('Action to perform'),
|
|
148
|
+
repoPath: zod_1.z.string().optional()
|
|
149
|
+
.describe('Repository path (defaults to cwd)'),
|
|
150
|
+
outputDir: zod_1.z.string().optional()
|
|
151
|
+
.describe('Output directory (default: ./.context)'),
|
|
152
|
+
type: zod_1.z.enum(['docs', 'agents', 'both']).optional()
|
|
153
|
+
.describe('(init) Type of scaffolding to create'),
|
|
154
|
+
semantic: zod_1.z.boolean().optional()
|
|
155
|
+
.describe('(init, scaffoldPlan) Enable semantic analysis'),
|
|
156
|
+
include: zod_1.z.array(zod_1.z.string()).optional()
|
|
157
|
+
.describe('(init) Include patterns'),
|
|
158
|
+
exclude: zod_1.z.array(zod_1.z.string()).optional()
|
|
159
|
+
.describe('(init) Exclude patterns'),
|
|
160
|
+
autoFill: zod_1.z.boolean().optional()
|
|
161
|
+
.describe('(init, scaffoldPlan) Auto-fill with codebase content'),
|
|
162
|
+
skipContentGeneration: zod_1.z.boolean().optional()
|
|
163
|
+
.describe('(init) Skip pre-generating content'),
|
|
164
|
+
target: zod_1.z.enum(['docs', 'agents', 'plans', 'all']).optional()
|
|
165
|
+
.describe('(fill, listToFill) Which scaffolding to target'),
|
|
166
|
+
offset: zod_1.z.number().optional()
|
|
167
|
+
.describe('(fill) Skip first N files'),
|
|
168
|
+
limit: zod_1.z.number().optional()
|
|
169
|
+
.describe('(fill) Max files to return'),
|
|
170
|
+
filePath: zod_1.z.string().optional()
|
|
171
|
+
.describe('(fillSingle) Absolute path to scaffold file'),
|
|
172
|
+
section: zod_1.z.enum([
|
|
173
|
+
'all', 'stack', 'structure', 'architecture', 'symbols',
|
|
174
|
+
'symbols.classes', 'symbols.interfaces', 'symbols.functions',
|
|
175
|
+
'symbols.types', 'symbols.enums', 'publicAPI', 'dependencies', 'stats'
|
|
176
|
+
]).optional()
|
|
177
|
+
.describe('(getMap) Section to retrieve'),
|
|
178
|
+
contextType: zod_1.z.enum(['documentation', 'playbook', 'plan', 'compact']).optional()
|
|
179
|
+
.describe('(buildSemantic) Type of context to build'),
|
|
180
|
+
targetFile: zod_1.z.string().optional()
|
|
181
|
+
.describe('(buildSemantic) Target file for focused context'),
|
|
182
|
+
options: zod_1.z.object({
|
|
183
|
+
useLSP: zod_1.z.boolean().optional(),
|
|
184
|
+
maxContextLength: zod_1.z.number().optional(),
|
|
185
|
+
includeDocumentation: zod_1.z.boolean().optional(),
|
|
186
|
+
includeSignatures: zod_1.z.boolean().optional()
|
|
187
|
+
}).optional()
|
|
188
|
+
.describe('(buildSemantic) Builder options'),
|
|
189
|
+
planName: zod_1.z.string().optional()
|
|
190
|
+
.describe('(scaffoldPlan) Name of the plan'),
|
|
191
|
+
title: zod_1.z.string().optional()
|
|
192
|
+
.describe('(scaffoldPlan) Plan title'),
|
|
193
|
+
summary: zod_1.z.string().optional()
|
|
194
|
+
.describe('(scaffoldPlan) Plan summary/goal'),
|
|
195
|
+
}
|
|
196
|
+
}, wrap('context', async (params) => {
|
|
197
|
+
return (0, gatewayTools_1.handleContext)(params, { repoPath: this.getRepoPath(params.repoPath), contextBuilder: this.contextBuilder });
|
|
198
|
+
}));
|
|
199
|
+
// Dedicated Workflow Tools (split from consolidated workflow gateway)
|
|
200
|
+
// Tool 3a: workflow-init - Initialize PREVC workflow
|
|
201
|
+
this.server.registerTool('workflow-init', {
|
|
202
|
+
description: `Initialize a PREVC workflow for structured development.
|
|
203
|
+
|
|
204
|
+
**What it does:**
|
|
205
|
+
- Creates .context/workflow/ folder (automatically, if it doesn't exist)
|
|
206
|
+
- Initializes workflow status file with phase tracking
|
|
207
|
+
- Detects project scale and configures gates
|
|
208
|
+
- Sets up PREVC phases (Plan → Review → Execute → Verify → Complete)
|
|
209
|
+
|
|
210
|
+
**Prerequisites:**
|
|
211
|
+
- .context/ folder must exist (use context with action "init" first)
|
|
212
|
+
- Scaffolding files should be filled (use context with action "fillSingle")
|
|
213
|
+
|
|
214
|
+
**When to use:**
|
|
215
|
+
- Starting a new feature or bug fix after scaffolding is set up
|
|
216
|
+
- Need structured, phase-gated development
|
|
217
|
+
- Working on non-trivial changes
|
|
218
|
+
|
|
219
|
+
**Don't use if:**
|
|
220
|
+
- Making trivial changes (typo fixes, single-line edits)
|
|
221
|
+
- Just exploring/researching code
|
|
222
|
+
- User explicitly wants to skip workflow`,
|
|
223
|
+
inputSchema: {
|
|
224
|
+
name: zod_1.z.string().describe('Workflow/feature name (required)'),
|
|
225
|
+
description: zod_1.z.string().optional()
|
|
226
|
+
.describe('Task description for scale detection'),
|
|
227
|
+
scale: zod_1.z.enum(['QUICK', 'SMALL', 'MEDIUM', 'LARGE']).optional()
|
|
228
|
+
.describe(`Project scale - AI should evaluate based on task characteristics:
|
|
229
|
+
|
|
230
|
+
SCALE EVALUATION CRITERIA:
|
|
231
|
+
• QUICK: Single file changes, bug fixes, typos (~5 min)
|
|
232
|
+
- Phases: E → V only
|
|
233
|
+
- Example: "Fix typo in button text"
|
|
234
|
+
|
|
235
|
+
• SMALL: Simple features, no architecture changes (~15 min)
|
|
236
|
+
- Phases: P → E → V
|
|
237
|
+
- Example: "Add email validation to form"
|
|
238
|
+
|
|
239
|
+
• MEDIUM: Regular features with design decisions (~30 min)
|
|
240
|
+
- Phases: P → R → E → V
|
|
241
|
+
- Example: "Implement user profile page"
|
|
242
|
+
|
|
243
|
+
• LARGE: Complex features, systems, compliance (~1+ hour)
|
|
244
|
+
- Phases: P → R → E → V → C (full workflow)
|
|
245
|
+
- Examples: "Build OAuth system", "Add GDPR compliance"
|
|
246
|
+
|
|
247
|
+
GUIDANCE:
|
|
248
|
+
- Analyze task complexity, architectural impact, and review needs
|
|
249
|
+
- Use LARGE for security/compliance requirements
|
|
250
|
+
- When uncertain, prefer MEDIUM
|
|
251
|
+
- Omit scale only if unable to evaluate (auto-detect fallback)`),
|
|
252
|
+
autonomous: zod_1.z.boolean().optional()
|
|
253
|
+
.describe('Skip all workflow gates (default: scale-dependent)'),
|
|
254
|
+
require_plan: zod_1.z.boolean().optional()
|
|
255
|
+
.describe('Require plan before P→R'),
|
|
256
|
+
require_approval: zod_1.z.boolean().optional()
|
|
257
|
+
.describe('Require approval before R→E'),
|
|
258
|
+
archive_previous: zod_1.z.boolean().optional()
|
|
259
|
+
.describe('Archive existing workflow'),
|
|
260
|
+
}
|
|
261
|
+
}, wrap('workflow-init', async (params) => {
|
|
262
|
+
return (0, gatewayTools_1.handleWorkflowInit)(params, { repoPath: this.getRepoPath(params.repoPath) });
|
|
263
|
+
}));
|
|
264
|
+
// Tool 3b: workflow-status - Get current workflow status
|
|
265
|
+
this.server.registerTool('workflow-status', {
|
|
266
|
+
description: `Get current PREVC workflow status including phase, gates, and linked plans.
|
|
267
|
+
|
|
268
|
+
Returns: Current phase, all phase statuses, gate settings, linked plans, agent activity.`,
|
|
269
|
+
inputSchema: {
|
|
270
|
+
// No required parameters
|
|
271
|
+
}
|
|
272
|
+
}, wrap('workflow-status', async (params) => {
|
|
273
|
+
return (0, gatewayTools_1.handleWorkflowStatus)(params, { repoPath: this.getRepoPath(params.repoPath) });
|
|
274
|
+
}));
|
|
275
|
+
// Tool 3c: workflow-advance - Advance to next phase
|
|
276
|
+
this.server.registerTool('workflow-advance', {
|
|
277
|
+
description: `Advance workflow to the next PREVC phase (P→R→E→V→C).
|
|
278
|
+
|
|
279
|
+
Enforces gates:
|
|
280
|
+
- P→R: Requires plan if require_plan=true
|
|
281
|
+
- R→E: Requires approval if require_approval=true
|
|
282
|
+
|
|
283
|
+
Use force=true to bypass gates, or use workflow-manage({ action: 'setAutonomous' }).`,
|
|
1219
284
|
inputSchema: {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
285
|
+
outputs: zod_1.z.array(zod_1.z.string()).optional()
|
|
286
|
+
.describe('Artifact paths produced in current phase'),
|
|
287
|
+
force: zod_1.z.boolean().optional()
|
|
288
|
+
.describe('Force advancement even if gates block'),
|
|
289
|
+
}
|
|
290
|
+
}, wrap('workflow-advance', async (params) => {
|
|
291
|
+
return (0, gatewayTools_1.handleWorkflowAdvance)(params, { repoPath: this.getRepoPath(params.repoPath) });
|
|
292
|
+
}));
|
|
293
|
+
// Tool 3d: workflow-manage - Manage workflow operations
|
|
294
|
+
this.server.registerTool('workflow-manage', {
|
|
295
|
+
description: `Manage workflow operations: handoffs, collaboration, documents, gates, approvals.
|
|
296
|
+
|
|
297
|
+
Actions:
|
|
298
|
+
- handoff: Transfer work between agents (params: from, to, artifacts)
|
|
299
|
+
- collaborate: Start collaboration session (params: topic, participants?)
|
|
300
|
+
- createDoc: Create workflow document (params: type, docName)
|
|
301
|
+
- getGates: Check gate status
|
|
302
|
+
- approvePlan: Approve linked plan (params: planSlug?, approver?, notes?)
|
|
303
|
+
- setAutonomous: Toggle autonomous mode (params: enabled, reason?)`,
|
|
304
|
+
inputSchema: {
|
|
305
|
+
action: zod_1.z.enum(['handoff', 'collaborate', 'createDoc', 'getGates', 'approvePlan', 'setAutonomous'])
|
|
306
|
+
.describe('Action to perform'),
|
|
307
|
+
from: zod_1.z.string().optional()
|
|
308
|
+
.describe('(handoff) Agent handing off (e.g., feature-developer)'),
|
|
309
|
+
to: zod_1.z.string().optional()
|
|
310
|
+
.describe('(handoff) Agent receiving (e.g., code-reviewer)'),
|
|
311
|
+
artifacts: zod_1.z.array(zod_1.z.string()).optional()
|
|
312
|
+
.describe('(handoff) Artifacts to hand off'),
|
|
313
|
+
topic: zod_1.z.string().optional()
|
|
314
|
+
.describe('(collaborate) Collaboration topic'),
|
|
315
|
+
participants: zod_1.z.array(zod_1.z.enum(workflow_2.PREVC_ROLES)).optional()
|
|
316
|
+
.describe('(collaborate) Participating roles'),
|
|
317
|
+
type: zod_1.z.enum(['prd', 'tech-spec', 'architecture', 'adr', 'test-plan', 'changelog']).optional()
|
|
318
|
+
.describe('(createDoc) Document type'),
|
|
319
|
+
docName: zod_1.z.string().optional()
|
|
320
|
+
.describe('(createDoc) Document name'),
|
|
321
|
+
planSlug: zod_1.z.string().optional()
|
|
322
|
+
.describe('(approvePlan) Plan to approve'),
|
|
323
|
+
approver: zod_1.z.enum(workflow_2.PREVC_ROLES).optional()
|
|
324
|
+
.describe('(approvePlan) Approving role'),
|
|
325
|
+
notes: zod_1.z.string().optional()
|
|
326
|
+
.describe('(approvePlan) Approval notes'),
|
|
327
|
+
enabled: zod_1.z.boolean().optional()
|
|
328
|
+
.describe('(setAutonomous) Enable/disable'),
|
|
329
|
+
reason: zod_1.z.string().optional()
|
|
330
|
+
.describe('(setAutonomous) Reason for change'),
|
|
331
|
+
}
|
|
332
|
+
}, wrap('workflow-manage', async (params) => {
|
|
333
|
+
return (0, gatewayTools_1.handleWorkflowManage)(params, { repoPath: this.getRepoPath(params.repoPath) });
|
|
334
|
+
}));
|
|
335
|
+
// Gateway 5: sync - Import/export synchronization
|
|
336
|
+
this.server.registerTool('sync', {
|
|
337
|
+
description: `Import/export synchronization with AI tools. Actions:
|
|
338
|
+
- exportRules: Export rules to AI tools (params: preset?, force?, dryRun?)
|
|
339
|
+
- exportDocs: Export docs to AI tools (params: preset?, indexMode?, force?, dryRun?)
|
|
340
|
+
- exportAgents: Export agents to AI tools (params: preset?, mode?, force?, dryRun?)
|
|
341
|
+
- exportContext: Export all context (params: preset?, skipDocs?, skipAgents?, skipSkills?, docsIndexMode?, agentMode?, force?, dryRun?)
|
|
342
|
+
- exportSkills: Export skills to AI tools (params: preset?, includeBuiltIn?, force?)
|
|
343
|
+
- reverseSync: Import from AI tools to .context/ (params: skipRules?, skipAgents?, skipSkills?, mergeStrategy?, dryRun?, force?, addMetadata?)
|
|
344
|
+
- importDocs: Import docs from AI tools (params: autoDetect?, force?, dryRun?)
|
|
345
|
+
- importAgents: Import agents from AI tools (params: autoDetect?, force?, dryRun?)
|
|
346
|
+
- importSkills: Import skills from AI tools (params: autoDetect?, mergeStrategy?, force?, dryRun?)`,
|
|
347
|
+
inputSchema: {
|
|
348
|
+
action: zod_1.z.enum(['exportRules', 'exportDocs', 'exportAgents', 'exportContext', 'exportSkills', 'reverseSync', 'importDocs', 'importAgents', 'importSkills'])
|
|
349
|
+
.describe('Action to perform'),
|
|
350
|
+
preset: zod_1.z.string().optional()
|
|
351
|
+
.describe('Target AI tool preset'),
|
|
352
|
+
force: zod_1.z.boolean().optional()
|
|
353
|
+
.describe('Overwrite existing files'),
|
|
354
|
+
dryRun: zod_1.z.boolean().optional()
|
|
355
|
+
.describe('Preview without writing'),
|
|
356
|
+
indexMode: zod_1.z.enum(['readme', 'all']).optional()
|
|
357
|
+
.describe('(exportDocs) Index mode'),
|
|
358
|
+
mode: zod_1.z.enum(['symlink', 'markdown']).optional()
|
|
359
|
+
.describe('(exportAgents) Sync mode'),
|
|
360
|
+
skipDocs: zod_1.z.boolean().optional()
|
|
361
|
+
.describe('(exportContext) Skip docs'),
|
|
362
|
+
skipAgents: zod_1.z.boolean().optional()
|
|
363
|
+
.describe('(exportContext, reverseSync) Skip agents'),
|
|
364
|
+
skipSkills: zod_1.z.boolean().optional()
|
|
365
|
+
.describe('(exportContext, reverseSync) Skip skills'),
|
|
366
|
+
skipRules: zod_1.z.boolean().optional()
|
|
367
|
+
.describe('(reverseSync) Skip rules'),
|
|
368
|
+
docsIndexMode: zod_1.z.enum(['readme', 'all']).optional()
|
|
369
|
+
.describe('(exportContext) Docs index mode'),
|
|
370
|
+
agentMode: zod_1.z.enum(['symlink', 'markdown']).optional()
|
|
371
|
+
.describe('(exportContext) Agent sync mode'),
|
|
372
|
+
includeBuiltInSkills: zod_1.z.boolean().optional()
|
|
373
|
+
.describe('(exportContext) Include built-in skills'),
|
|
374
|
+
includeBuiltIn: zod_1.z.boolean().optional()
|
|
375
|
+
.describe('(exportSkills) Include built-in skills'),
|
|
376
|
+
mergeStrategy: zod_1.z.enum(['skip', 'overwrite', 'merge', 'rename']).optional()
|
|
377
|
+
.describe('(reverseSync, importSkills) Conflict handling'),
|
|
378
|
+
autoDetect: zod_1.z.boolean().optional()
|
|
379
|
+
.describe('(import*) Auto-detect files'),
|
|
380
|
+
addMetadata: zod_1.z.boolean().optional()
|
|
381
|
+
.describe('(reverseSync) Add frontmatter metadata'),
|
|
382
|
+
repoPath: zod_1.z.string().optional()
|
|
383
|
+
.describe('Repository path'),
|
|
384
|
+
}
|
|
385
|
+
}, wrap('sync', async (params) => {
|
|
386
|
+
return (0, gatewayTools_1.handleSync)(params, { repoPath: this.getRepoPath(params.repoPath) });
|
|
387
|
+
}));
|
|
388
|
+
// Gateway 6: plan - Plan management and execution tracking
|
|
389
|
+
this.server.registerTool('plan', {
|
|
390
|
+
description: `Plan management and execution tracking. Actions:
|
|
391
|
+
- link: Link plan to workflow (params: planSlug)
|
|
392
|
+
- getLinked: Get all linked plans
|
|
393
|
+
- getDetails: Get detailed plan info (params: planSlug)
|
|
394
|
+
- getForPhase: Get plans for PREVC phase (params: phase)
|
|
395
|
+
- updatePhase: Update plan phase status (params: planSlug, phaseId, status)
|
|
396
|
+
- recordDecision: Record a decision (params: planSlug, title, description, phase?, alternatives?)
|
|
397
|
+
- updateStep: Update step status (params: planSlug, phaseId, stepIndex, status, output?, notes?)
|
|
398
|
+
- getStatus: Get plan execution status (params: planSlug)
|
|
399
|
+
- syncMarkdown: Sync tracking to markdown (params: planSlug)
|
|
400
|
+
- commitPhase: Create git commit for completed phase (params: planSlug, phaseId, coAuthor?, stagePatterns?, dryRun?)`,
|
|
401
|
+
inputSchema: {
|
|
402
|
+
action: zod_1.z.enum(['link', 'getLinked', 'getDetails', 'getForPhase', 'updatePhase', 'recordDecision', 'updateStep', 'getStatus', 'syncMarkdown', 'commitPhase'])
|
|
403
|
+
.describe('Action to perform'),
|
|
404
|
+
planSlug: zod_1.z.string().optional()
|
|
405
|
+
.describe('Plan slug/identifier'),
|
|
406
|
+
phaseId: zod_1.z.string().optional()
|
|
407
|
+
.describe('(updatePhase, updateStep, commitPhase) Phase ID'),
|
|
408
|
+
status: zod_1.z.enum(['pending', 'in_progress', 'completed', 'skipped']).optional()
|
|
409
|
+
.describe('(updatePhase, updateStep) New status'),
|
|
410
|
+
phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).optional()
|
|
411
|
+
.describe('(getForPhase, recordDecision) PREVC phase'),
|
|
412
|
+
title: zod_1.z.string().optional()
|
|
413
|
+
.describe('(recordDecision) Decision title'),
|
|
414
|
+
description: zod_1.z.string().optional()
|
|
415
|
+
.describe('(recordDecision) Decision description'),
|
|
416
|
+
alternatives: zod_1.z.array(zod_1.z.string()).optional()
|
|
417
|
+
.describe('(recordDecision) Considered alternatives'),
|
|
418
|
+
stepIndex: zod_1.z.number().optional()
|
|
419
|
+
.describe('(updateStep) Step number (1-based)'),
|
|
420
|
+
output: zod_1.z.string().optional()
|
|
421
|
+
.describe('(updateStep) Step output artifact'),
|
|
422
|
+
notes: zod_1.z.string().optional()
|
|
423
|
+
.describe('(updateStep) Execution notes'),
|
|
424
|
+
coAuthor: zod_1.z.string().optional()
|
|
425
|
+
.describe('(commitPhase) Agent name for Co-Authored-By footer'),
|
|
426
|
+
stagePatterns: zod_1.z.array(zod_1.z.string()).optional()
|
|
427
|
+
.describe('(commitPhase) Patterns for files to stage (default: [".context/**"])'),
|
|
428
|
+
dryRun: zod_1.z.boolean().optional()
|
|
429
|
+
.describe('(commitPhase) Preview without committing'),
|
|
430
|
+
}
|
|
431
|
+
}, wrap('plan', async (params) => {
|
|
432
|
+
return (0, gatewayTools_1.handlePlan)(params, { repoPath: this.getRepoPath() });
|
|
433
|
+
}));
|
|
434
|
+
// Gateway 7: agent - Agent orchestration and discovery
|
|
435
|
+
this.server.registerTool('agent', {
|
|
436
|
+
description: `Agent orchestration and discovery. Actions:
|
|
437
|
+
- discover: Discover all agents (built-in + custom)
|
|
438
|
+
- getInfo: Get agent details (params: agentType)
|
|
439
|
+
- orchestrate: Select agents for task/phase/role (params: task?, phase?, role?)
|
|
440
|
+
- getSequence: Get agent handoff sequence (params: task, includeReview?, phases?)
|
|
441
|
+
- getDocs: Get agent documentation (params: agent)
|
|
442
|
+
- getPhaseDocs: Get phase documentation (params: phase)
|
|
443
|
+
- listTypes: List all agent types`,
|
|
444
|
+
inputSchema: {
|
|
445
|
+
action: zod_1.z.enum(['discover', 'getInfo', 'orchestrate', 'getSequence', 'getDocs', 'getPhaseDocs', 'listTypes'])
|
|
446
|
+
.describe('Action to perform'),
|
|
447
|
+
agentType: zod_1.z.string().optional()
|
|
448
|
+
.describe('(getInfo) Agent type identifier'),
|
|
449
|
+
task: zod_1.z.string().optional()
|
|
450
|
+
.describe('(orchestrate, getSequence) Task description'),
|
|
451
|
+
phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).optional()
|
|
452
|
+
.describe('(orchestrate, getPhaseDocs) PREVC phase'),
|
|
453
|
+
role: zod_1.z.enum(workflow_2.PREVC_ROLES).optional()
|
|
454
|
+
.describe('(orchestrate) PREVC role'),
|
|
455
|
+
includeReview: zod_1.z.boolean().optional()
|
|
456
|
+
.describe('(getSequence) Include code review'),
|
|
457
|
+
phases: zod_1.z.array(zod_1.z.enum(['P', 'R', 'E', 'V', 'C'])).optional()
|
|
458
|
+
.describe('(getSequence) Phases to include'),
|
|
459
|
+
agent: zod_1.z.enum(workflow_2.AGENT_TYPES).optional()
|
|
460
|
+
.describe('(getDocs) Agent type for docs'),
|
|
461
|
+
}
|
|
462
|
+
}, wrap('agent', async (params) => {
|
|
463
|
+
return (0, gatewayTools_1.handleAgent)(params, { repoPath: this.getRepoPath() });
|
|
464
|
+
}));
|
|
465
|
+
// Gateway 8: skill - Skill management
|
|
466
|
+
this.server.registerTool('skill', {
|
|
467
|
+
description: `Skill management for on-demand expertise. Actions:
|
|
468
|
+
- list: List all skills (params: includeContent?)
|
|
469
|
+
- getContent: Get skill content (params: skillSlug)
|
|
470
|
+
- getForPhase: Get skills for PREVC phase (params: phase)
|
|
471
|
+
- scaffold: Generate skill files (params: skills?, force?)
|
|
472
|
+
- export: Export skills to AI tools (params: preset?, includeBuiltIn?, force?)
|
|
473
|
+
- fill: Fill skills with codebase content (params: skills?, force?)`,
|
|
474
|
+
inputSchema: {
|
|
475
|
+
action: zod_1.z.enum(['list', 'getContent', 'getForPhase', 'scaffold', 'export', 'fill'])
|
|
476
|
+
.describe('Action to perform'),
|
|
477
|
+
skillSlug: zod_1.z.string().optional()
|
|
478
|
+
.describe('(getContent) Skill identifier'),
|
|
479
|
+
phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).optional()
|
|
480
|
+
.describe('(getForPhase) PREVC phase'),
|
|
481
|
+
skills: zod_1.z.array(zod_1.z.string()).optional()
|
|
482
|
+
.describe('(scaffold, fill) Specific skills to process'),
|
|
483
|
+
includeContent: zod_1.z.boolean().optional()
|
|
484
|
+
.describe('(list) Include full content'),
|
|
485
|
+
includeBuiltIn: zod_1.z.boolean().optional()
|
|
486
|
+
.describe('(export, fill) Include built-in skills'),
|
|
487
|
+
preset: zod_1.z.enum(['claude', 'gemini', 'codex', 'antigravity', 'all']).optional()
|
|
488
|
+
.describe('(export) Target AI tool'),
|
|
489
|
+
force: zod_1.z.boolean().optional()
|
|
490
|
+
.describe('(scaffold, export) Overwrite existing'),
|
|
491
|
+
}
|
|
492
|
+
}, wrap('skill', async (params) => {
|
|
493
|
+
return (0, gatewayTools_1.handleSkill)(params, { repoPath: this.getRepoPath() });
|
|
494
|
+
}));
|
|
495
|
+
this.log('Registered 9 tools (5 consolidated gateways + 4 dedicated workflow tools)');
|
|
1249
496
|
}
|
|
1250
497
|
/**
|
|
1251
498
|
* Register semantic context resources
|
|
499
|
+
* Uses initialRepoPath if found, otherwise process.cwd()
|
|
1252
500
|
*/
|
|
1253
501
|
registerResources() {
|
|
1254
|
-
const repoPath = this.
|
|
502
|
+
const repoPath = this.initialRepoPath ?? process.cwd();
|
|
1255
503
|
// Register context resources as templates with URI patterns
|
|
1256
504
|
this.server.registerResource('codebase-context', `context://codebase/{contextType}`, {
|
|
1257
505
|
description: 'Semantic context for the codebase. Use contextType: documentation, playbook, plan, or compact',
|
|
@@ -1305,14 +553,13 @@ class AIContextMCPServer {
|
|
|
1305
553
|
this.log('Registered 2 resource templates');
|
|
1306
554
|
// Register PREVC workflow resources
|
|
1307
555
|
this.registerWorkflowResources();
|
|
1308
|
-
// Register orchestration tools
|
|
1309
|
-
this.registerOrchestrationTools();
|
|
1310
556
|
}
|
|
1311
557
|
/**
|
|
1312
558
|
* Register PREVC workflow resources
|
|
559
|
+
* Uses initialRepoPath if found, otherwise process.cwd()
|
|
1313
560
|
*/
|
|
1314
561
|
registerWorkflowResources() {
|
|
1315
|
-
const repoPath = this.
|
|
562
|
+
const repoPath = this.initialRepoPath ?? process.cwd();
|
|
1316
563
|
// workflow://status - Current workflow status
|
|
1317
564
|
this.server.registerResource('workflow-status', 'workflow://status', {
|
|
1318
565
|
description: 'Current PREVC workflow status including phases, roles, and progress',
|
|
@@ -1362,552 +609,161 @@ class AIContextMCPServer {
|
|
|
1362
609
|
this.log('Registered 1 workflow resource');
|
|
1363
610
|
}
|
|
1364
611
|
/**
|
|
1365
|
-
*
|
|
612
|
+
* Initialize repo path with smart detection and caching
|
|
613
|
+
*
|
|
614
|
+
* Strategy:
|
|
615
|
+
* 1. If explicit options.repoPath provided, try to find project root from there
|
|
616
|
+
* 2. Otherwise search upward from process.cwd() for .context or .git
|
|
617
|
+
* 3. Set as initialRepoPath if found (for resources)
|
|
618
|
+
* 4. First valid repoPath from client gets cached for all subsequent tool calls
|
|
619
|
+
* 5. Fallback to process.cwd() if nothing found (allows flexible MCP usage)
|
|
1366
620
|
*/
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
this.
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
if (task) {
|
|
1381
|
-
agents = workflow_2.agentOrchestrator.selectAgentsByTask(task);
|
|
1382
|
-
source = `task: "${task}"`;
|
|
1383
|
-
}
|
|
1384
|
-
else if (phase) {
|
|
1385
|
-
agents = workflow_2.agentOrchestrator.getAgentsForPhase(phase);
|
|
1386
|
-
source = `phase: ${phase} (${workflow_2.PHASE_NAMES_EN[phase]})`;
|
|
1387
|
-
}
|
|
1388
|
-
else if (role) {
|
|
1389
|
-
agents = workflow_2.agentOrchestrator.getAgentsForRole(role);
|
|
1390
|
-
source = `role: ${workflow_2.ROLE_DISPLAY_NAMES[role]}`;
|
|
1391
|
-
}
|
|
1392
|
-
else {
|
|
1393
|
-
return {
|
|
1394
|
-
content: [{ type: 'text', text: 'Error: Provide task, phase, or role parameter' }],
|
|
1395
|
-
};
|
|
1396
|
-
}
|
|
1397
|
-
const agentDetails = agents.map((agent) => ({
|
|
1398
|
-
type: agent,
|
|
1399
|
-
description: workflow_2.agentOrchestrator.getAgentDescription(agent),
|
|
1400
|
-
docs: workflow_2.documentLinker.getDocPathsForAgent(agent),
|
|
1401
|
-
}));
|
|
1402
|
-
return {
|
|
1403
|
-
content: [{
|
|
1404
|
-
type: 'text',
|
|
1405
|
-
text: JSON.stringify({
|
|
1406
|
-
source,
|
|
1407
|
-
agents: agentDetails,
|
|
1408
|
-
count: agents.length,
|
|
1409
|
-
}, null, 2),
|
|
1410
|
-
}],
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
catch (error) {
|
|
1414
|
-
return {
|
|
1415
|
-
content: [{
|
|
1416
|
-
type: 'text',
|
|
1417
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
1418
|
-
}],
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
});
|
|
1422
|
-
// getAgentSequence - Get recommended agent sequence for a task
|
|
1423
|
-
this.server.registerTool('getAgentSequence', {
|
|
1424
|
-
description: 'Get recommended sequence of agents for a task, including handoff order. Useful for planning multi-agent workflows.',
|
|
1425
|
-
inputSchema: {
|
|
1426
|
-
task: zod_1.z.string().describe('Task description'),
|
|
1427
|
-
includeReview: zod_1.z.boolean().optional().describe('Include code review in sequence (default: true)'),
|
|
1428
|
-
phases: zod_1.z.array(zod_1.z.enum(['P', 'R', 'E', 'V', 'C'])).optional().describe('PREVC phases to include (for phase-based sequencing)'),
|
|
1429
|
-
},
|
|
1430
|
-
}, async ({ task, includeReview, phases }) => {
|
|
1431
|
-
try {
|
|
1432
|
-
let sequence;
|
|
1433
|
-
if (phases && phases.length > 0) {
|
|
1434
|
-
sequence = workflow_2.agentOrchestrator.getAgentHandoffSequence(phases);
|
|
1435
|
-
}
|
|
1436
|
-
else {
|
|
1437
|
-
sequence = workflow_2.agentOrchestrator.getTaskAgentSequence(task, includeReview !== false);
|
|
1438
|
-
}
|
|
1439
|
-
const sequenceDetails = sequence.map((agent, index) => ({
|
|
1440
|
-
order: index + 1,
|
|
1441
|
-
agent,
|
|
1442
|
-
description: workflow_2.agentOrchestrator.getAgentDescription(agent),
|
|
1443
|
-
primaryDoc: workflow_2.documentLinker.getPrimaryDocForAgent(agent)?.path || null,
|
|
1444
|
-
}));
|
|
1445
|
-
return {
|
|
1446
|
-
content: [{
|
|
1447
|
-
type: 'text',
|
|
1448
|
-
text: JSON.stringify({
|
|
1449
|
-
task,
|
|
1450
|
-
sequence: sequenceDetails,
|
|
1451
|
-
totalAgents: sequence.length,
|
|
1452
|
-
}, null, 2),
|
|
1453
|
-
}],
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
|
-
catch (error) {
|
|
1457
|
-
return {
|
|
1458
|
-
content: [{
|
|
1459
|
-
type: 'text',
|
|
1460
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
1461
|
-
}],
|
|
1462
|
-
};
|
|
1463
|
-
}
|
|
1464
|
-
});
|
|
1465
|
-
// getAgentDocs - Get documentation relevant to an agent
|
|
1466
|
-
this.server.registerTool('getAgentDocs', {
|
|
1467
|
-
description: 'Get documentation guides relevant to a specific agent type. Helps agents find the right context.',
|
|
1468
|
-
inputSchema: {
|
|
1469
|
-
agent: zod_1.z.enum(workflow_2.AGENT_TYPES).describe('Agent type to get documentation for'),
|
|
1470
|
-
},
|
|
1471
|
-
}, async ({ agent }) => {
|
|
1472
|
-
try {
|
|
1473
|
-
if (!workflow_2.agentOrchestrator.isValidAgentType(agent)) {
|
|
1474
|
-
return {
|
|
1475
|
-
content: [{
|
|
1476
|
-
type: 'text',
|
|
1477
|
-
text: `Error: Invalid agent type "${agent}". Valid types: ${workflow_2.AGENT_TYPES.join(', ')}`,
|
|
1478
|
-
}],
|
|
1479
|
-
};
|
|
1480
|
-
}
|
|
1481
|
-
const docs = workflow_2.documentLinker.getDocsForAgent(agent);
|
|
1482
|
-
const agentDesc = workflow_2.agentOrchestrator.getAgentDescription(agent);
|
|
1483
|
-
return {
|
|
1484
|
-
content: [{
|
|
1485
|
-
type: 'text',
|
|
1486
|
-
text: JSON.stringify({
|
|
1487
|
-
agent,
|
|
1488
|
-
description: agentDesc,
|
|
1489
|
-
documentation: docs.map((doc) => ({
|
|
1490
|
-
type: doc.type,
|
|
1491
|
-
title: doc.title,
|
|
1492
|
-
path: doc.path,
|
|
1493
|
-
description: doc.description,
|
|
1494
|
-
})),
|
|
1495
|
-
}, null, 2),
|
|
1496
|
-
}],
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
|
-
catch (error) {
|
|
1500
|
-
return {
|
|
1501
|
-
content: [{
|
|
1502
|
-
type: 'text',
|
|
1503
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
1504
|
-
}],
|
|
1505
|
-
};
|
|
1506
|
-
}
|
|
1507
|
-
});
|
|
1508
|
-
// getPhaseDocs - Get documentation for a PREVC phase
|
|
1509
|
-
this.server.registerTool('getPhaseDocs', {
|
|
1510
|
-
description: 'Get documentation relevant to a PREVC workflow phase. Helps understand what documentation is needed at each phase.',
|
|
1511
|
-
inputSchema: {
|
|
1512
|
-
phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).describe('PREVC phase (P=Planning, R=Review, E=Execution, V=Validation, C=Confirmation)'),
|
|
1513
|
-
},
|
|
1514
|
-
}, async ({ phase }) => {
|
|
1515
|
-
try {
|
|
1516
|
-
const docs = workflow_2.documentLinker.getDocsForPhase(phase);
|
|
1517
|
-
const agents = workflow_2.agentOrchestrator.getAgentsForPhase(phase);
|
|
1518
|
-
return {
|
|
1519
|
-
content: [{
|
|
1520
|
-
type: 'text',
|
|
1521
|
-
text: JSON.stringify({
|
|
1522
|
-
phase,
|
|
1523
|
-
phaseName: workflow_2.PHASE_NAMES_EN[phase],
|
|
1524
|
-
documentation: docs.map((doc) => ({
|
|
1525
|
-
type: doc.type,
|
|
1526
|
-
title: doc.title,
|
|
1527
|
-
path: doc.path,
|
|
1528
|
-
description: doc.description,
|
|
1529
|
-
})),
|
|
1530
|
-
recommendedAgents: agents.map((agent) => ({
|
|
1531
|
-
type: agent,
|
|
1532
|
-
description: workflow_2.agentOrchestrator.getAgentDescription(agent),
|
|
1533
|
-
})),
|
|
1534
|
-
}, null, 2),
|
|
1535
|
-
}],
|
|
1536
|
-
};
|
|
1537
|
-
}
|
|
1538
|
-
catch (error) {
|
|
1539
|
-
return {
|
|
1540
|
-
content: [{
|
|
1541
|
-
type: 'text',
|
|
1542
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
1543
|
-
}],
|
|
1544
|
-
};
|
|
1545
|
-
}
|
|
1546
|
-
});
|
|
1547
|
-
// listAgentTypes - List all available agent types
|
|
1548
|
-
this.server.registerTool('listAgentTypes', {
|
|
1549
|
-
description: 'List all available agent types with their descriptions. Use this to understand what agents are available.',
|
|
1550
|
-
inputSchema: {},
|
|
1551
|
-
}, async () => {
|
|
1552
|
-
const agents = workflow_2.agentOrchestrator.getAllAgentTypes().map((agent) => ({
|
|
1553
|
-
type: agent,
|
|
1554
|
-
description: workflow_2.agentOrchestrator.getAgentDescription(agent),
|
|
1555
|
-
primaryDoc: workflow_2.documentLinker.getPrimaryDocForAgent(agent)?.title || null,
|
|
1556
|
-
}));
|
|
1557
|
-
return {
|
|
1558
|
-
content: [{
|
|
1559
|
-
type: 'text',
|
|
1560
|
-
text: JSON.stringify({
|
|
1561
|
-
agents,
|
|
1562
|
-
total: agents.length,
|
|
1563
|
-
}, null, 2),
|
|
1564
|
-
}],
|
|
1565
|
-
};
|
|
1566
|
-
});
|
|
1567
|
-
this.log('Registered 5 orchestration tools');
|
|
1568
|
-
// Register skill tools
|
|
1569
|
-
this.registerSkillTools();
|
|
621
|
+
async initializeRepoPath() {
|
|
622
|
+
const startPath = this.options.repoPath || process.cwd();
|
|
623
|
+
const foundRoot = await this.findProjectRoot(startPath);
|
|
624
|
+
if (foundRoot) {
|
|
625
|
+
this.initialRepoPath = path.resolve(foundRoot);
|
|
626
|
+
this.log(`Server initialized with project root: ${this.initialRepoPath}`);
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
// No project found - will use process.cwd() as fallback
|
|
630
|
+
// This allows flexible MCP server usage without strict project detection
|
|
631
|
+
this.initialRepoPath = null;
|
|
632
|
+
this.log(`No project root found. Will use process.cwd() or first valid client-provided path.`);
|
|
633
|
+
}
|
|
1570
634
|
}
|
|
1571
635
|
/**
|
|
1572
|
-
*
|
|
636
|
+
* Find project root by searching upward for .context or .git
|
|
1573
637
|
*/
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
});
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
const registry = createSkillRegistry(repoPath);
|
|
1633
|
-
const content = await registry.getSkillContent(skillSlug);
|
|
1634
|
-
if (!content) {
|
|
1635
|
-
return {
|
|
1636
|
-
content: [{
|
|
1637
|
-
type: 'text',
|
|
1638
|
-
text: JSON.stringify({
|
|
1639
|
-
success: false,
|
|
1640
|
-
error: `Skill not found: ${skillSlug}`,
|
|
1641
|
-
availableSkills: BUILT_IN_SKILLS,
|
|
1642
|
-
}, null, 2)
|
|
1643
|
-
}]
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
const skill = await registry.getSkillMetadata(skillSlug);
|
|
1647
|
-
return {
|
|
1648
|
-
content: [{
|
|
1649
|
-
type: 'text',
|
|
1650
|
-
text: JSON.stringify({
|
|
1651
|
-
success: true,
|
|
1652
|
-
skill: {
|
|
1653
|
-
slug: skillSlug,
|
|
1654
|
-
name: skill?.metadata.name,
|
|
1655
|
-
description: skill?.metadata.description,
|
|
1656
|
-
phases: skill?.metadata.phases,
|
|
1657
|
-
isBuiltIn: skill?.isBuiltIn,
|
|
1658
|
-
},
|
|
1659
|
-
content,
|
|
1660
|
-
}, null, 2)
|
|
1661
|
-
}]
|
|
1662
|
-
};
|
|
1663
|
-
}
|
|
1664
|
-
catch (error) {
|
|
1665
|
-
return {
|
|
1666
|
-
content: [{
|
|
1667
|
-
type: 'text',
|
|
1668
|
-
text: JSON.stringify({
|
|
1669
|
-
success: false,
|
|
1670
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1671
|
-
}, null, 2)
|
|
1672
|
-
}]
|
|
1673
|
-
};
|
|
1674
|
-
}
|
|
1675
|
-
});
|
|
1676
|
-
// getSkillsForPhase - Get skills relevant to a PREVC phase
|
|
1677
|
-
this.server.registerTool('getSkillsForPhase', {
|
|
1678
|
-
description: 'Get all skills relevant to a specific PREVC phase. Useful for knowing which skills to activate during workflow execution.',
|
|
1679
|
-
inputSchema: {
|
|
1680
|
-
phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).describe('PREVC phase'),
|
|
1681
|
-
}
|
|
1682
|
-
}, async ({ phase }) => {
|
|
1683
|
-
try {
|
|
1684
|
-
const registry = createSkillRegistry(repoPath);
|
|
1685
|
-
const skills = await registry.getSkillsForPhase(phase);
|
|
1686
|
-
return {
|
|
1687
|
-
content: [{
|
|
1688
|
-
type: 'text',
|
|
1689
|
-
text: JSON.stringify({
|
|
1690
|
-
success: true,
|
|
1691
|
-
phase,
|
|
1692
|
-
phaseName: workflow_2.PHASE_NAMES_EN[phase],
|
|
1693
|
-
skills: skills.map((s) => ({
|
|
1694
|
-
slug: s.slug,
|
|
1695
|
-
name: s.metadata.name,
|
|
1696
|
-
description: s.metadata.description,
|
|
1697
|
-
isBuiltIn: s.isBuiltIn,
|
|
1698
|
-
})),
|
|
1699
|
-
count: skills.length,
|
|
1700
|
-
}, null, 2)
|
|
1701
|
-
}]
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
catch (error) {
|
|
1705
|
-
return {
|
|
1706
|
-
content: [{
|
|
1707
|
-
type: 'text',
|
|
1708
|
-
text: JSON.stringify({
|
|
1709
|
-
success: false,
|
|
1710
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1711
|
-
}, null, 2)
|
|
1712
|
-
}]
|
|
1713
|
-
};
|
|
1714
|
-
}
|
|
1715
|
-
});
|
|
1716
|
-
// scaffoldSkills - Generate skill files
|
|
1717
|
-
this.server.registerTool('scaffoldSkills', {
|
|
1718
|
-
description: 'Scaffold skill files in .context/skills/. Creates SKILL.md files for built-in or custom skills.',
|
|
1719
|
-
inputSchema: {
|
|
1720
|
-
skills: zod_1.z.array(zod_1.z.string()).optional().describe('Specific skills to scaffold (default: all built-in)'),
|
|
1721
|
-
force: zod_1.z.boolean().optional().describe('Overwrite existing skill files'),
|
|
1722
|
-
}
|
|
1723
|
-
}, async ({ skills, force }) => {
|
|
638
|
+
async findProjectRoot(startPath) {
|
|
639
|
+
let currentPath = path.resolve(startPath);
|
|
640
|
+
const root = path.parse(currentPath).root;
|
|
641
|
+
// Search upward for .context or .git
|
|
642
|
+
while (currentPath !== root) {
|
|
643
|
+
if (await fs.pathExists(path.join(currentPath, '.context')) ||
|
|
644
|
+
await fs.pathExists(path.join(currentPath, '.git'))) {
|
|
645
|
+
return currentPath;
|
|
646
|
+
}
|
|
647
|
+
currentPath = path.dirname(currentPath);
|
|
648
|
+
}
|
|
649
|
+
// Not found
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Cache a valid repoPath from client
|
|
654
|
+
* Only cache if it contains .context and we haven't cached yet
|
|
655
|
+
*/
|
|
656
|
+
cacheRepoPathIfValid(repoPath) {
|
|
657
|
+
if (this.cachedRepoPath) {
|
|
658
|
+
return; // Already cached
|
|
659
|
+
}
|
|
660
|
+
const contextPath = path.join(repoPath, '.context');
|
|
661
|
+
if (fs.existsSync(contextPath)) {
|
|
662
|
+
this.cachedRepoPath = path.resolve(repoPath);
|
|
663
|
+
process.stderr.write(`[mcp] ✓ Cached repoPath for this session: ${this.cachedRepoPath}\n`);
|
|
664
|
+
this.log(`Cached valid repoPath: ${this.cachedRepoPath}`);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Get the effective repo path for a tool call
|
|
669
|
+
* Priority: 1) explicit param, 2) cached path, 3) initial path, 4) process.cwd()
|
|
670
|
+
*/
|
|
671
|
+
getRepoPath(paramsRepoPath) {
|
|
672
|
+
if (paramsRepoPath) {
|
|
673
|
+
const resolved = path.resolve(paramsRepoPath);
|
|
674
|
+
this.cacheRepoPathIfValid(resolved);
|
|
675
|
+
return resolved;
|
|
676
|
+
}
|
|
677
|
+
if (this.cachedRepoPath) {
|
|
678
|
+
this.log(`Using cached repoPath: ${this.cachedRepoPath}`);
|
|
679
|
+
return this.cachedRepoPath;
|
|
680
|
+
}
|
|
681
|
+
if (this.initialRepoPath) {
|
|
682
|
+
this.log(`Using initial repoPath: ${this.initialRepoPath}`);
|
|
683
|
+
return this.initialRepoPath;
|
|
684
|
+
}
|
|
685
|
+
// Fallback to current working directory
|
|
686
|
+
const cwd = process.cwd();
|
|
687
|
+
this.log(`Using fallback cwd: ${cwd}`);
|
|
688
|
+
return cwd;
|
|
689
|
+
}
|
|
690
|
+
wrapWithActionLogging(toolName, handler) {
|
|
691
|
+
return async (params) => {
|
|
692
|
+
const resolvedRepoPath = this.getRepoPath(params?.repoPath);
|
|
693
|
+
const action = typeof params?.action === 'string'
|
|
694
|
+
? params.action
|
|
695
|
+
: toolName;
|
|
1724
696
|
try {
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
return {
|
|
1729
|
-
content: [{
|
|
1730
|
-
type: 'text',
|
|
1731
|
-
text: JSON.stringify({
|
|
1732
|
-
success: true,
|
|
1733
|
-
skillsDir: result.skillsDir,
|
|
1734
|
-
generated: result.generatedSkills,
|
|
1735
|
-
skipped: result.skippedSkills,
|
|
1736
|
-
indexPath: result.indexPath,
|
|
1737
|
-
}, null, 2)
|
|
1738
|
-
}]
|
|
1739
|
-
};
|
|
697
|
+
const response = await handler(params);
|
|
698
|
+
await this.logToolResponse(resolvedRepoPath, toolName, action, params, response);
|
|
699
|
+
return response;
|
|
1740
700
|
}
|
|
1741
701
|
catch (error) {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
type: 'text',
|
|
1745
|
-
text: JSON.stringify({
|
|
1746
|
-
success: false,
|
|
1747
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1748
|
-
}, null, 2)
|
|
1749
|
-
}]
|
|
1750
|
-
};
|
|
702
|
+
await this.logToolError(resolvedRepoPath, toolName, action, params, error);
|
|
703
|
+
throw error;
|
|
1751
704
|
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
async logToolResponse(repoPath, toolName, action, params, response) {
|
|
708
|
+
const payload = this.parseResponsePayload(response);
|
|
709
|
+
const success = typeof payload?.success === 'boolean'
|
|
710
|
+
? payload.success
|
|
711
|
+
: !response.isError;
|
|
712
|
+
const errorMessage = typeof payload?.error === 'string' ? payload.error : undefined;
|
|
713
|
+
const resultSummary = payload ? this.buildResultSummary(payload) : undefined;
|
|
714
|
+
await (0, actionLogger_1.logMcpAction)(repoPath, {
|
|
715
|
+
tool: toolName,
|
|
716
|
+
action,
|
|
717
|
+
status: success ? 'success' : 'error',
|
|
718
|
+
details: {
|
|
719
|
+
params,
|
|
720
|
+
...(resultSummary ? { result: resultSummary } : {}),
|
|
721
|
+
},
|
|
722
|
+
...(success ? {} : { error: errorMessage || 'Tool reported failure' }),
|
|
1752
723
|
});
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
}, async ({ preset, includeBuiltIn, force }) => {
|
|
1763
|
-
try {
|
|
1764
|
-
const { SkillExportService } = require('../export/skillExportService');
|
|
1765
|
-
const exportService = new SkillExportService({
|
|
1766
|
-
ui: {
|
|
1767
|
-
displayOutput: () => { },
|
|
1768
|
-
displaySuccess: () => { },
|
|
1769
|
-
displayError: () => { },
|
|
1770
|
-
displayWarning: () => { },
|
|
1771
|
-
startSpinner: () => { },
|
|
1772
|
-
stopSpinner: () => { },
|
|
1773
|
-
updateSpinner: () => { },
|
|
1774
|
-
},
|
|
1775
|
-
t: (key) => key,
|
|
1776
|
-
version: version_1.VERSION,
|
|
1777
|
-
});
|
|
1778
|
-
const result = await exportService.run(repoPath, {
|
|
1779
|
-
preset,
|
|
1780
|
-
includeBuiltIn,
|
|
1781
|
-
force,
|
|
1782
|
-
});
|
|
1783
|
-
return {
|
|
1784
|
-
content: [{
|
|
1785
|
-
type: 'text',
|
|
1786
|
-
text: JSON.stringify({
|
|
1787
|
-
success: result.filesCreated > 0,
|
|
1788
|
-
targets: result.targets,
|
|
1789
|
-
skillsExported: result.skillsExported,
|
|
1790
|
-
filesCreated: result.filesCreated,
|
|
1791
|
-
filesSkipped: result.filesSkipped,
|
|
1792
|
-
}, null, 2)
|
|
1793
|
-
}]
|
|
1794
|
-
};
|
|
1795
|
-
}
|
|
1796
|
-
catch (error) {
|
|
1797
|
-
return {
|
|
1798
|
-
content: [{
|
|
1799
|
-
type: 'text',
|
|
1800
|
-
text: JSON.stringify({
|
|
1801
|
-
success: false,
|
|
1802
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1803
|
-
}, null, 2)
|
|
1804
|
-
}]
|
|
1805
|
-
};
|
|
1806
|
-
}
|
|
724
|
+
}
|
|
725
|
+
async logToolError(repoPath, toolName, action, params, error) {
|
|
726
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
727
|
+
await (0, actionLogger_1.logMcpAction)(repoPath, {
|
|
728
|
+
tool: toolName,
|
|
729
|
+
action,
|
|
730
|
+
status: 'error',
|
|
731
|
+
details: { params },
|
|
732
|
+
error: message,
|
|
1807
733
|
});
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
// Filter by specific skills if provided
|
|
1839
|
-
if (skills && skills.length > 0) {
|
|
1840
|
-
skillsToFill = skillsToFill.filter((s) => skills.includes(s.slug));
|
|
1841
|
-
}
|
|
1842
|
-
// Filter out already-filled skills unless force is set
|
|
1843
|
-
if (!force) {
|
|
1844
|
-
skillsToFill = skillsToFill.filter((s) => {
|
|
1845
|
-
// Check if skill file exists and has minimal content (likely a template)
|
|
1846
|
-
if (!fs.existsSync(s.path))
|
|
1847
|
-
return true;
|
|
1848
|
-
const content = fs.readFileSync(s.path, 'utf-8');
|
|
1849
|
-
// Consider it unfilled if it's a template (has placeholder markers)
|
|
1850
|
-
return content.includes('<!-- TODO') || content.includes('[PLACEHOLDER]') || content.length < 500;
|
|
1851
|
-
});
|
|
1852
|
-
}
|
|
1853
|
-
if (skillsToFill.length === 0) {
|
|
1854
|
-
return {
|
|
1855
|
-
content: [{
|
|
1856
|
-
type: 'text',
|
|
1857
|
-
text: JSON.stringify({
|
|
1858
|
-
success: true,
|
|
1859
|
-
message: 'No skills need filling. Use force=true to refill existing skills.',
|
|
1860
|
-
skillsDir,
|
|
1861
|
-
}, null, 2)
|
|
1862
|
-
}]
|
|
1863
|
-
};
|
|
1864
|
-
}
|
|
1865
|
-
// Build semantic context
|
|
1866
|
-
let semanticContext;
|
|
1867
|
-
try {
|
|
1868
|
-
semanticContext = await (0, tools_1.getOrBuildContext)(repoPath);
|
|
1869
|
-
}
|
|
1870
|
-
catch (contextError) {
|
|
1871
|
-
// Continue without semantic context
|
|
1872
|
-
semanticContext = undefined;
|
|
1873
|
-
}
|
|
1874
|
-
// Build fill instructions for each skill
|
|
1875
|
-
const fillInstructions = skillsToFill.map((skill) => ({
|
|
1876
|
-
skillPath: skill.path,
|
|
1877
|
-
skillSlug: skill.slug,
|
|
1878
|
-
skillName: skill.metadata.name || skill.slug,
|
|
1879
|
-
description: skill.metadata.description || '',
|
|
1880
|
-
isBuiltIn: skill.isBuiltIn,
|
|
1881
|
-
instructions: getSkillFillInstructions(skill.slug),
|
|
1882
|
-
}));
|
|
1883
|
-
// Build comprehensive fill prompt
|
|
1884
|
-
const fillPrompt = buildSkillFillPrompt(fillInstructions, semanticContext);
|
|
1885
|
-
return {
|
|
1886
|
-
content: [{
|
|
1887
|
-
type: 'text',
|
|
1888
|
-
text: JSON.stringify({
|
|
1889
|
-
success: true,
|
|
1890
|
-
skillsToFill: fillInstructions,
|
|
1891
|
-
semanticContext,
|
|
1892
|
-
fillPrompt,
|
|
1893
|
-
instructions: 'IMPORTANT: You MUST now fill each skill file using the semantic context and fill instructions provided. Write the content to each skillPath.',
|
|
1894
|
-
}, null, 2)
|
|
1895
|
-
}]
|
|
1896
|
-
};
|
|
1897
|
-
}
|
|
1898
|
-
catch (error) {
|
|
1899
|
-
return {
|
|
1900
|
-
content: [{
|
|
1901
|
-
type: 'text',
|
|
1902
|
-
text: JSON.stringify({
|
|
1903
|
-
success: false,
|
|
1904
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1905
|
-
}, null, 2)
|
|
1906
|
-
}]
|
|
1907
|
-
};
|
|
734
|
+
}
|
|
735
|
+
parseResponsePayload(response) {
|
|
736
|
+
const text = response.content?.[0]?.text;
|
|
737
|
+
if (!text)
|
|
738
|
+
return null;
|
|
739
|
+
try {
|
|
740
|
+
const parsed = JSON.parse(text);
|
|
741
|
+
return parsed && typeof parsed === 'object' ? parsed : null;
|
|
742
|
+
}
|
|
743
|
+
catch {
|
|
744
|
+
return null;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
buildResultSummary(payload) {
|
|
748
|
+
const summaryKeys = [
|
|
749
|
+
'success',
|
|
750
|
+
'message',
|
|
751
|
+
'currentPhase',
|
|
752
|
+
'nextPhase',
|
|
753
|
+
'phase',
|
|
754
|
+
'scale',
|
|
755
|
+
'planSlug',
|
|
756
|
+
'count',
|
|
757
|
+
'total',
|
|
758
|
+
'status',
|
|
759
|
+
];
|
|
760
|
+
const summary = {};
|
|
761
|
+
for (const key of summaryKeys) {
|
|
762
|
+
if (key in payload) {
|
|
763
|
+
summary[key] = payload[key];
|
|
1908
764
|
}
|
|
1909
|
-
}
|
|
1910
|
-
|
|
765
|
+
}
|
|
766
|
+
return Object.keys(summary).length > 0 ? summary : null;
|
|
1911
767
|
}
|
|
1912
768
|
/**
|
|
1913
769
|
* Start the MCP server with stdio transport
|
|
@@ -1935,115 +791,6 @@ The AI agent MUST then fill each skill file using the provided context and instr
|
|
|
1935
791
|
}
|
|
1936
792
|
}
|
|
1937
793
|
exports.AIContextMCPServer = AIContextMCPServer;
|
|
1938
|
-
/**
|
|
1939
|
-
* Get fill instructions for a skill based on its type
|
|
1940
|
-
*/
|
|
1941
|
-
function getSkillFillInstructions(skillSlug) {
|
|
1942
|
-
const instructions = {
|
|
1943
|
-
'commit-message': `Fill this skill with:
|
|
1944
|
-
- Commit message format conventions for this project
|
|
1945
|
-
- Examples of good commit messages from the codebase
|
|
1946
|
-
- Branch naming conventions if applicable
|
|
1947
|
-
- Semantic versioning guidelines`,
|
|
1948
|
-
'pr-review': `Fill this skill with:
|
|
1949
|
-
- PR review checklist specific to this codebase
|
|
1950
|
-
- Code quality standards to check
|
|
1951
|
-
- Testing requirements before merge
|
|
1952
|
-
- Documentation expectations`,
|
|
1953
|
-
'code-review': `Fill this skill with:
|
|
1954
|
-
- Code review guidelines for this project
|
|
1955
|
-
- Common patterns to look for
|
|
1956
|
-
- Security and performance considerations
|
|
1957
|
-
- Style and convention checks`,
|
|
1958
|
-
'test-generation': `Fill this skill with:
|
|
1959
|
-
- Testing framework and conventions used
|
|
1960
|
-
- Test file organization patterns
|
|
1961
|
-
- Mocking strategies for this codebase
|
|
1962
|
-
- Coverage requirements`,
|
|
1963
|
-
'documentation': `Fill this skill with:
|
|
1964
|
-
- Documentation standards for this project
|
|
1965
|
-
- JSDoc/TSDoc conventions
|
|
1966
|
-
- README structure expectations
|
|
1967
|
-
- API documentation guidelines`,
|
|
1968
|
-
'refactoring': `Fill this skill with:
|
|
1969
|
-
- Refactoring patterns common in this codebase
|
|
1970
|
-
- Code smell detection guidelines
|
|
1971
|
-
- Safe refactoring procedures
|
|
1972
|
-
- Testing requirements after refactoring`,
|
|
1973
|
-
'bug-investigation': `Fill this skill with:
|
|
1974
|
-
- Debugging workflow for this codebase
|
|
1975
|
-
- Common bug patterns and their fixes
|
|
1976
|
-
- Logging and error handling conventions
|
|
1977
|
-
- Test verification steps`,
|
|
1978
|
-
'feature-breakdown': `Fill this skill with:
|
|
1979
|
-
- Feature decomposition approach
|
|
1980
|
-
- Task estimation guidelines
|
|
1981
|
-
- Dependency identification process
|
|
1982
|
-
- Integration points to consider`,
|
|
1983
|
-
'api-design': `Fill this skill with:
|
|
1984
|
-
- API design patterns used in this project
|
|
1985
|
-
- Endpoint naming conventions
|
|
1986
|
-
- Request/response format standards
|
|
1987
|
-
- Versioning and deprecation policies`,
|
|
1988
|
-
'security-audit': `Fill this skill with:
|
|
1989
|
-
- Security checklist for this codebase
|
|
1990
|
-
- Common vulnerabilities to check
|
|
1991
|
-
- Authentication/authorization patterns
|
|
1992
|
-
- Data validation requirements`,
|
|
1993
|
-
};
|
|
1994
|
-
return instructions[skillSlug] || `Fill this skill with project-specific content for ${skillSlug}:
|
|
1995
|
-
- Identify relevant patterns from the codebase
|
|
1996
|
-
- Include specific examples from the project
|
|
1997
|
-
- Add conventions and best practices
|
|
1998
|
-
- Reference important files and components`;
|
|
1999
|
-
}
|
|
2000
|
-
/**
|
|
2001
|
-
* Build comprehensive fill prompt for skills
|
|
2002
|
-
*/
|
|
2003
|
-
function buildSkillFillPrompt(skills, semanticContext) {
|
|
2004
|
-
const lines = [];
|
|
2005
|
-
lines.push('# Skill Fill Instructions');
|
|
2006
|
-
lines.push('');
|
|
2007
|
-
lines.push('You MUST fill each of the following skill files with codebase-specific content.');
|
|
2008
|
-
lines.push('');
|
|
2009
|
-
if (semanticContext) {
|
|
2010
|
-
lines.push('## Codebase Context');
|
|
2011
|
-
lines.push('');
|
|
2012
|
-
lines.push('Use this semantic context to understand the codebase:');
|
|
2013
|
-
lines.push('');
|
|
2014
|
-
lines.push('```');
|
|
2015
|
-
lines.push(semanticContext.length > 6000 ? semanticContext.substring(0, 6000) + '\n...(truncated)' : semanticContext);
|
|
2016
|
-
lines.push('```');
|
|
2017
|
-
lines.push('');
|
|
2018
|
-
}
|
|
2019
|
-
lines.push('## Skills to Fill');
|
|
2020
|
-
lines.push('');
|
|
2021
|
-
for (const skill of skills) {
|
|
2022
|
-
lines.push(`### ${skill.skillName} (${skill.skillSlug})`);
|
|
2023
|
-
lines.push(`**Path:** \`${skill.skillPath}\``);
|
|
2024
|
-
if (skill.description) {
|
|
2025
|
-
lines.push(`**Description:** ${skill.description}`);
|
|
2026
|
-
}
|
|
2027
|
-
lines.push('');
|
|
2028
|
-
lines.push('**Fill Instructions:**');
|
|
2029
|
-
lines.push(skill.instructions);
|
|
2030
|
-
lines.push('');
|
|
2031
|
-
}
|
|
2032
|
-
lines.push('## Action Required');
|
|
2033
|
-
lines.push('');
|
|
2034
|
-
lines.push('For each skill listed above:');
|
|
2035
|
-
lines.push('1. Read the current skill template');
|
|
2036
|
-
lines.push('2. Generate codebase-specific content based on the instructions and context');
|
|
2037
|
-
lines.push('3. Write the filled content to the skill file');
|
|
2038
|
-
lines.push('');
|
|
2039
|
-
lines.push('Each skill should be personalized with:');
|
|
2040
|
-
lines.push('- Specific examples from this codebase');
|
|
2041
|
-
lines.push('- Project-specific conventions and patterns');
|
|
2042
|
-
lines.push('- References to relevant files and components');
|
|
2043
|
-
lines.push('');
|
|
2044
|
-
lines.push('DO NOT leave placeholder text. Each skill must have meaningful, project-specific content.');
|
|
2045
|
-
return lines.join('\n');
|
|
2046
|
-
}
|
|
2047
794
|
/**
|
|
2048
795
|
* Create and start an MCP server
|
|
2049
796
|
*/
|