@ai-coders/context 0.5.2 → 0.6.1
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 +247 -12
- package/dist/generators/agents/agentGenerator.d.ts +3 -0
- package/dist/generators/agents/agentGenerator.d.ts.map +1 -1
- package/dist/generators/agents/agentGenerator.js +13 -7
- package/dist/generators/agents/agentGenerator.js.map +1 -1
- package/dist/generators/agents/templates/playbookTemplate.d.ts.map +1 -1
- package/dist/generators/agents/templates/playbookTemplate.js +3 -1
- package/dist/generators/agents/templates/playbookTemplate.js.map +1 -1
- package/dist/generators/documentation/codebaseMapGenerator.d.ts +98 -0
- package/dist/generators/documentation/codebaseMapGenerator.d.ts.map +1 -0
- package/dist/generators/documentation/codebaseMapGenerator.js +247 -0
- package/dist/generators/documentation/codebaseMapGenerator.js.map +1 -0
- package/dist/generators/documentation/documentationGenerator.d.ts +2 -0
- package/dist/generators/documentation/documentationGenerator.d.ts.map +1 -1
- package/dist/generators/documentation/documentationGenerator.js +20 -1
- package/dist/generators/documentation/documentationGenerator.js.map +1 -1
- package/dist/generators/documentation/index.d.ts +2 -0
- package/dist/generators/documentation/index.d.ts.map +1 -1
- package/dist/generators/documentation/index.js +3 -1
- package/dist/generators/documentation/index.js.map +1 -1
- package/dist/generators/documentation/templates/architectureTemplate.d.ts.map +1 -1
- package/dist/generators/documentation/templates/architectureTemplate.js +2 -31
- package/dist/generators/documentation/templates/architectureTemplate.js.map +1 -1
- package/dist/generators/documentation/templates/common.d.ts +4 -1
- package/dist/generators/documentation/templates/common.d.ts.map +1 -1
- package/dist/generators/documentation/templates/common.js +4 -2
- package/dist/generators/documentation/templates/common.js.map +1 -1
- package/dist/generators/plans/templates/planTemplate.d.ts.map +1 -1
- package/dist/generators/plans/templates/planTemplate.js +46 -2
- package/dist/generators/plans/templates/planTemplate.js.map +1 -1
- package/dist/generators/skills/index.d.ts +7 -0
- package/dist/generators/skills/index.d.ts.map +1 -0
- package/dist/generators/skills/index.js +15 -0
- package/dist/generators/skills/index.js.map +1 -0
- package/dist/generators/skills/skillGenerator.d.ts +53 -0
- package/dist/generators/skills/skillGenerator.d.ts.map +1 -0
- package/dist/generators/skills/skillGenerator.js +149 -0
- package/dist/generators/skills/skillGenerator.js.map +1 -0
- package/dist/generators/skills/templates/indexTemplate.d.ts +13 -0
- package/dist/generators/skills/templates/indexTemplate.d.ts.map +1 -0
- package/dist/generators/skills/templates/indexTemplate.js +102 -0
- package/dist/generators/skills/templates/indexTemplate.js.map +1 -0
- package/dist/generators/skills/templates/skillTemplate.d.ts +20 -0
- package/dist/generators/skills/templates/skillTemplate.d.ts.map +1 -0
- package/dist/generators/skills/templates/skillTemplate.js +85 -0
- package/dist/generators/skills/templates/skillTemplate.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1315 -43
- package/dist/index.js.map +1 -1
- package/dist/services/ai/agentEvents.d.ts +1 -1
- package/dist/services/ai/agentEvents.d.ts.map +1 -1
- package/dist/services/ai/agents/index.d.ts +2 -0
- package/dist/services/ai/agents/index.d.ts.map +1 -1
- package/dist/services/ai/agents/index.js +3 -1
- package/dist/services/ai/agents/index.js.map +1 -1
- package/dist/services/ai/agents/skillAgent.d.ts +49 -0
- package/dist/services/ai/agents/skillAgent.d.ts.map +1 -0
- package/dist/services/ai/agents/skillAgent.js +179 -0
- package/dist/services/ai/agents/skillAgent.js.map +1 -0
- package/dist/services/ai/prompts/index.d.ts +1 -1
- package/dist/services/ai/prompts/index.d.ts.map +1 -1
- package/dist/services/ai/prompts/index.js +2 -1
- package/dist/services/ai/prompts/index.js.map +1 -1
- package/dist/services/ai/prompts/sharedPrompts.d.ts +4 -0
- package/dist/services/ai/prompts/sharedPrompts.d.ts.map +1 -1
- package/dist/services/ai/prompts/sharedPrompts.js +33 -0
- package/dist/services/ai/prompts/sharedPrompts.js.map +1 -1
- package/dist/services/ai/schemas.d.ts +98 -1
- package/dist/services/ai/schemas.d.ts.map +1 -1
- package/dist/services/ai/schemas.js +61 -3
- 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 +17 -0
- package/dist/services/ai/toolRegistry.js.map +1 -1
- package/dist/services/ai/tools/fillScaffoldingTool.d.ts +21 -4
- package/dist/services/ai/tools/fillScaffoldingTool.d.ts.map +1 -1
- package/dist/services/ai/tools/fillScaffoldingTool.js +17 -0
- package/dist/services/ai/tools/fillScaffoldingTool.js.map +1 -1
- package/dist/services/ai/tools/getCodebaseMapTool.d.ts +17 -0
- package/dist/services/ai/tools/getCodebaseMapTool.d.ts.map +1 -0
- package/dist/services/ai/tools/getCodebaseMapTool.js +115 -0
- package/dist/services/ai/tools/getCodebaseMapTool.js.map +1 -0
- package/dist/services/ai/tools/index.d.ts +3 -2
- package/dist/services/ai/tools/index.d.ts.map +1 -1
- package/dist/services/ai/tools/index.js +12 -3
- package/dist/services/ai/tools/index.js.map +1 -1
- package/dist/services/ai/tools/initializeContextTool.d.ts +22 -4
- package/dist/services/ai/tools/initializeContextTool.d.ts.map +1 -1
- package/dist/services/ai/tools/initializeContextTool.js +201 -16
- package/dist/services/ai/tools/initializeContextTool.js.map +1 -1
- package/dist/services/ai/tools/scaffoldPlanTool.d.ts +11 -0
- package/dist/services/ai/tools/scaffoldPlanTool.d.ts.map +1 -1
- package/dist/services/ai/tools/scaffoldPlanTool.js +79 -7
- package/dist/services/ai/tools/scaffoldPlanTool.js.map +1 -1
- package/dist/services/export/exportRulesService.d.ts +62 -0
- package/dist/services/export/exportRulesService.d.ts.map +1 -0
- package/dist/services/export/exportRulesService.js +242 -0
- package/dist/services/export/exportRulesService.js.map +1 -0
- package/dist/services/export/index.d.ts +5 -0
- package/dist/services/export/index.d.ts.map +1 -0
- package/dist/services/export/index.js +10 -0
- package/dist/services/export/index.js.map +1 -0
- package/dist/services/export/skillExportService.d.ts +64 -0
- package/dist/services/export/skillExportService.d.ts.map +1 -0
- package/dist/services/export/skillExportService.js +238 -0
- package/dist/services/export/skillExportService.js.map +1 -0
- package/dist/services/fill/skillFillService.d.ts +50 -0
- package/dist/services/fill/skillFillService.d.ts.map +1 -0
- package/dist/services/fill/skillFillService.js +254 -0
- package/dist/services/fill/skillFillService.js.map +1 -0
- package/dist/services/import/agentsDetector.d.ts +12 -0
- package/dist/services/import/agentsDetector.d.ts.map +1 -0
- package/dist/services/import/agentsDetector.js +183 -0
- package/dist/services/import/agentsDetector.js.map +1 -0
- package/dist/services/import/importAgentsService.d.ts +14 -0
- package/dist/services/import/importAgentsService.d.ts.map +1 -0
- package/dist/services/import/importAgentsService.js +195 -0
- package/dist/services/import/importAgentsService.js.map +1 -0
- package/dist/services/import/importRulesService.d.ts +17 -0
- package/dist/services/import/importRulesService.d.ts.map +1 -0
- package/dist/services/import/importRulesService.js +222 -0
- package/dist/services/import/importRulesService.js.map +1 -0
- package/dist/services/import/index.d.ts +7 -0
- package/dist/services/import/index.d.ts.map +1 -0
- package/dist/services/import/index.js +28 -0
- package/dist/services/import/index.js.map +1 -0
- package/dist/services/import/presets.d.ts +8 -0
- package/dist/services/import/presets.d.ts.map +1 -0
- package/dist/services/import/presets.js +176 -0
- package/dist/services/import/presets.js.map +1 -0
- package/dist/services/import/rulesDetector.d.ts +16 -0
- package/dist/services/import/rulesDetector.d.ts.map +1 -0
- package/dist/services/import/rulesDetector.js +278 -0
- package/dist/services/import/rulesDetector.js.map +1 -0
- package/dist/services/import/types.d.ts +72 -0
- package/dist/services/import/types.d.ts.map +1 -0
- package/dist/services/import/types.js +3 -0
- package/dist/services/import/types.js.map +1 -0
- package/dist/services/mcp/mcpServer.d.ts +24 -0
- package/dist/services/mcp/mcpServer.d.ts.map +1 -1
- package/dist/services/mcp/mcpServer.js +1651 -7
- package/dist/services/mcp/mcpServer.js.map +1 -1
- package/dist/services/quickSync/index.d.ts +3 -0
- package/dist/services/quickSync/index.d.ts.map +1 -0
- package/dist/services/quickSync/index.js +7 -0
- package/dist/services/quickSync/index.js.map +1 -0
- package/dist/services/quickSync/quickSyncService.d.ts +72 -0
- package/dist/services/quickSync/quickSyncService.d.ts.map +1 -0
- package/dist/services/quickSync/quickSyncService.js +268 -0
- package/dist/services/quickSync/quickSyncService.js.map +1 -0
- package/dist/services/report/index.d.ts +3 -0
- package/dist/services/report/index.d.ts.map +1 -0
- package/dist/services/report/index.js +6 -0
- package/dist/services/report/index.js.map +1 -0
- package/dist/services/report/reportService.d.ts +131 -0
- package/dist/services/report/reportService.d.ts.map +1 -0
- package/dist/services/report/reportService.js +372 -0
- package/dist/services/report/reportService.js.map +1 -0
- package/dist/services/semantic/contextBuilder.d.ts +8 -1
- package/dist/services/semantic/contextBuilder.d.ts.map +1 -1
- package/dist/services/semantic/contextBuilder.js +107 -20
- package/dist/services/semantic/contextBuilder.js.map +1 -1
- package/dist/services/shared/globPatterns.d.ts +48 -0
- package/dist/services/shared/globPatterns.d.ts.map +1 -0
- package/dist/services/shared/globPatterns.js +110 -0
- package/dist/services/shared/globPatterns.js.map +1 -0
- package/dist/services/shared/index.d.ts +10 -0
- package/dist/services/shared/index.d.ts.map +1 -0
- package/dist/services/shared/index.js +46 -0
- package/dist/services/shared/index.js.map +1 -0
- package/dist/services/shared/pathHelpers.d.ts +71 -0
- package/dist/services/shared/pathHelpers.d.ts.map +1 -0
- package/dist/services/shared/pathHelpers.js +162 -0
- package/dist/services/shared/pathHelpers.js.map +1 -0
- package/dist/services/shared/types.d.ts +74 -0
- package/dist/services/shared/types.d.ts.map +1 -0
- package/dist/services/shared/types.js +44 -0
- package/dist/services/shared/types.js.map +1 -0
- package/dist/services/shared/uiHelpers.d.ts +70 -0
- package/dist/services/shared/uiHelpers.d.ts.map +1 -0
- package/dist/services/shared/uiHelpers.js +131 -0
- package/dist/services/shared/uiHelpers.js.map +1 -0
- package/dist/services/stack/index.d.ts +6 -0
- package/dist/services/stack/index.d.ts.map +1 -0
- package/dist/services/stack/index.js +25 -0
- package/dist/services/stack/index.js.map +1 -0
- package/dist/services/stack/projectTypeClassifier.d.ts +59 -0
- package/dist/services/stack/projectTypeClassifier.d.ts.map +1 -0
- package/dist/services/stack/projectTypeClassifier.js +242 -0
- package/dist/services/stack/projectTypeClassifier.js.map +1 -0
- package/dist/services/stack/scaffoldFilter.d.ts +75 -0
- package/dist/services/stack/scaffoldFilter.d.ts.map +1 -0
- package/dist/services/stack/scaffoldFilter.js +222 -0
- package/dist/services/stack/scaffoldFilter.js.map +1 -0
- package/dist/services/stack/stackDetector.d.ts +43 -0
- package/dist/services/stack/stackDetector.d.ts.map +1 -0
- package/dist/services/stack/stackDetector.js +406 -0
- package/dist/services/stack/stackDetector.js.map +1 -0
- package/dist/services/start/index.d.ts +3 -0
- package/dist/services/start/index.d.ts.map +1 -0
- package/dist/services/start/index.js +6 -0
- package/dist/services/start/index.js.map +1 -0
- package/dist/services/start/startService.d.ts +64 -0
- package/dist/services/start/startService.d.ts.map +1 -0
- package/dist/services/start/startService.js +180 -0
- package/dist/services/start/startService.js.map +1 -0
- package/dist/services/sync/presets.d.ts.map +1 -1
- package/dist/services/sync/presets.js +16 -1
- package/dist/services/sync/presets.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/workflow/autoAdvance.d.ts +38 -0
- package/dist/services/workflow/autoAdvance.d.ts.map +1 -0
- package/dist/services/workflow/autoAdvance.js +219 -0
- package/dist/services/workflow/autoAdvance.js.map +1 -0
- package/dist/services/workflow/index.d.ts +6 -0
- package/dist/services/workflow/index.d.ts.map +1 -0
- package/dist/services/workflow/index.js +11 -0
- package/dist/services/workflow/index.js.map +1 -0
- package/dist/services/workflow/workflowService.d.ts +98 -0
- package/dist/services/workflow/workflowService.d.ts.map +1 -0
- package/dist/services/workflow/workflowService.js +210 -0
- package/dist/services/workflow/workflowService.js.map +1 -0
- package/dist/utils/cliUI.d.ts +4 -0
- package/dist/utils/cliUI.d.ts.map +1 -1
- package/dist/utils/cliUI.js +31 -1
- package/dist/utils/cliUI.js.map +1 -1
- package/dist/utils/i18n.d.ts +202 -0
- package/dist/utils/i18n.d.ts.map +1 -1
- package/dist/utils/i18n.js +438 -2
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/theme.d.ts +1 -0
- package/dist/utils/theme.d.ts.map +1 -1
- package/dist/utils/theme.js +1 -0
- package/dist/utils/theme.js.map +1 -1
- package/dist/workflow/agents/agentRegistry.d.ts +82 -0
- package/dist/workflow/agents/agentRegistry.d.ts.map +1 -0
- package/dist/workflow/agents/agentRegistry.js +205 -0
- package/dist/workflow/agents/agentRegistry.js.map +1 -0
- package/dist/workflow/agents/index.d.ts +7 -0
- package/dist/workflow/agents/index.d.ts.map +1 -0
- package/dist/workflow/agents/index.js +14 -0
- package/dist/workflow/agents/index.js.map +1 -0
- package/dist/workflow/collaboration.d.ts +110 -0
- package/dist/workflow/collaboration.d.ts.map +1 -0
- package/dist/workflow/collaboration.js +301 -0
- package/dist/workflow/collaboration.js.map +1 -0
- package/dist/workflow/index.d.ts +25 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +124 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/orchestration/agentOrchestrator.d.ts +68 -0
- package/dist/workflow/orchestration/agentOrchestrator.d.ts.map +1 -0
- package/dist/workflow/orchestration/agentOrchestrator.js +280 -0
- package/dist/workflow/orchestration/agentOrchestrator.js.map +1 -0
- package/dist/workflow/orchestration/documentLinker.d.ts +100 -0
- package/dist/workflow/orchestration/documentLinker.d.ts.map +1 -0
- package/dist/workflow/orchestration/documentLinker.js +266 -0
- package/dist/workflow/orchestration/documentLinker.js.map +1 -0
- package/dist/workflow/orchestration/index.d.ts +9 -0
- package/dist/workflow/orchestration/index.d.ts.map +1 -0
- package/dist/workflow/orchestration/index.js +25 -0
- package/dist/workflow/orchestration/index.js.map +1 -0
- package/dist/workflow/orchestrator.d.ts +99 -0
- package/dist/workflow/orchestrator.d.ts.map +1 -0
- package/dist/workflow/orchestrator.js +217 -0
- package/dist/workflow/orchestrator.js.map +1 -0
- package/dist/workflow/phases.d.ts +64 -0
- package/dist/workflow/phases.d.ts.map +1 -0
- package/dist/workflow/phases.js +151 -0
- package/dist/workflow/phases.js.map +1 -0
- package/dist/workflow/plans/index.d.ts +8 -0
- package/dist/workflow/plans/index.d.ts.map +1 -0
- package/dist/workflow/plans/index.js +27 -0
- package/dist/workflow/plans/index.js.map +1 -0
- package/dist/workflow/plans/planLinker.d.ts +119 -0
- package/dist/workflow/plans/planLinker.d.ts.map +1 -0
- package/dist/workflow/plans/planLinker.js +499 -0
- package/dist/workflow/plans/planLinker.js.map +1 -0
- package/dist/workflow/plans/types.d.ts +167 -0
- package/dist/workflow/plans/types.d.ts.map +1 -0
- package/dist/workflow/plans/types.js +25 -0
- package/dist/workflow/plans/types.js.map +1 -0
- package/dist/workflow/prevcConfig.d.ts +27 -0
- package/dist/workflow/prevcConfig.d.ts.map +1 -0
- package/dist/workflow/prevcConfig.js +153 -0
- package/dist/workflow/prevcConfig.js.map +1 -0
- package/dist/workflow/roles.d.ts +44 -0
- package/dist/workflow/roles.d.ts.map +1 -0
- package/dist/workflow/roles.js +112 -0
- package/dist/workflow/roles.js.map +1 -0
- package/dist/workflow/scaling.d.ts +44 -0
- package/dist/workflow/scaling.d.ts.map +1 -0
- package/dist/workflow/scaling.js +224 -0
- package/dist/workflow/scaling.js.map +1 -0
- package/dist/workflow/skills/frontmatter.d.ts +23 -0
- package/dist/workflow/skills/frontmatter.d.ts.map +1 -0
- package/dist/workflow/skills/frontmatter.js +100 -0
- package/dist/workflow/skills/frontmatter.js.map +1 -0
- package/dist/workflow/skills/index.d.ts +10 -0
- package/dist/workflow/skills/index.d.ts.map +1 -0
- package/dist/workflow/skills/index.js +22 -0
- package/dist/workflow/skills/index.js.map +1 -0
- package/dist/workflow/skills/skillRegistry.d.ts +60 -0
- package/dist/workflow/skills/skillRegistry.d.ts.map +1 -0
- package/dist/workflow/skills/skillRegistry.js +257 -0
- package/dist/workflow/skills/skillRegistry.js.map +1 -0
- package/dist/workflow/skills/skillTemplates.d.ts +16 -0
- package/dist/workflow/skills/skillTemplates.d.ts.map +1 -0
- package/dist/workflow/skills/skillTemplates.js +610 -0
- package/dist/workflow/skills/skillTemplates.js.map +1 -0
- package/dist/workflow/skills/types.d.ts +72 -0
- package/dist/workflow/skills/types.d.ts.map +1 -0
- package/dist/workflow/skills/types.js +48 -0
- package/dist/workflow/skills/types.js.map +1 -0
- package/dist/workflow/status/statusManager.d.ts +84 -0
- package/dist/workflow/status/statusManager.d.ts.map +1 -0
- package/dist/workflow/status/statusManager.js +402 -0
- package/dist/workflow/status/statusManager.js.map +1 -0
- package/dist/workflow/status/templates.d.ts +40 -0
- package/dist/workflow/status/templates.d.ts.map +1 -0
- package/dist/workflow/status/templates.js +148 -0
- package/dist/workflow/status/templates.js.map +1 -0
- package/dist/workflow/types.d.ts +178 -0
- package/dist/workflow/types.d.ts.map +1 -0
- package/dist/workflow/types.js +25 -0
- package/dist/workflow/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -4,16 +4,59 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Exposes code analysis tools and semantic context as MCP resources.
|
|
6
6
|
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
7
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
41
|
exports.AIContextMCPServer = void 0;
|
|
9
42
|
exports.startMCPServer = startMCPServer;
|
|
10
43
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
11
44
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
12
45
|
const zod_1 = require("zod");
|
|
46
|
+
const path = __importStar(require("path"));
|
|
13
47
|
const tools_1 = require("../ai/tools");
|
|
14
48
|
const toolRegistry_1 = require("../ai/toolRegistry");
|
|
15
49
|
const contextBuilder_1 = require("../semantic/contextBuilder");
|
|
16
50
|
const version_1 = require("../../version");
|
|
51
|
+
const providerFactory_1 = require("../ai/providerFactory");
|
|
52
|
+
const workflow_1 = require("../workflow");
|
|
53
|
+
// Default model for MCP tools that require LLM
|
|
54
|
+
const DEFAULT_MODEL = providerFactory_1.DEFAULT_MODELS.google || 'gemini-3-flash-preview';
|
|
55
|
+
const start_1 = require("../start");
|
|
56
|
+
const report_1 = require("../report");
|
|
57
|
+
const export_1 = require("../export");
|
|
58
|
+
const stack_1 = require("../stack");
|
|
59
|
+
const workflow_2 = require("../../workflow");
|
|
17
60
|
class AIContextMCPServer {
|
|
18
61
|
constructor(options = {}) {
|
|
19
62
|
this.transport = null;
|
|
@@ -203,16 +246,19 @@ class AIContextMCPServer {
|
|
|
203
246
|
semantic: zod_1.z.boolean().default(true).optional()
|
|
204
247
|
.describe('Enable semantic analysis for richer templates'),
|
|
205
248
|
include: zod_1.z.array(zod_1.z.string()).optional().describe('Include patterns'),
|
|
206
|
-
exclude: zod_1.z.array(zod_1.z.string()).optional().describe('Exclude 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)')
|
|
207
252
|
}
|
|
208
|
-
}, async ({ repoPath, type, outputDir, semantic, include, exclude }) => {
|
|
253
|
+
}, async ({ repoPath, type, outputDir, semantic, include, exclude, autoFill }) => {
|
|
209
254
|
const result = await tools_1.initializeContextTool.execute({
|
|
210
255
|
repoPath: repoPath || this.options.repoPath || process.cwd(),
|
|
211
256
|
type,
|
|
212
257
|
outputDir,
|
|
213
258
|
semantic,
|
|
214
259
|
include,
|
|
215
|
-
exclude
|
|
260
|
+
exclude,
|
|
261
|
+
autoFill
|
|
216
262
|
}, { toolCallId: '', messages: [] });
|
|
217
263
|
return {
|
|
218
264
|
content: [{
|
|
@@ -230,16 +276,19 @@ class AIContextMCPServer {
|
|
|
230
276
|
outputDir: zod_1.z.string().optional().describe('Output directory'),
|
|
231
277
|
title: zod_1.z.string().optional().describe('Plan title (defaults to formatted planName)'),
|
|
232
278
|
summary: zod_1.z.string().optional().describe('Plan summary/goal'),
|
|
233
|
-
semantic: zod_1.z.boolean().default(true).optional().describe('Enable semantic analysis')
|
|
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)')
|
|
234
282
|
}
|
|
235
|
-
}, async ({ planName, repoPath, outputDir, title, summary, semantic }) => {
|
|
283
|
+
}, async ({ planName, repoPath, outputDir, title, summary, semantic, autoFill }) => {
|
|
236
284
|
const result = await tools_1.scaffoldPlanTool.execute({
|
|
237
285
|
planName,
|
|
238
286
|
repoPath: repoPath || this.options.repoPath || process.cwd(),
|
|
239
287
|
outputDir,
|
|
240
288
|
title,
|
|
241
289
|
summary,
|
|
242
|
-
semantic
|
|
290
|
+
semantic,
|
|
291
|
+
autoFill
|
|
243
292
|
}, { toolCallId: '', messages: [] });
|
|
244
293
|
return {
|
|
245
294
|
content: [{
|
|
@@ -315,7 +364,888 @@ class AIContextMCPServer {
|
|
|
315
364
|
}]
|
|
316
365
|
};
|
|
317
366
|
});
|
|
318
|
-
|
|
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
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
// getAgentInfo - Get detailed info about a specific agent
|
|
1217
|
+
this.server.registerTool('getAgentInfo', {
|
|
1218
|
+
description: 'Get detailed information about a specific agent (built-in or custom). Returns path, existence status, title, and description.',
|
|
1219
|
+
inputSchema: {
|
|
1220
|
+
agentType: zod_1.z.string().describe('Agent type/identifier (e.g., "code-reviewer" or "agente-de-marketing")'),
|
|
1221
|
+
}
|
|
1222
|
+
}, async ({ agentType }) => {
|
|
1223
|
+
try {
|
|
1224
|
+
const linker = (0, workflow_2.createPlanLinker)(repoPath);
|
|
1225
|
+
const info = await linker.getAgentInfo(agentType);
|
|
1226
|
+
return {
|
|
1227
|
+
content: [{
|
|
1228
|
+
type: 'text',
|
|
1229
|
+
text: JSON.stringify({
|
|
1230
|
+
success: true,
|
|
1231
|
+
agent: info,
|
|
1232
|
+
}, null, 2)
|
|
1233
|
+
}]
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
catch (error) {
|
|
1237
|
+
return {
|
|
1238
|
+
content: [{
|
|
1239
|
+
type: 'text',
|
|
1240
|
+
text: JSON.stringify({
|
|
1241
|
+
success: false,
|
|
1242
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1243
|
+
}, null, 2)
|
|
1244
|
+
}]
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
this.log('Registered 8 plan-workflow tools');
|
|
319
1249
|
}
|
|
320
1250
|
/**
|
|
321
1251
|
* Register semantic context resources
|
|
@@ -373,6 +1303,611 @@ class AIContextMCPServer {
|
|
|
373
1303
|
};
|
|
374
1304
|
});
|
|
375
1305
|
this.log('Registered 2 resource templates');
|
|
1306
|
+
// Register PREVC workflow resources
|
|
1307
|
+
this.registerWorkflowResources();
|
|
1308
|
+
// Register orchestration tools
|
|
1309
|
+
this.registerOrchestrationTools();
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Register PREVC workflow resources
|
|
1313
|
+
*/
|
|
1314
|
+
registerWorkflowResources() {
|
|
1315
|
+
const repoPath = this.options.repoPath || process.cwd();
|
|
1316
|
+
// workflow://status - Current workflow status
|
|
1317
|
+
this.server.registerResource('workflow-status', 'workflow://status', {
|
|
1318
|
+
description: 'Current PREVC workflow status including phases, roles, and progress',
|
|
1319
|
+
mimeType: 'application/json'
|
|
1320
|
+
}, async () => {
|
|
1321
|
+
try {
|
|
1322
|
+
const service = new workflow_1.WorkflowService(repoPath);
|
|
1323
|
+
if (!(await service.hasWorkflow())) {
|
|
1324
|
+
return {
|
|
1325
|
+
contents: [{
|
|
1326
|
+
uri: 'workflow://status',
|
|
1327
|
+
mimeType: 'application/json',
|
|
1328
|
+
text: JSON.stringify({ error: 'No workflow found' }, null, 2)
|
|
1329
|
+
}]
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
const summary = await service.getSummary();
|
|
1333
|
+
const status = await service.getStatus();
|
|
1334
|
+
return {
|
|
1335
|
+
contents: [{
|
|
1336
|
+
uri: 'workflow://status',
|
|
1337
|
+
mimeType: 'application/json',
|
|
1338
|
+
text: JSON.stringify({
|
|
1339
|
+
name: summary.name,
|
|
1340
|
+
scale: (0, workflow_2.getScaleName)(summary.scale),
|
|
1341
|
+
currentPhase: summary.currentPhase,
|
|
1342
|
+
progress: summary.progress,
|
|
1343
|
+
isComplete: summary.isComplete,
|
|
1344
|
+
phases: status.phases,
|
|
1345
|
+
roles: status.roles,
|
|
1346
|
+
}, null, 2)
|
|
1347
|
+
}]
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
catch (error) {
|
|
1351
|
+
return {
|
|
1352
|
+
contents: [{
|
|
1353
|
+
uri: 'workflow://status',
|
|
1354
|
+
mimeType: 'application/json',
|
|
1355
|
+
text: JSON.stringify({
|
|
1356
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1357
|
+
}, null, 2)
|
|
1358
|
+
}]
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
this.log('Registered 1 workflow resource');
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Register agent orchestration tools
|
|
1366
|
+
*/
|
|
1367
|
+
registerOrchestrationTools() {
|
|
1368
|
+
// orchestrateAgents - Select agents for a task, phase, or role
|
|
1369
|
+
this.server.registerTool('orchestrateAgents', {
|
|
1370
|
+
description: 'Select appropriate agents based on task description, PREVC phase, or role. Returns recommended agents with their descriptions and relevant documentation.',
|
|
1371
|
+
inputSchema: {
|
|
1372
|
+
task: zod_1.z.string().optional().describe('Task description for intelligent agent selection'),
|
|
1373
|
+
phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).optional().describe('PREVC phase to get agents for'),
|
|
1374
|
+
role: zod_1.z.enum(workflow_2.PREVC_ROLES).optional().describe('PREVC role to get agents for'),
|
|
1375
|
+
},
|
|
1376
|
+
}, async ({ task, phase, role }) => {
|
|
1377
|
+
try {
|
|
1378
|
+
let agents = [];
|
|
1379
|
+
let source = '';
|
|
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();
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Register skill tools for on-demand expertise
|
|
1573
|
+
*/
|
|
1574
|
+
registerSkillTools() {
|
|
1575
|
+
const repoPath = this.options.repoPath || process.cwd();
|
|
1576
|
+
// Import skill registry
|
|
1577
|
+
const { createSkillRegistry, BUILT_IN_SKILLS, SKILL_TO_PHASES } = require('../../workflow/skills');
|
|
1578
|
+
// listSkills - List all available skills
|
|
1579
|
+
this.server.registerTool('listSkills', {
|
|
1580
|
+
description: 'List all available skills (built-in + custom). Skills are on-demand expertise for specific tasks.',
|
|
1581
|
+
inputSchema: {
|
|
1582
|
+
includeContent: zod_1.z.boolean().optional().describe('Include full skill content in response'),
|
|
1583
|
+
}
|
|
1584
|
+
}, async ({ includeContent }) => {
|
|
1585
|
+
try {
|
|
1586
|
+
const registry = createSkillRegistry(repoPath);
|
|
1587
|
+
const discovered = await registry.discoverAll();
|
|
1588
|
+
const format = (skill) => ({
|
|
1589
|
+
slug: skill.slug,
|
|
1590
|
+
name: skill.metadata.name,
|
|
1591
|
+
description: skill.metadata.description,
|
|
1592
|
+
phases: skill.metadata.phases || [],
|
|
1593
|
+
isBuiltIn: skill.isBuiltIn,
|
|
1594
|
+
...(includeContent ? { content: skill.content } : {}),
|
|
1595
|
+
});
|
|
1596
|
+
return {
|
|
1597
|
+
content: [{
|
|
1598
|
+
type: 'text',
|
|
1599
|
+
text: JSON.stringify({
|
|
1600
|
+
success: true,
|
|
1601
|
+
totalSkills: discovered.all.length,
|
|
1602
|
+
builtInCount: discovered.builtIn.length,
|
|
1603
|
+
customCount: discovered.custom.length,
|
|
1604
|
+
skills: {
|
|
1605
|
+
builtIn: discovered.builtIn.map(format),
|
|
1606
|
+
custom: discovered.custom.map(format),
|
|
1607
|
+
},
|
|
1608
|
+
}, null, 2)
|
|
1609
|
+
}]
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
catch (error) {
|
|
1613
|
+
return {
|
|
1614
|
+
content: [{
|
|
1615
|
+
type: 'text',
|
|
1616
|
+
text: JSON.stringify({
|
|
1617
|
+
success: false,
|
|
1618
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1619
|
+
}, null, 2)
|
|
1620
|
+
}]
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
// getSkillContent - Get full content of a specific skill
|
|
1625
|
+
this.server.registerTool('getSkillContent', {
|
|
1626
|
+
description: 'Get the full content of a skill by slug. Returns the SKILL.md content with instructions.',
|
|
1627
|
+
inputSchema: {
|
|
1628
|
+
skillSlug: zod_1.z.string().describe('Skill slug/identifier (e.g., "commit-message", "pr-review")'),
|
|
1629
|
+
}
|
|
1630
|
+
}, async ({ skillSlug }) => {
|
|
1631
|
+
try {
|
|
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 }) => {
|
|
1724
|
+
try {
|
|
1725
|
+
const { createSkillGenerator } = require('../../generators/skills');
|
|
1726
|
+
const generator = createSkillGenerator({ repoPath });
|
|
1727
|
+
const result = await generator.generate({ skills, force });
|
|
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
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
catch (error) {
|
|
1742
|
+
return {
|
|
1743
|
+
content: [{
|
|
1744
|
+
type: 'text',
|
|
1745
|
+
text: JSON.stringify({
|
|
1746
|
+
success: false,
|
|
1747
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1748
|
+
}, null, 2)
|
|
1749
|
+
}]
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
});
|
|
1753
|
+
// exportSkills - Export skills to AI tool directories
|
|
1754
|
+
this.server.registerTool('exportSkills', {
|
|
1755
|
+
description: 'Export skills to AI tool directories (Claude Code, Gemini CLI, Codex). Copies skills to .claude/skills/, .gemini/skills/, etc.',
|
|
1756
|
+
inputSchema: {
|
|
1757
|
+
preset: zod_1.z.enum(['claude', 'gemini', 'codex', 'all']).default('all')
|
|
1758
|
+
.describe('Target AI tool or "all" for all supported tools'),
|
|
1759
|
+
includeBuiltIn: zod_1.z.boolean().optional().describe('Include built-in skills even if not scaffolded'),
|
|
1760
|
+
force: zod_1.z.boolean().optional().describe('Overwrite existing files'),
|
|
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
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
// fillSkills - Return fill instructions for skill files (NO API key required)
|
|
1809
|
+
this.server.registerTool('fillSkills', {
|
|
1810
|
+
description: `Fill/personalize skill files with codebase-aware content.
|
|
1811
|
+
Returns semantic context and fill instructions for the AI agent to process.
|
|
1812
|
+
The AI agent MUST then fill each skill file using the provided context and instructions.`,
|
|
1813
|
+
inputSchema: {
|
|
1814
|
+
skills: zod_1.z.array(zod_1.z.string()).optional().describe('Specific skills to fill (default: all scaffolded)'),
|
|
1815
|
+
force: zod_1.z.boolean().optional().describe('Include already-filled skills'),
|
|
1816
|
+
}
|
|
1817
|
+
}, async ({ skills, force }) => {
|
|
1818
|
+
try {
|
|
1819
|
+
const fs = require('fs-extra');
|
|
1820
|
+
const registry = createSkillRegistry(repoPath);
|
|
1821
|
+
const skillsDir = path.join(repoPath, '.context', 'skills');
|
|
1822
|
+
// Check if skills directory exists
|
|
1823
|
+
if (!await fs.pathExists(skillsDir)) {
|
|
1824
|
+
return {
|
|
1825
|
+
content: [{
|
|
1826
|
+
type: 'text',
|
|
1827
|
+
text: JSON.stringify({
|
|
1828
|
+
success: false,
|
|
1829
|
+
error: 'Skills directory does not exist. Run scaffoldSkills first.',
|
|
1830
|
+
skillsDir,
|
|
1831
|
+
}, null, 2)
|
|
1832
|
+
}]
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
// Discover skills to fill
|
|
1836
|
+
const discovered = await registry.discoverAll();
|
|
1837
|
+
let skillsToFill = discovered.all;
|
|
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
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
this.log('Registered 6 skill tools');
|
|
376
1911
|
}
|
|
377
1912
|
/**
|
|
378
1913
|
* Start the MCP server with stdio transport
|
|
@@ -400,6 +1935,115 @@ class AIContextMCPServer {
|
|
|
400
1935
|
}
|
|
401
1936
|
}
|
|
402
1937
|
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
|
+
}
|
|
403
2047
|
/**
|
|
404
2048
|
* Create and start an MCP server
|
|
405
2049
|
*/
|