@claude-flow/cli 3.0.0-alpha.1

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 (229) hide show
  1. package/.agentic-flow/intelligence.json +16 -0
  2. package/.claude-flow/metrics/agent-metrics.json +1 -0
  3. package/.claude-flow/metrics/performance.json +87 -0
  4. package/.claude-flow/metrics/task-metrics.json +10 -0
  5. package/README.md +1186 -0
  6. package/__tests__/README.md +140 -0
  7. package/__tests__/TEST_SUMMARY.md +144 -0
  8. package/__tests__/cli.test.ts +558 -0
  9. package/__tests__/commands.test.ts +726 -0
  10. package/__tests__/config-adapter.test.ts +362 -0
  11. package/__tests__/config-loading.test.ts +106 -0
  12. package/__tests__/coverage/.tmp/coverage-0.json +1 -0
  13. package/__tests__/coverage/.tmp/coverage-1.json +1 -0
  14. package/__tests__/coverage/.tmp/coverage-2.json +1 -0
  15. package/__tests__/coverage/.tmp/coverage-3.json +1 -0
  16. package/__tests__/coverage/.tmp/coverage-4.json +1 -0
  17. package/__tests__/coverage/.tmp/coverage-5.json +1 -0
  18. package/__tests__/mcp-client.test.ts +480 -0
  19. package/__tests__/p1-commands.test.ts +1064 -0
  20. package/bin/cli.js +14 -0
  21. package/dist/src/commands/agent.d.ts +8 -0
  22. package/dist/src/commands/agent.d.ts.map +1 -0
  23. package/dist/src/commands/agent.js +803 -0
  24. package/dist/src/commands/agent.js.map +1 -0
  25. package/dist/src/commands/config.d.ts +8 -0
  26. package/dist/src/commands/config.d.ts.map +1 -0
  27. package/dist/src/commands/config.js +406 -0
  28. package/dist/src/commands/config.js.map +1 -0
  29. package/dist/src/commands/hive-mind.d.ts +8 -0
  30. package/dist/src/commands/hive-mind.d.ts.map +1 -0
  31. package/dist/src/commands/hive-mind.js +627 -0
  32. package/dist/src/commands/hive-mind.js.map +1 -0
  33. package/dist/src/commands/hooks.d.ts +8 -0
  34. package/dist/src/commands/hooks.d.ts.map +1 -0
  35. package/dist/src/commands/hooks.js +2098 -0
  36. package/dist/src/commands/hooks.js.map +1 -0
  37. package/dist/src/commands/index.d.ts +51 -0
  38. package/dist/src/commands/index.d.ts.map +1 -0
  39. package/dist/src/commands/index.js +105 -0
  40. package/dist/src/commands/index.js.map +1 -0
  41. package/dist/src/commands/init.d.ts +8 -0
  42. package/dist/src/commands/init.d.ts.map +1 -0
  43. package/dist/src/commands/init.js +532 -0
  44. package/dist/src/commands/init.js.map +1 -0
  45. package/dist/src/commands/mcp.d.ts +11 -0
  46. package/dist/src/commands/mcp.d.ts.map +1 -0
  47. package/dist/src/commands/mcp.js +662 -0
  48. package/dist/src/commands/mcp.js.map +1 -0
  49. package/dist/src/commands/memory.d.ts +8 -0
  50. package/dist/src/commands/memory.d.ts.map +1 -0
  51. package/dist/src/commands/memory.js +911 -0
  52. package/dist/src/commands/memory.js.map +1 -0
  53. package/dist/src/commands/migrate.d.ts +8 -0
  54. package/dist/src/commands/migrate.d.ts.map +1 -0
  55. package/dist/src/commands/migrate.js +398 -0
  56. package/dist/src/commands/migrate.js.map +1 -0
  57. package/dist/src/commands/process.d.ts +10 -0
  58. package/dist/src/commands/process.d.ts.map +1 -0
  59. package/dist/src/commands/process.js +566 -0
  60. package/dist/src/commands/process.js.map +1 -0
  61. package/dist/src/commands/session.d.ts +8 -0
  62. package/dist/src/commands/session.d.ts.map +1 -0
  63. package/dist/src/commands/session.js +750 -0
  64. package/dist/src/commands/session.js.map +1 -0
  65. package/dist/src/commands/start.d.ts +8 -0
  66. package/dist/src/commands/start.d.ts.map +1 -0
  67. package/dist/src/commands/start.js +398 -0
  68. package/dist/src/commands/start.js.map +1 -0
  69. package/dist/src/commands/status.d.ts +8 -0
  70. package/dist/src/commands/status.d.ts.map +1 -0
  71. package/dist/src/commands/status.js +560 -0
  72. package/dist/src/commands/status.js.map +1 -0
  73. package/dist/src/commands/swarm.d.ts +8 -0
  74. package/dist/src/commands/swarm.d.ts.map +1 -0
  75. package/dist/src/commands/swarm.js +573 -0
  76. package/dist/src/commands/swarm.js.map +1 -0
  77. package/dist/src/commands/task.d.ts +8 -0
  78. package/dist/src/commands/task.d.ts.map +1 -0
  79. package/dist/src/commands/task.js +671 -0
  80. package/dist/src/commands/task.js.map +1 -0
  81. package/dist/src/commands/workflow.d.ts +8 -0
  82. package/dist/src/commands/workflow.d.ts.map +1 -0
  83. package/dist/src/commands/workflow.js +617 -0
  84. package/dist/src/commands/workflow.js.map +1 -0
  85. package/dist/src/config-adapter.d.ts +15 -0
  86. package/dist/src/config-adapter.d.ts.map +1 -0
  87. package/dist/src/config-adapter.js +185 -0
  88. package/dist/src/config-adapter.js.map +1 -0
  89. package/dist/src/index.d.ts +55 -0
  90. package/dist/src/index.d.ts.map +1 -0
  91. package/dist/src/index.js +312 -0
  92. package/dist/src/index.js.map +1 -0
  93. package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  94. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
  95. package/dist/src/infrastructure/in-memory-repositories.js +264 -0
  96. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -0
  97. package/dist/src/init/claudemd-generator.d.ts +15 -0
  98. package/dist/src/init/claudemd-generator.d.ts.map +1 -0
  99. package/dist/src/init/claudemd-generator.js +626 -0
  100. package/dist/src/init/claudemd-generator.js.map +1 -0
  101. package/dist/src/init/executor.d.ts +11 -0
  102. package/dist/src/init/executor.d.ts.map +1 -0
  103. package/dist/src/init/executor.js +647 -0
  104. package/dist/src/init/executor.js.map +1 -0
  105. package/dist/src/init/helpers-generator.d.ts +42 -0
  106. package/dist/src/init/helpers-generator.d.ts.map +1 -0
  107. package/dist/src/init/helpers-generator.js +613 -0
  108. package/dist/src/init/helpers-generator.js.map +1 -0
  109. package/dist/src/init/index.d.ts +12 -0
  110. package/dist/src/init/index.d.ts.map +1 -0
  111. package/dist/src/init/index.js +15 -0
  112. package/dist/src/init/index.js.map +1 -0
  113. package/dist/src/init/mcp-generator.d.ts +18 -0
  114. package/dist/src/init/mcp-generator.d.ts.map +1 -0
  115. package/dist/src/init/mcp-generator.js +71 -0
  116. package/dist/src/init/mcp-generator.js.map +1 -0
  117. package/dist/src/init/settings-generator.d.ts +14 -0
  118. package/dist/src/init/settings-generator.d.ts.map +1 -0
  119. package/dist/src/init/settings-generator.js +257 -0
  120. package/dist/src/init/settings-generator.js.map +1 -0
  121. package/dist/src/init/statusline-generator.d.ts +14 -0
  122. package/dist/src/init/statusline-generator.d.ts.map +1 -0
  123. package/dist/src/init/statusline-generator.js +206 -0
  124. package/dist/src/init/statusline-generator.js.map +1 -0
  125. package/dist/src/init/types.d.ts +240 -0
  126. package/dist/src/init/types.d.ts.map +1 -0
  127. package/dist/src/init/types.js +210 -0
  128. package/dist/src/init/types.js.map +1 -0
  129. package/dist/src/mcp-client.d.ts +92 -0
  130. package/dist/src/mcp-client.d.ts.map +1 -0
  131. package/dist/src/mcp-client.js +189 -0
  132. package/dist/src/mcp-client.js.map +1 -0
  133. package/dist/src/mcp-server.d.ts +153 -0
  134. package/dist/src/mcp-server.d.ts.map +1 -0
  135. package/dist/src/mcp-server.js +448 -0
  136. package/dist/src/mcp-server.js.map +1 -0
  137. package/dist/src/mcp-tools/agent-tools.d.ts +8 -0
  138. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -0
  139. package/dist/src/mcp-tools/agent-tools.js +90 -0
  140. package/dist/src/mcp-tools/agent-tools.js.map +1 -0
  141. package/dist/src/mcp-tools/config-tools.d.ts +8 -0
  142. package/dist/src/mcp-tools/config-tools.d.ts.map +1 -0
  143. package/dist/src/mcp-tools/config-tools.js +86 -0
  144. package/dist/src/mcp-tools/config-tools.js.map +1 -0
  145. package/dist/src/mcp-tools/hooks-tools.d.ts +41 -0
  146. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -0
  147. package/dist/src/mcp-tools/hooks-tools.js +1646 -0
  148. package/dist/src/mcp-tools/hooks-tools.js.map +1 -0
  149. package/dist/src/mcp-tools/index.d.ts +12 -0
  150. package/dist/src/mcp-tools/index.d.ts.map +1 -0
  151. package/dist/src/mcp-tools/index.js +11 -0
  152. package/dist/src/mcp-tools/index.js.map +1 -0
  153. package/dist/src/mcp-tools/memory-tools.d.ts +8 -0
  154. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -0
  155. package/dist/src/mcp-tools/memory-tools.js +87 -0
  156. package/dist/src/mcp-tools/memory-tools.js.map +1 -0
  157. package/dist/src/mcp-tools/swarm-tools.d.ts +8 -0
  158. package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -0
  159. package/dist/src/mcp-tools/swarm-tools.js +67 -0
  160. package/dist/src/mcp-tools/swarm-tools.js.map +1 -0
  161. package/dist/src/mcp-tools/types.d.ts +31 -0
  162. package/dist/src/mcp-tools/types.d.ts.map +1 -0
  163. package/dist/src/mcp-tools/types.js +7 -0
  164. package/dist/src/mcp-tools/types.js.map +1 -0
  165. package/dist/src/output.d.ts +117 -0
  166. package/dist/src/output.d.ts.map +1 -0
  167. package/dist/src/output.js +471 -0
  168. package/dist/src/output.js.map +1 -0
  169. package/dist/src/parser.d.ts +41 -0
  170. package/dist/src/parser.d.ts.map +1 -0
  171. package/dist/src/parser.js +353 -0
  172. package/dist/src/parser.js.map +1 -0
  173. package/dist/src/prompt.d.ts +44 -0
  174. package/dist/src/prompt.d.ts.map +1 -0
  175. package/dist/src/prompt.js +501 -0
  176. package/dist/src/prompt.js.map +1 -0
  177. package/dist/src/types.d.ts +198 -0
  178. package/dist/src/types.d.ts.map +1 -0
  179. package/dist/src/types.js +38 -0
  180. package/dist/src/types.js.map +1 -0
  181. package/dist/tsconfig.tsbuildinfo +1 -0
  182. package/docs/CONFIG_LOADING.md +236 -0
  183. package/docs/IMPLEMENTATION_COMPLETE.md +421 -0
  184. package/docs/MCP_CLIENT_GUIDE.md +620 -0
  185. package/docs/REFACTORING_SUMMARY.md +247 -0
  186. package/package.json +29 -0
  187. package/src/commands/agent.ts +941 -0
  188. package/src/commands/config.ts +452 -0
  189. package/src/commands/hive-mind.ts +762 -0
  190. package/src/commands/hooks.ts +2603 -0
  191. package/src/commands/index.ts +115 -0
  192. package/src/commands/init.ts +597 -0
  193. package/src/commands/mcp.ts +753 -0
  194. package/src/commands/memory.ts +1063 -0
  195. package/src/commands/migrate.ts +447 -0
  196. package/src/commands/process.ts +617 -0
  197. package/src/commands/session.ts +891 -0
  198. package/src/commands/start.ts +457 -0
  199. package/src/commands/status.ts +705 -0
  200. package/src/commands/swarm.ts +648 -0
  201. package/src/commands/task.ts +792 -0
  202. package/src/commands/workflow.ts +742 -0
  203. package/src/config-adapter.ts +210 -0
  204. package/src/index.ts +383 -0
  205. package/src/infrastructure/in-memory-repositories.ts +310 -0
  206. package/src/init/claudemd-generator.ts +631 -0
  207. package/src/init/executor.ts +756 -0
  208. package/src/init/helpers-generator.ts +628 -0
  209. package/src/init/index.ts +60 -0
  210. package/src/init/mcp-generator.ts +83 -0
  211. package/src/init/settings-generator.ts +274 -0
  212. package/src/init/statusline-generator.ts +211 -0
  213. package/src/init/types.ts +447 -0
  214. package/src/mcp-client.ts +227 -0
  215. package/src/mcp-server.ts +571 -0
  216. package/src/mcp-tools/agent-tools.ts +92 -0
  217. package/src/mcp-tools/config-tools.ts +88 -0
  218. package/src/mcp-tools/hooks-tools.ts +1819 -0
  219. package/src/mcp-tools/index.ts +12 -0
  220. package/src/mcp-tools/memory-tools.ts +89 -0
  221. package/src/mcp-tools/swarm-tools.ts +69 -0
  222. package/src/mcp-tools/types.ts +33 -0
  223. package/src/output.ts +593 -0
  224. package/src/parser.ts +417 -0
  225. package/src/prompt.ts +619 -0
  226. package/src/types.ts +287 -0
  227. package/tsconfig.json +16 -0
  228. package/tsconfig.tsbuildinfo +1 -0
  229. package/vitest.config.ts +13 -0
