claude-flow-novice 2.0.3 → 2.0.4

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 (272) hide show
  1. package/dist/src/cli/commands/guidance.js +487 -668
  2. package/dist/src/cli/commands/index-validate.js +18 -29
  3. package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
  4. package/dist/src/cli/commands/neural-goal-init.js +92 -125
  5. package/dist/src/cli/commands/swarm-exec.js +317 -393
  6. package/dist/src/cli/commands/swarm.js +1 -1
  7. package/dist/src/cli/commands/validate-framework.js +983 -1100
  8. package/dist/src/cli/commands/validate.js +144 -223
  9. package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
  10. package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
  11. package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
  12. package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
  13. package/dist/src/cli/simple-commands/agent.js +157 -193
  14. package/dist/src/cli/simple-commands/analysis.js +336 -446
  15. package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
  16. package/dist/src/cli/simple-commands/automation.js +481 -469
  17. package/dist/src/cli/simple-commands/batch-manager.js +261 -313
  18. package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
  19. package/dist/src/cli/simple-commands/claude-track.js +68 -90
  20. package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
  21. package/dist/src/cli/simple-commands/config.js +245 -290
  22. package/dist/src/cli/simple-commands/coordination.js +182 -234
  23. package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
  24. package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
  25. package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
  26. package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
  27. package/dist/src/cli/simple-commands/github/github-api.js +535 -574
  28. package/dist/src/cli/simple-commands/github/init.js +276 -303
  29. package/dist/src/cli/simple-commands/github.js +222 -247
  30. package/dist/src/cli/simple-commands/goal.js +51 -63
  31. package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
  32. package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
  33. package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
  34. package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
  35. package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
  36. package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
  37. package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
  38. package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
  39. package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
  40. package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
  41. package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
  42. package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
  43. package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
  44. package/dist/src/cli/simple-commands/hive.js +90 -79
  45. package/dist/src/cli/simple-commands/hook-safety.js +431 -521
  46. package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
  47. package/dist/src/cli/simple-commands/hooks.js +1064 -1204
  48. package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
  49. package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
  50. package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
  51. package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
  52. package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
  53. package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
  54. package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
  55. package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
  56. package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
  57. package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
  58. package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
  59. package/dist/src/cli/simple-commands/init/help.js +104 -107
  60. package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
  61. package/dist/src/cli/simple-commands/init/index.js +1510 -1759
  62. package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
  63. package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
  64. package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
  65. package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
  66. package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
  67. package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
  68. package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
  69. package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
  70. package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
  71. package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
  72. package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
  73. package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
  74. package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
  75. package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
  76. package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
  77. package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
  78. package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
  79. package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
  80. package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
  81. package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
  82. package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
  83. package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
  84. package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
  85. package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
  86. package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
  87. package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
  88. package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
  89. package/dist/src/cli/simple-commands/init.js +1 -2
  90. package/dist/src/cli/simple-commands/mcp-health.js +131 -158
  91. package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
  92. package/dist/src/cli/simple-commands/mcp.js +345 -400
  93. package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
  94. package/dist/src/cli/simple-commands/memory.js +247 -311
  95. package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
  96. package/dist/src/cli/simple-commands/monitor.js +294 -363
  97. package/dist/src/cli/simple-commands/neural.js +51 -65
  98. package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
  99. package/dist/src/cli/simple-commands/pair-basic.js +528 -656
  100. package/dist/src/cli/simple-commands/pair-old.js +430 -543
  101. package/dist/src/cli/simple-commands/pair-working.js +615 -751
  102. package/dist/src/cli/simple-commands/pair.js +615 -751
  103. package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
  104. package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
  105. package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
  106. package/dist/src/cli/simple-commands/process-ui.js +230 -254
  107. package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
  108. package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
  109. package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
  110. package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
  111. package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
  112. package/dist/src/cli/simple-commands/sparc/index.js +241 -298
  113. package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
  114. package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
  115. package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
  116. package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
  117. package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
  118. package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
  119. package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
  120. package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
  121. package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
  122. package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
  123. package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
  124. package/dist/src/cli/simple-commands/sparc-modes/index.js +47 -55
  125. package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
  126. package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
  127. package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
  128. package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
  129. package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
  130. package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
  131. package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
  132. package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
  133. package/dist/src/cli/simple-commands/sparc-modes/swarm.js +101 -87
  134. package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
  135. package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
  136. package/dist/src/cli/simple-commands/sparc.js +465 -493
  137. package/dist/src/cli/simple-commands/start-ui.js +108 -132
  138. package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
  139. package/dist/src/cli/simple-commands/start.js +1 -1
  140. package/dist/src/cli/simple-commands/status.js +254 -275
  141. package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
  142. package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
  143. package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
  144. package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
  145. package/dist/src/cli/simple-commands/stream-chain.js +260 -318
  146. package/dist/src/cli/simple-commands/stream-processor.js +290 -315
  147. package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
  148. package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
  149. package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
  150. package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
  151. package/dist/src/cli/simple-commands/swarm.js +887 -1082
  152. package/dist/src/cli/simple-commands/task.js +161 -206
  153. package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
  154. package/dist/src/cli/simple-commands/token-tracker.js +258 -316
  155. package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
  156. package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
  157. package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
  158. package/dist/src/cli/simple-commands/training.js +170 -227
  159. package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
  160. package/dist/src/cli/simple-commands/verification-integration.js +389 -417
  161. package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
  162. package/dist/src/cli/simple-commands/verification.js +493 -513
  163. package/dist/src/cli/simple-commands/web-server.js +766 -836
  164. package/dist/src/cli/simple-commands/webui-validator.js +106 -124
  165. package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
  166. package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
  167. package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
  168. package/dist/src/coordination/iteration-tracker.js +363 -454
  169. package/dist/src/enterprise/analytics-manager.js +1135 -0
  170. package/dist/src/enterprise/audit-manager.js +1115 -0
  171. package/dist/src/enterprise/cloud-manager.js +891 -0
  172. package/dist/src/enterprise/deployment-manager.js +966 -0
  173. package/dist/src/enterprise/index.js +6 -0
  174. package/dist/src/enterprise/project-manager.js +584 -0
  175. package/dist/src/enterprise/security-manager.js +991 -0
  176. package/dist/src/index.js +1 -1
  177. package/dist/src/mcp/DEPRECATED.js +46 -60
  178. package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
  179. package/dist/src/mcp/implementations/agent-tracker.js +114 -128
  180. package/dist/src/mcp/implementations/daa-tools.js +292 -350
  181. package/dist/src/mcp/implementations/workflow-tools.js +329 -361
  182. package/dist/src/mcp/mcp-config-manager.js +1183 -1331
  183. package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
  184. package/dist/src/mcp/mcp-server-novice.js +11 -17
  185. package/dist/src/mcp/mcp-server-sdk.js +11 -17
  186. package/dist/src/mcp/mcp-server.js +1620 -1484
  187. package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
  188. package/dist/src/memory/advanced-serializer.js +609 -589
  189. package/dist/src/memory/enhanced-examples.js +220 -305
  190. package/dist/src/memory/enhanced-memory.js +295 -336
  191. package/dist/src/memory/enhanced-session-serializer.js +408 -492
  192. package/dist/src/memory/fallback-memory-system.js +900 -1021
  193. package/dist/src/memory/fallback-store.js +93 -131
  194. package/dist/src/memory/high-performance-serialization.js +592 -730
  195. package/dist/src/memory/in-memory-store.js +161 -213
  196. package/dist/src/memory/index.js +123 -157
  197. package/dist/src/memory/lock-free-structures.js +578 -764
  198. package/dist/src/memory/memory-mapped-persistence.js +585 -766
  199. package/dist/src/memory/memory-pressure-manager.js +569 -707
  200. package/dist/src/memory/migration.js +358 -445
  201. package/dist/src/memory/shared-memory.js +641 -768
  202. package/dist/src/memory/sqlite-store.js +245 -325
  203. package/dist/src/memory/sqlite-wrapper.js +122 -151
  204. package/dist/src/memory/swarm-memory.js +470 -603
  205. package/dist/src/memory/test-example.js +126 -134
  206. package/dist/src/memory/ultra-fast-memory-store.js +622 -821
  207. package/dist/src/memory/unified-memory-manager.js +356 -437
  208. package/dist/src/migration/index.js +92 -0
  209. package/dist/src/migration/logger.js +121 -0
  210. package/dist/src/migration/migration-analyzer.js +268 -0
  211. package/dist/src/migration/migration-runner.js +522 -0
  212. package/dist/src/migration/migration-validator.js +285 -0
  213. package/dist/src/migration/progress-reporter.js +150 -0
  214. package/dist/src/migration/rollback-manager.js +321 -0
  215. package/dist/src/migration/tests/migration-system.test.js +7 -0
  216. package/dist/src/migration/types.js +3 -0
  217. package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
  218. package/dist/src/swarm/__tests__/integration.test.js +227 -0
  219. package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
  220. package/dist/src/swarm/advanced-orchestrator.js +1095 -0
  221. package/dist/src/swarm/claude-code-interface.js +961 -0
  222. package/dist/src/swarm/claude-flow-executor.js +229 -0
  223. package/dist/src/swarm/consensus-coordinator.js +475 -0
  224. package/dist/src/swarm/coordinator.js +2993 -0
  225. package/dist/src/swarm/direct-executor.js +1180 -0
  226. package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
  227. package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
  228. package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
  229. package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
  230. package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
  231. package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
  232. package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
  233. package/dist/src/swarm/executor-v2.js +322 -0
  234. package/dist/src/swarm/executor.js +815 -0
  235. package/dist/src/swarm/hive-mind-integration.js +703 -0
  236. package/dist/src/swarm/index.js +41 -0
  237. package/dist/src/swarm/json-output-aggregator.js +267 -0
  238. package/dist/src/swarm/large-scale-coordinator.js +542 -0
  239. package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
  240. package/dist/src/swarm/memory.js +1117 -0
  241. package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
  242. package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
  243. package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
  244. package/dist/src/swarm/optimizations/connection-pool.js +244 -0
  245. package/dist/src/swarm/optimizations/index.js +28 -0
  246. package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
  247. package/dist/src/swarm/optimizations/ttl-map.js +234 -0
  248. package/dist/src/swarm/prompt-cli.js +200 -0
  249. package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
  250. package/dist/src/swarm/prompt-copier.js +381 -0
  251. package/dist/src/swarm/prompt-manager.js +295 -0
  252. package/dist/src/swarm/prompt-utils.js +310 -0
  253. package/dist/src/swarm/result-aggregator.js +718 -0
  254. package/dist/src/swarm/sparc-executor.js +1568 -0
  255. package/dist/src/swarm/strategies/auto.js +758 -0
  256. package/dist/src/swarm/strategies/base.js +128 -0
  257. package/dist/src/swarm/strategies/research.js +914 -0
  258. package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
  259. package/dist/src/swarm/types.js +52 -0
  260. package/dist/src/swarm/workers/copy-worker.js +56 -0
  261. package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
  262. package/dist/src/utils/github-cli-safe.js +56 -64
  263. package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
  264. package/dist/src/utils/npx-isolated-cache.js +104 -119
  265. package/dist/src/utils/preference-manager.js +622 -652
  266. package/dist/src/utils/timezone-utils.js +86 -105
  267. package/dist/src/validators/epic-config-schema.js +214 -0
  268. package/dist/src/validators/index.js +10 -0
  269. package/dist/src/validators/swarm-init-validator.js +259 -0
  270. package/dist/src/validators/todowrite-batching-validator.js +215 -0
  271. package/dist/src/validators/todowrite-integration.js +187 -0
  272. package/package.json +2 -2
