ccsetup 1.1.1 → 1.2.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 (88) hide show
  1. package/README.md +96 -363
  2. package/bin/create-project.js +1616 -60
  3. package/bin/lib/claudeInterface.js +209 -0
  4. package/bin/lib/contextGenerator.js +287 -0
  5. package/bin/lib/scanner/index.js +28 -0
  6. package/bin/scan.js +367 -0
  7. package/lib/aiAgentSelector.js +155 -0
  8. package/lib/aiMergeHelper.js +112 -0
  9. package/lib/contextGenerator.js +574 -0
  10. package/lib/contextMerger.js +812 -0
  11. package/lib/progressReporter.js +88 -0
  12. package/lib/scanConfig.js +200 -0
  13. package/lib/scanner/fileAnalyzer.js +605 -0
  14. package/lib/scanner/index.js +164 -0
  15. package/lib/scanner/patterns.js +277 -0
  16. package/lib/scanner/projectDetector.js +147 -0
  17. package/lib/templates/README.md +176 -0
  18. package/lib/templates/catalog.js +230 -0
  19. package/lib/templates/filter.js +257 -0
  20. package/lib/templates/index.js +45 -0
  21. package/lib/templates/metadata/agents.json +413 -0
  22. package/lib/templates/metadata-extractor.js +329 -0
  23. package/lib/templates/search.js +356 -0
  24. package/package.json +11 -4
  25. package/template/{agents → .claude/agents}/checker.md +29 -0
  26. package/template/.claude/settings.json +15 -0
  27. package/template/.claude/skills/prd/SKILL.md +343 -0
  28. package/template/.claude/skills/ralph/SKILL.md +339 -0
  29. package/template/CLAUDE.md +39 -21
  30. package/template/CONTRIBUTING.md +37 -0
  31. package/template/agents/README.md +15 -171
  32. package/template/docs/ROADMAP.md +0 -36
  33. package/template/docs/agent-orchestration.md +24 -141
  34. package/template/hooks/workflow-selector/index.js +398 -0
  35. package/template/scripts/ralph/CLAUDE.md +174 -0
  36. package/template/scripts/ralph/ralph.sh +127 -0
  37. package/template/tickets/ticket-list.md +17 -68
  38. package/template/agents/ai-engineer.md +0 -31
  39. package/template/agents/api-documenter.md +0 -31
  40. package/template/agents/architect-review.md +0 -42
  41. package/template/agents/backend-architect.md +0 -29
  42. package/template/agents/business-analyst.md +0 -34
  43. package/template/agents/c-pro.md +0 -34
  44. package/template/agents/cloud-architect.md +0 -31
  45. package/template/agents/code-reviewer.md +0 -28
  46. package/template/agents/content-marketer.md +0 -34
  47. package/template/agents/context-manager.md +0 -63
  48. package/template/agents/cpp-pro.md +0 -37
  49. package/template/agents/customer-support.md +0 -34
  50. package/template/agents/data-engineer.md +0 -31
  51. package/template/agents/data-scientist.md +0 -28
  52. package/template/agents/database-admin.md +0 -31
  53. package/template/agents/database-optimizer.md +0 -31
  54. package/template/agents/debugger.md +0 -29
  55. package/template/agents/deployment-engineer.md +0 -31
  56. package/template/agents/devops-troubleshooter.md +0 -31
  57. package/template/agents/dx-optimizer.md +0 -62
  58. package/template/agents/error-detective.md +0 -31
  59. package/template/agents/frontend-developer.md +0 -30
  60. package/template/agents/golang-pro.md +0 -31
  61. package/template/agents/graphql-architect.md +0 -31
  62. package/template/agents/incident-responder.md +0 -73
  63. package/template/agents/javascript-pro.md +0 -34
  64. package/template/agents/legacy-modernizer.md +0 -31
  65. package/template/agents/ml-engineer.md +0 -31
  66. package/template/agents/mlops-engineer.md +0 -56
  67. package/template/agents/mobile-developer.md +0 -31
  68. package/template/agents/network-engineer.md +0 -31
  69. package/template/agents/payment-integration.md +0 -31
  70. package/template/agents/performance-engineer.md +0 -31
  71. package/template/agents/prompt-engineer.md +0 -58
  72. package/template/agents/python-pro.md +0 -31
  73. package/template/agents/quant-analyst.md +0 -31
  74. package/template/agents/risk-manager.md +0 -40
  75. package/template/agents/rust-pro.md +0 -34
  76. package/template/agents/sales-automator.md +0 -34
  77. package/template/agents/search-specialist.md +0 -58
  78. package/template/agents/security-auditor.md +0 -31
  79. package/template/agents/sql-pro.md +0 -34
  80. package/template/agents/terraform-specialist.md +0 -34
  81. package/template/agents/test-automator.md +0 -31
  82. /package/template/{agents → .claude/agents}/backend.md +0 -0
  83. /package/template/{agents → .claude/agents}/blockchain.md +0 -0
  84. /package/template/{agents → .claude/agents}/coder.md +0 -0
  85. /package/template/{agents → .claude/agents}/frontend.md +0 -0
  86. /package/template/{agents → .claude/agents}/planner.md +0 -0
  87. /package/template/{agents → .claude/agents}/researcher.md +0 -0
  88. /package/template/{agents → .claude/agents}/shadcn.md +0 -0
