moflo 4.8.9 → 4.8.11

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 (166) hide show
  1. package/.claude/agents/core/coder.md +265 -265
  2. package/.claude/agents/core/planner.md +167 -167
  3. package/.claude/agents/core/researcher.md +189 -189
  4. package/.claude/agents/core/reviewer.md +325 -325
  5. package/.claude/agents/core/tester.md +318 -318
  6. package/.claude/agents/dual-mode/codex-coordinator.md +224 -224
  7. package/.claude/agents/dual-mode/codex-worker.md +211 -211
  8. package/.claude/agents/dual-mode/dual-orchestrator.md +291 -291
  9. package/.claude/agents/github/code-review-swarm.md +537 -537
  10. package/.claude/agents/github/github-modes.md +172 -172
  11. package/.claude/agents/github/issue-tracker.md +318 -318
  12. package/.claude/agents/github/multi-repo-swarm.md +552 -552
  13. package/.claude/agents/github/pr-manager.md +190 -190
  14. package/.claude/agents/github/project-board-sync.md +508 -508
  15. package/.claude/agents/github/release-manager.md +366 -366
  16. package/.claude/agents/github/release-swarm.md +582 -582
  17. package/.claude/agents/github/repo-architect.md +397 -397
  18. package/.claude/agents/github/swarm-issue.md +572 -572
  19. package/.claude/agents/github/swarm-pr.md +427 -427
  20. package/.claude/agents/github/sync-coordinator.md +451 -451
  21. package/.claude/agents/github/workflow-automation.md +634 -634
  22. package/.claude/agents/goal/code-goal-planner.md +445 -445
  23. package/.claude/agents/hive-mind/collective-intelligence-coordinator.md +129 -129
  24. package/.claude/agents/hive-mind/queen-coordinator.md +202 -202
  25. package/.claude/agents/hive-mind/scout-explorer.md +241 -241
  26. package/.claude/agents/hive-mind/swarm-memory-manager.md +192 -192
  27. package/.claude/agents/hive-mind/worker-specialist.md +216 -216
  28. package/.claude/agents/neural/safla-neural.md +73 -73
  29. package/.claude/agents/reasoning/goal-planner.md +72 -72
  30. package/.claude/agents/swarm/adaptive-coordinator.md +395 -395
  31. package/.claude/agents/swarm/hierarchical-coordinator.md +326 -326
  32. package/.claude/agents/swarm/mesh-coordinator.md +391 -391
  33. package/.claude/agents/templates/migration-plan.md +745 -745
  34. package/.claude/commands/agents/agent-spawning.md +28 -28
  35. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +53 -53
  36. package/.claude/commands/analysis/bottleneck-detect.md +162 -162
  37. package/.claude/commands/analysis/performance-bottlenecks.md +58 -58
  38. package/.claude/commands/analysis/token-efficiency.md +44 -44
  39. package/.claude/commands/automation/auto-agent.md +122 -122
  40. package/.claude/commands/automation/self-healing.md +105 -105
  41. package/.claude/commands/automation/session-memory.md +89 -89
  42. package/.claude/commands/automation/smart-agents.md +72 -72
  43. package/.claude/commands/coordination/init.md +44 -44
  44. package/.claude/commands/coordination/orchestrate.md +43 -43
  45. package/.claude/commands/coordination/spawn.md +45 -45
  46. package/.claude/commands/coordination/swarm-init.md +85 -85
  47. package/.claude/commands/github/github-modes.md +146 -146
  48. package/.claude/commands/github/github-swarm.md +121 -121
  49. package/.claude/commands/github/issue-tracker.md +291 -291
  50. package/.claude/commands/github/pr-manager.md +169 -169
  51. package/.claude/commands/github/release-manager.md +337 -337
  52. package/.claude/commands/github/repo-architect.md +366 -366
  53. package/.claude/commands/github/sync-coordinator.md +300 -300
  54. package/.claude/commands/memory/neural.md +47 -47
  55. package/.claude/commands/monitoring/agents.md +44 -44
  56. package/.claude/commands/monitoring/status.md +46 -46
  57. package/.claude/commands/optimization/auto-topology.md +61 -61
  58. package/.claude/commands/optimization/parallel-execution.md +49 -49
  59. package/.claude/commands/sparc/analyzer.md +51 -51
  60. package/.claude/commands/sparc/architect.md +53 -53
  61. package/.claude/commands/sparc/ask.md +97 -97
  62. package/.claude/commands/sparc/batch-executor.md +54 -54
  63. package/.claude/commands/sparc/code.md +89 -89
  64. package/.claude/commands/sparc/coder.md +54 -54
  65. package/.claude/commands/sparc/debug.md +83 -83
  66. package/.claude/commands/sparc/debugger.md +54 -54
  67. package/.claude/commands/sparc/designer.md +53 -53
  68. package/.claude/commands/sparc/devops.md +109 -109
  69. package/.claude/commands/sparc/docs-writer.md +80 -80
  70. package/.claude/commands/sparc/documenter.md +54 -54
  71. package/.claude/commands/sparc/innovator.md +54 -54
  72. package/.claude/commands/sparc/integration.md +83 -83
  73. package/.claude/commands/sparc/mcp.md +117 -117
  74. package/.claude/commands/sparc/memory-manager.md +54 -54
  75. package/.claude/commands/sparc/optimizer.md +54 -54
  76. package/.claude/commands/sparc/orchestrator.md +131 -131
  77. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -83
  78. package/.claude/commands/sparc/refinement-optimization-mode.md +83 -83
  79. package/.claude/commands/sparc/researcher.md +54 -54
  80. package/.claude/commands/sparc/reviewer.md +54 -54
  81. package/.claude/commands/sparc/security-review.md +80 -80
  82. package/.claude/commands/sparc/sparc-modes.md +174 -174
  83. package/.claude/commands/sparc/sparc.md +111 -111
  84. package/.claude/commands/sparc/spec-pseudocode.md +80 -80
  85. package/.claude/commands/sparc/supabase-admin.md +348 -348
  86. package/.claude/commands/sparc/swarm-coordinator.md +54 -54
  87. package/.claude/commands/sparc/tdd.md +54 -54
  88. package/.claude/commands/sparc/tester.md +54 -54
  89. package/.claude/commands/sparc/tutorial.md +79 -79
  90. package/.claude/commands/sparc/workflow-manager.md +54 -54
  91. package/.claude/commands/sparc.md +166 -166
  92. package/.claude/commands/swarm/analysis.md +95 -95
  93. package/.claude/commands/swarm/development.md +96 -96
  94. package/.claude/commands/swarm/examples.md +168 -168
  95. package/.claude/commands/swarm/maintenance.md +102 -102
  96. package/.claude/commands/swarm/optimization.md +117 -117
  97. package/.claude/commands/swarm/research.md +136 -136
  98. package/.claude/commands/swarm/testing.md +131 -131
  99. package/.claude/commands/training/neural-patterns.md +73 -73
  100. package/.claude/commands/training/specialization.md +62 -62
  101. package/.claude/commands/workflows/development.md +77 -77
  102. package/.claude/commands/workflows/research.md +62 -62
  103. package/.claude/guidance/{agent-bootstrap.md → shipped/agent-bootstrap.md} +126 -126
  104. package/.claude/guidance/{guidance-memory-strategy.md → shipped/guidance-memory-strategy.md} +262 -262
  105. package/.claude/guidance/{memory-strategy.md → shipped/memory-strategy.md} +204 -204
  106. package/.claude/guidance/{moflo.md → shipped/moflo.md} +45 -31
  107. package/.claude/guidance/{task-swarm-integration.md → shipped/task-swarm-integration.md} +441 -348
  108. package/.claude/helpers/gate.cjs +236 -236
  109. package/.claude/helpers/hook-handler.cjs +42 -46
  110. package/.claude/settings.json +2 -2
  111. package/.claude/settings.local.json +3 -3
  112. package/.claude/skills/fl/SKILL.md +29 -23
  113. package/.claude/skills/flo/SKILL.md +29 -23
  114. package/.claude/skills/github-code-review/SKILL.md +4 -4
  115. package/.claude/skills/github-multi-repo/SKILL.md +8 -8
  116. package/.claude/skills/github-project-management/SKILL.md +6 -6
  117. package/.claude/skills/github-release-management/SKILL.md +12 -12
  118. package/.claude/skills/github-workflow-automation/SKILL.md +6 -6
  119. package/.claude/skills/hooks-automation/SKILL.md +1201 -1201
  120. package/.claude/skills/performance-analysis/SKILL.md +563 -563
  121. package/.claude/skills/sparc-methodology/SKILL.md +64 -64
  122. package/.claude/skills/swarm-advanced/SKILL.md +77 -77
  123. package/.claude-plugin/README.md +3 -3
  124. package/.claude-plugin/docs/PLUGIN_SUMMARY.md +3 -3
  125. package/.claude-plugin/docs/QUICKSTART.md +4 -4
  126. package/.claude-plugin/marketplace.json +3 -3
  127. package/.claude-plugin/plugin.json +3 -3
  128. package/.claude-plugin/scripts/install.sh +9 -9
  129. package/.claude-plugin/scripts/verify.sh +7 -7
  130. package/README.md +311 -116
  131. package/bin/gate-hook.mjs +50 -0
  132. package/bin/gate.cjs +138 -0
  133. package/bin/hook-handler.cjs +83 -0
  134. package/bin/hooks.mjs +72 -12
  135. package/bin/index-guidance.mjs +28 -34
  136. package/bin/index-tests.mjs +710 -0
  137. package/bin/lib/process-manager.mjs +243 -0
  138. package/bin/lib/registry-cleanup.cjs +41 -0
  139. package/bin/prompt-hook.mjs +72 -0
  140. package/bin/semantic-search.mjs +473 -441
  141. package/bin/session-start-launcher.mjs +81 -31
  142. package/bin/setup-project.mjs +13 -10
  143. package/package.json +4 -2
  144. package/src/@claude-flow/cli/README.md +1 -1
  145. package/src/@claude-flow/cli/bin/cli.js +175 -175
  146. package/src/@claude-flow/cli/dist/src/commands/doctor.js +1091 -736
  147. package/src/@claude-flow/cli/dist/src/commands/github.d.ts +12 -0
  148. package/src/@claude-flow/cli/dist/src/commands/github.js +505 -0
  149. package/src/@claude-flow/cli/dist/src/commands/hive-mind.js +90 -90
  150. package/src/@claude-flow/cli/dist/src/commands/index.d.ts +1 -0
  151. package/src/@claude-flow/cli/dist/src/commands/index.js +7 -0
  152. package/src/@claude-flow/cli/dist/src/config-adapter.js +1 -1
  153. package/src/@claude-flow/cli/dist/src/init/claudemd-generator.js +1 -1
  154. package/src/@claude-flow/cli/dist/src/init/executor.js +109 -5
  155. package/src/@claude-flow/cli/dist/src/init/helpers-generator.d.ts +14 -0
  156. package/src/@claude-flow/cli/dist/src/init/helpers-generator.js +156 -24
  157. package/src/@claude-flow/cli/dist/src/init/mcp-generator.js +20 -20
  158. package/src/@claude-flow/cli/dist/src/init/moflo-init.d.ts +7 -0
  159. package/src/@claude-flow/cli/dist/src/init/moflo-init.js +72 -10
  160. package/src/@claude-flow/cli/dist/src/init/settings-generator.js +23 -14
  161. package/src/@claude-flow/cli/dist/src/mcp-server.js +3 -3
  162. package/src/@claude-flow/cli/dist/src/plugins/manager.js +9 -8
  163. package/src/@claude-flow/cli/dist/src/services/worker-daemon.d.ts +1 -0
  164. package/src/@claude-flow/cli/dist/src/services/worker-daemon.js +3 -1
  165. package/src/@claude-flow/cli/dist/src/services/workflow-gate.js +10 -10
  166. package/src/@claude-flow/cli/package.json +1 -1
