@codemcp/workflows 4.10.12 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/plugin-system/commit-plugin.d.ts +40 -0
  3. package/dist/plugin-system/commit-plugin.d.ts.map +1 -0
  4. package/dist/plugin-system/commit-plugin.js +204 -0
  5. package/dist/plugin-system/commit-plugin.js.map +1 -0
  6. package/dist/plugin-system/plugin-interfaces.d.ts +0 -1
  7. package/dist/plugin-system/plugin-interfaces.d.ts.map +1 -1
  8. package/dist/server-config.d.ts.map +1 -1
  9. package/dist/server-config.js +14 -9
  10. package/dist/server-config.js.map +1 -1
  11. package/dist/tool-handlers/proceed-to-phase.d.ts.map +1 -1
  12. package/dist/tool-handlers/proceed-to-phase.js +2 -9
  13. package/dist/tool-handlers/proceed-to-phase.js.map +1 -1
  14. package/dist/tool-handlers/start-development.d.ts +0 -1
  15. package/dist/tool-handlers/start-development.d.ts.map +1 -1
  16. package/dist/tool-handlers/start-development.js +25 -22
  17. package/dist/tool-handlers/start-development.js.map +1 -1
  18. package/dist/tool-handlers/whats-next.d.ts.map +1 -1
  19. package/dist/tool-handlers/whats-next.js +2 -8
  20. package/dist/tool-handlers/whats-next.js.map +1 -1
  21. package/package.json +2 -2
  22. package/src/plugin-system/commit-plugin.ts +252 -0
  23. package/src/plugin-system/plugin-interfaces.ts +0 -1
  24. package/src/server-config.ts +15 -10
  25. package/src/tool-handlers/proceed-to-phase.ts +2 -12
  26. package/src/tool-handlers/start-development.ts +39 -29
  27. package/src/tool-handlers/whats-next.ts +2 -11
  28. package/test/e2e/commit-plugin-integration.test.ts +222 -0
  29. package/test/unit/commit-plugin.test.ts +196 -0
  30. package/tsconfig.build.tsbuildinfo +1 -1
  31. package/test/unit/commit-behaviour-interface.test.ts +0 -244