@@ -1,154 +1,134 @@
1
1
  // batch-init.js - Batch initialization features with parallel processing
2
- import { printSuccess, printError, printWarning, printInfo } from '../../utils.js';
3
- import { promises as fs } from 'fs';
4
- import { cwd, exit, existsSync } from '../../node-compat.js';
5
- import process from 'process';
6
- import {
7
- PerformanceMonitor,
8
- ResourceThresholdMonitor,
9
- BatchOptimizer,
10
- } from './performance-monitor.js';
11
- import { initCommand } from './index.js';
12
- import { createSparcStructureManually } from './sparc-structure.js';
13
- import { createClaudeSlashCommands } from './claude-commands/slash-commands.js';
14
- import {
15
- createSparcClaudeMd,
16
- createFullClaudeMd,
17
- createMinimalClaudeMd,
18
- } from './templates/claude-md.js';
19
- import { createFullMemoryBankMd, createMinimalMemoryBankMd } from './templates/memory-bank-md.js';
20
- import {
21
- createFullCoordinationMd,
22
- createMinimalCoordinationMd,
23
- } from './templates/coordination-md.js';
24
- import { createAgentsReadme, createSessionsReadme } from './templates/readme-files.js';
25
-
2
+ import { printSuccess, printError, printWarning } from "../../utils.js";
3
+ import { promises as fs } from "fs";
4
+ import { cwd } from "../../node-compat.js";
5
+ import process from "process";
6
+ import { PerformanceMonitor, ResourceThresholdMonitor, BatchOptimizer } from "./performance-monitor.js";
7
+ import { createSparcStructureManually } from "./sparc-structure.js";
8
+ import { createClaudeSlashCommands } from "./claude-commands/slash-commands.js";
9
+ import { createSparcClaudeMd, createFullClaudeMd, createMinimalClaudeMd } from "./templates/claude-md.js";
10
+ import { createFullMemoryBankMd, createMinimalMemoryBankMd } from "./templates/memory-bank-md.js";
11
+ import { createFullCoordinationMd, createMinimalCoordinationMd } from "./templates/coordination-md.js";
12
+ import { createAgentsReadme, createSessionsReadme } from "./templates/readme-files.js";
26
13
  // Progress tracking for batch operations
