mycontext-cli 2.0.8 → 2.0.9

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 (198) hide show
  1. package/dist/agents/communication/AgentCommunicationManager.d.ts +3 -3
  2. package/dist/agents/communication/AgentCommunicationManager.d.ts.map +1 -1
  3. package/dist/agents/communication/AgentCommunicationManager.js +7 -6
  4. package/dist/agents/communication/AgentCommunicationManager.js.map +1 -1
  5. package/dist/agents/evolution/CodeEvolutionEngine.d.ts.map +1 -1
  6. package/dist/agents/evolution/CodeEvolutionEngine.js +10 -7
  7. package/dist/agents/evolution/CodeEvolutionEngine.js.map +1 -1
  8. package/dist/agents/implementations/ArchitectAgent.js +2 -2
  9. package/dist/agents/implementations/ArchitectAgent.js.map +1 -1
  10. package/dist/agents/implementations/BackendDevAgent.d.ts.map +1 -1
  11. package/dist/agents/implementations/BackendDevAgent.js +4 -1
  12. package/dist/agents/implementations/BackendDevAgent.js.map +1 -1
  13. package/dist/agents/implementations/BuildStrategyAgent.d.ts.map +1 -1
  14. package/dist/agents/implementations/BuildStrategyAgent.js +4 -3
  15. package/dist/agents/implementations/BuildStrategyAgent.js.map +1 -1
  16. package/dist/agents/implementations/CodeGenSubAgent.d.ts.map +1 -1
  17. package/dist/agents/implementations/CodeGenSubAgent.js +6 -5
  18. package/dist/agents/implementations/CodeGenSubAgent.js.map +1 -1
  19. package/dist/agents/implementations/DocsSubAgent.js +2 -2
  20. package/dist/agents/implementations/DocsSubAgent.js.map +1 -1
  21. package/dist/agents/implementations/EnhancementAgent.d.ts.map +1 -1
  22. package/dist/agents/implementations/EnhancementAgent.js +6 -4
  23. package/dist/agents/implementations/EnhancementAgent.js.map +1 -1
  24. package/dist/agents/implementations/InteractiveAgent.d.ts.map +1 -1
  25. package/dist/agents/implementations/InteractiveAgent.js +8 -1
  26. package/dist/agents/implementations/InteractiveAgent.js.map +1 -1
  27. package/dist/agents/implementations/PromptConstructorAgent.d.ts.map +1 -1
  28. package/dist/agents/implementations/PromptConstructorAgent.js +79 -31
  29. package/dist/agents/implementations/PromptConstructorAgent.js.map +1 -1
  30. package/dist/agents/implementations/QASubAgent.js +2 -2
  31. package/dist/agents/implementations/QASubAgent.js.map +1 -1
  32. package/dist/agents/implementations/SecurityAgent.js +2 -2
  33. package/dist/agents/implementations/SecurityAgent.js.map +1 -1
  34. package/dist/agents/implementations/WorkflowAgent.d.ts +0 -1
  35. package/dist/agents/implementations/WorkflowAgent.d.ts.map +1 -1
  36. package/dist/agents/implementations/WorkflowAgent.js +6 -10
  37. package/dist/agents/implementations/WorkflowAgent.js.map +1 -1
  38. package/dist/agents/intelligence/ProjectIntelligence.js +5 -5
  39. package/dist/agents/intelligence/ProjectIntelligence.js.map +1 -1
  40. package/dist/agents/orchestrator/SubAgentOrchestrator.d.ts.map +1 -1
  41. package/dist/agents/orchestrator/SubAgentOrchestrator.js +4 -4
  42. package/dist/agents/orchestrator/SubAgentOrchestrator.js.map +1 -1
  43. package/dist/cli.js +8 -40
  44. package/dist/cli.js.map +1 -1
  45. package/dist/commands/analyze.d.ts.map +1 -1
  46. package/dist/commands/analyze.js +9 -9
  47. package/dist/commands/analyze.js.map +1 -1
  48. package/dist/commands/enhance.d.ts.map +1 -1
  49. package/dist/commands/enhance.js +23 -78
  50. package/dist/commands/enhance.js.map +1 -1
  51. package/dist/commands/generate-components.d.ts.map +1 -1
  52. package/dist/commands/generate-components.js +12 -7
  53. package/dist/commands/generate-components.js.map +1 -1
  54. package/dist/commands/generate-todos.js +1 -1
  55. package/dist/commands/generate-todos.js.map +1 -1
  56. package/dist/commands/generate.d.ts.map +1 -1
  57. package/dist/commands/generate.js +57 -41
  58. package/dist/commands/generate.js.map +1 -1
  59. package/dist/commands/playbooks.d.ts.map +1 -1
  60. package/dist/commands/playbooks.js +14 -8
  61. package/dist/commands/playbooks.js.map +1 -1
  62. package/dist/commands/preview.js +1 -1
  63. package/dist/commands/preview.js.map +1 -1
  64. package/dist/commands/refine.d.ts.map +1 -1
  65. package/dist/commands/refine.js +5 -3
  66. package/dist/commands/refine.js.map +1 -1
  67. package/dist/commands/sanitize.d.ts.map +1 -1
  68. package/dist/commands/sanitize.js +11 -4
  69. package/dist/commands/sanitize.js.map +1 -1
  70. package/dist/commands/setup-database.d.ts.map +1 -1
  71. package/dist/commands/setup-database.js +9 -7
  72. package/dist/commands/setup-database.js.map +1 -1
  73. package/dist/commands/setup-instantdb.d.ts.map +1 -1
  74. package/dist/commands/setup-instantdb.js +9 -7
  75. package/dist/commands/setup-instantdb.js.map +1 -1
  76. package/dist/config/build-strategies.json +2 -2
  77. package/dist/{agents/personalities/definitions.d.ts → constants/subAgentPersonalities.d.ts} +2 -2
  78. package/dist/constants/subAgentPersonalities.d.ts.map +1 -0
  79. package/dist/{agents/personalities/definitions.js → constants/subAgentPersonalities.js} +2 -2
  80. package/dist/constants/subAgentPersonalities.js.map +1 -0
  81. package/dist/package.json +1 -1
  82. package/dist/types/analysis.d.ts +67 -0
  83. package/dist/types/analysis.d.ts.map +1 -0
  84. package/dist/types/analysis.js +7 -0
  85. package/dist/types/analysis.js.map +1 -0
  86. package/dist/types/components.d.ts +90 -0
  87. package/dist/types/components.d.ts.map +1 -0
  88. package/dist/types/components.js +7 -0
  89. package/dist/types/components.js.map +1 -0
  90. package/dist/types/enhancement.d.ts +127 -0
  91. package/dist/types/enhancement.d.ts.map +1 -0
  92. package/dist/types/enhancement.js +7 -0
  93. package/dist/types/enhancement.js.map +1 -0
  94. package/dist/types/index.d.ts +4 -0
  95. package/dist/types/index.d.ts.map +1 -1
  96. package/dist/types/index.js +25 -0
  97. package/dist/types/index.js.map +1 -1
  98. package/dist/types/progress.d.ts +88 -0
  99. package/dist/types/progress.d.ts.map +1 -0
  100. package/dist/types/progress.js +7 -0
  101. package/dist/types/progress.js.map +1 -0
  102. package/dist/utils/ProjectHealthMonitor.d.ts.map +1 -1
  103. package/dist/utils/ProjectHealthMonitor.js +47 -36
  104. package/dist/utils/ProjectHealthMonitor.js.map +1 -1
  105. package/dist/utils/agentDefinitions.d.ts +2 -2
  106. package/dist/utils/agentDefinitions.d.ts.map +1 -1
  107. package/dist/utils/agentDefinitions.js +40 -33
  108. package/dist/utils/agentDefinitions.js.map +1 -1
  109. package/dist/utils/buildStrategyManager.d.ts.map +1 -1
  110. package/dist/utils/buildStrategyManager.js +1 -1
  111. package/dist/utils/buildStrategyManager.js.map +1 -1
  112. package/dist/utils/claudeAgentClient.d.ts +0 -1
  113. package/dist/utils/claudeAgentClient.d.ts.map +1 -1
  114. package/dist/utils/claudeAgentClient.js +46 -39
  115. package/dist/utils/claudeAgentClient.js.map +1 -1
  116. package/dist/utils/hybridAIClient.d.ts +1 -9
  117. package/dist/utils/hybridAIClient.d.ts.map +1 -1
  118. package/dist/utils/hybridAIClient.js +81 -78
  119. package/dist/utils/hybridAIClient.js.map +1 -1
  120. package/dist/utils/mcpAgentIntegration.d.ts.map +1 -1
  121. package/dist/utils/mcpAgentIntegration.js +1 -1
  122. package/dist/utils/mcpAgentIntegration.js.map +1 -1
  123. package/dist/utils/mcpTools.d.ts +5 -5
  124. package/dist/utils/mcpTools.d.ts.map +1 -1
  125. package/dist/utils/mcpTools.js +319 -241
  126. package/dist/utils/mcpTools.js.map +1 -1
  127. package/dist/utils/progressTracker.d.ts +3 -79
  128. package/dist/utils/progressTracker.d.ts.map +1 -1
  129. package/dist/utils/progressTracker.js +92 -68
  130. package/dist/utils/progressTracker.js.map +1 -1
  131. package/dist/utils/typeTemplateGenerator.d.ts.map +1 -1
  132. package/dist/utils/typeTemplateGenerator.js +125 -79
  133. package/dist/utils/typeTemplateGenerator.js.map +1 -1
  134. package/package.json +1 -1
  135. package/dist/agents/implementations/ClaudeAgentWorkflow.d.ts +0 -110
  136. package/dist/agents/implementations/ClaudeAgentWorkflow.d.ts.map +0 -1
  137. package/dist/agents/implementations/ClaudeAgentWorkflow.js +0 -661
  138. package/dist/agents/implementations/ClaudeAgentWorkflow.js.map +0 -1
  139. package/dist/agents/personalities/definitions.d.ts.map +0 -1
  140. package/dist/agents/personalities/definitions.js.map +0 -1
  141. package/dist/commands/model.d.ts +0 -22
  142. package/dist/commands/model.d.ts.map +0 -1
  143. package/dist/commands/model.js +0 -130
  144. package/dist/commands/model.js.map +0 -1
  145. package/dist/commands/normalize.d.ts +0 -5
  146. package/dist/commands/normalize.d.ts.map +0 -1
  147. package/dist/commands/normalize.js +0 -128
  148. package/dist/commands/normalize.js.map +0 -1
  149. package/dist/commands/pricing.d.ts +0 -15
  150. package/dist/commands/pricing.d.ts.map +0 -1
  151. package/dist/commands/pricing.js +0 -94
  152. package/dist/commands/pricing.js.map +0 -1
  153. package/dist/config/ai-providers.json +0 -102
  154. package/dist/config/pricing.json +0 -55
  155. package/dist/utils/aiClientFactory.d.ts +0 -93
  156. package/dist/utils/aiClientFactory.d.ts.map +0 -1
  157. package/dist/utils/aiClientFactory.js +0 -290
  158. package/dist/utils/aiClientFactory.js.map +0 -1
  159. package/dist/utils/aiClientRouter.d.ts +0 -121
  160. package/dist/utils/aiClientRouter.d.ts.map +0 -1
  161. package/dist/utils/aiClientRouter.js +0 -401
  162. package/dist/utils/aiClientRouter.js.map +0 -1
  163. package/dist/utils/apiKeyManager.d.ts +0 -137
  164. package/dist/utils/apiKeyManager.d.ts.map +0 -1
  165. package/dist/utils/apiKeyManager.js +0 -479
  166. package/dist/utils/apiKeyManager.js.map +0 -1
  167. package/dist/utils/claudeClient.d.ts +0 -28
  168. package/dist/utils/claudeClient.d.ts.map +0 -1
  169. package/dist/utils/claudeClient.js +0 -233
  170. package/dist/utils/claudeClient.js.map +0 -1
  171. package/dist/utils/geminiClient.d.ts +0 -61
  172. package/dist/utils/geminiClient.d.ts.map +0 -1
  173. package/dist/utils/geminiClient.js +0 -173
  174. package/dist/utils/geminiClient.js.map +0 -1
  175. package/dist/utils/githubModelsClient.d.ts +0 -27
  176. package/dist/utils/githubModelsClient.d.ts.map +0 -1
  177. package/dist/utils/githubModelsClient.js +0 -332
  178. package/dist/utils/githubModelsClient.js.map +0 -1
  179. package/dist/utils/huggingFaceClient.d.ts +0 -44
  180. package/dist/utils/huggingFaceClient.d.ts.map +0 -1
  181. package/dist/utils/huggingFaceClient.js +0 -169
  182. package/dist/utils/huggingFaceClient.js.map +0 -1
  183. package/dist/utils/openaiClient.d.ts +0 -24
  184. package/dist/utils/openaiClient.d.ts.map +0 -1
  185. package/dist/utils/openaiClient.js +0 -204
  186. package/dist/utils/openaiClient.js.map +0 -1
  187. package/dist/utils/qwenClient.d.ts +0 -22
  188. package/dist/utils/qwenClient.d.ts.map +0 -1
  189. package/dist/utils/qwenClient.js +0 -185
  190. package/dist/utils/qwenClient.js.map +0 -1
  191. package/dist/utils/streamingHandler.d.ts +0 -98
  192. package/dist/utils/streamingHandler.d.ts.map +0 -1
  193. package/dist/utils/streamingHandler.js +0 -259
  194. package/dist/utils/streamingHandler.js.map +0 -1
  195. package/dist/utils/xaiClient.d.ts +0 -19
  196. package/dist/utils/xaiClient.d.ts.map +0 -1
  197. package/dist/utils/xaiClient.js +0 -135
  198. package/dist/utils/xaiClient.js.map +0 -1