@@ -4,42 +4,6 @@
4
4
 
5
5
  High-level overview of the project, what it does, the main features
6
6
 
7
- ## Development Workflow
8
-
9
- 1. **Task Planning**
10
- - Study the existing codebase and understand the current state
11
- - Use the **planner** agent to break down complex problems and create implementation roadmaps
12
- - Create a plan document in the `/plans` directory for complex features
13
- - Update `ROADMAP.md` to include the new task under Development
14
- - Priority tasks should be inserted after the last completed task
15
-
16
- 2. **Ticket Creation**
17
- - Study the existing codebase and understand the current state
18
- - Create a new ticket file in the `/tickets` directory
19
- - Name format: `TICKET-XXX-description.md` (e.g., `TICKET-001-user-auth.md`)
20
- - Include high-level specifications, relevant files, acceptance criteria, and implementation steps
21
- - Refer to last completed ticket in the `/tickets` directory for examples
22
- - Note that completed tickets show checked boxes and summary of changes
23
- - For new tickets, use empty checkboxes and no summary section
24
-
25
- 3. **Task Implementation**
26
- - Use the **coder** agent for implementing features, fixing bugs, and optimizing code
27
- - Follow the specifications in the ticket file
28
- - Implement features and functionality following project conventions
29
- - Update step progress within the ticket file after each step
30
- - Stop after completing each step and wait for further instructions
31
-
32
- 4. **Quality Assurance**
33
- - Use the **checker** agent for testing, security analysis, and code review
34
- - Verify all acceptance criteria are met
35
- - Run tests and ensure code quality standards
36
- - Document any issues found and their resolutions
37
-
38
- 5. **Roadmap Updates**
39
- - Mark completed tasks with ✅ in the roadmap
40
- - Add reference to the ticket file (e.g., `See: /tickets/TICKET-001-user-auth.md`)
41
- - Update related plan documents if applicable
42
-
43
7
  ## Development
44
8
 
45
9
  ### Project Setup and Boilerplate
@@ -1,152 +1,35 @@
1
- # Agent Orchestration Guide
1
+ # Agent Orchestration
2
2
 
3
- ## Overview
4
- This document defines the standard workflows for orchestrating multiple agents in Claude Code to complete complex tasks efficiently. Follow these patterns to ensure consistent and thorough task execution.
3
+ Standard workflows for chaining agents on complex tasks. Always end with **Checker**.
5
4
 
6
- ## Core Agent Workflows
5
+ ## Workflows
7
6
 
8
- ### 1. Feature Development Workflow
9
- **Purpose**: Implement new features from conception to completion
7
+ ### Feature Development
8
+ researcher planner coder checker
10
9
 
11
- **Flow**:
12
- 1. **Researcher Agent**Gather requirements and understand existing codebase
13
- 2. **Planner Agent** → Create detailed implementation plan and architecture
14
- 3. **Coder Agent** → Implement the feature following the plan
15
- 4. **Checker Agent** → Test, review, and validate the implementation
10
+ ### Bug Fix
11
+ researcher coderchecker
16
12
 
