@ai-coders/context 0.5.2 → 0.6.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.
Files changed (325) hide show
  1. package/README.md +244 -12
  2. package/dist/generators/agents/agentGenerator.d.ts +3 -0
  3. package/dist/generators/agents/agentGenerator.d.ts.map +1 -1
  4. package/dist/generators/agents/agentGenerator.js +13 -7
  5. package/dist/generators/agents/agentGenerator.js.map +1 -1
  6. package/dist/generators/agents/templates/playbookTemplate.d.ts.map +1 -1
  7. package/dist/generators/agents/templates/playbookTemplate.js +3 -1
  8. package/dist/generators/agents/templates/playbookTemplate.js.map +1 -1
  9. package/dist/generators/documentation/codebaseMapGenerator.d.ts +98 -0
  10. package/dist/generators/documentation/codebaseMapGenerator.d.ts.map +1 -0
  11. package/dist/generators/documentation/codebaseMapGenerator.js +247 -0
  12. package/dist/generators/documentation/codebaseMapGenerator.js.map +1 -0
  13. package/dist/generators/documentation/documentationGenerator.d.ts +2 -0
  14. package/dist/generators/documentation/documentationGenerator.d.ts.map +1 -1
  15. package/dist/generators/documentation/documentationGenerator.js +20 -1
  16. package/dist/generators/documentation/documentationGenerator.js.map +1 -1
  17. package/dist/generators/documentation/index.d.ts +2 -0
  18. package/dist/generators/documentation/index.d.ts.map +1 -1
  19. package/dist/generators/documentation/index.js +3 -1
  20. package/dist/generators/documentation/index.js.map +1 -1
  21. package/dist/generators/documentation/templates/architectureTemplate.d.ts.map +1 -1
  22. package/dist/generators/documentation/templates/architectureTemplate.js +2 -31
  23. package/dist/generators/documentation/templates/architectureTemplate.js.map +1 -1
  24. package/dist/generators/documentation/templates/common.d.ts +4 -1
  25. package/dist/generators/documentation/templates/common.d.ts.map +1 -1
  26. package/dist/generators/documentation/templates/common.js +4 -2
  27. package/dist/generators/documentation/templates/common.js.map +1 -1
  28. package/dist/generators/plans/templates/planTemplate.d.ts.map +1 -1
  29. package/dist/generators/plans/templates/planTemplate.js +46 -2
  30. package/dist/generators/plans/templates/planTemplate.js.map +1 -1
  31. package/dist/generators/skills/index.d.ts +7 -0
  32. package/dist/generators/skills/index.d.ts.map +1 -0
  33. package/dist/generators/skills/index.js +15 -0
  34. package/dist/generators/skills/index.js.map +1 -0
  35. package/dist/generators/skills/skillGenerator.d.ts +53 -0
  36. package/dist/generators/skills/skillGenerator.d.ts.map +1 -0
  37. package/dist/generators/skills/skillGenerator.js +149 -0
  38. package/dist/generators/skills/skillGenerator.js.map +1 -0
  39. package/dist/generators/skills/templates/indexTemplate.d.ts +13 -0
  40. package/dist/generators/skills/templates/indexTemplate.d.ts.map +1 -0
  41. package/dist/generators/skills/templates/indexTemplate.js +102 -0
  42. package/dist/generators/skills/templates/indexTemplate.js.map +1 -0
  43. package/dist/generators/skills/templates/skillTemplate.d.ts +20 -0
  44. package/dist/generators/skills/templates/skillTemplate.d.ts.map +1 -0
  45. package/dist/generators/skills/templates/skillTemplate.js +85 -0
  46. package/dist/generators/skills/templates/skillTemplate.js.map +1 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +1315 -43
  49. package/dist/index.js.map +1 -1
  50. package/dist/services/ai/agentEvents.d.ts +1 -1
  51. package/dist/services/ai/agentEvents.d.ts.map +1 -1
  52. package/dist/services/ai/agents/index.d.ts +2 -0
  53. package/dist/services/ai/agents/index.d.ts.map +1 -1
  54. package/dist/services/ai/agents/index.js +3 -1
  55. package/dist/services/ai/agents/index.js.map +1 -1
  56. package/dist/services/ai/agents/skillAgent.d.ts +49 -0
  57. package/dist/services/ai/agents/skillAgent.d.ts.map +1 -0
  58. package/dist/services/ai/agents/skillAgent.js +179 -0
  59. package/dist/services/ai/agents/skillAgent.js.map +1 -0
  60. package/dist/services/ai/prompts/index.d.ts +1 -1
  61. package/dist/services/ai/prompts/index.d.ts.map +1 -1
  62. package/dist/services/ai/prompts/index.js +2 -1
  63. package/dist/services/ai/prompts/index.js.map +1 -1
  64. package/dist/services/ai/prompts/sharedPrompts.d.ts +4 -0
  65. package/dist/services/ai/prompts/sharedPrompts.d.ts.map +1 -1
  66. package/dist/services/ai/prompts/sharedPrompts.js +33 -0
  67. package/dist/services/ai/prompts/sharedPrompts.js.map +1 -1
  68. package/dist/services/ai/schemas.d.ts +96 -1
  69. package/dist/services/ai/schemas.d.ts.map +1 -1
  70. package/dist/services/ai/schemas.js +56 -2
  71. package/dist/services/ai/schemas.js.map +1 -1
  72. package/dist/services/ai/toolRegistry.d.ts.map +1 -1
  73. package/dist/services/ai/toolRegistry.js +17 -0
  74. package/dist/services/ai/toolRegistry.js.map +1 -1
  75. package/dist/services/ai/tools/fillScaffoldingTool.d.ts +4 -4
  76. package/dist/services/ai/tools/getCodebaseMapTool.d.ts +17 -0
  77. package/dist/services/ai/tools/getCodebaseMapTool.d.ts.map +1 -0
  78. package/dist/services/ai/tools/getCodebaseMapTool.js +115 -0
  79. package/dist/services/ai/tools/getCodebaseMapTool.js.map +1 -0
  80. package/dist/services/ai/tools/index.d.ts +2 -1
  81. package/dist/services/ai/tools/index.d.ts.map +1 -1
  82. package/dist/services/ai/tools/index.js +8 -3
  83. package/dist/services/ai/tools/index.js.map +1 -1
  84. package/dist/services/ai/tools/initializeContextTool.d.ts +9 -1
  85. package/dist/services/ai/tools/initializeContextTool.d.ts.map +1 -1
  86. package/dist/services/ai/tools/initializeContextTool.js +33 -3
  87. package/dist/services/ai/tools/initializeContextTool.js.map +1 -1
  88. package/dist/services/ai/tools/scaffoldPlanTool.d.ts +6 -0
  89. package/dist/services/ai/tools/scaffoldPlanTool.d.ts.map +1 -1
  90. package/dist/services/ai/tools/scaffoldPlanTool.js +16 -3
  91. package/dist/services/ai/tools/scaffoldPlanTool.js.map +1 -1
  92. package/dist/services/export/exportRulesService.d.ts +62 -0
  93. package/dist/services/export/exportRulesService.d.ts.map +1 -0
  94. package/dist/services/export/exportRulesService.js +242 -0
  95. package/dist/services/export/exportRulesService.js.map +1 -0
  96. package/dist/services/export/index.d.ts +5 -0
  97. package/dist/services/export/index.d.ts.map +1 -0
  98. package/dist/services/export/index.js +10 -0
  99. package/dist/services/export/index.js.map +1 -0
  100. package/dist/services/export/skillExportService.d.ts +64 -0
  101. package/dist/services/export/skillExportService.d.ts.map +1 -0
  102. package/dist/services/export/skillExportService.js +238 -0
  103. package/dist/services/export/skillExportService.js.map +1 -0
  104. package/dist/services/fill/skillFillService.d.ts +50 -0
  105. package/dist/services/fill/skillFillService.d.ts.map +1 -0
  106. package/dist/services/fill/skillFillService.js +254 -0
  107. package/dist/services/fill/skillFillService.js.map +1 -0
  108. package/dist/services/import/agentsDetector.d.ts +12 -0
  109. package/dist/services/import/agentsDetector.d.ts.map +1 -0
  110. package/dist/services/import/agentsDetector.js +183 -0
  111. package/dist/services/import/agentsDetector.js.map +1 -0
  112. package/dist/services/import/importAgentsService.d.ts +14 -0
  113. package/dist/services/import/importAgentsService.d.ts.map +1 -0
  114. package/dist/services/import/importAgentsService.js +195 -0
  115. package/dist/services/import/importAgentsService.js.map +1 -0
  116. package/dist/services/import/importRulesService.d.ts +17 -0
  117. package/dist/services/import/importRulesService.d.ts.map +1 -0
  118. package/dist/services/import/importRulesService.js +222 -0
  119. package/dist/services/import/importRulesService.js.map +1 -0
  120. package/dist/services/import/index.d.ts +7 -0
  121. package/dist/services/import/index.d.ts.map +1 -0
  122. package/dist/services/import/index.js +28 -0
  123. package/dist/services/import/index.js.map +1 -0
  124. package/dist/services/import/presets.d.ts +8 -0
  125. package/dist/services/import/presets.d.ts.map +1 -0
  126. package/dist/services/import/presets.js +176 -0
  127. package/dist/services/import/presets.js.map +1 -0
  128. package/dist/services/import/rulesDetector.d.ts +16 -0
  129. package/dist/services/import/rulesDetector.d.ts.map +1 -0
  130. package/dist/services/import/rulesDetector.js +278 -0
  131. package/dist/services/import/rulesDetector.js.map +1 -0
  132. package/dist/services/import/types.d.ts +72 -0
  133. package/dist/services/import/types.d.ts.map +1 -0
  134. package/dist/services/import/types.js +3 -0
  135. package/dist/services/import/types.js.map +1 -0
  136. package/dist/services/mcp/mcpServer.d.ts +24 -0
  137. package/dist/services/mcp/mcpServer.d.ts.map +1 -1
  138. package/dist/services/mcp/mcpServer.js +1451 -1
  139. package/dist/services/mcp/mcpServer.js.map +1 -1
  140. package/dist/services/quickSync/index.d.ts +3 -0
  141. package/dist/services/quickSync/index.d.ts.map +1 -0
  142. package/dist/services/quickSync/index.js +7 -0
  143. package/dist/services/quickSync/index.js.map +1 -0
  144. package/dist/services/quickSync/quickSyncService.d.ts +72 -0
  145. package/dist/services/quickSync/quickSyncService.d.ts.map +1 -0
  146. package/dist/services/quickSync/quickSyncService.js +268 -0
  147. package/dist/services/quickSync/quickSyncService.js.map +1 -0
  148. package/dist/services/report/index.d.ts +3 -0
  149. package/dist/services/report/index.d.ts.map +1 -0
  150. package/dist/services/report/index.js +6 -0
  151. package/dist/services/report/index.js.map +1 -0
  152. package/dist/services/report/reportService.d.ts +131 -0
  153. package/dist/services/report/reportService.d.ts.map +1 -0
  154. package/dist/services/report/reportService.js +372 -0
  155. package/dist/services/report/reportService.js.map +1 -0
  156. package/dist/services/semantic/contextBuilder.d.ts +8 -1
  157. package/dist/services/semantic/contextBuilder.d.ts.map +1 -1
  158. package/dist/services/semantic/contextBuilder.js +107 -20
  159. package/dist/services/semantic/contextBuilder.js.map +1 -1
  160. package/dist/services/shared/globPatterns.d.ts +48 -0
  161. package/dist/services/shared/globPatterns.d.ts.map +1 -0
  162. package/dist/services/shared/globPatterns.js +110 -0
  163. package/dist/services/shared/globPatterns.js.map +1 -0
  164. package/dist/services/shared/index.d.ts +10 -0
  165. package/dist/services/shared/index.d.ts.map +1 -0
  166. package/dist/services/shared/index.js +46 -0
  167. package/dist/services/shared/index.js.map +1 -0
  168. package/dist/services/shared/pathHelpers.d.ts +71 -0
  169. package/dist/services/shared/pathHelpers.d.ts.map +1 -0
  170. package/dist/services/shared/pathHelpers.js +162 -0
  171. package/dist/services/shared/pathHelpers.js.map +1 -0
  172. package/dist/services/shared/types.d.ts +74 -0
  173. package/dist/services/shared/types.d.ts.map +1 -0
  174. package/dist/services/shared/types.js +44 -0
  175. package/dist/services/shared/types.js.map +1 -0
  176. package/dist/services/shared/uiHelpers.d.ts +70 -0
  177. package/dist/services/shared/uiHelpers.d.ts.map +1 -0
  178. package/dist/services/shared/uiHelpers.js +131 -0
  179. package/dist/services/shared/uiHelpers.js.map +1 -0
  180. package/dist/services/stack/index.d.ts +6 -0
  181. package/dist/services/stack/index.d.ts.map +1 -0
  182. package/dist/services/stack/index.js +25 -0
  183. package/dist/services/stack/index.js.map +1 -0
  184. package/dist/services/stack/projectTypeClassifier.d.ts +59 -0
  185. package/dist/services/stack/projectTypeClassifier.d.ts.map +1 -0
  186. package/dist/services/stack/projectTypeClassifier.js +242 -0
  187. package/dist/services/stack/projectTypeClassifier.js.map +1 -0
  188. package/dist/services/stack/scaffoldFilter.d.ts +75 -0
  189. package/dist/services/stack/scaffoldFilter.d.ts.map +1 -0
  190. package/dist/services/stack/scaffoldFilter.js +222 -0
  191. package/dist/services/stack/scaffoldFilter.js.map +1 -0
  192. package/dist/services/stack/stackDetector.d.ts +43 -0
  193. package/dist/services/stack/stackDetector.d.ts.map +1 -0
  194. package/dist/services/stack/stackDetector.js +406 -0
  195. package/dist/services/stack/stackDetector.js.map +1 -0
  196. package/dist/services/start/index.d.ts +3 -0
  197. package/dist/services/start/index.d.ts.map +1 -0
  198. package/dist/services/start/index.js +6 -0
  199. package/dist/services/start/index.js.map +1 -0
  200. package/dist/services/start/startService.d.ts +64 -0
  201. package/dist/services/start/startService.d.ts.map +1 -0
  202. package/dist/services/start/startService.js +180 -0
  203. package/dist/services/start/startService.js.map +1 -0
  204. package/dist/services/sync/presets.d.ts.map +1 -1
  205. package/dist/services/sync/presets.js +16 -1
  206. package/dist/services/sync/presets.js.map +1 -1
  207. package/dist/services/sync/types.d.ts +1 -1
  208. package/dist/services/sync/types.d.ts.map +1 -1
  209. package/dist/services/workflow/autoAdvance.d.ts +38 -0
  210. package/dist/services/workflow/autoAdvance.d.ts.map +1 -0
  211. package/dist/services/workflow/autoAdvance.js +219 -0
  212. package/dist/services/workflow/autoAdvance.js.map +1 -0
  213. package/dist/services/workflow/index.d.ts +6 -0
  214. package/dist/services/workflow/index.d.ts.map +1 -0
  215. package/dist/services/workflow/index.js +11 -0
  216. package/dist/services/workflow/index.js.map +1 -0
  217. package/dist/services/workflow/workflowService.d.ts +98 -0
  218. package/dist/services/workflow/workflowService.d.ts.map +1 -0
  219. package/dist/services/workflow/workflowService.js +210 -0
  220. package/dist/services/workflow/workflowService.js.map +1 -0
  221. package/dist/utils/cliUI.d.ts +4 -0
  222. package/dist/utils/cliUI.d.ts.map +1 -1
  223. package/dist/utils/cliUI.js +31 -1
  224. package/dist/utils/cliUI.js.map +1 -1
  225. package/dist/utils/i18n.d.ts +202 -0
  226. package/dist/utils/i18n.d.ts.map +1 -1
  227. package/dist/utils/i18n.js +438 -2
  228. package/dist/utils/i18n.js.map +1 -1
  229. package/dist/utils/theme.d.ts +1 -0
  230. package/dist/utils/theme.d.ts.map +1 -1
  231. package/dist/utils/theme.js +1 -0
  232. package/dist/utils/theme.js.map +1 -1
  233. package/dist/workflow/agents/agentRegistry.d.ts +82 -0
  234. package/dist/workflow/agents/agentRegistry.d.ts.map +1 -0
  235. package/dist/workflow/agents/agentRegistry.js +205 -0
  236. package/dist/workflow/agents/agentRegistry.js.map +1 -0
  237. package/dist/workflow/agents/index.d.ts +7 -0
  238. package/dist/workflow/agents/index.d.ts.map +1 -0
  239. package/dist/workflow/agents/index.js +14 -0
  240. package/dist/workflow/agents/index.js.map +1 -0
  241. package/dist/workflow/collaboration.d.ts +110 -0
  242. package/dist/workflow/collaboration.d.ts.map +1 -0
  243. package/dist/workflow/collaboration.js +301 -0
  244. package/dist/workflow/collaboration.js.map +1 -0
  245. package/dist/workflow/index.d.ts +25 -0
  246. package/dist/workflow/index.d.ts.map +1 -0
  247. package/dist/workflow/index.js +124 -0
  248. package/dist/workflow/index.js.map +1 -0
  249. package/dist/workflow/orchestration/agentOrchestrator.d.ts +68 -0
  250. package/dist/workflow/orchestration/agentOrchestrator.d.ts.map +1 -0
  251. package/dist/workflow/orchestration/agentOrchestrator.js +280 -0
  252. package/dist/workflow/orchestration/agentOrchestrator.js.map +1 -0
  253. package/dist/workflow/orchestration/documentLinker.d.ts +100 -0
  254. package/dist/workflow/orchestration/documentLinker.d.ts.map +1 -0
  255. package/dist/workflow/orchestration/documentLinker.js +266 -0
  256. package/dist/workflow/orchestration/documentLinker.js.map +1 -0
  257. package/dist/workflow/orchestration/index.d.ts +9 -0
  258. package/dist/workflow/orchestration/index.d.ts.map +1 -0
  259. package/dist/workflow/orchestration/index.js +25 -0
  260. package/dist/workflow/orchestration/index.js.map +1 -0
  261. package/dist/workflow/orchestrator.d.ts +99 -0
  262. package/dist/workflow/orchestrator.d.ts.map +1 -0
  263. package/dist/workflow/orchestrator.js +217 -0
  264. package/dist/workflow/orchestrator.js.map +1 -0
  265. package/dist/workflow/phases.d.ts +64 -0
  266. package/dist/workflow/phases.d.ts.map +1 -0
  267. package/dist/workflow/phases.js +151 -0
  268. package/dist/workflow/phases.js.map +1 -0
  269. package/dist/workflow/plans/index.d.ts +8 -0
  270. package/dist/workflow/plans/index.d.ts.map +1 -0
  271. package/dist/workflow/plans/index.js +27 -0
  272. package/dist/workflow/plans/index.js.map +1 -0
  273. package/dist/workflow/plans/planLinker.d.ts +119 -0
  274. package/dist/workflow/plans/planLinker.d.ts.map +1 -0
  275. package/dist/workflow/plans/planLinker.js +499 -0
  276. package/dist/workflow/plans/planLinker.js.map +1 -0
  277. package/dist/workflow/plans/types.d.ts +167 -0
  278. package/dist/workflow/plans/types.d.ts.map +1 -0
  279. package/dist/workflow/plans/types.js +25 -0
  280. package/dist/workflow/plans/types.js.map +1 -0
  281. package/dist/workflow/prevcConfig.d.ts +27 -0
  282. package/dist/workflow/prevcConfig.d.ts.map +1 -0
  283. package/dist/workflow/prevcConfig.js +153 -0
  284. package/dist/workflow/prevcConfig.js.map +1 -0
  285. package/dist/workflow/roles.d.ts +44 -0
  286. package/dist/workflow/roles.d.ts.map +1 -0
  287. package/dist/workflow/roles.js +112 -0
  288. package/dist/workflow/roles.js.map +1 -0
  289. package/dist/workflow/scaling.d.ts +44 -0
  290. package/dist/workflow/scaling.d.ts.map +1 -0
  291. package/dist/workflow/scaling.js +224 -0
  292. package/dist/workflow/scaling.js.map +1 -0
  293. package/dist/workflow/skills/frontmatter.d.ts +23 -0
  294. package/dist/workflow/skills/frontmatter.d.ts.map +1 -0
  295. package/dist/workflow/skills/frontmatter.js +100 -0
  296. package/dist/workflow/skills/frontmatter.js.map +1 -0
  297. package/dist/workflow/skills/index.d.ts +10 -0
  298. package/dist/workflow/skills/index.d.ts.map +1 -0
  299. package/dist/workflow/skills/index.js +22 -0
  300. package/dist/workflow/skills/index.js.map +1 -0
  301. package/dist/workflow/skills/skillRegistry.d.ts +60 -0
  302. package/dist/workflow/skills/skillRegistry.d.ts.map +1 -0
  303. package/dist/workflow/skills/skillRegistry.js +257 -0
  304. package/dist/workflow/skills/skillRegistry.js.map +1 -0
  305. package/dist/workflow/skills/skillTemplates.d.ts +16 -0
  306. package/dist/workflow/skills/skillTemplates.d.ts.map +1 -0
  307. package/dist/workflow/skills/skillTemplates.js +610 -0
  308. package/dist/workflow/skills/skillTemplates.js.map +1 -0
  309. package/dist/workflow/skills/types.d.ts +72 -0
  310. package/dist/workflow/skills/types.d.ts.map +1 -0
  311. package/dist/workflow/skills/types.js +48 -0
  312. package/dist/workflow/skills/types.js.map +1 -0
  313. package/dist/workflow/status/statusManager.d.ts +84 -0
  314. package/dist/workflow/status/statusManager.d.ts.map +1 -0
  315. package/dist/workflow/status/statusManager.js +402 -0
  316. package/dist/workflow/status/statusManager.js.map +1 -0
  317. package/dist/workflow/status/templates.d.ts +40 -0
  318. package/dist/workflow/status/templates.d.ts.map +1 -0
  319. package/dist/workflow/status/templates.js +148 -0
  320. package/dist/workflow/status/templates.js.map +1 -0
  321. package/dist/workflow/types.d.ts +178 -0
  322. package/dist/workflow/types.d.ts.map +1 -0
  323. package/dist/workflow/types.js +25 -0
  324. package/dist/workflow/types.js.map +1 -0
  325. package/package.json +1 -1