@@ -0,0 +1,626 @@
1
+ /**
2
+ * CLAUDE.md Generator
3
+ * Generates project-specific Claude Code configuration with V3 swarm guidance
4
+ */
5
+ /**
6
+ * Generate CLAUDE.md content based on init options
7
+ */
8
+ export function generateClaudeMd(options) {
9
+ const topology = options.runtime.topology;
10
+ const maxAgents = options.runtime.maxAgents;
11
+ const memoryBackend = options.runtime.memoryBackend;
12
+ return `# Claude Code Configuration - SPARC Development Environment
13
+
14
+ ## 🚨 AUTOMATIC SWARM ORCHESTRATION
15
+
16
+ **When starting work on complex tasks, Claude Code MUST automatically:**
17
+
18
+ 1. **Initialize the swarm** using MCP tools
19
+ 2. **Spawn concurrent agents** using Claude Code's Task tool
20
+ 3. **Coordinate via hooks** and memory
21
+
22
+ ### 🚨 CRITICAL: MCP + Task Tool in SAME Message
23
+
24
+ **When user says "spawn swarm" or requests complex work, Claude Code MUST in ONE message:**
25
+ 1. Call MCP tools to initialize coordination
26
+ 2. **IMMEDIATELY** call Task tool to spawn REAL working agents
27
+ 3. Both MCP and Task calls must be in the SAME response
28
+
29
+ **MCP alone does NOT execute work - Task tool agents do the actual work!**
30
+
31
+ ### 🔄 Auto-Start Swarm Protocol
32
+
33
+ When the user requests a complex task (multi-file changes, feature implementation, refactoring), **immediately execute this pattern in a SINGLE message:**
34
+
35
+ \`\`\`javascript
36
+ // STEP 1: Initialize swarm coordination via MCP (in parallel with agent spawning)
37
+ mcp__claude-flow__swarm_init({
38
+ topology: "${topology}",
39
+ maxAgents: ${maxAgents},
40
+ strategy: "adaptive"
41
+ })
42
+
43
+ // STEP 2: Spawn agents concurrently using Claude Code's Task tool
44
+ // ALL Task calls MUST be in the SAME message for parallel execution
45
+ Task("Coordinator", "You are the swarm coordinator. Initialize session, coordinate other agents via memory. Run: npx claude-flow@v3alpha hooks session-start", "hierarchical-coordinator")
46
+ Task("Researcher", "Analyze requirements and existing code patterns. Store findings in memory via hooks.", "researcher")
47
+ Task("Architect", "Design implementation approach based on research. Document decisions in memory.", "system-architect")
48
+ Task("Coder", "Implement the solution following architect's design. Coordinate via hooks.", "coder")
49
+ Task("Tester", "Write tests for the implementation. Report coverage via hooks.", "tester")
50
+ Task("Reviewer", "Review code quality and security. Document findings.", "reviewer")
51
+
52
+ // STEP 3: Batch all todos
53
+ TodoWrite({ todos: [
54
+ {content: "Initialize swarm coordination", status: "in_progress", activeForm: "Initializing swarm"},
55
+ {content: "Research and analyze requirements", status: "in_progress", activeForm: "Researching requirements"},
56
+ {content: "Design architecture", status: "pending", activeForm: "Designing architecture"},
57
+ {content: "Implement solution", status: "pending", activeForm: "Implementing solution"},
58
+ {content: "Write tests", status: "pending", activeForm: "Writing tests"},
59
+ {content: "Review and finalize", status: "pending", activeForm: "Reviewing code"}
60
+ ]})
61
+
62
+ // STEP 4: Store swarm state in memory
63
+ mcp__claude-flow__memory_usage({
64
+ action: "store",
65
+ namespace: "swarm",
66
+ key: "current-session",
67
+ value: JSON.stringify({task: "[user's task]", agents: 6, startedAt: new Date().toISOString()})
68
+ })
69
+ \`\`\`
70
+
71
+ ### 📋 Agent Routing by Task Type
72
+
73
+ **Automatically select agents based on task:**
74
+
75
+ | Task Type | Required Agents | Topology |
76
+ |-----------|-----------------|----------|
77
+ | Bug Fix | researcher, coder, tester | mesh |
78
+ | New Feature | coordinator, architect, coder, tester, reviewer | hierarchical |
79
+ | Refactoring | architect, coder, reviewer | mesh |
80
+ | Performance | researcher, coder, perf-analyzer | hierarchical |
81
+ | Security Audit | security-manager, reviewer, tester | hierarchical |
82
+ | Documentation | researcher, api-docs | mesh |
83
+
84
+ ### 🎯 Task Complexity Detection
85
+
86
+ **AUTO-INVOKE SWARM when task involves:**
87
+ - Multiple files (3+)
88
+ - New feature implementation
89
+ - Refactoring across modules
90
+ - API changes with tests
91
+ - Security-related changes
92
+ - Performance optimization
93
+ - Database schema changes
94
+
95
+ **SKIP SWARM for:**
96
+ - Single file edits
97
+ - Simple bug fixes (1-2 lines)
98
+ - Documentation updates
99
+ - Configuration changes
100
+ - Quick questions/exploration
101
+
102
+ ### 🔧 Settings Configuration
103
+
104
+ The following settings are auto-configured in \`.claude/settings.json\`:
105
+
106
+ \`\`\`json
107
+ {
108
+ "hooks": {
109
+ "PreToolUse": [{
110
+ "matcher": "Task",
111
+ "commands": ["npx claude-flow@v3alpha hooks pre-task --tool Task"]
112
+ }],
113
+ "PostToolUse": [{
114
+ "matcher": "Task",
115
+ "commands": ["npx claude-flow@v3alpha hooks post-task --tool Task"]
116
+ }],
117
+ "UserPromptSubmit": [{
118
+ "matcher": ".*",
119
+ "commands": ["npx claude-flow@v3alpha hooks route-task"]
120
+ }]
121
+ },
122
+ "permissions": {
123
+ "allow": [
124
+ "Bash(npx claude-flow:*)",
125
+ "mcp__claude-flow__*",
126
+ "mcp__ruv-swarm__*"
127
+ ]
128
+ }
129
+ }
130
+ \`\`\`
131
+
132
+ ## 🚨 CRITICAL: CONCURRENT EXECUTION & FILE MANAGEMENT
133
+
134
+ **ABSOLUTE RULES**:
135
+ 1. ALL operations MUST be concurrent/parallel in a single message
136
+ 2. **NEVER save working files, text/mds and tests to the root folder**
137
+ 3. ALWAYS organize files in appropriate subdirectories
138
+ 4. **USE CLAUDE CODE'S TASK TOOL** for spawning agents concurrently, not just MCP
139
+
140
+ ### ⚡ GOLDEN RULE: "1 MESSAGE = ALL RELATED OPERATIONS"
141
+
142
+ **MANDATORY PATTERNS:**
143
+ - **TodoWrite**: ALWAYS batch ALL todos in ONE call (5-10+ todos minimum)
144
+ - **Task tool (Claude Code)**: ALWAYS spawn ALL agents in ONE message with full instructions
145
+ - **File operations**: ALWAYS batch ALL reads/writes/edits in ONE message
146
+ - **Bash commands**: ALWAYS batch ALL terminal operations in ONE message
147
+ - **Memory operations**: ALWAYS batch ALL memory store/retrieve in ONE message
148
+
149
+ ### 🎯 CRITICAL: Claude Code Task Tool for Agent Execution
150
+
151
+ **Claude Code's Task tool is the PRIMARY way to spawn agents:**
152
+ \`\`\`javascript
153
+ // ✅ CORRECT: Use Claude Code's Task tool for parallel agent execution
154
+ [Single Message]:
155
+ Task("Research agent", "Analyze requirements and patterns...", "researcher")
156
+ Task("Coder agent", "Implement core features...", "coder")
157
+ Task("Tester agent", "Create comprehensive tests...", "tester")
158
+ Task("Reviewer agent", "Review code quality...", "reviewer")
159
+ Task("Architect agent", "Design system architecture...", "system-architect")
160
+ \`\`\`
161
+
162
+ **MCP tools are ONLY for coordination setup:**
163
+ - \`mcp__claude-flow__swarm_init\` - Initialize coordination topology
164
+ - \`mcp__claude-flow__agent_spawn\` - Define agent types for coordination
165
+ - \`mcp__claude-flow__task_orchestrate\` - Orchestrate high-level workflows
166
+
167
+ ### 📁 File Organization Rules
168
+
169
+ **NEVER save to root folder. Use these directories:**
170
+ - \`/src\` - Source code files
171
+ - \`/tests\` - Test files
172
+ - \`/docs\` - Documentation and markdown files
173
+ - \`/config\` - Configuration files
174
+ - \`/scripts\` - Utility scripts
175
+ - \`/examples\` - Example code
176
+
177
+ ## Project Configuration
178
+
179
+ This project is configured with Claude Flow V3:
180
+ - **Topology**: ${topology}
181
+ - **Max Agents**: ${maxAgents}
182
+ - **Memory Backend**: ${memoryBackend}
183
+ - **HNSW Indexing**: ${options.runtime.enableHNSW ? 'Enabled' : 'Disabled'}
184
+ - **Neural Learning**: ${options.runtime.enableNeural ? 'Enabled' : 'Disabled'}
185
+
186
+ ## SPARC Workflow Phases
187
+
188
+ 1. **Specification** - Requirements analysis (\`sparc run spec-pseudocode\`)
189
+ 2. **Pseudocode** - Algorithm design (\`sparc run spec-pseudocode\`)
190
+ 3. **Architecture** - System design (\`sparc run architect\`)
191
+ 4. **Refinement** - TDD implementation (\`sparc tdd\`)
192
+ 5. **Completion** - Integration (\`sparc run integration\`)
193
+
194
+ ## Code Style & Best Practices
195
+
196
+ - **Modular Design**: Files under 500 lines
197
+ - **Environment Safety**: Never hardcode secrets
198
+ - **Test-First**: Write tests before implementation
199
+ - **Clean Architecture**: Separate concerns
200
+ - **Documentation**: Keep updated
201
+
202
+ ## 🚀 Available Agents
203
+
204
+ ### Core Development
205
+ \`coder\`, \`reviewer\`, \`tester\`, \`planner\`, \`researcher\`
206
+
207
+ ### Swarm Coordination
208
+ \`hierarchical-coordinator\`, \`mesh-coordinator\`, \`adaptive-coordinator\`, \`collective-intelligence-coordinator\`, \`swarm-memory-manager\`
209
+
210
+ ### Consensus & Distributed
211
+ \`byzantine-coordinator\`, \`raft-manager\`, \`gossip-coordinator\`, \`consensus-builder\`, \`crdt-synchronizer\`, \`quorum-manager\`, \`security-manager\`
212
+
213
+ ### Performance & Optimization
214
+ \`perf-analyzer\`, \`performance-benchmarker\`, \`task-orchestrator\`, \`memory-coordinator\`, \`smart-agent\`
215
+
216
+ ### GitHub & Repository
217
+ \`github-modes\`, \`pr-manager\`, \`code-review-swarm\`, \`issue-tracker\`, \`release-manager\`, \`workflow-automation\`, \`project-board-sync\`, \`repo-architect\`, \`multi-repo-swarm\`
218
+
219
+ ### SPARC Methodology
220
+ \`sparc-coord\`, \`sparc-coder\`, \`specification\`, \`pseudocode\`, \`architecture\`, \`refinement\`
221
+
222
+ ### Specialized Development
223
+ \`backend-dev\`, \`mobile-dev\`, \`ml-developer\`, \`cicd-engineer\`, \`api-docs\`, \`system-architect\`, \`code-analyzer\`, \`base-template-generator\`
224
+
225
+ ### Testing & Validation
226
+ \`tdd-london-swarm\`, \`production-validator\`
227
+
228
+ ## 🎯 Claude Code vs MCP Tools
229
+
230
+ ### Claude Code Handles ALL EXECUTION:
231
+ - **Task tool**: Spawn and run agents concurrently for actual work
232
+ - File operations (Read, Write, Edit, MultiEdit, Glob, Grep)
233
+ - Code generation and programming
234
+ - Bash commands and system operations
235
+ - Implementation work
236
+ - Project navigation and analysis
237
+ - TodoWrite and task management
238
+ - Git operations
239
+ - Package management
240
+ - Testing and debugging
241
+
242
+ ### MCP Tools ONLY COORDINATE:
243
+ - Swarm initialization (topology setup)
244
+ - Agent type definitions (coordination patterns)
245
+ - Task orchestration (high-level planning)
246
+ - Memory management
247
+ - Neural features
248
+ - Performance tracking
249
+ - GitHub integration
250
+
251
+ **KEY**: MCP coordinates the strategy, Claude Code's Task tool executes with real agents.
252
+
253
+ ## 🚀 Quick Setup
254
+
255
+ \`\`\`bash
256
+ # Add MCP servers (Claude Flow required, others optional)
257
+ claude mcp add claude-flow npx claude-flow@v3alpha mcp start
258
+ claude mcp add ruv-swarm npx ruv-swarm mcp start # Optional: Enhanced coordination
259
+ claude mcp add flow-nexus npx flow-nexus@latest mcp start # Optional: Cloud features
260
+ \`\`\`
261
+
262
+ ## MCP Tool Categories
263
+
264
+ ### Coordination
265
+ \`swarm_init\`, \`agent_spawn\`, \`task_orchestrate\`
266
+
267
+ ### Monitoring
268
+ \`swarm_status\`, \`agent_list\`, \`agent_metrics\`, \`task_status\`, \`task_results\`
269
+
270
+ ### Memory & Neural
271
+ \`memory_usage\`, \`neural_status\`, \`neural_train\`, \`neural_patterns\`
272
+
273
+ ### GitHub Integration
274
+ \`github_swarm\`, \`repo_analyze\`, \`pr_enhance\`, \`issue_triage\`, \`code_review\`
275
+
276
+ ### System
277
+ \`benchmark_run\`, \`features_detect\`, \`swarm_monitor\`
278
+
279
+ ## 🚀 Agent Execution Flow with Claude Code
280
+
281
+ ### The Correct Pattern:
282
+
283
+ 1. **Optional**: Use MCP tools to set up coordination topology
284
+ 2. **REQUIRED**: Use Claude Code's Task tool to spawn agents that do actual work
285
+ 3. **REQUIRED**: Each agent runs hooks for coordination
286
+ 4. **REQUIRED**: Batch all operations in single messages
287
+
288
+ ### Example Full-Stack Development:
289
+
290
+ \`\`\`javascript
291
+ // Single message with all agent spawning via Claude Code's Task tool
292
+ [Parallel Agent Execution]:
293
+ Task("Backend Developer", "Build REST API with Express. Use hooks for coordination.", "backend-dev")
294
+ Task("Frontend Developer", "Create React UI. Coordinate with backend via memory.", "coder")
295
+ Task("Database Architect", "Design PostgreSQL schema. Store schema in memory.", "code-analyzer")
296
+ Task("Test Engineer", "Write Jest tests. Check memory for API contracts.", "tester")
297
+ Task("DevOps Engineer", "Setup Docker and CI/CD. Document in memory.", "cicd-engineer")
298
+ Task("Security Auditor", "Review authentication. Report findings via hooks.", "reviewer")
299
+
300
+ // All todos batched together
301
+ TodoWrite { todos: [...8-10 todos...] }
302
+
303
+ // All file operations together
304
+ Write "backend/server.js"
305
+ Write "frontend/App.jsx"
306
+ Write "database/schema.sql"
307
+ \`\`\`
308
+
309
+ ## 📋 Agent Coordination Protocol
310
+
311
+ ### Every Agent Spawned via Task Tool MUST:
312
+
313
+ **1️⃣ BEFORE Work:**
314
+ \`\`\`bash
315
+ npx claude-flow@v3alpha hooks pre-task --description "[task]"
316
+ npx claude-flow@v3alpha hooks session-restore --session-id "swarm-[id]"
317
+ \`\`\`
318
+
319
+ **2️⃣ DURING Work:**
320
+ \`\`\`bash
321
+ npx claude-flow@v3alpha hooks post-edit --file "[file]" --memory-key "swarm/[agent]/[step]"
322
+ npx claude-flow@v3alpha hooks notify --message "[what was done]"
323
+ \`\`\`
324
+
325
+ **3️⃣ AFTER Work:**
326
+ \`\`\`bash
327
+ npx claude-flow@v3alpha hooks post-task --task-id "[task]"
328
+ npx claude-flow@v3alpha hooks session-end --export-metrics true
329
+ \`\`\`
330
+
331
+ ## 🚀 Swarm Lifecycle Management
332
+
333
+ ### Session Start (AUTOMATIC)
334
+ When beginning ANY development task, Claude Code should:
335
+
336
+ \`\`\`javascript
337
+ // 1. Check for existing swarm session
338
+ mcp__claude-flow__swarm_status({})
339
+
340
+ // 2. If no active swarm, initialize one
341
+ mcp__claude-flow__swarm_init({ topology: "${topology}", maxAgents: ${maxAgents} })
342
+
343
+ // 3. Restore previous context if available
344
+ mcp__claude-flow__memory_usage({ action: "retrieve", namespace: "swarm", key: "last-session" })
345
+ \`\`\`
346
+
347
+ ### Task Execution (AUTOMATIC)
348
+ For each significant task:
349
+
350
+ \`\`\`javascript
351
+ // 1. Create task orchestration
352
+ mcp__claude-flow__task_orchestrate({
353
+ task: "[task description]",
354
+ priority: "high",
355
+ strategy: "adaptive"
356
+ })
357
+
358
+ // 2. Spawn appropriate agents via Task tool (PARALLEL)
359
+ Task("Agent1", "...", "agent-type")
360
+ Task("Agent2", "...", "agent-type")
361
+ Task("Agent3", "...", "agent-type")
362
+
363
+ // 3. Monitor progress via MCP
364
+ mcp__claude-flow__swarm_status({ includeAgents: true, includeMetrics: true })
365
+ \`\`\`
366
+
367
+ ### Session End (AUTOMATIC)
368
+ When task completes or user ends session:
369
+
370
+ \`\`\`javascript
371
+ // 1. Save session state
372
+ mcp__claude-flow__memory_usage({
373
+ action: "store",
374
+ namespace: "swarm",
375
+ key: "last-session",
376
+ value: JSON.stringify({ completedAt: new Date().toISOString(), summary: "..." })
377
+ })
378
+
379
+ // 2. Export metrics if enabled
380
+ mcp__claude-flow__agent_metrics({})
381
+
382
+ // 3. Graceful shutdown (only if explicitly requested)
383
+ // mcp__claude-flow__swarm_destroy({ swarmId: "..." })
384
+ \`\`\`
385
+
386
+ ## 🎯 Concurrent Execution Examples
387
+
388
+ ### ✅ CORRECT WORKFLOW: MCP Coordinates, Claude Code Executes
389
+
390
+ \`\`\`javascript
391
+ // Step 1: MCP tools set up coordination (optional, for complex tasks)
392
+ [Single Message - Coordination Setup]:
393
+ mcp__claude-flow__swarm_init { topology: "${topology}", maxAgents: ${maxAgents} }
394
+ mcp__claude-flow__agent_spawn { type: "researcher" }
395
+ mcp__claude-flow__agent_spawn { type: "coder" }
396
+ mcp__claude-flow__agent_spawn { type: "tester" }
397
+
398
+ // Step 2: Claude Code Task tool spawns ACTUAL agents that do the work
399
+ [Single Message - Parallel Agent Execution]:
400
+ // Claude Code's Task tool spawns real agents concurrently
401
+ Task("Research agent", "Analyze API requirements and best practices. Check memory for prior decisions.", "researcher")
402
+ Task("Coder agent", "Implement REST endpoints with authentication. Coordinate via hooks.", "coder")
403
+ Task("Database agent", "Design and implement database schema. Store decisions in memory.", "code-analyzer")
404
+ Task("Tester agent", "Create comprehensive test suite with 90% coverage.", "tester")
405
+ Task("Reviewer agent", "Review code quality and security. Document findings.", "reviewer")
406
+
407
+ // Batch ALL todos in ONE call
408
+ TodoWrite { todos: [
409
+ {id: "1", content: "Research API patterns", status: "in_progress", priority: "high"},
410
+ {id: "2", content: "Design database schema", status: "in_progress", priority: "high"},
411
+ {id: "3", content: "Implement authentication", status: "pending", priority: "high"},
412
+ {id: "4", content: "Build REST endpoints", status: "pending", priority: "high"},
413
+ {id: "5", content: "Write unit tests", status: "pending", priority: "medium"},
414
+ {id: "6", content: "Integration tests", status: "pending", priority: "medium"},
415
+ {id: "7", content: "API documentation", status: "pending", priority: "low"},
416
+ {id: "8", content: "Performance optimization", status: "pending", priority: "low"}
417
+ ]}
418
+
419
+ // Parallel file operations
420
+ Bash "mkdir -p app/{src,tests,docs,config}"
421
+ Write "app/package.json"
422
+ Write "app/src/server.js"
423
+ Write "app/tests/server.test.js"
424
+ Write "app/docs/API.md"
425
+ \`\`\`
426
+
427
+ ### ❌ WRONG (Multiple Messages):
428
+ \`\`\`javascript
429
+ Message 1: mcp__claude-flow__swarm_init
430
+ Message 2: Task("agent 1")
431
+ Message 3: TodoWrite { todos: [single todo] }
432
+ Message 4: Write "file.js"
433
+ // This breaks parallel coordination!
434
+ \`\`\`
435
+
436
+ ## V3 Performance Targets
437
+
438
+ - **2.49x-7.47x** Flash Attention speedup
439
+ - **150x-12,500x** search improvements with HNSW
440
+ - **50-75%** memory reduction with quantization
441
+ - **Sub-100ms** MCP response times
442
+
443
+ ## 🪝 V3 Hooks System (26 Hooks)
444
+
445
+ Claude Flow V3 provides 26 hooks for comprehensive agent coordination and self-learning.
446
+
447
+ ### Hook Categories
448
+
449
+ | Category | Hooks | Purpose |
450
+ |----------|-------|---------|
451
+ | **Core** | \`pre-edit\`, \`post-edit\`, \`pre-command\`, \`post-command\`, \`pre-task\`, \`post-task\` | Tool lifecycle |
452
+ | **Routing** | \`route\`, \`metrics\`, \`list\` | Task analysis |
453
+ | **Intelligence** | \`explain\`, \`pretrain\`, \`build-agents\`, \`transfer\`, \`init\` | Neural learning |
454
+ | **Session** | \`session-start\`, \`session-end\`, \`session-restore\`, \`notify\` | Context management |
455
+ | **Learning** | \`trajectory-start\`, \`trajectory-step\`, \`trajectory-end\` | Reinforcement learning |
456
+ | **Patterns** | \`pattern-store\`, \`pattern-search\`, \`stats\`, \`learn\`, \`attention\` | Memory & search |
457
+
458
+ ### Essential Hook Commands
459
+
460
+ \`\`\`bash
461
+ # Core hooks for tool coordination
462
+ npx claude-flow@v3alpha hooks pre-task --description "[task]"
463
+ npx claude-flow@v3alpha hooks post-task --task-id "[id]" --success true
464
+ npx claude-flow@v3alpha hooks post-edit --file "[file]" --train-patterns
465
+
466
+ # Session management
467
+ npx claude-flow@v3alpha hooks session-start --session-id "[id]"
468
+ npx claude-flow@v3alpha hooks session-end --export-metrics true --persist-patterns
469
+ npx claude-flow@v3alpha hooks session-restore --session-id "[id]"
470
+
471
+ # Intelligence routing
472
+ npx claude-flow@v3alpha hooks route --task "[task]" --include-explanation
473
+ npx claude-flow@v3alpha hooks explain --topic "[topic]" --depth comprehensive
474
+
475
+ # Neural learning
476
+ npx claude-flow@v3alpha hooks pretrain --model-type moe --epochs 10
477
+ npx claude-flow@v3alpha hooks build-agents --agent-types coder,tester --config-format yaml
478
+
479
+ # Trajectory learning (reinforcement)
480
+ npx claude-flow@v3alpha hooks intelligence trajectory-start --session "[session]"
481
+ npx claude-flow@v3alpha hooks intelligence trajectory-step --action "[action]" --reward "[reward]"
482
+ npx claude-flow@v3alpha hooks intelligence trajectory-end --verdict success
483
+
484
+ # Pattern storage (HNSW-indexed)
485
+ npx claude-flow@v3alpha hooks intelligence pattern-store --pattern "[pattern]" --embedding "[json]"
486
+ npx claude-flow@v3alpha hooks intelligence pattern-search --query "[query]" --limit 10
487
+
488
+ # Learning stats & attention
489
+ npx claude-flow@v3alpha hooks intelligence stats
490
+ npx claude-flow@v3alpha hooks intelligence attention --focus "[task]"
491
+ \`\`\`
492
+
493
+ ### Intelligence System (RuVector)
494
+
495
+ V3 includes the RuVector Intelligence System with:
496
+ - **SONA**: Self-Optimizing Neural Architecture
497
+ - **MoE**: Mixture of Experts for specialized routing
498
+ - **HNSW**: 150x faster pattern search
499
+ - **EWC++**: Elastic Weight Consolidation (prevents forgetting)
500
+ - **Flash Attention**: 2.49x-7.47x speedup
501
+
502
+ The 4-step intelligence pipeline:
503
+ 1. **RETRIEVE** - Fetch relevant patterns via HNSW
504
+ 2. **JUDGE** - Evaluate with verdicts (success/failure)
505
+ 3. **DISTILL** - Extract key learnings via LoRA
506
+ 4. **CONSOLIDATE** - Prevent catastrophic forgetting via EWC++
507
+
508
+ ### Auto-Configured Hooks
509
+
510
+ The init system configures these hooks in \`.claude/settings.json\`:
511
+
512
+ \`\`\`json
513
+ {
514
+ "hooks": {
515
+ "PreToolUse": [
516
+ { "matcher": "Task", "commands": ["npx claude-flow@v3alpha hooks pre-task --tool Task"] }
517
+ ],
518
+ "PostToolUse": [
519
+ { "matcher": "Task", "commands": ["npx claude-flow@v3alpha hooks post-task --tool Task --train-patterns"] }
520
+ ],
521
+ "UserPromptSubmit": [
522
+ { "matcher": ".*", "commands": ["npx claude-flow@v3alpha hooks route-task --analyze-complexity"] }
523
+ ],
524
+ "SessionStart": [
525
+ { "commands": ["npx claude-flow@v3alpha hooks session-start --load-context"] }
526
+ ]
527
+ }
528
+ }
529
+ \`\`\`
530
+
531
+ ### Agent Coordination via Hooks
532
+
533
+ Every spawned agent should use hooks for coordination:
534
+
535
+ \`\`\`javascript
536
+ // In agent prompt instructions
537
+ Task("Coder", \`
538
+ BEFORE starting: npx claude-flow@v3alpha hooks pre-task --description "Implement feature X"
539
+
540
+ DURING work:
541
+ - After each file edit: npx claude-flow@v3alpha hooks post-edit --file "[file]"
542
+ - To notify others: npx claude-flow@v3alpha hooks notify --message "[update]"
543
+
544
+ AFTER completing: npx claude-flow@v3alpha hooks post-task --success true
545
+ \`, "coder")
546
+ \`\`\`
547
+
548
+ ## Advanced Features (V3)
549
+
550
+ - 🚀 Automatic Topology Selection
551
+ - ⚡ Parallel Execution (2.8-4.4x speed)
552
+ - 🧠 Neural Training with ReasoningBank
553
+ - 📊 Bottleneck Analysis
554
+ - 🤖 Smart Auto-Spawning
555
+ - 🛡️ Self-Healing Workflows
556
+ - 💾 Cross-Session Memory with AgentDB
557
+ - 🔗 GitHub Integration
558
+ - 🔐 Security-Hardened Architecture
559
+
560
+ ## Integration Tips
561
+
562
+ 1. Start with basic swarm init
563
+ 2. Scale agents gradually
564
+ 3. Use memory for context
565
+ 4. Monitor progress regularly
566
+ 5. Train patterns from success
567
+ 6. Enable hooks automation
568
+ 7. Use GitHub tools first
569
+
570
+ ## Support
571
+
572
+ - Documentation: https://github.com/ruvnet/claude-flow
573
+ - Issues: https://github.com/ruvnet/claude-flow/issues
574
+
575
+ ---
576
+
577
+ Remember: **Claude Flow coordinates, Claude Code creates!**
578
+
579
+ # important-instruction-reminders
580
+ Do what has been asked; nothing more, nothing less.
581
+ NEVER create files unless they're absolutely necessary for achieving your goal.
582
+ ALWAYS prefer editing an existing file to creating a new one.
583
+ NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
584
+ Never save working files, text/mds and tests to the root folder.
585
+ `;
586
+ }
587
+ /**
588
+ * Generate minimal CLAUDE.md content
589
+ */
590
+ export function generateMinimalClaudeMd(options) {
591
+ return `# Claude Code Configuration
592
+
593
+ ## Quick Reference
594
+
595
+ - **Topology**: ${options.runtime.topology}
596
+ - **Max Agents**: ${options.runtime.maxAgents}
597
+ - **Memory**: ${options.runtime.memoryBackend}
598
+
599
+ ## Key Rules
600
+
601
+ 1. **Batch Operations**: All related operations in ONE message
602
+ 2. **Task Tool**: Use Claude Code's Task tool for agent execution
603
+ 3. **MCP Tools**: Only for coordination, not execution
604
+ 4. **File Organization**: Never save to root folder
605
+
606
+ ## Agent Execution Pattern
607
+
608
+ \`\`\`javascript
609
+ // Single message with parallel agents
610
+ Task("Researcher", "Analyze requirements...", "researcher")
611
+ Task("Coder", "Implement features...", "coder")
612
+ Task("Tester", "Write tests...", "tester")
613
+ \`\`\`
614
+
615
+ ## MCP Setup
616
+
617
+ \`\`\`bash
618
+ claude mcp add claude-flow npx claude-flow@v3alpha mcp start
619
+ \`\`\`
620
+
621
+ ---
622
+ Remember: **Claude Flow coordinates, Claude Code creates!**
623
+ `;
624
+ }
625
+ export default generateClaudeMd;
626
+ //# sourceMappingURL=claudemd-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claudemd-generator.js","sourceRoot":"","sources":["../../../src/init/claudemd-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAoB;IACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC1C,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAC5C,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC;IAEpD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;eA0BM,QAAQ;eACR,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6IN,QAAQ;oBACN,SAAS;wBACL,aAAa;uBACd,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;yBACjD,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CA6JlC,QAAQ,iBAAiB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAoDhC,QAAQ,iBAAiB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgM/E,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAoB;IAC1D,OAAO;;;;kBAIS,OAAO,CAAC,OAAO,CAAC,QAAQ;oBACtB,OAAO,CAAC,OAAO,CAAC,SAAS;gBAC7B,OAAO,CAAC,OAAO,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B5C,CAAC;AACF,CAAC;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Init Executor
3
+ * Main execution logic for V3 initialization
4
+ */
5
+ import type { InitOptions, InitResult } from './types.js';
6
+ /**
7
+ * Execute initialization
8
+ */
9
+ export declare function executeInit(options: InitOptions): Promise<InitResult>;
10
+ export default executeInit;
11
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/init/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AA8GxE;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAiF3E;AA0iBD,eAAe,WAAW,CAAC"}