17
- **Example Prompt**:
18
- ```
19
- "I need to add user authentication to the app. First use the researcher agent to understand the current architecture, then the planner to design the auth system, coder to implement it, and checker to validate."
20
- ```
13
+ ### Refactoring
14
+ researcher → planner → coder → checker
21
15
 
22
- ### 2. Bug Fix Workflow
23
- **Purpose**: Systematically identify and fix bugs
16
+ ### API Development
17
+ planner backend frontend (optional) → checker
24
18
 
25
- **Flow**:
26
- 1. **Researcher Agent** Investigate the bug and find root cause
27
- 2. **Coder Agent** → Implement the fix
28
- 3. **Checker Agent** → Verify fix and check for regressions
19
+ ### UI Component
20
+ frontendshadcn (if React) checker
29
21
 
30
- ### 3. Refactoring Workflow
31
- **Purpose**: Improve code quality without changing functionality
22
+ ### Blockchain
23
+ planner blockchain checker
32
24
 
33
- **Flow**:
34
- 1. **Researcher Agent**Analyze current implementation and identify improvements
35
- 2. **Planner Agent** → Design refactoring approach
36
- 3. **Coder Agent** → Execute refactoring
37
- 4. **Checker Agent** → Ensure functionality remains intact
25
+ ### QA
26
+ researcher checkercoder (fix issues) checker
38
27
 
39
- ### 4. API Development Workflow
40
- **Purpose**: Design and implement APIs
28
+ ## Rules
41
29
 