@@ -14,6 +14,15 @@ const tools_1 = require("../ai/tools");
14
14
  const toolRegistry_1 = require("../ai/toolRegistry");
15
15
  const contextBuilder_1 = require("../semantic/contextBuilder");
16
16
  const version_1 = require("../../version");
17
+ const providerFactory_1 = require("../ai/providerFactory");
18
+ const workflow_1 = require("../workflow");
19
+ // Default model for MCP tools that require LLM
20
+ const DEFAULT_MODEL = providerFactory_1.DEFAULT_MODELS.google || 'gemini-3-flash-preview';
21
+ const start_1 = require("../start");
22
+ const report_1 = require("../report");
23
+ const export_1 = require("../export");
24
+ const stack_1 = require("../stack");
25
+ const workflow_2 = require("../../workflow");
17
26
  class AIContextMCPServer {
18
27
  constructor(options = {}) {
19
28
  this.transport = null;
@@ -315,7 +324,878 @@ class AIContextMCPServer {
315
324
  }]
316
325
  };
317
326
  });
318
- this.log('Registered 12 tools');
327
+ // getCodebaseMap tool - retrieve sections of the codebase map JSON
328
+ this.server.registerTool('getCodebaseMap', {
329
+ description: (0, toolRegistry_1.getToolDescription)('getCodebaseMap', true),
330
+ inputSchema: {
331
+ repoPath: zod_1.z.string().optional().describe('Repository path (defaults to cwd)'),
332
+ section: zod_1.z.enum([
333
+ 'all',
334
+ 'stack',
335
+ 'structure',
336
+ 'architecture',
337
+ 'symbols',
338
+ 'symbols.classes',
339
+ 'symbols.interfaces',
340
+ 'symbols.functions',
341
+ 'symbols.types',
342
+ 'symbols.enums',
343
+ 'publicAPI',
344
+ 'dependencies',
345
+ 'stats'
346
+ ]).default('all').optional()
347
+ .describe('Section of the codebase map to retrieve. Use specific sections to reduce token usage.')
348
+ }
349
+ }, async ({ repoPath, section }) => {
350
+ const result = await tools_1.getCodebaseMapTool.execute({
351
+ repoPath: repoPath || this.options.repoPath || process.cwd(),
352
+ section
353
+ }, { toolCallId: '', messages: [] });
354
+ return {
355
+ content: [{
356
+ type: 'text',
357
+ text: JSON.stringify(result, null, 2)
358
+ }]
359
+ };
360
+ });
361
+ this.log('Registered 13 tools');
362
+ // Register PREVC workflow tools
363
+ this.registerWorkflowTools();
364
+ }
365
+ /**
366
+ * Register PREVC workflow tools
367
+ */
368
+ registerWorkflowTools() {
369
+ const repoPath = this.options.repoPath || process.cwd();
370
+ // workflowInit - Initialize a PREVC workflow
371
+ this.server.registerTool('workflowInit', {
372
+ description: 'Initialize a PREVC workflow with automatic scale detection. PREVC = Planejamento, Revisão, Execução, Validação, Confirmação.',
373
+ inputSchema: {
374
+ name: zod_1.z.string().describe('Name of the project/feature'),
375
+ description: zod_1.z.string().optional().describe('Description for scale detection'),
376
+ scale: zod_1.z.enum(['QUICK', 'SMALL', 'MEDIUM', 'LARGE', 'ENTERPRISE']).optional()
377
+ .describe('Project scale (auto-detected if not provided)')
378
+ }
379
+ }, async ({ name, description, scale }) => {
380
+ try {
381
+ const service = new workflow_1.WorkflowService(repoPath);
382
+ const status = await service.init({
383
+ name,
384
+ description,
385
+ scale: scale,
386
+ });
387
+ return {
388
+ content: [{
389
+ type: 'text',
390
+ text: JSON.stringify({
391
+ success: true,
392
+ message: `Workflow initialized: ${name}`,
393
+ scale: (0, workflow_2.getScaleName)(status.project.scale),
394
+ currentPhase: status.project.current_phase,
395
+ phases: Object.keys(status.phases).filter((p) => status.phases[p].status !== 'skipped'),
396
+ }, null, 2)
397
+ }]
398
+ };
399
+ }
400
+ catch (error) {
401
+ return {
402
+ content: [{
403
+ type: 'text',
404
+ text: JSON.stringify({
405
+ success: false,
406
+ error: error instanceof Error ? error.message : String(error)
407
+ }, null, 2)
408
+ }]
409
+ };
410
+ }
411
+ });
412
+ // workflowStatus - Get current workflow status
413
+ this.server.registerTool('workflowStatus', {
414
+ description: 'Get the current status of the PREVC workflow including phases, roles, and progress.',
415
+ inputSchema: {}
416
+ }, async () => {
417
+ try {
418
+ const service = new workflow_1.WorkflowService(repoPath);
419
+ if (!(await service.hasWorkflow())) {
420
+ return {
421
+ content: [{
422
+ type: 'text',
423
+ text: JSON.stringify({
424
+ success: false,
425
+ error: 'No workflow found. Run workflowInit first.'
426
+ }, null, 2)
427
+ }]
428
+ };
429
+ }
430
+ const summary = await service.getSummary();
431
+ const status = await service.getStatus();
432
+ return {
433
+ content: [{
434
+ type: 'text',
435
+ text: JSON.stringify({
436
+ success: true,
437
+ name: summary.name,
438
+ scale: (0, workflow_2.getScaleName)(summary.scale),
439
+ currentPhase: {
440
+ code: summary.currentPhase,
441
+ name: workflow_2.PHASE_NAMES_EN[summary.currentPhase],
442
+ },
443
+ progress: summary.progress,
444
+ isComplete: summary.isComplete,
445
+ phases: status.phases,
446
+ roles: status.roles,
447
+ }, null, 2)
448
+ }]
449
+ };
450
+ }
451
+ catch (error) {
452
+ return {
453
+ content: [{
454
+ type: 'text',
455
+ text: JSON.stringify({
456
+ success: false,
457
+ error: error instanceof Error ? error.message : String(error)
458
+ }, null, 2)
459
+ }]
460
+ };
461
+ }
462
+ });
463
+ // workflowAdvance - Advance to the next phase
464
+ this.server.registerTool('workflowAdvance', {
465
+ description: 'Complete the current phase and advance to the next phase in the PREVC workflow.',
466
+ inputSchema: {
467
+ outputs: zod_1.z.array(zod_1.z.string()).optional()
468
+ .describe('List of artifact paths generated in the current phase')
469
+ }
470
+ }, async ({ outputs }) => {
471
+ try {
472
+ const service = new workflow_1.WorkflowService(repoPath);
473
+ if (!(await service.hasWorkflow())) {
474
+ return {
475
+ content: [{
476
+ type: 'text',
477
+ text: JSON.stringify({
478
+ success: false,
479
+ error: 'No workflow found. Run workflowInit first.'
480
+ }, null, 2)
481
+ }]
482
+ };
483
+ }
484
+ const nextPhase = await service.advance(outputs);
485
+ if (nextPhase) {
486
+ return {
487
+ content: [{
488
+ type: 'text',
489
+ text: JSON.stringify({
490
+ success: true,
491
+ message: `Advanced to ${workflow_2.PHASE_NAMES_EN[nextPhase]} phase`,
492
+ nextPhase: {
493
+ code: nextPhase,
494
+ name: workflow_2.PHASE_NAMES_EN[nextPhase],
495
+ }
496
+ }, null, 2)
497
+ }]
498
+ };
499
+ }
500
+ else {
501
+ return {
502
+ content: [{
503
+ type: 'text',
504
+ text: JSON.stringify({
505
+ success: true,
506
+ message: 'Workflow completed!',
507
+ isComplete: true
508
+ }, null, 2)
509
+ }]
510
+ };
511
+ }
512
+ }
513
+ catch (error) {
514
+ return {
515
+ content: [{
516
+ type: 'text',
517
+ text: JSON.stringify({
518
+ success: false,
519
+ error: error instanceof Error ? error.message : String(error)
520
+ }, null, 2)
521
+ }]
522
+ };
523
+ }
524
+ });
525
+ // workflowHandoff - Handoff between roles
526
+ this.server.registerTool('workflowHandoff', {
527
+ description: 'Perform a handoff from one role to another within the PREVC workflow.',
528
+ inputSchema: {
529
+ from: zod_1.z.enum(workflow_2.PREVC_ROLES)
530
+ .describe('Role handing off'),
531
+ to: zod_1.z.enum(workflow_2.PREVC_ROLES)
532
+ .describe('Role receiving handoff'),
533
+ artifacts: zod_1.z.array(zod_1.z.string()).describe('Artifacts being handed off')
534
+ }
535
+ }, async ({ from, to, artifacts }) => {
536
+ try {
537
+ const service = new workflow_1.WorkflowService(repoPath);
538
+ if (!(await service.hasWorkflow())) {
539
+ return {
540
+ content: [{
541
+ type: 'text',
542
+ text: JSON.stringify({
543
+ success: false,
544
+ error: 'No workflow found. Run workflowInit first.'
545
+ }, null, 2)
546
+ }]
547
+ };
548
+ }
549
+ await service.handoff(from, to, artifacts);
550
+ return {
551
+ content: [{
552
+ type: 'text',
553
+ text: JSON.stringify({
554
+ success: true,
555
+ message: `Handoff complete: ${workflow_2.ROLE_DISPLAY_NAMES[from]} → ${workflow_2.ROLE_DISPLAY_NAMES[to]}`,
556
+ from: { role: from, displayName: workflow_2.ROLE_DISPLAY_NAMES[from] },
557
+ to: { role: to, displayName: workflow_2.ROLE_DISPLAY_NAMES[to] },
558
+ artifacts
559
+ }, null, 2)
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
+ // workflowCollaborate - Start a collaboration session
576
+ this.server.registerTool('workflowCollaborate', {
577
+ description: 'Start a multi-role collaboration session for complex decisions or brainstorming.',
578
+ inputSchema: {
579
+ topic: zod_1.z.string().describe('Topic for the collaboration session'),
580
+ participants: zod_1.z.array(zod_1.z.enum(workflow_2.PREVC_ROLES))
581
+ .optional()
582
+ .describe('Roles to participate (auto-selected if not provided)')
583
+ }
584
+ }, async ({ topic, participants }) => {
585
+ try {
586
+ const service = new workflow_1.WorkflowService(repoPath);
587
+ const session = await service.startCollaboration(topic, participants);
588
+ const status = session.getStatus();
589
+ return {
590
+ content: [{
591
+ type: 'text',
592
+ text: JSON.stringify({
593
+ success: true,
594
+ message: `Collaboration session started: ${topic}`,
595
+ sessionId: status.id,
596
+ topic: status.topic,
597
+ participants: status.participants.map((p) => ({
598
+ role: p,
599
+ displayName: workflow_2.ROLE_DISPLAY_NAMES[p],
600
+ })),
601
+ }, null, 2)
602
+ }]
603
+ };
604
+ }
605
+ catch (error) {
606
+ return {
607
+ content: [{
608
+ type: 'text',
609
+ text: JSON.stringify({
610
+ success: false,
611
+ error: error instanceof Error ? error.message : String(error)
612
+ }, null, 2)
613
+ }]
614
+ };
615
+ }
616
+ });
617
+ // workflowCreateDoc - Create a document for the current phase
618
+ this.server.registerTool('workflowCreateDoc', {
619
+ description: 'Create a document template for the current phase of the PREVC workflow.',
620
+ inputSchema: {
621
+ type: zod_1.z.enum(['prd', 'tech-spec', 'architecture', 'adr', 'test-plan', 'changelog'])
622
+ .describe('Type of document to create'),
623
+ name: zod_1.z.string().describe('Name/title for the document')
624
+ }
625
+ }, async ({ type, name }) => {
626
+ try {
627
+ const service = new workflow_1.WorkflowService(repoPath);
628
+ if (!(await service.hasWorkflow())) {
629
+ return {
630
+ content: [{
631
+ type: 'text',
632
+ text: JSON.stringify({
633
+ success: false,
634
+ error: 'No workflow found. Run workflowInit first.'
635
+ }, null, 2)
636
+ }]
637
+ };
638
+ }
639
+ // For now, return the document path that should be created
640
+ const docPath = `.context/workflow/docs/${type}-${name.toLowerCase().replace(/\s+/g, '-')}.md`;
641
+ return {
642
+ content: [{
643
+ type: 'text',
644
+ text: JSON.stringify({
645
+ success: true,
646
+ message: `Document template ready: ${type}`,
647
+ documentType: type,
648
+ suggestedPath: docPath,
649
+ name,
650
+ }, null, 2)
651
+ }]
652
+ };
653
+ }
654
+ catch (error) {
655
+ return {
656
+ content: [{
657
+ type: 'text',
658
+ text: JSON.stringify({
659
+ success: false,
660
+ error: error instanceof Error ? error.message : String(error)
661
+ }, null, 2)
662
+ }]
663
+ };
664
+ }
665
+ });
666
+ this.log('Registered 6 workflow tools');
667
+ // Register extended workflow tools (start, report, export, stack detection)
668
+ this.registerExtendedWorkflowTools();
669
+ }
670
+ /**
671
+ * Register extended workflow tools (start, report, export, stack detection)
672
+ */
673
+ registerExtendedWorkflowTools() {
674
+ const repoPath = this.options.repoPath || process.cwd();
675
+ // projectStart - Unified start command
676
+ this.server.registerTool('projectStart', {
677
+ description: 'Start a new project with unified setup: scaffolding + context fill + workflow initialization. Supports workflow templates (hotfix, feature, mvp).',
678
+ inputSchema: {
679
+ featureName: zod_1.z.string().describe('Feature/project name'),
680
+ template: zod_1.z.enum(['hotfix', 'feature', 'mvp', 'auto']).optional()
681
+ .describe('Workflow template (hotfix=quick fix, feature=standard, mvp=complete)'),
682
+ skipFill: zod_1.z.boolean().optional().describe('Skip AI-assisted context filling'),
683
+ skipWorkflow: zod_1.z.boolean().optional().describe('Skip workflow initialization'),
684
+ }
685
+ }, async ({ featureName, template, skipFill, skipWorkflow }) => {
686
+ try {
687
+ const startService = new start_1.StartService({
688
+ ui: {
689
+ displayOutput: () => { },
690
+ displaySuccess: () => { },
691
+ displayError: () => { },
692
+ displayInfo: () => { },
693
+ displayWarning: () => { },
694
+ startSpinner: () => { },
695
+ stopSpinner: () => { },
696
+ updateSpinner: () => { },
697
+ prompt: async () => '',
698
+ confirm: async () => true,
699
+ },
700
+ t: (key) => key,
701
+ version: version_1.VERSION,
702
+ defaultModel: 'claude-3-5-sonnet-20241022',
703
+ });
704
+ const result = await startService.run(repoPath, {
705
+ featureName,
706
+ template: template,
707
+ skipFill,
708
+ skipWorkflow,
709
+ });
710
+ return {
711
+ content: [{
712
+ type: 'text',
713
+ text: JSON.stringify({
714
+ success: result.workflowStarted || result.initialized,
715
+ initialized: result.initialized,
716
+ filled: result.filled,
717
+ workflowStarted: result.workflowStarted,
718
+ scale: result.scale ? (0, workflow_2.getScaleName)(result.scale) : null,
719
+ featureName: result.featureName,
720
+ stack: result.stackDetected ? {
721
+ primaryLanguage: result.stackDetected.primaryLanguage,
722
+ frameworks: result.stackDetected.frameworks,
723
+ } : null,
724
+ }, null, 2)
725
+ }]
726
+ };
727
+ }
728
+ catch (error) {
729
+ return {
730
+ content: [{
731
+ type: 'text',
732
+ text: JSON.stringify({
733
+ success: false,
734
+ error: error instanceof Error ? error.message : String(error)
735
+ }, null, 2)
736
+ }]
737
+ };
738
+ }
739
+ });
740
+ // projectReport - Generate visual reports
741
+ this.server.registerTool('projectReport', {
742
+ description: 'Generate a visual progress report for the current PREVC workflow. Shows phases, roles, deliverables, and a visual dashboard.',
743
+ inputSchema: {
744
+ format: zod_1.z.enum(['json', 'markdown', 'dashboard']).default('dashboard').optional()
745
+ .describe('Output format: json (raw data), markdown (formatted), dashboard (visual)'),
746
+ includeStack: zod_1.z.boolean().optional().describe('Include technology stack info'),
747
+ }
748
+ }, async ({ format, includeStack }) => {
749
+ try {
750
+ const reportService = new report_1.ReportService({
751
+ ui: {
752
+ displayOutput: () => { },
753
+ displaySuccess: () => { },
754
+ displayError: () => { },
755
+ displayInfo: () => { },
756
+ displayWarning: () => { },
757
+ startSpinner: () => { },
758
+ stopSpinner: () => { },
759
+ updateSpinner: () => { },
760
+ },
761
+ t: (key) => key,
762
+ version: version_1.VERSION,
763
+ });
764
+ const report = await reportService.generate(repoPath, { includeStack });
765
+ let output;
766
+ if (format === 'json') {
767
+ output = JSON.stringify(report, null, 2);
768
+ }
769
+ else if (format === 'dashboard') {
770
+ output = reportService.generateVisualDashboard(report);
771
+ }
772
+ else {
773
+ // Markdown format - use visual dashboard as fallback
774
+ output = reportService.generateVisualDashboard(report);
775
+ }
776
+ return {
777
+ content: [{
778
+ type: 'text',
779
+ text: output
780
+ }]
781
+ };
782
+ }
783
+ catch (error) {
784
+ return {
785
+ content: [{
786
+ type: 'text',
787
+ text: JSON.stringify({
788
+ success: false,
789
+ error: error instanceof Error ? error.message : String(error)
790
+ }, null, 2)
791
+ }]
792
+ };
793
+ }
794
+ });
795
+ // exportRules - Export rules to AI tools
796
+ this.server.registerTool('exportRules', {
797
+ description: 'Export context rules to AI tool directories (Cursor, Claude, GitHub Copilot, Windsurf, Cline, Aider, Codex). Bidirectional rules sync.',
798
+ inputSchema: {
799
+ preset: zod_1.z.enum(['cursor', 'claude', 'github', 'windsurf', 'cline', 'aider', 'codex', 'all']).default('all')
800
+ .describe('Target AI tool preset or "all" for all supported tools'),
801
+ force: zod_1.z.boolean().optional().describe('Overwrite existing files'),
802
+ dryRun: zod_1.z.boolean().optional().describe('Preview changes without writing'),
803
+ }
804
+ }, async ({ preset, force, dryRun }) => {
805
+ try {
806
+ const exportService = new export_1.ExportRulesService({
807
+ ui: {
808
+ displayOutput: () => { },
809
+ displaySuccess: () => { },
810
+ displayError: () => { },
811
+ displayInfo: () => { },
812
+ displayWarning: () => { },
813
+ startSpinner: () => { },
814
+ stopSpinner: () => { },
815
+ updateSpinner: () => { },
816
+ },
817
+ t: (key) => key,
818
+ version: version_1.VERSION,
819
+ });
820
+ const result = await exportService.run(repoPath, { preset, force, dryRun });
821
+ return {
822
+ content: [{
823
+ type: 'text',
824
+ text: JSON.stringify({
825
+ success: true,
826
+ filesCreated: result.filesCreated,
827
+ filesSkipped: result.filesSkipped,
828
+ filesFailed: result.filesFailed,
829
+ targets: result.targets,
830
+ errors: result.errors,
831
+ dryRun: dryRun || false,
832
+ }, null, 2)
833
+ }]
834
+ };
835
+ }
836
+ catch (error) {
837
+ return {
838
+ content: [{
839
+ type: 'text',
840
+ text: JSON.stringify({
841
+ success: false,
842
+ error: error instanceof Error ? error.message : String(error)
843
+ }, null, 2)
844
+ }]
845
+ };
846
+ }
847
+ });
848
+ // detectStack - Detect project technology stack
849
+ this.server.registerTool('detectStack', {
850
+ description: 'Detect the project technology stack including languages, frameworks, build tools, and test frameworks. Useful for intelligent defaults.',
851
+ inputSchema: {}
852
+ }, async () => {
853
+ try {
854
+ const detector = new stack_1.StackDetector();
855
+ const stackInfo = await detector.detect(repoPath);
856
+ return {
857
+ content: [{
858
+ type: 'text',
859
+ text: JSON.stringify({
860
+ success: true,
861
+ stack: stackInfo,
862
+ }, null, 2)
863
+ }]
864
+ };
865
+ }
866
+ catch (error) {
867
+ return {
868
+ content: [{
869
+ type: 'text',
870
+ text: JSON.stringify({
871
+ success: false,
872
+ error: error instanceof Error ? error.message : String(error)
873
+ }, null, 2)
874
+ }]
875
+ };
876
+ }
877
+ });
878
+ this.log('Registered 4 extended workflow tools');
879
+ // Register plan-workflow integration tools
880
+ this.registerPlanTools();
881
+ }
882
+ /**
883
+ * Register plan-workflow integration tools
884
+ */
885
+ registerPlanTools() {
886
+ const repoPath = this.options.repoPath || process.cwd();
887
+ // linkPlan - Link a plan to the current workflow
888
+ this.server.registerTool('linkPlan', {
889
+ description: 'Link an implementation plan to the current PREVC workflow. Plans provide detailed steps mapped to workflow phases.',
890
+ inputSchema: {
891
+ planSlug: zod_1.z.string().describe('Plan slug/identifier (filename without .md)'),
892
+ }
893
+ }, async ({ planSlug }) => {
894
+ try {
895
+ const linker = (0, workflow_2.createPlanLinker)(repoPath);
896
+ const ref = await linker.linkPlan(planSlug);
897
+ if (!ref) {
898
+ return {
899
+ content: [{
900
+ type: 'text',
901
+ text: JSON.stringify({
902
+ success: false,
903
+ error: `Plan not found: ${planSlug}`,
904
+ }, null, 2)
905
+ }]
906
+ };
907
+ }
908
+ return {
909
+ content: [{
910
+ type: 'text',
911
+ text: JSON.stringify({
912
+ success: true,
913
+ plan: ref,
914
+ }, null, 2)
915
+ }]
916
+ };
917
+ }
918
+ catch (error) {
919
+ return {
920
+ content: [{
921
+ type: 'text',
922
+ text: JSON.stringify({
923
+ success: false,
924
+ error: error instanceof Error ? error.message : String(error)
925
+ }, null, 2)
926
+ }]
927
+ };
928
+ }
929
+ });
930
+ // getLinkedPlans - Get all plans linked to the workflow
931
+ this.server.registerTool('getLinkedPlans', {
932
+ description: 'Get all implementation plans linked to the current PREVC workflow.',
933
+ inputSchema: {}
934
+ }, async () => {
935
+ try {
936
+ const linker = (0, workflow_2.createPlanLinker)(repoPath);
937
+ const plans = await linker.getLinkedPlans();
938
+ return {
939
+ content: [{
940
+ type: 'text',
941
+ text: JSON.stringify({
942
+ success: true,
943
+ plans,
944
+ }, null, 2)
945
+ }]
946
+ };
947
+ }
948
+ catch (error) {
949
+ return {
950
+ content: [{
951
+ type: 'text',
952
+ text: JSON.stringify({
953
+ success: false,
954
+ error: error instanceof Error ? error.message : String(error)
955
+ }, null, 2)
956
+ }]
957
+ };
958
+ }
959
+ });
960
+ // getPlanDetails - Get detailed plan with PREVC mapping
961
+ this.server.registerTool('getPlanDetails', {
962
+ description: 'Get detailed plan information including phases mapped to PREVC, agents, and documentation.',
963
+ inputSchema: {
964
+ planSlug: zod_1.z.string().describe('Plan slug/identifier'),
965
+ }
966
+ }, async ({ planSlug }) => {
967
+ try {
968
+ const linker = (0, workflow_2.createPlanLinker)(repoPath);
969
+ const plan = await linker.getLinkedPlan(planSlug);
970
+ if (!plan) {
971
+ return {
972
+ content: [{
973
+ type: 'text',
974
+ text: JSON.stringify({
975
+ success: false,
976
+ error: `Plan not found or not linked: ${planSlug}`,
977
+ }, null, 2)
978
+ }]
979
+ };
980
+ }
981
+ return {
982
+ content: [{
983
+ type: 'text',
984
+ text: JSON.stringify({
985
+ success: true,
986
+ plan: {
987
+ ...plan,
988
+ phasesWithPrevc: plan.phases.map(p => ({
989
+ ...p,
990
+ prevcPhaseName: workflow_2.PHASE_NAMES_EN[p.prevcPhase],
991
+ })),
992
+ },
993
+ }, null, 2)
994
+ }]
995
+ };
996
+ }
997
+ catch (error) {
998
+ return {
999
+ content: [{
1000
+ type: 'text',
1001
+ text: JSON.stringify({
1002
+ success: false,
1003
+ error: error instanceof Error ? error.message : String(error)
1004
+ }, null, 2)
1005
+ }]
1006
+ };
1007
+ }
1008
+ });
1009
+ // getPlansForPhase - Get plans relevant to current PREVC phase
1010
+ this.server.registerTool('getPlansForPhase', {
1011
+ description: 'Get all plans that have work items for a specific PREVC phase.',
1012
+ inputSchema: {
1013
+ phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).describe('PREVC phase'),
1014
+ }
1015
+ }, async ({ phase }) => {
1016
+ try {
1017
+ const linker = (0, workflow_2.createPlanLinker)(repoPath);
1018
+ const plans = await linker.getPlansForPhase(phase);
1019
+ return {
1020
+ content: [{
1021
+ type: 'text',
1022
+ text: JSON.stringify({
1023
+ success: true,
1024
+ phase,
1025
+ phaseName: workflow_2.PHASE_NAMES_EN[phase],
1026
+ plans: plans.map(p => ({
1027
+ slug: p.ref.slug,
1028
+ title: p.ref.title,
1029
+ phasesInThisPrevc: p.phases
1030
+ .filter(ph => ph.prevcPhase === phase)
1031
+ .map(ph => ({ id: ph.id, name: ph.name, status: ph.status })),
1032
+ hasPendingWork: linker.hasPendingWorkForPhase(p, phase),
1033
+ })),
1034
+ }, null, 2)
1035
+ }]
1036
+ };
1037
+ }
1038
+ catch (error) {
1039
+ return {
1040
+ content: [{
1041
+ type: 'text',
1042
+ text: JSON.stringify({
1043
+ success: false,
1044
+ error: error instanceof Error ? error.message : String(error)
1045
+ }, null, 2)
1046
+ }]
1047
+ };
1048
+ }
1049
+ });
1050
+ // updatePlanPhase - Update plan phase status
1051
+ this.server.registerTool('updatePlanPhase', {
1052
+ description: 'Update the status of a plan phase (syncs with PREVC workflow tracking).',
1053
+ inputSchema: {
1054
+ planSlug: zod_1.z.string().describe('Plan slug/identifier'),
1055
+ phaseId: zod_1.z.string().describe('Phase ID within the plan (e.g., "phase-1")'),
1056
+ status: zod_1.z.enum(['pending', 'in_progress', 'completed', 'skipped']).describe('New status'),
1057
+ }
1058
+ }, async ({ planSlug, phaseId, status }) => {
1059
+ try {
1060
+ const linker = (0, workflow_2.createPlanLinker)(repoPath);
1061
+ const success = await linker.updatePlanPhase(planSlug, phaseId, status);
1062
+ return {
1063
+ content: [{
1064
+ type: 'text',
1065
+ text: JSON.stringify({
1066
+ success,
1067
+ planSlug,
1068
+ phaseId,
1069
+ status,
1070
+ }, null, 2)
1071
+ }]
1072
+ };
1073
+ }
1074
+ catch (error) {
1075
+ return {
1076
+ content: [{
1077
+ type: 'text',
1078
+ text: JSON.stringify({
1079
+ success: false,
1080
+ error: error instanceof Error ? error.message : String(error)
1081
+ }, null, 2)
1082
+ }]
1083
+ };
1084
+ }
1085
+ });
1086
+ // recordDecision - Record a decision in a plan
1087
+ this.server.registerTool('recordDecision', {
1088
+ description: 'Record a decision made during plan execution. Decisions are tracked and can be referenced later.',
1089
+ inputSchema: {
1090
+ planSlug: zod_1.z.string().describe('Plan slug/identifier'),
1091
+ title: zod_1.z.string().describe('Decision title'),
1092
+ description: zod_1.z.string().describe('Decision description and rationale'),
1093
+ phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).optional().describe('Related PREVC phase'),
1094
+ alternatives: zod_1.z.array(zod_1.z.string()).optional().describe('Alternatives that were considered'),
1095
+ }
1096
+ }, async ({ planSlug, title, description, phase, alternatives }) => {
1097
+ try {
1098
+ const linker = (0, workflow_2.createPlanLinker)(repoPath);
1099
+ const decision = await linker.recordDecision(planSlug, {
1100
+ title,
1101
+ description,
1102
+ phase: phase,
1103
+ alternatives,
1104
+ status: 'accepted',
1105
+ });
1106
+ return {
1107
+ content: [{
1108
+ type: 'text',
1109
+ text: JSON.stringify({
1110
+ success: true,
1111
+ decision,
1112
+ }, null, 2)
1113
+ }]
1114
+ };
1115
+ }
1116
+ catch (error) {
1117
+ return {
1118
+ content: [{
1119
+ type: 'text',
1120
+ text: JSON.stringify({
1121
+ success: false,
1122
+ error: error instanceof Error ? error.message : String(error)
1123
+ }, null, 2)
1124
+ }]
1125
+ };
1126
+ }
1127
+ });
1128
+ // discoverAgents - Discover all available agents (built-in + custom)
1129
+ this.server.registerTool('discoverAgents', {
1130
+ description: 'Discover all available agents including custom ones. Scans .context/agents/ for custom agent playbooks.',
1131
+ inputSchema: {}
1132
+ }, async () => {
1133
+ try {
1134
+ const linker = (0, workflow_2.createPlanLinker)(repoPath);
1135
+ const agents = await linker.discoverAgents();
1136
+ const builtIn = agents.filter(a => !a.isCustom);
1137
+ const custom = agents.filter(a => a.isCustom);
1138
+ return {
1139
+ content: [{
1140
+ type: 'text',
1141
+ text: JSON.stringify({
1142
+ success: true,
1143
+ totalAgents: agents.length,
1144
+ builtInCount: builtIn.length,
1145
+ customCount: custom.length,
1146
+ agents: {
1147
+ builtIn: builtIn.map(a => a.type),
1148
+ custom: custom.map(a => ({ type: a.type, path: a.path })),
1149
+ },
1150
+ }, null, 2)
1151
+ }]
1152
+ };
1153
+ }
1154
+ catch (error) {
1155
+ return {
1156
+ content: [{
1157
+ type: 'text',
1158
+ text: JSON.stringify({
1159
+ success: false,
1160
+ error: error instanceof Error ? error.message : String(error)
1161
+ }, null, 2)
1162
+ }]
1163
+ };
1164
+ }
1165
+ });
1166
+ // getAgentInfo - Get detailed info about a specific agent
1167
+ this.server.registerTool('getAgentInfo', {
1168
+ description: 'Get detailed information about a specific agent (built-in or custom). Returns path, existence status, title, and description.',
1169
+ inputSchema: {
1170
+ agentType: zod_1.z.string().describe('Agent type/identifier (e.g., "code-reviewer" or "agente-de-marketing")'),
1171
+ }
1172
+ }, async ({ agentType }) => {
1173
+ try {
1174
+ const linker = (0, workflow_2.createPlanLinker)(repoPath);
1175
+ const info = await linker.getAgentInfo(agentType);
1176
+ return {
1177
+ content: [{
1178
+ type: 'text',
1179
+ text: JSON.stringify({
1180
+ success: true,
1181
+ agent: info,
1182
+ }, null, 2)
1183
+ }]
1184
+ };
1185
+ }
1186
+ catch (error) {
1187
+ return {
1188
+ content: [{
1189
+ type: 'text',
1190
+ text: JSON.stringify({
1191
+ success: false,
1192
+ error: error instanceof Error ? error.message : String(error)
1193
+ }, null, 2)
1194
+ }]
1195
+ };
1196
+ }
1197
+ });
1198
+ this.log('Registered 8 plan-workflow tools');
319
1199
  }
320
1200
  /**
321
1201
  * Register semantic context resources
@@ -373,6 +1253,576 @@ class AIContextMCPServer {
373
1253
  };
374
1254
  });
375
1255
  this.log('Registered 2 resource templates');
1256
+ // Register PREVC workflow resources
1257
+ this.registerWorkflowResources();
1258
+ // Register orchestration tools
1259
+ this.registerOrchestrationTools();
1260
+ }
1261
+ /**
1262
+ * Register PREVC workflow resources
1263
+ */
1264
+ registerWorkflowResources() {
1265
+ const repoPath = this.options.repoPath || process.cwd();
1266
+ // workflow://status - Current workflow status
1267
+ this.server.registerResource('workflow-status', 'workflow://status', {
1268
+ description: 'Current PREVC workflow status including phases, roles, and progress',
1269
+ mimeType: 'application/json'
1270
+ }, async () => {
1271
+ try {
1272
+ const service = new workflow_1.WorkflowService(repoPath);
1273
+ if (!(await service.hasWorkflow())) {
1274
+ return {
1275
+ contents: [{
1276
+ uri: 'workflow://status',
1277
+ mimeType: 'application/json',
1278
+ text: JSON.stringify({ error: 'No workflow found' }, null, 2)
1279
+ }]
1280
+ };
1281
+ }
1282
+ const summary = await service.getSummary();
1283
+ const status = await service.getStatus();
1284
+ return {
1285
+ contents: [{
1286
+ uri: 'workflow://status',
1287
+ mimeType: 'application/json',
1288
+ text: JSON.stringify({
1289
+ name: summary.name,
1290
+ scale: (0, workflow_2.getScaleName)(summary.scale),
1291
+ currentPhase: summary.currentPhase,
1292
+ progress: summary.progress,
1293
+ isComplete: summary.isComplete,
1294
+ phases: status.phases,
1295
+ roles: status.roles,
1296
+ }, null, 2)
1297
+ }]
1298
+ };
1299
+ }
1300
+ catch (error) {
1301
+ return {
1302
+ contents: [{
1303
+ uri: 'workflow://status',
1304
+ mimeType: 'application/json',
1305
+ text: JSON.stringify({
1306
+ error: error instanceof Error ? error.message : String(error)
1307
+ }, null, 2)
1308
+ }]
1309
+ };
1310
+ }
1311
+ });
1312
+ this.log('Registered 1 workflow resource');
1313
+ }
1314
+ /**
1315
+ * Register agent orchestration tools
1316
+ */
1317
+ registerOrchestrationTools() {
1318
+ // orchestrateAgents - Select agents for a task, phase, or role
1319
+ this.server.registerTool('orchestrateAgents', {
1320
+ description: 'Select appropriate agents based on task description, PREVC phase, or role. Returns recommended agents with their descriptions and relevant documentation.',
1321
+ inputSchema: {
1322
+ task: zod_1.z.string().optional().describe('Task description for intelligent agent selection'),
1323
+ phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).optional().describe('PREVC phase to get agents for'),
1324
+ role: zod_1.z.enum(workflow_2.PREVC_ROLES).optional().describe('PREVC role to get agents for'),
1325
+ },
1326
+ }, async ({ task, phase, role }) => {
1327
+ try {
1328
+ let agents = [];
1329
+ let source = '';
1330
+ if (task) {
1331
+ agents = workflow_2.agentOrchestrator.selectAgentsByTask(task);
1332
+ source = `task: "${task}"`;
1333
+ }
1334
+ else if (phase) {
1335
+ agents = workflow_2.agentOrchestrator.getAgentsForPhase(phase);
1336
+ source = `phase: ${phase} (${workflow_2.PHASE_NAMES_EN[phase]})`;
1337
+ }
1338
+ else if (role) {
1339
+ agents = workflow_2.agentOrchestrator.getAgentsForRole(role);
1340
+ source = `role: ${workflow_2.ROLE_DISPLAY_NAMES[role]}`;
1341
+ }
1342
+ else {
1343
+ return {
1344
+ content: [{ type: 'text', text: 'Error: Provide task, phase, or role parameter' }],
1345
+ };
1346
+ }
1347
+ const agentDetails = agents.map((agent) => ({
1348
+ type: agent,
1349
+ description: workflow_2.agentOrchestrator.getAgentDescription(agent),
1350
+ docs: workflow_2.documentLinker.getDocPathsForAgent(agent),
1351
+ }));
1352
+ return {
1353
+ content: [{
1354
+ type: 'text',
1355
+ text: JSON.stringify({
1356
+ source,
1357
+ agents: agentDetails,
1358
+ count: agents.length,
1359
+ }, null, 2),
1360
+ }],
1361
+ };
1362
+ }
1363
+ catch (error) {
1364
+ return {
1365
+ content: [{
1366
+ type: 'text',
1367
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
1368
+ }],
1369
+ };
1370
+ }
1371
+ });
1372
+ // getAgentSequence - Get recommended agent sequence for a task
1373
+ this.server.registerTool('getAgentSequence', {
1374
+ description: 'Get recommended sequence of agents for a task, including handoff order. Useful for planning multi-agent workflows.',
1375
+ inputSchema: {
1376
+ task: zod_1.z.string().describe('Task description'),
1377
+ includeReview: zod_1.z.boolean().optional().describe('Include code review in sequence (default: true)'),
1378
+ phases: zod_1.z.array(zod_1.z.enum(['P', 'R', 'E', 'V', 'C'])).optional().describe('PREVC phases to include (for phase-based sequencing)'),
1379
+ },
1380
+ }, async ({ task, includeReview, phases }) => {
1381
+ try {
1382
+ let sequence;
1383
+ if (phases && phases.length > 0) {
1384
+ sequence = workflow_2.agentOrchestrator.getAgentHandoffSequence(phases);
1385
+ }
1386
+ else {
1387
+ sequence = workflow_2.agentOrchestrator.getTaskAgentSequence(task, includeReview !== false);
1388
+ }
1389
+ const sequenceDetails = sequence.map((agent, index) => ({
1390
+ order: index + 1,
1391
+ agent,
1392
+ description: workflow_2.agentOrchestrator.getAgentDescription(agent),
1393
+ primaryDoc: workflow_2.documentLinker.getPrimaryDocForAgent(agent)?.path || null,
1394
+ }));
1395
+ return {
1396
+ content: [{
1397
+ type: 'text',
1398
+ text: JSON.stringify({
1399
+ task,
1400
+ sequence: sequenceDetails,
1401
+ totalAgents: sequence.length,
1402
+ }, null, 2),
1403
+ }],
1404
+ };
1405
+ }
1406
+ catch (error) {
1407
+ return {
1408
+ content: [{
1409
+ type: 'text',
1410
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
1411
+ }],
1412
+ };
1413
+ }
1414
+ });
1415
+ // getAgentDocs - Get documentation relevant to an agent
1416
+ this.server.registerTool('getAgentDocs', {
1417
+ description: 'Get documentation guides relevant to a specific agent type. Helps agents find the right context.',
1418
+ inputSchema: {
1419
+ agent: zod_1.z.enum(workflow_2.AGENT_TYPES).describe('Agent type to get documentation for'),
1420
+ },
1421
+ }, async ({ agent }) => {
1422
+ try {
1423
+ if (!workflow_2.agentOrchestrator.isValidAgentType(agent)) {
1424
+ return {
1425
+ content: [{
1426
+ type: 'text',
1427
+ text: `Error: Invalid agent type "${agent}". Valid types: ${workflow_2.AGENT_TYPES.join(', ')}`,
1428
+ }],
1429
+ };
1430
+ }
1431
+ const docs = workflow_2.documentLinker.getDocsForAgent(agent);
1432
+ const agentDesc = workflow_2.agentOrchestrator.getAgentDescription(agent);
1433
+ return {
1434
+ content: [{
1435
+ type: 'text',
1436
+ text: JSON.stringify({
1437
+ agent,
1438
+ description: agentDesc,
1439
+ documentation: docs.map((doc) => ({
1440
+ type: doc.type,
1441
+ title: doc.title,
1442
+ path: doc.path,
1443
+ description: doc.description,
1444
+ })),
1445
+ }, null, 2),
1446
+ }],
1447
+ };
1448
+ }
1449
+ catch (error) {
1450
+ return {
1451
+ content: [{
1452
+ type: 'text',
1453
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
1454
+ }],
1455
+ };
1456
+ }
1457
+ });
1458
+ // getPhaseDocs - Get documentation for a PREVC phase
1459
+ this.server.registerTool('getPhaseDocs', {
1460
+ description: 'Get documentation relevant to a PREVC workflow phase. Helps understand what documentation is needed at each phase.',
1461
+ inputSchema: {
1462
+ phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).describe('PREVC phase (P=Planning, R=Review, E=Execution, V=Validation, C=Confirmation)'),
1463
+ },
1464
+ }, async ({ phase }) => {
1465
+ try {
1466
+ const docs = workflow_2.documentLinker.getDocsForPhase(phase);
1467
+ const agents = workflow_2.agentOrchestrator.getAgentsForPhase(phase);
1468
+ return {
1469
+ content: [{
1470
+ type: 'text',
1471
+ text: JSON.stringify({
1472
+ phase,
1473
+ phaseName: workflow_2.PHASE_NAMES_EN[phase],
1474
+ documentation: docs.map((doc) => ({
1475
+ type: doc.type,
1476
+ title: doc.title,
1477
+ path: doc.path,
1478
+ description: doc.description,
1479
+ })),
1480
+ recommendedAgents: agents.map((agent) => ({
1481
+ type: agent,
1482
+ description: workflow_2.agentOrchestrator.getAgentDescription(agent),
1483
+ })),
1484
+ }, null, 2),
1485
+ }],
1486
+ };
1487
+ }
1488
+ catch (error) {
1489
+ return {
1490
+ content: [{
1491
+ type: 'text',
1492
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
1493
+ }],
1494
+ };
1495
+ }
1496
+ });
1497
+ // listAgentTypes - List all available agent types
1498
+ this.server.registerTool('listAgentTypes', {
1499
+ description: 'List all available agent types with their descriptions. Use this to understand what agents are available.',
1500
+ inputSchema: {},
1501
+ }, async () => {
1502
+ const agents = workflow_2.agentOrchestrator.getAllAgentTypes().map((agent) => ({
1503
+ type: agent,
1504
+ description: workflow_2.agentOrchestrator.getAgentDescription(agent),
1505
+ primaryDoc: workflow_2.documentLinker.getPrimaryDocForAgent(agent)?.title || null,
1506
+ }));
1507
+ return {
1508
+ content: [{
1509
+ type: 'text',
1510
+ text: JSON.stringify({
1511
+ agents,
1512
+ total: agents.length,
1513
+ }, null, 2),
1514
+ }],
1515
+ };
1516
+ });
1517
+ this.log('Registered 5 orchestration tools');
1518
+ // Register skill tools
1519
+ this.registerSkillTools();
1520
+ }
1521
+ /**
1522
+ * Register skill tools for on-demand expertise
1523
+ */
1524
+ registerSkillTools() {
1525
+ const repoPath = this.options.repoPath || process.cwd();
1526
+ // Import skill registry
1527
+ const { createSkillRegistry, BUILT_IN_SKILLS, SKILL_TO_PHASES } = require('../../workflow/skills');
1528
+ // listSkills - List all available skills
1529
+ this.server.registerTool('listSkills', {
1530
+ description: 'List all available skills (built-in + custom). Skills are on-demand expertise for specific tasks.',
1531
+ inputSchema: {
1532
+ includeContent: zod_1.z.boolean().optional().describe('Include full skill content in response'),
1533
+ }
1534
+ }, async ({ includeContent }) => {
1535
+ try {
1536
+ const registry = createSkillRegistry(repoPath);
1537
+ const discovered = await registry.discoverAll();
1538
+ const format = (skill) => ({
1539
+ slug: skill.slug,
1540
+ name: skill.metadata.name,
1541
+ description: skill.metadata.description,
1542
+ phases: skill.metadata.phases || [],
1543
+ isBuiltIn: skill.isBuiltIn,
1544
+ ...(includeContent ? { content: skill.content } : {}),
1545
+ });
1546
+ return {
1547
+ content: [{
1548
+ type: 'text',
1549
+ text: JSON.stringify({
1550
+ success: true,
1551
+ totalSkills: discovered.all.length,
1552
+ builtInCount: discovered.builtIn.length,
1553
+ customCount: discovered.custom.length,
1554
+ skills: {
1555
+ builtIn: discovered.builtIn.map(format),
1556
+ custom: discovered.custom.map(format),
1557
+ },
1558
+ }, null, 2)
1559
+ }]
1560
+ };
1561
+ }
1562
+ catch (error) {
1563
+ return {
1564
+ content: [{
1565
+ type: 'text',
1566
+ text: JSON.stringify({
1567
+ success: false,
1568
+ error: error instanceof Error ? error.message : String(error)
1569
+ }, null, 2)
1570
+ }]
1571
+ };
1572
+ }
1573
+ });
1574
+ // getSkillContent - Get full content of a specific skill
1575
+ this.server.registerTool('getSkillContent', {
1576
+ description: 'Get the full content of a skill by slug. Returns the SKILL.md content with instructions.',
1577
+ inputSchema: {
1578
+ skillSlug: zod_1.z.string().describe('Skill slug/identifier (e.g., "commit-message", "pr-review")'),
1579
+ }
1580
+ }, async ({ skillSlug }) => {
1581
+ try {
1582
+ const registry = createSkillRegistry(repoPath);
1583
+ const content = await registry.getSkillContent(skillSlug);
1584
+ if (!content) {
1585
+ return {
1586
+ content: [{
1587
+ type: 'text',
1588
+ text: JSON.stringify({
1589
+ success: false,
1590
+ error: `Skill not found: ${skillSlug}`,
1591
+ availableSkills: BUILT_IN_SKILLS,
1592
+ }, null, 2)
1593
+ }]
1594
+ };
1595
+ }
1596
+ const skill = await registry.getSkillMetadata(skillSlug);
1597
+ return {
1598
+ content: [{
1599
+ type: 'text',
1600
+ text: JSON.stringify({
1601
+ success: true,
1602
+ skill: {
1603
+ slug: skillSlug,
1604
+ name: skill?.metadata.name,
1605
+ description: skill?.metadata.description,
1606
+ phases: skill?.metadata.phases,
1607
+ isBuiltIn: skill?.isBuiltIn,
1608
+ },
1609
+ content,
1610
+ }, null, 2)
1611
+ }]
1612
+ };
1613
+ }
1614
+ catch (error) {
1615
+ return {
1616
+ content: [{
1617
+ type: 'text',
1618
+ text: JSON.stringify({
1619
+ success: false,
1620
+ error: error instanceof Error ? error.message : String(error)
1621
+ }, null, 2)
1622
+ }]
1623
+ };
1624
+ }
1625
+ });
1626
+ // getSkillsForPhase - Get skills relevant to a PREVC phase
1627
+ this.server.registerTool('getSkillsForPhase', {
1628
+ description: 'Get all skills relevant to a specific PREVC phase. Useful for knowing which skills to activate during workflow execution.',
1629
+ inputSchema: {
1630
+ phase: zod_1.z.enum(['P', 'R', 'E', 'V', 'C']).describe('PREVC phase'),
1631
+ }
1632
+ }, async ({ phase }) => {
1633
+ try {
1634
+ const registry = createSkillRegistry(repoPath);
1635
+ const skills = await registry.getSkillsForPhase(phase);
1636
+ return {
1637
+ content: [{
1638
+ type: 'text',
1639
+ text: JSON.stringify({
1640
+ success: true,
1641
+ phase,
1642
+ phaseName: workflow_2.PHASE_NAMES_EN[phase],
1643
+ skills: skills.map((s) => ({
1644
+ slug: s.slug,
1645
+ name: s.metadata.name,
1646
+ description: s.metadata.description,
1647
+ isBuiltIn: s.isBuiltIn,
1648
+ })),
1649
+ count: skills.length,
1650
+ }, null, 2)
1651
+ }]
1652
+ };
1653
+ }
1654
+ catch (error) {
1655
+ return {
1656
+ content: [{
1657
+ type: 'text',
1658
+ text: JSON.stringify({
1659
+ success: false,
1660
+ error: error instanceof Error ? error.message : String(error)
1661
+ }, null, 2)
1662
+ }]
1663
+ };
1664
+ }
1665
+ });
1666
+ // scaffoldSkills - Generate skill files
1667
+ this.server.registerTool('scaffoldSkills', {
1668
+ description: 'Scaffold skill files in .context/skills/. Creates SKILL.md files for built-in or custom skills.',
1669
+ inputSchema: {
1670
+ skills: zod_1.z.array(zod_1.z.string()).optional().describe('Specific skills to scaffold (default: all built-in)'),
1671
+ force: zod_1.z.boolean().optional().describe('Overwrite existing skill files'),
1672
+ }
1673
+ }, async ({ skills, force }) => {
1674
+ try {
1675
+ const { createSkillGenerator } = require('../../generators/skills');
1676
+ const generator = createSkillGenerator({ repoPath });
1677
+ const result = await generator.generate({ skills, force });
1678
+ return {
1679
+ content: [{
1680
+ type: 'text',
1681
+ text: JSON.stringify({
1682
+ success: true,
1683
+ skillsDir: result.skillsDir,
1684
+ generated: result.generatedSkills,
1685
+ skipped: result.skippedSkills,
1686
+ indexPath: result.indexPath,
1687
+ }, null, 2)
1688
+ }]
1689
+ };
1690
+ }
1691
+ catch (error) {
1692
+ return {
1693
+ content: [{
1694
+ type: 'text',
1695
+ text: JSON.stringify({
1696
+ success: false,
1697
+ error: error instanceof Error ? error.message : String(error)
1698
+ }, null, 2)
1699
+ }]
1700
+ };
1701
+ }
1702
+ });
1703
+ // exportSkills - Export skills to AI tool directories
1704
+ this.server.registerTool('exportSkills', {
1705
+ description: 'Export skills to AI tool directories (Claude Code, Gemini CLI, Codex). Copies skills to .claude/skills/, .gemini/skills/, etc.',
1706
+ inputSchema: {
1707
+ preset: zod_1.z.enum(['claude', 'gemini', 'codex', 'all']).default('all')
1708
+ .describe('Target AI tool or "all" for all supported tools'),
1709
+ includeBuiltIn: zod_1.z.boolean().optional().describe('Include built-in skills even if not scaffolded'),
1710
+ force: zod_1.z.boolean().optional().describe('Overwrite existing files'),
1711
+ }
1712
+ }, async ({ preset, includeBuiltIn, force }) => {
1713
+ try {
1714
+ const { SkillExportService } = require('../export/skillExportService');
1715
+ const exportService = new SkillExportService({
1716
+ ui: {
1717
+ displayOutput: () => { },
1718
+ displaySuccess: () => { },
1719
+ displayError: () => { },
1720
+ displayWarning: () => { },
1721
+ startSpinner: () => { },
1722
+ stopSpinner: () => { },
1723
+ updateSpinner: () => { },
1724
+ },
1725
+ t: (key) => key,
1726
+ version: version_1.VERSION,
1727
+ });
1728
+ const result = await exportService.run(repoPath, {
1729
+ preset,
1730
+ includeBuiltIn,
1731
+ force,
1732
+ });
1733
+ return {
1734
+ content: [{
1735
+ type: 'text',
1736
+ text: JSON.stringify({
1737
+ success: result.filesCreated > 0,
1738
+ targets: result.targets,
1739
+ skillsExported: result.skillsExported,
1740
+ filesCreated: result.filesCreated,
1741
+ filesSkipped: result.filesSkipped,
1742
+ }, null, 2)
1743
+ }]
1744
+ };
1745
+ }
1746
+ catch (error) {
1747
+ return {
1748
+ content: [{
1749
+ type: 'text',
1750
+ text: JSON.stringify({
1751
+ success: false,
1752
+ error: error instanceof Error ? error.message : String(error)
1753
+ }, null, 2)
1754
+ }]
1755
+ };
1756
+ }
1757
+ });
1758
+ // fillSkills - Fill/personalize skill files with AI
1759
+ this.server.registerTool('fillSkills', {
1760
+ description: 'Fill/personalize skill files using AI analysis of the codebase. Reads docs and agents for context.',
1761
+ inputSchema: {
1762
+ skills: zod_1.z.array(zod_1.z.string()).optional().describe('Specific skills to fill (default: all scaffolded)'),
1763
+ force: zod_1.z.boolean().optional().describe('Overwrite existing content'),
1764
+ useSemanticContext: zod_1.z.boolean().default(true).optional().describe('Use semantic context mode (more token efficient)'),
1765
+ useLsp: zod_1.z.boolean().optional().describe('Enable LSP for deeper analysis'),
1766
+ }
1767
+ }, async ({ skills, force, useSemanticContext, useLsp }) => {
1768
+ try {
1769
+ const { SkillFillService } = require('../fill/skillFillService');
1770
+ const skillFillService = new SkillFillService({
1771
+ ui: {
1772
+ displayWelcome: () => { },
1773
+ displayProjectInfo: () => { },
1774
+ displayStep: () => { },
1775
+ displaySuccess: () => { },
1776
+ displayError: () => { },
1777
+ displayWarning: () => { },
1778
+ displayInfo: () => { },
1779
+ startSpinner: () => { },
1780
+ stopSpinner: () => { },
1781
+ updateSpinner: () => { },
1782
+ createAgentCallbacks: () => ({
1783
+ onAgentStart: () => { },
1784
+ onAgentStep: () => { },
1785
+ onAgentComplete: () => { },
1786
+ onToolCall: () => { },
1787
+ onToolResult: () => { },
1788
+ }),
1789
+ },
1790
+ t: (key) => key,
1791
+ version: version_1.VERSION,
1792
+ defaultModel: DEFAULT_MODEL,
1793
+ });
1794
+ const result = await skillFillService.run(repoPath, {
1795
+ skills,
1796
+ force,
1797
+ semantic: useSemanticContext ?? true,
1798
+ useLsp,
1799
+ });
1800
+ return {
1801
+ content: [{
1802
+ type: 'text',
1803
+ text: JSON.stringify({
1804
+ success: true,
1805
+ filled: result.filled,
1806
+ skipped: result.skipped,
1807
+ failed: result.failed,
1808
+ model: result.model,
1809
+ }, null, 2)
1810
+ }]
1811
+ };
1812
+ }
1813
+ catch (error) {
1814
+ return {
1815
+ content: [{
1816
+ type: 'text',
1817
+ text: JSON.stringify({
1818
+ success: false,
1819
+ error: error instanceof Error ? error.message : String(error)
1820
+ }, null, 2)
1821
+ }]
1822
+ };
1823
+ }
1824
+ });
1825
+ this.log('Registered 6 skill tools');
376
1826
  }
377
1827
  /**
378
1828
  * Start the MCP server with stdio transport