@programinglive/dev-workflow-mcp-server 1.7.16 → 1.8.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.
@@ -0,0 +1,219 @@
1
+ import path from "path";
2
+ import { existsSync } from "fs";
3
+ import { textResponse, isReleaseSatisfied, resetToCommitIfWorkingChanges } from "./shared.js";
4
+
5
+ export async function handleStartTask(args, workflowState) {
6
+ workflowState.reset();
7
+ workflowState.state.currentPhase = "coding";
8
+ workflowState.state.taskDescription = args.description;
9
+ workflowState.state.taskType = args.type;
10
+ workflowState.state.testsSkipped = false;
11
+ workflowState.state.testsSkippedReason = "";
12
+ workflowState.state.commitAndPushCompleted = false;
13
+ workflowState.state.lastCommitMessage = "";
14
+ workflowState.state.lastPushBranch = "";
15
+ await workflowState.save();
16
+
17
+ return textResponse(
18
+ `✅ Task Started: ${args.description}\n\n🎯 Be conscious about what you're coding!\n\nWorkflow Steps:\n1. ✓ Start task (current)\n2. ⏳ Fix/implement the feature\n3. ⏳ Create tests\n4. ⏳ Run tests (must pass!)\n5. ⏳ Create documentation\n6. ⏳ Run 'check_ready_to_commit'\n7. ⏳ Run 'commit_and_push' (commits and pushes)\n8. ⏳ Run 'perform_release' (handles versioning and tags) or 'skip_release' (when no release is needed)\n9. ⏳ Complete task\n\nReminder: Focus on writing clean, maintainable code!`
19
+ );
20
+ }
21
+
22
+ export async function handleMarkBugFixed(args, workflowState) {
23
+ if (workflowState.state.currentPhase === "idle") {
24
+ return textResponse("⚠️ Please start a task first using 'start_task'!");
25
+ }
26
+
27
+ if (workflowState.state.bugFixed) {
28
+ const summary = typeof args.summary === "string" ? args.summary : "";
29
+ if (summary && summary.trim() !== "") {
30
+ workflowState.state.fixSummary = summary;
31
+ }
32
+
33
+ if (workflowState.state.testsPassed && workflowState.state.documentationCreated) {
34
+ workflowState.state.currentPhase = "ready";
35
+ workflowState.state.readyToCommit = true;
36
+ } else if (workflowState.state.testsCreated) {
37
+ workflowState.state.currentPhase = "testing";
38
+ }
39
+ workflowState.state.readyCheckCompleted = false;
40
+ workflowState.state.commitAndPushCompleted = false;
41
+ await workflowState.save();
42
+
43
+ return textResponse(
44
+ "ℹ️ Already marked as fixed; kept existing tests/documentation. Continue with the next step."
45
+ );
46
+ }
47
+
48
+ workflowState.state.bugFixed = true;
49
+ workflowState.state.testsCreated = false;
50
+ workflowState.state.currentPhase = "testing";
51
+ workflowState.state.testsSkipped = false;
52
+ workflowState.state.testsSkippedReason = "";
53
+ workflowState.state.fixSummary = args.summary;
54
+ workflowState.state.readyCheckCompleted = false;
55
+ workflowState.state.released = false;
56
+ workflowState.state.releaseSkipped = false;
57
+ workflowState.state.releaseSkippedReason = "";
58
+ workflowState.state.releaseCommand = "";
59
+ workflowState.state.releaseNotes = "";
60
+ workflowState.state.commitAndPushCompleted = false;
61
+ workflowState.state.lastCommitMessage = "";
62
+ workflowState.state.lastPushBranch = "";
63
+ await workflowState.save();
64
+
65
+ return textResponse(
66
+ `✅ Feature/Bug marked as fixed!\n\n⚠️ CRITICAL REMINDER: You MUST create tests now!\n\nNext Steps:\n1. ✓ Fix/implement feature\n2. ⏳ Create tests for: ${args.summary}\n3. ⏳ Run tests (must be green!)\n4. ⏳ Create documentation\n5. ⏳ Run 'check_ready_to_commit'\n6. ⏳ Run 'commit_and_push'\n7. ⏳ Run 'perform_release' (or 'skip_release' if no release applies)\n8. ⏳ Complete task\n\n🚫 DO NOT SKIP TESTING!`
67
+ );
68
+ }
69
+
70
+ export async function handleCreateTests(workflowState) {
71
+ if (!workflowState.state.bugFixed) {
72
+ return textResponse("⚠️ Please mark your feature/bug as fixed first using 'mark_bug_fixed'!");
73
+ }
74
+
75
+ workflowState.state.testsCreated = true;
76
+ workflowState.state.testsSkipped = false;
77
+ workflowState.state.testsSkippedReason = "";
78
+ workflowState.state.readyCheckCompleted = false;
79
+ workflowState.state.released = false;
80
+ workflowState.state.releaseSkipped = false;
81
+ workflowState.state.releaseSkippedReason = "";
82
+ workflowState.state.commitAndPushCompleted = false;
83
+ workflowState.state.lastCommitMessage = "";
84
+ workflowState.state.lastPushBranch = "";
85
+ await workflowState.save();
86
+
87
+ return textResponse(
88
+ "✅ Tests recorded!\n\nNext Steps:\n1. ✓ Fix/implement feature\n2. ✓ Create tests\n3. ⏳ Run tests (must be green!)\n4. ⏳ Create documentation\n5. ⏳ Run 'check_ready_to_commit'\n6. ⏳ Run 'commit_and_push'\n7. ⏳ Run 'perform_release' (or 'skip_release' if appropriate)\n8. ⏳ Complete task\n\n🧪 Run your test command and record the results using 'run_tests'."
89
+ );
90
+ }
91
+
92
+ export async function handleSkipTests(args, workflowState) {
93
+ if (workflowState.state.currentPhase === "idle") {
94
+ return textResponse("⚠️ No active task. Use 'start_task' before skipping tests.");
95
+ }
96
+
97
+ if (!workflowState.state.bugFixed) {
98
+ return textResponse("⚠️ Please mark your feature/bug as fixed first using 'mark_bug_fixed'!");
99
+ }
100
+
101
+ const reason = typeof args.reason === "string" ? args.reason.trim() : "";
102
+
103
+ if (!reason) {
104
+ return textResponse("⚠️ Provide a non-empty justification when skipping tests.");
105
+ }
106
+
107
+ workflowState.state.testsCreated = true;
108
+ workflowState.state.testsPassed = true;
109
+ workflowState.state.testsSkipped = true;
110
+ workflowState.state.testsSkippedReason = reason;
111
+ workflowState.state.currentPhase = "documentation";
112
+ workflowState.state.readyToCommit = false;
113
+ workflowState.state.readyCheckCompleted = false;
114
+ workflowState.state.released = false;
115
+ workflowState.state.releaseSkipped = false;
116
+ workflowState.state.releaseSkippedReason = "";
117
+ workflowState.state.commitAndPushCompleted = false;
118
+ workflowState.state.lastCommitMessage = "";
119
+ workflowState.state.lastPushBranch = "";
120
+ await workflowState.save();
121
+
122
+ return textResponse(
123
+ `⚠️ Tests skipped for this task.
124
+ Reason: ${reason}
125
+
126
+ Manual verification is now required.
127
+
128
+ Next Steps:
129
+ 1. ✓ Fix/implement feature
130
+ 2. ⚠️ Tests skipped (ensure manual QA)
131
+ 3. ⏳ Create/update documentation
132
+ 4. ⏳ Run 'check_ready_to_commit'
133
+ 5. ⏳ Run 'commit_and_push'
134
+ 6. ⏳ Run 'perform_release' or 'skip_release'
135
+ 7. ⏳ Complete task`
136
+ );
137
+ }
138
+
139
+ export async function handleRunTests(args, workflowState) {
140
+ if (!workflowState.state.bugFixed) {
141
+ return textResponse("⚠️ Please mark your feature/bug as fixed first using 'mark_bug_fixed'!");
142
+ }
143
+
144
+ if (!workflowState.state.testsCreated) {
145
+ return textResponse("⚠️ Please create tests first using 'create_tests' before recording test results!");
146
+ }
147
+
148
+ if (
149
+ typeof args.passed !== "boolean" ||
150
+ typeof args.testCommand !== "string" ||
151
+ args.testCommand.trim() === ""
152
+ ) {
153
+ return textResponse(
154
+ "⚠️ Please provide both 'passed' (boolean) and 'testCommand' (non-empty string) when recording test results."
155
+ );
156
+ }
157
+
158
+ workflowState.state.testsPassed = args.passed;
159
+ workflowState.state.testCommand = args.testCommand;
160
+ workflowState.state.testDetails = typeof args.details === "string" ? args.details : "";
161
+ workflowState.state.testsSkipped = false;
162
+ workflowState.state.testsSkippedReason = "";
163
+ workflowState.state.readyCheckCompleted = false;
164
+ workflowState.state.released = false;
165
+ workflowState.state.releaseSkipped = false;
166
+ workflowState.state.releaseSkippedReason = "";
167
+ workflowState.state.commitAndPushCompleted = false;
168
+ workflowState.state.lastCommitMessage = "";
169
+ workflowState.state.lastPushBranch = "";
170
+
171
+ if (!args.passed) {
172
+ workflowState.state.currentPhase = "testing";
173
+ await workflowState.save();
174
+
175
+ return textResponse(
176
+ `❌ TESTS FAILED!\n\n🚫 STOP! DO NOT COMMIT OR PUSH!\n\nYou must:\n1. Fix the failing tests\n2. Run tests again until they pass\n\nTest command: ${args.testCommand}\n\nNever skip or ignore failing tests!`
177
+ );
178
+ }
179
+
180
+ workflowState.state.currentPhase = "documentation";
181
+ await workflowState.save();
182
+
183
+ return textResponse(
184
+ `✅ All tests passed! 🎉\n\nTest command: ${args.testCommand}\n\n📝 Now create or update documentation using 'create_documentation' with:\n- documentationType: "PRD", "README", "RELEASE_NOTES", "inline-comments", "API-docs", "changelog", or "other"\n- summary: Brief description of what was documented\n\nNext Steps:\n1. ✓ Fix/implement feature\n2. ✓ Create tests\n3. ✓ Run tests (GREEN!)\n4. ⏳ Create/update documentation\n5. ⏳ Run 'check_ready_to_commit'\n6. ⏳ Run 'commit_and_push'\n7. ⏳ Run 'perform_release' (or use 'skip_release' if no release is needed)\n8. ⏳ Complete task`
185
+ );
186
+ }
187
+
188
+ export async function handleCreateDocumentation(args, workflowState) {
189
+ if (!workflowState.state.testsPassed) {
190
+ return textResponse("⚠️ Please ensure tests are passing first! Run 'run_tests' with passed=true.");
191
+ }
192
+
193
+ const prdPath = path.join(process.cwd(), "docs", "PRD.md");
194
+ const prdExists = existsSync(prdPath);
195
+
196
+ if (!prdExists) {
197
+ return textResponse(
198
+ `⚠️ PRD file not found!\n\nExpected location: docs/PRD.md\n\nPlease create or update the PRD before marking documentation as complete.`
199
+ );
200
+ }
201
+
202
+ workflowState.state.documentationCreated = true;
203
+ workflowState.state.documentationType = args.documentationType;
204
+ workflowState.state.documentationSummary = args.summary;
205
+ workflowState.state.currentPhase = "ready";
206
+ workflowState.state.readyToCommit = true;
207
+ workflowState.state.readyCheckCompleted = false;
208
+ workflowState.state.released = false;
209
+ workflowState.state.releaseSkipped = false;
210
+ workflowState.state.releaseSkippedReason = "";
211
+ workflowState.state.commitAndPushCompleted = false;
212
+ workflowState.state.lastCommitMessage = "";
213
+ workflowState.state.lastPushBranch = "";
214
+ await workflowState.save();
215
+
216
+ return textResponse(
217
+ `✅ Documentation created/updated!\n\nType: ${args.documentationType}\nSummary: ${args.summary}\n✅ PRD verified: docs/product/PRD.md exists\n\n🎉 You're ready to verify your work!\n\nNext Steps:\n1. ✓ Fix/implement feature\n2. ✓ Create tests\n3. ✓ Run tests (GREEN!)\n4. ✓ Create/update documentation\n5. ⏳ Run 'check_ready_to_commit' to verify\n6. ⏳ Run 'commit_and_push'\n7. ⏳ Run 'perform_release' (or 'skip_release' when applicable)\n8. ⏳ Mark as complete with 'complete_task'`
218
+ );
219
+ }
@@ -0,0 +1 @@
1
+ export { handleToolCall } from "./handler-modules/index.js";