forked from khaoss85/mcp-orchestro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_intelligent_workflow.mjs
More file actions
executable file
·258 lines (237 loc) · 10.4 KB
/
test_intelligent_workflow.mjs
File metadata and controls
executable file
·258 lines (237 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/usr/bin/env node
/**
* Test script for intelligent_decompose_story workflow
* This demonstrates the new workflow end-to-end
*/
import { intelligent_decompose_story, save_story_decomposition } from './dist/tools/intelligentDecompose.js';
async function testIntelligentWorkflow() {
console.log('🧪 Testing Intelligent Story Decomposition Workflow\n');
const userStory = "User should be able to view and filter tasks by multiple criteria including status, tags, and complexity in the web dashboard with real-time updates";
const projectId = "7b189723-6695-4f56-80bd-ef242f293402";
console.log('📋 User Story:');
console.log(`"${userStory}"\n`);
// Step 1: Get the analysis prompt
console.log('Step 1: Calling intelligent_decompose_story...\n');
try {
const result = await intelligent_decompose_story({
userStory,
projectId
});
if (!result.success) {
console.error('❌ Error:', result.error);
process.exit(1);
}
console.log('✅ Prompt generated successfully!\n');
console.log('📝 Generated Prompt:');
console.log('='.repeat(80));
console.log(result.prompt);
console.log('='.repeat(80));
console.log('\n');
console.log('📋 Next Steps:');
console.log(result.nextSteps);
console.log('\n');
console.log('🔍 Now Claude Code would:');
console.log('1. Use Grep to search for similar features');
console.log('2. Use Glob to find related components');
console.log('3. Use Read to understand existing patterns');
console.log('4. Create detailed task breakdown with real file paths');
console.log('5. Call save_story_decomposition with the analysis\n');
// Step 2: Simulate Claude Code's analysis
console.log('Step 2: Simulating codebase analysis...\n');
// This is what Claude Code would discover:
const mockAnalysis = {
tasks: [
{
title: "Extend TasksGrid component with advanced filtering UI",
description: "Add multi-select filters for status, tags, and complexity to the existing TasksGrid component in web-dashboard/components/tasks/TasksGrid.tsx. Follow the existing filter pattern from StatusFilter. Add FilterBar component with dropdown selects for each criteria. Ensure accessibility with proper ARIA labels.",
complexity: "medium",
estimatedHours: 4,
dependencies: [],
tags: ["frontend", "react", "ui", "filtering"],
category: "design_frontend",
filesToModify: [
{
path: "web-dashboard/components/tasks/TasksGrid.tsx",
reason: "Add FilterBar component and filter state management",
risk: "low"
},
{
path: "web-dashboard/components/tasks/TaskCard.tsx",
reason: "Ensure task card displays all filterable fields",
risk: "low"
}
],
filesToCreate: [
{
path: "web-dashboard/components/tasks/FilterBar.tsx",
reason: "New component for multi-criteria filtering UI"
},
{
path: "web-dashboard/hooks/useTaskFilters.ts",
reason: "Custom hook for filter state and logic"
}
],
codebaseReferences: [
{
file: "web-dashboard/components/tasks/TasksGrid.tsx",
description: "Existing grid structure and data fetching pattern",
lines: "1-150"
}
]
},
{
title: "Add multi-criteria filtering to list_tasks API",
description: "Extend the list_tasks MCP tool in src/tools/task.ts to support filtering by multiple criteria simultaneously. Update SQL query builder to handle AND/OR conditions for status, tags (array contains), and complexity. Maintain backward compatibility with existing single-filter API.",
complexity: "medium",
estimatedHours: 3,
dependencies: ["Extend TasksGrid component with advanced filtering UI"],
tags: ["backend", "api", "filtering", "database"],
category: "backend_database",
filesToModify: [
{
path: "src/tools/task.ts",
reason: "Extend listTasks function with multi-criteria filtering",
risk: "medium"
},
{
path: "src/server.ts",
reason: "Update list_tasks tool schema to include new filter params",
risk: "low"
}
],
filesToCreate: [],
codebaseReferences: [
{
file: "src/tools/task.ts",
description: "Existing listTasks implementation with status filter",
lines: "50-120"
}
]
},
{
title: "Implement real-time task updates with Supabase subscriptions",
description: "Add Supabase realtime subscription to tasks table in web dashboard. Create useTaskSubscription hook that subscribes to INSERT, UPDATE, DELETE events. Update TasksGrid to automatically refresh when tasks change. Handle reconnection and error states gracefully.",
complexity: "complex",
estimatedHours: 5,
dependencies: ["Add multi-criteria filtering to list_tasks API"],
tags: ["frontend", "realtime", "supabase", "subscriptions"],
category: "design_frontend",
filesToModify: [
{
path: "web-dashboard/components/tasks/TasksGrid.tsx",
reason: "Integrate useTaskSubscription hook for real-time updates",
risk: "medium"
}
],
filesToCreate: [
{
path: "web-dashboard/hooks/useTaskSubscription.ts",
reason: "Hook for managing Supabase realtime subscriptions"
},
{
path: "web-dashboard/lib/supabaseClient.ts",
reason: "Singleton Supabase client for realtime connections"
}
],
codebaseReferences: [
{
file: "web-dashboard/app/page.tsx",
description: "Existing data fetching pattern to enhance with subscriptions",
lines: "20-45"
}
]
},
{
title: "Add comprehensive tests for filtering and real-time features",
description: "Create unit tests for useTaskFilters hook, integration tests for list_tasks API with multiple filters, and E2E tests for real-time updates. Test edge cases: empty filters, all filters combined, rapid filter changes, subscription reconnection.",
complexity: "medium",
estimatedHours: 4,
dependencies: ["Implement real-time task updates with Supabase subscriptions"],
tags: ["testing", "e2e", "integration", "unit"],
category: "test_fix",
filesToModify: [],
filesToCreate: [
{
path: "web-dashboard/__tests__/hooks/useTaskFilters.test.tsx",
reason: "Unit tests for filter hook"
},
{
path: "web-dashboard/__tests__/hooks/useTaskSubscription.test.tsx",
reason: "Unit tests for subscription hook with mock Supabase"
},
{
path: "src/__tests__/tools/task-filtering.test.ts",
reason: "Integration tests for multi-criteria filtering API"
}
],
codebaseReferences: []
}
],
overallComplexity: "medium",
totalEstimatedHours: 16,
architectureNotes: [
"Following existing React component structure in web-dashboard/components/",
"Reusing Supabase client pattern from existing codebase",
"API maintains backward compatibility with single-filter interface",
"Real-time subscriptions use Supabase's built-in realtime feature"
],
risks: [
{
level: "medium",
description: "TasksGrid is a core component used throughout dashboard",
mitigation: "Add comprehensive tests and feature flag for gradual rollout"
},
{
level: "medium",
description: "Realtime subscriptions can cause performance issues with large datasets",
mitigation: "Implement pagination and limit subscription to visible tasks only"
},
{
level: "low",
description: "Multiple filter combinations increase SQL query complexity",
mitigation: "Add query performance monitoring and optimize indexes"
}
],
recommendations: [
"Consider adding filter presets (e.g., 'My Tasks', 'Urgent', 'Blocked')",
"Add URL query params to persist filter state across page reloads",
"Implement debouncing for rapid filter changes to reduce API calls",
"Add loading skeleton during real-time updates for better UX"
]
};
console.log('📊 Analysis Complete! Discovered:');
console.log(`- ${mockAnalysis.tasks.length} tasks`);
console.log(`- ${mockAnalysis.totalEstimatedHours} hours estimated`);
console.log(`- ${mockAnalysis.risks.length} risks identified`);
console.log(`- ${mockAnalysis.recommendations.length} recommendations\n`);
// Step 3: Save the decomposition
console.log('Step 3: Calling save_story_decomposition...\n');
const saveResult = await save_story_decomposition({
projectId,
userStory,
analysis: mockAnalysis
});
if (!saveResult.success) {
console.error('❌ Error:', saveResult.error);
process.exit(1);
}
console.log('✅ Story decomposed successfully!\n');
console.log('📦 Results:');
console.log(`- User Story ID: ${saveResult.userStory.id}`);
console.log(`- Tasks Created: ${saveResult.totalTasks}`);
console.log(`- Total Estimated Hours: ${saveResult.totalEstimatedHours}`);
console.log(`\n${saveResult.message}\n`);
console.log('🎉 Workflow test completed successfully!\n');
console.log('📋 Tasks created with:');
console.log(' ✅ Real file paths from codebase analysis');
console.log(' ✅ Accurate dependencies based on implementation order');
console.log(' ✅ Realistic estimates from code complexity');
console.log(' ✅ Identified risks and mitigation strategies');
console.log(' ✅ Actionable recommendations\n');
} catch (error) {
console.error('❌ Workflow test failed:', error);
console.error(error.stack);
process.exit(1);
}
}
testIntelligentWorkflow();