27
- class BatchProgressTracker {
28
- constructor(totalProjects) {
29
- this.totalProjects = totalProjects;
30
- this.completed = 0;
31
- this.failed = 0;
32
- this.inProgress = new Map();
33
- this.startTime = Date.now();
34
- }
35
-
36
- startProject(projectName) {
37
- this.inProgress.set(projectName, Date.now());
38
- this.updateDisplay();
39
- }
40
-
41
- completeProject(projectName, success = true) {
42
- this.inProgress.delete(projectName);
43
- if (success) {
44
- this.completed++;
45
- } else {
46
- this.failed++;
14
+ let BatchProgressTracker = class BatchProgressTracker {
15
+ startProject(projectName) {
16
+ this.inProgress.set(projectName, Date.now());
17
+ this.updateDisplay();
47
18
  }
48
- this.updateDisplay();
49
- }
50
-
51
- updateDisplay() {
52
- const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
53
- const progress = Math.floor(((this.completed + this.failed) / this.totalProjects) * 100);
54
-
55
- console.clear();
56
- console.log('🚀 Batch Initialization Progress');
57
- console.log('================================');
58
- console.log(`Total Projects: ${this.totalProjects}`);
59
- console.log(`Completed: ${this.completed} ✅`);
60
- console.log(`Failed: ${this.failed} ❌`);
61
- console.log(`In Progress: ${this.inProgress.size} 🔄`);
62
- console.log(`Progress: ${progress}% [${this.getProgressBar(progress)}]`);
63
- console.log(`Elapsed Time: ${elapsed}s`);
64
-
65
- if (this.inProgress.size > 0) {
66
- console.log('\nActive Projects:');
67
- for (const [project, startTime] of this.inProgress) {
68
- const projectElapsed = Math.floor((Date.now() - startTime) / 1000);
69
- console.log(` - ${project} (${projectElapsed}s)`);
70
- }
19
+ completeProject(projectName, success = true) {
20
+ this.inProgress.delete(projectName);
21
+ if (success) {
22
+ this.completed++;
23
+ } else {
24
+ this.failed++;
25
+ }
26
+ this.updateDisplay();
71
27
  }
72
- }
73
-
74
- getProgressBar(progress) {
75
- const filled = Math.floor(progress / 5);
76
- const empty = 20 - filled;
77
- return '█'.repeat(filled) + ''.repeat(empty);
78
- }
79
-
80
- getReport() {
81
- const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
82
- return {
83
- total: this.totalProjects,
84
- completed: this.completed,
85
- failed: this.failed,
86
- elapsedTime: elapsed,
87
- successRate:
88
- this.totalProjects > 0 ? ((this.completed / this.totalProjects) * 100).toFixed(1) : 0,
89
- };
90
- }
91
- }
92
-
28
+ updateDisplay() {
29
+ const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
30
+ const progress = Math.floor((this.completed + this.failed) / this.totalProjects * 100);
31
+ console.clear();
32
+ console.log('🚀 Batch Initialization Progress');
33
+ console.log('================================');
34
+ console.log(`Total Projects: ${this.totalProjects}`);
35
+ console.log(`Completed: ${this.completed} ✅`);
36
+ console.log(`Failed: ${this.failed} ❌`);
37
+ console.log(`In Progress: ${this.inProgress.size} 🔄`);
38
+ console.log(`Progress: ${progress}% [${this.getProgressBar(progress)}]`);
39
+ console.log(`Elapsed Time: ${elapsed}s`);
40
+ if (this.inProgress.size > 0) {
41
+ console.log('\nActive Projects:');
42
+ for (const [project, startTime] of this.inProgress){
43
+ const projectElapsed = Math.floor((Date.now() - startTime) / 1000);
44
+ console.log(` - ${project} (${projectElapsed}s)`);
45
+ }
46
+ }
47
+ }
48
+ getProgressBar(progress) {
49
+ const filled = Math.floor(progress / 5);
50
+ const empty = 20 - filled;
51
+ return '█'.repeat(filled) + '░'.repeat(empty);
52
+ }
53
+ getReport() {
54
+ const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
55
+ return {
56
+ total: this.totalProjects,
57
+ completed: this.completed,
58
+ failed: this.failed,
59
+ elapsedTime: elapsed,
60
+ successRate: this.totalProjects > 0 ? (this.completed / this.totalProjects * 100).toFixed(1) : 0
61
+ };
62
+ }
63
+ constructor(totalProjects){
64
+ this.totalProjects = totalProjects;
65
+ this.completed = 0;
66
+ this.failed = 0;
67
+ this.inProgress = new Map();
68
+ this.startTime = Date.now();
69
+ }
70
+ };
93
71
  // Resource management to prevent overload
94
- class ResourceManager {
95
- constructor(maxConcurrency = 5, maxMemoryMB = 1024) {
96
- this.maxConcurrency = maxConcurrency;
97
- this.maxMemoryMB = maxMemoryMB;
98
- this.currentTasks = 0;
99
- this.queue = [];
100
- }
101
-
102
- async acquire() {
103
- while (this.currentTasks >= this.maxConcurrency) {
104
- await new Promise((resolve) => {
105
- this.queue.push(resolve);
106
- });
72
+ let ResourceManager = class ResourceManager {
73
+ async acquire() {
74
+ while(this.currentTasks >= this.maxConcurrency){
75
+ await new Promise((resolve)=>{
76
+ this.queue.push(resolve);
77
+ });
78
+ }
79
+ this.currentTasks++;
107
80
  }
108
- this.currentTasks++;
109
- }
110
-
111
- release() {
112
- this.currentTasks--;
113
- if (this.queue.length > 0) {
114
- const resolve = this.queue.shift();
115
- resolve();
81
+ release() {
82
+ this.currentTasks--;
83
+ if (this.queue.length > 0) {
84
+ const resolve = this.queue.shift();
85
+ resolve();
86
+ }
116
87
  }
117
- }
118
-
119
- async withResource(fn) {
120
- await this.acquire();
121
- try {
122
- return await fn();
123
- } finally {
124
- this.release();
88
+ async withResource(fn) {
89
+ await this.acquire();
90
+ try {
91
+ return await fn();
92
+ } finally{
93
+ this.release();
94
+ }
125
95
  }
126
- }
127
- }
128
-
96
+ constructor(maxConcurrency = 5, maxMemoryMB = 1024){
97
+ this.maxConcurrency = maxConcurrency;
98
+ this.maxMemoryMB = maxMemoryMB;
99
+ this.currentTasks = 0;
100
+ this.queue = [];
101
+ }
102
+ };
129
103
  // Project template definitions
130
104
  const PROJECT_TEMPLATES = {
131
- 'web-api': {
132
- name: 'Web API',
133
- description: 'RESTful API with Express.js',
134
- extraDirs: ['src', 'src/controllers', 'src/models', 'src/routes', 'tests'],
135
- extraFiles: {
136
- 'package.json': {
137
- name: '{{PROJECT_NAME}}',
138
- version: '1.0.0',
139
- type: 'module',
140
- scripts: {
141
- start: 'node src/index.js',
142
- dev: 'nodemon src/index.js',
143
- test: 'jest',
144
- },
145
- dependencies: {
146
- express: '^4.18.0',
147
- cors: '^2.8.5',
148
- dotenv: '^16.0.0',
149
- },
150
- },
151
- 'src/index.js': `import express from 'express';
105
+ 'web-api': {
106
+ name: 'Web API',
107
+ description: 'RESTful API with Express.js',
108
+ extraDirs: [
109
+ 'src',
110
+ 'src/controllers',
111
+ 'src/models',
112
+ 'src/routes',
113
+ 'tests'
114
+ ],
115
+ extraFiles: {
116
+ 'package.json': {
117
+ name: '{{PROJECT_NAME}}',
118
+ version: '1.0.0',
119
+ type: 'module',
120
+ scripts: {
121
+ start: 'node src/index.js',
122
+ dev: 'nodemon src/index.js',
123
+ test: 'jest'
124
+ },
125
+ dependencies: {
126
+ express: '^4.18.0',
127
+ cors: '^2.8.5',
128
+ dotenv: '^16.0.0'
129
+ }
130
+ },
131
+ 'src/index.js': `import express from 'express';
152
132
  import cors from 'cors';
153
133
 
154
134
  const app = express();
@@ -164,51 +144,65 @@ app.get('/', (req, res) => {
164
144
  app.listen(PORT, () => {
165
145
  console.log(\`Server running on port \${PORT}\`);
166
146
  });
167
- `,
147
+ `
148
+ }
168
149
  },
169
- },
170
- 'react-app': {
171
- name: 'React Application',
172
- description: 'Modern React app with TypeScript',
173
- extraDirs: ['src', 'src/components', 'src/hooks', 'src/services', 'public'],
174
- extraFiles: {
175
- 'package.json': {
176
- name: '{{PROJECT_NAME}}',
177
- version: '0.1.0',
178
- private: true,
179
- dependencies: {
180
- react: '^18.2.0',
181
- 'react-dom': '^18.2.0',
182
- 'react-scripts': '5.0.1',
183
- typescript: '^4.9.5',
184
- },
185
- scripts: {
186
- start: 'react-scripts start',
187
- build: 'react-scripts build',
188
- test: 'react-scripts test',
189
- },
190
- },
191
- 'tsconfig.json': {
192
- compilerOptions: {
193
- target: 'es5',
194
- lib: ['dom', 'es2015'],
195
- jsx: 'react-jsx',
196
- module: 'esnext',
197
- moduleResolution: 'node',
198
- strict: true,
199
- esModuleInterop: true,
200
- skipLibCheck: true,
201
- forceConsistentCasingInFileNames: true,
202
- },
203
- },
150
+ 'react-app': {
151
+ name: 'React Application',
152
+ description: 'Modern React app with TypeScript',
153
+ extraDirs: [
154
+ 'src',
155
+ 'src/components',
156
+ 'src/hooks',
157
+ 'src/services',
158
+ 'public'
159
+ ],
160
+ extraFiles: {
161
+ 'package.json': {
162
+ name: '{{PROJECT_NAME}}',
163
+ version: '0.1.0',
164
+ private: true,
165
+ dependencies: {
166
+ react: '^18.2.0',
167
+ 'react-dom': '^18.2.0',
168
+ 'react-scripts': '5.0.1',
169
+ typescript: '^4.9.5'
170
+ },
171
+ scripts: {
172
+ start: 'react-scripts start',
173
+ build: 'react-scripts build',
174
+ test: 'react-scripts test'
175
+ }
176
+ },
177
+ 'tsconfig.json': {
178
+ compilerOptions: {
179
+ target: 'es5',
180
+ lib: [
181
+ 'dom',
182
+ 'es2015'
183
+ ],
184
+ jsx: 'react-jsx',
185
+ module: 'esnext',
186
+ moduleResolution: 'node',
187
+ strict: true,
188
+ esModuleInterop: true,
189
+ skipLibCheck: true,
190
+ forceConsistentCasingInFileNames: true
191
+ }
192
+ }
193
+ }
204
194
  },
205
- },
206
- microservice: {
207
- name: 'Microservice',
208
- description: 'Containerized microservice with Docker',
209
- extraDirs: ['src', 'config', 'tests', 'scripts'],
210
- extraFiles: {
211
- Dockerfile: `FROM node:18-alpine
195
+ microservice: {
196
+ name: 'Microservice',
197
+ description: 'Containerized microservice with Docker',
198
+ extraDirs: [
199
+ 'src',
200
+ 'config',
201
+ 'tests',
202
+ 'scripts'
203
+ ],
204
+ extraFiles: {
205
+ Dockerfile: `FROM node:18-alpine
212
206
  WORKDIR /app
213
207
  COPY package*.json ./
214
208
  RUN npm ci --only=production
@@ -216,7 +210,7 @@ COPY . .
216
210
  EXPOSE 8080
217
211
  CMD ["node", "src/index.js"]
218
212
  `,
219
- 'docker-compose.yml': `version: '3.8'
213
+ 'docker-compose.yml': `version: '3.8'
220
214
  services:
221
215
  {{PROJECT_NAME}}:
222
216
  build: .
@@ -227,7 +221,7 @@ services:
227
221
  - PORT=8080
228
222
  restart: unless-stopped
229
223
  `,
230
- '.dockerignore': `node_modules
224
+ '.dockerignore': `node_modules
231
225
  npm-debug.log
232
226
  .env
233
227
  .git
@@ -236,27 +230,32 @@ README.md
236
230
  .DS_Store
237
231
  coverage
238
232
  .nyc_output
239
- `,
233
+ `
234
+ }
240
235
  },
241
- },
242
- 'cli-tool': {
243
- name: 'CLI Tool',
244
- description: 'Command-line interface tool',
245
- extraDirs: ['src', 'src/commands', 'src/utils', 'tests'],
246
- extraFiles: {
247
- 'package.json': {
248
- name: '{{PROJECT_NAME}}',
249
- version: '1.0.0',
250
- type: 'module',
251
- bin: {
252
- '{{PROJECT_NAME}}': './src/cli.js',
253
- },
254
- scripts: {
255
- test: 'jest',
256
- lint: 'eslint src/',
257
- },
258
- },
259
- 'src/cli.js': `#!/usr/bin/env node
236
+ 'cli-tool': {
237
+ name: 'CLI Tool',
238
+ description: 'Command-line interface tool',
239
+ extraDirs: [
240
+ 'src',
241
+ 'src/commands',
242
+ 'src/utils',
243
+ 'tests'
244
+ ],
245
+ extraFiles: {
246
+ 'package.json': {
247
+ name: '{{PROJECT_NAME}}',
248
+ version: '1.0.0',
249
+ type: 'module',
250
+ bin: {
251
+ '{{PROJECT_NAME}}': './src/cli.js'
252
+ },
253
+ scripts: {
254
+ test: 'jest',
255
+ lint: 'eslint src/'
256
+ }
257
+ },
258
+ 'src/cli.js': `#!/usr/bin/env node
260
259
  import { Command } from 'commander';
261
260
 
262
261
  const program = new Command();
@@ -275,389 +274,324 @@ program
275
274
  });
276
275
 
277
276
  program.parse();
278
- `,
279
- },
280
- },
277
+ `
278
+ }
279
+ }
281
280
  };
282
-
283
281
  // Environment configurations
284
282
  const ENVIRONMENT_CONFIGS = {
285
- dev: {
286
- name: 'development',
287
- features: ['debug', 'hot-reload', 'verbose-logging'],
288
- config: {
289
- NODE_ENV: 'development',
290
- DEBUG: 'true',
291
- LOG_LEVEL: 'debug',
292
- },
293
- },
294
- staging: {
295
- name: 'staging',
296
- features: ['testing', 'monitoring'],
297
- config: {
298
- NODE_ENV: 'staging',
299
- DEBUG: 'false',
300
- LOG_LEVEL: 'info',
283
+ dev: {
284
+ name: 'development',
285
+ features: [
286
+ 'debug',
287
+ 'hot-reload',
288
+ 'verbose-logging'
289
+ ],
290
+ config: {
291
+ NODE_ENV: 'development',
292
+ DEBUG: 'true',
293
+ LOG_LEVEL: 'debug'
294
+ }
301
295
  },
302
- },
303
- prod: {
304
- name: 'production',
305
- features: ['optimization', 'security', 'monitoring'],
306
- config: {
307
- NODE_ENV: 'production',
308
- DEBUG: 'false',
309
- LOG_LEVEL: 'error',
296
+ staging: {
297
+ name: 'staging',
298
+ features: [
299
+ 'testing',
300
+ 'monitoring'
301
+ ],
302
+ config: {
303
+ NODE_ENV: 'staging',
304
+ DEBUG: 'false',
305
+ LOG_LEVEL: 'info'
306
+ }
310
307
  },
311
- },
308
+ prod: {
309
+ name: 'production',
310
+ features: [
311
+ 'optimization',
312
+ 'security',
313
+ 'monitoring'
314
+ ],
315
+ config: {
316
+ NODE_ENV: 'production',
317
+ DEBUG: 'false',
318
+ LOG_LEVEL: 'error'
319
+ }
320
+ }
312
321
  };
313
-
314
322
  // Initialize a single project with options
315
323
  async function initializeProject(projectPath, options = {}) {
316
- const {
317
- template = null,
318
- environment = 'dev',
319
- sparc = false,
320
- minimal = false,
321
- force = false,
322
- customConfig = {},
323
- } = options;
324
-
325
- try {
326
- // Get absolute project path
327
- const currentDir = cwd();
328
- const absoluteProjectPath = projectPath.startsWith('/')
329
- ? projectPath
330
- : `${currentDir}/${projectPath}`;
331
-
332
- // Create project directory
333
- await fs.mkdir(absoluteProjectPath, { recursive: true });
334
-
335
- // Change to project directory
336
- const originalDir = cwd();
337
- process.chdir(absoluteProjectPath);
338
-
339
- // Initialize base structure
340
- const directories = [
341
- 'memory',
342
- 'memory/agents',
343
- 'memory/sessions',
344
- 'coordination',
345
- 'coordination/memory_bank',
346
- 'coordination/subtasks',
347
- 'coordination/orchestration',
348
- '.claude',
349
- '.claude/commands',
350
- '.claude/commands/sparc',
351
- '.claude/logs',
352
- ];
353
-
354
- // Add template-specific directories
355
- if (template && PROJECT_TEMPLATES[template]) {
356
- const templateConfig = PROJECT_TEMPLATES[template];
357
- if (templateConfig.extraDirs) {
358
- directories.push(...templateConfig.extraDirs);
359
- }
360
- }
361
-
362
- // Create all directories in parallel
363
- await Promise.all(directories.map((dir) => fs.mkdir(dir, { recursive: true }).catch(() => {})));
364
-
365
- // Create configuration files in parallel
366
- const fileCreationTasks = [];
367
-
368
- // CLAUDE.md
369
- const claudeMd = sparc
370
- ? createSparcClaudeMd()
371
- : minimal
372
- ? createMinimalClaudeMd()
373
- : createFullClaudeMd();
374
- fileCreationTasks.push(fs.writeFile('CLAUDE.md', claudeMd));
375
-
376
- // memory-bank.md
377
- const memoryBankMd = minimal ? createMinimalMemoryBankMd() : createFullMemoryBankMd();
378
- fileCreationTasks.push(fs.writeFile('memory-bank.md', memoryBankMd));
379
-
380
- // coordination.md
381
- const coordinationMd = minimal ? createMinimalCoordinationMd() : createFullCoordinationMd();
382
- fileCreationTasks.push(fs.writeFile('coordination.md', coordinationMd));
383
-
384
- // README files
385
- fileCreationTasks.push(
386
- fs.writeFile('memory/agents/README.md', createAgentsReadme()),
387
- fs.writeFile('memory/sessions/README.md', createSessionsReadme()),
388
- );
389
-
390
- // Persistence database
391
- const initialData = {
392
- agents: [],
393
- tasks: [],
394
- environment: environment,
395
- template: template,
396
- customConfig: customConfig,
397
- lastUpdated: Date.now(),
398
- };
399
- fileCreationTasks.push(
400
- fs.writeFile('memory/claude-flow-data.json', JSON.stringify(initialData, null, 2)),
401
- );
402
-
403
- // Environment configuration
404
- if (ENVIRONMENT_CONFIGS[environment]) {
405
- const envConfig = ENVIRONMENT_CONFIGS[environment];
406
- const envContent = Object.entries(envConfig.config)
407
- .map(([key, value]) => `${key}=${value}`)
408
- .join('\n');
409
- fileCreationTasks.push(fs.writeFile('.env', envContent));
410
- }
411
-
412
- // Template-specific files
413
- if (template && PROJECT_TEMPLATES[template]) {
414
- const templateConfig = PROJECT_TEMPLATES[template];
415
- if (templateConfig.extraFiles) {
416
- for (const [filePath, content] of Object.entries(templateConfig.extraFiles)) {
417
- let fileContent =
418
- typeof content === 'object' ? JSON.stringify(content, null, 2) : content;
419
-
420
- // Replace template variables
421
- fileContent = fileContent
422
- .replace(/{{PROJECT_NAME}}/g, projectPath.split('/').pop())
423
- .replace(/{{PROJECT_DESCRIPTION}}/g, templateConfig.description)
424
- .replace(/{{ENVIRONMENT}}/g, environment);
425
-
426
- fileCreationTasks.push(fs.writeFile(filePath, fileContent));
324
+ const { template = null, environment = 'dev', sparc = false, minimal = false, force = false, customConfig = {} } = options;
325
+ try {
326
+ // Get absolute project path
327
+ const currentDir = cwd();
328
+ const absoluteProjectPath = projectPath.startsWith('/') ? projectPath : `${currentDir}/${projectPath}`;
329
+ // Create project directory
330
+ await fs.mkdir(absoluteProjectPath, {
331
+ recursive: true
332
+ });
333
+ // Change to project directory
334
+ const originalDir = cwd();
335
+ process.chdir(absoluteProjectPath);
336
+ // Initialize base structure
337
+ const directories = [
338
+ 'memory',
339
+ 'memory/agents',
340
+ 'memory/sessions',
341
+ 'coordination',
342
+ 'coordination/memory_bank',
343
+ 'coordination/subtasks',
344
+ 'coordination/orchestration',
345
+ '.claude',
346
+ '.claude/commands',
347
+ '.claude/commands/sparc',
348
+ '.claude/logs'
349
+ ];
350
+ // Add template-specific directories
351
+ if (template && PROJECT_TEMPLATES[template]) {
352
+ const templateConfig = PROJECT_TEMPLATES[template];
353
+ if (templateConfig.extraDirs) {
354
+ directories.push(...templateConfig.extraDirs);
355
+ }
427
356
  }
428
- }
429
- }
430
-
431
- // Execute all file creation tasks in parallel
432
- await Promise.all(fileCreationTasks);
433
-
434
- // SPARC initialization if requested
435
- if (sparc) {
436
- await createSparcStructureManually();
437
- await createClaudeSlashCommands(projectPath);
357
+ // Create all directories in parallel
358
+ await Promise.all(directories.map((dir)=>fs.mkdir(dir, {
359
+ recursive: true
360
+ }).catch(()=>{})));
361
+ // Create configuration files in parallel
362
+ const fileCreationTasks = [];
363
+ // CLAUDE.md
364
+ const claudeMd = sparc ? createSparcClaudeMd() : minimal ? createMinimalClaudeMd() : createFullClaudeMd();
365
+ fileCreationTasks.push(fs.writeFile('CLAUDE.md', claudeMd));
366
+ // memory-bank.md
367
+ const memoryBankMd = minimal ? createMinimalMemoryBankMd() : createFullMemoryBankMd();
368
+ fileCreationTasks.push(fs.writeFile('memory-bank.md', memoryBankMd));
369
+ // coordination.md
370
+ const coordinationMd = minimal ? createMinimalCoordinationMd() : createFullCoordinationMd();
371
+ fileCreationTasks.push(fs.writeFile('coordination.md', coordinationMd));
372
+ // README files
373
+ fileCreationTasks.push(fs.writeFile('memory/agents/README.md', createAgentsReadme()), fs.writeFile('memory/sessions/README.md', createSessionsReadme()));
374
+ // Persistence database
375
+ const initialData = {
376
+ agents: [],
377
+ tasks: [],
378
+ environment: environment,
379
+ template: template,
380
+ customConfig: customConfig,
381
+ lastUpdated: Date.now()
382
+ };
383
+ fileCreationTasks.push(fs.writeFile('memory/claude-flow-data.json', JSON.stringify(initialData, null, 2)));
384
+ // Environment configuration
385
+ if (ENVIRONMENT_CONFIGS[environment]) {
386
+ const envConfig = ENVIRONMENT_CONFIGS[environment];
387
+ const envContent = Object.entries(envConfig.config).map(([key, value])=>`${key}=${value}`).join('\n');
388
+ fileCreationTasks.push(fs.writeFile('.env', envContent));
389
+ }
390
+ // Template-specific files
391
+ if (template && PROJECT_TEMPLATES[template]) {
392
+ const templateConfig = PROJECT_TEMPLATES[template];
393
+ if (templateConfig.extraFiles) {
394
+ for (const [filePath, content] of Object.entries(templateConfig.extraFiles)){
395
+ let fileContent = typeof content === 'object' ? JSON.stringify(content, null, 2) : content;
396
+ // Replace template variables
397
+ fileContent = fileContent.replace(/{{PROJECT_NAME}}/g, projectPath.split('/').pop()).replace(/{{PROJECT_DESCRIPTION}}/g, templateConfig.description).replace(/{{ENVIRONMENT}}/g, environment);
398
+ fileCreationTasks.push(fs.writeFile(filePath, fileContent));
399
+ }
400
+ }
401
+ }
402
+ // Execute all file creation tasks in parallel
403
+ await Promise.all(fileCreationTasks);
404
+ // SPARC initialization if requested
405
+ if (sparc) {
406
+ await createSparcStructureManually();
407
+ await createClaudeSlashCommands(projectPath);
408
+ }
409
+ // Change back to original directory
410
+ process.chdir(originalDir);
411
+ return {
412
+ success: true,
413
+ projectPath: absoluteProjectPath
414
+ };
415
+ } catch (error) {
416
+ return {
417
+ success: false,
418
+ projectPath,
419
+ error: error.message
420
+ };
438
421
  }
439
-
440
- // Change back to original directory
441
- process.chdir(originalDir);
442
-
443
- return { success: true, projectPath: absoluteProjectPath };
444
- } catch (error) {
445
- return { success: false, projectPath, error: error.message };
446
- }
447
422
  }
448
-
449
423
  // Batch initialization with parallel processing
450
424
  export async function batchInitCommand(projects, options = {}) {
451
- const {
452
- parallel = true,
453
- maxConcurrency = 5,
454
- template = null,
455
- environments = ['dev'],
456
- sparc = false,
457
- minimal = false,
458
- force = false,
459
- progressTracking = true,
460
- performanceMonitoring = true,
461
- } = options;
462
-
463
- if (!projects || projects.length === 0) {
464
- printError('No projects specified for batch initialization');
465
- return;
466
- }
467
-
468
- const totalProjects = projects.length * environments.length;
469
- const tracker = progressTracking ? new BatchProgressTracker(totalProjects) : null;
470
- const resourceManager = new ResourceManager(parallel ? maxConcurrency : 1);
471
-
472
- // Initialize performance monitoring
473
- const perfMonitor = new PerformanceMonitor({
474
- enabled: performanceMonitoring,
475
- logLevel: 'info',
476
- });
477
-
478
- const resourceMonitor = new ResourceThresholdMonitor({
479
- maxMemoryMB: 2048,
480
- ...ResourceThresholdMonitor.createDefaultCallbacks(),
481
- });
482
-
483
- // Calculate optimal settings
484
- const optimalConcurrency = BatchOptimizer.calculateOptimalConcurrency(totalProjects);
485
- const timeEstimate = BatchOptimizer.estimateCompletionTime(totalProjects, options);
486
- const recommendations = BatchOptimizer.generateRecommendations(totalProjects, options);
487
-
488
- if (maxConcurrency > optimalConcurrency) {
489
- printWarning(`Concurrency ${maxConcurrency} may be too high. Optimal: ${optimalConcurrency}`);
490
- }
491
-
492
- perfMonitor.start();
493
- resourceMonitor.start();
494
-
495
- printSuccess(
496
- `Starting batch initialization for ${projects.length} projects across ${environments.length} environments`,
497
- );
498
- console.log(`Template: ${template || 'default'}`);
499
- console.log(`Parallelism: ${parallel ? `Yes (max ${maxConcurrency} concurrent)` : 'No'}`);
500
- console.log(`SPARC: ${sparc ? 'Enabled' : 'Disabled'}\n`);
501
-
502
- const results = [];
503
- const initTasks = [];
504
-
505
- for (const project of projects) {
506
- for (const env of environments) {
507
- const projectPath = environments.length > 1 ? `${project}-${env}` : project;
508
-
509
- const initTask = async () => {
510
- if (tracker) tracker.startProject(projectPath);
511
- perfMonitor.recordOperation('project-init-start', {
512
- projectPath,
513
- template,
514
- environment: env,
515
- });
516
-
517
- const result = await resourceManager.withResource(async () => {
518
- return await initializeProject(projectPath, {
519
- template,
520
- environment: env,
521
- sparc,
522
- minimal,
523
- force,
524
- });
525
- });
526
-
527
- if (result.success) {
528
- perfMonitor.recordOperation('project-init-success', { projectPath });
529
- } else {
530
- perfMonitor.recordError(result.error, { projectPath, template, environment: env });
425
+ const { parallel = true, maxConcurrency = 5, template = null, environments = [
426
+ 'dev'
427
+ ], sparc = false, minimal = false, force = false, progressTracking = true, performanceMonitoring = true } = options;
428
+ if (!projects || projects.length === 0) {
429
+ printError('No projects specified for batch initialization');
430
+ return;
431
+ }
432
+ const totalProjects = projects.length * environments.length;
433
+ const tracker = progressTracking ? new BatchProgressTracker(totalProjects) : null;
434
+ const resourceManager = new ResourceManager(parallel ? maxConcurrency : 1);
435
+ // Initialize performance monitoring
436
+ const perfMonitor = new PerformanceMonitor({
437
+ enabled: performanceMonitoring,
438
+ logLevel: 'info'
439
+ });
440
+ const resourceMonitor = new ResourceThresholdMonitor({
441
+ maxMemoryMB: 2048,
442
+ ...ResourceThresholdMonitor.createDefaultCallbacks()
443
+ });
444
+ // Calculate optimal settings
445
+ const optimalConcurrency = BatchOptimizer.calculateOptimalConcurrency(totalProjects);
446
+ const timeEstimate = BatchOptimizer.estimateCompletionTime(totalProjects, options);
447
+ const recommendations = BatchOptimizer.generateRecommendations(totalProjects, options);
448
+ if (maxConcurrency > optimalConcurrency) {
449
+ printWarning(`Concurrency ${maxConcurrency} may be too high. Optimal: ${optimalConcurrency}`);
450
+ }
451
+ perfMonitor.start();
452
+ resourceMonitor.start();
453
+ printSuccess(`Starting batch initialization for ${projects.length} projects across ${environments.length} environments`);
454
+ console.log(`Template: ${template || 'default'}`);
455
+ console.log(`Parallelism: ${parallel ? `Yes (max ${maxConcurrency} concurrent)` : 'No'}`);
456
+ console.log(`SPARC: ${sparc ? 'Enabled' : 'Disabled'}\n`);
457
+ const results = [];
458
+ const initTasks = [];
459
+ for (const project of projects){
460
+ for (const env of environments){
461
+ const projectPath = environments.length > 1 ? `${project}-${env}` : project;
462
+ const initTask = async ()=>{
463
+ if (tracker) tracker.startProject(projectPath);
464
+ perfMonitor.recordOperation('project-init-start', {
465
+ projectPath,
466
+ template,
467
+ environment: env
468
+ });
469
+ const result = await resourceManager.withResource(async ()=>{
470
+ return await initializeProject(projectPath, {
471
+ template,
472
+ environment: env,
473
+ sparc,
474
+ minimal,
475
+ force
476
+ });
477
+ });
478
+ if (result.success) {
479
+ perfMonitor.recordOperation('project-init-success', {
480
+ projectPath
481
+ });
482
+ } else {
483
+ perfMonitor.recordError(result.error, {
484
+ projectPath,
485
+ template,
486
+ environment: env
487
+ });
488
+ }
489
+ if (tracker) tracker.completeProject(projectPath, result.success);
490
+ results.push(result);
491
+ };
492
+ if (parallel) {
493
+ initTasks.push(initTask());
494
+ } else {
495
+ await initTask();
496
+ }
531
497
  }
532
-
533
- if (tracker) tracker.completeProject(projectPath, result.success);
534
- results.push(result);
535
- };
536
-
537
- if (parallel) {
538
- initTasks.push(initTask());
539
- } else {
540
- await initTask();
541
- }
542
498
  }
543
- }
544
-
545
- if (parallel) {
546
- await Promise.all(initTasks);
547
- }
548
-
549
- // Final report
550
- console.log('\n\n📊 Batch Initialization Report');
551
- console.log('================================');
552
-
553
- if (tracker) {
554
- const report = tracker.getReport();
555
- console.log(`Total Projects: ${report.total}`);
556
- console.log(`Successful: ${report.completed} ✅`);
557
- console.log(`Failed: ${report.failed} ❌`);
558
- console.log(`Success Rate: ${report.successRate}%`);
559
- console.log(`Total Time: ${report.elapsedTime}s`);
560
- console.log(`Average Time per Project: ${(report.elapsedTime / report.total).toFixed(1)}s`);
561
- }
562
-
563
- // List successful projects
564
- const successful = results.filter((r) => r.success);
565
- if (successful.length > 0) {
566
- console.log('\n✅ Successfully initialized:');
567
- successful.forEach((r) => console.log(` - ${r.projectPath}`));
568
- }
569
-
570
- // List failed projects
571
- const failed = results.filter((r) => !r.success);
572
- if (failed.length > 0) {
573
- console.log('\n❌ Failed to initialize:');
574
- failed.forEach((r) => console.log(` - ${r.projectPath}: ${r.error}`));
575
- }
576
-
577
- // Stop monitoring and generate performance report
578
- perfMonitor.stop();
579
- resourceMonitor.stop();
580
-
581
- if (performanceMonitoring) {
582
- console.log(perfMonitor.generateReport());
583
-
584
- // Show recommendations
585
- if (recommendations.length > 0) {
586
- console.log('\n💡 Recommendations:');
587
- recommendations.forEach((rec) => console.log(` • ${rec}`));
499
+ if (parallel) {
500
+ await Promise.all(initTasks);
588
501
  }
589
- }
590
-
591
- return results;
502
+ // Final report
503
+ console.log('\n\n📊 Batch Initialization Report');
504
+ console.log('================================');
505
+ if (tracker) {
506
+ const report = tracker.getReport();
507
+ console.log(`Total Projects: ${report.total}`);
508
+ console.log(`Successful: ${report.completed} ✅`);
509
+ console.log(`Failed: ${report.failed} ❌`);
510
+ console.log(`Success Rate: ${report.successRate}%`);
511
+ console.log(`Total Time: ${report.elapsedTime}s`);
512
+ console.log(`Average Time per Project: ${(report.elapsedTime / report.total).toFixed(1)}s`);
513
+ }
514
+ // List successful projects
515
+ const successful = results.filter((r)=>r.success);
516
+ if (successful.length > 0) {
517
+ console.log('\n✅ Successfully initialized:');
518
+ successful.forEach((r)=>console.log(` - ${r.projectPath}`));
519
+ }
520
+ // List failed projects
521
+ const failed = results.filter((r)=>!r.success);
522
+ if (failed.length > 0) {
523
+ console.log('\n❌ Failed to initialize:');
524
+ failed.forEach((r)=>console.log(` - ${r.projectPath}: ${r.error}`));
525
+ }
526
+ // Stop monitoring and generate performance report
527
+ perfMonitor.stop();
528
+ resourceMonitor.stop();
529
+ if (performanceMonitoring) {
530
+ console.log(perfMonitor.generateReport());
531
+ // Show recommendations
532
+ if (recommendations.length > 0) {
533
+ console.log('\n💡 Recommendations:');
534
+ recommendations.forEach((rec)=>console.log(` • ${rec}`));
535
+ }
536
+ }
537
+ return results;
592
538
  }
593
-
594
539
  // Parse batch initialization config from file
595
540
  export async function parseBatchConfig(configFile) {
596
- try {
597
- const content = await fs.readFile(configFile, 'utf8');
598
- return JSON.parse(content);
599
- } catch (error) {
600
- printError(`Failed to read batch config file: ${error.message}`);
601
- return null;
602
- }
541
+ try {
542
+ const content = await fs.readFile(configFile, 'utf8');
543
+ return JSON.parse(content);
544
+ } catch (error) {
545
+ printError(`Failed to read batch config file: ${error.message}`);
546
+ return null;
547
+ }
603
548
  }
604
-
605
549
  // Create batch initialization from config file
606
550
  export async function batchInitFromConfig(configFile, options = {}) {
607
- const config = await parseBatchConfig(configFile);
608
- if (!config) return;
609
-
610
- const { projects = [], baseOptions = {}, projectConfigs = {} } = config;
611
-
612
- // Merge options with config
613
- const mergedOptions = { ...baseOptions, ...options };
614
-
615
- // If projectConfigs are specified, use them for individual project customization
616
- if (Object.keys(projectConfigs).length > 0) {
617
- const results = [];
618
- const resourceManager = new ResourceManager(mergedOptions.maxConcurrency || 5);
619
-
620
- for (const [projectName, projectConfig] of Object.entries(projectConfigs)) {
621
- const projectOptions = { ...mergedOptions, ...projectConfig };
622
- const result = await resourceManager.withResource(async () => {
623
- return await initializeProject(projectName, projectOptions);
624
- });
625
- results.push(result);
551
+ const config = await parseBatchConfig(configFile);
552
+ if (!config) return;
553
+ const { projects = [], baseOptions = {}, projectConfigs = {} } = config;
554
+ // Merge options with config
555
+ const mergedOptions = {
556
+ ...baseOptions,
557
+ ...options
558
+ };
559
+ // If projectConfigs are specified, use them for individual project customization
560
+ if (Object.keys(projectConfigs).length > 0) {
561
+ const results = [];
562
+ const resourceManager = new ResourceManager(mergedOptions.maxConcurrency || 5);
563
+ for (const [projectName, projectConfig] of Object.entries(projectConfigs)){
564
+ const projectOptions = {
565
+ ...mergedOptions,
566
+ ...projectConfig
567
+ };
568
+ const result = await resourceManager.withResource(async ()=>{
569
+ return await initializeProject(projectName, projectOptions);
570
+ });
571
+ results.push(result);
572
+ }
573
+ return results;
626
574
  }
627
-
628
- return results;
629
- }
630
-
631
- // Otherwise, use standard batch init
632
- return await batchInitCommand(projects, mergedOptions);
575
+ // Otherwise, use standard batch init
576
+ return await batchInitCommand(projects, mergedOptions);
633
577
  }
634
-
635
578
  // Validation for batch operations
636
579
  export function validateBatchOptions(options) {
637
- const errors = [];
638
-
639
- if (options.maxConcurrency && (options.maxConcurrency < 1 || options.maxConcurrency > 20)) {
640
- errors.push('maxConcurrency must be between 1 and 20');
641
- }
642
-
643
- if (options.template && !PROJECT_TEMPLATES[options.template]) {
644
- errors.push(
645
- `Unknown template: ${options.template}. Available: ${Object.keys(PROJECT_TEMPLATES).join(', ')}`,
646
- );
647
- }
648
-
649
- if (options.environments) {
650
- for (const env of options.environments) {
651
- if (!ENVIRONMENT_CONFIGS[env]) {
652
- errors.push(
653
- `Unknown environment: ${env}. Available: ${Object.keys(ENVIRONMENT_CONFIGS).join(', ')}`,
654
- );
655
- }
580
+ const errors = [];
581
+ if (options.maxConcurrency && (options.maxConcurrency < 1 || options.maxConcurrency > 20)) {
582
+ errors.push('maxConcurrency must be between 1 and 20');
656
583
  }
657
- }
658
-
659
- return errors;
584
+ if (options.template && !PROJECT_TEMPLATES[options.template]) {
585
+ errors.push(`Unknown template: ${options.template}. Available: ${Object.keys(PROJECT_TEMPLATES).join(', ')}`);
586
+ }
587
+ if (options.environments) {
588
+ for (const env of options.environments){
589
+ if (!ENVIRONMENT_CONFIGS[env]) {
590
+ errors.push(`Unknown environment: ${env}. Available: ${Object.keys(ENVIRONMENT_CONFIGS).join(', ')}`);
591
+ }
592
+ }
593
+ }
594
+ return errors;
660
595
  }
661
-
662
596
  // Export template and environment configurations for external use
663
597
  export { PROJECT_TEMPLATES, ENVIRONMENT_CONFIGS };