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,530 +1,502 @@
1
1
  // sparc.js - SPARC development mode commands
2
- import { printSuccess, printError, printWarning } from '../utils.js';
3
- import { promises as fs } from 'fs';
4
- import { spawn } from 'child_process';
5
- import { promisify } from 'util';
6
- import { createSparcPrompt } from './sparc-modes/index.js';
7
- import { cwd, exit, existsSync } from '../node-compat.js';
8
- import process from 'process';
9
-
2
+ import { printSuccess, printError, printWarning } from "../utils.js";
3
+ import { promises as fs } from "fs";
4
+ import { spawn } from "child_process";
5
+ import { createSparcPrompt } from "./sparc-modes/index.js";
6
+ import { cwd } from "../node-compat.js";
7
+ import process from "process";
10
8
  export async function sparcCommand(subArgs, flags) {
11
- const sparcCmd = subArgs[0];
12
-
13
- // Show help if requested or no args
14
- if (
15
- flags.help ||
16
- flags.h ||
17
- sparcCmd === '--help' ||
18
- sparcCmd === '-h' ||
19
- (!sparcCmd && Object.keys(flags).length === 0)
20
- ) {
21
- showSparcHelp();
22
- return;
23
- }
24
-
25
- // Merge flags back into subArgs for backward compatibility
26
- const mergedArgs = [...subArgs];
27
- for (const [key, value] of Object.entries(flags)) {
28
- if (key === 'non-interactive' || key === 'n') {
29
- mergedArgs.push('--non-interactive');
30
- } else if (key === 'dry-run' || key === 'd') {
31
- mergedArgs.push('--dry-run');
32
- } else if (key === 'verbose' || key === 'v') {
33
- mergedArgs.push('--verbose');
34
- } else if (key === 'no-permissions') {
35
- mergedArgs.push('--no-permissions');
36
- } else if (key === 'enable-permissions') {
37
- mergedArgs.push('--enable-permissions');
38
- } else if (key === 'namespace') {
39
- mergedArgs.push('--namespace', value);
40
- } else if (key === 'config') {
41
- mergedArgs.push('--config', value);
42
- } else if (key === 'interactive' || key === 'i') {
43
- mergedArgs.push('--interactive');
9
+ const sparcCmd = subArgs[0];
10
+ // Show help if requested or no args
11
+ if (flags.help || flags.h || sparcCmd === '--help' || sparcCmd === '-h' || !sparcCmd && Object.keys(flags).length === 0) {
12
+ showSparcHelp();
13
+ return;
14
+ }
15
+ // Merge flags back into subArgs for backward compatibility
16
+ const mergedArgs = [
17
+ ...subArgs
18
+ ];
19
+ for (const [key, value] of Object.entries(flags)){
20
+ if (key === 'non-interactive' || key === 'n') {
21
+ mergedArgs.push('--non-interactive');
22
+ } else if (key === 'dry-run' || key === 'd') {
23
+ mergedArgs.push('--dry-run');
24
+ } else if (key === 'verbose' || key === 'v') {
25
+ mergedArgs.push('--verbose');
26
+ } else if (key === 'no-permissions') {
27
+ mergedArgs.push('--no-permissions');
28
+ } else if (key === 'enable-permissions') {
29
+ mergedArgs.push('--enable-permissions');
30
+ } else if (key === 'namespace') {
31
+ mergedArgs.push('--namespace', value);
32
+ } else if (key === 'config') {
33
+ mergedArgs.push('--config', value);
34
+ } else if (key === 'interactive' || key === 'i') {
35
+ mergedArgs.push('--interactive');
36
+ }
37
+ }
38
+ // Check if first arg is a known subcommand
39
+ const knownSubcommands = [
40
+ 'modes',
41
+ 'info',
42
+ 'run',
43
+ 'tdd'
44
+ ];
45
+ if (!knownSubcommands.includes(sparcCmd)) {
46
+ // If not a known subcommand, treat it as a task description for sparc orchestrator
47
+ // Insert 'run' and 'sparc' to make it: ['run', 'sparc', ...rest of args]
48
+ mergedArgs.unshift('run', 'sparc');
49
+ }
50
+ // Now process the command
51
+ const actualCmd = mergedArgs[0];
52
+ switch(actualCmd){
53
+ case 'modes':
54
+ await listSparcModes(mergedArgs);
55
+ break;
56
+ case 'info':
57
+ await showModeInfo(mergedArgs);
58
+ break;
59
+ case 'run':
60
+ await runSparcMode(mergedArgs, flags);
61
+ break;
62
+ case 'tdd':
63
+ await runTddWorkflow(mergedArgs);
64
+ break;
65
+ default:
66
+ showSparcHelp();
44
67
  }
45
- }
46
-
47
- // Check if first arg is a known subcommand
48
- const knownSubcommands = ['modes', 'info', 'run', 'tdd'];
49
-
50
- if (!knownSubcommands.includes(sparcCmd)) {
51
- // If not a known subcommand, treat it as a task description for sparc orchestrator
52
- // Insert 'run' and 'sparc' to make it: ['run', 'sparc', ...rest of args]
53
- mergedArgs.unshift('run', 'sparc');
54
- }
55
-
56
- // Now process the command
57
- const actualCmd = mergedArgs[0];
58
-
59
- switch (actualCmd) {
60
- case 'modes':
61
- await listSparcModes(mergedArgs);
62
- break;
63
-
64
- case 'info':
65
- await showModeInfo(mergedArgs);
66
- break;
67
-
68
- case 'run':
69
- await runSparcMode(mergedArgs, flags);
70
- break;
71
-
72
- case 'tdd':
73
- await runTddWorkflow(mergedArgs);
74
- break;
75
-
76
- default:
77
- showSparcHelp();
78
- }
79
68
  }
80
-
81
69
  async function listSparcModes(subArgs) {
82
- try {
83
- // Get the actual working directory where the command was run from
84
- const workingDir = process.env.PWD || cwd();
85
- const configPath = `${workingDir}/.roomodes`;
86
- let configContent;
87
70
  try {
88
- configContent = await fs.readFile(configPath, 'utf8');
89
- } catch (error) {
90
- printError('SPARC configuration file (.roomodes) not found');
91
- console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
92
- console.log();
93
- console.log('To enable SPARC development modes, run:');
94
- console.log(' npx claude-flow@latest init --sparc');
95
- console.log();
96
- console.log('This will create:');
97
- console.log(' • .roomodes file with 17+ SPARC development modes');
98
- console.log(' .roo/ directory with templates and workflows');
99
- console.log(' SPARC-enhanced CLAUDE.md configuration');
100
- return;
101
- }
102
-
103
- const config = JSON.parse(configContent);
104
- const verbose = subArgs.includes('--verbose') || subArgs.includes('-v');
105
-
106
- printSuccess('Available SPARC Modes:');
107
- console.log();
108
-
109
- for (const mode of config.customModes) {
110
- console.log(`• ${mode.name} (${mode.slug})`);
111
- if (verbose) {
112
- console.log(` ${mode.roleDefinition}`);
113
- console.log(` Tools: ${mode.groups.join(', ')}`);
71
+ // Get the actual working directory where the command was run from
72
+ const workingDir = process.env.PWD || cwd();
73
+ const configPath = `${workingDir}/.roomodes`;
74
+ let configContent;
75
+ try {
76
+ configContent = await fs.readFile(configPath, 'utf8');
77
+ } catch (error) {
78
+ printError('SPARC configuration file (.roomodes) not found');
79
+ console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
80
+ console.log();
81
+ console.log('To enable SPARC development modes, run:');
82
+ console.log(' npx claude-flow@latest init --sparc');
83
+ console.log();
84
+ console.log('This will create:');
85
+ console.log(' • .roomodes file with 17+ SPARC development modes');
86
+ console.log(' • .roo/ directory with templates and workflows');
87
+ console.log(' SPARC-enhanced CLAUDE.md configuration');
88
+ return;
89
+ }
90
+ const config = JSON.parse(configContent);
91
+ const verbose = subArgs.includes('--verbose') || subArgs.includes('-v');
92
+ printSuccess('Available SPARC Modes:');
114
93
  console.log();
115
- }
116
- }
117
-
118
- if (!verbose) {
119
- console.log();
120
- console.log('Use --verbose for detailed descriptions');
94
+ for (const mode of config.customModes){
95
+ console.log(`• ${mode.name} (${mode.slug})`);
96
+ if (verbose) {
97
+ console.log(` ${mode.roleDefinition}`);
98
+ console.log(` Tools: ${mode.groups.join(', ')}`);
99
+ console.log();
100
+ }
101
+ }
102
+ if (!verbose) {
103
+ console.log();
104
+ console.log('Use --verbose for detailed descriptions');
105
+ }
106
+ } catch (err) {
107
+ printError(`Failed to list SPARC modes: ${err.message}`);
121
108
  }
122
- } catch (err) {
123
- printError(`Failed to list SPARC modes: ${err.message}`);
124
- }
125
109
  }
126
-
127
110
  async function showModeInfo(subArgs) {
128
- const modeSlug = subArgs[1];
129
- if (!modeSlug) {
130
- printError('Usage: sparc info <mode-slug>');
131
- return;
132
- }
133
-
134
- try {
135
- // Get the actual working directory where the command was run from
136
- const workingDir = process.env.PWD || cwd();
137
- const configPath = `${workingDir}/.roomodes`;
138
- let configContent;
139
- try {
140
- configContent = await fs.readFile(configPath, 'utf8');
141
- } catch (error) {
142
- printError('SPARC configuration file (.roomodes) not found');
143
- console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
144
- console.log();
145
- console.log('To enable SPARC development modes, run:');
146
- console.log(' npx claude-flow@latest init --sparc');
147
- return;
111
+ const modeSlug = subArgs[1];
112
+ if (!modeSlug) {
113
+ printError('Usage: sparc info <mode-slug>');
114
+ return;
148
115
  }
149
- const config = JSON.parse(configContent);
150
- const mode = config.customModes.find((m) => m.slug === modeSlug);
151
-
152
- if (!mode) {
153
- printError(`Mode not found: ${modeSlug}`);
154
- console.log('Available modes:');
155
- for (const m of config.customModes) {
156
- console.log(` ${m.slug} - ${m.name}`);
157
- }
158
- return;
116
+ try {
117
+ // Get the actual working directory where the command was run from
118
+ const workingDir = process.env.PWD || cwd();
119
+ const configPath = `${workingDir}/.roomodes`;
120
+ let configContent;
121
+ try {
122
+ configContent = await fs.readFile(configPath, 'utf8');
123
+ } catch (error) {
124
+ printError('SPARC configuration file (.roomodes) not found');
125
+ console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
126
+ console.log();
127
+ console.log('To enable SPARC development modes, run:');
128
+ console.log(' npx claude-flow@latest init --sparc');
129
+ return;
130
+ }
131
+ const config = JSON.parse(configContent);
132
+ const mode = config.customModes.find((m)=>m.slug === modeSlug);
133
+ if (!mode) {
134
+ printError(`Mode not found: ${modeSlug}`);
135
+ console.log('Available modes:');
136
+ for (const m of config.customModes){
137
+ console.log(` ${m.slug} - ${m.name}`);
138
+ }
139
+ return;
140
+ }
141
+ printSuccess(`SPARC Mode: ${mode.name}`);
142
+ console.log();
143
+ console.log('Role Definition:');
144
+ console.log(mode.roleDefinition);
145
+ console.log();
146
+ console.log('Custom Instructions:');
147
+ console.log(mode.customInstructions);
148
+ console.log();
149
+ console.log('Tool Groups:');
150
+ console.log(mode.groups.join(', '));
151
+ console.log();
152
+ console.log('Source:');
153
+ console.log(mode.source);
154
+ } catch (err) {
155
+ printError(`Failed to show mode info: ${err.message}`);
159
156
  }
160
-
161
- printSuccess(`SPARC Mode: ${mode.name}`);
162
- console.log();
163
- console.log('Role Definition:');
164
- console.log(mode.roleDefinition);
165
- console.log();
166
- console.log('Custom Instructions:');
167
- console.log(mode.customInstructions);
168
- console.log();
169
- console.log('Tool Groups:');
170
- console.log(mode.groups.join(', '));
171
- console.log();
172
- console.log('Source:');
173
- console.log(mode.source);
174
- } catch (err) {
175
- printError(`Failed to show mode info: ${err.message}`);
176
- }
177
157
  }
178
-
179
158
  async function runSparcMode(subArgs, flags) {
180
- const runModeSlug = subArgs[1];
181
- const taskDescription = subArgs
182
- .slice(2)
183
- .filter((arg) => !arg.startsWith('--'))
184
- .join(' ');
185
-
186
- if (!runModeSlug || !taskDescription) {
187
- printError('Usage: sparc run <mode-slug> <task-description>');
188
- return;
189
- }
190
-
191
- try {
192
- // Get the actual working directory where the command was run from
193
- const workingDir = process.env.PWD || cwd();
194
- const configPath = `${workingDir}/.roomodes`;
195
- let configContent;
159
+ const runModeSlug = subArgs[1];
160
+ const taskDescription = subArgs.slice(2).filter((arg)=>!arg.startsWith('--')).join(' ');
161
+ if (!runModeSlug || !taskDescription) {
162
+ printError('Usage: sparc run <mode-slug> <task-description>');
163
+ return;
164
+ }
196
165
  try {
197
- configContent = await fs.readFile(configPath, 'utf8');
198
- } catch (error) {
199
- printError('SPARC configuration file (.roomodes) not found');
200
- console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
201
- console.log();
202
- console.log('To enable SPARC development modes, run:');
203
- console.log(' npx claude-flow@latest init --sparc');
204
- return;
166
+ // Get the actual working directory where the command was run from
167
+ const workingDir = process.env.PWD || cwd();
168
+ const configPath = `${workingDir}/.roomodes`;
169
+ let configContent;
170
+ try {
171
+ configContent = await fs.readFile(configPath, 'utf8');
172
+ } catch (error) {
173
+ printError('SPARC configuration file (.roomodes) not found');
174
+ console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
175
+ console.log();
176
+ console.log('To enable SPARC development modes, run:');
177
+ console.log(' npx claude-flow@latest init --sparc');
178
+ return;
179
+ }
180
+ const config = JSON.parse(configContent);
181
+ const mode = config.customModes.find((m)=>m.slug === runModeSlug);
182
+ if (!mode) {
183
+ printError(`Mode not found: ${runModeSlug}`);
184
+ return;
185
+ }
186
+ // Build enhanced SPARC prompt
187
+ const memoryNamespace = subArgs.includes('--namespace') ? subArgs[subArgs.indexOf('--namespace') + 1] : mode.slug;
188
+ const enhancedTask = createSparcPrompt(mode, taskDescription, memoryNamespace);
189
+ // Build tools based on mode groups
190
+ const tools = buildToolsFromGroups(mode.groups);
191
+ const toolsList = Array.from(tools).join(',');
192
+ const instanceId = `sparc-${runModeSlug}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
193
+ if (subArgs.includes('--dry-run') || subArgs.includes('-d')) {
194
+ printWarning('DRY RUN - SPARC Mode Configuration:');
195
+ console.log(`Mode: ${mode.name} (${mode.slug})`);
196
+ console.log(`Instance ID: ${instanceId}`);
197
+ const enablePermissions = subArgs.includes('--enable-permissions');
198
+ if (!enablePermissions) {
199
+ console.log(`Tools: ALL (via --dangerously-skip-permissions)`);
200
+ console.log(`Permissions: Will be auto-skipped`);
201
+ } else {
202
+ console.log(`Tools: ${toolsList}`);
203
+ console.log(`Permissions: Will prompt for actions`);
204
+ }
205
+ console.log(`Task: ${taskDescription}`);
206
+ console.log();
207
+ console.log('Enhanced prompt preview:');
208
+ console.log(enhancedTask.substring(0, 300) + '...');
209
+ return;
210
+ }
211
+ printSuccess(`Starting SPARC mode: ${mode.name}`);
212
+ console.log(`📝 Instance ID: ${instanceId}`);
213
+ console.log(`🎯 Mode: ${mode.slug}`);
214
+ const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');
215
+ const enablePermissions = subArgs.includes('--enable-permissions');
216
+ if (!enablePermissions) {
217
+ console.log(`🔧 Tools: ALL (including MCP and WebSearch via --dangerously-skip-permissions)`);
218
+ console.log(`⚡ Permissions: Auto-skipped (--dangerously-skip-permissions)`);
219
+ } else {
220
+ console.log(`🔧 Tools: ${toolsList}`);
221
+ console.log(`✅ Permissions: Enabled (will prompt for actions)`);
222
+ }
223
+ console.log(`📋 Task: ${taskDescription}`);
224
+ if (isNonInteractive) {
225
+ console.log(`🚀 Running in non-interactive mode with stream-json output`);
226
+ console.log();
227
+ // Show debug info immediately for non-interactive mode
228
+ console.log('🔍 Debug: Preparing claude command...');
229
+ console.log(`Enhanced prompt length: ${enhancedTask.length} characters`);
230
+ console.log(`First 200 chars of prompt: ${enhancedTask.substring(0, 200)}...`);
231
+ }
232
+ console.log();
233
+ // Execute Claude with SPARC configuration
234
+ await executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs);
235
+ } catch (err) {
236
+ printError(`Failed to run SPARC mode: ${err.message}`);
205
237
  }
206
- const config = JSON.parse(configContent);
207
- const mode = config.customModes.find((m) => m.slug === runModeSlug);
208
-
209
- if (!mode) {
210
- printError(`Mode not found: ${runModeSlug}`);
211
- return;
238
+ }
239
+ async function runTddWorkflow(subArgs) {
240
+ const tddTaskDescription = subArgs.slice(1).join(' ');
241
+ if (!tddTaskDescription) {
242
+ printError('Usage: sparc tdd <task-description>');
243
+ return;
212
244
  }
213
-
214
- // Build enhanced SPARC prompt
215
- const memoryNamespace = subArgs.includes('--namespace')
216
- ? subArgs[subArgs.indexOf('--namespace') + 1]
217
- : mode.slug;
218
-
219
- const enhancedTask = createSparcPrompt(mode, taskDescription, memoryNamespace);
220
-
221
- // Build tools based on mode groups
222
- const tools = buildToolsFromGroups(mode.groups);
223
- const toolsList = Array.from(tools).join(',');
224
- const instanceId = `sparc-${runModeSlug}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
225
-
226
- if (subArgs.includes('--dry-run') || subArgs.includes('-d')) {
227
- printWarning('DRY RUN - SPARC Mode Configuration:');
228
- console.log(`Mode: ${mode.name} (${mode.slug})`);
229
- console.log(`Instance ID: ${instanceId}`);
230
-
231
- const enablePermissions = subArgs.includes('--enable-permissions');
232
- if (!enablePermissions) {
233
- console.log(`Tools: ALL (via --dangerously-skip-permissions)`);
234
- console.log(`Permissions: Will be auto-skipped`);
235
- } else {
236
- console.log(`Tools: ${toolsList}`);
237
- console.log(`Permissions: Will prompt for actions`);
238
- }
239
-
240
- console.log(`Task: ${taskDescription}`);
241
- console.log();
242
- console.log('Enhanced prompt preview:');
243
- console.log(enhancedTask.substring(0, 300) + '...');
244
- return;
245
+ printSuccess('Starting SPARC TDD Workflow');
246
+ console.log('Following Test-Driven Development with SPARC methodology');
247
+ console.log();
248
+ const phases = [
249
+ {
250
+ name: 'Red',
251
+ description: 'Write failing tests',
252
+ mode: 'tdd'
253
+ },
254
+ {
255
+ name: 'Green',
256
+ description: 'Minimal implementation',
257
+ mode: 'code'
258
+ },
259
+ {
260
+ name: 'Refactor',
261
+ description: 'Optimize and clean',
262
+ mode: 'tdd'
263
+ }
264
+ ];
265
+ console.log('TDD Phases:');
266
+ for (const phase of phases){
267
+ console.log(` ${phase.name}: ${phase.description} (${phase.mode} mode)`);
245
268
  }
246
-
247
- printSuccess(`Starting SPARC mode: ${mode.name}`);
248
- console.log(`📝 Instance ID: ${instanceId}`);
249
- console.log(`🎯 Mode: ${mode.slug}`);
250
-
251
- const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');
252
- const enablePermissions = subArgs.includes('--enable-permissions');
253
-
254
- if (!enablePermissions) {
255
- console.log(`🔧 Tools: ALL (including MCP and WebSearch via --dangerously-skip-permissions)`);
256
- console.log(`⚡ Permissions: Auto-skipped (--dangerously-skip-permissions)`);
269
+ console.log();
270
+ if (subArgs.includes('--interactive') || subArgs.includes('-i')) {
271
+ printSuccess('Starting interactive TDD workflow');
272
+ console.log('This would walk through each phase interactively');
273
+ console.log('Run each phase with: sparc run <mode> "Phase: <task>"');
257
274
  } else {
258
- console.log(`🔧 Tools: ${toolsList}`);
259
- console.log(`✅ Permissions: Enabled (will prompt for actions)`);
275
+ printSuccess('Starting full TDD workflow');
276
+ console.log('This would execute all phases automatically');
277
+ console.log('Use --interactive for step-by-step control');
260
278
  }
261
- console.log(`📋 Task: ${taskDescription}`);
262
-
263
- if (isNonInteractive) {
264
- console.log(`🚀 Running in non-interactive mode with stream-json output`);
265
- console.log();
266
-
267
- // Show debug info immediately for non-interactive mode
268
- console.log('🔍 Debug: Preparing claude command...');
269
- console.log(`Enhanced prompt length: ${enhancedTask.length} characters`);
270
- console.log(`First 200 chars of prompt: ${enhancedTask.substring(0, 200)}...`);
271
- }
272
- console.log();
273
-
274
- // Execute Claude with SPARC configuration
275
- await executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs);
276
- } catch (err) {
277
- printError(`Failed to run SPARC mode: ${err.message}`);
278
- }
279
- }
280
-
281
- async function runTddWorkflow(subArgs) {
282
- const tddTaskDescription = subArgs.slice(1).join(' ');
283
-
284
- if (!tddTaskDescription) {
285
- printError('Usage: sparc tdd <task-description>');
286
- return;
287
- }
288
-
289
- printSuccess('Starting SPARC TDD Workflow');
290
- console.log('Following Test-Driven Development with SPARC methodology');
291
- console.log();
292
-
293
- const phases = [
294
- { name: 'Red', description: 'Write failing tests', mode: 'tdd' },
295
- { name: 'Green', description: 'Minimal implementation', mode: 'code' },
296
- { name: 'Refactor', description: 'Optimize and clean', mode: 'tdd' },
297
- ];
298
-
299
- console.log('TDD Phases:');
300
- for (const phase of phases) {
301
- console.log(` ${phase.name}: ${phase.description} (${phase.mode} mode)`);
302
- }
303
- console.log();
304
-
305
- if (subArgs.includes('--interactive') || subArgs.includes('-i')) {
306
- printSuccess('Starting interactive TDD workflow');
307
- console.log('This would walk through each phase interactively');
308
- console.log('Run each phase with: sparc run <mode> "Phase: <task>"');
309
- } else {
310
- printSuccess('Starting full TDD workflow');
311
- console.log('This would execute all phases automatically');
312
- console.log('Use --interactive for step-by-step control');
313
- }
314
279
  }
315
-
316
280
  // Remove the createSparcPrompt function from here as it's now imported from sparc-modes/index.js
317
-
318
281
  function buildToolsFromGroups(groups) {
319
- const toolMappings = {
320
- read: ['View', 'LS', 'GlobTool', 'GrepTool'],
321
- edit: ['Edit', 'Replace', 'MultiEdit', 'Write'],
322
- browser: ['WebFetch'],
323
- mcp: ['mcp_tools'],
324
- command: ['Bash', 'Terminal'],
325
- };
326
-
327
- const tools = new Set(['View', 'Edit', 'Bash']); // Always include basic tools
328
-
329
- for (const group of groups) {
330
- if (Array.isArray(group)) {
331
- const groupName = group[0];
332
- if (toolMappings[groupName]) {
333
- toolMappings[groupName].forEach((tool) => tools.add(tool));
334
- }
335
- } else if (toolMappings[group]) {
336
- toolMappings[group].forEach((tool) => tools.add(tool));
282
+ const toolMappings = {
283
+ read: [
284
+ 'View',
285
+ 'LS',
286
+ 'GlobTool',
287
+ 'GrepTool'
288
+ ],
289
+ edit: [
290
+ 'Edit',
291
+ 'Replace',
292
+ 'MultiEdit',
293
+ 'Write'
294
+ ],
295
+ browser: [
296
+ 'WebFetch'
297
+ ],
298
+ mcp: [
299
+ 'mcp_tools'
300
+ ],
301
+ command: [
302
+ 'Bash',
303
+ 'Terminal'
304
+ ]
305
+ };
306
+ const tools = new Set([
307
+ 'View',
308
+ 'Edit',
309
+ 'Bash'
310
+ ]); // Always include basic tools
311
+ for (const group of groups){
312
+ if (Array.isArray(group)) {
313
+ const groupName = group[0];
314
+ if (toolMappings[groupName]) {
315
+ toolMappings[groupName].forEach((tool)=>tools.add(tool));
316
+ }
317
+ } else if (toolMappings[group]) {
318
+ toolMappings[group].forEach((tool)=>tools.add(tool));
319
+ }
337
320
  }
338
- }
339
-
340
- return tools;
321
+ return tools;
341
322
  }
342
-
343
323
  async function executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs) {
344
- // Check for non-interactive mode
345
- const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');
346
- const enablePermissions = subArgs.includes('--enable-permissions');
347
-
348
- // Build arguments array correctly
349
- const claudeArgs = [];
350
- claudeArgs.push(enhancedTask);
351
-
352
- // Add --dangerously-skip-permissions by default unless --enable-permissions is set
353
- if (!enablePermissions) {
354
- claudeArgs.push('--dangerously-skip-permissions');
355
- }
356
-
357
- if (isNonInteractive) {
358
- // Non-interactive mode: add additional flags
359
- claudeArgs.push('-p'); // Use short form for print
360
- claudeArgs.push('--output-format', 'stream-json');
361
- claudeArgs.push('--verbose');
362
- } else {
363
- // Interactive mode - check for verbose flag
364
- if (subArgs.includes('--verbose') || subArgs.includes('-v')) {
365
- claudeArgs.push('--verbose');
324
+ // Check for non-interactive mode
325
+ const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');
326
+ const enablePermissions = subArgs.includes('--enable-permissions');
327
+ // Build arguments array correctly
328
+ const claudeArgs = [];
329
+ claudeArgs.push(enhancedTask);
330
+ // Add --dangerously-skip-permissions by default unless --enable-permissions is set
331
+ if (!enablePermissions) {
332
+ claudeArgs.push('--dangerously-skip-permissions');
366
333
  }
367
- }
368
-
369
- // When using --dangerously-skip-permissions, we don't need to specify individual tools
370
- // as it enables ALL tools including mcp and websearch
371
- // Only add --allowedTools if permissions are enabled
372
- if (enablePermissions) {
373
- claudeArgs.push('--allowedTools', toolsList);
374
- }
375
-
376
- if (subArgs.includes('--config')) {
377
- const configIndex = subArgs.indexOf('--config');
378
- claudeArgs.push('--mcp-config', subArgs[configIndex + 1]);
379
- }
380
-
381
- // Show debug info for non-interactive mode or when verbose
382
- if (isNonInteractive || subArgs.includes('--verbose') || subArgs.includes('-v')) {
383
- console.log('\n🔍 Debug: Executing claude with:');
384
- console.log('Command: claude');
385
- console.log(
386
- 'Permissions:',
387
- enablePermissions
388
- ? '✅ Enabled (will prompt)'
389
- : '⚡ Skipped (--dangerously-skip-permissions)',
390
- );
391
- console.log(
392
- 'Tools:',
393
- enablePermissions ? `Specified: ${toolsList}` : 'ALL tools enabled (MCP, WebSearch, etc.)',
394
- );
395
- console.log('Mode:', isNonInteractive ? '🤖 Non-interactive' : '💬 Interactive');
396
- console.log('Args array length:', claudeArgs.length);
397
- console.log('First arg (prompt) length:', claudeArgs[0].length, 'characters');
398
-
399
334
  if (isNonInteractive) {
400
- console.log('First 200 chars of prompt:', claudeArgs[0].substring(0, 200) + '...');
401
- console.log('\nAll arguments:');
402
- claudeArgs.forEach((arg, i) => {
403
- if (i === 0) {
404
- console.log(` [0] <SPARC prompt with ${arg.length} characters>`);
405
- } else {
406
- console.log(` [${i}] ${arg}`);
335
+ // Non-interactive mode: add additional flags
336
+ claudeArgs.push('-p'); // Use short form for print
337
+ claudeArgs.push('--output-format', 'stream-json');
338
+ claudeArgs.push('--verbose');
339
+ } else {
340
+ // Interactive mode - check for verbose flag
341
+ if (subArgs.includes('--verbose') || subArgs.includes('-v')) {
342
+ claudeArgs.push('--verbose');
407
343
  }
408
- });
409
- console.log('\nFull command structure:');
410
- console.log('claude "<SPARC prompt>" ' + claudeArgs.slice(1).join(' '));
411
344
  }
412
- console.log();
413
- }
414
-
415
- try {
416
- // Log the actual command being executed
417
- console.log('\n🚀 Executing command:');
418
- console.log(`Command: claude`);
419
- console.log(`Working Directory: ${cwd()}`);
420
- console.log(`Number of args: ${claudeArgs.length}`);
421
-
422
- // Check if claude command exists
345
+ // When using --dangerously-skip-permissions, we don't need to specify individual tools
346
+ // as it enables ALL tools including mcp and websearch
347
+ // Only add --allowedTools if permissions are enabled
348
+ if (enablePermissions) {
349
+ claudeArgs.push('--allowedTools', toolsList);
350
+ }
351
+ if (subArgs.includes('--config')) {
352
+ const configIndex = subArgs.indexOf('--config');
353
+ claudeArgs.push('--mcp-config', subArgs[configIndex + 1]);
354
+ }
355
+ // Show debug info for non-interactive mode or when verbose
356
+ if (isNonInteractive || subArgs.includes('--verbose') || subArgs.includes('-v')) {
357
+ console.log('\n🔍 Debug: Executing claude with:');
358
+ console.log('Command: claude');
359
+ console.log('Permissions:', enablePermissions ? '✅ Enabled (will prompt)' : '⚡ Skipped (--dangerously-skip-permissions)');
360
+ console.log('Tools:', enablePermissions ? `Specified: ${toolsList}` : 'ALL tools enabled (MCP, WebSearch, etc.)');
361
+ console.log('Mode:', isNonInteractive ? '🤖 Non-interactive' : '💬 Interactive');
362
+ console.log('Args array length:', claudeArgs.length);
363
+ console.log('First arg (prompt) length:', claudeArgs[0].length, 'characters');
364
+ if (isNonInteractive) {
365
+ console.log('First 200 chars of prompt:', claudeArgs[0].substring(0, 200) + '...');
366
+ console.log('\nAll arguments:');
367
+ claudeArgs.forEach((arg, i)=>{
368
+ if (i === 0) {
369
+ console.log(` [0] <SPARC prompt with ${arg.length} characters>`);
370
+ } else {
371
+ console.log(` [${i}] ${arg}`);
372
+ }
373
+ });
374
+ console.log('\nFull command structure:');
375
+ console.log('claude "<SPARC prompt>" ' + claudeArgs.slice(1).join(' '));
376
+ }
377
+ console.log();
378
+ }
423
379
  try {
424
- const checkResult = await new Promise((resolve) => {
425
- const child = spawn('which', ['claude'], {
426
- stdio: ['pipe', 'pipe', 'pipe'],
427
- });
428
- let stdout = '';
429
- child.stdout?.on('data', (data) => {
430
- stdout += data;
380
+ // Log the actual command being executed
381
+ console.log('\n🚀 Executing command:');
382
+ console.log(`Command: claude`);
383
+ console.log(`Working Directory: ${cwd()}`);
384
+ console.log(`Number of args: ${claudeArgs.length}`);
385
+ // Check if claude command exists
386
+ try {
387
+ const checkResult = await new Promise((resolve)=>{
388
+ const child = spawn('which', [
389
+ 'claude'
390
+ ], {
391
+ stdio: [
392
+ 'pipe',
393
+ 'pipe',
394
+ 'pipe'
395
+ ]
396
+ });
397
+ let stdout = '';
398
+ child.stdout?.on('data', (data)=>{
399
+ stdout += data;
400
+ });
401
+ child.on('close', (code)=>{
402
+ resolve({
403
+ success: code === 0,
404
+ stdout: Buffer.from(stdout)
405
+ });
406
+ });
407
+ });
408
+ if (!checkResult.success) {
409
+ console.error('❌ Error: claude command not found in PATH');
410
+ console.error('Please ensure claude CLI is installed and in your PATH');
411
+ return;
412
+ }
413
+ const claudePath = new TextDecoder().decode(checkResult.stdout).trim();
414
+ console.log(`Claude path: ${claudePath}`);
415
+ } catch (e) {
416
+ console.warn('⚠️ Could not verify claude command location');
417
+ }
418
+ // Use spawn for claude command
419
+ const env = {
420
+ ...process.env,
421
+ CLAUDE_INSTANCE_ID: instanceId
422
+ };
423
+ console.log('\n📡 Spawning claude process...\n');
424
+ const child = spawn('claude', claudeArgs, {
425
+ cwd: cwd(),
426
+ env: env,
427
+ stdio: 'inherit'
431
428
  });
432
- child.on('close', (code) => {
433
- resolve({ success: code === 0, stdout: Buffer.from(stdout) });
429
+ const status = await new Promise((resolve)=>{
430
+ child.on('close', (code)=>{
431
+ resolve({
432
+ code,
433
+ success: code === 0
434
+ });
435
+ });
434
436
  });
435
- });
436
- if (!checkResult.success) {
437
- console.error('❌ Error: claude command not found in PATH');
438
- console.error('Please ensure claude CLI is installed and in your PATH');
439
- return;
440
- }
441
- const claudePath = new TextDecoder().decode(checkResult.stdout).trim();
442
- console.log(`Claude path: ${claudePath}`);
443
- } catch (e) {
444
- console.warn('⚠️ Could not verify claude command location');
445
- }
446
-
447
- // Use spawn for claude command
448
- const env = { ...process.env, CLAUDE_INSTANCE_ID: instanceId };
449
-
450
- console.log('\n📡 Spawning claude process...\n');
451
- const child = spawn('claude', claudeArgs, {
452
- cwd: cwd(),
453
- env: env,
454
- stdio: 'inherit',
455
- });
456
- const status = await new Promise((resolve) => {
457
- child.on('close', (code) => {
458
- resolve({ code, success: code === 0 });
459
- });
460
- });
461
-
462
- if (status.success) {
463
- printSuccess(`SPARC instance ${instanceId} completed successfully`);
464
- } else {
465
- printError(`SPARC instance ${instanceId} exited with code ${status.code}`);
437
+ if (status.success) {
438
+ printSuccess(`SPARC instance ${instanceId} completed successfully`);
439
+ } else {
440
+ printError(`SPARC instance ${instanceId} exited with code ${status.code}`);
441
+ }
442
+ } catch (err) {
443
+ printError(`Failed to execute Claude: ${err.message}`);
444
+ console.error('Stack trace:', err.stack);
466
445
  }
467
- } catch (err) {
468
- printError(`Failed to execute Claude: ${err.message}`);
469
- console.error('Stack trace:', err.stack);
470
- }
471
446
  }
472
-
473
447
  function showSparcHelp() {
474
- console.log('SPARC commands:');
475
- console.log(' <task> Run SPARC orchestrator (default mode)');
476
- console.log(' modes List available SPARC development modes');
477
- console.log(' info <mode> Show detailed information about a mode');
478
- console.log(' run <mode> <task> Execute a task in specified SPARC mode');
479
- console.log(' tdd <task> Run Test-Driven Development workflow');
480
- console.log();
481
- console.log('Examples:');
482
- console.log(' claude-flow-novice sparc "orchestrate app development" # Uses sparc orchestrator');
483
- console.log(' claude-flow-novice sparc modes --verbose');
484
- console.log(' claude-flow-novice sparc info architect');
485
- console.log(' claude-flow-novice sparc run code "implement user authentication"');
486
- console.log(' claude-flow-novice sparc run code "add login feature" --non-interactive');
487
- console.log(' claude-flow-novice sparc run tdd "create test suite" --namespace tests');
488
- console.log(' claude-flow-novice sparc tdd "payment processing system" --interactive');
489
- console.log();
490
- console.log('Parallel Execution with BatchTool:');
491
- console.log(' # Run multiple SPARC modes concurrently');
492
- console.log(' batchtool run --parallel \\');
493
- console.log(' "npx claude-flow-novice sparc run code \'user service\' --non-interactive" \\');
494
- console.log(' "npx claude-flow-novice sparc run code \'auth service\' --non-interactive" \\');
495
- console.log(' "npx claude-flow-novice sparc run tdd \'test suite\' --non-interactive"');
496
- console.log();
497
- console.log(' # Boomerang orchestration pattern');
498
- console.log(' batchtool orchestrate --boomerang \\');
499
- console.log(
500
- ' --research "npx claude-flow-novice sparc run ask \'requirements\' --non-interactive" \\',
501
- );
502
- console.log(' --design "npx claude-flow-novice sparc run architect \'system\' --non-interactive" \\');
503
- console.log(' --implement "npx claude-flow-novice sparc run code \'features\' --non-interactive" \\');
504
- console.log(' --test "npx claude-flow-novice sparc run tdd \'validation\' --non-interactive"');
505
- console.log();
506
- console.log('Flags:');
507
- console.log(' --dry-run, -d Show configuration without executing');
508
- console.log(' --verbose, -v Show detailed output');
509
- console.log(' --interactive, -i Run TDD workflow interactively');
510
- console.log(' --non-interactive, -n Run in non-interactive mode with stream-json output');
511
- console.log(' --enable-permissions Enable permission prompts (default: skip permissions)');
512
- console.log(' --namespace <ns> Use custom memory namespace (default: mode slug)');
513
- console.log(' --config <path> Use custom MCP configuration file');
514
- console.log();
515
- console.log('Permission Behavior:');
516
- console.log(' By default, SPARC runs with --dangerously-skip-permissions for efficiency');
517
- console.log(' Use --enable-permissions to restore permission prompts if needed');
518
- console.log();
519
- console.log('Non-Interactive Mode:');
520
- console.log(' When using --non-interactive, claude will be executed with:');
521
- console.log(' - --dangerously-skip-permissions (unless --enable-permissions is set)');
522
- console.log(' - -p (print mode for streaming output)');
523
- console.log(' - --output-format stream-json (structured output format)');
524
- console.log(' - --verbose (detailed execution logs)');
525
- console.log();
526
- console.log('Boomerang Pattern:');
527
- console.log(' A cyclical orchestration where outputs from one phase feed into the next:');
528
- console.log(' Research → Design → Implement → Test → Optimize → Loop back');
529
- console.log(' Perfect for iterative development with continuous refinement');
448
+ console.log('SPARC commands:');
449
+ console.log(' <task> Run SPARC orchestrator (default mode)');
450
+ console.log(' modes List available SPARC development modes');
451
+ console.log(' info <mode> Show detailed information about a mode');
452
+ console.log(' run <mode> <task> Execute a task in specified SPARC mode');
453
+ console.log(' tdd <task> Run Test-Driven Development workflow');
454
+ console.log();
455
+ console.log('Examples:');
456
+ console.log(' claude-flow-novice sparc "orchestrate app development" # Uses sparc orchestrator');
457
+ console.log(' claude-flow-novice sparc modes --verbose');
458
+ console.log(' claude-flow-novice sparc info architect');
459
+ console.log(' claude-flow-novice sparc run code "implement user authentication"');
460
+ console.log(' claude-flow-novice sparc run code "add login feature" --non-interactive');
461
+ console.log(' claude-flow-novice sparc run tdd "create test suite" --namespace tests');
462
+ console.log(' claude-flow-novice sparc tdd "payment processing system" --interactive');
463
+ console.log();
464
+ console.log('Parallel Execution with BatchTool:');
465
+ console.log(' # Run multiple SPARC modes concurrently');
466
+ console.log(' batchtool run --parallel \\');
467
+ console.log(' "npx claude-flow-novice sparc run code \'user service\' --non-interactive" \\');
468
+ console.log(' "npx claude-flow-novice sparc run code \'auth service\' --non-interactive" \\');
469
+ console.log(' "npx claude-flow-novice sparc run tdd \'test suite\' --non-interactive"');
470
+ console.log();
471
+ console.log(' # Boomerang orchestration pattern');
472
+ console.log(' batchtool orchestrate --boomerang \\');
473
+ console.log(' --research "npx claude-flow-novice sparc run ask \'requirements\' --non-interactive" \\');
474
+ console.log(' --design "npx claude-flow-novice sparc run architect \'system\' --non-interactive" \\');
475
+ console.log(' --implement "npx claude-flow-novice sparc run code \'features\' --non-interactive" \\');
476
+ console.log(' --test "npx claude-flow-novice sparc run tdd \'validation\' --non-interactive"');
477
+ console.log();
478
+ console.log('Flags:');
479
+ console.log(' --dry-run, -d Show configuration without executing');
480
+ console.log(' --verbose, -v Show detailed output');
481
+ console.log(' --interactive, -i Run TDD workflow interactively');
482
+ console.log(' --non-interactive, -n Run in non-interactive mode with stream-json output');
483
+ console.log(' --enable-permissions Enable permission prompts (default: skip permissions)');
484
+ console.log(' --namespace <ns> Use custom memory namespace (default: mode slug)');
485
+ console.log(' --config <path> Use custom MCP configuration file');
486
+ console.log();
487
+ console.log('Permission Behavior:');
488
+ console.log(' By default, SPARC runs with --dangerously-skip-permissions for efficiency');
489
+ console.log(' Use --enable-permissions to restore permission prompts if needed');
490
+ console.log();
491
+ console.log('Non-Interactive Mode:');
492
+ console.log(' When using --non-interactive, claude will be executed with:');
493
+ console.log(' - --dangerously-skip-permissions (unless --enable-permissions is set)');
494
+ console.log(' - -p (print mode for streaming output)');
495
+ console.log(' - --output-format stream-json (structured output format)');
496
+ console.log(' - --verbose (detailed execution logs)');
497
+ console.log();
498
+ console.log('Boomerang Pattern:');
499
+ console.log(' A cyclical orchestration where outputs from one phase feed into the next:');
500
+ console.log(' Research → Design → Implement → Test → Optimize → Loop back');
501
+ console.log(' Perfect for iterative development with continuous refinement');
530
502
  }