claude-flow 2.0.0-alpha.99 → 2.0.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 (252) hide show
  1. package/.claude/agents/MIGRATION_SUMMARY.md +7 -0
  2. package/.claude/agents/README.md +7 -0
  3. package/.claude/agents/consensus/README.md +7 -0
  4. package/.claude/agents/flow-nexus/app-store.md +88 -0
  5. package/.claude/agents/flow-nexus/authentication.md +69 -0
  6. package/.claude/agents/flow-nexus/challenges.md +81 -0
  7. package/.claude/agents/flow-nexus/neural-network.md +88 -0
  8. package/.claude/agents/flow-nexus/payments.md +83 -0
  9. package/.claude/agents/flow-nexus/sandbox.md +76 -0
  10. package/.claude/agents/flow-nexus/swarm.md +76 -0
  11. package/.claude/agents/flow-nexus/user-tools.md +96 -0
  12. package/.claude/agents/flow-nexus/workflow.md +84 -0
  13. package/.claude/agents/optimization/README.md +7 -0
  14. package/.claude/agents/optimization/benchmark-suite.md +7 -0
  15. package/.claude/agents/optimization/load-balancer.md +7 -0
  16. package/.claude/agents/optimization/performance-monitor.md +7 -0
  17. package/.claude/agents/optimization/resource-allocator.md +7 -0
  18. package/.claude/agents/optimization/topology-optimizer.md +7 -0
  19. package/.claude/agents/swarm/README.md +7 -0
  20. package/.claude/checkpoints/1756227652.json +1 -0
  21. package/.claude/checkpoints/1756227653.json +1 -0
  22. package/.claude/checkpoints/1756227666.json +1 -0
  23. package/.claude/checkpoints/1756227668.json +1 -0
  24. package/.claude/checkpoints/1756227723.json +1 -0
  25. package/.claude/checkpoints/1756227725.json +1 -0
  26. package/.claude/checkpoints/1756227731.json +1 -0
  27. package/.claude/checkpoints/1756227733.json +1 -0
  28. package/.claude/checkpoints/1756231330.json +1 -0
  29. package/.claude/checkpoints/1756231331.json +1 -0
  30. package/.claude/checkpoints/1756231342.json +1 -0
  31. package/.claude/checkpoints/1756231344.json +1 -0
  32. package/.claude/checkpoints/1756231355.json +1 -0
  33. package/.claude/checkpoints/1756231357.json +1 -0
  34. package/.claude/checkpoints/1756231367.json +1 -0
  35. package/.claude/checkpoints/1756231368.json +1 -0
  36. package/.claude/checkpoints/1756231458.json +1 -0
  37. package/.claude/checkpoints/1756231459.json +1 -0
  38. package/.claude/checkpoints/1756231477.json +1 -0
  39. package/.claude/checkpoints/1756231479.json +1 -0
  40. package/.claude/checkpoints/1756233026.json +1 -0
  41. package/.claude/checkpoints/1756233028.json +1 -0
  42. package/.claude/checkpoints/1756233040.json +1 -0
  43. package/.claude/checkpoints/1756233041.json +1 -0
  44. package/.claude/checkpoints/1756233057.json +1 -0
  45. package/.claude/checkpoints/1756233059.json +1 -0
  46. package/.claude/checkpoints/1756233090.json +1 -0
  47. package/.claude/checkpoints/1756233092.json +1 -0
  48. package/.claude/checkpoints/1756233141.json +1 -0
  49. package/.claude/checkpoints/1756233143.json +1 -0
  50. package/.claude/checkpoints/1756475935.json +1 -0
  51. package/.claude/checkpoints/1756475936.json +1 -0
  52. package/.claude/checkpoints/1756475996.json +1 -0
  53. package/.claude/checkpoints/1756475998.json +1 -0
  54. package/.claude/checkpoints/1756476093.json +1 -0
  55. package/.claude/checkpoints/1756476098.json +1 -0
  56. package/.claude/checkpoints/1756476100.json +1 -0
  57. package/.claude/checkpoints/1756476101.json +1 -0
  58. package/.claude/checkpoints/1756476161.json +1 -0
  59. package/.claude/checkpoints/1756476163.json +1 -0
  60. package/.claude/checkpoints/1756476183.json +1 -0
  61. package/.claude/checkpoints/1756476184.json +1 -0
  62. package/.claude/checkpoints/1756476193.json +1 -0
  63. package/.claude/checkpoints/1756476194.json +1 -0
  64. package/.claude/checkpoints/1756476202.json +1 -0
  65. package/.claude/checkpoints/1756476204.json +1 -0
  66. package/.claude/checkpoints/1756476268.json +1 -0
  67. package/.claude/checkpoints/1756476269.json +1 -0
  68. package/.claude/checkpoints/1756476287.json +1 -0
  69. package/.claude/checkpoints/1756476288.json +1 -0
  70. package/.claude/checkpoints/1756997935.json +1 -0
  71. package/.claude/checkpoints/1756997937.json +1 -0
  72. package/.claude/checkpoints/1756997938.json +1 -0
  73. package/.claude/checkpoints/1756997940.json +1 -0
  74. package/.claude/checkpoints/1756997942.json +1 -0
  75. package/.claude/checkpoints/1756997944.json +1 -0
  76. package/.claude/checkpoints/1756997945.json +1 -0
  77. package/.claude/checkpoints/1756997947.json +1 -0
  78. package/.claude/checkpoints/1756997949.json +1 -0
  79. package/.claude/checkpoints/1756997951.json +1 -0
  80. package/.claude/checkpoints/1756997953.json +1 -0
  81. package/.claude/checkpoints/1756997955.json +1 -0
  82. package/.claude/checkpoints/1756997956.json +1 -0
  83. package/.claude/checkpoints/1756997958.json +1 -0
  84. package/.claude/checkpoints/1756997960.json +1 -0
  85. package/.claude/checkpoints/1756997962.json +1 -0
  86. package/.claude/checkpoints/1756997964.json +1 -0
  87. package/.claude/checkpoints/1756997966.json +1 -0
  88. package/.claude/checkpoints/1756997968.json +1 -0
  89. package/.claude/checkpoints/1756997970.json +1 -0
  90. package/.claude/checkpoints/1757190213.json +1 -0
  91. package/.claude/checkpoints/1757190215.json +1 -0
  92. package/.claude/checkpoints/1757190217.json +1 -0
  93. package/.claude/checkpoints/1757190219.json +1 -0
  94. package/.claude/checkpoints/1757190220.json +1 -0
  95. package/.claude/checkpoints/1757190222.json +1 -0
  96. package/.claude/checkpoints/1757190224.json +1 -0
  97. package/.claude/checkpoints/1757190225.json +1 -0
  98. package/.claude/checkpoints/1757190227.json +1 -0
  99. package/.claude/checkpoints/1757190229.json +1 -0
  100. package/.claude/checkpoints/1757190231.json +1 -0
  101. package/.claude/checkpoints/1757190232.json +1 -0
  102. package/.claude/checkpoints/1757190234.json +1 -0
  103. package/.claude/checkpoints/1757190236.json +1 -0
  104. package/.claude/checkpoints/1757190238.json +1 -0
  105. package/.claude/checkpoints/1757190240.json +1 -0
  106. package/.claude/checkpoints/1757190241.json +1 -0
  107. package/.claude/checkpoints/1757190243.json +1 -0
  108. package/.claude/checkpoints/1757190245.json +1 -0
  109. package/.claude/checkpoints/1757190247.json +1 -0
  110. package/.claude/checkpoints/1757190608.json +1 -0
  111. package/.claude/checkpoints/1757190610.json +1 -0
  112. package/.claude/checkpoints/1757190626.json +1 -0
  113. package/.claude/checkpoints/1757190628.json +1 -0
  114. package/.claude/checkpoints/1757190993.json +1 -0
  115. package/.claude/checkpoints/1757190997.json +1 -0
  116. package/.claude/checkpoints/1757191001.json +1 -0
  117. package/.claude/checkpoints/1757191004.json +1 -0
  118. package/.claude/checkpoints/1757191007.json +1 -0
  119. package/.claude/checkpoints/1757191009.json +1 -0
  120. package/.claude/checkpoints/1757191012.json +1 -0
  121. package/.claude/checkpoints/1757191014.json +1 -0
  122. package/.claude/checkpoints/1757191016.json +1 -0
  123. package/.claude/checkpoints/1757191019.json +1 -0
  124. package/.claude/checkpoints/1757191022.json +1 -0
  125. package/.claude/checkpoints/1757191024.json +1 -0
  126. package/.claude/checkpoints/1757191027.json +1 -0
  127. package/.claude/checkpoints/1757191029.json +1 -0
  128. package/.claude/checkpoints/1757191032.json +1 -0
  129. package/.claude/checkpoints/1757191034.json +1 -0
  130. package/.claude/checkpoints/1757191037.json +1 -0
  131. package/.claude/checkpoints/1757191040.json +1 -0
  132. package/.claude/checkpoints/1757191061.json +1 -0
  133. package/.claude/checkpoints/1757191063.json +1 -0
  134. package/.claude/checkpoints/1757191084.json +1 -0
  135. package/.claude/checkpoints/1757191086.json +1 -0
  136. package/.claude/checkpoints/1757192316.json +1 -0
  137. package/.claude/checkpoints/1757192318.json +1 -0
  138. package/.claude/checkpoints/1757192389.json +1 -0
  139. package/.claude/checkpoints/1757192391.json +1 -0
  140. package/.claude/checkpoints/1757192489.json +1 -0
  141. package/.claude/checkpoints/1757192491.json +1 -0
  142. package/.claude/checkpoints/1757192521.json +1 -0
  143. package/.claude/checkpoints/1757192523.json +1 -0
  144. package/.claude/checkpoints/1757192541.json +1 -0
  145. package/.claude/checkpoints/1757192543.json +1 -0
  146. package/.claude/checkpoints/1757193796.json +1 -0
  147. package/.claude/checkpoints/1757194415.json +1 -0
  148. package/.claude/checkpoints/1757194416.json +1 -0
  149. package/.claude/checkpoints/1757194435.json +1 -0
  150. package/.claude/checkpoints/1757194437.json +1 -0
  151. package/.claude/checkpoints/1757194468.json +1 -0
  152. package/.claude/checkpoints/1757194469.json +1 -0
  153. package/.claude/checkpoints/1757194554.json +1 -0
  154. package/.claude/checkpoints/1757194555.json +1 -0
  155. package/.claude/checkpoints/1757194606.json +1 -0
  156. package/.claude/checkpoints/1757194608.json +1 -0
  157. package/.claude/checkpoints/1757194817.json +1 -0
  158. package/.claude/checkpoints/1757194818.json +1 -0
  159. package/.claude/checkpoints/summary-session-20250826-165852.md +1351 -0
  160. package/.claude/checkpoints/summary-session-20250826-170402.md +1367 -0
  161. package/.claude/checkpoints/summary-session-20250826-175112.md +1327 -0
  162. package/.claude/checkpoints/summary-session-20250826-175609.md +1324 -0
  163. package/.claude/checkpoints/summary-session-20250826-175743.md +1327 -0
  164. package/.claude/checkpoints/summary-session-20250826-180554.md +1340 -0
  165. package/.claude/checkpoints/summary-session-20250826-181530.md +1344 -0
  166. package/.claude/checkpoints/summary-session-20250826-181633.md +1347 -0
  167. package/.claude/checkpoints/summary-session-20250826-182235.md +1350 -0
  168. package/.claude/checkpoints/summary-session-20250826-182618.md +1353 -0
  169. package/.claude/checkpoints/summary-session-20250826-183200.md +1372 -0
  170. package/.claude/checkpoints/summary-session-20250826-183232.md +1379 -0
  171. package/.claude/checkpoints/summary-session-20250829-133605.md +38 -0
  172. package/.claude/checkpoints/summary-session-20250829-134121.md +41 -0
  173. package/.claude/checkpoints/summary-session-20250829-134400.md +46 -0
  174. package/.claude/checkpoints/summary-session-20250829-134858.md +49 -0
  175. package/.claude/checkpoints/summary-session-20250829-135402.md +52 -0
  176. package/.claude/checkpoints/summary-session-20250829-135640.md +58 -0
  177. package/.claude/checkpoints/summary-session-20250829-135754.md +65 -0
  178. package/.claude/checkpoints/summary-session-20250829-135902.md +71 -0
  179. package/.claude/checkpoints/summary-session-20250829-140629.md +119 -0
  180. package/.claude/checkpoints/summary-session-20250829-140733.md +121 -0
  181. package/.claude/checkpoints/summary-session-20250902-190126.md +38 -0
  182. package/.claude/checkpoints/summary-session-20250904-150003.md +87 -0
  183. package/.claude/checkpoints/summary-session-20250906-202218.md +2757 -0
  184. package/.claude/checkpoints/summary-session-20250906-202622.md +2814 -0
  185. package/.claude/checkpoints/summary-session-20250906-203037.md +2826 -0
  186. package/.claude/checkpoints/task-1756227619.json +1 -0
  187. package/.claude/checkpoints/task-1756230633.json +1 -0
  188. package/.claude/checkpoints/task-1756230902.json +1 -0
  189. package/.claude/checkpoints/task-1756230993.json +1 -0
  190. package/.claude/checkpoints/task-1756231253.json +1 -0
  191. package/.claude/checkpoints/task-1756232070.json +1 -0
  192. package/.claude/checkpoints/task-1756232144.json +1 -0
  193. package/.claude/checkpoints/task-1756232251.json +1 -0
  194. package/.claude/checkpoints/task-1756232564.json +1 -0
  195. package/.claude/checkpoints/task-1756232982.json +1 -0
  196. package/.claude/checkpoints/task-1756233131.json +1 -0
  197. package/.claude/checkpoints/task-1756474562.json +1 -0
  198. package/.claude/checkpoints/task-1756474754.json +1 -0
  199. package/.claude/checkpoints/task-1756474922.json +1 -0
  200. package/.claude/checkpoints/task-1756475028.json +1 -0
  201. package/.claude/checkpoints/task-1756475307.json +1 -0
  202. package/.claude/checkpoints/task-1756475349.json +1 -0
  203. package/.claude/checkpoints/task-1756475699.json +1 -0
  204. package/.claude/checkpoints/task-1756475719.json +1 -0
  205. package/.claude/checkpoints/task-1756475828.json +1 -0
  206. package/.claude/checkpoints/task-1756475858.json +1 -0
  207. package/.claude/checkpoints/task-1756475868.json +1 -0
  208. package/.claude/checkpoints/task-1756476373.json +1 -0
  209. package/.claude/checkpoints/task-1756839595.json +1 -0
  210. package/.claude/checkpoints/task-1756997821.json +1 -0
  211. package/.claude/checkpoints/task-1757189936.json +1 -0
  212. package/.claude/checkpoints/task-1757190154.json +1 -0
  213. package/.claude/checkpoints/task-1757190301.json +1 -0
  214. package/.claude/checkpoints/task-1757190369.json +1 -0
  215. package/.claude/checkpoints/task-1757190483.json +1 -0
  216. package/.claude/checkpoints/task-1757190841.json +1 -0
  217. package/.claude/checkpoints/task-1757191219.json +1 -0
  218. package/.claude/checkpoints/task-1757192639.json +1 -0
  219. package/.claude/checkpoints/task-1757194091.json +1 -0
  220. package/.claude/checkpoints/task-1757194691.json +1 -0
  221. package/.claude/checkpoints/task-1757194856.json +1 -0
  222. package/.claude/commands/flow-nexus/app-store.md +124 -0
  223. package/.claude/commands/flow-nexus/challenges.md +120 -0
  224. package/.claude/commands/flow-nexus/login-registration.md +65 -0
  225. package/.claude/commands/flow-nexus/neural-network.md +134 -0
  226. package/.claude/commands/flow-nexus/payments.md +116 -0
  227. package/.claude/commands/flow-nexus/sandbox.md +83 -0
  228. package/.claude/commands/flow-nexus/swarm.md +87 -0
  229. package/.claude/commands/flow-nexus/user-tools.md +152 -0
  230. package/.claude/commands/flow-nexus/workflow.md +115 -0
  231. package/README.md +29 -1
  232. package/bin/claude-flow +1 -1
  233. package/package.json +1 -1
  234. package/src/api/auth-service.ts +644 -0
  235. package/src/api/database-schema.sql +366 -0
  236. package/src/api/database-service.ts +788 -0
  237. package/src/api/swarm-api.ts +741 -0
  238. package/src/cli/commands/index.ts +40 -1
  239. package/src/cli/simple-commands/hive-mind/session-manager.js +12 -0
  240. package/src/cli/simple-commands/init/agent-copier.js +129 -1
  241. package/src/cli/simple-commands/init/index.js +116 -1
  242. package/src/cli/simple-commands/init/templates/claude-md.js +295 -1
  243. package/src/core/version.js +1 -1
  244. package/src/ui/console/index.html +4 -0
  245. package/src/ui/console/js/real-time-dashboard.js +715 -0
  246. package/src/ui/console/js/swarm-integration.js +485 -0
  247. package/src/ui/console/js/swarm-visualizer.js +879 -0
  248. package/src/ui/console/styles/swarm-visualizer.css +487 -0
  249. package/src/cli/simple-commands/init/.claude-flow/metrics/agent-metrics.json +0 -1
  250. package/src/cli/simple-commands/init/.claude-flow/metrics/performance.json +0 -9
  251. package/src/cli/simple-commands/init/.claude-flow/metrics/task-metrics.json +0 -10
  252. package/src/cli/simple-commands/init/.swarm/memory.db +0 -0