42
- **Flow**:
43
- 1. **Planner Agent** Design API architecture and endpoints
44
- 2. **Backend Agent** Implement server-side logic
45
- 3. **Frontend Agent** Create client integration (if needed)
46
- 4. **Checker Agent** Test API functionality and security
47
-
48
- ### 5. UI Component Workflow
49
- **Purpose**: Create user interface components
50
-
51
- **Flow**:
52
- 1. **Frontend Agent** → Design and implement UI components
53
- 2. **Shadcn Agent** → Apply shadcn/ui styling (if using React)
54
- 3. **Checker Agent** → Test accessibility and responsiveness
55
-
56
- ### 6. Blockchain Development Workflow
57
- **Purpose**: Develop Web3 features and smart contracts
58
-
59
- **Flow**:
60
- 1. **Planner Agent** → Design smart contract architecture
61
- 2. **Blockchain Agent** → Implement contracts and Web3 integration
62
- 3. **Checker Agent** → Security audit and testing
63
-
64
- ## Orchestration Best Practices
65
-
66
- ### 1. Always Start with Understanding
67
- - Use Researcher Agent first for non-trivial tasks
68
- - Understand existing code before making changes
69
- - Document findings in plans directory
70
-
71
- ### 2. Plan Before Implementation
72
- - Use Planner Agent for complex features
73
- - Create detailed plans in `/plans` directory
74
- - Break down large tasks into smaller tickets
75
-
76
- ### 3. Sequential Execution
77
- - Complete each agent's task before moving to the next
78
- - Use TodoWrite to track progress through the workflow
79
- - Don't skip agents unless explicitly instructed
80
-
81
- ### 4. Validation is Mandatory
82
- - Always end with Checker Agent
83
- - Run tests and linting
84
- - Verify all acceptance criteria
85
-
86
- ### 5. Documentation Updates
87
- - Update ROADMAP.md after completing workflows
88
- - Mark tickets as complete with summaries
89
- - Keep plans updated with outcomes
90
-
91
- ## Workflow Triggers
92
-
93
- ### When to use Feature Development Workflow:
94
- - Adding new functionality
95
- - Implementing user stories
96
- - Creating new modules or services
97
-
98
- ### When to use Bug Fix Workflow:
99
- - Fixing reported issues
100
- - Addressing error messages
101
- - Resolving unexpected behavior
102
-
103
- ### When to use Refactoring Workflow:
104
- - Improving code readability
105
- - Optimizing performance
106
- - Updating deprecated code
107
-
108
- ### When to use API Development Workflow:
109
- - Creating new endpoints
110
- - Designing service interfaces
111
- - Building integrations
112
-
113
- ### When to use UI Component Workflow:
114
- - Building new UI elements
115
- - Updating existing interfaces
116
- - Implementing design changes
117
-
118
- ### When to use Blockchain Workflow:
119
- - Smart contract development
120
- - DeFi integrations
121
- - Web3 features
122
-
123
- ## Example Multi-Agent Execution
124
-
125
- ```
126
- User: "I need to add a payment processing feature"
127
-
128
- Claude's Response Flow:
129
- 1. "I'll help you add payment processing. Let me start by using the researcher agent to understand your current architecture and any existing payment-related code."
130
- [Uses Researcher Agent]
131
-
132
- 2. "Based on my research, I'll now use the planner agent to design the payment processing system."
133
- [Uses Planner Agent, creates plan in /plans]
134
-
135
- 3. "With the plan ready, I'll use the backend agent to implement the server-side payment processing."
136
- [Uses Backend Agent]
137
-
138
- 4. "Now I'll use the frontend agent to create the payment UI components."
139
- [Uses Frontend Agent]
140
-
141
- 5. "Finally, let me use the checker agent to verify the implementation and ensure security."
142
- [Uses Checker Agent]
143
- ```
144
-
145
- ## Workflow Customization
146
-
147
- You can create custom workflows by:
148
- 1. Combining agents in different sequences
149
- 2. Adding conditional paths based on findings
150
- 3. Creating specialized workflows for your project
151
-
152
- Remember: The goal is systematic, thorough task completion with proper validation at each step.
30
+ 1. Use **Researcher** first for non-trivial tasks
31
+ 2. Use **Planner** before implementing complex features
32
+ 3. Execute agents sequentially complete each step before the next
33
+ 4. Always finish with **Checker** for validation
34
+ 5. Track progress with TodoWrite
35
+ 6. Update ROADMAP.md and tickets after completing workflows
@@ -0,0 +1,398 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ // Environment variable toggle — exit early if not enabled
7
+ // Enable with: export CCSETUP_WORKFLOW=1
8
+ const enabled = process.env.CCSETUP_WORKFLOW;
9
+ if (!enabled || (enabled !== '1' && enabled.toLowerCase() !== 'true')) {
10
+ console.log('{}');
11
+ process.exit(0);
12
+ }
13
+
14
+ // Simple workflow selector that reads from agent-orchestration.md
15
+ class WorkflowSelector {
16
+ constructor() {
17
+ this.workflows = this.loadWorkflows();
18
+ this.availableAgents = this.getAvailableAgents();
19
+ }
20
+
21
+ loadWorkflows() {
22
+ const orchestrationPath = path.join(process.cwd(), 'docs', 'agent-orchestration.md');
23
+
24
+ if (!fs.existsSync(orchestrationPath)) {
25
+ return this.getDefaultWorkflows();
26
+ }
27
+
28
+ try {
29
+ // First try to use Claude to extract workflows intelligently
30
+ const workflows = this.loadWorkflowsWithClaude(orchestrationPath);
31
+ if (workflows && Object.keys(workflows).length > 0) {
32
+ return workflows;
33
+ }
34
+ } catch (error) {
35
+ // Claude extraction failed, continue with regex
36
+ }
37
+
38
+ // Fallback to regex-based extraction
39
+ return this.loadWorkflowsWithRegex(orchestrationPath);
40
+ }
41
+
42
+ loadWorkflowsWithClaude(orchestrationPath) {
43
+ const { execSync } = require('child_process');
44
+
45
+ try {
46
+ const content = fs.readFileSync(orchestrationPath, 'utf8');
47
+
48
+ const extractPrompt = `
49
+ Extract all workflows from this agent orchestration document.
50
+
51
+ For each workflow, identify:
52
+ 1. The workflow name
53
+ 2. The sequence of agents used
54
+ 3. The purpose/description
55
+
56
+ Return ONLY a JSON object with this structure:
57
+ {
58
+ "workflow_key": {
59
+ "name": "Workflow Name",
60
+ "agents": ["agent1", "agent2", "agent3"],
61
+ "purpose": "Brief description"
62
+ }
63
+ }
64
+
65
+ Document content:
66
+ ${content}
67
+
68
+ Extract all workflows and return valid JSON only.
69
+ `;
70
+
71
+ const claudeResult = execSync(
72
+ `claude --print "${extractPrompt.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"`,
73
+ { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'], maxBuffer: 1024 * 1024 * 10 }
74
+ );
75
+
76
+ // Parse the JSON result
77
+ const parsed = JSON.parse(claudeResult);
78
+
79
+ // Validate and normalize the workflows
80
+ const workflows = {};
81
+ for (const [key, workflow] of Object.entries(parsed)) {
82
+ if (workflow.name && Array.isArray(workflow.agents) && workflow.agents.length > 0) {
83
+ // Normalize agent names (remove "agent" suffix, lowercase)
84
+ const normalizedAgents = workflow.agents.map(agent =>
85
+ agent.toLowerCase().replace(/\s*agent\s*$/, '').trim()
86
+ );
87
+
88
+ workflows[key] = {
89
+ name: workflow.name,
90
+ agents: normalizedAgents,
91
+ purpose: workflow.purpose || ''
92
+ };
93
+ }
94
+ }
95
+
96
+ return workflows;
97
+ } catch (error) {
98
+ // Claude extraction failed
99
+ return null;
100
+ }
101
+ }
102
+
103
+ loadWorkflowsWithRegex(orchestrationPath) {
104
+ try {
105
+ const content = fs.readFileSync(orchestrationPath, 'utf8');
106
+ const workflows = {};
107
+
108
+ // Enhanced regex patterns for better extraction
109
+ const workflowSections = this.extractWorkflowSections(content);
110
+
111
+ for (const section of workflowSections) {
112
+ const workflow = this.parseWorkflowSection(section);
113
+ if (workflow) {
114
+ const key = workflow.name.toLowerCase().replace(/\s+/g, '_');
115
+ workflows[key] = workflow;
116
+ }
117
+ }
118
+
119
+ // If no workflows found, return defaults
120
+ return Object.keys(workflows).length > 0 ? workflows : this.getDefaultWorkflows();
121
+ } catch (error) {
122
+ return this.getDefaultWorkflows();
123
+ }
124
+ }
125
+
126
+ extractWorkflowSections(content) {
127
+ const sections = [];
128
+
129
+ // Split by workflow headers
130
+ const workflowRegex = /### \d+\.\s+(.+?)\s+Workflow([\s\S]*?)(?=### \d+\.|## |$)/g;
131
+ let match;
132
+
133
+ while ((match = workflowRegex.exec(content)) !== null) {
134
+ sections.push({
135
+ name: match[1].trim(),
136
+ content: match[2].trim()
137
+ });
138
+ }
139
+
140
+ return sections;
141
+ }
142
+
143
+ parseWorkflowSection(section) {
144
+ const workflow = {
145
+ name: section.name,
146
+ agents: []
147
+ };
148
+
149
+ // Look for the Flow section
150
+ const flowMatch = section.content.match(/\*\*Flow\*\*:?\s*([\s\S]*?)(?=\*\*|###|$)/);
151
+ if (!flowMatch) return null;
152
+
153
+ const flowContent = flowMatch[1];
154
+
155
+ // Extract agents from various formats
156
+ const agents = this.extractAgentsFromFlow(flowContent);
157
+
158
+ if (agents.length > 0) {
159
+ workflow.agents = agents;
160
+ return workflow;
161
+ }
162
+
163
+ return null;
164
+ }
165
+
166
+ extractAgentsFromFlow(flowContent) {
167
+ const agents = [];
168
+ const lines = flowContent.split('\n');
169
+
170
+ for (const line of lines) {
171
+ // Pattern 1: "1. **Agent Name** → Description"
172
+ let match = line.match(/^\d+\.\s*\*\*([^*→]+?)(?:\s+Agent)?\*\*/);
173
+
174
+ // Pattern 2: "- Agent Name: Description"
175
+ if (!match) {
176
+ match = line.match(/^[-•]\s*\*\*([^*:]+?)(?:\s+Agent)?\*\*/);
177
+ }
178
+
179
+ // Pattern 3: "Agent Name →"
180
+ if (!match) {
181
+ match = line.match(/^\s*([A-Za-z\s]+?)\s*(?:Agent\s*)?→/);
182
+ }
183
+
184
+ if (match) {
185
+ const agent = match[1].toLowerCase()
186
+ .replace(/\s*agent\s*$/, '')
187
+ .trim();
188
+
189
+ if (agent && !agents.includes(agent) && agent.length > 0) {
190
+ agents.push(agent);
191
+ }
192
+ }
193
+ }
194
+
195
+ return agents;
196
+ }
197
+
198
+ getDefaultWorkflows() {
199
+ return {
200
+ feature_development: {
201
+ name: 'Feature Development',
202
+ agents: ['researcher', 'planner', 'coder', 'checker']
203
+ },
204
+ bug_fix: {
205
+ name: 'Bug Fix',
206
+ agents: ['researcher', 'coder', 'checker']
207
+ },
208
+ refactoring: {
209
+ name: 'Refactoring',
210
+ agents: ['researcher', 'planner', 'coder', 'checker']
211
+ },
212
+ api_development: {
213
+ name: 'API Development',
214
+ agents: ['planner', 'backend', 'frontend', 'checker']
215
+ },
216
+ ui_component: {
217
+ name: 'UI Component',
218
+ agents: ['frontend', 'shadcn', 'checker']
219
+ },
220
+ blockchain: {
221
+ name: 'Blockchain Development',
222
+ agents: ['planner', 'blockchain', 'checker']
223
+ },
224
+ qa: {
225
+ name: 'QA',
226
+ agents: ['researcher', 'checker', 'coder', 'checker']
227
+ }
228
+ };
229
+ }
230
+
231
+ getAvailableAgents() {
232
+ const agentsDir = path.join(process.cwd(), '.claude', 'agents');
233
+
234
+ if (!fs.existsSync(agentsDir)) {
235
+ return [];
236
+ }
237
+
238
+ try {
239
+ return fs.readdirSync(agentsDir)
240
+ .filter(file => file.endsWith('.md'))
241
+ .map(file => file.replace('.md', '').toLowerCase());
242
+ } catch (error) {
243
+ return [];
244
+ }
245
+ }
246
+
247
+ async selectWorkflow(prompt) {
248
+ const { execSync } = require('child_process');
249
+
250
+ try {
251
+ // First, let's use Claude to analyze the prompt and understand the task type
252
+ const analyzePrompt = `
253
+ Analyze this user prompt and determine the most appropriate workflow type.
254
+ User prompt: "${prompt}"
255
+
256
+ Available workflows:
257
+ ${Object.entries(this.workflows).map(([key, workflow]) =>
258
+ `- ${workflow.name}: uses agents [${workflow.agents.join(', ')}]`
259
+ ).join('\n')}
260
+
261
+ Consider:
262
+ 1. What type of task is this? (feature, bug fix, refactoring, API work, UI work, testing, etc.)
263
+ 2. What agents would be most helpful?
264
+ 3. Match to the most appropriate workflow
265
+
266
+ Respond with ONLY the workflow key (e.g., 'feature_development', 'bug_fix', etc.)
267
+ `;
268
+
269
+ // Use Claude to analyze the prompt
270
+ const claudeAnalysis = execSync(
271
+ `claude --print "${analyzePrompt.replace(/"/g, '\\"')}"`,
272
+ { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }
273
+ ).trim().toLowerCase().replace(/['"]/g, '');
274
+
275
+ // Validate the response is a valid workflow key
276
+ if (this.workflows[claudeAnalysis]) {
277
+ return this.workflows[claudeAnalysis];
278
+ }
279
+
280
+ // If Claude's response isn't valid, fall back to enhanced keyword matching
281
+ return this.enhancedKeywordMatching(prompt);
282
+
283
+ } catch (error) {
284
+ // If Claude command fails, fall back to enhanced keyword matching
285
+ console.error('Claude analysis failed, using keyword matching:', error.message);
286
+ return this.enhancedKeywordMatching(prompt);
287
+ }
288
+ }
289
+
290
+ enhancedKeywordMatching(prompt) {
291
+ const promptLower = prompt.toLowerCase();
292
+
293
+ // Score each workflow based on keyword matches
294
+ const scores = {};
295
+
296
+ // Define keyword weights for each workflow
297
+ const workflowKeywords = {
298
+ bug_fix: {
299
+ keywords: ['fix', 'bug', 'error', 'issue', 'broken', 'crash', 'fail', 'debug', 'problem', 'wrong'],
300
+ weight: 2
301
+ },
302
+ refactoring: {
303
+ keywords: ['refactor', 'improve', 'optimize', 'clean', 'restructure', 'reorganize', 'simplify', 'enhance'],
304
+ weight: 2
305
+ },
306
+ api_development: {
307
+ keywords: ['api', 'endpoint', 'rest', 'graphql', 'backend', 'server', 'route', 'request', 'response'],
308
+ weight: 2
309
+ },
310
+ ui_component: {
311
+ keywords: ['ui', 'component', 'frontend', 'react', 'vue', 'interface', 'button', 'form', 'page', 'view'],
312
+ weight: 2
313
+ },
314
+ qa: {
315
+ keywords: ['test', 'qa', 'quality', 'testing', 'unit', 'integration', 'e2e', 'coverage', 'assert'],
316
+ weight: 2
317
+ },
318
+ feature_development: {
319
+ keywords: ['add', 'create', 'implement', 'build', 'develop', 'feature', 'new', 'functionality'],
320
+ weight: 1
321
+ },
322
+ blockchain: {
323
+ keywords: ['blockchain', 'smart contract', 'web3', 'ethereum', 'solidity', 'defi', 'crypto', 'wallet'],
324
+ weight: 3
325
+ }
326
+ };
327
+
328
+ // Calculate scores for each workflow
329
+ Object.entries(workflowKeywords).forEach(([workflow, config]) => {
330
+ scores[workflow] = 0;
331
+ config.keywords.forEach(keyword => {
332
+ if (promptLower.includes(keyword)) {
333
+ scores[workflow] += config.weight;
334
+ }
335
+ });
336
+ });
337
+
338
+ // Find the workflow with the highest score
339
+ let bestWorkflow = 'feature_development';
340
+ let highestScore = 0;
341
+
342
+ Object.entries(scores).forEach(([workflow, score]) => {
343
+ if (score > highestScore && this.workflows[workflow]) {
344
+ highestScore = score;
345
+ bestWorkflow = workflow;
346
+ }
347
+ });
348
+
349
+ return this.workflows[bestWorkflow] || this.workflows.feature_development || Object.values(this.workflows)[0];
350
+ }
351
+
352
+ filterAgentsByAvailability(agents) {
353
+ if (this.availableAgents.length === 0) {
354
+ return agents; // Return all if we can't check
355
+ }
356
+
357
+ return agents.filter(agent => this.availableAgents.includes(agent));
358
+ }
359
+ }
360
+
361
+ // Main execution - reads from stdin as Claude Code provides
362
+ if (require.main === module) {
363
+ let inputData = '';
364
+
365
+ process.stdin.on('data', (chunk) => {
366
+ inputData += chunk;
367
+ });
368
+
369
+ process.stdin.on('end', async () => {
370
+ try {
371
+ const input = JSON.parse(inputData);
372
+ const prompt = input.prompt || '';
373
+
374
+ if (!prompt) {
375
+ console.log('{}');
376
+ return;
377
+ }
378
+
379
+ const selector = new WorkflowSelector();
380
+ const workflow = await selector.selectWorkflow(prompt);
381
+ const agents = selector.filterAgentsByAvailability(workflow.agents);
382
+
383
+ // Output suggestion — Claude should ask the user before applying
384
+ const output = {
385
+ workflow: workflow.name,
386
+ agents: agents,
387
+ message: `[Workflow Suggestion] Based on this prompt, the "${workflow.name}" workflow may be a good fit: ${agents.join(' → ')}. Ask the user if they'd like to follow this workflow or just proceed normally with Claude Code's default behavior.`
388
+ };
389
+
390
+ console.log(JSON.stringify(output));
391
+ } catch (error) {
392
+ // Silent fail - just return empty
393
+ console.log('{}');
394
+ }
395
+ });
396
+ }
397
+
398
+ module.exports = WorkflowSelector;