@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.
- package/.turbo/turbo-build.log +4 -0
- package/.vibe/conversation-state.sqlite +0 -0
- package/LICENSE +674 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/notification-service.d.ts +14 -0
- package/dist/notification-service.d.ts.map +1 -0
- package/dist/notification-service.js +18 -0
- package/dist/notification-service.js.map +1 -0
- package/dist/resource-handlers/conversation-state.d.ts +15 -0
- package/dist/resource-handlers/conversation-state.d.ts.map +1 -0
- package/dist/resource-handlers/conversation-state.js +40 -0
- package/dist/resource-handlers/conversation-state.js.map +1 -0
- package/dist/resource-handlers/development-plan.d.ts +14 -0
- package/dist/resource-handlers/development-plan.d.ts.map +1 -0
- package/dist/resource-handlers/development-plan.js +31 -0
- package/dist/resource-handlers/development-plan.js.map +1 -0
- package/dist/resource-handlers/index.d.ts +24 -0
- package/dist/resource-handlers/index.d.ts.map +1 -0
- package/dist/resource-handlers/index.js +62 -0
- package/dist/resource-handlers/index.js.map +1 -0
- package/dist/resource-handlers/system-prompt.d.ts +15 -0
- package/dist/resource-handlers/system-prompt.d.ts.map +1 -0
- package/dist/resource-handlers/system-prompt.js +40 -0
- package/dist/resource-handlers/system-prompt.js.map +1 -0
- package/dist/resource-handlers/workflow-resource.d.ts +15 -0
- package/dist/resource-handlers/workflow-resource.d.ts.map +1 -0
- package/dist/resource-handlers/workflow-resource.js +85 -0
- package/dist/resource-handlers/workflow-resource.js.map +1 -0
- package/dist/response-renderer.d.ts +30 -0
- package/dist/response-renderer.d.ts.map +1 -0
- package/dist/response-renderer.js +94 -0
- package/dist/response-renderer.js.map +1 -0
- package/dist/server-config.d.ts +34 -0
- package/dist/server-config.d.ts.map +1 -0
- package/dist/server-config.js +486 -0
- package/dist/server-config.js.map +1 -0
- package/dist/server-helpers.d.ts +62 -0
- package/dist/server-helpers.d.ts.map +1 -0
- package/dist/server-helpers.js +156 -0
- package/dist/server-helpers.js.map +1 -0
- package/dist/server-implementation.d.ts +74 -0
- package/dist/server-implementation.d.ts.map +1 -0
- package/dist/server-implementation.js +201 -0
- package/dist/server-implementation.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +5 -0
- package/dist/server.js.map +1 -0
- package/dist/tool-handlers/base-tool-handler.d.ts +50 -0
- package/dist/tool-handlers/base-tool-handler.d.ts.map +1 -0
- package/dist/tool-handlers/base-tool-handler.js +74 -0
- package/dist/tool-handlers/base-tool-handler.js.map +1 -0
- package/dist/tool-handlers/conduct-review.d.ts +49 -0
- package/dist/tool-handlers/conduct-review.d.ts.map +1 -0
- package/dist/tool-handlers/conduct-review.js +105 -0
- package/dist/tool-handlers/conduct-review.js.map +1 -0
- package/dist/tool-handlers/get-tool-info.d.ts +76 -0
- package/dist/tool-handlers/get-tool-info.d.ts.map +1 -0
- package/dist/tool-handlers/get-tool-info.js +168 -0
- package/dist/tool-handlers/get-tool-info.js.map +1 -0
- package/dist/tool-handlers/index.d.ts +42 -0
- package/dist/tool-handlers/index.d.ts.map +1 -0
- package/dist/tool-handlers/index.js +74 -0
- package/dist/tool-handlers/index.js.map +1 -0
- package/dist/tool-handlers/install-workflow.d.ts +48 -0
- package/dist/tool-handlers/install-workflow.d.ts.map +1 -0
- package/dist/tool-handlers/install-workflow.js +131 -0
- package/dist/tool-handlers/install-workflow.js.map +1 -0
- package/dist/tool-handlers/list-workflows.d.ts +47 -0
- package/dist/tool-handlers/list-workflows.d.ts.map +1 -0
- package/dist/tool-handlers/list-workflows.js +58 -0
- package/dist/tool-handlers/list-workflows.js.map +1 -0
- package/dist/tool-handlers/no-idea.d.ts +41 -0
- package/dist/tool-handlers/no-idea.d.ts.map +1 -0
- package/dist/tool-handlers/no-idea.js +29 -0
- package/dist/tool-handlers/no-idea.js.map +1 -0
- package/dist/tool-handlers/proceed-to-phase.d.ts +39 -0
- package/dist/tool-handlers/proceed-to-phase.d.ts.map +1 -0
- package/dist/tool-handlers/proceed-to-phase.js +109 -0
- package/dist/tool-handlers/proceed-to-phase.js.map +1 -0
- package/dist/tool-handlers/reset-development.d.ts +31 -0
- package/dist/tool-handlers/reset-development.d.ts.map +1 -0
- package/dist/tool-handlers/reset-development.js +48 -0
- package/dist/tool-handlers/reset-development.js.map +1 -0
- package/dist/tool-handlers/resume-workflow.d.ts +88 -0
- package/dist/tool-handlers/resume-workflow.d.ts.map +1 -0
- package/dist/tool-handlers/resume-workflow.js +213 -0
- package/dist/tool-handlers/resume-workflow.js.map +1 -0
- package/dist/tool-handlers/setup-project-docs.d.ts +36 -0
- package/dist/tool-handlers/setup-project-docs.d.ts.map +1 -0
- package/dist/tool-handlers/setup-project-docs.js +136 -0
- package/dist/tool-handlers/setup-project-docs.js.map +1 -0
- package/dist/tool-handlers/start-development.d.ts +82 -0
- package/dist/tool-handlers/start-development.d.ts.map +1 -0
- package/dist/tool-handlers/start-development.js +448 -0
- package/dist/tool-handlers/start-development.js.map +1 -0
- package/dist/tool-handlers/whats-next.d.ts +42 -0
- package/dist/tool-handlers/whats-next.d.ts.map +1 -0
- package/dist/tool-handlers/whats-next.js +118 -0
- package/dist/tool-handlers/whats-next.js.map +1 -0
- package/dist/types.d.ts +114 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +29 -0
- package/src/index.ts +93 -0
- package/src/notification-service.ts +23 -0
- package/src/resource-handlers/conversation-state.ts +55 -0
- package/src/resource-handlers/development-plan.ts +48 -0
- package/src/resource-handlers/index.ts +73 -0
- package/src/resource-handlers/system-prompt.ts +55 -0
- package/src/resource-handlers/workflow-resource.ts +126 -0
- package/src/response-renderer.ts +116 -0
- package/src/server-config.ts +744 -0
- package/src/server-helpers.ts +225 -0
- package/src/server-implementation.ts +277 -0
- package/src/server.ts +9 -0
- package/src/tool-handlers/base-tool-handler.ts +141 -0
- package/src/tool-handlers/conduct-review.ts +191 -0
- package/src/tool-handlers/get-tool-info.ts +274 -0
- package/src/tool-handlers/index.ts +117 -0
- package/src/tool-handlers/install-workflow.ts +185 -0
- package/src/tool-handlers/list-workflows.ts +94 -0
- package/src/tool-handlers/no-idea.ts +47 -0
- package/src/tool-handlers/proceed-to-phase.ts +205 -0
- package/src/tool-handlers/reset-development.ts +90 -0
- package/src/tool-handlers/resume-workflow.ts +380 -0
- package/src/tool-handlers/setup-project-docs.ts +226 -0
- package/src/tool-handlers/start-development.ts +685 -0
- package/src/tool-handlers/whats-next.ts +235 -0
- package/src/types.ts +130 -0
- package/test/e2e/core-functionality.test.ts +176 -0
- package/test/e2e/mcp-contract.test.ts +540 -0
- package/test/e2e/plan-management.test.ts +331 -0
- package/test/e2e/state-management.test.ts +392 -0
- package/test/e2e/workflow-integration.test.ts +506 -0
- package/test/unit/commit-behaviour-interface.test.ts +244 -0
- package/test/unit/conduct-review.test.ts +151 -0
- package/test/unit/reset-functionality.test.ts +72 -0
- package/test/unit/resume-workflow.test.ts +192 -0
- package/test/unit/server-tools.test.ts +311 -0
- package/test/unit/setup-project-docs-handler.test.ts +267 -0
- package/test/unit/start-development-artifact-detection.test.ts +387 -0
- package/test/unit/start-development-gitignore.test.ts +178 -0
- package/test/unit/system-prompt-resource.test.ts +101 -0
- package/test/unit/tool-handlers/no-idea.test.ts +40 -0
- package/test/utils/e2e-test-setup.ts +453 -0
- package/test/utils/run-server-in-dir.sh +27 -0
- package/test/utils/temp-files.ts +308 -0
- package/test/utils/test-access.ts +79 -0
- package/test/utils/test-helpers.ts +286 -0
- package/test/utils/test-setup.ts +78 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +17 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StartDevelopment Tool Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles initialization of development workflow and transition to the initial
|
|
5
|
+
* development phase. Allows users to choose from predefined workflows or use a custom workflow.
|
|
6
|
+
*/
|
|
7
|
+
import { BaseToolHandler } from './base-tool-handler.js';
|
|
8
|
+
import { validateRequiredArgs } from '../server-helpers.js';
|
|
9
|
+
import { basename } from 'node:path';
|
|
10
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
11
|
+
import { resolve } from 'node:path';
|
|
12
|
+
import { GitManager } from '@codemcp/workflows-core';
|
|
13
|
+
import { ProjectDocsManager } from '@codemcp/workflows-core';
|
|
14
|
+
/**
|
|
15
|
+
* StartDevelopment tool handler implementation
|
|
16
|
+
*/
|
|
17
|
+
export class StartDevelopmentHandler extends BaseToolHandler {
|
|
18
|
+
projectDocsManager;
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.projectDocsManager = new ProjectDocsManager();
|
|
22
|
+
}
|
|
23
|
+
async executeHandler(args, context) {
|
|
24
|
+
// Validate required arguments
|
|
25
|
+
validateRequiredArgs(args, ['workflow']);
|
|
26
|
+
const selectedWorkflow = args.workflow;
|
|
27
|
+
const requireReviews = args.require_reviews ?? false;
|
|
28
|
+
// Process git commit configuration
|
|
29
|
+
const isGitRepository = GitManager.isGitRepository(context.projectPath);
|
|
30
|
+
// Translate commit_behaviour to internal git config
|
|
31
|
+
const commitBehaviour = args.commit_behaviour ?? (isGitRepository ? 'end' : 'none');
|
|
32
|
+
const gitCommitConfig = {
|
|
33
|
+
enabled: commitBehaviour !== 'none',
|
|
34
|
+
commitOnStep: commitBehaviour === 'step',
|
|
35
|
+
commitOnPhase: commitBehaviour === 'phase',
|
|
36
|
+
commitOnComplete: commitBehaviour === 'end' ||
|
|
37
|
+
commitBehaviour === 'step' ||
|
|
38
|
+
commitBehaviour === 'phase',
|
|
39
|
+
initialMessage: 'Development session',
|
|
40
|
+
startCommitHash: GitManager.getCurrentCommitHash(context.projectPath) || undefined,
|
|
41
|
+
};
|
|
42
|
+
this.logger.debug('Processing start_development request', {
|
|
43
|
+
selectedWorkflow,
|
|
44
|
+
projectPath: context.projectPath,
|
|
45
|
+
commitBehaviour,
|
|
46
|
+
gitCommitConfig,
|
|
47
|
+
});
|
|
48
|
+
// Validate workflow selection (ensure project workflows are loaded first)
|
|
49
|
+
context.workflowManager.loadProjectWorkflows(context.projectPath);
|
|
50
|
+
if (!context.workflowManager.validateWorkflowName(selectedWorkflow, context.projectPath)) {
|
|
51
|
+
const availableWorkflows = context.workflowManager.getWorkflowNames();
|
|
52
|
+
throw new Error(`Invalid workflow: ${selectedWorkflow}. Available workflows: ${availableWorkflows.join(', ')}`);
|
|
53
|
+
}
|
|
54
|
+
// Check for project documentation artifacts and guide setup if needed
|
|
55
|
+
const artifactGuidance = await this.checkProjectArtifacts(context.projectPath, selectedWorkflow, context);
|
|
56
|
+
if (artifactGuidance) {
|
|
57
|
+
return artifactGuidance;
|
|
58
|
+
}
|
|
59
|
+
// Check if user is on main/master branch and prompt for branch creation
|
|
60
|
+
const currentBranch = this.getCurrentGitBranch(context.projectPath);
|
|
61
|
+
if (currentBranch === 'main' || currentBranch === 'master') {
|
|
62
|
+
const suggestedBranchName = this.generateBranchSuggestion();
|
|
63
|
+
const branchPromptResponse = {
|
|
64
|
+
phase: 'branch-prompt',
|
|
65
|
+
instructions: `You're currently on the ${currentBranch} branch. It's recommended to create a feature branch for development. Propose a branch creation by suggesting a branch command to the user call start_development again.\n\nSuggested command: \`git checkout -b ${suggestedBranchName}\`\n\nPlease create a new branch and then call start_development again to begin development.`,
|
|
66
|
+
plan_file_path: '',
|
|
67
|
+
conversation_id: '',
|
|
68
|
+
workflow: {},
|
|
69
|
+
};
|
|
70
|
+
this.logger.debug('User on main/master branch, prompting for branch creation', {
|
|
71
|
+
currentBranch,
|
|
72
|
+
suggestedBranchName,
|
|
73
|
+
});
|
|
74
|
+
return branchPromptResponse;
|
|
75
|
+
}
|
|
76
|
+
// Create or get conversation context with the selected workflow
|
|
77
|
+
const conversationContext = await context.conversationManager.createConversationContext(selectedWorkflow);
|
|
78
|
+
const currentPhase = conversationContext.currentPhase;
|
|
79
|
+
// Load the selected workflow
|
|
80
|
+
const stateMachine = context.workflowManager.loadWorkflowForProject(conversationContext.projectPath, selectedWorkflow);
|
|
81
|
+
const initialState = stateMachine.initial_state;
|
|
82
|
+
// Check if development is already started
|
|
83
|
+
if (currentPhase !== initialState) {
|
|
84
|
+
throw new Error(`Development already started. Current phase is '${currentPhase}', not initial state '${initialState}'. Use whats_next() to continue development.`);
|
|
85
|
+
}
|
|
86
|
+
// The initial state IS the first development phase - it's explicitly modeled
|
|
87
|
+
const targetPhase = initialState;
|
|
88
|
+
// Transition to the initial development phase
|
|
89
|
+
const transitionResult = await context.transitionEngine.handleExplicitTransition(currentPhase, targetPhase, conversationContext.projectPath, 'Development initialization', selectedWorkflow);
|
|
90
|
+
// Update conversation state with workflow, phase, and git commit configuration
|
|
91
|
+
await context.conversationManager.updateConversationState(conversationContext.conversationId, {
|
|
92
|
+
currentPhase: transitionResult.newPhase,
|
|
93
|
+
workflowName: selectedWorkflow,
|
|
94
|
+
gitCommitConfig: gitCommitConfig,
|
|
95
|
+
requireReviewsBeforePhaseTransition: requireReviews,
|
|
96
|
+
});
|
|
97
|
+
// Set state machine on plan manager before creating plan file
|
|
98
|
+
context.planManager.setStateMachine(stateMachine);
|
|
99
|
+
// Ensure plan file exists
|
|
100
|
+
await context.planManager.ensurePlanFile(conversationContext.planFilePath, conversationContext.projectPath, conversationContext.gitBranch);
|
|
101
|
+
// Ensure .vibe/.gitignore exists to exclude SQLite files for git repositories
|
|
102
|
+
this.ensureGitignoreEntry(conversationContext.projectPath);
|
|
103
|
+
// Generate workflow documentation URL
|
|
104
|
+
const workflowDocumentationUrl = this.generateWorkflowDocumentationUrl(selectedWorkflow);
|
|
105
|
+
// Generate instructions with simple i18n guidance
|
|
106
|
+
const baseInstructions = `Look at the plan file (${conversationContext.planFilePath}). Define entrance criteria for each phase of the workflow except the initial phase. Those criteria shall be based on the contents of the previous phase. \n Example: \n \`\`\`\n ## Design\n\n ### Phase Entrance Criteria:\n - [ ] The requirements have been thoroughly defined.\n - [ ] Alternatives have been evaluated and are documented. \n - [ ] It's clear what's in scope and out of scope\n \`\`\`\n \n IMPORTANT: Once you added reasonable entrance call the whats_next() tool to get guided instructions for the next current phase.`;
|
|
107
|
+
const i18nGuidance = `\n\nNOTE: If the user is communicating in a non-English language, please translate the plan file content to that language while keeping the structure intact, and continue all interactions in the user's language.`;
|
|
108
|
+
// Add workflow documentation information if available
|
|
109
|
+
const workflowDocumentationInfo = workflowDocumentationUrl
|
|
110
|
+
? `\n\nInform the user about the chose workflow: He can visit: ${workflowDocumentationUrl} to get detailed information.`
|
|
111
|
+
: '';
|
|
112
|
+
const finalInstructions = baseInstructions + workflowDocumentationInfo + i18nGuidance;
|
|
113
|
+
const response = {
|
|
114
|
+
phase: transitionResult.newPhase,
|
|
115
|
+
instructions: finalInstructions,
|
|
116
|
+
plan_file_path: conversationContext.planFilePath,
|
|
117
|
+
conversation_id: conversationContext.conversationId,
|
|
118
|
+
workflow: stateMachine,
|
|
119
|
+
workflowDocumentationUrl,
|
|
120
|
+
};
|
|
121
|
+
// Log interaction
|
|
122
|
+
await this.logInteraction(context, conversationContext.conversationId, 'start_development', args, response, transitionResult.newPhase);
|
|
123
|
+
return response;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Check if project documentation artifacts exist and provide setup guidance if needed
|
|
127
|
+
* Dynamically analyzes the selected workflow to determine which documents are referenced
|
|
128
|
+
* Blocks workflow start if the workflow requires documentation
|
|
129
|
+
*/
|
|
130
|
+
async checkProjectArtifacts(projectPath, workflowName, context) {
|
|
131
|
+
try {
|
|
132
|
+
// Load the workflow to analyze its content
|
|
133
|
+
const stateMachine = context.workflowManager.loadWorkflowForProject(projectPath, workflowName);
|
|
134
|
+
// Check if this workflow requires documentation (defaults to false)
|
|
135
|
+
const requiresDocumentation = stateMachine.metadata?.requiresDocumentation ?? false;
|
|
136
|
+
// If workflow doesn't require documentation, skip artifact check entirely
|
|
137
|
+
if (!requiresDocumentation) {
|
|
138
|
+
this.logger.debug('Workflow does not require documentation, skipping artifact check', { workflowName, requiresDocumentation });
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
// Analyze workflow content to detect referenced document variables
|
|
142
|
+
const referencedVariables = this.analyzeWorkflowDocumentReferences(stateMachine, projectPath);
|
|
143
|
+
// If no document variables are referenced, skip artifact check
|
|
144
|
+
if (referencedVariables.length === 0) {
|
|
145
|
+
this.logger.debug('No document variables found in workflow, skipping artifact check', { workflowName });
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
// Check which referenced documents are missing
|
|
149
|
+
const docsInfo = await this.projectDocsManager.getProjectDocsInfo(projectPath);
|
|
150
|
+
const missingDocs = this.getMissingReferencedDocuments(referencedVariables, docsInfo, projectPath);
|
|
151
|
+
// If all referenced documents exist, continue with normal flow
|
|
152
|
+
if (missingDocs.length === 0) {
|
|
153
|
+
this.logger.debug('All referenced project artifacts exist, continuing with development', {
|
|
154
|
+
workflowName,
|
|
155
|
+
referencedVariables,
|
|
156
|
+
});
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
// Generate guidance for setting up missing artifacts
|
|
160
|
+
const setupGuidance = await this.generateArtifactSetupGuidance(missingDocs, workflowName, docsInfo, referencedVariables);
|
|
161
|
+
this.logger.info('Missing required project artifacts detected for workflow that requires documentation', {
|
|
162
|
+
workflowName,
|
|
163
|
+
requiresDocumentation,
|
|
164
|
+
referencedVariables,
|
|
165
|
+
missingDocs,
|
|
166
|
+
projectPath,
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
phase: 'artifact-setup',
|
|
170
|
+
instructions: setupGuidance,
|
|
171
|
+
plan_file_path: '',
|
|
172
|
+
conversation_id: '',
|
|
173
|
+
workflow: {},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
this.logger.warn('Failed to analyze workflow for document references, proceeding without artifact check', {
|
|
178
|
+
workflowName,
|
|
179
|
+
error: error instanceof Error ? error.message : String(error),
|
|
180
|
+
});
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Analyze workflow content to detect document variable references
|
|
186
|
+
*/
|
|
187
|
+
analyzeWorkflowDocumentReferences(stateMachine, projectPath) {
|
|
188
|
+
// Get available document variables from ProjectDocsManager
|
|
189
|
+
const variableSubstitutions = this.projectDocsManager.getVariableSubstitutions(projectPath);
|
|
190
|
+
const documentVariables = Object.keys(variableSubstitutions);
|
|
191
|
+
const referencedVariables = new Set();
|
|
192
|
+
// Convert the entire state machine to a string for analysis
|
|
193
|
+
const workflowContent = JSON.stringify(stateMachine);
|
|
194
|
+
// Check for each document variable
|
|
195
|
+
for (const variable of documentVariables) {
|
|
196
|
+
if (workflowContent.includes(variable)) {
|
|
197
|
+
referencedVariables.add(variable);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
this.logger.debug('Analyzed workflow for document references', {
|
|
201
|
+
workflowContent: workflowContent.length + ' characters',
|
|
202
|
+
availableVariables: documentVariables,
|
|
203
|
+
referencedVariables: Array.from(referencedVariables),
|
|
204
|
+
});
|
|
205
|
+
return Array.from(referencedVariables);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Determine which referenced documents are missing
|
|
209
|
+
*/
|
|
210
|
+
getMissingReferencedDocuments(referencedVariables, docsInfo, projectPath) {
|
|
211
|
+
const missingDocs = [];
|
|
212
|
+
// Get variable substitutions to derive the mapping
|
|
213
|
+
const variableSubstitutions = this.projectDocsManager.getVariableSubstitutions(projectPath);
|
|
214
|
+
// Create reverse mapping from variable to document type
|
|
215
|
+
const variableToDocMap = {};
|
|
216
|
+
for (const [variable, path] of Object.entries(variableSubstitutions)) {
|
|
217
|
+
// Extract document type from path (e.g., 'architecture' from 'architecture.md')
|
|
218
|
+
const filename = path.split('/').pop() || '';
|
|
219
|
+
const docType = filename.replace('.md', '');
|
|
220
|
+
variableToDocMap[variable] = docType;
|
|
221
|
+
}
|
|
222
|
+
for (const variable of referencedVariables) {
|
|
223
|
+
const docType = variableToDocMap[variable];
|
|
224
|
+
if (docType && docType in docsInfo) {
|
|
225
|
+
const docInfo = docsInfo[docType];
|
|
226
|
+
if (docInfo && !docInfo.exists) {
|
|
227
|
+
missingDocs.push(`${docType}.md`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return missingDocs;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Generate guidance for setting up missing project artifacts
|
|
235
|
+
*/
|
|
236
|
+
async generateArtifactSetupGuidance(missingDocs, workflowName, docsInfo, referencedVariables) {
|
|
237
|
+
const missingList = missingDocs.map(doc => `- ${doc}`).join('\n');
|
|
238
|
+
const existingDocs = [];
|
|
239
|
+
if (docsInfo.architecture.exists) {
|
|
240
|
+
const fileName = basename(docsInfo.architecture.path);
|
|
241
|
+
existingDocs.push(`✅ ${fileName}`);
|
|
242
|
+
}
|
|
243
|
+
if (docsInfo.requirements.exists) {
|
|
244
|
+
const fileName = basename(docsInfo.requirements.path);
|
|
245
|
+
existingDocs.push(`✅ ${fileName}`);
|
|
246
|
+
}
|
|
247
|
+
if (docsInfo.design.exists) {
|
|
248
|
+
const fileName = basename(docsInfo.design.path);
|
|
249
|
+
existingDocs.push(`✅ ${fileName}`);
|
|
250
|
+
}
|
|
251
|
+
const existingList = existingDocs.length > 0
|
|
252
|
+
? `\n\n**Existing Documents:**\n${existingDocs.join('\n')}`
|
|
253
|
+
: '';
|
|
254
|
+
const referencedVariablesList = referencedVariables
|
|
255
|
+
.map(v => `\`${v}\``)
|
|
256
|
+
.join(', ');
|
|
257
|
+
// Get available templates dynamically
|
|
258
|
+
const availableTemplates = await this.projectDocsManager.templateManager.getAvailableTemplates();
|
|
259
|
+
const defaults = await this.projectDocsManager.templateManager.getDefaults();
|
|
260
|
+
// Generate template options dynamically
|
|
261
|
+
const templateOptionsText = this.generateTemplateOptionsText(availableTemplates);
|
|
262
|
+
return `## Project Documentation Setup Required
|
|
263
|
+
|
|
264
|
+
The **${workflowName}** workflow references project documentation that doesn't exist yet.
|
|
265
|
+
|
|
266
|
+
**Referenced Variables:** ${referencedVariablesList}
|
|
267
|
+
|
|
268
|
+
**Missing Documents:**
|
|
269
|
+
${missingList}${existingList}
|
|
270
|
+
|
|
271
|
+
## 🚀 **Quick Setup**
|
|
272
|
+
|
|
273
|
+
Use the \`setup_project_docs\` tool to create these documents with templates:
|
|
274
|
+
|
|
275
|
+
\`\`\`
|
|
276
|
+
setup_project_docs({
|
|
277
|
+
architecture: "${defaults.architecture}", // or other available options
|
|
278
|
+
requirements: "${defaults.requirements}", // or other available options
|
|
279
|
+
design: "${defaults.design}" // or other available options
|
|
280
|
+
})
|
|
281
|
+
\`\`\`
|
|
282
|
+
|
|
283
|
+
${templateOptionsText}
|
|
284
|
+
|
|
285
|
+
## ⚡ **Next Steps**
|
|
286
|
+
|
|
287
|
+
1. **Call \`setup_project_docs\`** with your preferred templates
|
|
288
|
+
2. **Call \`start_development\`** again to begin the ${workflowName} workflow
|
|
289
|
+
3. The workflow will reference these documents using the detected variables: ${referencedVariablesList}
|
|
290
|
+
|
|
291
|
+
**Note:** You can also proceed without structured docs, but the workflow instructions will reference missing files.`;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Generate template options text dynamically
|
|
295
|
+
*/
|
|
296
|
+
generateTemplateOptionsText(availableTemplates) {
|
|
297
|
+
const sections = [];
|
|
298
|
+
if (availableTemplates.architecture.length > 0) {
|
|
299
|
+
const archOptions = availableTemplates.architecture
|
|
300
|
+
.map(template => {
|
|
301
|
+
const description = this.getTemplateDescription(template, 'architecture');
|
|
302
|
+
return `- **${template}**: ${description}`;
|
|
303
|
+
})
|
|
304
|
+
.join('\n');
|
|
305
|
+
sections.push(`**Architecture Templates:**\n${archOptions}`);
|
|
306
|
+
}
|
|
307
|
+
if (availableTemplates.requirements.length > 0) {
|
|
308
|
+
const reqOptions = availableTemplates.requirements
|
|
309
|
+
.map(template => {
|
|
310
|
+
const description = this.getTemplateDescription(template, 'requirements');
|
|
311
|
+
return `- **${template}**: ${description}`;
|
|
312
|
+
})
|
|
313
|
+
.join('\n');
|
|
314
|
+
sections.push(`**Requirements Templates:**\n${reqOptions}`);
|
|
315
|
+
}
|
|
316
|
+
if (availableTemplates.design.length > 0) {
|
|
317
|
+
const designOptions = availableTemplates.design
|
|
318
|
+
.map(template => {
|
|
319
|
+
const description = this.getTemplateDescription(template, 'design');
|
|
320
|
+
return `- **${template}**: ${description}`;
|
|
321
|
+
})
|
|
322
|
+
.join('\n');
|
|
323
|
+
sections.push(`**Design Templates:**\n${designOptions}`);
|
|
324
|
+
}
|
|
325
|
+
return sections.length > 0
|
|
326
|
+
? `## 📋 **Template Options**\n\n${sections.join('\n\n')}`
|
|
327
|
+
: '';
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get description for a template based on its name and type
|
|
331
|
+
*/
|
|
332
|
+
getTemplateDescription(template, type) {
|
|
333
|
+
switch (template) {
|
|
334
|
+
case 'arc42':
|
|
335
|
+
return 'Comprehensive software architecture template with diagrams';
|
|
336
|
+
case 'ears':
|
|
337
|
+
return 'WHEN...THEN format for clear, testable requirements';
|
|
338
|
+
case 'comprehensive':
|
|
339
|
+
return 'Full implementation guide with testing strategy';
|
|
340
|
+
case 'freestyle':
|
|
341
|
+
return `Simple, flexible ${type} documentation`;
|
|
342
|
+
default:
|
|
343
|
+
return `${template} format for ${type} documentation`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Generate workflow documentation URL for predefined workflows
|
|
348
|
+
* Returns undefined for custom workflows
|
|
349
|
+
*/
|
|
350
|
+
generateWorkflowDocumentationUrl(workflowName) {
|
|
351
|
+
// Don't generate URL for custom workflows
|
|
352
|
+
if (workflowName === 'custom') {
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
// Generate URL for predefined workflows
|
|
356
|
+
return `https://mrsimpson.github.io/responsible-vibe-mcp/workflows/${workflowName}`;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Get the current git branch for a project
|
|
360
|
+
* Uses the same logic as ConversationManager but locally accessible
|
|
361
|
+
*/
|
|
362
|
+
getCurrentGitBranch(projectPath) {
|
|
363
|
+
try {
|
|
364
|
+
const { execSync } = require('node:child_process');
|
|
365
|
+
const { existsSync } = require('node:fs');
|
|
366
|
+
// Check if this is a git repository
|
|
367
|
+
if (!existsSync(`${projectPath}/.git`)) {
|
|
368
|
+
this.logger.debug('Not a git repository, using "default" as branch name', { projectPath });
|
|
369
|
+
return 'default';
|
|
370
|
+
}
|
|
371
|
+
// Get current branch name
|
|
372
|
+
const branch = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
373
|
+
cwd: projectPath,
|
|
374
|
+
encoding: 'utf-8',
|
|
375
|
+
stdio: ['ignore', 'pipe', 'ignore'], // Suppress stderr
|
|
376
|
+
}).trim();
|
|
377
|
+
this.logger.debug('Detected git branch', { projectPath, branch });
|
|
378
|
+
return branch;
|
|
379
|
+
}
|
|
380
|
+
catch (_error) {
|
|
381
|
+
this.logger.debug('Failed to get git branch, using "default" as branch name', { projectPath });
|
|
382
|
+
return 'default';
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Generate a suggested branch name for feature development
|
|
387
|
+
*/
|
|
388
|
+
generateBranchSuggestion() {
|
|
389
|
+
const timestamp = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
|
390
|
+
return `feature/development-${timestamp}`;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Ensure .gitignore exists in .vibe folder to exclude SQLite files
|
|
394
|
+
* This function is idempotent and self-contained within the .vibe directory
|
|
395
|
+
*/
|
|
396
|
+
ensureGitignoreEntry(projectPath) {
|
|
397
|
+
try {
|
|
398
|
+
// Check if this is a git repository
|
|
399
|
+
if (!existsSync(`${projectPath}/.git`)) {
|
|
400
|
+
this.logger.debug('Not a git repository, skipping .gitignore management', { projectPath });
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const vibeDir = resolve(projectPath, '.vibe');
|
|
404
|
+
const gitignorePath = resolve(vibeDir, '.gitignore');
|
|
405
|
+
// Ensure .vibe directory exists
|
|
406
|
+
if (!existsSync(vibeDir)) {
|
|
407
|
+
mkdirSync(vibeDir, { recursive: true });
|
|
408
|
+
}
|
|
409
|
+
// Content for .vibe/.gitignore
|
|
410
|
+
const gitignoreContent = `# Exclude SQLite database files
|
|
411
|
+
*.sqlite
|
|
412
|
+
*.sqlite-*
|
|
413
|
+
conversation-state.sqlite*
|
|
414
|
+
`;
|
|
415
|
+
// Check if .gitignore already exists and has the right content
|
|
416
|
+
if (existsSync(gitignorePath)) {
|
|
417
|
+
try {
|
|
418
|
+
const existingContent = readFileSync(gitignorePath, 'utf-8');
|
|
419
|
+
if (existingContent.includes('*.sqlite') &&
|
|
420
|
+
existingContent.includes('conversation-state.sqlite')) {
|
|
421
|
+
this.logger.debug('.vibe/.gitignore already exists with SQLite exclusions', { gitignorePath });
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
this.logger.warn('Failed to read existing .vibe/.gitignore, will recreate', {
|
|
427
|
+
gitignorePath,
|
|
428
|
+
error: error instanceof Error ? error.message : String(error),
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
// Write the .gitignore file
|
|
433
|
+
writeFileSync(gitignorePath, gitignoreContent, 'utf-8');
|
|
434
|
+
this.logger.info('Created .vibe/.gitignore to exclude SQLite files', {
|
|
435
|
+
projectPath,
|
|
436
|
+
gitignorePath,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
// Log warning but don't fail development start
|
|
441
|
+
this.logger.warn('Failed to create .vibe/.gitignore, continuing with development start', {
|
|
442
|
+
projectPath,
|
|
443
|
+
error: error instanceof Error ? error.message : String(error),
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
//# sourceMappingURL=start-development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-development.js","sourceRoot":"","sources":["../../src/tool-handlers/start-development.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAmB,MAAM,yBAAyB,CAAC;AAwB9E;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,eAG5C;IACS,kBAAkB,CAAqB;IAE/C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACrD,CAAC;IAES,KAAK,CAAC,cAAc,CAC5B,IAA0B,EAC1B,OAAsB;QAEtB,8BAA8B;QAC9B,oBAAoB,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAEzC,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC;QACvC,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,IAAI,KAAK,CAAC;QAErD,mCAAmC;QACnC,MAAM,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAExE,oDAA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C,MAAM,CAAC,IAAI,CACd,yDAAyD,EACzD;wBACE,aAAa;wBACb,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;qBAC9D,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,4BAA4B;YAC5B,aAAa,CAAC,aAAa,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;YAExD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kDAAkD,EAAE;gBACnE,WAAW;gBACX,aAAa;aACd,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,+CAA+C;YAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,sEAAsE,EACtE;gBACE,WAAW;gBACX,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WhatsNext Tool Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles the whats_next tool which analyzes conversation context and
|
|
5
|
+
* determines the next development phase with specific instructions for the LLM.
|
|
6
|
+
*/
|
|
7
|
+
import { ConversationRequiredToolHandler } from './base-tool-handler.js';
|
|
8
|
+
import type { ConversationContext } from '@codemcp/workflows-core';
|
|
9
|
+
import { ServerContext } from '../types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Arguments for the whats_next tool
|
|
12
|
+
*/
|
|
13
|
+
export interface WhatsNextArgs {
|
|
14
|
+
context?: string;
|
|
15
|
+
user_input?: string;
|
|
16
|
+
conversation_summary?: string;
|
|
17
|
+
recent_messages?: Array<{
|
|
18
|
+
role: 'user' | 'assistant';
|
|
19
|
+
content: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Response from the whats_next tool
|
|
24
|
+
*/
|
|
25
|
+
export interface WhatsNextResult {
|
|
26
|
+
phase: string;
|
|
27
|
+
instructions: string;
|
|
28
|
+
plan_file_path: string;
|
|
29
|
+
is_modeled_transition: boolean;
|
|
30
|
+
conversation_id: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* WhatsNext tool handler implementation
|
|
34
|
+
*/
|
|
35
|
+
export declare class WhatsNextHandler extends ConversationRequiredToolHandler<WhatsNextArgs, WhatsNextResult> {
|
|
36
|
+
protected executeWithConversation(args: WhatsNextArgs, context: ServerContext, conversationContext: ConversationContext): Promise<WhatsNextResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Determines whether conversation state should be updated for a phase transition
|
|
39
|
+
*/
|
|
40
|
+
private shouldUpdateConversationState;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=whats-next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whats-next.d.ts","sourceRoot":"","sources":["../../src/tool-handlers/whats-next.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,KAAK,CAAC;QACtB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,+BAA+B,CACnE,aAAa,EACb,eAAe,CAChB;cACiB,uBAAuB,CACrC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,aAAa,EACtB,mBAAmB,EAAE,mBAAmB,GACvC,OAAO,CAAC,eAAe,CAAC;IA8I3B;;OAEG;YACW,6BAA6B;CA2C5C"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WhatsNext Tool Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles the whats_next tool which analyzes conversation context and
|
|
5
|
+
* determines the next development phase with specific instructions for the LLM.
|
|
6
|
+
*/
|
|
7
|
+
import { ConversationRequiredToolHandler } from './base-tool-handler.js';
|
|
8
|
+
/**
|
|
9
|
+
* WhatsNext tool handler implementation
|
|
10
|
+
*/
|
|
11
|
+
export class WhatsNextHandler extends ConversationRequiredToolHandler {
|
|
12
|
+
async executeWithConversation(args, context, conversationContext) {
|
|
13
|
+
const { context: requestContext = '', user_input = '', conversation_summary = '', recent_messages = [], } = args;
|
|
14
|
+
const conversationId = conversationContext.conversationId;
|
|
15
|
+
const currentPhase = conversationContext.currentPhase;
|
|
16
|
+
this.logger.debug('Processing whats_next request', {
|
|
17
|
+
conversationId,
|
|
18
|
+
currentPhase,
|
|
19
|
+
hasContext: !!requestContext,
|
|
20
|
+
hasUserInput: !!user_input,
|
|
21
|
+
});
|
|
22
|
+
// Ensure state machine is loaded for this project
|
|
23
|
+
this.ensureStateMachineForProject(context, conversationContext.projectPath, conversationContext.workflowName);
|
|
24
|
+
// Ensure plan file exists
|
|
25
|
+
await context.planManager.ensurePlanFile(conversationContext.planFilePath, conversationContext.projectPath, conversationContext.gitBranch);
|
|
26
|
+
// Analyze phase transition
|
|
27
|
+
const transitionResult = await context.transitionEngine.analyzePhaseTransition({
|
|
28
|
+
currentPhase,
|
|
29
|
+
projectPath: conversationContext.projectPath,
|
|
30
|
+
userInput: user_input,
|
|
31
|
+
context: requestContext,
|
|
32
|
+
conversationSummary: conversation_summary,
|
|
33
|
+
recentMessages: recent_messages,
|
|
34
|
+
conversationId: conversationContext.conversationId,
|
|
35
|
+
});
|
|
36
|
+
// Update conversation state if phase changed
|
|
37
|
+
if (transitionResult.newPhase !== currentPhase) {
|
|
38
|
+
const shouldUpdateState = await this.shouldUpdateConversationState(currentPhase, transitionResult.newPhase, conversationContext, context);
|
|
39
|
+
if (shouldUpdateState) {
|
|
40
|
+
await context.conversationManager.updateConversationState(conversationId, { currentPhase: transitionResult.newPhase });
|
|
41
|
+
}
|
|
42
|
+
// If this was a first-call auto-transition, regenerate the plan file
|
|
43
|
+
if (transitionResult.transitionReason.includes('Starting development - defining criteria')) {
|
|
44
|
+
this.logger.info('Regenerating plan file after first-call auto-transition', {
|
|
45
|
+
from: currentPhase,
|
|
46
|
+
to: transitionResult.newPhase,
|
|
47
|
+
planFilePath: conversationContext.planFilePath,
|
|
48
|
+
});
|
|
49
|
+
await context.planManager.ensurePlanFile(conversationContext.planFilePath, conversationContext.projectPath, conversationContext.gitBranch);
|
|
50
|
+
}
|
|
51
|
+
this.logger.info('Phase transition completed', {
|
|
52
|
+
from: currentPhase,
|
|
53
|
+
to: transitionResult.newPhase,
|
|
54
|
+
reason: transitionResult.transitionReason,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Check if plan file exists
|
|
58
|
+
const planInfo = await context.planManager.getPlanFileInfo(conversationContext.planFilePath);
|
|
59
|
+
// Generate enhanced instructions
|
|
60
|
+
const instructions = await context.instructionGenerator.generateInstructions(transitionResult.instructions, {
|
|
61
|
+
phase: transitionResult.newPhase,
|
|
62
|
+
conversationContext: {
|
|
63
|
+
...conversationContext,
|
|
64
|
+
currentPhase: transitionResult.newPhase,
|
|
65
|
+
},
|
|
66
|
+
transitionReason: transitionResult.transitionReason,
|
|
67
|
+
isModeled: transitionResult.isModeled,
|
|
68
|
+
planFileExists: planInfo.exists,
|
|
69
|
+
});
|
|
70
|
+
// Add commit instructions if configured
|
|
71
|
+
let finalInstructions = instructions.instructions;
|
|
72
|
+
if (conversationContext.gitCommitConfig?.enabled &&
|
|
73
|
+
conversationContext.gitCommitConfig.commitOnStep) {
|
|
74
|
+
const commitMessage = requestContext || 'Step completion';
|
|
75
|
+
finalInstructions += `\n\n**Git Commit Required**: Create a commit for this step using:\n\`\`\`bash\ngit add . && git commit -m "${commitMessage}"\n\`\`\``;
|
|
76
|
+
}
|
|
77
|
+
// Prepare response
|
|
78
|
+
const response = {
|
|
79
|
+
phase: transitionResult.newPhase,
|
|
80
|
+
instructions: finalInstructions,
|
|
81
|
+
plan_file_path: conversationContext.planFilePath,
|
|
82
|
+
is_modeled_transition: transitionResult.isModeled,
|
|
83
|
+
conversation_id: conversationContext.conversationId,
|
|
84
|
+
};
|
|
85
|
+
// Log interaction
|
|
86
|
+
await this.logInteraction(context, conversationId, 'whats_next', args, response, transitionResult.newPhase);
|
|
87
|
+
return response;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Determines whether conversation state should be updated for a phase transition
|
|
91
|
+
*/
|
|
92
|
+
async shouldUpdateConversationState(currentPhase, newPhase, conversationContext, context) {
|
|
93
|
+
if (!conversationContext.requireReviewsBeforePhaseTransition) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
const stateMachine = context.workflowManager.loadWorkflowForProject(conversationContext.projectPath, conversationContext.workflowName);
|
|
97
|
+
const currentState = stateMachine.states[currentPhase];
|
|
98
|
+
if (!currentState) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
const transition = currentState.transitions.find(t => t.to === newPhase);
|
|
102
|
+
if (!transition) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
const hasReviewPerspectives = transition.review_perspectives &&
|
|
106
|
+
transition.review_perspectives.length > 0;
|
|
107
|
+
if (hasReviewPerspectives) {
|
|
108
|
+
this.logger.debug('Preventing state update - review required for transition', {
|
|
109
|
+
from: currentPhase,
|
|
110
|
+
to: newPhase,
|
|
111
|
+
reviewPerspectives: transition.review_perspectives?.length || 0,
|
|
112
|
+
});
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=whats-next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whats-next.js","sourceRoot":"","sources":["../../src/tool-handlers/whats-next.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AA4BzE;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,+BAGrC;IACW,KAAK,CAAC,uBAAuB,CACrC,IAAmB,EACnB,OAAsB,EACtB,mBAAwC;QAExC,MAAM,EACJ,OAAO,EAAE,cAAc,GAAG,EAAE,EAC5B,UAAU,GAAG,EAAE,EACf,oBAAoB,GAAG,EAAE,EACzB,eAAe,GAAG,EAAE,GACrB,GAAG,IAAI,CAAC;QAET,MAAM,cAAc,GAAG,mBAAmB,CAAC,cAAc,CAAC;QAC1D,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;QAEtD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE;YACjD,cAAc;YACd,YAAY;YACZ,UAAU,EAAE,CAAC,CAAC,cAAc;YAC5B,YAAY,EAAE,CAAC,CAAC,UAAU;SAC3B,CAAC,CAAC;QAEH,kDAAkD;QAClD,IAAI,CAAC,4BAA4B,CAC/B,OAAO,EACP,mBAAmB,CAAC,WAAW,EAC/B,mBAAmB,CAAC,YAAY,CACjC,CAAC;QAEF,0BAA0B;QAC1B,MAAM,OAAO,CAAC,WAAW,CAAC,cAAc,CACtC,mBAAmB,CAAC,YAAY,EAChC,mB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