@codemcp/workflows-core 3.1.16

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 (114) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/LICENSE +674 -0
  3. package/dist/config-manager.d.ts +24 -0
  4. package/dist/config-manager.js +68 -0
  5. package/dist/config-manager.js.map +1 -0
  6. package/dist/conversation-manager.d.ts +97 -0
  7. package/dist/conversation-manager.js +367 -0
  8. package/dist/conversation-manager.js.map +1 -0
  9. package/dist/database.d.ts +73 -0
  10. package/dist/database.js +500 -0
  11. package/dist/database.js.map +1 -0
  12. package/dist/file-detection-manager.d.ts +53 -0
  13. package/dist/file-detection-manager.js +221 -0
  14. package/dist/file-detection-manager.js.map +1 -0
  15. package/dist/git-manager.d.ts +14 -0
  16. package/dist/git-manager.js +59 -0
  17. package/dist/git-manager.js.map +1 -0
  18. package/dist/index.d.ts +19 -0
  19. package/dist/index.js +25 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/instruction-generator.d.ts +69 -0
  22. package/dist/instruction-generator.js +133 -0
  23. package/dist/instruction-generator.js.map +1 -0
  24. package/dist/interaction-logger.d.ts +37 -0
  25. package/dist/interaction-logger.js +87 -0
  26. package/dist/interaction-logger.js.map +1 -0
  27. package/dist/logger.d.ts +64 -0
  28. package/dist/logger.js +283 -0
  29. package/dist/logger.js.map +1 -0
  30. package/dist/path-validation-utils.d.ts +51 -0
  31. package/dist/path-validation-utils.js +202 -0
  32. package/dist/path-validation-utils.js.map +1 -0
  33. package/dist/plan-manager.d.ts +65 -0
  34. package/dist/plan-manager.js +256 -0
  35. package/dist/plan-manager.js.map +1 -0
  36. package/dist/project-docs-manager.d.ts +119 -0
  37. package/dist/project-docs-manager.js +357 -0
  38. package/dist/project-docs-manager.js.map +1 -0
  39. package/dist/state-machine-loader.d.ts +60 -0
  40. package/dist/state-machine-loader.js +235 -0
  41. package/dist/state-machine-loader.js.map +1 -0
  42. package/dist/state-machine-types.d.ts +58 -0
  43. package/dist/state-machine-types.js +7 -0
  44. package/dist/state-machine-types.js.map +1 -0
  45. package/dist/state-machine.d.ts +52 -0
  46. package/dist/state-machine.js +256 -0
  47. package/dist/state-machine.js.map +1 -0
  48. package/dist/system-prompt-generator.d.ts +17 -0
  49. package/dist/system-prompt-generator.js +113 -0
  50. package/dist/system-prompt-generator.js.map +1 -0
  51. package/dist/template-manager.d.ts +61 -0
  52. package/dist/template-manager.js +229 -0
  53. package/dist/template-manager.js.map +1 -0
  54. package/dist/transition-engine.d.ts +70 -0
  55. package/dist/transition-engine.js +240 -0
  56. package/dist/transition-engine.js.map +1 -0
  57. package/dist/types.d.ts +56 -0
  58. package/dist/types.js +5 -0
  59. package/dist/types.js.map +1 -0
  60. package/dist/workflow-manager.d.ts +89 -0
  61. package/dist/workflow-manager.js +466 -0
  62. package/dist/workflow-manager.js.map +1 -0
  63. package/package.json +27 -0
  64. package/src/config-manager.ts +96 -0
  65. package/src/conversation-manager.ts +492 -0
  66. package/src/database.ts +685 -0
  67. package/src/file-detection-manager.ts +302 -0
  68. package/src/git-manager.ts +64 -0
  69. package/src/index.ts +28 -0
  70. package/src/instruction-generator.ts +210 -0
  71. package/src/interaction-logger.ts +109 -0
  72. package/src/logger.ts +353 -0
  73. package/src/path-validation-utils.ts +261 -0
  74. package/src/plan-manager.ts +323 -0
  75. package/src/project-docs-manager.ts +522 -0
  76. package/src/state-machine-loader.ts +308 -0
  77. package/src/state-machine-types.ts +72 -0
  78. package/src/state-machine.ts +370 -0
  79. package/src/system-prompt-generator.ts +122 -0
  80. package/src/template-manager.ts +321 -0
  81. package/src/transition-engine.ts +386 -0
  82. package/src/types.ts +60 -0
  83. package/src/workflow-manager.ts +601 -0
  84. package/test/unit/conversation-manager.test.ts +179 -0
  85. package/test/unit/custom-workflow-loading.test.ts +174 -0
  86. package/test/unit/directory-linking-and-extensions.test.ts +338 -0
  87. package/test/unit/file-linking-integration.test.ts +256 -0
  88. package/test/unit/git-commit-integration.test.ts +91 -0
  89. package/test/unit/git-manager.test.ts +86 -0
  90. package/test/unit/install-workflow.test.ts +138 -0
  91. package/test/unit/instruction-generator.test.ts +247 -0
  92. package/test/unit/list-workflows-filtering.test.ts +68 -0
  93. package/test/unit/none-template-functionality.test.ts +224 -0
  94. package/test/unit/project-docs-manager.test.ts +337 -0
  95. package/test/unit/state-machine-loader.test.ts +234 -0
  96. package/test/unit/template-manager.test.ts +217 -0
  97. package/test/unit/validate-workflow-name.test.ts +150 -0
  98. package/test/unit/workflow-domain-filtering.test.ts +75 -0
  99. package/test/unit/workflow-enum-generation.test.ts +92 -0
  100. package/test/unit/workflow-manager-enhanced-path-resolution.test.ts +369 -0
  101. package/test/unit/workflow-manager-path-resolution.test.ts +150 -0
  102. package/test/unit/workflow-migration.test.ts +155 -0
  103. package/test/unit/workflow-override-by-name.test.ts +116 -0
  104. package/test/unit/workflow-prioritization.test.ts +38 -0
  105. package/test/unit/workflow-validation.test.ts +303 -0
  106. package/test/utils/e2e-test-setup.ts +453 -0
  107. package/test/utils/run-server-in-dir.sh +27 -0
  108. package/test/utils/temp-files.ts +308 -0
  109. package/test/utils/test-access.ts +79 -0
  110. package/test/utils/test-helpers.ts +286 -0
  111. package/test/utils/test-setup.ts +78 -0
  112. package/tsconfig.build.json +21 -0
  113. package/tsconfig.json +8 -0
  114. package/vitest.config.ts +18 -0
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Template Manager
3
+ *
4
+ * Handles loading and rendering of project document templates.
5
+ * Supports different template formats for architecture, requirements, and design documents.
6
+ */
7
+ import { readFile, readdir, stat } from 'node:fs/promises';
8
+ import { join, dirname } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+ import { createRequire } from 'node:module';
11
+ import { createLogger } from './logger.js';
12
+ const logger = createLogger('TemplateManager');
13
+ export class TemplateManager {
14
+ templatesPath;
15
+ constructor() {
16
+ this.templatesPath = this.resolveTemplatesPath();
17
+ }
18
+ /**
19
+ * Resolve templates path using similar strategy as WorkflowManager
20
+ */
21
+ resolveTemplatesPath() {
22
+ const strategies = [];
23
+ // Strategy 1: From compiled dist directory
24
+ const currentFileUrl = import.meta.url;
25
+ if (currentFileUrl.startsWith('file://')) {
26
+ const currentFilePath = fileURLToPath(currentFileUrl);
27
+ // From dist/template-manager.js -> ../resources/templates
28
+ strategies.push(join(dirname(currentFilePath), '../resources/templates'));
29
+ }
30
+ // Strategy 2: From node_modules
31
+ strategies.push(join(process.cwd(), 'node_modules/responsible-vibe-mcp/resources/templates'));
32
+ // Strategy 3: From package directory (for development)
33
+ try {
34
+ const require = createRequire(import.meta.url);
35
+ const packagePath = require.resolve('responsible-vibe-mcp/package.json');
36
+ const packageDir = dirname(packagePath);
37
+ strategies.push(join(packageDir, 'resources/templates'));
38
+ }
39
+ catch (_error) {
40
+ // Ignore if package not found
41
+ }
42
+ // Strategy 4: Current working directory (for development)
43
+ strategies.push(join(process.cwd(), 'resources/templates'));
44
+ // Find the first existing path
45
+ for (const strategy of strategies) {
46
+ try {
47
+ // This will throw if path doesn't exist
48
+ require('node:fs').accessSync(strategy);
49
+ logger.debug('Using templates path', { path: strategy });
50
+ return strategy;
51
+ }
52
+ catch (_error) {
53
+ // Continue to next strategy
54
+ }
55
+ }
56
+ // Fallback to first strategy if none found
57
+ const fallback = strategies[0];
58
+ logger.warn('No templates directory found, using fallback', {
59
+ fallback,
60
+ strategies,
61
+ });
62
+ return fallback;
63
+ }
64
+ /**
65
+ * Get the default template options based on available templates
66
+ */
67
+ async getDefaults() {
68
+ const availableTemplates = await this.getAvailableTemplates();
69
+ return {
70
+ architecture: this.getPreferredTemplate(availableTemplates.architecture, [
71
+ 'arc42',
72
+ 'freestyle',
73
+ ]),
74
+ requirements: this.getPreferredTemplate(availableTemplates.requirements, [
75
+ 'ears',
76
+ 'freestyle',
77
+ ]),
78
+ design: this.getPreferredTemplate(availableTemplates.design, [
79
+ 'comprehensive',
80
+ 'freestyle',
81
+ ]),
82
+ };
83
+ }
84
+ /**
85
+ * Get preferred template from available options, with fallback preferences
86
+ */
87
+ getPreferredTemplate(available, preferences) {
88
+ // Try to find the first preference that's available
89
+ for (const preference of preferences) {
90
+ if (available.includes(preference)) {
91
+ return preference;
92
+ }
93
+ }
94
+ // If no preferences are available, return the first available template
95
+ return available[0] || preferences[0];
96
+ }
97
+ /**
98
+ * Load and render a template
99
+ */
100
+ async loadTemplate(type, template) {
101
+ const templatePath = join(this.templatesPath, type, template);
102
+ const templateFilePath = `${templatePath}.md`;
103
+ try {
104
+ // First try to check if it's a directory (like arc42)
105
+ try {
106
+ const stats = await stat(templatePath);
107
+ if (stats.isDirectory()) {
108
+ return await this.loadDirectoryTemplate(templatePath);
109
+ }
110
+ }
111
+ catch (_error) {
112
+ // Not a directory, continue to file check
113
+ }
114
+ // Try to load as a markdown file
115
+ const content = await readFile(templateFilePath, 'utf-8');
116
+ return { content };
117
+ }
118
+ catch (error) {
119
+ logger.error(`Failed to load template: ${type}/${template}`, error);
120
+ throw new Error(`Template not found: ${type}/${template}. Tried: ${templatePath} (directory) and ${templateFilePath} (file)`);
121
+ }
122
+ }
123
+ /**
124
+ * Load a directory-based template (like arc42 with images)
125
+ */
126
+ async loadDirectoryTemplate(templatePath) {
127
+ const additionalFiles = [];
128
+ // Find the main markdown file
129
+ const files = await readdir(templatePath);
130
+ const markdownFile = files.find(file => file.endsWith('.md'));
131
+ if (!markdownFile) {
132
+ throw new Error(`No markdown file found in template directory: ${templatePath}`);
133
+ }
134
+ const content = await readFile(join(templatePath, markdownFile), 'utf-8');
135
+ // Load additional files (like images)
136
+ await this.loadAdditionalFiles(templatePath, '', additionalFiles);
137
+ return {
138
+ content,
139
+ additionalFiles: additionalFiles.filter(file => !file.relativePath.endsWith('.md')),
140
+ };
141
+ }
142
+ /**
143
+ * Recursively load additional files from template directory
144
+ */
145
+ async loadAdditionalFiles(basePath, relativePath, additionalFiles) {
146
+ const currentPath = join(basePath, relativePath);
147
+ const items = await readdir(currentPath);
148
+ for (const item of items) {
149
+ const itemPath = join(currentPath, item);
150
+ const itemRelativePath = relativePath ? join(relativePath, item) : item;
151
+ const stats = await stat(itemPath);
152
+ if (stats.isDirectory()) {
153
+ // Recursively process subdirectories
154
+ await this.loadAdditionalFiles(basePath, itemRelativePath, additionalFiles);
155
+ }
156
+ else if (!item.endsWith('.md')) {
157
+ // Load non-markdown files as additional files
158
+ const content = await readFile(itemPath);
159
+ additionalFiles.push({
160
+ relativePath: itemRelativePath,
161
+ content,
162
+ });
163
+ }
164
+ }
165
+ }
166
+ /**
167
+ * Validate template options against available templates
168
+ */
169
+ async validateOptions(options) {
170
+ const availableTemplates = await this.getAvailableTemplates();
171
+ if (options.architecture &&
172
+ !availableTemplates.architecture.includes(options.architecture)) {
173
+ throw new Error(`Invalid architecture template: ${options.architecture}. Valid options: ${availableTemplates.architecture.join(', ')}`);
174
+ }
175
+ if (options.requirements &&
176
+ !availableTemplates.requirements.includes(options.requirements)) {
177
+ throw new Error(`Invalid requirements template: ${options.requirements}. Valid options: ${availableTemplates.requirements.join(', ')}`);
178
+ }
179
+ if (options.design && !availableTemplates.design.includes(options.design)) {
180
+ throw new Error(`Invalid design template: ${options.design}. Valid options: ${availableTemplates.design.join(', ')}`);
181
+ }
182
+ }
183
+ /**
184
+ * Get available templates for each type by scanning the file system
185
+ */
186
+ async getAvailableTemplates() {
187
+ const result = {
188
+ architecture: [],
189
+ requirements: [],
190
+ design: [],
191
+ };
192
+ try {
193
+ // Scan each template type directory
194
+ for (const [type, templates] of Object.entries(result)) {
195
+ const typePath = join(this.templatesPath, type);
196
+ try {
197
+ const entries = await readdir(typePath, { withFileTypes: true });
198
+ for (const entry of entries) {
199
+ if (entry.isDirectory()) {
200
+ // Directory-based template (like arc42)
201
+ templates.push(entry.name);
202
+ }
203
+ else if (entry.isFile() && entry.name.endsWith('.md')) {
204
+ // File-based template (like freestyle.md)
205
+ const templateName = entry.name.replace('.md', '');
206
+ templates.push(templateName);
207
+ }
208
+ }
209
+ // Sort templates for consistent ordering
210
+ templates.sort();
211
+ }
212
+ catch (error) {
213
+ logger.warn(`Failed to scan templates for type: ${type}`, {
214
+ typePath,
215
+ error: error instanceof Error ? error.message : String(error),
216
+ });
217
+ }
218
+ }
219
+ logger.debug('Discovered available templates', result);
220
+ return result;
221
+ }
222
+ catch (error) {
223
+ logger.error('Failed to discover templates', error);
224
+ // Return empty arrays if discovery fails
225
+ return result;
226
+ }
227
+ }
228
+ }
229
+ //# sourceMappingURL=template-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-manager.js","sourceRoot":"","sources":["../src/template-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAqB/C,MAAM,OAAO,eAAe;IAClB,aAAa,CAAS;IAE9B;QACE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACnD,CAAC;IAED;;OAEG;IACK,oBAAoB;QAC1B,MAAM,UAAU,GAAa,EAAE,CAAC;QAEhC,2CAA2C;QAC3C,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QACvC,IAAI,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACzC,MAAM,eAAe,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;YACtD,0DAA0D;YAC1D,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC;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,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;4BACxD,0CAA0C;4BAC1C,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;4BACnD,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;wBAC/B,CAAC;oBACH,CAAC;oBAED,yCAAyC;oBACzC,SAAS,CAAC,IAAI,EAAE,CAAC;gBACnB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CAAC,sCAAsC,IAAI,EAAE,EAAE;wBACxD,QAAQ;wBACR,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;qBAC9D,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC;YACvD,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAc,CAAC,CAAC;YAC7D,yCAAyC;YACzC,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Transition Engine
3
+ *
4
+ * Manages the development state machine and determines appropriate phase transitions.
5
+ * Analyzes conversation context and user input to make intelligent phase decisions.
6
+ */
7
+ import type { ConversationState } from './types.js';
8
+ export interface TransitionContext {
9
+ currentPhase: string;
10
+ projectPath: string;
11
+ conversationId: string;
12
+ userInput?: string;
13
+ context?: string;
14
+ conversationSummary?: string;
15
+ recentMessages?: Array<{
16
+ role: string;
17
+ content: string;
18
+ }>;
19
+ }
20
+ export interface TransitionResult {
21
+ newPhase: string;
22
+ instructions: string;
23
+ transitionReason: string;
24
+ isModeled: boolean;
25
+ }
26
+ export declare class TransitionEngine {
27
+ private stateMachineLoader;
28
+ private workflowManager;
29
+ private conversationManager?;
30
+ constructor(projectPath: string);
31
+ /**
32
+ * Set the conversation manager (dependency injection)
33
+ */
34
+ setConversationManager(conversationManager: {
35
+ hasInteractions: (conversationId: string) => Promise<boolean>;
36
+ getConversationState: (conversationId: string) => Promise<ConversationState | null>;
37
+ }): void;
38
+ /**
39
+ * Get the loaded state machine for the current project
40
+ */
41
+ getStateMachine(projectPath: string, workflowName?: string): import("./state-machine-types.js").YamlStateMachine;
42
+ /**
43
+ * Check if this is the first call from initial state based on database interactions
44
+ */
45
+ private isFirstCallFromInitialState;
46
+ /**
47
+ * Generate instructions for defining phase entrance criteria
48
+ */
49
+ private generateCriteriaDefinitionInstructions;
50
+ /**
51
+ * Get phase-specific instructions for continuing work in current phase
52
+ */
53
+ private getContinuePhaseInstructions;
54
+ /**
55
+ * Get the first development phase from the state machine
56
+ */
57
+ private getFirstDevelopmentPhase;
58
+ /**
59
+ * Analyze context and determine appropriate phase transition
60
+ */
61
+ analyzePhaseTransition(context: TransitionContext): Promise<TransitionResult>;
62
+ /**
63
+ * Handle explicit phase transition request
64
+ */
65
+ handleExplicitTransition(currentPhase: string, targetPhase: string, projectPath: string, reason?: string, workflowName?: string): TransitionResult;
66
+ /**
67
+ * Capitalize phase name for display
68
+ */
69
+ private capitalizePhase;
70
+ }
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Transition Engine
3
+ *
4
+ * Manages the development state machine and determines appropriate phase transitions.
5
+ * Analyzes conversation context and user input to make intelligent phase decisions.
6
+ */
7
+ import { createLogger } from './logger.js';
8
+ import { StateMachineLoader } from './state-machine-loader.js';
9
+ import { WorkflowManager } from './workflow-manager.js';
10
+ const logger = createLogger('TransitionEngine');
11
+ export class TransitionEngine {
12
+ stateMachineLoader;
13
+ workflowManager;
14
+ conversationManager;
15
+ constructor(projectPath) {
16
+ this.stateMachineLoader = new StateMachineLoader();
17
+ this.workflowManager = new WorkflowManager();
18
+ logger.info('TransitionEngine initialized', { projectPath });
19
+ }
20
+ /**
21
+ * Set the conversation manager (dependency injection)
22
+ */
23
+ setConversationManager(conversationManager) {
24
+ this.conversationManager = conversationManager;
25
+ }
26
+ /**
27
+ * Get the loaded state machine for the current project
28
+ */
29
+ getStateMachine(projectPath, workflowName) {
30
+ // Use WorkflowManager to load the appropriate workflow
31
+ return this.workflowManager.loadWorkflowForProject(projectPath, workflowName);
32
+ }
33
+ /**
34
+ * Check if this is the first call from initial state based on database interactions
35
+ */
36
+ async isFirstCallFromInitialState(context) {
37
+ // Get workflow name from conversation state
38
+ const conversationState = await this.conversationManager?.getConversationState(context.conversationId);
39
+ const workflowName = conversationState?.workflowName;
40
+ const stateMachine = this.workflowManager.loadWorkflowForProject(context.projectPath, workflowName);
41
+ const isInitialState = context.currentPhase === stateMachine.initial_state;
42
+ if (!isInitialState)
43
+ return false;
44
+ // Check database for any previous interactions in this conversation
45
+ if (!this.conversationManager) {
46
+ logger.warn('ConversationManager not set, assuming first call');
47
+ return true;
48
+ }
49
+ const hasInteractions = await this.conversationManager.hasInteractions(context.conversationId);
50
+ logger.debug('Checking first call from initial state', {
51
+ isInitialState,
52
+ hasInteractions,
53
+ conversationId: context.conversationId,
54
+ currentPhase: context.currentPhase,
55
+ });
56
+ return !hasInteractions;
57
+ }
58
+ /**
59
+ * Generate instructions for defining phase entrance criteria
60
+ */
61
+ async generateCriteriaDefinitionInstructions(projectPath, conversationId) {
62
+ // Get workflow name from conversation state
63
+ const conversationState = await this.conversationManager?.getConversationState(conversationId);
64
+ const workflowName = conversationState?.workflowName;
65
+ const stateMachine = this.workflowManager.loadWorkflowForProject(projectPath, workflowName);
66
+ const phases = Object.keys(stateMachine.states);
67
+ let instructions = `Welcome to ${stateMachine.name}!
68
+
69
+ Before we begin development, let's establish clear entrance criteria for each phase. This will help us make informed decisions about when to transition between phases throughout the development process.
70
+
71
+ Please update the plan file with a "Phase Entrance Criteria" section that defines specific, measurable criteria for entering each phase:
72
+
73
+ ## Phase Entrance Criteria
74
+
75
+ `;
76
+ // Generate criteria template for each phase (except initial state)
77
+ for (const phase of phases) {
78
+ if (phase === stateMachine.initial_state)
79
+ continue; // Skip initial state
80
+ const phaseDefinition = stateMachine.states[phase];
81
+ const capitalizedPhase = this.capitalizePhase(phase);
82
+ instructions += `### ${capitalizedPhase} Phase
83
+ *${phaseDefinition.description}*
84
+
85
+ **Enter when:**
86
+ - [ ] [Define specific criteria for entering ${phase} phase]
87
+ - [ ] [Add measurable conditions that must be met]
88
+ - [ ] [Include any deliverables or milestones required]
89
+
90
+ `;
91
+ }
92
+ instructions += `
93
+ Once you've defined these criteria, we can begin development. Throughout the process, consult these criteria when considering phase transitions.
94
+
95
+ **Remember**: These criteria should be specific and measurable so we can clearly determine when each phase is ready to begin.`;
96
+ return instructions;
97
+ }
98
+ /**
99
+ * Get phase-specific instructions for continuing work in current phase
100
+ */
101
+ async getContinuePhaseInstructions(phase, projectPath, conversationId) {
102
+ // Get workflow name from conversation state
103
+ const conversationState = await this.conversationManager?.getConversationState(conversationId);
104
+ const workflowName = conversationState?.workflowName;
105
+ const stateMachine = this.workflowManager.loadWorkflowForProject(projectPath, workflowName);
106
+ const stateDefinition = stateMachine.states[phase];
107
+ if (!stateDefinition) {
108
+ logger.error('Unknown phase', new Error(`Unknown phase: ${phase}`));
109
+ throw new Error(`Unknown phase: ${phase}`);
110
+ }
111
+ const continueTransition = stateDefinition.transitions.find(t => t.to === phase);
112
+ if (continueTransition) {
113
+ // Use the transition instructions if available, otherwise use default + additional
114
+ if (continueTransition.instructions) {
115
+ return continueTransition.instructions;
116
+ }
117
+ else {
118
+ let composedInstructions = stateDefinition.default_instructions;
119
+ if (continueTransition.additional_instructions) {
120
+ composedInstructions = `${composedInstructions}\n\n**Additional Context:**\n${continueTransition.additional_instructions}`;
121
+ }
122
+ return composedInstructions;
123
+ }
124
+ }
125
+ // Fall back to default instructions for the phase
126
+ return stateDefinition.default_instructions;
127
+ }
128
+ /**
129
+ * Get the first development phase from the state machine
130
+ */
131
+ async getFirstDevelopmentPhase(projectPath, conversationId) {
132
+ // Get workflow name from conversation state
133
+ const conversationState = await this.conversationManager?.getConversationState(conversationId);
134
+ const workflowName = conversationState?.workflowName;
135
+ const stateMachine = this.workflowManager.loadWorkflowForProject(projectPath, workflowName);
136
+ const initialState = stateMachine.initial_state;
137
+ // The first development phase IS the initial state - we should stay there
138
+ // Don't automatically transition to the first transition target
139
+ return initialState;
140
+ }
141
+ /**
142
+ * Analyze context and determine appropriate phase transition
143
+ */
144
+ async analyzePhaseTransition(context) {
145
+ const { currentPhase, projectPath, conversationId, userInput, context: additionalContext, conversationSummary, } = context;
146
+ // Load the appropriate workflow for this project/conversation
147
+ logger.debug('Analyzing phase transition', {
148
+ currentPhase,
149
+ projectPath,
150
+ hasUserInput: !!userInput,
151
+ hasContext: !!additionalContext,
152
+ hasSummary: !!conversationSummary,
153
+ userInput: userInput
154
+ ? userInput.substring(0, 50) + (userInput.length > 50 ? '...' : '')
155
+ : undefined,
156
+ });
157
+ // Check if this is the first call from initial state - transition to first development phase
158
+ if (await this.isFirstCallFromInitialState(context)) {
159
+ const firstDevelopmentPhase = await this.getFirstDevelopmentPhase(projectPath, conversationId);
160
+ logger.info('First call from initial state - transitioning to first development phase with criteria', {
161
+ currentPhase,
162
+ firstDevelopmentPhase,
163
+ projectPath,
164
+ });
165
+ // Combine criteria definition with first phase instructions
166
+ const criteriaInstructions = await this.generateCriteriaDefinitionInstructions(projectPath, conversationId);
167
+ const phaseInstructions = await this.getContinuePhaseInstructions(firstDevelopmentPhase, projectPath, conversationId);
168
+ return {
169
+ newPhase: firstDevelopmentPhase, // Transition to first development phase
170
+ instructions: criteriaInstructions + '\n\n---\n\n' + phaseInstructions,
171
+ transitionReason: 'Starting development - defining criteria and beginning first phase',
172
+ isModeled: true,
173
+ };
174
+ }
175
+ // For all other cases, stay in current phase and let LLM decide based on plan file criteria
176
+ // The LLM will consult the entrance criteria in the plan file and use proceed_to_phase when ready
177
+ const continueInstructions = await this.getContinuePhaseInstructions(currentPhase, projectPath, conversationId);
178
+ logger.debug('Continuing in current phase - LLM will evaluate transition criteria', {
179
+ currentPhase,
180
+ projectPath,
181
+ });
182
+ return {
183
+ newPhase: currentPhase,
184
+ instructions: continueInstructions,
185
+ transitionReason: 'Continue current phase - LLM will evaluate transition criteria from plan file',
186
+ isModeled: false,
187
+ };
188
+ }
189
+ /**
190
+ * Handle explicit phase transition request
191
+ */
192
+ handleExplicitTransition(currentPhase, targetPhase, projectPath, reason, workflowName) {
193
+ // Load the appropriate state machine for this project/workflow
194
+ const stateMachine = this.getStateMachine(projectPath, workflowName);
195
+ logger.debug('Handling explicit phase transition', {
196
+ currentPhase,
197
+ targetPhase,
198
+ projectPath,
199
+ workflowName,
200
+ reason,
201
+ });
202
+ // Validate that the target phase exists in the state machine
203
+ if (!stateMachine.states[targetPhase]) {
204
+ const validPhases = Object.keys(stateMachine.states);
205
+ const errorMsg = `Invalid target phase: "${targetPhase}". Valid phases are: ${validPhases.join(', ')}`;
206
+ logger.error('Invalid target phase', new Error(errorMsg));
207
+ throw new Error(errorMsg);
208
+ }
209
+ // Get default instructions from the target state
210
+ const targetState = stateMachine.states[targetPhase];
211
+ const instructions = targetState.default_instructions;
212
+ const transitionInfo = {
213
+ instructions: instructions,
214
+ transitionReason: reason || `Moving to ${targetPhase}`,
215
+ isModeled: false, // Direct phase transitions are not modeled
216
+ };
217
+ logger.info('Explicit phase transition processed', {
218
+ fromPhase: currentPhase,
219
+ toPhase: targetPhase,
220
+ reason: transitionInfo.transitionReason,
221
+ isModeled: transitionInfo.isModeled,
222
+ });
223
+ return {
224
+ newPhase: targetPhase,
225
+ instructions: transitionInfo.instructions,
226
+ transitionReason: reason || transitionInfo.transitionReason,
227
+ isModeled: transitionInfo.isModeled,
228
+ };
229
+ }
230
+ /**
231
+ * Capitalize phase name for display
232
+ */
233
+ capitalizePhase(phase) {
234
+ return phase
235
+ .split('_')
236
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1))
237
+ .join(' ');
238
+ }
239
+ }
240
+ //# sourceMappingURL=transition-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transition-engine.js","sourceRoot":"","sources":["../src/transition-engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,MAAM,MAAM,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAmBhD,MAAM,OAAO,gBAAgB;IACnB,kBAAkB,CAAqB;IACvC,eAAe,CAAkB;IACjC,mBAAmB,CAKzB;IAEF,YAAY,WAAmB;QAC7B,IAAI,CAAC,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACnD,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAE7C,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,sBAAsB,CAAC,mBAKtB;QACC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,WAAmB,EAAE,YAAqB;QACxD,uDAAuD;QACvD,OAAO,IAAI,CAAC,eAAe,CAAC,sBAAsB,CAChD,WAAW,EACX,YAAY,CACb,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,2BAA2B,CACvC,OAA0B;QAE1B,4CAA4C;QAC5C,MAAM,iBAAiB,GACrB,MAAM,IAAI,CAAC,mBAAmB,EAAE,oBAAoB,CAClD,OAAO,CAAC,cAAc,CACvB,CAAC;QACJ,MAAM,YAAY,GAAG,iBAAiB,EAAE,YAAY,CAAC;QAErD,MAAM,YAAY,GAAG,IAAI,CAAC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;IACK,eAAe,CAAC,KAAa;QACnC,OAAO,KAAK;aACT,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACzD,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Common types used across the application
3
+ */
4
+ /**
5
+ * Interface for interaction log entries
6
+ */
7
+ export interface InteractionLog {
8
+ id?: number;
9
+ conversationId: string;
10
+ toolName: string;
11
+ inputParams: string;
12
+ responseData: string;
13
+ currentPhase: string;
14
+ timestamp: string;
15
+ isReset?: boolean;
16
+ resetAt?: string;
17
+ }
18
+ /**
19
+ * Interface for conversation state
20
+ */
21
+ /**
22
+ * Git commit configuration options
23
+ */
24
+ export interface GitCommitConfig {
25
+ enabled: boolean;
26
+ commitOnStep: boolean;
27
+ commitOnPhase: boolean;
28
+ commitOnComplete: boolean;
29
+ initialMessage: string;
30
+ startCommitHash?: string;
31
+ }
32
+ export interface ConversationState {
33
+ conversationId: string;
34
+ projectPath: string;
35
+ gitBranch: string;
36
+ currentPhase: string;
37
+ planFilePath: string;
38
+ workflowName: string;
39
+ gitCommitConfig?: GitCommitConfig;
40
+ requireReviewsBeforePhaseTransition: boolean;
41
+ createdAt: string;
42
+ updatedAt: string;
43
+ }
44
+ /**
45
+ * Interface for conversation context
46
+ */
47
+ export interface ConversationContext {
48
+ conversationId: string;
49
+ projectPath: string;
50
+ gitBranch: string;
51
+ currentPhase: string;
52
+ planFilePath: string;
53
+ workflowName: string;
54
+ gitCommitConfig?: GitCommitConfig;
55
+ requireReviewsBeforePhaseTransition?: boolean;
56
+ }
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Common types used across the application
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}