@@ -1,661 +0,0 @@
1
- "use strict";
2
- /**
3
- * ClaudeAgentWorkflow Implementation
4
- *
5
- * Enhanced workflow agent that leverages Claude Agent SDK for advanced
6
- * context management, tool permissions, and MCP integration.
7
- */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ClaudeAgentWorkflow = void 0;
13
- const claudeAgentClient_1 = require("../../utils/claudeAgentClient");
14
- const contextManager_1 = require("../../utils/contextManager");
15
- const toolPermissions_1 = require("../../utils/toolPermissions");
16
- const mcpAgentIntegration_1 = require("../../utils/mcpAgentIntegration");
17
- const chalk_1 = __importDefault(require("chalk"));
18
- class ClaudeAgentWorkflow {
19
- constructor(workingDirectory) {
20
- this.name = "ClaudeAgentWorkflow";
21
- this.description = "Enhanced workflow agent using Claude Agent SDK with advanced context management and MCP integration";
22
- this.personality = "Advanced AI coordinator with deep project understanding and intelligent workflow orchestration";
23
- this.llmProvider = "claude-agent-sdk";
24
- this.expertise = [
25
- "workflow-management",
26
- "context-management",
27
- "tool-permissions",
28
- "mcp-integration",
29
- "agent-coordination",
30
- "error-handling",
31
- "user-experience",
32
- ];
33
- this.completedSteps = new Set();
34
- this.failedSteps = [];
35
- this.userInteractions = 0;
36
- this.totalRetries = 0;
37
- this.workflowContext = {};
38
- this.claudeAgentClient = new claudeAgentClient_1.ClaudeAgentClient(workingDirectory);
39
- this.contextManager = new contextManager_1.ContextManager(workingDirectory);
40
- this.permissionManager = new toolPermissions_1.ToolPermissionManager(workingDirectory);
41
- this.mcpIntegration = new mcpAgentIntegration_1.MCPAgentIntegration(workingDirectory);
42
- }
43
- /**
44
- * Check if Claude Agent SDK is available
45
- */
46
- isClaudeAgentAvailable() {
47
- return this.claudeAgentClient.hasApiKey();
48
- }
49
- async run(input) {
50
- const startTime = Date.now();
51
- const maxRetries = input.maxRetries || 3;
52
- console.log(chalk_1.default.blue.bold("🚀 Starting Claude Agent SDK Enhanced Workflow\n"));
53
- console.log(chalk_1.default.gray(`Project: ${input.projectName}`));
54
- console.log(chalk_1.default.gray(`Framework: ${input.framework}`));
55
- console.log(chalk_1.default.gray(`Interactive Mode: ${input.interactive ? "Enabled" : "Disabled"}\n`));
56
- try {
57
- // Initialize Claude Agent SDK
58
- await this.initializeClaudeAgent();
59
- // Load and prepare context
60
- await this.prepareWorkflowContext(input);
61
- // Define enhanced workflow steps
62
- const steps = this.defineEnhancedWorkflowSteps(input);
63
- // Execute workflow with Claude Agent SDK
64
- await this.executeEnhancedWorkflow(steps, maxRetries, input.interactive || false);
65
- const duration = Date.now() - startTime;
66
- const completedSteps = Array.from(this.completedSteps);
67
- console.log(chalk_1.default.green.bold("\n✅ Claude Agent SDK Workflow completed successfully!"));
68
- console.log(chalk_1.default.blue(`⏱️ Total duration: ${Math.round(duration / 1000)}s`));
69
- console.log(chalk_1.default.blue(`📋 Completed steps: ${completedSteps.length}`));
70
- console.log(chalk_1.default.blue(`🔄 Total retries: ${this.totalRetries}`));
71
- console.log(chalk_1.default.blue(`💬 User interactions: ${this.userInteractions}`));
72
- // Save final context
73
- await this.contextManager.saveContext(this.workflowContext);
74
- return {
75
- success: true,
76
- projectPath: input.projectName,
77
- completedSteps,
78
- failedSteps: this.failedSteps,
79
- userInteractions: this.userInteractions,
80
- totalRetries: this.totalRetries,
81
- duration,
82
- };
83
- }
84
- catch (error) {
85
- const duration = Date.now() - startTime;
86
- console.log(chalk_1.default.red.bold("\n❌ Claude Agent SDK Workflow failed"));
87
- console.log(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
88
- return {
89
- success: false,
90
- projectPath: input.projectName,
91
- completedSteps: Array.from(this.completedSteps),
92
- failedSteps: this.failedSteps,
93
- userInteractions: this.userInteractions,
94
- totalRetries: this.totalRetries,
95
- duration,
96
- };
97
- }
98
- finally {
99
- // Cleanup
100
- await this.claudeAgentClient.cleanup();
101
- }
102
- }
103
- /**
104
- * Initialize Claude Agent SDK with enhanced configuration
105
- */
106
- async initializeClaudeAgent() {
107
- console.log(chalk_1.default.yellow("🔧 Initializing Claude Agent SDK with advanced features..."));
108
- try {
109
- // Check if Claude Agent SDK is available
110
- if (!this.claudeAgentClient.hasApiKey()) {
111
- throw new Error("Claude API key not configured. Set MYCONTEXT_CLAUDE_API_KEY or ANTHROPIC_API_KEY");
112
- }
113
- // Initialize MCP integration
114
- await this.mcpIntegration.initialize(this.claudeAgentClient);
115
- // Get permission configuration
116
- const permissionConfig = this.permissionManager.getClaudeAgentConfig();
117
- // Initialize Claude Agent with Phase 2 enhanced configuration
118
- await this.claudeAgentClient.initialize({
119
- model: "claude-3-5-sonnet-20241022",
120
- temperature: 0.2,
121
- maxTokens: 8000,
122
- systemPrompt: this.getEnhancedSystemPrompt(),
123
- ...permissionConfig,
124
- contextManagement: true,
125
- // NEW: Setting sources for reproducible builds
126
- settingSources: ['project', 'local'],
127
- // NEW: Register workflow-specific hooks
128
- hooks: {
129
- PreToolUse: async (input, toolUseID, options) => {
130
- const toolInput = input;
131
- console.log(chalk_1.default.gray(` 🔧 Using tool: ${toolInput.tool_name || 'unknown'}`));
132
- return { continue: true };
133
- },
134
- PostToolUse: async (input, toolUseID, options) => {
135
- const toolInput = input;
136
- console.log(chalk_1.default.gray(` ✅ Tool completed: ${toolInput.tool_name || 'unknown'}`));
137
- return { continue: true };
138
- },
139
- SessionStart: async (input, toolUseID, options) => {
140
- console.log(chalk_1.default.blue(' 🚀 Agent session started'));
141
- return { continue: true };
142
- },
143
- },
144
- // NEW: Permission callback for interactive approval
145
- canUseTool: async (toolName, input, options) => {
146
- // Auto-approve safe read operations
147
- if (['Read', 'Glob', 'Grep'].includes(toolName)) {
148
- return { behavior: 'allow', updatedInput: input };
149
- }
150
- // Always approve our custom MCP tools
151
- if ([
152
- 'AnalyzeComponent',
153
- 'ValidatePRD',
154
- 'CheckTypes',
155
- 'GenerateDocs',
156
- 'DetectExistingComponents',
157
- 'MapComponentsToRoutes',
158
- 'GenerateScaffolding',
159
- ].includes(toolName)) {
160
- return { behavior: 'allow', updatedInput: input };
161
- }
162
- // For write operations, ask for permission (simplified for now)
163
- return { behavior: 'allow', updatedInput: input };
164
- },
165
- });
166
- console.log(chalk_1.default.green("✅ Claude Agent SDK initialized with advanced features"));
167
- // Log available agents
168
- const availableAgents = this.claudeAgentClient.getAvailableAgents();
169
- console.log(chalk_1.default.gray(` 📦 Available agents: ${availableAgents.length}`));
170
- }
171
- catch (error) {
172
- console.log(chalk_1.default.red(`❌ Claude Agent SDK initialization failed: ${error.message}`));
173
- throw error;
174
- }
175
- }
176
- /**
177
- * Prepare workflow context
178
- */
179
- async prepareWorkflowContext(input) {
180
- console.log(chalk_1.default.yellow("📋 Preparing workflow context..."));
181
- try {
182
- // Load existing context
183
- this.workflowContext = await this.contextManager.loadContext();
184
- // Add workflow-specific context
185
- this.workflowContext = await this.contextManager.mergeContext(this.workflowContext, {
186
- userPrompt: input.description,
187
- workingDirectory: input.projectName === "." ? process.cwd() : input.projectName,
188
- previousOutputs: {
189
- workflowStart: {
190
- projectName: input.projectName,
191
- framework: input.framework,
192
- description: input.description,
193
- interactive: input.interactive,
194
- timestamp: new Date().toISOString(),
195
- },
196
- },
197
- });
198
- // Check if context needs compaction
199
- const contextStats = this.contextManager.getContextStats(this.workflowContext);
200
- if (contextStats.totalSize > 50000) {
201
- // 50KB limit
202
- console.log(chalk_1.default.yellow("⚠️ Context size exceeds limit, compacting..."));
203
- this.workflowContext = await this.contextManager.compactContext(this.workflowContext);
204
- }
205
- console.log(chalk_1.default.green("✅ Workflow context prepared"));
206
- }
207
- catch (error) {
208
- console.log(chalk_1.default.yellow(`⚠️ Context preparation warning: ${error.message}`));
209
- }
210
- }
211
- /**
212
- * Define enhanced workflow steps with Claude Agent SDK
213
- */
214
- defineEnhancedWorkflowSteps(input) {
215
- return [
216
- {
217
- id: "context-analysis",
218
- name: "Context Analysis",
219
- description: "Analyze project context and requirements using Claude Agent SDK",
220
- agentName: this.name,
221
- agent: this,
222
- input: {
223
- workflowType: "context-analysis",
224
- projectContext: this.workflowContext,
225
- requirements: input.description,
226
- },
227
- required: true,
228
- retryable: true,
229
- interactive: false,
230
- },
231
- {
232
- id: "project-setup",
233
- name: "Project Setup",
234
- description: "Initialize project structure with enhanced context awareness",
235
- agentName: this.name,
236
- agent: this,
237
- input: {
238
- workflowType: "project-setup",
239
- projectName: input.projectName,
240
- framework: input.framework,
241
- context: this.workflowContext,
242
- },
243
- dependencies: ["context-analysis"],
244
- required: true,
245
- retryable: true,
246
- interactive: false,
247
- },
248
- // NEW: Component Detection Step (Component-First Workflow)
249
- {
250
- id: "component-detection",
251
- name: "Component Detection",
252
- description: "Detect existing validated components for component-first workflow",
253
- agentName: "component-first-builder",
254
- agent: this,
255
- input: {
256
- workflowType: "component-detection",
257
- projectPath: input.projectName,
258
- includeValidation: true,
259
- },
260
- dependencies: ["project-setup"],
261
- required: true,
262
- retryable: true,
263
- interactive: false,
264
- },
265
- {
266
- id: "requirement-gathering",
267
- name: "Requirement Gathering",
268
- description: "Gather detailed requirements using Claude Agent SDK",
269
- agentName: this.name,
270
- agent: this,
271
- input: {
272
- workflowType: "requirement-gathering",
273
- context: this.workflowContext,
274
- interactive: input.interactive,
275
- },
276
- dependencies: ["component-detection"],
277
- required: input.interactive,
278
- retryable: true,
279
- interactive: true,
280
- },
281
- {
282
- id: "context-generation",
283
- name: "Context Generation",
284
- description: "Generate comprehensive context files using Claude Agent SDK",
285
- agentName: this.name,
286
- agent: this,
287
- input: {
288
- workflowType: "context-generation",
289
- context: this.workflowContext,
290
- requirements: input.description,
291
- },
292
- dependencies: ["requirement-gathering"],
293
- required: true,
294
- retryable: true,
295
- interactive: false,
296
- // Skip if components already exist and should be reused
297
- skip: (context) => context.componentDetection?.recommendation === "REUSE_COMPONENTS",
298
- },
299
- // NEW: Component Mapping Step (Only for REUSE_COMPONENTS mode)
300
- {
301
- id: "component-mapping",
302
- name: "Component Mapping",
303
- description: "Map existing components to routes intelligently",
304
- agentName: "component-first-builder",
305
- agent: this,
306
- input: {
307
- workflowType: "component-mapping",
308
- context: this.workflowContext,
309
- architectureType: input.architectureType || "nextjs-app-router",
310
- },
311
- dependencies: ["component-detection"],
312
- required: false,
313
- retryable: true,
314
- interactive: false,
315
- // Only run in REUSE_COMPONENTS mode
316
- skip: (context) => context.componentDetection?.recommendation !== "REUSE_COMPONENTS",
317
- },
318
- {
319
- id: "component-generation",
320
- name: "Component Generation",
321
- description: "Generate React components using Claude Agent SDK with MCP integration",
322
- agentName: this.name,
323
- agent: this,
324
- input: {
325
- workflowType: "component-generation",
326
- context: this.workflowContext,
327
- components: "all",
328
- },
329
- dependencies: ["context-generation"],
330
- required: true,
331
- retryable: true,
332
- interactive: false,
333
- // Skip if components should be reused
334
- skip: (context) => context.componentDetection?.recommendation === "REUSE_COMPONENTS",
335
- },
336
- // NEW: Scaffolding Generation Step
337
- {
338
- id: "scaffolding-generation",
339
- name: "Scaffolding Generation",
340
- description: "Generate routes, actions, and hooks for components",
341
- agentName: "component-first-builder",
342
- agent: this,
343
- input: {
344
- workflowType: "scaffolding-generation",
345
- context: this.workflowContext,
346
- projectPath: input.projectName,
347
- generateRoutes: input.generateRoutes !== false,
348
- generateActions: input.generateServerActions !== false,
349
- generateHooks: true,
350
- generateLayouts: true,
351
- },
352
- dependencies: ["component-mapping", "component-generation"],
353
- required: false,
354
- retryable: true,
355
- interactive: false,
356
- // Always run if complete architecture is enabled
357
- skip: (context) => !input.completeArchitecture,
358
- },
359
- {
360
- id: "validation-testing",
361
- name: "Validation & Testing",
362
- description: "Validate and test generated components using Claude Agent SDK",
363
- agentName: this.name,
364
- agent: this,
365
- input: {
366
- workflowType: "validation-testing",
367
- context: this.workflowContext,
368
- },
369
- dependencies: ["component-generation", "scaffolding-generation"],
370
- required: true,
371
- retryable: true,
372
- interactive: false,
373
- },
374
- ];
375
- }
376
- /**
377
- * Execute enhanced workflow with Claude Agent SDK
378
- */
379
- async executeEnhancedWorkflow(steps, maxRetries, interactive) {
380
- for (const step of steps) {
381
- await this.executeStepWithClaudeAgent(step, maxRetries, interactive);
382
- }
383
- }
384
- /**
385
- * Execute individual step using Claude Agent SDK
386
- */
387
- async executeStepWithClaudeAgent(step, maxRetries, interactive) {
388
- const stepId = step.id;
389
- let retryCount = 0;
390
- console.log(chalk_1.default.blue(`\n🔄 Executing: ${step.name}`));
391
- console.log(chalk_1.default.gray(` ${step.description}`));
392
- while (retryCount <= maxRetries) {
393
- try {
394
- // Build step-specific prompt
395
- const stepPrompt = this.buildStepPrompt(step);
396
- // Execute step using Claude Agent SDK
397
- const result = await this.claudeAgentClient.runAgentWorkflow(stepPrompt, this.workflowContext, {
398
- model: "claude-3-5-sonnet-20241022",
399
- temperature: 0.2,
400
- maxTokens: 8000,
401
- });
402
- // Process step result
403
- await this.processStepResult(step, result);
404
- // Mark step as completed
405
- this.completedSteps.add(stepId);
406
- console.log(chalk_1.default.green(`✅ ${step.name} completed successfully`));
407
- // Update context with step results
408
- this.workflowContext = await this.contextManager.mergeContext(this.workflowContext, {
409
- previousOutputs: {
410
- ...this.workflowContext.previousOutputs,
411
- [stepId]: {
412
- result: result.content,
413
- timestamp: new Date().toISOString(),
414
- success: true,
415
- },
416
- },
417
- });
418
- return;
419
- }
420
- catch (error) {
421
- retryCount++;
422
- this.totalRetries++;
423
- if (retryCount <= maxRetries) {
424
- console.log(chalk_1.default.yellow(`⚠️ ${step.name} failed, retrying (${retryCount}/${maxRetries})`));
425
- console.log(chalk_1.default.gray(` Error: ${error.message}`));
426
- // Add delay before retry
427
- await new Promise((resolve) => setTimeout(resolve, 1000 * retryCount));
428
- }
429
- else {
430
- console.log(chalk_1.default.red(`❌ ${step.name} failed after ${maxRetries} retries`));
431
- this.failedSteps.push(stepId);
432
- if (step.required) {
433
- throw new Error(`Required step '${step.name}' failed: ${error.message}`);
434
- }
435
- }
436
- }
437
- }
438
- }
439
- /**
440
- * Build step-specific prompt for Claude Agent SDK
441
- */
442
- buildStepPrompt(step) {
443
- const basePrompt = `Execute the following workflow step: ${step.name}\n\nDescription: ${step.description}\n\n`;
444
- switch (step.input.workflowType) {
445
- case "context-analysis":
446
- return basePrompt + this.buildContextAnalysisPrompt(step);
447
- case "project-setup":
448
- return basePrompt + this.buildProjectSetupPrompt(step);
449
- case "requirement-gathering":
450
- return basePrompt + this.buildRequirementGatheringPrompt(step);
451
- case "context-generation":
452
- return basePrompt + this.buildContextGenerationPrompt(step);
453
- case "component-generation":
454
- return basePrompt + this.buildComponentGenerationPrompt(step);
455
- case "validation-testing":
456
- return basePrompt + this.buildValidationTestingPrompt(step);
457
- default:
458
- return (basePrompt +
459
- "Please execute this workflow step according to the provided input.");
460
- }
461
- }
462
- /**
463
- * Build context analysis prompt
464
- */
465
- buildContextAnalysisPrompt(step) {
466
- return `Analyze the project context and requirements:
467
-
468
- Project Context:
469
- ${JSON.stringify(step.input.projectContext, null, 2)}
470
-
471
- Requirements:
472
- ${step.input.requirements}
473
-
474
- Please provide:
475
- 1. Context analysis summary
476
- 2. Key requirements identified
477
- 3. Recommended approach
478
- 4. Potential challenges and solutions`;
479
- }
480
- /**
481
- * Build project setup prompt
482
- */
483
- buildProjectSetupPrompt(step) {
484
- return `Set up the project structure:
485
-
486
- Project Name: ${step.input.projectName}
487
- Framework: ${step.input.framework}
488
-
489
- Context:
490
- ${JSON.stringify(step.input.context, null, 2)}
491
-
492
- Please provide:
493
- 1. Project structure recommendations
494
- 2. Dependencies to install
495
- 3. Configuration files needed
496
- 4. Initial setup steps`;
497
- }
498
- /**
499
- * Build requirement gathering prompt
500
- */
501
- buildRequirementGatheringPrompt(step) {
502
- return `Gather detailed requirements:
503
-
504
- Current Context:
505
- ${JSON.stringify(step.input.context, null, 2)}
506
-
507
- Interactive Mode: ${step.input.interactive}
508
-
509
- Please provide:
510
- 1. Detailed requirements analysis
511
- 2. User stories and use cases
512
- 3. Technical specifications
513
- 4. Acceptance criteria`;
514
- }
515
- /**
516
- * Build context generation prompt
517
- */
518
- buildContextGenerationPrompt(step) {
519
- return `Generate comprehensive context files:
520
-
521
- Context:
522
- ${JSON.stringify(step.input.context, null, 2)}
523
-
524
- Requirements:
525
- ${step.input.requirements}
526
-
527
- Please provide:
528
- 1. PRD (Product Requirements Document)
529
- 2. TypeScript type definitions
530
- 3. Branding guidelines
531
- 4. Component list
532
- 5. Project structure documentation`;
533
- }
534
- /**
535
- * Build component generation prompt
536
- */
537
- buildComponentGenerationPrompt(step) {
538
- return `Generate React components:
539
-
540
- Context:
541
- ${JSON.stringify(step.input.context, null, 2)}
542
-
543
- Components to generate: ${step.input.components}
544
-
545
- Please provide:
546
- 1. Complete React component code
547
- 2. TypeScript interfaces
548
- 3. Styling with Tailwind CSS
549
- 4. Component documentation
550
- 5. Usage examples`;
551
- }
552
- /**
553
- * Build validation testing prompt
554
- */
555
- buildValidationTestingPrompt(step) {
556
- return `Validate and test generated components:
557
-
558
- Context:
559
- ${JSON.stringify(step.input.context, null, 2)}
560
-
561
- Please provide:
562
- 1. Component validation results
563
- 2. Test cases and scenarios
564
- 3. Performance analysis
565
- 4. Accessibility checks
566
- 5. Recommendations for improvements`;
567
- }
568
- /**
569
- * Process step result
570
- */
571
- async processStepResult(step, result) {
572
- // Process result based on step type
573
- switch (step.input.workflowType) {
574
- case "context-analysis":
575
- await this.processContextAnalysisResult(result);
576
- break;
577
- case "project-setup":
578
- await this.processProjectSetupResult(result);
579
- break;
580
- case "requirement-gathering":
581
- await this.processRequirementGatheringResult(result);
582
- break;
583
- case "context-generation":
584
- await this.processContextGenerationResult(result);
585
- break;
586
- case "component-generation":
587
- await this.processComponentGenerationResult(result);
588
- break;
589
- case "validation-testing":
590
- await this.processValidationTestingResult(result);
591
- break;
592
- }
593
- }
594
- /**
595
- * Process context analysis result
596
- */
597
- async processContextAnalysisResult(result) {
598
- // Extract key insights from context analysis
599
- console.log(chalk_1.default.green("📊 Context analysis completed"));
600
- }
601
- /**
602
- * Process project setup result
603
- */
604
- async processProjectSetupResult(result) {
605
- // Process project setup recommendations
606
- console.log(chalk_1.default.green("🏗️ Project setup completed"));
607
- }
608
- /**
609
- * Process requirement gathering result
610
- */
611
- async processRequirementGatheringResult(result) {
612
- // Process gathered requirements
613
- console.log(chalk_1.default.green("📋 Requirements gathered"));
614
- }
615
- /**
616
- * Process context generation result
617
- */
618
- async processContextGenerationResult(result) {
619
- // Process generated context files
620
- console.log(chalk_1.default.green("📄 Context files generated"));
621
- }
622
- /**
623
- * Process component generation result
624
- */
625
- async processComponentGenerationResult(result) {
626
- // Process generated components
627
- console.log(chalk_1.default.green("🎨 Components generated"));
628
- }
629
- /**
630
- * Process validation testing result
631
- */
632
- async processValidationTestingResult(result) {
633
- // Process validation results
634
- console.log(chalk_1.default.green("✅ Validation completed"));
635
- }
636
- /**
637
- * Get enhanced system prompt for Claude Agent SDK
638
- */
639
- getEnhancedSystemPrompt() {
640
- return `You are an expert AI assistant specialized in React/Next.js development and component generation, enhanced with Claude Agent SDK capabilities.
641
-
642
- Your enhanced capabilities include:
643
- - Advanced context management and compaction
644
- - Fine-grained tool permissions
645
- - MCP (Model Context Protocol) integration
646
- - Intelligent workflow orchestration
647
- - Automatic error handling and retry logic
648
-
649
- When executing workflows:
650
- 1. Use context management to maintain project state
651
- 2. Respect tool permissions and restrictions
652
- 3. Leverage MCP tools when available
653
- 4. Provide detailed progress updates
654
- 5. Handle errors gracefully with retry logic
655
- 6. Maintain comprehensive project context
656
-
657
- Provide intelligent, context-aware responses that demonstrate deep understanding of the project and requirements.`;
658
- }
659
- }
660
- exports.ClaudeAgentWorkflow = ClaudeAgentWorkflow;
661
- //# sourceMappingURL=ClaudeAgentWorkflow.js.map