@@ -15,6 +15,7 @@ import { SimpleMemoryManager } from './memory.js';
15
15
  import { sparcAction } from './sparc.js';
16
16
  import { createMigrateCommand } from './migrate.js';
17
17
  import { enterpriseCommands } from './enterprise.js';
18
+ import { createFlowNexusClaudeMd } from '../simple-commands/init/templates/claude-md.js';
18
19
 
19
20
  // Import enhanced orchestration commands
20
21
  import { startCommand } from './start.js';
@@ -70,6 +71,11 @@ export function setupCommands(cli: CLI): void {
70
71
  description: 'Create minimal configuration files',
71
72
  type: 'boolean',
72
73
  },
74
+ {
75
+ name: 'flow-nexus',
76
+ description: 'Initialize with Flow Nexus commands, agents, and CLAUDE.md only',
77
+ type: 'boolean',
78
+ },
73
79
  ],
74
80
  action: async (ctx: CommandContext) => {
75
81
  try {
@@ -77,8 +83,33 @@ export function setupCommands(cli: CLI): void {
77
83
 
78
84
  const force = (ctx.flags.force as boolean) || (ctx.flags.f as boolean);
79
85
  const minimal = (ctx.flags.minimal as boolean) || (ctx.flags.m as boolean);
86
+ const flowNexus = ctx.flags['flow-nexus'] as boolean;
87
+
88
+ // Handle Flow Nexus minimal init
89
+ if (flowNexus) {
90
+ success('Initializing Flow Nexus minimal setup...');
91
+
92
+ // Create Flow Nexus CLAUDE.md with integrated section
93
+ const flowNexusClaudeMd = createFlowNexusClaudeMd();
94
+ const { writeFile, mkdir } = await import('fs/promises');
95
+ await writeFile('CLAUDE.md', flowNexusClaudeMd);
96
+ console.log(' āœ“ Created CLAUDE.md with Flow Nexus integration');
97
+
98
+ // Create .claude/commands/flow-nexus directory and copy commands
99
+ await mkdir('.claude/commands/flow-nexus', { recursive: true });
100
+
101
+ // Create .claude/agents/flow-nexus directory and copy agents
102
+ await mkdir('.claude/agents/flow-nexus', { recursive: true });
103
+
104
+ success('Flow Nexus initialization complete!');
105
+ console.log('šŸ“š Created: CLAUDE.md with Flow Nexus documentation');
106
+ console.log('šŸ“ Created: .claude/commands/flow-nexus/ directory structure');
107
+ console.log('šŸ¤– Created: .claude/agents/flow-nexus/ directory structure');
108
+ console.log('šŸ’” Use MCP Flow Nexus tools in Claude Code for full functionality');
109
+ return;
110
+ }
80
111
 
81
- // Check if files already exist
112
+ // Check if files already exist for full init
82
113
  const files = ['CLAUDE.md', 'memory-bank.md', 'coordination.md'];
83
114
  const existingFiles = [];
84
115
 
@@ -2481,6 +2512,7 @@ This is a Claude-Flow AI agent orchestration system.
2481
2512
  `;
2482
2513
  }
2483
2514
 
2515
+
2484
2516
  function createFullClaudeMd(): string {
2485
2517
  return `# Claude Code Configuration
2486
2518
 
@@ -2531,6 +2563,7 @@ This is a Claude-Flow AI agent orchestration system with the following component
2531
2563
  `;
2532
2564
  }
2533
2565
 
2566
+
2534
2567
  function createMinimalMemoryBankMd(): string {
2535
2568
  return `# Memory Bank
2536
2569
 
@@ -2545,6 +2578,7 @@ function createMinimalMemoryBankMd(): string {
2545
2578
  `;
2546
2579
  }
2547
2580
 
2581
+
2548
2582
  function createFullMemoryBankMd(): string {
2549
2583
  return `# Memory Bank Configuration
2550
2584
 
@@ -2607,6 +2641,7 @@ Memory settings are configured in \`claude-flow.config.json\`:
2607
2641
  `;
2608
2642
  }
2609
2643
 
2644
+
2610
2645
  function createMinimalCoordinationMd(): string {
2611
2646
  return `# Agent Coordination
2612
2647
 
@@ -2620,6 +2655,7 @@ function createMinimalCoordinationMd(): string {
2620
2655
  `;
2621
2656
  }
2622
2657
 
2658
+
2623
2659
  function createFullCoordinationMd(): string {
2624
2660
  return `# Agent Coordination System
2625
2661
 
@@ -2712,6 +2748,7 @@ Coordination settings in \`claude-flow.config.json\`:
2712
2748
  `;
2713
2749
  }
2714
2750
 
2751
+
2715
2752
  function createAgentsReadme(): string {
2716
2753
  return `# Agent Memory Storage
2717
2754
 
@@ -2747,6 +2784,7 @@ ${new Date().toISOString()}
2747
2784
  `;
2748
2785
  }
2749
2786
 
2787
+
2750
2788
  function createSessionsReadme(): string {
2751
2789
  return `# Session Memory Storage
2752
2790
 
@@ -2782,3 +2820,4 @@ memory/sessions/
2782
2820
  ${new Date().toISOString()}
2783
2821
  `;
2784
2822
  }
2823
+
@@ -983,6 +983,12 @@ To enable persistence, see: https://github.com/ruvnet/claude-code-flow/docs/wind
983
983
  return true;
984
984
  }
985
985
 
986
+ // Check if database connection is still open before operations
987
+ if (!this.db || !this.db.open) {
988
+ console.warn('Database connection closed, cannot remove child PID during cleanup');
989
+ return false;
990
+ }
991
+
986
992
  const session = this.db.prepare('SELECT child_pids FROM sessions WHERE id = ?').get(sessionId);
987
993
  if (!session) return false;
988
994
 
@@ -1016,6 +1022,12 @@ To enable persistence, see: https://github.com/ruvnet/claude-code-flow/docs/wind
1016
1022
  if (!session || !session.child_pids) return [];
1017
1023
  return sessionSerializer.deserializeLogData(session.child_pids);
1018
1024
  } else {
1025
+ // Check if database connection is still open
1026
+ if (!this.db || !this.db.open) {
1027
+ console.warn('Database connection closed, cannot get child PIDs during cleanup');
1028
+ return [];
1029
+ }
1030
+
1019
1031
  // Use SQLite
1020
1032
  const session = this.db.prepare('SELECT child_pids FROM sessions WHERE id = ?').get(sessionId);
1021
1033
  if (!session || !session.child_pids) return [];
@@ -162,7 +162,10 @@ export async function createAgentDirectories(targetDir, dryRun = false) {
162
162
  '.claude/agents/documentation',
163
163
  '.claude/agents/documentation/api-docs',
164
164
  '.claude/agents/specialized',
165
- '.claude/agents/specialized/mobile'
165
+ '.claude/agents/specialized/mobile',
166
+ '.claude/agents/flow-nexus',
167
+ '.claude/commands',
168
+ '.claude/commands/flow-nexus'
166
169
  ];
167
170
 
168
171
  if (dryRun) {
@@ -180,6 +183,131 @@ export async function createAgentDirectories(targetDir, dryRun = false) {
180
183
  /**
181
184
  * Validate agent system after copying
182
185
  */
186
+ /**
187
+ * Copy all command files from the installed package to project directory
188
+ */
189
+ export async function copyCommandFiles(targetDir, options = {}) {
190
+ const { force = false, dryRun = false } = options;
191
+
192
+ // Path to command files - try multiple locations
193
+ const packageCommandsDir = join(__dirname, '../../../../.claude/commands'); // From npm package
194
+ const localCommandsDir = '/workspaces/claude-code-flow/.claude/commands'; // Local development
195
+ const cwdCommandsDir = join(process.cwd(), '.claude/commands'); // Current working directory
196
+
197
+ let sourceCommandsDir;
198
+
199
+ // Try local development first, then package, then cwd
200
+ try {
201
+ await fs.access(localCommandsDir);
202
+ sourceCommandsDir = localCommandsDir;
203
+ console.log(' šŸ“ Using local development command files');
204
+ } catch {
205
+ try {
206
+ await fs.access(packageCommandsDir);
207
+ sourceCommandsDir = packageCommandsDir;
208
+ console.log(' šŸ“ Using packaged command files');
209
+ } catch {
210
+ try {
211
+ await fs.access(cwdCommandsDir);
212
+ sourceCommandsDir = cwdCommandsDir;
213
+ console.log(' šŸ“ Using current directory command files');
214
+ } catch {
215
+ console.log(' āš ļø No command files found in any location');
216
+ return { success: false, error: 'Command files not found' };
217
+ }
218
+ }
219
+ }
220
+
221
+ const targetCommandsDir = join(targetDir, '.claude/commands');
222
+
223
+ console.log('šŸ“ Copying command system files...');
224
+ console.log(` šŸ“‚ Source: ${sourceCommandsDir}`);
225
+ console.log(` šŸ“‚ Target: ${targetCommandsDir}`);
226
+
227
+ try {
228
+ // Create target directory
229
+ if (!dryRun) {
230
+ await fs.mkdir(targetCommandsDir, { recursive: true });
231
+ }
232
+
233
+ const copiedFiles = [];
234
+ const errors = [];
235
+
236
+ // Recursively copy all command files
237
+ async function copyRecursive(srcDir, destDir) {
238
+ const items = await fs.readdir(srcDir, { withFileTypes: true });
239
+
240
+ for (const item of items) {
241
+ const srcPath = join(srcDir, item.name);
242
+ const destPath = join(destDir, item.name);
243
+
244
+ if (item.isDirectory()) {
245
+ if (!dryRun) {
246
+ await fs.mkdir(destPath, { recursive: true });
247
+ }
248
+ await copyRecursive(srcPath, destPath);
249
+ } else if (item.isFile() && item.name.endsWith('.md')) {
250
+ try {
251
+ // Check if file already exists
252
+ let shouldCopy = force;
253
+ if (!force) {
254
+ try {
255
+ await fs.access(destPath);
256
+ // File exists, skip unless force is true
257
+ continue;
258
+ } catch {
259
+ // File doesn't exist, safe to copy
260
+ shouldCopy = true;
261
+ }
262
+ }
263
+
264
+ if (shouldCopy && !dryRun) {
265
+ const content = await fs.readFile(srcPath, 'utf8');
266
+ await fs.writeFile(destPath, content, 'utf8');
267
+ copiedFiles.push(destPath.replace(targetDir + '/', ''));
268
+ } else if (dryRun) {
269
+ copiedFiles.push(destPath.replace(targetDir + '/', ''));
270
+ }
271
+ } catch (err) {
272
+ errors.push(`Failed to copy ${item.name}: ${err.message}`);
273
+ }
274
+ }
275
+ }
276
+ }
277
+
278
+ await copyRecursive(sourceCommandsDir, targetCommandsDir);
279
+
280
+ if (!dryRun && copiedFiles.length > 0) {
281
+ console.log(` āœ… Copied ${copiedFiles.length} command files`);
282
+ console.log(' šŸ“‹ Command system initialized with comprehensive documentation');
283
+ console.log(' šŸŽÆ Available categories: Analysis, Automation, GitHub, Hooks, Memory, Flow Nexus');
284
+ } else if (dryRun) {
285
+ console.log(` [DRY RUN] Would copy ${copiedFiles.length} command files`);
286
+ }
287
+
288
+ if (errors.length > 0) {
289
+ console.log(' āš ļø Some command files could not be copied:');
290
+ errors.forEach(error => console.log(` - ${error}`));
291
+ }
292
+
293
+ return {
294
+ success: true,
295
+ copiedFiles,
296
+ errors,
297
+ totalCommands: copiedFiles.length
298
+ };
299
+
300
+ } catch (err) {
301
+ console.log(` āŒ Failed to copy command files: ${err.message}`);
302
+ return {
303
+ success: false,
304
+ error: err.message,
305
+ copiedFiles: [],
306
+ errors: [err.message]
307
+ };
308
+ }
309
+ }
310
+
183
311
  export async function validateAgentSystem(targetDir) {
184
312
  const agentsDir = join(targetDir, '.claude/agents');
185
313
 
@@ -41,7 +41,7 @@ import { createOptimizedClaudeSlashCommands } from './claude-commands/optimized-
41
41
  import { promises as fs } from 'fs';
42
42
  import { copyTemplates } from './template-copier.js';
43
43
  import { copyRevisedTemplates, validateTemplatesExist } from './copy-revised-templates.js';
44
- import { copyAgentFiles, createAgentDirectories, validateAgentSystem } from './agent-copier.js';
44
+ import { copyAgentFiles, createAgentDirectories, validateAgentSystem, copyCommandFiles } from './agent-copier.js';
45
45
  import { showInitHelp } from './help.js';
46
46
  import { batchInitCommand, batchInitFromConfig, validateBatchOptions } from './batch-init.js';
47
47
  import { ValidationSystem, runFullValidation } from './validation/index.js';
@@ -110,6 +110,11 @@ async function setupMcpServers(dryRun = false) {
110
110
  command: 'npx ruv-swarm mcp start',
111
111
  description: 'ruv-swarm MCP server for enhanced coordination',
112
112
  },
113
+ {
114
+ name: 'flow-nexus',
115
+ command: 'npx flow-nexus@latest mcp start',
116
+ description: 'Flow Nexus Complete MCP server for advanced AI orchestration',
117
+ },
113
118
  ];
114
119
 
115
120
  for (const server of servers) {
@@ -150,6 +155,11 @@ export async function initCommand(subArgs, flags) {
150
155
  const hasVerificationFlags = subArgs.includes('--verify') || subArgs.includes('--pair') ||
151
156
  flags.verify || flags.pair;
152
157
 
158
+ // Handle Flow Nexus minimal init
159
+ if (flags['flow-nexus']) {
160
+ return await flowNexusMinimalInit(flags, subArgs);
161
+ }
162
+
153
163
  // Default to enhanced Claude Flow v2 init unless other modes are specified
154
164
  // Use --basic flag for old behavior, or verification flags for verification mode
155
165
  if (!flags.basic && !flags.minimal && !flags.sparc && !hasVerificationFlags) {
@@ -529,6 +539,7 @@ export async function initCommand(subArgs, flags) {
529
539
  console.log(' šŸ“‹ Then add MCP servers manually with:');
530
540
  console.log(' claude mcp add claude-flow claude-flow mcp start');
531
541
  console.log(' claude mcp add ruv-swarm npx ruv-swarm mcp start');
542
+ console.log(' claude mcp add flow-nexus npx flow-nexus@latest mcp start');
532
543
  }
533
544
  }
534
545
  } catch (err) {
@@ -1437,6 +1448,7 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
1437
1448
  console.log('\n šŸ“‹ To add MCP servers manually:');
1438
1449
  console.log(' claude mcp add claude-flow npx claude-flow@alpha mcp start');
1439
1450
  console.log(' claude mcp add ruv-swarm npx ruv-swarm@latest mcp start');
1451
+ console.log(' claude mcp add flow-nexus npx flow-nexus@latest mcp start');
1440
1452
  console.log('\n šŸ’” MCP servers are defined in .mcp.json (project scope)');
1441
1453
  }
1442
1454
  } else if (!dryRun && !isClaudeCodeInstalled()) {
@@ -1446,6 +1458,7 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
1446
1458
  console.log('\n šŸ“‹ After installing, add MCP servers:');
1447
1459
  console.log(' claude mcp add claude-flow npx claude-flow@alpha mcp start');
1448
1460
  console.log(' claude mcp add ruv-swarm npx ruv-swarm@latest mcp start');
1461
+ console.log(' claude mcp add flow-nexus npx flow-nexus@latest mcp start');
1449
1462
  console.log('\n šŸ’” MCP servers are defined in .mcp.json (project scope)');
1450
1463
  }
1451
1464
 
@@ -1460,6 +1473,20 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
1460
1473
 
1461
1474
  if (agentResult.success) {
1462
1475
  await validateAgentSystem(workingDir);
1476
+
1477
+ // Copy command files including Flow Nexus commands
1478
+ console.log('\nšŸ“š Setting up command system...');
1479
+ const commandResult = await copyCommandFiles(workingDir, {
1480
+ force: force,
1481
+ dryRun: dryRun
1482
+ });
1483
+
1484
+ if (commandResult.success) {
1485
+ console.log('āœ… āœ“ Command system setup complete with Flow Nexus integration');
1486
+ } else {
1487
+ console.log('āš ļø Command system setup failed:', commandResult.error);
1488
+ }
1489
+
1463
1490
  console.log('āœ… āœ“ Agent system setup complete with 64 specialized agents');
1464
1491
  } else {
1465
1492
  console.log('āš ļø Agent system setup failed:', agentResult.error);
@@ -1531,3 +1558,91 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
1531
1558
  }
1532
1559
  }
1533
1560
  }
1561
+
1562
+ /**
1563
+ * Flow Nexus minimal initialization - only creates Flow Nexus CLAUDE.md, commands, and agents
1564
+ */
1565
+ async function flowNexusMinimalInit(flags, subArgs) {
1566
+ console.log('🌐 Flow Nexus: Initializing minimal setup...');
1567
+
1568
+ try {
1569
+ const force = flags.force || flags.f;
1570
+
1571
+ // Import functions we need
1572
+ const { createFlowNexusClaudeMd } = await import('./templates/claude-md.js');
1573
+ const { promises: fs } = await import('fs');
1574
+
1575
+ // Create Flow Nexus CLAUDE.md
1576
+ console.log('šŸ“ Creating Flow Nexus CLAUDE.md...');
1577
+ const flowNexusClaudeMd = createFlowNexusClaudeMd();
1578
+ await fs.writeFile('CLAUDE.md', flowNexusClaudeMd);
1579
+ console.log(' āœ… Created CLAUDE.md with Flow Nexus integration');
1580
+
1581
+ // Create .claude/commands/flow-nexus directory and copy commands
1582
+ console.log('šŸ“ Setting up Flow Nexus commands...');
1583
+ await fs.mkdir('.claude/commands/flow-nexus', { recursive: true });
1584
+
1585
+ // Copy Flow Nexus command files
1586
+ const sourceCommandsDir = '/workspaces/claude-code-flow/.claude/commands/flow-nexus';
1587
+ try {
1588
+ const commandFiles = await fs.readdir(sourceCommandsDir);
1589
+ let copiedCommands = 0;
1590
+
1591
+ for (const file of commandFiles) {
1592
+ if (file.endsWith('.md')) {
1593
+ const sourcePath = `${sourceCommandsDir}/${file}`;
1594
+ const destPath = `.claude/commands/flow-nexus/${file}`;
1595
+ const content = await fs.readFile(sourcePath, 'utf8');
1596
+ await fs.writeFile(destPath, content);
1597
+ copiedCommands++;
1598
+ }
1599
+ }
1600
+
1601
+ console.log(` āœ… Copied ${copiedCommands} Flow Nexus command files`);
1602
+ } catch (err) {
1603
+ console.log(' āš ļø Could not copy Flow Nexus commands:', err.message);
1604
+ }
1605
+
1606
+ // Create .claude/agents/flow-nexus directory and copy agents
1607
+ console.log('šŸ¤– Setting up Flow Nexus agents...');
1608
+ await fs.mkdir('.claude/agents/flow-nexus', { recursive: true });
1609
+
1610
+ // Copy Flow Nexus agent files
1611
+ const sourceAgentsDir = '/workspaces/claude-code-flow/.claude/agents/flow-nexus';
1612
+ try {
1613
+ const agentFiles = await fs.readdir(sourceAgentsDir);
1614
+ let copiedAgents = 0;
1615
+
1616
+ for (const file of agentFiles) {
1617
+ if (file.endsWith('.md')) {
1618
+ const sourcePath = `${sourceAgentsDir}/${file}`;
1619
+ const destPath = `.claude/agents/flow-nexus/${file}`;
1620
+ const content = await fs.readFile(sourcePath, 'utf8');
1621
+ await fs.writeFile(destPath, content);
1622
+ copiedAgents++;
1623
+ }
1624
+ }
1625
+
1626
+ console.log(` āœ… Copied ${copiedAgents} Flow Nexus agent files`);
1627
+ } catch (err) {
1628
+ console.log(' āš ļø Could not copy Flow Nexus agents:', err.message);
1629
+ }
1630
+
1631
+ console.log('\nšŸŽ‰ Flow Nexus minimal initialization complete!');
1632
+ console.log('šŸ“š Created: CLAUDE.md with Flow Nexus documentation');
1633
+ console.log('šŸ“ Created: .claude/commands/flow-nexus/ directory with command documentation');
1634
+ console.log('šŸ¤– Created: .claude/agents/flow-nexus/ directory with specialized agents');
1635
+ console.log('');
1636
+ console.log('šŸ’” Quick Start:');
1637
+ console.log(' 1. Register: mcp__flow-nexus__user_register({ email, password })');
1638
+ console.log(' 2. Login: mcp__flow-nexus__user_login({ email, password })');
1639
+ console.log(' 3. Deploy: mcp__flow-nexus__swarm_init({ topology: "mesh", maxAgents: 5 })');
1640
+ console.log('');
1641
+ console.log('šŸ”— Use Flow Nexus MCP tools in Claude Code for full functionality');
1642
+
1643
+ } catch (err) {
1644
+ console.log(`āŒ Flow Nexus initialization failed: ${err.message}`);
1645
+ console.log('Stack trace:', err.stack);
1646
+ process.exit(1);
1647
+ }
1648
+ }