@@ -50,96 +50,96 @@ function generateHiveMindPrompt(swarmId, swarmName, objective, workers, workerGr
50
50
  const queenType = flags.queenType || 'strategic';
51
51
  const consensusAlgorithm = flags.consensus || 'byzantine';
52
52
  const topology = flags.topology || 'hierarchical-mesh';
53
- return `🧠 HIVE MIND COLLECTIVE INTELLIGENCE SYSTEM
54
- ═══════════════════════════════════════════════
55
-
56
- You are the Queen coordinator of a Hive Mind swarm with collective intelligence capabilities.
57
-
58
- HIVE MIND CONFIGURATION:
59
- 📌 Swarm ID: ${swarmId}
60
- 📌 Swarm Name: ${swarmName}
61
- 🎯 Objective: ${objective}
62
- 👑 Queen Type: ${queenType}
63
- 🐝 Worker Count: ${workers.length}
64
- 🔗 Topology: ${topology}
65
- 🤝 Consensus Algorithm: ${consensusAlgorithm}
66
- ⏰ Initialized: ${currentTime}
67
-
68
- WORKER DISTRIBUTION:
69
- ${workerTypes.map(type => `• ${type}: ${workerGroups[type].length} agents`).join('\n')}
70
-
71
- 🔧 AVAILABLE MCP TOOLS FOR HIVE MIND COORDINATION:
72
-
73
- 1️⃣ **COLLECTIVE INTELLIGENCE**
74
- mcp__claude-flow__hive-mind_consensus - Democratic decision making
75
- mcp__claude-flow__hive-mind_memory - Share knowledge across the hive
76
- mcp__claude-flow__hive-mind_broadcast - Broadcast to all workers
77
- mcp__claude-flow__neural_patterns - Neural pattern recognition
78
-
79
- 2️⃣ **QUEEN COORDINATION**
80
- mcp__claude-flow__hive-mind_status - Monitor swarm health
81
- mcp__claude-flow__task_create - Create and delegate tasks
82
- mcp__claude-flow__task_orchestrate - Orchestrate task distribution
83
- mcp__claude-flow__agent_spawn - Spawn additional workers
84
-
85
- 3️⃣ **WORKER MANAGEMENT**
86
- mcp__claude-flow__agent_list - List all active agents
87
- mcp__claude-flow__agent_status - Check agent status
88
- mcp__claude-flow__agent_metrics - Track worker performance
89
- mcp__claude-flow__hive-mind_join - Add agent to hive
90
- mcp__claude-flow__hive-mind_leave - Remove agent from hive
91
-
92
- 4️⃣ **TASK ORCHESTRATION**
93
- mcp__claude-flow__task_create - Create hierarchical tasks
94
- mcp__claude-flow__task_status - Track task progress
95
- mcp__claude-flow__task_complete - Mark tasks complete
96
- mcp__claude-flow__workflow_create - Create workflows
97
-
98
- 5️⃣ **MEMORY & LEARNING**
99
- mcp__claude-flow__memory_store - Store collective knowledge
100
- mcp__claude-flow__memory_retrieve - Access shared memory
101
- mcp__claude-flow__memory_search - Search memory patterns
102
- mcp__claude-flow__neural_train - Learn from experiences
103
- mcp__claude-flow__hooks_intelligence_pattern-store - Store patterns
104
-
105
- 📋 HIVE MIND EXECUTION PROTOCOL:
106
-
107
- 1. **INITIALIZATION PHASE**
108
- - Verify all workers are online and responsive
109
- - Establish communication channels
110
- - Load previous session state if available
111
- - Initialize shared memory space
112
-
113
- 2. **TASK DISTRIBUTION PHASE**
114
- - Analyze the objective and decompose into subtasks
115
- - Assign tasks based on worker specializations
116
- - Set up task dependencies and ordering
117
- - Monitor parallel execution
118
-
119
- 3. **COORDINATION PHASE**
120
- - Use consensus for critical decisions
121
- - Aggregate results from workers
122
- - Resolve conflicts using ${consensusAlgorithm} consensus
123
- - Share learnings across the hive
124
-
125
- 4. **COMPLETION PHASE**
126
- - Verify all subtasks are complete
127
- - Consolidate results
128
- - Store learnings in collective memory
129
- - Report final status
130
-
131
- 🎯 YOUR OBJECTIVE:
132
- ${objective}
133
-
134
- 💡 COORDINATION TIPS:
135
- • Use mcp__claude-flow__hive-mind_broadcast for swarm-wide announcements
136
- • Check worker status regularly with mcp__claude-flow__hive-mind_status
137
- • Store important decisions in shared memory for persistence
138
- • Use consensus for any decisions affecting multiple workers
139
- • Monitor task progress and reassign if workers are blocked
140
-
141
- 🚀 BEGIN HIVE MIND COORDINATION NOW!
142
- Start by checking the current hive status and then proceed with the objective.
53
+ return `🧠 HIVE MIND COLLECTIVE INTELLIGENCE SYSTEM
54
+ ═══════════════════════════════════════════════
55
+
56
+ You are the Queen coordinator of a Hive Mind swarm with collective intelligence capabilities.
57
+
58
+ HIVE MIND CONFIGURATION:
59
+ 📌 Swarm ID: ${swarmId}
60
+ 📌 Swarm Name: ${swarmName}
61
+ 🎯 Objective: ${objective}
62
+ 👑 Queen Type: ${queenType}
63
+ 🐝 Worker Count: ${workers.length}
64
+ 🔗 Topology: ${topology}
65
+ 🤝 Consensus Algorithm: ${consensusAlgorithm}
66
+ ⏰ Initialized: ${currentTime}
67
+
68
+ WORKER DISTRIBUTION:
69
+ ${workerTypes.map(type => `• ${type}: ${workerGroups[type].length} agents`).join('\n')}
70
+
71
+ 🔧 AVAILABLE MCP TOOLS FOR HIVE MIND COORDINATION:
72
+
73
+ 1️⃣ **COLLECTIVE INTELLIGENCE**
74
+ mcp__moflo__hive-mind_consensus - Democratic decision making
75
+ mcp__moflo__hive-mind_memory - Share knowledge across the hive
76
+ mcp__moflo__hive-mind_broadcast - Broadcast to all workers
77
+ mcp__moflo__neural_patterns - Neural pattern recognition
78
+
79
+ 2️⃣ **QUEEN COORDINATION**
80
+ mcp__moflo__hive-mind_status - Monitor swarm health
81
+ mcp__moflo__task_create - Create and delegate tasks
82
+ mcp__moflo__task_orchestrate - Orchestrate task distribution
83
+ mcp__moflo__agent_spawn - Spawn additional workers
84
+
85
+ 3️⃣ **WORKER MANAGEMENT**
86
+ mcp__moflo__agent_list - List all active agents
87
+ mcp__moflo__agent_status - Check agent status
88
+ mcp__moflo__agent_metrics - Track worker performance
89
+ mcp__moflo__hive-mind_join - Add agent to hive
90
+ mcp__moflo__hive-mind_leave - Remove agent from hive
91
+
92
+ 4️⃣ **TASK ORCHESTRATION**
93
+ mcp__moflo__task_create - Create hierarchical tasks
94
+ mcp__moflo__task_status - Track task progress
95
+ mcp__moflo__task_complete - Mark tasks complete
96
+ mcp__moflo__workflow_create - Create workflows
97
+
98
+ 5️⃣ **MEMORY & LEARNING**
99
+ mcp__moflo__memory_store - Store collective knowledge
100
+ mcp__moflo__memory_retrieve - Access shared memory
101
+ mcp__moflo__memory_search - Search memory patterns
102
+ mcp__moflo__neural_train - Learn from experiences
103
+ mcp__moflo__hooks_intelligence_pattern-store - Store patterns
104
+
105
+ 📋 HIVE MIND EXECUTION PROTOCOL:
106
+
107
+ 1. **INITIALIZATION PHASE**
108
+ - Verify all workers are online and responsive
109
+ - Establish communication channels
110
+ - Load previous session state if available
111
+ - Initialize shared memory space
112
+
113
+ 2. **TASK DISTRIBUTION PHASE**
114
+ - Analyze the objective and decompose into subtasks
115
+ - Assign tasks based on worker specializations
116
+ - Set up task dependencies and ordering
117
+ - Monitor parallel execution
118
+
119
+ 3. **COORDINATION PHASE**
120
+ - Use consensus for critical decisions
121
+ - Aggregate results from workers
122
+ - Resolve conflicts using ${consensusAlgorithm} consensus
123
+ - Share learnings across the hive
124
+
125
+ 4. **COMPLETION PHASE**
126
+ - Verify all subtasks are complete
127
+ - Consolidate results
128
+ - Store learnings in collective memory
129
+ - Report final status
130
+
131
+ 🎯 YOUR OBJECTIVE:
132
+ ${objective}
133
+
134
+ 💡 COORDINATION TIPS:
135
+ • Use mcp__moflo__hive-mind_broadcast for swarm-wide announcements
136
+ • Check worker status regularly with mcp__moflo__hive-mind_status
137
+ • Store important decisions in shared memory for persistence
138
+ • Use consensus for any decisions affecting multiple workers
139
+ • Monitor task progress and reassign if workers are blocked
140
+
141
+ 🚀 BEGIN HIVE MIND COORDINATION NOW!
142
+ Start by checking the current hive status and then proceed with the objective.
143
143
  `;
144
144
  }
145
145
  /**
@@ -30,6 +30,7 @@ export { hiveMindCommand } from './hive-mind.js';
30
30
  export { guidanceCommand } from './guidance.js';
31
31
  export { applianceCommand } from './appliance.js';
32
32
  export { diagnoseCommand } from './diagnose.js';
33
+ export { githubCommand } from './github.js';
33
34
  export declare function getConfigCommand(): Promise<Command | undefined>;
34
35
  export declare function getMigrateCommand(): Promise<Command | undefined>;
35
36
  export declare function getWorkflowCommand(): Promise<Command | undefined>;
@@ -67,6 +67,8 @@ const commandLoaders = {
67
67
  gate: () => import('./gate.js'),
68
68
  // Feature Orchestrator
69
69
  orc: () => import('./orc.js'),
70
+ // GitHub Repository Setup
71
+ github: () => import('./github.js'),
70
72
  };
71
73
  // Cache for loaded commands
72
74
  const loadedCommands = new Map();
@@ -137,6 +139,7 @@ import { processCommand } from './process.js';
137
139
  import { guidanceCommand } from './guidance.js';
138
140
  import { applianceCommand } from './appliance.js';
139
141
  import { diagnoseCommand } from './diagnose.js';
142
+ import { githubCommand } from './github.js';
140
143
  // Pre-populate cache with core commands
141
144
  loadedCommands.set('init', initCommand);
142
145
  loadedCommands.set('start', startCommand);
@@ -158,6 +161,7 @@ loadedCommands.set('ruvector', ruvectorCommand);
158
161
  loadedCommands.set('hive-mind', hiveMindCommand);
159
162
  loadedCommands.set('guidance', guidanceCommand);
160
163
  loadedCommands.set('diagnose', diagnoseCommand);
164
+ loadedCommands.set('github', githubCommand);
161
165
  // =============================================================================
162
166
  // Exports (maintain backwards compatibility)
163
167
  // =============================================================================
@@ -183,6 +187,7 @@ export { hiveMindCommand } from './hive-mind.js';
183
187
  export { guidanceCommand } from './guidance.js';
184
188
  export { applianceCommand } from './appliance.js';
185
189
  export { diagnoseCommand } from './diagnose.js';
190
+ export { githubCommand } from './github.js';
186
191
  // Lazy-loaded command re-exports (for backwards compatibility, but async-only)
187
192
  export async function getConfigCommand() { return loadCommand('config'); }
188
193
  export async function getMigrateCommand() { return loadCommand('migrate'); }
@@ -233,6 +238,7 @@ export const commands = [
233
238
  hiveMindCommand,
234
239
  guidanceCommand,
235
240
  diagnoseCommand,
241
+ githubCommand,
236
242
  ];
237
243
  /**
238
244
  * Commands organized by category for help display
@@ -282,6 +288,7 @@ export const commandsByCategory = {
282
288
  updateCommand,
283
289
  processCommand,
284
290
  applianceCommand,
291
+ githubCommand,
285
292
  ],
286
293
  };
287
294
  /**
@@ -118,7 +118,7 @@ export function v3ConfigToSystemConfig(v3Config) {
118
118
  },
119
119
  },
120
120
  mcp: {
121
- name: 'claude-flow',
121
+ name: 'moflo',
122
122
  version: '3.0.0',
123
123
  transport: {
124
124
  type: v3Config.mcp.transportType,
@@ -364,7 +364,7 @@ function setupAndBoundary() {
364
364
  return `## Quick Setup
365
365
 
366
366
  \`\`\`bash
367
- claude mcp add claude-flow -- npx -y moflo
367
+ claude mcp add moflo -- npx -y moflo
368
368
  npx moflo daemon start
369
369
  npx moflo doctor --fix
370
370
  \`\`\`
@@ -14,7 +14,7 @@ import { detectPlatform, DEFAULT_INIT_OPTIONS } from './types.js';
14
14
  import { generateSettingsJson, generateSettings } from './settings-generator.js';
15
15
  import { generateMCPJson } from './mcp-generator.js';
16
16
  import { generateStatuslineScript } from './statusline-generator.js';
17
- import { generatePreCommitHook, generatePostCommitHook, generateAutoMemoryHook, generateGateScript, generateHookHandlerScript, } from './helpers-generator.js';
17
+ import { generatePreCommitHook, generatePostCommitHook, generateAutoMemoryHook, generateGateScript, generateGateHookScript, generatePromptHookScript, generateHookHandlerScript, } from './helpers-generator.js';
18
18
  import { generateClaudeMd } from './claudemd-generator.js';
19
19
  /**
20
20
  * Skills to copy based on configuration
@@ -377,6 +377,8 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
377
377
  const generatedCritical = {
378
378
  'auto-memory-hook.mjs': generateAutoMemoryHook(),
379
379
  'gate.cjs': generateGateScript(),
380
+ 'gate-hook.mjs': generateGateHookScript(),
381
+ 'prompt-hook.mjs': generatePromptHookScript(),
380
382
  'hook-handler.cjs': generateHookHandlerScript(),
381
383
  };
382
384
  for (const [helperName, content] of Object.entries(generatedCritical)) {
@@ -463,6 +465,22 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
463
465
  }
464
466
  }
465
467
  }
468
+ // 1c. Build manifest of files we're installing, clean up stale ones
469
+ const manifestPath = path.join(targetDir, '.claude-flow', 'installed-files.json');
470
+ let previousManifest = [];
471
+ try {
472
+ previousManifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
473
+ }
474
+ catch { /* ok */ }
475
+ const currentManifest = [];
476
+ // Collect everything we just synced into the manifest
477
+ for (const entry of [...result.created, ...result.updated]) {
478
+ // Strip annotations like " (removed, obsolete)" — keep only clean paths
479
+ const clean = entry.replace(/\s*\(.*\)$/, '');
480
+ if (clean.startsWith('.claude/') || clean.startsWith('.claude-flow/')) {
481
+ currentManifest.push(clean);
482
+ }
483
+ }
466
484
  // 2. Create MISSING metrics files only (preserve existing data)
467
485
  const metricsDir = path.join(targetDir, '.claude-flow', 'metrics');
468
486
  const securityDir = path.join(targetDir, '.claude-flow', 'security');
@@ -579,6 +597,39 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
579
597
  result.settingsUpdated = ['Created new settings.json with Agent Teams'];
580
598
  }
581
599
  }
600
+ // ── Final: collect any additional generated files into manifest, then clean up stale ──
601
+ // Re-scan result arrays since metrics/security files were added after initial collection
602
+ for (const entry of [...result.created, ...result.updated]) {
603
+ const clean = entry.replace(/\s*\(.*\)$/, '');
604
+ if ((clean.startsWith('.claude/') || clean.startsWith('.claude-flow/')) && !currentManifest.includes(clean)) {
605
+ currentManifest.push(clean);
606
+ }
607
+ }
608
+ // Remove files that were in the OLD manifest but NOT in the new one.
609
+ // This only deletes files moflo previously installed — never user or runtime files.
610
+ if (previousManifest.length > 0) {
611
+ const currentSet = new Set(currentManifest);
612
+ for (const rel of previousManifest) {
613
+ if (!currentSet.has(rel)) {
614
+ const abs = path.join(targetDir, rel);
615
+ try {
616
+ if (fs.existsSync(abs)) {
617
+ fs.unlinkSync(abs);
618
+ result.updated.push(`${rel} (removed, no longer shipped)`);
619
+ }
620
+ }
621
+ catch { /* non-fatal */ }
622
+ }
623
+ }
624
+ }
625
+ // Write manifest for next upgrade
626
+ try {
627
+ const cfDir = path.join(targetDir, '.claude-flow');
628
+ if (!fs.existsSync(cfDir))
629
+ fs.mkdirSync(cfDir, { recursive: true });
630
+ fs.writeFileSync(manifestPath, JSON.stringify(currentManifest, null, 2), 'utf-8');
631
+ }
632
+ catch { /* non-fatal */ }
582
633
  }
583
634
  catch (error) {
584
635
  result.success = false;
@@ -713,12 +764,63 @@ async function writeSettings(targetDir, options, result) {
713
764
  }
714
765
  /**
715
766
  * Write .mcp.json
767
+ *
768
+ * If an existing config contains the legacy 'claude-flow' server key, prompt
769
+ * the user to migrate it to 'moflo', keep both side-by-side, or leave as-is.
716
770
  */
717
771
  async function writeMCPConfig(targetDir, options, result) {
718
772
  const mcpPath = path.join(targetDir, '.mcp.json');
719
- if (fs.existsSync(mcpPath) && !options.force) {
720
- result.skipped.push('.mcp.json');
721
- return;
773
+ if (fs.existsSync(mcpPath)) {
774
+ const existing = JSON.parse(fs.readFileSync(mcpPath, 'utf-8'));
775
+ const servers = existing?.mcpServers ?? {};
776
+ const hasLegacy = 'claude-flow' in servers;
777
+ const hasMoflo = 'moflo' in servers;
778
+ if (hasLegacy && !hasMoflo) {
779
+ // Interactive mode: prompt the user
780
+ if (process.stdin.isTTY && !options.force) {
781
+ const { select } = await import('../prompt.js');
782
+ const action = await select({
783
+ message: "Found existing 'claude-flow' MCP server. How should we handle it?",
784
+ options: [
785
+ { value: 'migrate', label: 'Migrate to moflo', hint: 'Rename claude-flow → moflo (recommended)' },
786
+ { value: 'side-by-side', label: 'Keep both', hint: 'Add moflo alongside existing claude-flow' },
787
+ { value: 'skip', label: 'Skip', hint: 'Leave .mcp.json unchanged' },
788
+ ],
789
+ default: 'migrate',
790
+ });
791
+ if (action === 'skip') {
792
+ result.skipped.push('.mcp.json');
793
+ return;
794
+ }
795
+ if (action === 'migrate') {
796
+ servers['moflo'] = servers['claude-flow'];
797
+ delete servers['claude-flow'];
798
+ existing.mcpServers = servers;
799
+ fs.writeFileSync(mcpPath, JSON.stringify(existing, null, 2), 'utf-8');
800
+ result.created.files.push('.mcp.json (migrated claude-flow → moflo)');
801
+ return;
802
+ }
803
+ // side-by-side: fall through to generate new config and merge
804
+ const newConfig = JSON.parse(generateMCPJson(options));
805
+ Object.assign(servers, newConfig.mcpServers ?? {});
806
+ existing.mcpServers = servers;
807
+ fs.writeFileSync(mcpPath, JSON.stringify(existing, null, 2), 'utf-8');
808
+ result.created.files.push('.mcp.json (added moflo alongside claude-flow)');
809
+ return;
810
+ }
811
+ // Non-interactive (CI/pipe): auto-migrate silently
812
+ servers['moflo'] = servers['claude-flow'];
813
+ delete servers['claude-flow'];
814
+ existing.mcpServers = servers;
815
+ fs.writeFileSync(mcpPath, JSON.stringify(existing, null, 2), 'utf-8');
816
+ result.created.files.push('.mcp.json (auto-migrated claude-flow → moflo)');
817
+ return;
818
+ }
819
+ // Already has moflo or no legacy key — skip unless forced
820
+ if (!options.force) {
821
+ result.skipped.push('.mcp.json');
822
+ return;
823
+ }
722
824
  }
723
825
  const content = generateMCPJson(options);
724
826
  fs.writeFileSync(mcpPath, content, 'utf-8');
@@ -1012,6 +1114,8 @@ async function writeHelpers(targetDir, options, result) {
1012
1114
  'post-commit': generatePostCommitHook(),
1013
1115
  'auto-memory-hook.mjs': generateAutoMemoryHook(),
1014
1116
  'gate.cjs': generateGateScript(),
1117
+ 'gate-hook.mjs': generateGateHookScript(),
1118
+ 'prompt-hook.mjs': generatePromptHookScript(),
1015
1119
  'hook-handler.cjs': generateHookHandlerScript(),
1016
1120
  };
1017
1121
  for (const [name, content] of Object.entries(helpers)) {
@@ -1653,7 +1757,7 @@ npx moflo hive-mind consensus --propose "task"
1653
1757
  ### MCP Server Setup
1654
1758
  \`\`\`bash
1655
1759
  # Add Claude Flow MCP
1656
- claude mcp add claude-flow -- npx -y moflo
1760
+ claude mcp add moflo -- npx -y moflo
1657
1761
 
1658
1762
  # Optional servers
1659
1763
  claude mcp add ruv-swarm -- npx -y ruv-swarm mcp start
@@ -28,6 +28,20 @@ export declare function generateHelpers(options: InitOptions): Record<string, st
28
28
  * on every tool call (~500ms npx overhead → ~20ms direct node).
29
29
  */
30
30
  export declare function generateGateScript(): string;
31
+ /**
32
+ * Generate gate-hook.mjs — ESM wrapper that reads Claude Code stdin JSON
33
+ * and passes tool_name + tool_input to gate.cjs via environment variables.
34
+ *
35
+ * Claude Code hooks receive context as JSON on stdin but don't set env vars
36
+ * for tool input. This script bridges that gap. It also translates exit code 1
37
+ * from gate.cjs into exit code 2 (which Claude Code requires to block tools).
38
+ */
39
+ export declare function generateGateHookScript(): string;
40
+ /**
41
+ * Generate prompt-hook.mjs — reads user prompt from Claude Code stdin JSON,
42
+ * runs prompt classification via gate.cjs, and appends namespace hints.
43
+ */
44
+ export declare function generatePromptHookScript(): string;
31
45
  /**
32
46
  * Generate lightweight hook-handler.cjs — hook dispatch without CLI bootstrap.
33
47
  * Handles routing, edit/task tracking, session lifecycle, and notifications.