@codemcp/workflows 3.1.21

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 (159) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/.vibe/conversation-state.sqlite +0 -0
  3. package/LICENSE +674 -0
  4. package/dist/index.d.ts +9 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +74 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/notification-service.d.ts +14 -0
  9. package/dist/notification-service.d.ts.map +1 -0
  10. package/dist/notification-service.js +18 -0
  11. package/dist/notification-service.js.map +1 -0
  12. package/dist/resource-handlers/conversation-state.d.ts +15 -0
  13. package/dist/resource-handlers/conversation-state.d.ts.map +1 -0
  14. package/dist/resource-handlers/conversation-state.js +40 -0
  15. package/dist/resource-handlers/conversation-state.js.map +1 -0
  16. package/dist/resource-handlers/development-plan.d.ts +14 -0
  17. package/dist/resource-handlers/development-plan.d.ts.map +1 -0
  18. package/dist/resource-handlers/development-plan.js +31 -0
  19. package/dist/resource-handlers/development-plan.js.map +1 -0
  20. package/dist/resource-handlers/index.d.ts +24 -0
  21. package/dist/resource-handlers/index.d.ts.map +1 -0
  22. package/dist/resource-handlers/index.js +62 -0
  23. package/dist/resource-handlers/index.js.map +1 -0
  24. package/dist/resource-handlers/system-prompt.d.ts +15 -0
  25. package/dist/resource-handlers/system-prompt.d.ts.map +1 -0
  26. package/dist/resource-handlers/system-prompt.js +40 -0
  27. package/dist/resource-handlers/system-prompt.js.map +1 -0
  28. package/dist/resource-handlers/workflow-resource.d.ts +15 -0
  29. package/dist/resource-handlers/workflow-resource.d.ts.map +1 -0
  30. package/dist/resource-handlers/workflow-resource.js +85 -0
  31. package/dist/resource-handlers/workflow-resource.js.map +1 -0
  32. package/dist/response-renderer.d.ts +30 -0
  33. package/dist/response-renderer.d.ts.map +1 -0
  34. package/dist/response-renderer.js +94 -0
  35. package/dist/response-renderer.js.map +1 -0
  36. package/dist/server-config.d.ts +34 -0
  37. package/dist/server-config.d.ts.map +1 -0
  38. package/dist/server-config.js +486 -0
  39. package/dist/server-config.js.map +1 -0
  40. package/dist/server-helpers.d.ts +62 -0
  41. package/dist/server-helpers.d.ts.map +1 -0
  42. package/dist/server-helpers.js +156 -0
  43. package/dist/server-helpers.js.map +1 -0
  44. package/dist/server-implementation.d.ts +74 -0
  45. package/dist/server-implementation.d.ts.map +1 -0
  46. package/dist/server-implementation.js +201 -0
  47. package/dist/server-implementation.js.map +1 -0
  48. package/dist/server.d.ts +6 -0
  49. package/dist/server.d.ts.map +1 -0
  50. package/dist/server.js +5 -0
  51. package/dist/server.js.map +1 -0
  52. package/dist/tool-handlers/base-tool-handler.d.ts +50 -0
  53. package/dist/tool-handlers/base-tool-handler.d.ts.map +1 -0
  54. package/dist/tool-handlers/base-tool-handler.js +74 -0
  55. package/dist/tool-handlers/base-tool-handler.js.map +1 -0
  56. package/dist/tool-handlers/conduct-review.d.ts +49 -0
  57. package/dist/tool-handlers/conduct-review.d.ts.map +1 -0
  58. package/dist/tool-handlers/conduct-review.js +105 -0
  59. package/dist/tool-handlers/conduct-review.js.map +1 -0
  60. package/dist/tool-handlers/get-tool-info.d.ts +76 -0
  61. package/dist/tool-handlers/get-tool-info.d.ts.map +1 -0
  62. package/dist/tool-handlers/get-tool-info.js +168 -0
  63. package/dist/tool-handlers/get-tool-info.js.map +1 -0
  64. package/dist/tool-handlers/index.d.ts +42 -0
  65. package/dist/tool-handlers/index.d.ts.map +1 -0
  66. package/dist/tool-handlers/index.js +74 -0
  67. package/dist/tool-handlers/index.js.map +1 -0
  68. package/dist/tool-handlers/install-workflow.d.ts +48 -0
  69. package/dist/tool-handlers/install-workflow.d.ts.map +1 -0
  70. package/dist/tool-handlers/install-workflow.js +131 -0
  71. package/dist/tool-handlers/install-workflow.js.map +1 -0
  72. package/dist/tool-handlers/list-workflows.d.ts +47 -0
  73. package/dist/tool-handlers/list-workflows.d.ts.map +1 -0
  74. package/dist/tool-handlers/list-workflows.js +58 -0
  75. package/dist/tool-handlers/list-workflows.js.map +1 -0
  76. package/dist/tool-handlers/no-idea.d.ts +41 -0
  77. package/dist/tool-handlers/no-idea.d.ts.map +1 -0
  78. package/dist/tool-handlers/no-idea.js +29 -0
  79. package/dist/tool-handlers/no-idea.js.map +1 -0
  80. package/dist/tool-handlers/proceed-to-phase.d.ts +39 -0
  81. package/dist/tool-handlers/proceed-to-phase.d.ts.map +1 -0
  82. package/dist/tool-handlers/proceed-to-phase.js +109 -0
  83. package/dist/tool-handlers/proceed-to-phase.js.map +1 -0
  84. package/dist/tool-handlers/reset-development.d.ts +31 -0
  85. package/dist/tool-handlers/reset-development.d.ts.map +1 -0
  86. package/dist/tool-handlers/reset-development.js +48 -0
  87. package/dist/tool-handlers/reset-development.js.map +1 -0
  88. package/dist/tool-handlers/resume-workflow.d.ts +88 -0
  89. package/dist/tool-handlers/resume-workflow.d.ts.map +1 -0
  90. package/dist/tool-handlers/resume-workflow.js +213 -0
  91. package/dist/tool-handlers/resume-workflow.js.map +1 -0
  92. package/dist/tool-handlers/setup-project-docs.d.ts +36 -0
  93. package/dist/tool-handlers/setup-project-docs.d.ts.map +1 -0
  94. package/dist/tool-handlers/setup-project-docs.js +136 -0
  95. package/dist/tool-handlers/setup-project-docs.js.map +1 -0
  96. package/dist/tool-handlers/start-development.d.ts +82 -0
  97. package/dist/tool-handlers/start-development.d.ts.map +1 -0
  98. package/dist/tool-handlers/start-development.js +448 -0
  99. package/dist/tool-handlers/start-development.js.map +1 -0
  100. package/dist/tool-handlers/whats-next.d.ts +42 -0
  101. package/dist/tool-handlers/whats-next.d.ts.map +1 -0
  102. package/dist/tool-handlers/whats-next.js +118 -0
  103. package/dist/tool-handlers/whats-next.js.map +1 -0
  104. package/dist/types.d.ts +114 -0
  105. package/dist/types.d.ts.map +1 -0
  106. package/dist/types.js +5 -0
  107. package/dist/types.js.map +1 -0
  108. package/package.json +29 -0
  109. package/src/index.ts +93 -0
  110. package/src/notification-service.ts +23 -0
  111. package/src/resource-handlers/conversation-state.ts +55 -0
  112. package/src/resource-handlers/development-plan.ts +48 -0
  113. package/src/resource-handlers/index.ts +73 -0
  114. package/src/resource-handlers/system-prompt.ts +55 -0
  115. package/src/resource-handlers/workflow-resource.ts +126 -0
  116. package/src/response-renderer.ts +116 -0
  117. package/src/server-config.ts +744 -0
  118. package/src/server-helpers.ts +225 -0
  119. package/src/server-implementation.ts +277 -0
  120. package/src/server.ts +9 -0
  121. package/src/tool-handlers/base-tool-handler.ts +141 -0
  122. package/src/tool-handlers/conduct-review.ts +191 -0
  123. package/src/tool-handlers/get-tool-info.ts +274 -0
  124. package/src/tool-handlers/index.ts +117 -0
  125. package/src/tool-handlers/install-workflow.ts +185 -0
  126. package/src/tool-handlers/list-workflows.ts +94 -0
  127. package/src/tool-handlers/no-idea.ts +47 -0
  128. package/src/tool-handlers/proceed-to-phase.ts +205 -0
  129. package/src/tool-handlers/reset-development.ts +90 -0
  130. package/src/tool-handlers/resume-workflow.ts +380 -0
  131. package/src/tool-handlers/setup-project-docs.ts +226 -0
  132. package/src/tool-handlers/start-development.ts +685 -0
  133. package/src/tool-handlers/whats-next.ts +235 -0
  134. package/src/types.ts +130 -0
  135. package/test/e2e/core-functionality.test.ts +176 -0
  136. package/test/e2e/mcp-contract.test.ts +540 -0
  137. package/test/e2e/plan-management.test.ts +331 -0
  138. package/test/e2e/state-management.test.ts +392 -0
  139. package/test/e2e/workflow-integration.test.ts +506 -0
  140. package/test/unit/commit-behaviour-interface.test.ts +244 -0
  141. package/test/unit/conduct-review.test.ts +151 -0
  142. package/test/unit/reset-functionality.test.ts +72 -0
  143. package/test/unit/resume-workflow.test.ts +192 -0
  144. package/test/unit/server-tools.test.ts +311 -0
  145. package/test/unit/setup-project-docs-handler.test.ts +267 -0
  146. package/test/unit/start-development-artifact-detection.test.ts +387 -0
  147. package/test/unit/start-development-gitignore.test.ts +178 -0
  148. package/test/unit/system-prompt-resource.test.ts +101 -0
  149. package/test/unit/tool-handlers/no-idea.test.ts +40 -0
  150. package/test/utils/e2e-test-setup.ts +453 -0
  151. package/test/utils/run-server-in-dir.sh +27 -0
  152. package/test/utils/temp-files.ts +308 -0
  153. package/test/utils/test-access.ts +79 -0
  154. package/test/utils/test-helpers.ts +286 -0
  155. package/test/utils/test-setup.ts +78 -0
  156. package/tsconfig.build.json +9 -0
  157. package/tsconfig.build.tsbuildinfo +1 -0
  158. package/tsconfig.json +12 -0
  159. package/vitest.config.ts +17 -0
