claude-flow-novice 2.0.4 → 2.0.5
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.
- package/dist/src/cli/commands/guidance.js +668 -487
- package/dist/src/cli/commands/index-validate.js +29 -18
- package/dist/src/cli/commands/mcp-troubleshoot.js +282 -230
- package/dist/src/cli/commands/neural-goal-init.js +125 -92
- package/dist/src/cli/commands/swarm-exec.js +393 -317
- package/dist/src/cli/commands/validate-framework.js +1100 -983
- package/dist/src/cli/commands/validate.js +223 -144
- package/dist/src/cli/main.js +1 -1
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +277 -265
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +7 -6
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +356 -373
- package/dist/src/cli/simple-commands/__tests__/task.test.js +7 -6
- package/dist/src/cli/simple-commands/agent.js +193 -157
- package/dist/src/cli/simple-commands/analysis.js +446 -336
- package/dist/src/cli/simple-commands/automation-executor.js +1339 -1095
- package/dist/src/cli/simple-commands/automation.js +469 -481
- package/dist/src/cli/simple-commands/batch-manager.js +313 -261
- package/dist/src/cli/simple-commands/claude-telemetry.js +267 -241
- package/dist/src/cli/simple-commands/claude-track.js +90 -68
- package/dist/src/cli/simple-commands/concurrent-display.js +320 -266
- package/dist/src/cli/simple-commands/config.js +290 -245
- package/dist/src/cli/simple-commands/coordination.js +234 -182
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +615 -812
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +981 -922
- package/dist/src/cli/simple-commands/fix-hook-variables.js +294 -274
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +457 -378
- package/dist/src/cli/simple-commands/github/github-api.js +574 -535
- package/dist/src/cli/simple-commands/github/init.js +303 -276
- package/dist/src/cli/simple-commands/github.js +247 -222
- package/dist/src/cli/simple-commands/goal.js +63 -51
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +278 -208
- package/dist/src/cli/simple-commands/hive-mind/communication.js +696 -601
- package/dist/src/cli/simple-commands/hive-mind/core.js +979 -907
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +655 -406
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1245 -1125
- package/dist/src/cli/simple-commands/hive-mind/memory.js +1090 -854
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +574 -459
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +347 -263
- package/dist/src/cli/simple-commands/hive-mind/queen.js +768 -727
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +1049 -745
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +283 -227
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +217 -174
- package/dist/src/cli/simple-commands/hive-mind.js +2282 -1841
- package/dist/src/cli/simple-commands/hive.js +79 -90
- package/dist/src/cli/simple-commands/hook-safety.js +521 -431
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +254 -203
- package/dist/src/cli/simple-commands/hooks.js +1204 -1064
- package/dist/src/cli/simple-commands/init/agent-copier.js +319 -294
- package/dist/src/cli/simple-commands/init/batch-init.js +562 -496
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +19 -13
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +19 -13
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +88 -61
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +150 -125
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +49 -42
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +61 -43
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +147 -141
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +44 -31
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +90 -64
- package/dist/src/cli/simple-commands/init/help.js +107 -104
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +528 -509
- package/dist/src/cli/simple-commands/init/index.js +1759 -1510
- package/dist/src/cli/simple-commands/init/performance-monitor.js +317 -234
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +504 -441
- package/dist/src/cli/simple-commands/init/rollback/index.js +364 -289
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +728 -652
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +481 -416
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +448 -369
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +2 -1
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +99 -122
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +37 -32
- package/dist/src/cli/simple-commands/init/sparc-structure.js +62 -55
- package/dist/src/cli/simple-commands/init/template-copier.js +533 -421
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +6 -3
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +318 -344
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +218 -173
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +75 -65
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +6 -3
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +4 -2
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +230 -187
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +80 -53
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +85 -101
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +330 -283
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +561 -495
- package/dist/src/cli/simple-commands/init/validation/index.js +358 -302
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +359 -308
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +366 -389
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +268 -270
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +447 -427
- package/dist/src/cli/simple-commands/init.js +2 -1
- package/dist/src/cli/simple-commands/mcp-health.js +158 -131
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +634 -533
- package/dist/src/cli/simple-commands/mcp.js +400 -345
- package/dist/src/cli/simple-commands/memory-consolidation.js +537 -426
- package/dist/src/cli/simple-commands/memory.js +311 -247
- package/dist/src/cli/simple-commands/migrate-hooks.js +46 -39
- package/dist/src/cli/simple-commands/monitor.js +363 -294
- package/dist/src/cli/simple-commands/neural.js +65 -51
- package/dist/src/cli/simple-commands/pair-autofix-only.js +662 -538
- package/dist/src/cli/simple-commands/pair-basic.js +656 -528
- package/dist/src/cli/simple-commands/pair-old.js +543 -430
- package/dist/src/cli/simple-commands/pair-working.js +751 -615
- package/dist/src/cli/simple-commands/pair.js +751 -615
- package/dist/src/cli/simple-commands/performance-hooks.js +111 -83
- package/dist/src/cli/simple-commands/performance-metrics.js +433 -348
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +787 -708
- package/dist/src/cli/simple-commands/process-ui.js +254 -230
- package/dist/src/cli/simple-commands/realtime-update-system.js +611 -525
- package/dist/src/cli/simple-commands/sparc/architecture.js +1530 -1704
- package/dist/src/cli/simple-commands/sparc/commands.js +516 -438
- package/dist/src/cli/simple-commands/sparc/completion.js +1481 -1224
- package/dist/src/cli/simple-commands/sparc/coordinator.js +978 -913
- package/dist/src/cli/simple-commands/sparc/index.js +298 -241
- package/dist/src/cli/simple-commands/sparc/phase-base.js +390 -314
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +869 -965
- package/dist/src/cli/simple-commands/sparc/refinement.js +1273 -980
- package/dist/src/cli/simple-commands/sparc/specification.js +645 -559
- package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/index.js +55 -47
- package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/swarm.js +87 -101
- package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
- package/dist/src/cli/simple-commands/sparc.js +493 -465
- package/dist/src/cli/simple-commands/start-ui.js +132 -108
- package/dist/src/cli/simple-commands/start-wrapper.js +268 -240
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +275 -254
- package/dist/src/cli/simple-commands/stream-chain-clean.js +171 -128
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +82 -61
- package/dist/src/cli/simple-commands/stream-chain-real.js +331 -267
- package/dist/src/cli/simple-commands/stream-chain-working.js +263 -211
- package/dist/src/cli/simple-commands/stream-chain.js +318 -260
- package/dist/src/cli/simple-commands/stream-processor.js +315 -290
- package/dist/src/cli/simple-commands/swarm-executor.js +222 -189
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +300 -208
- package/dist/src/cli/simple-commands/swarm-ui.js +703 -623
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +286 -258
- package/dist/src/cli/simple-commands/swarm.js +1082 -887
- package/dist/src/cli/simple-commands/task.js +206 -161
- package/dist/src/cli/simple-commands/timestamp-fix.js +89 -59
- package/dist/src/cli/simple-commands/token-tracker.js +316 -258
- package/dist/src/cli/simple-commands/tool-execution-framework.js +519 -433
- package/dist/src/cli/simple-commands/train-and-stream.js +331 -275
- package/dist/src/cli/simple-commands/training-pipeline.js +725 -619
- package/dist/src/cli/simple-commands/training.js +227 -170
- package/dist/src/cli/simple-commands/verification-hooks.js +284 -261
- package/dist/src/cli/simple-commands/verification-integration.js +417 -389
- package/dist/src/cli/simple-commands/verification-training-integration.js +606 -486
- package/dist/src/cli/simple-commands/verification.js +513 -493
- package/dist/src/cli/simple-commands/web-server.js +836 -766
- package/dist/src/cli/simple-commands/webui-validator.js +124 -106
- package/dist/src/coordination/byzantine-memory-channels.js +25 -1
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +251 -212
- package/dist/src/coordination/event-bus/qe-event-bus.js +748 -608
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +454 -379
- package/dist/src/coordination/iteration-tracker.js +454 -363
- package/dist/src/index.js +384 -35
- package/dist/src/mcp/DEPRECATED.js +60 -46
- package/dist/src/mcp/fixes/mcp-error-fixes.js +134 -115
- package/dist/src/mcp/implementations/agent-tracker.js +128 -114
- package/dist/src/mcp/implementations/daa-tools.js +350 -292
- package/dist/src/mcp/implementations/workflow-tools.js +361 -329
- package/dist/src/mcp/mcp-config-manager.js +1331 -1183
- package/dist/src/mcp/mcp-server-novice-simplified.js +17 -11
- package/dist/src/mcp/mcp-server-novice.js +17 -11
- package/dist/src/mcp/mcp-server-sdk.js +17 -11
- package/dist/src/mcp/mcp-server.js +1484 -1620
- package/dist/src/mcp/ruv-swarm-wrapper.js +239 -209
- package/dist/src/memory/advanced-serializer.js +589 -609
- package/dist/src/memory/enhanced-examples.js +305 -220
- package/dist/src/memory/enhanced-memory.js +336 -295
- package/dist/src/memory/enhanced-session-serializer.js +492 -408
- package/dist/src/memory/fallback-memory-system.js +1021 -900
- package/dist/src/memory/fallback-store.js +131 -93
- package/dist/src/memory/high-performance-serialization.js +730 -592
- package/dist/src/memory/in-memory-store.js +213 -161
- package/dist/src/memory/index.js +157 -123
- package/dist/src/memory/lock-free-structures.js +764 -578
- package/dist/src/memory/memory-mapped-persistence.js +766 -585
- package/dist/src/memory/memory-pressure-manager.js +707 -569
- package/dist/src/memory/migration.js +445 -358
- package/dist/src/memory/shared-memory.js +768 -641
- package/dist/src/memory/sqlite-store.js +325 -245
- package/dist/src/memory/sqlite-wrapper.js +151 -122
- package/dist/src/memory/swarm-memory.js +603 -470
- package/dist/src/memory/test-example.js +134 -126
- package/dist/src/memory/ultra-fast-memory-store.js +821 -622
- package/dist/src/memory/unified-memory-manager.js +437 -356
- package/dist/src/swarm/CodeRefactoringSwarm.js +952 -777
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +400 -332
- package/dist/src/utils/error-handler.js +2 -36
- package/dist/src/utils/github-cli-safe.js +64 -56
- package/dist/src/utils/github-cli-safety-wrapper.js +546 -451
- package/dist/src/utils/npx-isolated-cache.js +119 -104
- package/dist/src/utils/preference-manager.js +652 -622
- package/dist/src/utils/timezone-utils.js +105 -86
- package/dist/src/web/api/apm-routes.js +353 -0
- package/dist/src/web/api/config/api-config.js +184 -0
- package/dist/src/web/api/middleware/auth.js +203 -0
- package/dist/src/web/api/middleware/cache.js +273 -0
- package/dist/src/web/api/middleware/error-handler.js +257 -0
- package/dist/src/web/api/middleware/request-logger.js +215 -0
- package/dist/src/web/api/middleware/validation.js +323 -0
- package/dist/src/web/api/routes/events.js +463 -0
- package/dist/src/web/api/routes/hierarchy.js +300 -0
- package/dist/src/web/api/routes/index.js +12 -0
- package/dist/src/web/api/routes/metrics.js +559 -0
- package/dist/src/web/api/routes/parallel-status.js +359 -0
- package/dist/src/web/api/routes/status.js +448 -0
- package/dist/src/web/api/server.js +462 -0
- package/dist/src/web/dashboard/hooks/useWebSocket.js +383 -0
- package/dist/src/web/dashboard/index.js +85 -0
- package/dist/src/web/dashboard/realtime/CustomSyncManager.js +439 -0
- package/dist/src/web/dashboard/realtime/NativeWebSocketManager.js +323 -0
- package/dist/src/web/dashboard/realtime/PerformanceBenchmark.js +527 -0
- package/dist/src/web/dashboard/realtime/RealtimeCommunicationManager.js +474 -0
- package/dist/src/web/dashboard/realtime/RealtimeServer.js +666 -0
- package/dist/src/web/dashboard/realtime/SSEManager.js +426 -0
- package/dist/src/web/dashboard/types.js +4 -0
- package/dist/src/web/messaging/agent-status-tracker.js +453 -0
- package/dist/src/web/messaging/human-intervention-system.js +305 -0
- package/dist/src/web/messaging/message-filter.js +302 -0
- package/dist/src/web/messaging/swarm-message-router.js +324 -0
- package/dist/src/web/messaging/transparency-logger.js +421 -0
- package/dist/src/web/portal-server.js +460 -0
- package/dist/src/web/server.js +322 -0
- package/dist/src/web/websocket/apm-websocket-handler.js +453 -0
- package/dist/src/web/websocket/websocket-manager.js +780 -0
- package/package.json +5 -3
- package/dist/src/cli/minimal-main.js +0 -22
- package/dist/src/enterprise/analytics-manager.js +0 -1135
- package/dist/src/enterprise/audit-manager.js +0 -1115
- package/dist/src/enterprise/cloud-manager.js +0 -891
- package/dist/src/enterprise/deployment-manager.js +0 -966
- package/dist/src/enterprise/index.js +0 -6
- package/dist/src/enterprise/project-manager.js +0 -584
- package/dist/src/enterprise/security-manager.js +0 -991
- package/dist/src/migration/index.js +0 -92
- package/dist/src/migration/logger.js +0 -121
- package/dist/src/migration/migration-analyzer.js +0 -268
- package/dist/src/migration/migration-runner.js +0 -522
- package/dist/src/migration/migration-validator.js +0 -285
- package/dist/src/migration/progress-reporter.js +0 -150
- package/dist/src/migration/rollback-manager.js +0 -321
- package/dist/src/migration/tests/migration-system.test.js +0 -7
- package/dist/src/migration/types.js +0 -3
- package/dist/src/swarm/__tests__/integration.test.js +0 -227
- package/dist/src/swarm/__tests__/prompt-copier.test.js +0 -344
- package/dist/src/swarm/advanced-orchestrator.js +0 -1095
- package/dist/src/swarm/claude-code-interface.js +0 -961
- package/dist/src/swarm/claude-flow-executor.js +0 -229
- package/dist/src/swarm/consensus-coordinator.js +0 -475
- package/dist/src/swarm/coordinator.js +0 -2993
- package/dist/src/swarm/direct-executor.js +0 -1180
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +0 -691
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +0 -998
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +0 -1197
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +0 -772
- package/dist/src/swarm/error-recovery/resilience-architecture.js +0 -714
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +0 -1319
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +0 -808
- package/dist/src/swarm/executor-v2.js +0 -322
- package/dist/src/swarm/executor.js +0 -815
- package/dist/src/swarm/hive-mind-integration.js +0 -703
- package/dist/src/swarm/index.js +0 -41
- package/dist/src/swarm/json-output-aggregator.js +0 -267
- package/dist/src/swarm/large-scale-coordinator.js +0 -542
- package/dist/src/swarm/mcp-integration-wrapper.js +0 -628
- package/dist/src/swarm/memory.js +0 -1117
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +0 -348
- package/dist/src/swarm/optimizations/async-file-manager.js +0 -285
- package/dist/src/swarm/optimizations/circular-buffer.js +0 -162
- package/dist/src/swarm/optimizations/connection-pool.js +0 -244
- package/dist/src/swarm/optimizations/index.js +0 -28
- package/dist/src/swarm/optimizations/optimized-executor.js +0 -320
- package/dist/src/swarm/optimizations/ttl-map.js +0 -234
- package/dist/src/swarm/prompt-cli.js +0 -200
- package/dist/src/swarm/prompt-copier-enhanced.js +0 -202
- package/dist/src/swarm/prompt-copier.js +0 -381
- package/dist/src/swarm/prompt-manager.js +0 -295
- package/dist/src/swarm/prompt-utils.js +0 -310
- package/dist/src/swarm/result-aggregator.js +0 -718
- package/dist/src/swarm/sparc-executor.js +0 -1568
- package/dist/src/swarm/strategies/auto.js +0 -758
- package/dist/src/swarm/strategies/base.js +0 -128
- package/dist/src/swarm/strategies/research.js +0 -914
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +0 -2
- package/dist/src/swarm/types.js +0 -52
- package/dist/src/swarm/workers/copy-worker.js +0 -56
- package/dist/src/validators/epic-config-schema.js +0 -214
- package/dist/src/validators/index.js +0 -10
- package/dist/src/validators/swarm-init-validator.js +0 -259
- package/dist/src/validators/todowrite-batching-validator.js +0 -215
- package/dist/src/validators/todowrite-integration.js +0 -187
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/documentSymbols/browser/documentSymbols.js +0 -23
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js +0 -57
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +0 -401
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/defaultProviders.js +0 -181
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js +0 -44
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js +0 -157
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/edit.js +0 -71
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/editorState/browser/editorState.js +0 -112
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findController.js +0 -990
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findDecorations.js +0 -296
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findModel.js +0 -488
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findOptionsWidget.js +0 -138
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findState.js +0 -243
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findWidget.js +0 -1177
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/folding.js +0 -1093
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingDecorations.js +0 -133
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingModel.js +0 -538
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingRanges.js +0 -351
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/fontZoom/browser/fontZoom.js +0 -49
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/format.js +0 -360
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formatActions.js +0 -263
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formattingEdit.js +0 -54
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/gotoSymbol/browser/link/clickLinkGesture.js +0 -149
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/hover/browser/contentHover.js +0 -874
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commandIds.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commands.js +0 -199
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/linesOperations/browser/copyLinesCommand.js +0 -70
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.js +0 -26
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/editorNavigationQuickAccess.js +0 -153
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/readOnlyMessage/browser/contribution.js +0 -33
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/semanticTokens/browser/documentSemanticTokens.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/smartSelect/browser/bracketSelections.js +0 -146
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/suggest/browser/completionModel.js +0 -224
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/unicodeHighlighter/browser/bannerController.js +0 -119
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/edcore.main.js +0 -14
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.all.js +0 -63
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.api.js +0 -55
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.main.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.worker.js +0 -25
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/standalone/browser/colorizer.js +0 -118
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/css.worker.js +0 -36869
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/cssMode.js +0 -2035
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/browser/accessibilityService.js +0 -88
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/common/accessibility.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/action.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/actionCommonCategories.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionList.js +0 -276
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionWidget.js +0 -248
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/common/actionWidget.js +0 -5
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actions/common/actions.js +0 -409
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/audioCues/browser/audioCueService.js +0 -176
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/browser/clipboardService.js +0 -141
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/common/clipboardService.js +0 -6
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/commands/common/commands.js +0 -80
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configuration.js +0 -86
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationModels.js +0 -554
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationRegistry.js +0 -317
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurations.js +0 -41
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/browser/contextKeyService.js +0 -432
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkey.js +0 -1547
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkeys.js +0 -18
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuHandler.js +0 -124
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuService.js +0 -101
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextView.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextViewService.js +0 -72
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dialogs/common/dialogs.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dnd/browser/dnd.js +0 -36
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/editor/common/editor.js +0 -17
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/environment/common/environment.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/extensions/common/extensions.js +0 -47
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/files/common/files.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +0 -105
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/descriptors.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/extensions.js +0 -15
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/abstractKeybindingService.js +0 -277
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -53
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/browser/defaultStyles.js +0 -162
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/common/colorRegistry.js +0 -482
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/abap/abap.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/apex/apex.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/azcli/azcli.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bat/bat.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bicep/bicep.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cameligo/cameligo.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/clojure/clojure.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/coffee/coffee.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cpp/cpp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csharp/csharp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csp/csp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/css/css.js +0 -12
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cypher/cypher.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dart/dart.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dockerfile/dockerfile.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/ecl/ecl.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/elixir/elixir.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/flow9/flow9.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.js +0 -745
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.de.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.es.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.fr.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.it.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ja.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ko.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ru.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-cn.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-tw.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssMode.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssWorker.js +0 -81
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/cli.js +0 -64
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/example.js +0 -36
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/index.js +0 -205
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/test.js +0 -260
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.browser.js +0 -34
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.js +0 -35
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.native.js +0 -26
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.browser.js +0 -34
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.js +0 -45
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/nanoid.js +0 -1
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/non-secure/index.js +0 -21
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/url-alphabet/index.js +0 -3
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/bin/nodemon.js +0 -16
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/index.js +0 -49
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/parse.js +0 -230
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/command.js +0 -43
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/defaults.js +0 -34
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/exec.js +0 -234
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/index.js +0 -93
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/load.js +0 -225
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/help/index.js +0 -27
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/index.js +0 -1
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/index.js +0 -4
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/match.js +0 -287
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/run.js +0 -562
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/signals.js +0 -34
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/watch.js +0 -244
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/nodemon.js +0 -317
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/add.js +0 -89
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/index.js +0 -53
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/parse.js +0 -43
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/spawn.js +0 -74
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/bus.js +0 -44
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/clone.js +0 -40
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/colour.js +0 -26
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/index.js +0 -103
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/log.js +0 -82
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/merge.js +0 -47
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/version.js +0 -100
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/brace-expansion/index.js +0 -201
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/has-flag/index.js +0 -8
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/minimatch/minimatch.js +0 -947
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/browser.js +0 -5
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/index.js +0 -131
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/bin/pidtree.js +0 -128
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/index.js +0 -49
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/bin.js +0 -61
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/get.js +0 -45
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/pidtree.js +0 -104
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/ps.js +0 -47
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/wmic.js +0 -49
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/doc.js +0 -1270
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/acorn.js +0 -15
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/angular.js +0 -2
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/babel.js +0 -15
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/estree.js +0 -36
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/flow.js +0 -19
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/glimmer.js +0 -29
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/graphql.js +0 -29
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/html.js +0 -22
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/markdown.js +0 -63
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/meriyah.js +0 -4
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/postcss.js +0 -54
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/typescript.js +0 -20
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/yaml.js +0 -160
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/standalone.js +0 -34
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/bin/react-scripts.js +0 -58
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/env.js +0 -112
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/getHttpsConfig.js +0 -74
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/babelTransform.js +0 -37
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/cssTransform.js +0 -22
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/fileTransform.js +0 -40
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/modules.js +0 -142
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/paths.js +0 -153
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack.config.js +0 -796
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpackDevServer.config.js +0 -135
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/build.js +0 -225
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/eject.js +0 -340
|
@@ -1,121 +1,150 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Swarm command wrapper for simple CLI
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { args, mkdirAsync, writeTextFile, exit, cwd } from '../node-compat.js';
|
|
6
|
+
import { spawn, execSync } from 'child_process';
|
|
7
|
+
import { existsSync, chmodSync, statSync } from 'fs';
|
|
8
|
+
import { open } from 'fs/promises';
|
|
9
|
+
import process from 'process';
|
|
10
|
+
import path from 'path';
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* Detects if the environment is headless (non-interactive)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
*/
|
|
15
|
+
function isHeadlessEnvironment() {
|
|
16
|
+
// Check for common CI environment variables
|
|
17
|
+
const ciEnvironments = [
|
|
18
|
+
'CI',
|
|
19
|
+
'GITHUB_ACTIONS',
|
|
20
|
+
'GITLAB_CI',
|
|
21
|
+
'JENKINS_URL',
|
|
22
|
+
'CIRCLECI',
|
|
23
|
+
'TRAVIS',
|
|
24
|
+
'BUILDKITE',
|
|
25
|
+
'DRONE',
|
|
26
|
+
'DOCKER_CONTAINER',
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const isCI = ciEnvironments.some((env) => process.env[env]);
|
|
30
|
+
|
|
31
|
+
// Check if running in Docker
|
|
32
|
+
const isDocker =
|
|
33
|
+
existsSync('/.dockerenv') ||
|
|
34
|
+
(existsSync('/proc/1/cgroup') &&
|
|
35
|
+
require('fs').readFileSync('/proc/1/cgroup', 'utf8').includes('docker'));
|
|
36
|
+
|
|
37
|
+
// Check TTY availability
|
|
38
|
+
const hasTTY = process.stdin.isTTY && process.stdout.isTTY;
|
|
39
|
+
|
|
40
|
+
return isCI || isDocker || !hasTTY;
|
|
29
41
|
}
|
|
42
|
+
|
|
30
43
|
/**
|
|
31
44
|
* Basic swarm implementation for fallback scenarios
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
*/
|
|
46
|
+
async function basicSwarmNew(args, flags) {
|
|
47
|
+
const objective = (args || []).join(' ').trim();
|
|
48
|
+
|
|
49
|
+
if (!objective) {
|
|
50
|
+
console.error('❌ Usage: swarm <objective>');
|
|
51
|
+
showSwarmHelp();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const isHeadless = isHeadlessEnvironment();
|
|
56
|
+
|
|
57
|
+
// Configure for headless mode
|
|
58
|
+
if (isHeadless) {
|
|
59
|
+
console.log('🤖 Headless environment detected - running in non-interactive mode');
|
|
60
|
+
flags = {
|
|
61
|
+
...flags,
|
|
62
|
+
'non-interactive': true,
|
|
63
|
+
'output-format': flags['output-format'] || 'stream-json', // Use stream-json for Claude compatibility
|
|
64
|
+
'no-auto-permissions': false,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Set up graceful shutdown handlers
|
|
69
|
+
const cleanup = () => {
|
|
70
|
+
console.log('\n🛑 Shutting down swarm gracefully...');
|
|
71
|
+
process.exit(0);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
process.on('SIGTERM', cleanup);
|
|
75
|
+
process.on('SIGINT', cleanup);
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
// Try to use the swarm executor
|
|
79
|
+
const { executeSwarm } = await import('./swarm-executor.js');
|
|
80
|
+
|
|
81
|
+
console.log(`🐝 Starting basic swarm execution...`);
|
|
82
|
+
console.log(`📋 Objective: ${objective}`);
|
|
83
|
+
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
|
84
|
+
console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`);
|
|
85
|
+
console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`);
|
|
86
|
+
|
|
41
87
|
if (isHeadless) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
...flags,
|
|
45
|
-
'non-interactive': true,
|
|
46
|
-
'output-format': flags['output-format'] || 'stream-json',
|
|
47
|
-
'no-auto-permissions': false
|
|
48
|
-
};
|
|
88
|
+
console.log(`🖥️ Headless Mode: Enabled`);
|
|
89
|
+
console.log(`📄 Output Format: ${flags['output-format']}`);
|
|
49
90
|
}
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
82
|
-
if (flags['output-file']) {
|
|
83
|
-
const fs = await import("node:fs/promises");
|
|
84
|
-
await fs.writeFile(flags['output-file'], JSON.stringify(output, null, 2));
|
|
85
|
-
console.log(`✅ Output saved to: ${flags['output-file']}`);
|
|
86
|
-
} else {
|
|
87
|
-
console.log(JSON.stringify(output, null, 2));
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
// Text mode output
|
|
91
|
-
if (result.success) {
|
|
92
|
-
console.log(`\n✅ Swarm execution completed successfully!`);
|
|
93
|
-
if (result.summary) {
|
|
94
|
-
console.log(` Duration: ${result.summary.duration}`);
|
|
95
|
-
console.log(` Agents: ${result.summary.totalAgents}`);
|
|
96
|
-
console.log(` Tasks: ${result.summary.totalTasks}`);
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
console.error(`\n❌ Swarm execution failed: ${result.error}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return result;
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.error(`❌ Basic swarm execution error: ${error.message}`);
|
|
105
|
-
// In headless mode, ensure we output JSON error
|
|
106
|
-
if (flags['output-format'] === 'json') {
|
|
107
|
-
const errorOutput = {
|
|
108
|
-
success: false,
|
|
109
|
-
error: error.message,
|
|
110
|
-
timestamp: new Date().toISOString()
|
|
111
|
-
};
|
|
112
|
-
console.log(JSON.stringify(errorOutput, null, 2));
|
|
91
|
+
|
|
92
|
+
const result = await executeSwarm(objective, flags);
|
|
93
|
+
|
|
94
|
+
// Handle output based on format
|
|
95
|
+
if (flags['output-format'] === 'json') {
|
|
96
|
+
// In JSON mode, output clean JSON
|
|
97
|
+
const output = {
|
|
98
|
+
success: result.success,
|
|
99
|
+
swarmId: result.summary?.swarmId,
|
|
100
|
+
objective: objective,
|
|
101
|
+
duration: result.summary?.duration,
|
|
102
|
+
agents: result.summary?.totalAgents,
|
|
103
|
+
tasks: result.summary?.totalTasks,
|
|
104
|
+
timestamp: new Date().toISOString(),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
if (flags['output-file']) {
|
|
108
|
+
const fs = await import('fs/promises');
|
|
109
|
+
await fs.writeFile(flags['output-file'], JSON.stringify(output, null, 2));
|
|
110
|
+
console.log(`✅ Output saved to: ${flags['output-file']}`);
|
|
111
|
+
} else {
|
|
112
|
+
console.log(JSON.stringify(output, null, 2));
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
// Text mode output
|
|
116
|
+
if (result.success) {
|
|
117
|
+
console.log(`\n✅ Swarm execution completed successfully!`);
|
|
118
|
+
if (result.summary) {
|
|
119
|
+
console.log(` Duration: ${result.summary.duration}`);
|
|
120
|
+
console.log(` Agents: ${result.summary.totalAgents}`);
|
|
121
|
+
console.log(` Tasks: ${result.summary.totalTasks}`);
|
|
113
122
|
}
|
|
114
|
-
|
|
123
|
+
} else {
|
|
124
|
+
console.error(`\n❌ Swarm execution failed: ${result.error}`);
|
|
125
|
+
}
|
|
115
126
|
}
|
|
127
|
+
|
|
128
|
+
return result;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error(`❌ Basic swarm execution error: ${error.message}`);
|
|
131
|
+
|
|
132
|
+
// In headless mode, ensure we output JSON error
|
|
133
|
+
if (flags['output-format'] === 'json') {
|
|
134
|
+
const errorOutput = {
|
|
135
|
+
success: false,
|
|
136
|
+
error: error.message,
|
|
137
|
+
timestamp: new Date().toISOString(),
|
|
138
|
+
};
|
|
139
|
+
console.log(JSON.stringify(errorOutput, null, 2));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
116
144
|
}
|
|
145
|
+
|
|
117
146
|
function showSwarmHelp() {
|
|
118
|
-
|
|
147
|
+
console.log(`
|
|
119
148
|
🐝 Claude Flow Advanced Swarm System
|
|
120
149
|
|
|
121
150
|
USAGE:
|
|
@@ -221,114 +250,136 @@ For complete documentation and examples:
|
|
|
221
250
|
https://github.com/ruvnet/claude-code-flow/docs/swarm.md
|
|
222
251
|
`);
|
|
223
252
|
}
|
|
253
|
+
|
|
224
254
|
export async function swarmCommand(args, flags) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
showSwarmHelp();
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
// Force headless mode if flag is set
|
|
263
|
-
if (flags && flags.headless) {
|
|
264
|
-
const isHeadless = isHeadlessEnvironment();
|
|
265
|
-
if (!isHeadless) {
|
|
266
|
-
console.log('🤖 Forcing headless mode as requested');
|
|
267
|
-
}
|
|
268
|
-
flags = {
|
|
269
|
-
...flags,
|
|
270
|
-
'non-interactive': true,
|
|
271
|
-
'output-format': flags['output-format'] || 'json',
|
|
272
|
-
'no-auto-permissions': false
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
// Handle JSON output format
|
|
276
|
-
const outputFormat = flags && flags['output-format'];
|
|
277
|
-
const outputFile = flags && flags['output-file'];
|
|
278
|
-
const isJsonOutput = outputFormat === 'json';
|
|
279
|
-
const isNonInteractive = isJsonOutput || flags && flags['no-interactive'];
|
|
280
|
-
const useJsonLogs = flags && flags['json-logs'];
|
|
281
|
-
// Override console.log for JSON logs if requested
|
|
282
|
-
if (useJsonLogs) {
|
|
283
|
-
const originalLog = console.log;
|
|
284
|
-
const originalError = console.error;
|
|
285
|
-
console.log = (...args)=>{
|
|
286
|
-
originalLog(JSON.stringify({
|
|
287
|
-
level: 'info',
|
|
288
|
-
message: args.join(' '),
|
|
289
|
-
timestamp: new Date().toISOString(),
|
|
290
|
-
service: 'claude-flow-swarm'
|
|
291
|
-
}));
|
|
292
|
-
};
|
|
293
|
-
console.error = (...args)=>{
|
|
294
|
-
originalError(JSON.stringify({
|
|
295
|
-
level: 'error',
|
|
296
|
-
message: args.join(' '),
|
|
297
|
-
timestamp: new Date().toISOString(),
|
|
298
|
-
service: 'claude-flow-swarm'
|
|
299
|
-
}));
|
|
300
|
-
};
|
|
255
|
+
// Handle headless mode early
|
|
256
|
+
if (flags && flags.headless) {
|
|
257
|
+
const isHeadless = isHeadlessEnvironment();
|
|
258
|
+
// Configure for headless mode
|
|
259
|
+
flags = {
|
|
260
|
+
...flags,
|
|
261
|
+
'non-interactive': true,
|
|
262
|
+
'output-format': flags['output-format'] || 'stream-json',
|
|
263
|
+
'no-auto-permissions': false,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Handle health check first
|
|
268
|
+
if (flags && flags['health-check']) {
|
|
269
|
+
try {
|
|
270
|
+
// Quick health check for Docker/K8s
|
|
271
|
+
console.log(
|
|
272
|
+
JSON.stringify({
|
|
273
|
+
status: 'healthy',
|
|
274
|
+
service: 'claude-flow-swarm',
|
|
275
|
+
version: process.env.npm_package_version || '2.0.0',
|
|
276
|
+
timestamp: new Date().toISOString(),
|
|
277
|
+
}),
|
|
278
|
+
);
|
|
279
|
+
process.exit(0);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
console.error(
|
|
282
|
+
JSON.stringify({
|
|
283
|
+
status: 'unhealthy',
|
|
284
|
+
error: error.message,
|
|
285
|
+
timestamp: new Date().toISOString(),
|
|
286
|
+
}),
|
|
287
|
+
);
|
|
288
|
+
process.exit(1);
|
|
301
289
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const objective = (args || []).join(' ').trim();
|
|
293
|
+
|
|
294
|
+
if (!objective) {
|
|
295
|
+
console.error('❌ Usage: swarm <objective>');
|
|
296
|
+
showSwarmHelp();
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Force headless mode if flag is set
|
|
301
|
+
if (flags && flags.headless) {
|
|
302
|
+
const isHeadless = isHeadlessEnvironment();
|
|
303
|
+
if (!isHeadless) {
|
|
304
|
+
console.log('🤖 Forcing headless mode as requested');
|
|
313
305
|
}
|
|
314
|
-
|
|
315
|
-
|
|
306
|
+
flags = {
|
|
307
|
+
...flags,
|
|
308
|
+
'non-interactive': true,
|
|
309
|
+
'output-format': flags['output-format'] || 'json',
|
|
310
|
+
'no-auto-permissions': false,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Handle JSON output format
|
|
315
|
+
const outputFormat = flags && flags['output-format'];
|
|
316
|
+
const outputFile = flags && flags['output-file'];
|
|
317
|
+
const isJsonOutput = outputFormat === 'json';
|
|
318
|
+
const isNonInteractive = isJsonOutput || (flags && flags['no-interactive']);
|
|
319
|
+
const useJsonLogs = flags && flags['json-logs'];
|
|
320
|
+
|
|
321
|
+
// Override console.log for JSON logs if requested
|
|
322
|
+
if (useJsonLogs) {
|
|
323
|
+
const originalLog = console.log;
|
|
324
|
+
const originalError = console.error;
|
|
325
|
+
|
|
326
|
+
console.log = (...args) => {
|
|
327
|
+
originalLog(
|
|
328
|
+
JSON.stringify({
|
|
329
|
+
level: 'info',
|
|
330
|
+
message: args.join(' '),
|
|
331
|
+
timestamp: new Date().toISOString(),
|
|
332
|
+
service: 'claude-flow-swarm',
|
|
333
|
+
}),
|
|
334
|
+
);
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
console.error = (...args) => {
|
|
338
|
+
originalError(
|
|
339
|
+
JSON.stringify({
|
|
340
|
+
level: 'error',
|
|
341
|
+
message: args.join(' '),
|
|
342
|
+
timestamp: new Date().toISOString(),
|
|
343
|
+
service: 'claude-flow-swarm',
|
|
344
|
+
}),
|
|
345
|
+
);
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Handle analysis/read-only mode
|
|
350
|
+
const isAnalysisMode = flags && (flags.analysis || flags['read-only']);
|
|
351
|
+
const analysisMode = isAnalysisMode ? 'analysis' : 'standard';
|
|
352
|
+
|
|
353
|
+
// For JSON output, allow using Claude with stream-json format
|
|
354
|
+
// Only force executor mode if explicitly using 'json' format (not 'stream-json')
|
|
355
|
+
if (flags && flags['output-format'] === 'json' && !(flags && flags.executor)) {
|
|
356
|
+
// Keep backward compatibility - regular 'json' format uses executor
|
|
357
|
+
flags = { ...(flags || {}), executor: true };
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Check if we should use the old executor (opt-in with --executor flag)
|
|
361
|
+
if (flags && flags.executor) {
|
|
316
362
|
// Continue with the old swarm executor implementation below
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
363
|
+
} else {
|
|
364
|
+
// Default behavior: spawn Claude Code with comprehensive swarm MCP instructions
|
|
365
|
+
try {
|
|
366
|
+
const { execSync, spawn } = await import('child_process');
|
|
367
|
+
|
|
368
|
+
// Get configuration values first
|
|
369
|
+
const strategy = flags.strategy || 'auto';
|
|
370
|
+
const mode = flags.mode || 'centralized';
|
|
371
|
+
const maxAgents = flags['max-agents'] || 5;
|
|
372
|
+
|
|
373
|
+
// Get strategy-specific guidance
|
|
374
|
+
const strategyGuidance = getStrategyGuidance(strategy, objective);
|
|
375
|
+
const modeGuidance = getModeGuidance(mode);
|
|
376
|
+
const agentRecommendations = getAgentRecommendations(strategy, maxAgents, objective);
|
|
377
|
+
|
|
378
|
+
const enableSparc =
|
|
379
|
+
flags.sparc !== false && (strategy === 'development' || strategy === 'auto');
|
|
380
|
+
|
|
381
|
+
// Build the complete swarm prompt before checking for claude
|
|
382
|
+
const swarmPrompt = `You are orchestrating a Claude Flow Swarm using Claude Code's Task tool for agent execution.
|
|
332
383
|
|
|
333
384
|
🚨 CRITICAL INSTRUCTION: Use Claude Code's Task Tool for ALL Agent Spawning!
|
|
334
385
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
@@ -348,7 +399,9 @@ export async function swarmCommand(args, flags) {
|
|
|
348
399
|
- Testing Mode: ${flags.testing || false}
|
|
349
400
|
- Analysis Mode: ${isAnalysisMode ? 'ENABLED (Read-Only)' : 'DISABLED'}
|
|
350
401
|
|
|
351
|
-
${
|
|
402
|
+
${
|
|
403
|
+
isAnalysisMode
|
|
404
|
+
? `🔍 ANALYSIS MODE CONSTRAINTS:
|
|
352
405
|
|
|
353
406
|
⚠️ READ-ONLY MODE ACTIVE - NO CODE MODIFICATIONS ALLOWED
|
|
354
407
|
|
|
@@ -381,7 +434,9 @@ ALL AGENTS MUST OPERATE IN READ-ONLY MODE. Focus on:
|
|
|
381
434
|
|
|
382
435
|
Generate comprehensive reports instead of making changes.
|
|
383
436
|
|
|
384
|
-
`
|
|
437
|
+
`
|
|
438
|
+
: ''
|
|
439
|
+
}🚨 CRITICAL: PARALLEL EXECUTION IS MANDATORY! 🚨
|
|
385
440
|
|
|
386
441
|
📋 CLAUDE-FLOW SWARM BATCHTOOL INSTRUCTIONS
|
|
387
442
|
|
|
@@ -592,7 +647,9 @@ ${agentRecommendations}
|
|
|
592
647
|
- Tools: agent_communicate, memory_store/retrieve
|
|
593
648
|
|
|
594
649
|
⚡ EXECUTION WORKFLOW - ALWAYS USE BATCHTOOL:
|
|
595
|
-
${
|
|
650
|
+
${
|
|
651
|
+
enableSparc
|
|
652
|
+
? `
|
|
596
653
|
1. SPARC METHODOLOGY WITH PARALLEL EXECUTION:
|
|
597
654
|
|
|
598
655
|
S - Specification Phase (Single BatchTool):
|
|
@@ -640,7 +697,8 @@ ${enableSparc ? `
|
|
|
640
697
|
mcp__claude-flow__memory_retrieve { pattern: "**/*" }
|
|
641
698
|
TodoWrite { todos: [{content: "Final review", status: "completed"}] }
|
|
642
699
|
\`\`\`
|
|
643
|
-
`
|
|
700
|
+
`
|
|
701
|
+
: `
|
|
644
702
|
1. STANDARD SWARM EXECUTION WITH PARALLEL OPERATIONS:
|
|
645
703
|
|
|
646
704
|
Initial Setup (Single BatchTool):
|
|
@@ -668,7 +726,8 @@ ${enableSparc ? `
|
|
|
668
726
|
mcp__claude-flow__agent_communicate { to: "all", message: "Status update" }
|
|
669
727
|
mcp__claude-flow__memory_store { key: "progress", value: {...} }
|
|
670
728
|
\`\`\`
|
|
671
|
-
`
|
|
729
|
+
`
|
|
730
|
+
}
|
|
672
731
|
|
|
673
732
|
🤝 AGENT TYPES & THEIR MCP TOOL USAGE:
|
|
674
733
|
|
|
@@ -733,207 +792,243 @@ Use hierarchical keys for organization:
|
|
|
733
792
|
Start by spawning a coordinator agent and creating the initial task structure. Use the MCP tools to orchestrate the swarm, coordinate agents, and track progress. Remember to store important decisions and artifacts in collective memory for other agents to access.
|
|
734
793
|
|
|
735
794
|
The swarm should be self-documenting - use memory_store to save all important information, decisions, and results throughout the execution.`;
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
const claudeEnv = {
|
|
759
|
-
...process.env
|
|
760
|
-
};
|
|
761
|
-
// Remove telemetry env vars to prevent console output
|
|
762
|
-
delete claudeEnv.CLAUDE_CODE_ENABLE_TELEMETRY;
|
|
763
|
-
delete claudeEnv.OTEL_METRICS_EXPORTER;
|
|
764
|
-
delete claudeEnv.OTEL_LOGS_EXPORTER;
|
|
765
|
-
const claudeProcess = spawn('claude', claudeArgs, {
|
|
766
|
-
stdio: 'inherit',
|
|
767
|
-
shell: false,
|
|
768
|
-
env: claudeEnv
|
|
769
|
-
});
|
|
770
|
-
console.log('\n✓ Claude Code launched with swarm coordination prompt!');
|
|
771
|
-
console.log(' The swarm coordinator will orchestrate all agent tasks');
|
|
772
|
-
console.log(' Use MCP tools for coordination and memory sharing');
|
|
773
|
-
console.log('\n💡 Pro Tips:');
|
|
774
|
-
console.log('─'.repeat(30));
|
|
775
|
-
console.log('• Use TodoWrite to track parallel tasks');
|
|
776
|
-
console.log('• Store results with mcp__claude-flow__memory_usage');
|
|
777
|
-
console.log('• Monitor progress with mcp__claude-flow__swarm_monitor');
|
|
778
|
-
console.log('• Check task status with mcp__claude-flow__task_status');
|
|
779
|
-
// Set up clean termination
|
|
780
|
-
const cleanup = ()=>{
|
|
781
|
-
console.log('\n🛑 Shutting down swarm gracefully...');
|
|
782
|
-
if (claudeProcess && !claudeProcess.killed) {
|
|
783
|
-
claudeProcess.kill('SIGTERM');
|
|
784
|
-
}
|
|
785
|
-
process.exit(0);
|
|
786
|
-
};
|
|
787
|
-
process.on('SIGINT', cleanup);
|
|
788
|
-
process.on('SIGTERM', cleanup);
|
|
789
|
-
// Wait for claude to exit
|
|
790
|
-
claudeProcess.on('exit', (code)=>{
|
|
791
|
-
if (code === 0) {
|
|
792
|
-
console.log('\n✓ Swarm execution completed successfully');
|
|
793
|
-
} else if (code !== null) {
|
|
794
|
-
console.log(`\n✗ Swarm execution exited with code ${code}`);
|
|
795
|
-
}
|
|
796
|
-
process.exit(code || 0);
|
|
797
|
-
});
|
|
798
|
-
// Handle spawn errors (e.g., claude not found)
|
|
799
|
-
claudeProcess.on('error', (err)=>{
|
|
800
|
-
if (err.code === 'ENOENT') {
|
|
801
|
-
console.error('\n❌ Claude Code CLI not found. Please install Claude Code:');
|
|
802
|
-
console.error(' https://claude.ai/download');
|
|
803
|
-
} else {
|
|
804
|
-
console.error('\n❌ Failed to launch Claude Code:', err.message);
|
|
805
|
-
}
|
|
806
|
-
process.exit(1);
|
|
807
|
-
});
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
// Check if we're in non-interactive/headless mode FIRST (like alpha.83)
|
|
811
|
-
const isNonInteractive = flags['no-interactive'] || flags['non-interactive'] || flags['output-format'] === 'stream-json' || isHeadlessEnvironment();
|
|
812
|
-
// Check if claude command exists
|
|
813
|
-
let claudeAvailable = false;
|
|
814
|
-
try {
|
|
815
|
-
execSync('which claude', {
|
|
816
|
-
stdio: 'ignore'
|
|
817
|
-
});
|
|
818
|
-
claudeAvailable = true;
|
|
819
|
-
} catch {
|
|
820
|
-
if (!isNonInteractive) {
|
|
821
|
-
console.log('⚠️ Claude Code CLI not found in PATH');
|
|
822
|
-
console.log('Install it with: npm install -g @anthropic-ai/claude-code');
|
|
823
|
-
console.log('Or use --claude flag to open Claude Code CLI');
|
|
824
|
-
console.log('\nWould spawn Claude Code with swarm objective:');
|
|
825
|
-
console.log(`📋 Objective: ${objective}`);
|
|
826
|
-
console.log('\nOptions:');
|
|
827
|
-
console.log(' • Use --executor flag for built-in executor: claude-flow-novice swarm "objective" --executor');
|
|
828
|
-
console.log(' • Use --claude flag to open Claude Code CLI: claude-flow-novice swarm "objective" --claude');
|
|
829
|
-
} else {
|
|
830
|
-
// In non-interactive mode, output JSON error
|
|
831
|
-
console.error(JSON.stringify({
|
|
832
|
-
error: 'Claude Code CLI not found',
|
|
833
|
-
message: 'Install with: npm install -g @anthropic-ai/claude-code',
|
|
834
|
-
fallback: 'Use --executor flag for built-in executor'
|
|
835
|
-
}));
|
|
836
|
-
}
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
// Claude is available, use it to run swarm
|
|
840
|
-
if (!isNonInteractive) {
|
|
841
|
-
console.log('🐝 Launching Claude Flow Swarm System...');
|
|
842
|
-
console.log(`📋 Objective: ${objective}`);
|
|
843
|
-
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
|
844
|
-
console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`);
|
|
845
|
-
console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`);
|
|
846
|
-
if (isAnalysisMode) {
|
|
847
|
-
console.log(`🔍 Analysis Mode: ENABLED (Read-Only - No Code Changes)`);
|
|
848
|
-
}
|
|
849
|
-
console.log();
|
|
850
|
-
} else {
|
|
851
|
-
// Non-interactive mode output
|
|
852
|
-
console.log('🤖 Running in non-interactive mode with Claude');
|
|
853
|
-
console.log('📋 Command: claude [prompt] -p --output-format stream-json --verbose');
|
|
854
|
-
}
|
|
855
|
-
// Continue with the default swarm behavior if not using --claude flag
|
|
856
|
-
// Build arguments in correct order: flags first, then prompt
|
|
857
|
-
const claudeArgs = [];
|
|
858
|
-
// Add non-interactive flags FIRST if needed
|
|
859
|
-
if (isNonInteractive) {
|
|
860
|
-
claudeArgs.push('-p'); // Print mode
|
|
861
|
-
claudeArgs.push('--output-format', 'stream-json'); // JSON streaming
|
|
862
|
-
claudeArgs.push('--verbose'); // Verbose output
|
|
863
|
-
}
|
|
864
|
-
// Add auto-permission flag BEFORE the prompt
|
|
865
|
-
if (flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions']) {
|
|
866
|
-
claudeArgs.push('--dangerously-skip-permissions');
|
|
867
|
-
if (!isNonInteractive) {
|
|
868
|
-
console.log('🔓 Using --dangerously-skip-permissions by default for seamless swarm execution');
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
// Add the prompt as the LAST argument
|
|
872
|
-
claudeArgs.push(swarmPrompt);
|
|
873
|
-
// Spawn claude with properly ordered arguments
|
|
874
|
-
const claudeProcess = spawn('claude', claudeArgs, {
|
|
875
|
-
stdio: 'inherit',
|
|
876
|
-
shell: false
|
|
877
|
-
});
|
|
878
|
-
if (!isNonInteractive) {
|
|
879
|
-
console.log('✓ Claude Code launched with swarm coordination prompt!');
|
|
880
|
-
console.log('\n🚀 The swarm coordination instructions have been injected into Claude Code');
|
|
881
|
-
console.log(' The prompt includes:');
|
|
882
|
-
console.log(' • Strategy-specific guidance for', strategy);
|
|
883
|
-
console.log(' • Coordination patterns for', mode, 'mode');
|
|
884
|
-
console.log(' • Recommended agents and MCP tool usage');
|
|
885
|
-
console.log(' • Complete workflow documentation\n');
|
|
886
|
-
}
|
|
887
|
-
// Handle process events
|
|
888
|
-
claudeProcess.on('error', (err)=>{
|
|
889
|
-
console.error('❌ Failed to launch Claude Code:', err.message);
|
|
890
|
-
});
|
|
891
|
-
// Don't wait for completion - let it run
|
|
892
|
-
return;
|
|
893
|
-
} catch (error) {
|
|
894
|
-
console.error('❌ Failed to spawn Claude Code:', error.message);
|
|
895
|
-
console.log('\nFalling back to built-in executor...');
|
|
896
|
-
// Fall through to executor implementation
|
|
795
|
+
|
|
796
|
+
// If --claude flag is used, force Claude Code even if CLI not available
|
|
797
|
+
if (flags && flags.claude) {
|
|
798
|
+
// --claude flag means interactive mode, so don't apply non-interactive
|
|
799
|
+
console.log('🐝 Launching Claude Flow Swarm System...');
|
|
800
|
+
console.log(`📋 Objective: ${objective}`);
|
|
801
|
+
console.log(`🎯 Strategy: ${strategy}`);
|
|
802
|
+
console.log(`🏗️ Mode: ${mode}`);
|
|
803
|
+
console.log(`🤖 Max Agents: ${maxAgents}\n`);
|
|
804
|
+
|
|
805
|
+
console.log('🚀 Launching Claude Code with Swarm Coordination');
|
|
806
|
+
console.log('─'.repeat(60));
|
|
807
|
+
|
|
808
|
+
// Build arguments properly: for interactive mode, prompt can be first
|
|
809
|
+
const claudeArgs = [];
|
|
810
|
+
|
|
811
|
+
// Add auto-permission flag first
|
|
812
|
+
if (flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions']) {
|
|
813
|
+
claudeArgs.push('--dangerously-skip-permissions');
|
|
814
|
+
console.log(
|
|
815
|
+
'🔓 Using --dangerously-skip-permissions by default for seamless swarm execution',
|
|
816
|
+
);
|
|
897
817
|
}
|
|
818
|
+
|
|
819
|
+
// Add the prompt (for interactive mode, position doesn't matter as much)
|
|
820
|
+
claudeArgs.push(swarmPrompt);
|
|
821
|
+
|
|
822
|
+
// --claude flag means interactive mode, so don't add non-interactive flags
|
|
823
|
+
|
|
824
|
+
// For --claude interactive mode, spawn Claude directly
|
|
825
|
+
// Temporarily disable telemetry to avoid console output interference
|
|
826
|
+
const claudeEnv = { ...process.env };
|
|
827
|
+
|
|
828
|
+
// Remove telemetry env vars to prevent console output
|
|
829
|
+
delete claudeEnv.CLAUDE_CODE_ENABLE_TELEMETRY;
|
|
830
|
+
delete claudeEnv.OTEL_METRICS_EXPORTER;
|
|
831
|
+
delete claudeEnv.OTEL_LOGS_EXPORTER;
|
|
832
|
+
|
|
833
|
+
const claudeProcess = spawn('claude', claudeArgs, {
|
|
834
|
+
stdio: 'inherit',
|
|
835
|
+
shell: false,
|
|
836
|
+
env: claudeEnv,
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
console.log('\n✓ Claude Code launched with swarm coordination prompt!');
|
|
840
|
+
console.log(' The swarm coordinator will orchestrate all agent tasks');
|
|
841
|
+
console.log(' Use MCP tools for coordination and memory sharing');
|
|
842
|
+
|
|
843
|
+
console.log('\n💡 Pro Tips:');
|
|
844
|
+
console.log('─'.repeat(30));
|
|
845
|
+
console.log('• Use TodoWrite to track parallel tasks');
|
|
846
|
+
console.log('• Store results with mcp__claude-flow__memory_usage');
|
|
847
|
+
console.log('• Monitor progress with mcp__claude-flow__swarm_monitor');
|
|
848
|
+
console.log('• Check task status with mcp__claude-flow__task_status');
|
|
849
|
+
|
|
850
|
+
// Set up clean termination
|
|
851
|
+
const cleanup = () => {
|
|
852
|
+
console.log('\n🛑 Shutting down swarm gracefully...');
|
|
853
|
+
if (claudeProcess && !claudeProcess.killed) {
|
|
854
|
+
claudeProcess.kill('SIGTERM');
|
|
855
|
+
}
|
|
856
|
+
process.exit(0);
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
process.on('SIGINT', cleanup);
|
|
860
|
+
process.on('SIGTERM', cleanup);
|
|
861
|
+
|
|
862
|
+
// Wait for claude to exit
|
|
863
|
+
claudeProcess.on('exit', (code) => {
|
|
864
|
+
if (code === 0) {
|
|
865
|
+
console.log('\n✓ Swarm execution completed successfully');
|
|
866
|
+
} else if (code !== null) {
|
|
867
|
+
console.log(`\n✗ Swarm execution exited with code ${code}`);
|
|
868
|
+
}
|
|
869
|
+
process.exit(code || 0);
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
// Handle spawn errors (e.g., claude not found)
|
|
873
|
+
claudeProcess.on('error', (err) => {
|
|
874
|
+
if (err.code === 'ENOENT') {
|
|
875
|
+
console.error('\n❌ Claude Code CLI not found. Please install Claude Code:');
|
|
876
|
+
console.error(' https://claude.ai/download');
|
|
877
|
+
} else {
|
|
878
|
+
console.error('\n❌ Failed to launch Claude Code:', err.message);
|
|
879
|
+
}
|
|
880
|
+
process.exit(1);
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
// Check if we're in non-interactive/headless mode FIRST (like alpha.83)
|
|
887
|
+
const isNonInteractive =
|
|
888
|
+
flags['no-interactive'] ||
|
|
889
|
+
flags['non-interactive'] ||
|
|
890
|
+
flags['output-format'] === 'stream-json' ||
|
|
891
|
+
isHeadlessEnvironment();
|
|
892
|
+
|
|
893
|
+
// Check if claude command exists
|
|
894
|
+
let claudeAvailable = false;
|
|
895
|
+
try {
|
|
896
|
+
execSync('which claude', { stdio: 'ignore' });
|
|
897
|
+
claudeAvailable = true;
|
|
898
|
+
} catch {
|
|
899
|
+
if (!isNonInteractive) {
|
|
900
|
+
console.log('⚠️ Claude Code CLI not found in PATH');
|
|
901
|
+
console.log('Install it with: npm install -g @anthropic-ai/claude-code');
|
|
902
|
+
console.log('Or use --claude flag to open Claude Code CLI');
|
|
903
|
+
console.log('\nWould spawn Claude Code with swarm objective:');
|
|
904
|
+
console.log(`📋 Objective: ${objective}`);
|
|
905
|
+
console.log('\nOptions:');
|
|
906
|
+
console.log(
|
|
907
|
+
' • Use --executor flag for built-in executor: claude-flow-novice swarm "objective" --executor',
|
|
908
|
+
);
|
|
909
|
+
console.log(
|
|
910
|
+
' • Use --claude flag to open Claude Code CLI: claude-flow-novice swarm "objective" --claude',
|
|
911
|
+
);
|
|
912
|
+
} else {
|
|
913
|
+
// In non-interactive mode, output JSON error
|
|
914
|
+
console.error(
|
|
915
|
+
JSON.stringify({
|
|
916
|
+
error: 'Claude Code CLI not found',
|
|
917
|
+
message: 'Install with: npm install -g @anthropic-ai/claude-code',
|
|
918
|
+
fallback: 'Use --executor flag for built-in executor',
|
|
919
|
+
}),
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// Claude is available, use it to run swarm
|
|
926
|
+
if (!isNonInteractive) {
|
|
927
|
+
console.log('🐝 Launching Claude Flow Swarm System...');
|
|
928
|
+
console.log(`📋 Objective: ${objective}`);
|
|
929
|
+
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
|
930
|
+
console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`);
|
|
931
|
+
console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`);
|
|
932
|
+
if (isAnalysisMode) {
|
|
933
|
+
console.log(`🔍 Analysis Mode: ENABLED (Read-Only - No Code Changes)`);
|
|
934
|
+
}
|
|
935
|
+
console.log();
|
|
936
|
+
} else {
|
|
937
|
+
// Non-interactive mode output
|
|
938
|
+
console.log('🤖 Running in non-interactive mode with Claude');
|
|
939
|
+
console.log('📋 Command: claude [prompt] -p --output-format stream-json --verbose');
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// Continue with the default swarm behavior if not using --claude flag
|
|
943
|
+
|
|
944
|
+
// Build arguments in correct order: flags first, then prompt
|
|
945
|
+
const claudeArgs = [];
|
|
946
|
+
|
|
947
|
+
// Add non-interactive flags FIRST if needed
|
|
948
|
+
if (isNonInteractive) {
|
|
949
|
+
claudeArgs.push('-p'); // Print mode
|
|
950
|
+
claudeArgs.push('--output-format', 'stream-json'); // JSON streaming
|
|
951
|
+
claudeArgs.push('--verbose'); // Verbose output
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// Add auto-permission flag BEFORE the prompt
|
|
955
|
+
if (flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions']) {
|
|
956
|
+
claudeArgs.push('--dangerously-skip-permissions');
|
|
957
|
+
if (!isNonInteractive) {
|
|
958
|
+
console.log(
|
|
959
|
+
'🔓 Using --dangerously-skip-permissions by default for seamless swarm execution',
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// Add the prompt as the LAST argument
|
|
965
|
+
claudeArgs.push(swarmPrompt);
|
|
966
|
+
|
|
967
|
+
// Spawn claude with properly ordered arguments
|
|
968
|
+
const claudeProcess = spawn('claude', claudeArgs, {
|
|
969
|
+
stdio: 'inherit',
|
|
970
|
+
shell: false,
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
if (!isNonInteractive) {
|
|
974
|
+
console.log('✓ Claude Code launched with swarm coordination prompt!');
|
|
975
|
+
console.log('\n🚀 The swarm coordination instructions have been injected into Claude Code');
|
|
976
|
+
console.log(' The prompt includes:');
|
|
977
|
+
console.log(' • Strategy-specific guidance for', strategy);
|
|
978
|
+
console.log(' • Coordination patterns for', mode, 'mode');
|
|
979
|
+
console.log(' • Recommended agents and MCP tool usage');
|
|
980
|
+
console.log(' • Complete workflow documentation\n');
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// Handle process events
|
|
984
|
+
claudeProcess.on('error', (err) => {
|
|
985
|
+
console.error('❌ Failed to launch Claude Code:', err.message);
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
// Don't wait for completion - let it run
|
|
989
|
+
return;
|
|
990
|
+
} catch (error) {
|
|
991
|
+
console.error('❌ Failed to spawn Claude Code:', error.message);
|
|
992
|
+
console.log('\nFalling back to built-in executor...');
|
|
993
|
+
// Fall through to executor implementation
|
|
898
994
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
const scriptContent = `#!/usr/bin/env -S deno run --allow-all
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
// Check if we should run in background mode
|
|
998
|
+
if (flags && flags.background && !process.env.CLAUDE_SWARM_NO_BG) {
|
|
999
|
+
// Check if we're in Deno environment
|
|
1000
|
+
if (typeof Deno !== 'undefined') {
|
|
1001
|
+
// In Deno, spawn a new process for true background execution
|
|
1002
|
+
const objective = (args || []).join(' ').trim();
|
|
1003
|
+
const swarmId = `swarm_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
1004
|
+
const swarmRunDir = `./swarm-runs/${swarmId}`;
|
|
1005
|
+
|
|
1006
|
+
// Create swarm directory
|
|
1007
|
+
await mkdirAsync(swarmRunDir, { recursive: true });
|
|
1008
|
+
|
|
1009
|
+
console.log(`🐝 Launching swarm in background mode...`);
|
|
1010
|
+
console.log(`📋 Objective: ${objective}`);
|
|
1011
|
+
console.log(`🆔 Swarm ID: ${swarmId}`);
|
|
1012
|
+
console.log(`📁 Results: ${swarmRunDir}`);
|
|
1013
|
+
|
|
1014
|
+
// Build command args without background flag (to prevent infinite loop)
|
|
1015
|
+
const commandArgs = ['run', '--allow-all', import.meta.url, objective];
|
|
1016
|
+
const newFlags = { ...flags };
|
|
1017
|
+
delete newFlags.background; // Remove background flag
|
|
1018
|
+
|
|
1019
|
+
for (const [key, value] of Object.entries(newFlags)) {
|
|
1020
|
+
commandArgs.push(`--${key}`);
|
|
1021
|
+
if (value !== true) {
|
|
1022
|
+
commandArgs.push(String(value));
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
// Create log file
|
|
1027
|
+
const logFile = `${swarmRunDir}/swarm.log`;
|
|
1028
|
+
const logHandle = await open(logFile, 'w');
|
|
1029
|
+
|
|
1030
|
+
// Create a script to run the swarm without background flag
|
|
1031
|
+
const scriptContent = `#!/usr/bin/env -S deno run --allow-all
|
|
937
1032
|
import { swarmCommand } from "${import.meta.url}";
|
|
938
1033
|
import { cwd, exit, existsSync } from '../node-compat.js';
|
|
939
1034
|
import process from 'process';
|
|
@@ -948,53 +1043,64 @@ process.env.CLAUDE_SWARM_NO_BG = 'true';
|
|
|
948
1043
|
// Run the swarm
|
|
949
1044
|
await swarmCommand(args, flags);
|
|
950
1045
|
`;
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1046
|
+
|
|
1047
|
+
const scriptPath = `${swarmRunDir}/run-swarm.js`;
|
|
1048
|
+
await writeTextFile(scriptPath, scriptContent);
|
|
1049
|
+
|
|
1050
|
+
// Save process info first
|
|
1051
|
+
await writeTextFile(
|
|
1052
|
+
`${swarmRunDir}/process.json`,
|
|
1053
|
+
JSON.stringify(
|
|
1054
|
+
{
|
|
1055
|
+
swarmId: swarmId,
|
|
1056
|
+
objective: objective,
|
|
1057
|
+
startTime: new Date().toISOString(),
|
|
1058
|
+
logFile: logFile,
|
|
1059
|
+
status: 'starting',
|
|
1060
|
+
},
|
|
1061
|
+
null,
|
|
1062
|
+
2,
|
|
1063
|
+
),
|
|
1064
|
+
);
|
|
1065
|
+
|
|
1066
|
+
// Close log handle before spawning
|
|
1067
|
+
logHandle.close();
|
|
1068
|
+
|
|
1069
|
+
// Use the bash script for true background execution
|
|
1070
|
+
const binDir = new URL('../../../bin/', import.meta.url).pathname;
|
|
1071
|
+
const bgScriptPath = `${binDir}claude-flow-swarm-bg`;
|
|
1072
|
+
|
|
1073
|
+
try {
|
|
1074
|
+
// Check if the background script exists
|
|
1075
|
+
statSync(bgScriptPath);
|
|
1076
|
+
|
|
1077
|
+
// Build command args for the background script
|
|
1078
|
+
const bgArgs = [objective];
|
|
1079
|
+
for (const [key, value] of Object.entries(newFlags)) {
|
|
1080
|
+
bgArgs.push(`--${key}`);
|
|
1081
|
+
if (value !== true) {
|
|
1082
|
+
bgArgs.push(String(value));
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
// Use the bash background script
|
|
1087
|
+
const bgProcess = spawn(bgScriptPath, bgArgs, {
|
|
1088
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
// Read and display output
|
|
1092
|
+
const decoder = new TextDecoder();
|
|
1093
|
+
const output = await bgProcess.output();
|
|
1094
|
+
console.log(decoder.decode(output.stdout));
|
|
1095
|
+
|
|
1096
|
+
// Exit immediately after launching
|
|
1097
|
+
exit(0);
|
|
1098
|
+
} catch (error) {
|
|
1099
|
+
// Fallback: create a double-fork pattern using a shell script
|
|
1100
|
+
console.log(`\n⚠️ Background script not found, using fallback method`);
|
|
1101
|
+
|
|
1102
|
+
// Create a shell script that will run the swarm
|
|
1103
|
+
const shellScript = `#!/bin/bash
|
|
998
1104
|
# Double fork to detach from parent
|
|
999
1105
|
(
|
|
1000
1106
|
(
|
|
@@ -1004,231 +1110,262 @@ await swarmCommand(args, flags);
|
|
|
1004
1110
|
)
|
|
1005
1111
|
exit 0
|
|
1006
1112
|
`;
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
} catch (error) {
|
|
1054
|
-
console.error('Failed to launch background swarm:', error.message);
|
|
1055
|
-
}
|
|
1056
|
-
} else {
|
|
1057
|
-
// Fallback to simple message
|
|
1058
|
-
console.log(`🐝 Background mode requested`);
|
|
1059
|
-
console.log(`📋 Objective: ${objective}`);
|
|
1060
|
-
console.log(`\n⚠️ Background execution requires the claude-flow-swarm-bg script.`);
|
|
1061
|
-
console.log(`\nFor true background execution, use:`);
|
|
1062
|
-
console.log(` nohup claude-flow-novice swarm "${objective}" ${Object.entries(flags).filter(([k, v])=>k !== 'background' && v).map(([k, v])=>`--${k}${v !== true ? ` ${v}` : ''}`).join(' ')} > swarm.log 2>&1 &`);
|
|
1113
|
+
|
|
1114
|
+
const shellScriptPath = `${swarmRunDir}/launch-background.sh`;
|
|
1115
|
+
await writeTextFile(shellScriptPath, shellScript);
|
|
1116
|
+
chmodSync(shellScriptPath, 0o755);
|
|
1117
|
+
|
|
1118
|
+
// Execute the shell script
|
|
1119
|
+
const shellProcess = spawn('bash', [shellScriptPath], {
|
|
1120
|
+
stdio: 'ignore',
|
|
1121
|
+
detached: true,
|
|
1122
|
+
});
|
|
1123
|
+
shellProcess.unref();
|
|
1124
|
+
|
|
1125
|
+
console.log(`\n✅ Swarm launched in background!`);
|
|
1126
|
+
console.log(`📄 Logs: tail -f ${logFile}`);
|
|
1127
|
+
console.log(`📊 Status: claude-flow-novice swarm status ${swarmId}`);
|
|
1128
|
+
console.log(`\nThe swarm will continue running independently.`);
|
|
1129
|
+
|
|
1130
|
+
// Exit immediately
|
|
1131
|
+
exit(0);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
// Node.js environment - use background script
|
|
1136
|
+
const { execSync } = await import('child_process');
|
|
1137
|
+
const path = await import('path');
|
|
1138
|
+
const fs = await import('fs');
|
|
1139
|
+
|
|
1140
|
+
const objective = (args || []).join(' ').trim();
|
|
1141
|
+
|
|
1142
|
+
// Get the claude-flow-swarm-bg script path
|
|
1143
|
+
const bgScriptPath = path.join(
|
|
1144
|
+
path.dirname(new URL(import.meta.url).pathname),
|
|
1145
|
+
'../../../bin/claude-flow-swarm-bg',
|
|
1146
|
+
);
|
|
1147
|
+
|
|
1148
|
+
// Check if background script exists
|
|
1149
|
+
if (fs.existsSync(bgScriptPath)) {
|
|
1150
|
+
// Build command args
|
|
1151
|
+
const commandArgs = [objective];
|
|
1152
|
+
for (const [key, value] of Object.entries(flags)) {
|
|
1153
|
+
if (key !== 'background') {
|
|
1154
|
+
// Skip background flag
|
|
1155
|
+
commandArgs.push(`--${key}`);
|
|
1156
|
+
if (value !== true) {
|
|
1157
|
+
commandArgs.push(String(value));
|
|
1158
|
+
}
|
|
1063
1159
|
}
|
|
1064
|
-
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// Execute the background script
|
|
1163
|
+
try {
|
|
1164
|
+
execSync(`"${bgScriptPath}" ${commandArgs.map((arg) => `"${arg}"`).join(' ')}`, {
|
|
1165
|
+
stdio: 'inherit',
|
|
1166
|
+
});
|
|
1167
|
+
} catch (error) {
|
|
1168
|
+
console.error('Failed to launch background swarm:', error.message);
|
|
1169
|
+
}
|
|
1170
|
+
} else {
|
|
1171
|
+
// Fallback to simple message
|
|
1172
|
+
console.log(`🐝 Background mode requested`);
|
|
1173
|
+
console.log(`📋 Objective: ${objective}`);
|
|
1174
|
+
console.log(`\n⚠️ Background execution requires the claude-flow-swarm-bg script.`);
|
|
1175
|
+
console.log(`\nFor true background execution, use:`);
|
|
1176
|
+
console.log(
|
|
1177
|
+
` nohup claude-flow-novice swarm "${objective}" ${Object.entries(flags)
|
|
1178
|
+
.filter(([k, v]) => k !== 'background' && v)
|
|
1179
|
+
.map(([k, v]) => `--${k}${v !== true ? ` ${v}` : ''}`)
|
|
1180
|
+
.join(' ')} > swarm.log 2>&1 &`,
|
|
1181
|
+
);
|
|
1065
1182
|
}
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
try {
|
|
1187
|
+
// Try to load the compiled JavaScript module first
|
|
1188
|
+
let swarmAction;
|
|
1066
1189
|
try {
|
|
1067
|
-
|
|
1068
|
-
|
|
1190
|
+
// Try the compiled version first (for production/npm packages)
|
|
1191
|
+
const distPath = new URL('../../../dist/cli/commands/swarm-new.js', import.meta.url);
|
|
1192
|
+
const module = await import(distPath);
|
|
1193
|
+
swarmAction = module.swarmAction;
|
|
1194
|
+
} catch (distError) {
|
|
1195
|
+
// Instead of immediately falling back to basic mode,
|
|
1196
|
+
// continue to the Claude integration below
|
|
1197
|
+
console.log('📦 Compiled swarm module not found, checking for Claude CLI...');
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// Only call swarmAction if it was successfully loaded
|
|
1201
|
+
if (swarmAction) {
|
|
1202
|
+
// Create command context compatible with TypeScript version
|
|
1203
|
+
const ctx = {
|
|
1204
|
+
args: args || [],
|
|
1205
|
+
flags: flags || {},
|
|
1206
|
+
command: 'swarm',
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
await swarmAction(ctx);
|
|
1210
|
+
return; // Exit after successful execution
|
|
1211
|
+
}
|
|
1212
|
+
} catch (error) {
|
|
1213
|
+
// If import fails (e.g., in node_modules), provide inline implementation
|
|
1214
|
+
if (
|
|
1215
|
+
error.code === 'ERR_MODULE_NOT_FOUND' ||
|
|
1216
|
+
error.code === 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING' ||
|
|
1217
|
+
error.code === 'ERR_UNKNOWN_FILE_EXTENSION'
|
|
1218
|
+
) {
|
|
1219
|
+
// Provide a basic swarm implementation that works without TypeScript imports
|
|
1220
|
+
const objective = (args || []).join(' ').trim();
|
|
1221
|
+
|
|
1222
|
+
if (!objective) {
|
|
1223
|
+
console.error('❌ Usage: swarm <objective>');
|
|
1224
|
+
showSwarmHelp();
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
// Try to use the swarm executor directly
|
|
1229
|
+
try {
|
|
1230
|
+
const { executeSwarm } = await import('./swarm-executor.js');
|
|
1231
|
+
const result = await executeSwarm(objective, flags);
|
|
1232
|
+
|
|
1233
|
+
// If execution was successful, exit
|
|
1234
|
+
if (result && result.success) {
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
} catch (execError) {
|
|
1238
|
+
console.log(`⚠️ Swarm executor error: ${execError.message}`);
|
|
1239
|
+
// If swarm executor fails, try to create files directly
|
|
1069
1240
|
try {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
// Instead of immediately falling back to basic mode,
|
|
1076
|
-
// continue to the Claude integration below
|
|
1077
|
-
console.log('📦 Compiled swarm module not found, checking for Claude CLI...');
|
|
1241
|
+
await createSwarmFiles(objective, flags);
|
|
1242
|
+
return;
|
|
1243
|
+
} catch (createError) {
|
|
1244
|
+
console.log(`⚠️ Direct file creation error: ${createError.message}`);
|
|
1245
|
+
// Continue with fallback implementation
|
|
1078
1246
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
// Provide a basic inline swarm implementation for npm packages
|
|
1250
|
+
console.log('🐝 Launching swarm system...');
|
|
1251
|
+
console.log(`📋 Objective: ${objective}`);
|
|
1252
|
+
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
|
1253
|
+
console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`);
|
|
1254
|
+
console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`);
|
|
1255
|
+
console.log();
|
|
1256
|
+
|
|
1257
|
+
// Generate swarm ID
|
|
1258
|
+
const swarmId = `swarm_${Math.random().toString(36).substring(2, 11)}_${Math.random().toString(36).substring(2, 11)}`;
|
|
1259
|
+
|
|
1260
|
+
if (flags['dry-run']) {
|
|
1261
|
+
console.log(`🆔 Swarm ID: ${swarmId}`);
|
|
1262
|
+
console.log(`📊 Max Tasks: ${flags['max-tasks'] || 100}`);
|
|
1263
|
+
console.log(`⏰ Timeout: ${flags.timeout || 60} minutes`);
|
|
1264
|
+
console.log(`🔄 Parallel: ${flags.parallel || false}`);
|
|
1265
|
+
console.log(`🌐 Distributed: ${flags.distributed || false}`);
|
|
1266
|
+
console.log(`🔍 Monitoring: ${flags.monitor || false}`);
|
|
1267
|
+
console.log(`👥 Review Mode: ${flags.review || false}`);
|
|
1268
|
+
console.log(`🧪 Testing: ${flags.testing || false}`);
|
|
1269
|
+
console.log(`🧠 Memory Namespace: ${flags['memory-namespace'] || 'swarm'}`);
|
|
1270
|
+
console.log(`💾 Persistence: ${flags.persistence !== false}`);
|
|
1271
|
+
console.log(`🔒 Encryption: ${flags.encryption || false}`);
|
|
1272
|
+
console.log(`📊 Quality Threshold: ${flags['quality-threshold'] || 0.8}`);
|
|
1273
|
+
console.log();
|
|
1274
|
+
console.log('🎛️ Coordination Strategy:');
|
|
1275
|
+
console.log(` • Agent Selection: ${flags['agent-selection'] || 'capability-based'}`);
|
|
1276
|
+
console.log(` • Task Scheduling: ${flags['task-scheduling'] || 'priority'}`);
|
|
1277
|
+
console.log(` • Load Balancing: ${flags['load-balancing'] || 'work-stealing'}`);
|
|
1278
|
+
console.log(` • Fault Tolerance: ${flags['fault-tolerance'] || 'retry'}`);
|
|
1279
|
+
console.log(` • Communication: ${flags.communication || 'event-driven'}`);
|
|
1280
|
+
console.log('⚠️ DRY RUN - Advanced Swarm Configuration');
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
// For actual execution in npm context, try to find and run swarm-demo.ts
|
|
1285
|
+
try {
|
|
1286
|
+
const path = await import('path');
|
|
1287
|
+
const { fileURLToPath } = await import('url');
|
|
1288
|
+
const fs = await import('fs');
|
|
1289
|
+
const { spawn } = await import('child_process');
|
|
1290
|
+
|
|
1291
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
1292
|
+
const __dirname = path.dirname(__filename);
|
|
1293
|
+
|
|
1294
|
+
// Look for swarm-demo.ts in the package
|
|
1295
|
+
const possiblePaths = [
|
|
1296
|
+
path.join(__dirname, '../../../swarm-demo.ts'),
|
|
1297
|
+
path.join(__dirname, '../../swarm-demo.ts'),
|
|
1298
|
+
];
|
|
1299
|
+
|
|
1300
|
+
let swarmDemoPath = null;
|
|
1301
|
+
for (const p of possiblePaths) {
|
|
1302
|
+
if (fs.existsSync(p)) {
|
|
1303
|
+
swarmDemoPath = p;
|
|
1304
|
+
break;
|
|
1305
|
+
}
|
|
1089
1306
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
return;
|
|
1099
|
-
}
|
|
1100
|
-
// Try to use the swarm executor directly
|
|
1101
|
-
try {
|
|
1102
|
-
const { executeSwarm } = await import("./swarm-executor.js");
|
|
1103
|
-
const result = await executeSwarm(objective, flags);
|
|
1104
|
-
// If execution was successful, exit
|
|
1105
|
-
if (result && result.success) {
|
|
1106
|
-
return;
|
|
1107
|
-
}
|
|
1108
|
-
} catch (execError) {
|
|
1109
|
-
console.log(`⚠️ Swarm executor error: ${execError.message}`);
|
|
1110
|
-
// If swarm executor fails, try to create files directly
|
|
1111
|
-
try {
|
|
1112
|
-
await createSwarmFiles(objective, flags);
|
|
1113
|
-
return;
|
|
1114
|
-
} catch (createError) {
|
|
1115
|
-
console.log(`⚠️ Direct file creation error: ${createError.message}`);
|
|
1116
|
-
// Continue with fallback implementation
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
// Provide a basic inline swarm implementation for npm packages
|
|
1120
|
-
console.log('🐝 Launching swarm system...');
|
|
1121
|
-
console.log(`📋 Objective: ${objective}`);
|
|
1122
|
-
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
|
1123
|
-
console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`);
|
|
1124
|
-
console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`);
|
|
1125
|
-
console.log();
|
|
1126
|
-
// Generate swarm ID
|
|
1127
|
-
const swarmId = `swarm_${Math.random().toString(36).substring(2, 11)}_${Math.random().toString(36).substring(2, 11)}`;
|
|
1128
|
-
if (flags['dry-run']) {
|
|
1129
|
-
console.log(`🆔 Swarm ID: ${swarmId}`);
|
|
1130
|
-
console.log(`📊 Max Tasks: ${flags['max-tasks'] || 100}`);
|
|
1131
|
-
console.log(`⏰ Timeout: ${flags.timeout || 60} minutes`);
|
|
1132
|
-
console.log(`🔄 Parallel: ${flags.parallel || false}`);
|
|
1133
|
-
console.log(`🌐 Distributed: ${flags.distributed || false}`);
|
|
1134
|
-
console.log(`🔍 Monitoring: ${flags.monitor || false}`);
|
|
1135
|
-
console.log(`👥 Review Mode: ${flags.review || false}`);
|
|
1136
|
-
console.log(`🧪 Testing: ${flags.testing || false}`);
|
|
1137
|
-
console.log(`🧠 Memory Namespace: ${flags['memory-namespace'] || 'swarm'}`);
|
|
1138
|
-
console.log(`💾 Persistence: ${flags.persistence !== false}`);
|
|
1139
|
-
console.log(`🔒 Encryption: ${flags.encryption || false}`);
|
|
1140
|
-
console.log(`📊 Quality Threshold: ${flags['quality-threshold'] || 0.8}`);
|
|
1141
|
-
console.log();
|
|
1142
|
-
console.log('🎛️ Coordination Strategy:');
|
|
1143
|
-
console.log(` • Agent Selection: ${flags['agent-selection'] || 'capability-based'}`);
|
|
1144
|
-
console.log(` • Task Scheduling: ${flags['task-scheduling'] || 'priority'}`);
|
|
1145
|
-
console.log(` • Load Balancing: ${flags['load-balancing'] || 'work-stealing'}`);
|
|
1146
|
-
console.log(` • Fault Tolerance: ${flags['fault-tolerance'] || 'retry'}`);
|
|
1147
|
-
console.log(` • Communication: ${flags.communication || 'event-driven'}`);
|
|
1148
|
-
console.log('⚠️ DRY RUN - Advanced Swarm Configuration');
|
|
1149
|
-
return;
|
|
1307
|
+
|
|
1308
|
+
if (swarmDemoPath && Deno) {
|
|
1309
|
+
// Run swarm-demo.ts directly with Deno
|
|
1310
|
+
const swarmArgs = [objective];
|
|
1311
|
+
for (const [key, value] of Object.entries(flags || {})) {
|
|
1312
|
+
swarmArgs.push(`--${key}`);
|
|
1313
|
+
if (value !== true) {
|
|
1314
|
+
swarmArgs.push(String(value));
|
|
1150
1315
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
for (const p of possiblePaths){
|
|
1166
|
-
if (fs.existsSync(p)) {
|
|
1167
|
-
swarmDemoPath = p;
|
|
1168
|
-
break;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
if (swarmDemoPath && Deno) {
|
|
1172
|
-
// Run swarm-demo.ts directly with Deno
|
|
1173
|
-
const swarmArgs = [
|
|
1174
|
-
objective
|
|
1175
|
-
];
|
|
1176
|
-
for (const [key, value] of Object.entries(flags || {})){
|
|
1177
|
-
swarmArgs.push(`--${key}`);
|
|
1178
|
-
if (value !== true) {
|
|
1179
|
-
swarmArgs.push(String(value));
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
console.log('🚀 Starting advanced swarm execution...');
|
|
1183
|
-
const swarmProcess = spawn('node', [
|
|
1184
|
-
swarmDemoPath,
|
|
1185
|
-
...swarmArgs
|
|
1186
|
-
], {
|
|
1187
|
-
stdio: 'inherit'
|
|
1188
|
-
});
|
|
1189
|
-
swarmProcess.on('error', (err)=>{
|
|
1190
|
-
console.error('❌ Failed to launch swarm:', err.message);
|
|
1191
|
-
});
|
|
1192
|
-
swarmProcess.on('exit', (code)=>{
|
|
1193
|
-
if (code !== 0) {
|
|
1194
|
-
console.error(`❌ Swarm exited with code ${code}`);
|
|
1195
|
-
}
|
|
1196
|
-
});
|
|
1197
|
-
return;
|
|
1198
|
-
}
|
|
1199
|
-
} catch (e) {
|
|
1200
|
-
// Fallback to basic message if can't run swarm-demo.ts
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
console.log('🚀 Starting advanced swarm execution...');
|
|
1319
|
+
const swarmProcess = spawn('node', [swarmDemoPath, ...swarmArgs], {
|
|
1320
|
+
stdio: 'inherit',
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
swarmProcess.on('error', (err) => {
|
|
1324
|
+
console.error('❌ Failed to launch swarm:', err.message);
|
|
1325
|
+
});
|
|
1326
|
+
|
|
1327
|
+
swarmProcess.on('exit', (code) => {
|
|
1328
|
+
if (code !== 0) {
|
|
1329
|
+
console.error(`❌ Swarm exited with code ${code}`);
|
|
1201
1330
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1331
|
+
});
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
} catch (e) {
|
|
1335
|
+
// Fallback to basic message if can't run swarm-demo.ts
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// Try to use Claude wrapper approach like SPARC does
|
|
1339
|
+
try {
|
|
1340
|
+
const { execSync } = await import('child_process');
|
|
1341
|
+
|
|
1342
|
+
// Check if claude command exists
|
|
1343
|
+
try {
|
|
1344
|
+
execSync('which claude', { stdio: 'ignore' });
|
|
1345
|
+
} catch (e) {
|
|
1346
|
+
// Claude not found, show fallback message
|
|
1347
|
+
console.log(`✅ Swarm initialized with ID: ${swarmId}`);
|
|
1348
|
+
console.log('\n⚠️ Note: Advanced swarm features require Claude or local installation.');
|
|
1349
|
+
console.log('Install Claude: https://claude.ai/code');
|
|
1350
|
+
console.log('Or install locally: npm install -g claude-flow@latest');
|
|
1351
|
+
console.log('\nThe swarm system would coordinate the following:');
|
|
1352
|
+
console.log('1. Agent spawning and task distribution');
|
|
1353
|
+
console.log('2. Parallel execution of subtasks');
|
|
1354
|
+
console.log('3. Memory sharing between agents');
|
|
1355
|
+
console.log('4. Progress monitoring and reporting');
|
|
1356
|
+
console.log('5. Result aggregation and quality checks');
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// Claude is available, use it to run swarm
|
|
1361
|
+
console.log('🚀 Launching swarm via Claude wrapper...');
|
|
1362
|
+
if (flags.sparc !== false) {
|
|
1363
|
+
console.log('🧪 SPARC methodology enabled - using full TDD workflow');
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
// Build the prompt for Claude using SPARC methodology
|
|
1367
|
+
const enableSparc = flags.sparc !== false;
|
|
1368
|
+
const swarmPrompt = `Execute a swarm coordination task using ${enableSparc ? 'the full SPARC methodology' : 'standard approach'}:
|
|
1232
1369
|
|
|
1233
1370
|
OBJECTIVE: ${objective}
|
|
1234
1371
|
|
|
@@ -1240,7 +1377,9 @@ CONFIGURATION:
|
|
|
1240
1377
|
- Quality Threshold: ${flags['quality-threshold'] || 0.8}
|
|
1241
1378
|
${enableSparc ? '- SPARC Enabled: YES - Use full Specification, Pseudocode, Architecture, Refinement (TDD), Completion methodology' : ''}
|
|
1242
1379
|
|
|
1243
|
-
${
|
|
1380
|
+
${
|
|
1381
|
+
enableSparc
|
|
1382
|
+
? `
|
|
1244
1383
|
SPARC METHODOLOGY REQUIREMENTS:
|
|
1245
1384
|
|
|
1246
1385
|
1. SPECIFICATION PHASE:
|
|
@@ -1272,7 +1411,9 @@ SPARC METHODOLOGY REQUIREMENTS:
|
|
|
1272
1411
|
- Create comprehensive documentation
|
|
1273
1412
|
- Perform end-to-end testing
|
|
1274
1413
|
- Validate against original requirements
|
|
1275
|
-
`
|
|
1414
|
+
`
|
|
1415
|
+
: ''
|
|
1416
|
+
}
|
|
1276
1417
|
|
|
1277
1418
|
EXECUTION APPROACH:
|
|
1278
1419
|
1. Analyze the objective and break it down into specific tasks
|
|
@@ -1295,56 +1436,62 @@ IMPORTANT:
|
|
|
1295
1436
|
- Make the code production-ready, not just examples
|
|
1296
1437
|
|
|
1297
1438
|
Begin execution now. Create all necessary files and provide a complete, working solution.`;
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
stdio: [
|
|
1308
|
-
'pipe',
|
|
1309
|
-
'inherit',
|
|
1310
|
-
'inherit'
|
|
1311
|
-
],
|
|
1312
|
-
shell: false
|
|
1313
|
-
});
|
|
1314
|
-
// Write the prompt to stdin and close it
|
|
1315
|
-
claudeProcess.stdin.write(swarmPrompt);
|
|
1316
|
-
claudeProcess.stdin.end();
|
|
1317
|
-
// Wait for the process to complete
|
|
1318
|
-
await new Promise((resolve, reject)=>{
|
|
1319
|
-
claudeProcess.on('close', (code)=>{
|
|
1320
|
-
if (code === 0) {
|
|
1321
|
-
resolve();
|
|
1322
|
-
} else {
|
|
1323
|
-
reject(new Error(`Claude process exited with code ${code}`));
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
claudeProcess.on('error', (err)=>{
|
|
1327
|
-
reject(err);
|
|
1328
|
-
});
|
|
1329
|
-
});
|
|
1330
|
-
} catch (error) {
|
|
1331
|
-
// Fallback if Claude execution fails
|
|
1332
|
-
console.log(`✅ Swarm initialized with ID: ${swarmId}`);
|
|
1333
|
-
console.log('\n⚠️ Note: Advanced swarm features require Claude or local installation.');
|
|
1334
|
-
console.log('Install Claude: https://claude.ai/code');
|
|
1335
|
-
console.log('Or install locally: npm install -g claude-flow@latest');
|
|
1336
|
-
console.log('\nThe swarm system would coordinate the following:');
|
|
1337
|
-
console.log('1. Agent spawning and task distribution');
|
|
1338
|
-
console.log('2. Parallel execution of subtasks');
|
|
1339
|
-
console.log('3. Memory sharing between agents');
|
|
1340
|
-
console.log('4. Progress monitoring and reporting');
|
|
1341
|
-
console.log('5. Result aggregation and quality checks');
|
|
1342
|
-
}
|
|
1343
|
-
return;
|
|
1439
|
+
|
|
1440
|
+
// Execute Claude non-interactively by piping the prompt
|
|
1441
|
+
const { spawn } = await import('child_process');
|
|
1442
|
+
|
|
1443
|
+
const claudeArgs = [];
|
|
1444
|
+
|
|
1445
|
+
// Add auto-permission flag by default for swarm mode (unless explicitly disabled)
|
|
1446
|
+
if (flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions']) {
|
|
1447
|
+
claudeArgs.push('--dangerously-skip-permissions');
|
|
1344
1448
|
}
|
|
1345
|
-
|
|
1346
|
-
//
|
|
1347
|
-
|
|
1449
|
+
|
|
1450
|
+
// Spawn claude process
|
|
1451
|
+
const claudeProcess = spawn('claude', claudeArgs, {
|
|
1452
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
1453
|
+
shell: false,
|
|
1454
|
+
});
|
|
1455
|
+
|
|
1456
|
+
// Write the prompt to stdin and close it
|
|
1457
|
+
claudeProcess.stdin.write(swarmPrompt);
|
|
1458
|
+
claudeProcess.stdin.end();
|
|
1459
|
+
|
|
1460
|
+
// Wait for the process to complete
|
|
1461
|
+
await new Promise((resolve, reject) => {
|
|
1462
|
+
claudeProcess.on('close', (code) => {
|
|
1463
|
+
if (code === 0) {
|
|
1464
|
+
resolve();
|
|
1465
|
+
} else {
|
|
1466
|
+
reject(new Error(`Claude process exited with code ${code}`));
|
|
1467
|
+
}
|
|
1468
|
+
});
|
|
1469
|
+
|
|
1470
|
+
claudeProcess.on('error', (err) => {
|
|
1471
|
+
reject(err);
|
|
1472
|
+
});
|
|
1473
|
+
});
|
|
1474
|
+
} catch (error) {
|
|
1475
|
+
// Fallback if Claude execution fails
|
|
1476
|
+
console.log(`✅ Swarm initialized with ID: ${swarmId}`);
|
|
1477
|
+
console.log('\n⚠️ Note: Advanced swarm features require Claude or local installation.');
|
|
1478
|
+
console.log('Install Claude: https://claude.ai/code');
|
|
1479
|
+
console.log('Or install locally: npm install -g claude-flow@latest');
|
|
1480
|
+
console.log('\nThe swarm system would coordinate the following:');
|
|
1481
|
+
console.log('1. Agent spawning and task distribution');
|
|
1482
|
+
console.log('2. Parallel execution of subtasks');
|
|
1483
|
+
console.log('3. Memory sharing between agents');
|
|
1484
|
+
console.log('4. Progress monitoring and reporting');
|
|
1485
|
+
console.log('5. Result aggregation and quality checks');
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
console.error('Swarm command error:', error);
|
|
1492
|
+
|
|
1493
|
+
// Fallback to comprehensive help if there's an import error
|
|
1494
|
+
console.log(`
|
|
1348
1495
|
🐝 Claude Flow Advanced Swarm System
|
|
1349
1496
|
|
|
1350
1497
|
USAGE:
|
|
@@ -1421,40 +1568,48 @@ ADVANCED OPTIONS:
|
|
|
1421
1568
|
For complete documentation and examples:
|
|
1422
1569
|
https://github.com/ruvnet/claude-code-flow/docs/swarm.md
|
|
1423
1570
|
`);
|
|
1424
|
-
|
|
1571
|
+
}
|
|
1425
1572
|
}
|
|
1573
|
+
|
|
1426
1574
|
// Function to create swarm files directly
|
|
1427
1575
|
async function createSwarmFiles(objective, flags) {
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1576
|
+
const fs = await import('fs');
|
|
1577
|
+
const path = await import('path');
|
|
1578
|
+
|
|
1579
|
+
const swarmId = `swarm_${Math.random().toString(36).substring(2, 11)}_${Math.random().toString(36).substring(2, 11)}`;
|
|
1580
|
+
|
|
1581
|
+
console.log(`🐝 Swarm Execution Started: ${swarmId}`);
|
|
1582
|
+
console.log(`📋 Objective: ${objective}`);
|
|
1583
|
+
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
|
1584
|
+
|
|
1585
|
+
// Extract target directory from objective
|
|
1586
|
+
const targetMatch = objective.match(/in\s+([^\s]+)\/?$/i);
|
|
1587
|
+
let targetDir = targetMatch ? targetMatch[1] : 'output';
|
|
1588
|
+
|
|
1589
|
+
// Resolve relative paths
|
|
1590
|
+
if (!targetDir.startsWith('/')) {
|
|
1591
|
+
targetDir = path.join(process.cwd(), targetDir);
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
console.log(`📁 Target directory: ${targetDir}`);
|
|
1595
|
+
|
|
1596
|
+
// Ensure target directory exists
|
|
1597
|
+
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
1598
|
+
|
|
1599
|
+
// Determine what to build based on objective
|
|
1600
|
+
const isRestAPI =
|
|
1601
|
+
objective.toLowerCase().includes('rest api') || objective.toLowerCase().includes('api');
|
|
1602
|
+
|
|
1603
|
+
if (isRestAPI) {
|
|
1604
|
+
// Create REST API
|
|
1605
|
+
const apiDir = path.join(targetDir, 'rest-api');
|
|
1606
|
+
await fs.promises.mkdir(apiDir, { recursive: true });
|
|
1607
|
+
|
|
1608
|
+
console.log(`\n🏗️ Creating REST API...`);
|
|
1609
|
+
console.log(` 🤖 Agent developer-1: Creating server implementation`);
|
|
1610
|
+
|
|
1611
|
+
// Create server.js
|
|
1612
|
+
const serverCode = `const express = require('express');
|
|
1458
1613
|
const app = express();
|
|
1459
1614
|
const port = process.env.PORT || 3000;
|
|
1460
1615
|
|
|
@@ -1509,45 +1664,47 @@ app.listen(port, () => {
|
|
|
1509
1664
|
|
|
1510
1665
|
module.exports = app;
|
|
1511
1666
|
`;
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1667
|
+
|
|
1668
|
+
await fs.promises.writeFile(path.join(apiDir, 'server.js'), serverCode);
|
|
1669
|
+
console.log(` ✅ Created: server.js`);
|
|
1670
|
+
|
|
1671
|
+
// Create package.json
|
|
1672
|
+
const packageJson = {
|
|
1673
|
+
name: 'rest-api',
|
|
1674
|
+
version: '1.0.0',
|
|
1675
|
+
description: 'REST API created by Claude Flow Swarm',
|
|
1676
|
+
main: 'server.js',
|
|
1677
|
+
scripts: {
|
|
1678
|
+
start: 'node server.js',
|
|
1679
|
+
dev: 'nodemon server.js',
|
|
1680
|
+
test: 'jest',
|
|
1681
|
+
},
|
|
1682
|
+
keywords: ['rest', 'api', 'swarm', 'claude-flow'],
|
|
1683
|
+
author: 'Claude Flow Swarm',
|
|
1684
|
+
license: 'MIT',
|
|
1685
|
+
dependencies: {
|
|
1686
|
+
express: '^4.18.2',
|
|
1687
|
+
},
|
|
1688
|
+
devDependencies: {
|
|
1689
|
+
nodemon: '^3.0.1',
|
|
1690
|
+
jest: '^29.7.0',
|
|
1691
|
+
supertest: '^6.3.3',
|
|
1692
|
+
},
|
|
1693
|
+
swarmMetadata: {
|
|
1694
|
+
swarmId,
|
|
1695
|
+
strategy: flags.strategy || 'development',
|
|
1696
|
+
created: new Date().toISOString(),
|
|
1697
|
+
},
|
|
1698
|
+
};
|
|
1699
|
+
|
|
1700
|
+
await fs.promises.writeFile(
|
|
1701
|
+
path.join(apiDir, 'package.json'),
|
|
1702
|
+
JSON.stringify(packageJson, null, 2),
|
|
1703
|
+
);
|
|
1704
|
+
console.log(` ✅ Created: package.json`);
|
|
1705
|
+
|
|
1706
|
+
// Create README
|
|
1707
|
+
const readme = `# REST API
|
|
1551
1708
|
|
|
1552
1709
|
This REST API was created by the Claude Flow Swarm system.
|
|
1553
1710
|
|
|
@@ -1579,15 +1736,18 @@ npm start
|
|
|
1579
1736
|
---
|
|
1580
1737
|
Created by Claude Flow Swarm
|
|
1581
1738
|
`;
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1739
|
+
|
|
1740
|
+
await fs.promises.writeFile(path.join(apiDir, 'README.md'), readme);
|
|
1741
|
+
console.log(` ✅ Created: README.md`);
|
|
1742
|
+
|
|
1743
|
+
console.log(`\n✅ Swarm completed successfully!`);
|
|
1744
|
+
console.log(`📁 Files created in: ${apiDir}`);
|
|
1745
|
+
console.log(`🆔 Swarm ID: ${swarmId}`);
|
|
1746
|
+
} else {
|
|
1747
|
+
// Create generic application
|
|
1748
|
+
console.log(`\n🏗️ Creating application...`);
|
|
1749
|
+
|
|
1750
|
+
const appCode = `// Application created by Claude Flow Swarm
|
|
1591
1751
|
// Objective: ${objective}
|
|
1592
1752
|
// Swarm ID: ${swarmId}
|
|
1593
1753
|
|
|
@@ -1598,34 +1758,43 @@ function main() {
|
|
|
1598
1758
|
|
|
1599
1759
|
main();
|
|
1600
1760
|
`;
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1761
|
+
|
|
1762
|
+
await fs.promises.writeFile(path.join(targetDir, 'app.js'), appCode);
|
|
1763
|
+
console.log(` ✅ Created: app.js`);
|
|
1764
|
+
|
|
1765
|
+
const packageJson = {
|
|
1766
|
+
name: 'swarm-app',
|
|
1767
|
+
version: '1.0.0',
|
|
1768
|
+
description: `Application created by Claude Flow Swarm: ${objective}`,
|
|
1769
|
+
main: 'app.js',
|
|
1770
|
+
scripts: {
|
|
1771
|
+
start: 'node app.js',
|
|
1772
|
+
},
|
|
1773
|
+
swarmMetadata: {
|
|
1774
|
+
swarmId,
|
|
1775
|
+
objective,
|
|
1776
|
+
created: new Date().toISOString(),
|
|
1777
|
+
},
|
|
1778
|
+
};
|
|
1779
|
+
|
|
1780
|
+
await fs.promises.writeFile(
|
|
1781
|
+
path.join(targetDir, 'package.json'),
|
|
1782
|
+
JSON.stringify(packageJson, null, 2),
|
|
1783
|
+
);
|
|
1784
|
+
console.log(` ✅ Created: package.json`);
|
|
1785
|
+
|
|
1786
|
+
console.log(`\n✅ Swarm completed successfully!`);
|
|
1787
|
+
console.log(`📁 Files created in: ${targetDir}`);
|
|
1788
|
+
console.log(`🆔 Swarm ID: ${swarmId}`);
|
|
1789
|
+
}
|
|
1623
1790
|
}
|
|
1791
|
+
|
|
1624
1792
|
/**
|
|
1625
1793
|
* Get strategy-specific guidance for swarm execution
|
|
1626
|
-
*/
|
|
1627
|
-
|
|
1628
|
-
|
|
1794
|
+
*/
|
|
1795
|
+
function getStrategyGuidance(strategy, objective) {
|
|
1796
|
+
const guidanceMap = {
|
|
1797
|
+
auto: `🤖 AUTO STRATEGY - INTELLIGENT TASK ANALYSIS:
|
|
1629
1798
|
The swarm will analyze "${objective}" and automatically determine the best approach.
|
|
1630
1799
|
|
|
1631
1800
|
ANALYSIS APPROACH:
|
|
@@ -1639,7 +1808,8 @@ MCP TOOL PATTERN:
|
|
|
1639
1808
|
- Use task_create to build a hierarchical task structure
|
|
1640
1809
|
- Spawn agents with agent_spawn based on detected requirements
|
|
1641
1810
|
- Monitor with swarm_monitor and adjust strategy as needed`,
|
|
1642
|
-
|
|
1811
|
+
|
|
1812
|
+
research: `🔬 RESEARCH STRATEGY - INFORMATION GATHERING & ANALYSIS:
|
|
1643
1813
|
Optimized for: "${objective}"
|
|
1644
1814
|
|
|
1645
1815
|
RESEARCH PHASES:
|
|
@@ -1659,7 +1829,8 @@ MCP TOOL USAGE:
|
|
|
1659
1829
|
- memory_search: Find related information across research
|
|
1660
1830
|
- agent_communicate: Share discoveries between researchers
|
|
1661
1831
|
- task_create: Break research into focused sub-investigations`,
|
|
1662
|
-
|
|
1832
|
+
|
|
1833
|
+
development: `💻 DEVELOPMENT STRATEGY - SOFTWARE CREATION:
|
|
1663
1834
|
Building: "${objective}"
|
|
1664
1835
|
|
|
1665
1836
|
DEVELOPMENT WORKFLOW:
|
|
@@ -1681,7 +1852,8 @@ MCP TOOL USAGE:
|
|
|
1681
1852
|
- task_create: Create implementation tasks with dependencies
|
|
1682
1853
|
- agent_assign: Assign specific components to developers
|
|
1683
1854
|
- swarm_monitor: Track build progress and blockers`,
|
|
1684
|
-
|
|
1855
|
+
|
|
1856
|
+
analysis: `📊 ANALYSIS STRATEGY - DATA EXAMINATION:
|
|
1685
1857
|
Analyzing: "${objective}"
|
|
1686
1858
|
|
|
1687
1859
|
ANALYSIS FRAMEWORK:
|
|
@@ -1703,7 +1875,8 @@ MCP TOOL USAGE:
|
|
|
1703
1875
|
- memory_retrieve: Access historical analysis
|
|
1704
1876
|
- task_create: Define analysis pipelines
|
|
1705
1877
|
- agent_coordinate: Sync analysis phases`,
|
|
1706
|
-
|
|
1878
|
+
|
|
1879
|
+
testing: `🧪 TESTING STRATEGY - QUALITY ASSURANCE:
|
|
1707
1880
|
Testing: "${objective}"
|
|
1708
1881
|
|
|
1709
1882
|
TESTING PHASES:
|
|
@@ -1725,7 +1898,8 @@ MCP TOOL USAGE:
|
|
|
1725
1898
|
- memory_store: Save test results and bug reports
|
|
1726
1899
|
- agent_communicate: Report bugs to developers
|
|
1727
1900
|
- swarm_monitor: Track testing coverage and progress`,
|
|
1728
|
-
|
|
1901
|
+
|
|
1902
|
+
optimization: `⚡ OPTIMIZATION STRATEGY - PERFORMANCE IMPROVEMENT:
|
|
1729
1903
|
Optimizing: "${objective}"
|
|
1730
1904
|
|
|
1731
1905
|
OPTIMIZATION PROCESS:
|
|
@@ -1747,7 +1921,8 @@ MCP TOOL USAGE:
|
|
|
1747
1921
|
- task_create: Create optimization tasks by priority
|
|
1748
1922
|
- swarm_monitor: Track performance improvements
|
|
1749
1923
|
- agent_communicate: Coordinate optimization efforts`,
|
|
1750
|
-
|
|
1924
|
+
|
|
1925
|
+
maintenance: `🔧 MAINTENANCE STRATEGY - SYSTEM UPKEEP:
|
|
1751
1926
|
Maintaining: "${objective}"
|
|
1752
1927
|
|
|
1753
1928
|
MAINTENANCE WORKFLOW:
|
|
@@ -1768,15 +1943,18 @@ MCP TOOL USAGE:
|
|
|
1768
1943
|
- memory_retrieve: Access system history
|
|
1769
1944
|
- task_create: Schedule maintenance tasks
|
|
1770
1945
|
- agent_assign: Delegate specific updates
|
|
1771
|
-
- memory_store: Document all changes
|
|
1772
|
-
|
|
1773
|
-
|
|
1946
|
+
- memory_store: Document all changes`,
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
return guidanceMap[strategy] || guidanceMap['auto'];
|
|
1774
1950
|
}
|
|
1951
|
+
|
|
1775
1952
|
/**
|
|
1776
1953
|
* Get mode-specific guidance for coordination
|
|
1777
|
-
*/
|
|
1778
|
-
|
|
1779
|
-
|
|
1954
|
+
*/
|
|
1955
|
+
function getModeGuidance(mode) {
|
|
1956
|
+
const modeMap = {
|
|
1957
|
+
centralized: `🎯 CENTRALIZED MODE - SINGLE COORDINATOR:
|
|
1780
1958
|
All decisions flow through one coordinator agent.
|
|
1781
1959
|
|
|
1782
1960
|
COORDINATION PATTERN:
|
|
@@ -1796,7 +1974,8 @@ BEST FOR:
|
|
|
1796
1974
|
- Small to medium projects
|
|
1797
1975
|
- Well-defined objectives
|
|
1798
1976
|
- Clear task dependencies`,
|
|
1799
|
-
|
|
1977
|
+
|
|
1978
|
+
distributed: `🌐 DISTRIBUTED MODE - MULTIPLE COORDINATORS:
|
|
1800
1979
|
Multiple coordinators share responsibility by domain.
|
|
1801
1980
|
|
|
1802
1981
|
COORDINATION PATTERN:
|
|
@@ -1817,7 +1996,8 @@ BEST FOR:
|
|
|
1817
1996
|
- Multiple workstreams
|
|
1818
1997
|
- Complex systems
|
|
1819
1998
|
- High availability needs`,
|
|
1820
|
-
|
|
1999
|
+
|
|
2000
|
+
hierarchical: `🏗️ HIERARCHICAL MODE - TREE STRUCTURE:
|
|
1821
2001
|
Agents organized in management layers.
|
|
1822
2002
|
|
|
1823
2003
|
COORDINATION PATTERN:
|
|
@@ -1838,7 +2018,8 @@ BEST FOR:
|
|
|
1838
2018
|
- Multi-team efforts
|
|
1839
2019
|
- Complex hierarchies
|
|
1840
2020
|
- Phased deliveries`,
|
|
1841
|
-
|
|
2021
|
+
|
|
2022
|
+
mesh: `🔗 MESH MODE - PEER-TO-PEER:
|
|
1842
2023
|
Agents coordinate directly without central authority.
|
|
1843
2024
|
|
|
1844
2025
|
COORDINATION PATTERN:
|
|
@@ -1859,7 +2040,8 @@ BEST FOR:
|
|
|
1859
2040
|
- Exploratory work
|
|
1860
2041
|
- Innovation tasks
|
|
1861
2042
|
- Small expert teams`,
|
|
1862
|
-
|
|
2043
|
+
|
|
2044
|
+
hybrid: `🎨 HYBRID MODE - MIXED STRATEGIES:
|
|
1863
2045
|
Combine different coordination patterns as needed.
|
|
1864
2046
|
|
|
1865
2047
|
COORDINATION PATTERN:
|
|
@@ -1878,15 +2060,18 @@ BEST FOR:
|
|
|
1878
2060
|
- Complex projects
|
|
1879
2061
|
- Uncertain requirements
|
|
1880
2062
|
- Long-term efforts
|
|
1881
|
-
- Diverse objectives
|
|
1882
|
-
|
|
1883
|
-
|
|
2063
|
+
- Diverse objectives`,
|
|
2064
|
+
};
|
|
2065
|
+
|
|
2066
|
+
return modeMap[mode] || modeMap['centralized'];
|
|
1884
2067
|
}
|
|
2068
|
+
|
|
1885
2069
|
/**
|
|
1886
2070
|
* Get agent recommendations based on strategy
|
|
1887
|
-
*/
|
|
1888
|
-
|
|
1889
|
-
|
|
2071
|
+
*/
|
|
2072
|
+
function getAgentRecommendations(strategy, maxAgents, objective) {
|
|
2073
|
+
const recommendations = {
|
|
2074
|
+
auto: `
|
|
1890
2075
|
🤖 RECOMMENDED AGENT COMPOSITION (Auto-detected):
|
|
1891
2076
|
⚡ SPAWN ALL AGENTS IN ONE BATCH - Copy this entire block:
|
|
1892
2077
|
|
|
@@ -1905,7 +2090,8 @@ BEST FOR:
|
|
|
1905
2090
|
{"id": "4", "content": "Spawn additional agents as needed", "status": "pending", "priority": "medium"}
|
|
1906
2091
|
]}
|
|
1907
2092
|
\`\`\``,
|
|
1908
|
-
|
|
2093
|
+
|
|
2094
|
+
research: `
|
|
1909
2095
|
🔬 RECOMMENDED RESEARCH AGENTS:
|
|
1910
2096
|
⚡ SPAWN ALL AGENTS IN ONE BATCH - Copy this entire block:
|
|
1911
2097
|
|
|
@@ -1929,7 +2115,8 @@ BEST FOR:
|
|
|
1929
2115
|
{"id": "5", "content": "Compile and synthesize insights", "status": "pending", "priority": "medium"}
|
|
1930
2116
|
]}
|
|
1931
2117
|
\`\`\``,
|
|
1932
|
-
|
|
2118
|
+
|
|
2119
|
+
development: `
|
|
1933
2120
|
💻 RECOMMENDED DEVELOPMENT AGENTS:
|
|
1934
2121
|
⚡ SPAWN ALL AGENTS IN ONE BATCH - Copy this entire block:
|
|
1935
2122
|
|
|
@@ -1953,7 +2140,8 @@ BEST FOR:
|
|
|
1953
2140
|
{"id": "5", "content": "Create comprehensive tests", "status": "pending", "priority": "medium"}
|
|
1954
2141
|
]}
|
|
1955
2142
|
\`\`\``,
|
|
1956
|
-
|
|
2143
|
+
|
|
2144
|
+
analysis: `
|
|
1957
2145
|
📊 RECOMMENDED ANALYSIS AGENTS:
|
|
1958
2146
|
⚡ SPAWN ALL AGENTS IN ONE BATCH - Copy this entire block:
|
|
1959
2147
|
|
|
@@ -1977,7 +2165,8 @@ BEST FOR:
|
|
|
1977
2165
|
{"id": "5", "content": "Generate business insights", "status": "pending", "priority": "medium"}
|
|
1978
2166
|
]}
|
|
1979
2167
|
\`\`\``,
|
|
1980
|
-
|
|
2168
|
+
|
|
2169
|
+
testing: `
|
|
1981
2170
|
🧪 RECOMMENDED TESTING AGENTS:
|
|
1982
2171
|
⚡ SPAWN ALL AGENTS IN ONE BATCH - Copy this entire block:
|
|
1983
2172
|
|
|
@@ -2001,7 +2190,8 @@ BEST FOR:
|
|
|
2001
2190
|
{"id": "5", "content": "Execute security audit", "status": "pending", "priority": "high"}
|
|
2002
2191
|
]}
|
|
2003
2192
|
\`\`\``,
|
|
2004
|
-
|
|
2193
|
+
|
|
2194
|
+
optimization: `
|
|
2005
2195
|
⚡ RECOMMENDED OPTIMIZATION AGENTS:
|
|
2006
2196
|
⚡ SPAWN ALL AGENTS IN ONE BATCH - Copy this entire block:
|
|
2007
2197
|
|
|
@@ -2025,7 +2215,8 @@ BEST FOR:
|
|
|
2025
2215
|
{"id": "5", "content": "Tune system parameters", "status": "pending", "priority": "medium"}
|
|
2026
2216
|
]}
|
|
2027
2217
|
\`\`\``,
|
|
2028
|
-
|
|
2218
|
+
|
|
2219
|
+
maintenance: `
|
|
2029
2220
|
🔧 RECOMMENDED MAINTENANCE AGENTS:
|
|
2030
2221
|
⚡ SPAWN ALL AGENTS IN ONE BATCH - Copy this entire block:
|
|
2031
2222
|
|
|
@@ -2048,35 +2239,39 @@ BEST FOR:
|
|
|
2048
2239
|
{"id": "4", "content": "Run regression tests", "status": "pending", "priority": "high"},
|
|
2049
2240
|
{"id": "5", "content": "Update documentation", "status": "pending", "priority": "medium"}
|
|
2050
2241
|
]}
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2242
|
+
\`\`\``,
|
|
2243
|
+
};
|
|
2244
|
+
|
|
2245
|
+
return recommendations[strategy] || recommendations['auto'];
|
|
2054
2246
|
}
|
|
2247
|
+
|
|
2055
2248
|
// Allow direct execution
|
|
2056
2249
|
if (import.meta.main) {
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2250
|
+
// When called directly as a script, parse all arguments
|
|
2251
|
+
const args = [];
|
|
2252
|
+
const flags = {};
|
|
2253
|
+
|
|
2254
|
+
// Parse arguments and flags
|
|
2255
|
+
for (let i = 0; i < args.length; i++) {
|
|
2256
|
+
const arg = args[i];
|
|
2257
|
+
if (arg.startsWith('--')) {
|
|
2258
|
+
const flagName = arg.substring(2);
|
|
2259
|
+
const nextArg = args[i + 1];
|
|
2260
|
+
|
|
2261
|
+
if (nextArg && !nextArg.startsWith('--')) {
|
|
2262
|
+
flags[flagName] = nextArg;
|
|
2263
|
+
i++; // Skip the next argument
|
|
2264
|
+
} else {
|
|
2265
|
+
flags[flagName] = true;
|
|
2266
|
+
}
|
|
2267
|
+
} else {
|
|
2268
|
+
args.push(arg);
|
|
2075
2269
|
}
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
// The objective is all non-flag arguments joined
|
|
2273
|
+
const objective = args.join(' ');
|
|
2274
|
+
|
|
2275
|
+
// Execute the swarm command
|
|
2276
|
+
await swarmCommand([objective], flags);
|
|
2082
2277
|
}
|