@@ -1,244 +0,0 @@
1
- /**
2
- * Test the new commit_behaviour interface
3
- */
4
-
5
- import { describe, it, expect, beforeEach, vi } from 'vitest';
6
- import { StartDevelopmentHandler } from '../../src/tool-handlers/start-development.js';
7
- import * as GitManagerModule from '@codemcp/workflows-core';
8
- import type { ServerContext } from '../../src/types.js';
9
-
10
- // Spy on GitManager methods
11
- const isGitRepositorySpy = vi.spyOn(
12
- GitManagerModule.GitManager,
13
- 'isGitRepository'
14
- );
15
- const getCurrentCommitHashSpy = vi.spyOn(
16
- GitManagerModule.GitManager,
17
- 'getCurrentCommitHash'
18
- );
19
-
20
- describe('Commit Behaviour Interface', () => {
21
- beforeEach(() => {
22
- vi.clearAllMocks();
23
- isGitRepositorySpy.mockReturnValue(true);
24
- getCurrentCommitHashSpy.mockReturnValue('abc123');
25
- });
26
-
27
- it('should translate commit_behaviour "step" to correct git config', async () => {
28
- const handler = new StartDevelopmentHandler();
29
- const mockContext = {
30
- projectPath: '/test/path',
31
- conversationManager: {
32
- createConversationContext: vi
33
- .fn()
34
- .mockResolvedValue({ conversationId: 'test' }),
35
- updateConversationState: vi.fn().mockResolvedValue(undefined),
36
- },
37
- workflowManager: {
38
- validateWorkflowName: vi.fn().mockReturnValue(true),
39
- loadProjectWorkflows: vi.fn(),
40
- loadWorkflowForProject: vi
41
- .fn()
42
- .mockReturnValue({ name: 'minor', phases: ['explore', 'implement'] }),
43
- },
44
- transitionEngine: {
45
- handleExplicitTransition: vi
46
- .fn()
47
- .mockResolvedValue({ newPhase: 'explore' }),
48
- },
49
- planManager: {
50
- setStateMachine: vi.fn(),
51
- ensurePlanFile: vi.fn().mockResolvedValue('/test/plan.md'),
52
- },
53
- instructionGenerator: {
54
- generateInstructions: vi.fn().mockReturnValue('Test instructions'),
55
- },
56
- };
57
-
58
- const result = await handler.handle(
59
- {
60
- workflow: 'minor',
61
- commit_behaviour: 'step',
62
- },
63
- mockContext as ServerContext
64
- );
65
-
66
- // Verify the handler processed the commit_behaviour parameter
67
- expect(result).toBeTruthy();
68
- expect(
69
- mockContext.conversationManager.updateConversationState
70
- ).toHaveBeenCalledWith(
71
- 'test',
72
- expect.objectContaining({
73
- gitCommitConfig: expect.objectContaining({
74
- enabled: true,
75
- commitOnStep: true,
76
- commitOnPhase: false,
77
- commitOnComplete: true, // Should be true when step commits are enabled
78
- }),
79
- })
80
- );
81
- });
82
-
83
- it('should translate commit_behaviour "phase" to correct git config', async () => {
84
- const handler = new StartDevelopmentHandler();
85
- const mockContext = {
86
- projectPath: '/test/path',
87
- conversationManager: {
88
- createConversationContext: vi
89
- .fn()
90
- .mockResolvedValue({ conversationId: 'test' }),
91
- updateConversationState: vi.fn().mockResolvedValue(undefined),
92
- },
93
- workflowManager: {
94
- validateWorkflowName: vi.fn().mockReturnValue(true),
95
- loadProjectWorkflows: vi.fn(),
96
- loadWorkflowForProject: vi
97
- .fn()
98
- .mockReturnValue({ name: 'minor', phases: ['explore', 'implement'] }),
99
- },
100
- transitionEngine: {
101
- handleExplicitTransition: vi
102
- .fn()
103
- .mockResolvedValue({ newPhase: 'explore' }),
104
- },
105
- planManager: {
106
- setStateMachine: vi.fn(),
107
- ensurePlanFile: vi.fn().mockResolvedValue('/test/plan.md'),
108
- },
109
- instructionGenerator: {
110
- generateInstructions: vi.fn().mockReturnValue('Test instructions'),
111
- },
112
- };
113
-
114
- await handler.handle(
115
- {
116
- workflow: 'minor',
117
- commit_behaviour: 'phase',
118
- },
119
- mockContext as unknown as ServerContext
120
- );
121
-
122
- expect(
123
- mockContext.conversationManager.updateConversationState
124
- ).toHaveBeenCalledWith(
125
- 'test',
126
- expect.objectContaining({
127
- gitCommitConfig: expect.objectContaining({
128
- enabled: true,
129
- commitOnStep: false,
130
- commitOnPhase: true,
131
- commitOnComplete: true, // Should be true when phase commits are enabled
132
- }),
133
- })
134
- );
135
- });
136
-
137
- it('should translate commit_behaviour "end" to correct git config', async () => {
138
- const handler = new StartDevelopmentHandler();
139
- const mockContext = {
140
- projectPath: '/test/path',
141
- conversationManager: {
142
- createConversationContext: vi
143
- .fn()
144
- .mockResolvedValue({ conversationId: 'test' }),
145
- updateConversationState: vi.fn().mockResolvedValue(undefined),
146
- },
147
- workflowManager: {
148
- validateWorkflowName: vi.fn().mockReturnValue(true),
149
- loadProjectWorkflows: vi.fn(),
150
- loadWorkflowForProject: vi
151
- .fn()
152
- .mockReturnValue({ name: 'minor', phases: ['explore', 'implement'] }),
153
- },
154
- transitionEngine: {
155
- handleExplicitTransition: vi
156
- .fn()
157
- .mockResolvedValue({ newPhase: 'explore' }),
158
- },
159
- planManager: {
160
- setStateMachine: vi.fn(),
161
- ensurePlanFile: vi.fn().mockResolvedValue('/test/plan.md'),
162
- },
163
- instructionGenerator: {
164
- generateInstructions: vi.fn().mockReturnValue('Test instructions'),
165
- },
166
- };
167
-
168
- await handler.handle(
169
- {
170
- workflow: 'minor',
171
- commit_behaviour: 'end',
172
- },
173
- mockContext as ServerContext
174
- );
175
-
176
- expect(
177
- mockContext.conversationManager.updateConversationState
178
- ).toHaveBeenCalledWith(
179
- 'test',
180
- expect.objectContaining({
181
- gitCommitConfig: expect.objectContaining({
182
- enabled: true,
183
- commitOnStep: false,
184
- commitOnPhase: false,
185
- commitOnComplete: true,
186
- }),
187
- })
188
- );
189
- });
190
-
191
- it('should translate commit_behaviour "none" to disabled git config', async () => {
192
- const handler = new StartDevelopmentHandler();
193
- const mockContext = {
194
- projectPath: '/test/path',
195
- conversationManager: {
196
- createConversationContext: vi
197
- .fn()
198
- .mockResolvedValue({ conversationId: 'test' }),
199
- updateConversationState: vi.fn().mockResolvedValue(undefined),
200
- },
201
- workflowManager: {
202
- validateWorkflowName: vi.fn().mockReturnValue(true),
203
- loadProjectWorkflows: vi.fn(),
204
- loadWorkflowForProject: vi
205
- .fn()
206
- .mockReturnValue({ name: 'minor', phases: ['explore', 'implement'] }),
207
- },
208
- transitionEngine: {
209
- handleExplicitTransition: vi
210
- .fn()
211
- .mockResolvedValue({ newPhase: 'explore' }),
212
- },
213
- planManager: {
214
- setStateMachine: vi.fn(),
215
- ensurePlanFile: vi.fn().mockResolvedValue('/test/plan.md'),
216
- },
217
- instructionGenerator: {
218
- generateInstructions: vi.fn().mockReturnValue('Test instructions'),
219
- },
220
- };
221
-
222
- await handler.handle(
223
- {
224
- workflow: 'minor',
225
- commit_behaviour: 'none',
226
- },
227
- mockContext as ServerContext
228
- );
229
-
230
- expect(
231
- mockContext.conversationManager.updateConversationState
232
- ).toHaveBeenCalledWith(
233
- 'test',
234
- expect.objectContaining({
235
- gitCommitConfig: expect.objectContaining({
236
- enabled: false,
237
- commitOnStep: false,
238
- commitOnPhase: false,
239
- commitOnComplete: false,
240
- }),
241
- })
242
- );
243
- });
244
- });