@@ -0,0 +1,191 @@
1
+ /**
2
+ * ConductReview Tool Handler
3
+ *
4
+ * Handles review requests before phase transitions. Adapts to MCP environment
5
+ * capabilities - returns automated review results if sampling available,
6
+ * otherwise returns instructions for LLM to conduct guided review.
7
+ */
8
+
9
+ import { ConversationRequiredToolHandler } from './base-tool-handler.js';
10
+ import { validateRequiredArgs } from '../server-helpers.js';
11
+ import type { ConversationContext } from '@codemcp/workflows-core';
12
+ import type { YamlTransition } from '@codemcp/workflows-core';
13
+ import { ServerContext } from '../types.js';
14
+
15
+ /**
16
+ * Arguments for the conduct_review tool
17
+ */
18
+ export interface ConductReviewArgs {
19
+ target_phase: string;
20
+ }
21
+
22
+ /**
23
+ * Response from the conduct_review tool
24
+ */
25
+ export interface ConductReviewResult {
26
+ instructions: string;
27
+ perspectives: Array<{
28
+ name: string;
29
+ prompt: string;
30
+ }>;
31
+ }
32
+
33
+ /**
34
+ * ConductReview tool handler implementation
35
+ */
36
+ export class ConductReviewHandler extends ConversationRequiredToolHandler<
37
+ ConductReviewArgs,
38
+ ConductReviewResult
39
+ > {
40
+ protected async executeWithConversation(
41
+ args: ConductReviewArgs,
42
+ context: ServerContext,
43
+ conversationContext: ConversationContext
44
+ ): Promise<ConductReviewResult> {
45
+ // Validate required arguments
46
+ validateRequiredArgs(args, ['target_phase']);
47
+
48
+ const { target_phase } = args;
49
+ const currentPhase = conversationContext.currentPhase;
50
+ const conversationId = conversationContext.conversationId;
51
+
52
+ this.logger.debug('Processing conduct_review request', {
53
+ conversationId,
54
+ currentPhase,
55
+ targetPhase: target_phase,
56
+ });
57
+
58
+ // Ensure state machine is loaded for this project
59
+ this.ensureStateMachineForProject(context, conversationContext.projectPath);
60
+
61
+ // Get transition configuration from workflow
62
+ const transition = this.getTransitionConfig(
63
+ currentPhase,
64
+ target_phase,
65
+ conversationContext.workflowName,
66
+ context
67
+ );
68
+
69
+ if (
70
+ !transition.review_perspectives ||
71
+ transition.review_perspectives.length === 0
72
+ ) {
73
+ throw new Error(
74
+ `No review perspectives defined for transition from ${currentPhase} to ${target_phase}`
75
+ );
76
+ }
77
+
78
+ // Check if MCP environment supports sampling (LLM interaction tools)
79
+ const hasSamplingCapability = await this.checkSamplingCapability(context);
80
+
81
+ if (hasSamplingCapability) {
82
+ // Conduct automated review using available LLM tools
83
+ return await this.conductAutomatedReview(
84
+ transition.review_perspectives,
85
+ conversationContext
86
+ );
87
+ } else {
88
+ // Generate instructions for LLM to conduct review
89
+ return await this.generateReviewInstructions(
90
+ transition.review_perspectives,
91
+ currentPhase,
92
+ target_phase
93
+ );
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Get transition configuration from workflow
99
+ */
100
+ private getTransitionConfig(
101
+ currentPhase: string,
102
+ targetPhase: string,
103
+ workflowName: string,
104
+ context: ServerContext
105
+ ) {
106
+ const stateMachine = context.workflowManager.loadWorkflowForProject(
107
+ context.projectPath,
108
+ workflowName
109
+ );
110
+ const currentState = stateMachine.states[currentPhase];
111
+
112
+ if (!currentState) {
113
+ throw new Error(`Invalid current phase: ${currentPhase}`);
114
+ }
115
+
116
+ const transition = currentState.transitions.find(
117
+ (t: YamlTransition) => t.to === targetPhase
118
+ );
119
+ if (!transition) {
120
+ throw new Error(
121
+ `No transition found from ${currentPhase} to ${targetPhase}`
122
+ );
123
+ }
124
+
125
+ return transition;
126
+ }
127
+
128
+ /**
129
+ * Check if MCP environment supports sampling capabilities
130
+ */
131
+ private async checkSamplingCapability(
132
+ _context: ServerContext
133
+ ): Promise<boolean> {
134
+ // For now, assume non-sampling (most common case)
135
+ // In the future, this could check for specific LLM interaction tools
136
+ return false;
137
+ }
138
+
139
+ /**
140
+ * Conduct automated review using LLM tools (when sampling is available)
141
+ */
142
+ private async conductAutomatedReview(
143
+ perspectives: Array<{ perspective: string; prompt: string }>,
144
+ conversationContext: ConversationContext
145
+ ): Promise<ConductReviewResult> {
146
+ // TODO: Implement automated review when sampling tools are available
147
+ // For now, fall back to guided instructions
148
+ return this.generateReviewInstructions(
149
+ perspectives,
150
+ conversationContext.currentPhase,
151
+ 'target'
152
+ );
153
+ }
154
+
155
+ /**
156
+ * Generate instructions for LLM to conduct guided review
157
+ */
158
+ private async generateReviewInstructions(
159
+ perspectives: Array<{ perspective: string; prompt: string }>,
160
+ currentPhase: string,
161
+ targetPhase: string
162
+ ): Promise<ConductReviewResult> {
163
+ const instructions = `Conduct a review of the ${currentPhase} phase before proceeding to ${targetPhase}.
164
+
165
+ First, identify the artifacts and decisions from the ${currentPhase} phase by:
166
+ 1. Reviewing the plan file to see completed tasks and key decisions
167
+ 2. Using git status/diff to see what files were changed (if in a git repository)
168
+ 3. Analyzing recent conversation history for important decisions
169
+
170
+ Then, for each perspective below, analyze these artifacts and provide feedback:
171
+
172
+ ${perspectives
173
+ .map(
174
+ (p, i) => `**${i + 1}. ${p.perspective.toUpperCase()} PERSPECTIVE:**
175
+ ${p.prompt}
176
+
177
+ `
178
+ )
179
+ .join('')}
180
+
181
+ After completing all perspective reviews, summarize your findings and ask the user if they're ready to proceed to the ${targetPhase} phase.`;
182
+
183
+ return {
184
+ instructions,
185
+ perspectives: perspectives.map(p => ({
186
+ name: p.perspective,
187
+ prompt: p.prompt,
188
+ })),
189
+ };
190
+ }
191
+ }
@@ -0,0 +1,274 @@
1
+ /**
2
+ * Get Tool Info Handler
3
+ *
4
+ * Provides comprehensive information about the responsible-vibe-mcp development
5
+ * workflow tools for better tool discoverability and AI integration.
6
+ */
7
+
8
+ import { z } from 'zod';
9
+ import { BaseToolHandler } from './base-tool-handler.js';
10
+ import { createLogger } from '@codemcp/workflows-core';
11
+ import { ServerContext } from '../types.js';
12
+
13
+ const logger = createLogger('GetToolInfoHandler');
14
+
15
+ /**
16
+ * Schema for get_tool_info tool arguments
17
+ */
18
+ const GetToolInfoArgsSchema = z.object({
19
+ // No input parameters needed
20
+ });
21
+
22
+ type GetToolInfoArgs = z.infer<typeof GetToolInfoArgsSchema>;
23
+
24
+ /**
25
+ * Tool information structure
26
+ */
27
+ interface ToolInfo {
28
+ name: string;
29
+ description: string;
30
+ parameters: string[];
31
+ schema?: {
32
+ required: string[];
33
+ optional: string[];
34
+ };
35
+ }
36
+
37
+ /**
38
+ * Workflow information structure
39
+ */
40
+ interface WorkflowInfo {
41
+ name: string;
42
+ displayName: string;
43
+ description: string;
44
+ phases?: string[];
45
+ }
46
+
47
+ /**
48
+ * Complete tool information response
49
+ */
50
+ interface GetToolInfoResponse {
51
+ tool_name: string;
52
+ version: string;
53
+ purpose: string;
54
+ description: string;
55
+
56
+ available_tools: ToolInfo[];
57
+ available_workflows: WorkflowInfo[];
58
+
59
+ core_concepts: {
60
+ phase_management: string;
61
+ plan_file_tracking: string;
62
+ conversation_context: string;
63
+ workflow_guidance: string;
64
+ };
65
+
66
+ usage_guidelines: {
67
+ required_pattern: string;
68
+ phase_transitions: string;
69
+ context_requirements: string;
70
+ plan_file_management: string;
71
+ };
72
+
73
+ workflow_states?: {
74
+ current_phase?: string;
75
+ conversation_id?: string;
76
+ plan_file_path?: string;
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Tool handler for providing comprehensive tool information
82
+ */
83
+ export class GetToolInfoHandler extends BaseToolHandler<
84
+ GetToolInfoArgs,
85
+ GetToolInfoResponse
86
+ > {
87
+ protected readonly argsSchema = GetToolInfoArgsSchema;
88
+
89
+ async executeHandler(
90
+ _args: GetToolInfoArgs,
91
+ context: ServerContext
92
+ ): Promise<GetToolInfoResponse> {
93
+ logger.info('Generating comprehensive tool information', {
94
+ projectPath: context.projectPath,
95
+ });
96
+
97
+ // Get available workflows
98
+ const availableWorkflows =
99
+ context.workflowManager.getAvailableWorkflowsForProject(
100
+ context.projectPath
101
+ );
102
+
103
+ // Transform workflows to response format
104
+ const workflows: WorkflowInfo[] = availableWorkflows.map(workflow => ({
105
+ name: workflow.name,
106
+ displayName: workflow.displayName,
107
+ description: workflow.description,
108
+ phases: this.extractWorkflowPhases(workflow),
109
+ }));
110
+
111
+ // Define available tools with their information
112
+ const tools: ToolInfo[] = [
113
+ {
114
+ name: 'start_development',
115
+ description:
116
+ 'Initialize new development project with structured workflow',
117
+ parameters: ['workflow', 'commit_behaviour'],
118
+ schema: {
119
+ required: ['commit_behaviour'],
120
+ optional: ['workflow'],
121
+ },
122
+ },
123
+ {
124
+ name: 'whats_next',
125
+ description:
126
+ 'Get phase-specific instructions and guidance for current development state',
127
+ parameters: [
128
+ 'context',
129
+ 'user_input',
130
+ 'conversation_summary',
131
+ 'recent_messages',
132
+ ],
133
+ schema: {
134
+ required: ['context', 'user_input'],
135
+ optional: ['conversation_summary', 'recent_messages'],
136
+ },
137
+ },
138
+ {
139
+ name: 'proceed_to_phase',
140
+ description:
141
+ 'Transition to the next development phase when current phase is complete',
142
+ parameters: ['target_phase', 'reason'],
143
+ schema: {
144
+ required: ['target_phase'],
145
+ optional: ['reason'],
146
+ },
147
+ },
148
+ {
149
+ name: 'resume_workflow',
150
+ description:
151
+ 'Continue development after a break or conversation restart',
152
+ parameters: ['include_system_prompt'],
153
+ schema: {
154
+ required: [],
155
+ optional: ['include_system_prompt'],
156
+ },
157
+ },
158
+ {
159
+ name: 'reset_development',
160
+ description:
161
+ 'Start over with a clean slate by deleting all development progress',
162
+ parameters: ['confirm', 'reason'],
163
+ schema: {
164
+ required: ['confirm'],
165
+ optional: ['reason'],
166
+ },
167
+ },
168
+ {
169
+ name: 'list_workflows',
170
+ description:
171
+ 'Get an overview of all available workflows with descriptions',
172
+ parameters: [],
173
+ schema: {
174
+ required: [],
175
+ optional: [],
176
+ },
177
+ },
178
+ {
179
+ name: 'get_tool_info',
180
+ description:
181
+ 'Get comprehensive information about all available tools and workflows',
182
+ parameters: [],
183
+ schema: {
184
+ required: [],
185
+ optional: [],
186
+ },
187
+ },
188
+ ];
189
+
190
+ // Try to get current workflow state if available
191
+ let workflowState: GetToolInfoResponse['workflow_states'] = undefined;
192
+ try {
193
+ const conversationContext =
194
+ await context.conversationManager.getConversationContext();
195
+ workflowState = {
196
+ current_phase: conversationContext.currentPhase,
197
+ conversation_id: conversationContext.conversationId,
198
+ plan_file_path: conversationContext.planFilePath,
199
+ };
200
+ } catch (error) {
201
+ // No active conversation - this is fine
202
+ logger.debug('No active conversation found for workflow state', {
203
+ error,
204
+ });
205
+ }
206
+
207
+ // Build the complete response
208
+ const response: GetToolInfoResponse = {
209
+ tool_name: 'Responsible Vibe MCP - Development Workflow Management',
210
+ version: '3.1.6-monorepo', // This should ideally come from package.json
211
+ purpose:
212
+ 'Structured development workflows with guided phase transitions and conversation state management',
213
+ description:
214
+ 'A Model Context Protocol server that acts as an intelligent conversation state manager and development guide for LLMs, providing structured workflows for various development tasks including bug fixes, features, architecture documentation, and more.',
215
+
216
+ available_tools: tools,
217
+ available_workflows: workflows,
218
+
219
+ core_concepts: {
220
+ phase_management:
221
+ 'Structured progression through development phases with entrance criteria and transition conditions',
222
+ plan_file_tracking:
223
+ 'Maintains development state and progress in .vibe/development-plan-*.md files with task tracking',
224
+ conversation_context:
225
+ 'Stateless operation requiring context in each whats_next() call for proper guidance',
226
+ workflow_guidance:
227
+ 'Provides phase-specific instructions and recommendations based on current development state',
228
+ },
229
+
230
+ usage_guidelines: {
231
+ required_pattern:
232
+ 'Always call whats_next() after user interactions to get context-appropriate guidance',
233
+ phase_transitions:
234
+ 'Only proceed to next phase when entrance criteria are met and current phase tasks are complete',
235
+ context_requirements:
236
+ 'Provide conversation history and context in whats_next() calls for optimal guidance',
237
+ plan_file_management:
238
+ 'Update plan file with completed tasks [x] and add new tasks as they are identified',
239
+ },
240
+ };
241
+
242
+ // Add workflow state if available
243
+ if (workflowState) {
244
+ response.workflow_states = workflowState;
245
+ }
246
+
247
+ logger.info('Successfully generated tool information', {
248
+ toolCount: tools.length,
249
+ workflowCount: workflows.length,
250
+ hasWorkflowState: !!workflowState,
251
+ });
252
+
253
+ return response;
254
+ }
255
+
256
+ /**
257
+ * Extract phase names from a workflow configuration
258
+ */
259
+ private extractWorkflowPhases(workflowInfo: unknown): string[] | undefined {
260
+ if (
261
+ workflowInfo &&
262
+ typeof workflowInfo === 'object' &&
263
+ 'states' in workflowInfo &&
264
+ workflowInfo.states &&
265
+ typeof workflowInfo.states === 'object'
266
+ ) {
267
+ return Object.keys(workflowInfo.states);
268
+ }
269
+ return undefined;
270
+ }
271
+ }
272
+
273
+ // Export type for external use
274
+ export type { GetToolInfoArgs, GetToolInfoResponse };
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Tool Handler Registry
3
+ *
4
+ * Central registry for all tool handlers. Provides registration and lookup
5
+ * functionality for tool handlers used by the MCP server.
6
+ */
7
+
8
+ import { createLogger } from '@codemcp/workflows-core';
9
+ import { WhatsNextHandler } from './whats-next.js';
10
+ import { ProceedToPhaseHandler } from './proceed-to-phase.js';
11
+ import { ConductReviewHandler } from './conduct-review.js';
12
+ import { StartDevelopmentHandler } from './start-development.js';
13
+ import { ResumeWorkflowHandler } from './resume-workflow.js';
14
+ import { ResetDevelopmentHandler } from './reset-development.js';
15
+ import { InstallWorkflowHandler } from './install-workflow.js';
16
+ import { ListWorkflowsHandler } from './list-workflows.js';
17
+ import { GetToolInfoHandler } from './get-tool-info.js';
18
+ import { SetupProjectDocsHandler } from './setup-project-docs.js';
19
+ import { NoIdeaHandler } from './no-idea.js';
20
+ import { ToolHandler, ToolRegistry } from '../types.js';
21
+
22
+ const logger = createLogger('ToolRegistry');
23
+
24
+ /**
25
+ * Default implementation of ToolRegistry
26
+ */
27
+ export class DefaultToolRegistry implements ToolRegistry {
28
+ private handlers = new Map<string, ToolHandler>();
29
+
30
+ register<T extends ToolHandler>(name: string, handler: T): void {
31
+ logger.debug('Registering tool handler', {
32
+ name,
33
+ handlerType: handler.constructor.name,
34
+ });
35
+ this.handlers.set(name, handler);
36
+ }
37
+
38
+ get(name: string): ToolHandler | undefined {
39
+ return this.handlers.get(name);
40
+ }
41
+
42
+ list(): string[] {
43
+ return Array.from(this.handlers.keys());
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Create and configure the default tool registry with all standard handlers
49
+ */
50
+ export function createToolRegistry(): ToolRegistry {
51
+ const registry = new DefaultToolRegistry();
52
+
53
+ // Register all standard tool handlers
54
+ registry.register('whats_next', new WhatsNextHandler());
55
+ registry.register('proceed_to_phase', new ProceedToPhaseHandler());
56
+ registry.register('conduct_review', new ConductReviewHandler());
57
+ registry.register('start_development', new StartDevelopmentHandler());
58
+ registry.register('resume_workflow', new ResumeWorkflowHandler());
59
+ registry.register('reset_development', new ResetDevelopmentHandler());
60
+ registry.register('install_workflow', new InstallWorkflowHandler());
61
+ registry.register('list_workflows', new ListWorkflowsHandler());
62
+ registry.register('get_tool_info', new GetToolInfoHandler());
63
+ registry.register('setup_project_docs', new SetupProjectDocsHandler());
64
+ registry.register('no_idea', new NoIdeaHandler());
65
+
66
+ logger.info('Tool registry created with handlers', {
67
+ handlers: registry.list(),
68
+ });
69
+
70
+ return registry;
71
+ }
72
+
73
+ // Export all handler types for external use
74
+ export { WhatsNextHandler } from './whats-next.js';
75
+ export { ProceedToPhaseHandler } from './proceed-to-phase.js';
76
+ export { ConductReviewHandler } from './conduct-review.js';
77
+ export { StartDevelopmentHandler } from './start-development.js';
78
+ export { ResumeWorkflowHandler } from './resume-workflow.js';
79
+ export { ResetDevelopmentHandler } from './reset-development.js';
80
+ export { InstallWorkflowHandler } from './install-workflow.js';
81
+ export { ListWorkflowsHandler } from './list-workflows.js';
82
+ export { GetToolInfoHandler } from './get-tool-info.js';
83
+ export { SetupProjectDocsHandler } from './setup-project-docs.js';
84
+ export { NoIdeaHandler } from './no-idea.js';
85
+ export {
86
+ BaseToolHandler,
87
+ ConversationRequiredToolHandler,
88
+ } from './base-tool-handler.js';
89
+
90
+ // Export argument and result types
91
+ export type { WhatsNextArgs, WhatsNextResult } from './whats-next.js';
92
+ export type {
93
+ ProceedToPhaseArgs,
94
+ ProceedToPhaseResult,
95
+ } from './proceed-to-phase.js';
96
+ export type {
97
+ ConductReviewArgs,
98
+ ConductReviewResult,
99
+ } from './conduct-review.js';
100
+ export type {
101
+ StartDevelopmentArgs,
102
+ StartDevelopmentResult,
103
+ } from './start-development.js';
104
+ export type {
105
+ ResumeWorkflowArgs,
106
+ ResumeWorkflowResult,
107
+ } from './resume-workflow.js';
108
+ export type {
109
+ ResetDevelopmentArgs,
110
+ ResetDevelopmentResult,
111
+ } from './reset-development.js';
112
+ export type { GetToolInfoArgs, GetToolInfoResponse } from './get-tool-info.js';
113
+ export type {
114
+ SetupProjectDocsArgs,
115
+ SetupProjectDocsResult,
116
+ } from './setup-project-docs.js';
117
+ export type { NoIdeaArgs, NoIdeaResponse } from './no-idea.js';