kynjal-cli 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
- package/dist/src/appliance/gguf-engine.js +286 -525
- package/dist/src/appliance/gguf-engine.js.map +1 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +203 -403
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +154 -208
- package/dist/src/appliance/rvfa-builder.js.map +1 -1
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +260 -423
- package/dist/src/appliance/rvfa-distribution.js.map +1 -1
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-format.js +128 -200
- package/dist/src/appliance/rvfa-format.js.map +1 -1
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +168 -304
- package/dist/src/appliance/rvfa-runner.js.map +1 -1
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +173 -295
- package/dist/src/appliance/rvfa-signing.js.map +1 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +331 -542
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.js +574 -697
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1218 -1548
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.js +158 -267
- package/dist/src/commands/appliance-advanced.js.map +1 -1
- package/dist/src/commands/appliance.js +318 -493
- package/dist/src/commands/appliance.js.map +1 -1
- package/dist/src/commands/benchmark.js +372 -523
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +274 -364
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.js +113 -157
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.js +477 -118
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +237 -303
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.js +487 -596
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +194 -275
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.js +504 -686
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1293 -1543
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +449 -596
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +854 -938
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +3112 -3519
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +115 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +126 -308
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.js +788 -940
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +383 -558
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.js +493 -605
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.js +833 -1026
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +282 -347
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.js +1289 -1563
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +497 -643
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +668 -841
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +392 -447
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +162 -256
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +150 -220
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +520 -665
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +505 -651
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +349 -401
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +224 -266
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +37 -75
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +336 -359
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +335 -322
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +375 -431
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +703 -117
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +364 -419
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.js +485 -608
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.js +504 -626
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.js +267 -364
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.js +380 -486
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +408 -488
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.js +423 -538
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +322 -412
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +196 -291
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +386 -486
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +38 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +309 -411
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +246 -507
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +25 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +368 -78
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +1307 -996
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +60 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +657 -12
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.js +33 -37
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.js +76 -77
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.js +801 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +76 -59
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +81 -125
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +161 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +470 -757
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +391 -492
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.js +332 -533
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +172 -236
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
- package/dist/src/mcp-tools/auto-install.js +80 -142
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +252 -375
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +473 -565
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +197 -272
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +500 -572
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +286 -364
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +582 -693
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +260 -311
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +350 -505
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +315 -412
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +420 -480
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +204 -278
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +297 -429
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +185 -234
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +207 -260
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +276 -325
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +270 -336
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +148 -196
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +186 -333
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +405 -450
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts +295 -0
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
- package/dist/src/memory/ewc-consolidation.js +190 -303
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +338 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -0
- package/dist/src/memory/intelligence.js +569 -794
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +407 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge.js +1170 -1640
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +412 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -0
- package/dist/src/memory/memory-initializer.js +1836 -1851
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +227 -0
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
- package/dist/src/memory/sona-optimizer.js +199 -329
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +242 -272
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts +51 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +140 -187
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.d.ts.map +1 -0
- package/dist/src/plugins/manager.js +285 -521
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts +88 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +271 -358
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +48 -105
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +69 -107
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +172 -223
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +190 -228
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.d.ts.map +1 -0
- package/dist/src/production/circuit-breaker.js +62 -126
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.d.ts.map +1 -0
- package/dist/src/production/error-handler.js +86 -156
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.d.ts.map +1 -0
- package/dist/src/production/monitoring.js +139 -220
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.d.ts.map +1 -0
- package/dist/src/production/rate-limiter.js +74 -93
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.d.ts.map +1 -0
- package/dist/src/production/retry.js +75 -167
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +436 -560
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.d.ts.map +1 -0
- package/dist/src/runtime/headless.js +197 -286
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.d.ts +182 -0
- package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/agent-wasm.js +156 -351
- package/dist/src/ruvector/agent-wasm.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +145 -232
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +287 -419
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +56 -101
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +324 -451
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
- package/dist/src/ruvector/enhanced-model-router.js +260 -336
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +223 -254
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +486 -680
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +40 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +36 -106
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +218 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
- package/dist/src/ruvector/lora-adapter.js +155 -248
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +175 -248
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +228 -286
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +257 -338
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/ruvllm-wasm.js +270 -434
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
- package/dist/src/ruvector/semantic-router.js +60 -67
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +119 -205
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
- package/dist/src/services/agentic-flow-bridge.js +32 -105
- package/dist/src/services/agentic-flow-bridge.js.map +1 -1
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.d.ts.map +1 -0
- package/dist/src/services/claim-service.js +615 -940
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.d.ts +197 -0
- package/dist/src/services/container-worker-pool.d.ts.map +1 -0
- package/dist/src/services/container-worker-pool.js +398 -666
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.d.ts +304 -0
- package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
- package/dist/src/services/headless-worker-executor.js +441 -467
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +4 -4
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.d.ts.map +1 -0
- package/dist/src/services/registry-api.js +92 -200
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.d.ts.map +1 -0
- package/dist/src/services/ruvector-training.js +257 -337
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.d.ts +228 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +591 -849
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.d.ts.map +1 -0
- package/dist/src/services/worker-queue.js +331 -548
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +45 -55
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +29 -37
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.js +128 -155
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +84 -142
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +0 -2
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +187 -337
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +288 -434
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +55 -55
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +30 -31
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
- package/dist/src/transfer/storage/gcs.js +165 -232
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +239 -349
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +243 -365
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +63 -130
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +184 -258
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +50 -72
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +64 -96
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +174 -231
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +95 -130
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +194 -239
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +26 -55
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.d.ts.map +1 -0
- package/dist/src/update/checker.js +106 -183
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +32 -0
- package/dist/src/update/executor.d.ts.map +1 -0
- package/dist/src/update/executor.js +135 -198
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.d.ts.map +1 -0
- package/dist/src/update/index.js +38 -85
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.d.ts.map +1 -0
- package/dist/src/update/rate-limiter.js +19 -31
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.d.ts.map +1 -0
- package/dist/src/update/validator.js +38 -64
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -5,42 +5,6 @@
|
|
|
5
5
|
* Updated to support --claude flag for launching interactive Claude Code sessions
|
|
6
6
|
* PR: Fix #955 - Implement --claude flag for hive-mind spawn command
|
|
7
7
|
*/
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
18
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
-
function step(op) {
|
|
22
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
-
while (_) try {
|
|
24
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
25
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
-
switch (op[0]) {
|
|
27
|
-
case 0: case 1: t = op; break;
|
|
28
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
-
default:
|
|
32
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
-
if (t[2]) _.ops.pop();
|
|
37
|
-
_.trys.pop(); continue;
|
|
38
|
-
}
|
|
39
|
-
op = body.call(thisArg, _);
|
|
40
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
8
|
import { output } from '../output.js';
|
|
45
9
|
import { select, confirm, input } from '../prompt.js';
|
|
46
10
|
import { callMCPTool, MCPClientError } from '../mcp-client.js';
|
|
@@ -48,14 +12,14 @@ import { spawn as childSpawn, execSync } from 'child_process';
|
|
|
48
12
|
import { mkdir, writeFile } from 'fs/promises';
|
|
49
13
|
import { join } from 'path';
|
|
50
14
|
// Hive topologies
|
|
51
|
-
|
|
15
|
+
const TOPOLOGIES = [
|
|
52
16
|
{ value: 'hierarchical', label: 'Hierarchical', hint: 'Queen-led with worker agents' },
|
|
53
17
|
{ value: 'mesh', label: 'Mesh', hint: 'Peer-to-peer coordination' },
|
|
54
18
|
{ value: 'hierarchical-mesh', label: 'Hierarchical Mesh', hint: 'Queen + peer communication (recommended)' },
|
|
55
19
|
{ value: 'adaptive', label: 'Adaptive', hint: 'Dynamic topology based on task' }
|
|
56
20
|
];
|
|
57
21
|
// Consensus strategies
|
|
58
|
-
|
|
22
|
+
const CONSENSUS_STRATEGIES = [
|
|
59
23
|
{ value: 'byzantine', label: 'Byzantine Fault Tolerant', hint: '2/3 majority, handles malicious actors' },
|
|
60
24
|
{ value: 'raft', label: 'Raft', hint: 'Leader-based consensus' },
|
|
61
25
|
{ value: 'gossip', label: 'Gossip', hint: 'Eventually consistent, scalable' },
|
|
@@ -66,10 +30,9 @@ var CONSENSUS_STRATEGIES = [
|
|
|
66
30
|
* Group workers by their type for prompt generation
|
|
67
31
|
*/
|
|
68
32
|
function groupWorkersByType(workers) {
|
|
69
|
-
|
|
70
|
-
for (
|
|
71
|
-
|
|
72
|
-
var type = worker.type || worker.role || 'worker';
|
|
33
|
+
const groups = {};
|
|
34
|
+
for (const worker of workers) {
|
|
35
|
+
const type = worker.type || worker.role || 'worker';
|
|
73
36
|
if (!groups[type]) {
|
|
74
37
|
groups[type] = [];
|
|
75
38
|
}
|
|
@@ -82,187 +45,267 @@ function groupWorkersByType(workers) {
|
|
|
82
45
|
* Ported from v2.7.47 with enhancements for v3
|
|
83
46
|
*/
|
|
84
47
|
function generateHiveMindPrompt(swarmId, swarmName, objective, workers, workerGroups, flags) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return
|
|
48
|
+
const currentTime = new Date().toISOString();
|
|
49
|
+
const workerTypes = Object.keys(workerGroups);
|
|
50
|
+
const queenType = flags.queenType || 'strategic';
|
|
51
|
+
const consensusAlgorithm = flags.consensus || 'byzantine';
|
|
52
|
+
const topology = flags.topology || 'hierarchical-mesh';
|
|
53
|
+
return `🧠 HIVE MIND COLLECTIVE INTELLIGENCE SYSTEM
|
|
54
|
+
═══════════════════════════════════════════════
|
|
55
|
+
|
|
56
|
+
You are the Queen coordinator of a Hive Mind swarm with collective intelligence capabilities.
|
|
57
|
+
|
|
58
|
+
HIVE MIND CONFIGURATION:
|
|
59
|
+
📌 Swarm ID: ${swarmId}
|
|
60
|
+
📌 Swarm Name: ${swarmName}
|
|
61
|
+
🎯 Objective: ${objective}
|
|
62
|
+
👑 Queen Type: ${queenType}
|
|
63
|
+
🐝 Worker Count: ${workers.length}
|
|
64
|
+
🔗 Topology: ${topology}
|
|
65
|
+
🤝 Consensus Algorithm: ${consensusAlgorithm}
|
|
66
|
+
⏰ Initialized: ${currentTime}
|
|
67
|
+
|
|
68
|
+
WORKER DISTRIBUTION:
|
|
69
|
+
${workerTypes.map(type => `• ${type}: ${workerGroups[type].length} agents`).join('\n')}
|
|
70
|
+
|
|
71
|
+
🔧 AVAILABLE MCP TOOLS FOR HIVE MIND COORDINATION:
|
|
72
|
+
|
|
73
|
+
1️⃣ **COLLECTIVE INTELLIGENCE**
|
|
74
|
+
mcp__ruflo__hive-mind_consensus - Democratic decision making
|
|
75
|
+
mcp__ruflo__hive-mind_memory - Share knowledge across the hive
|
|
76
|
+
mcp__ruflo__hive-mind_broadcast - Broadcast to all workers
|
|
77
|
+
mcp__ruflo__neural_patterns - Neural pattern recognition
|
|
78
|
+
|
|
79
|
+
2️⃣ **QUEEN COORDINATION**
|
|
80
|
+
mcp__ruflo__hive-mind_status - Monitor swarm health
|
|
81
|
+
mcp__ruflo__task_create - Create and delegate tasks
|
|
82
|
+
mcp__ruflo__coordination_orchestrate - Orchestrate task distribution
|
|
83
|
+
mcp__ruflo__agent_spawn - Spawn additional workers
|
|
84
|
+
|
|
85
|
+
3️⃣ **WORKER MANAGEMENT**
|
|
86
|
+
mcp__ruflo__agent_list - List all active agents
|
|
87
|
+
mcp__ruflo__agent_status - Check agent status
|
|
88
|
+
mcp__ruflo__agent_health - Check worker health
|
|
89
|
+
mcp__ruflo__hive-mind_join - Add agent to hive
|
|
90
|
+
mcp__ruflo__hive-mind_leave - Remove agent from hive
|
|
91
|
+
|
|
92
|
+
4️⃣ **TASK ORCHESTRATION**
|
|
93
|
+
mcp__ruflo__task_assign - Assign tasks to workers
|
|
94
|
+
mcp__ruflo__task_status - Track task progress
|
|
95
|
+
mcp__ruflo__task_complete - Mark tasks complete
|
|
96
|
+
mcp__ruflo__workflow_create - Create workflows
|
|
97
|
+
|
|
98
|
+
5️⃣ **MEMORY & LEARNING**
|
|
99
|
+
mcp__ruflo__memory_store - Store collective knowledge
|
|
100
|
+
mcp__ruflo__memory_retrieve - Access shared memory
|
|
101
|
+
mcp__ruflo__memory_search - Search memory patterns
|
|
102
|
+
mcp__ruflo__neural_train - Learn from experiences
|
|
103
|
+
mcp__ruflo__hooks_intelligence_pattern-store - Store patterns
|
|
104
|
+
|
|
105
|
+
📋 HIVE MIND EXECUTION PROTOCOL:
|
|
106
|
+
|
|
107
|
+
1. **INITIALIZATION PHASE**
|
|
108
|
+
- Verify all workers are online and responsive
|
|
109
|
+
- Establish communication channels
|
|
110
|
+
- Load previous session state if available
|
|
111
|
+
- Initialize shared memory space
|
|
112
|
+
|
|
113
|
+
2. **TASK DISTRIBUTION PHASE**
|
|
114
|
+
- Analyze the objective and decompose into subtasks
|
|
115
|
+
- Assign tasks based on worker specializations
|
|
116
|
+
- Set up task dependencies and ordering
|
|
117
|
+
- Monitor parallel execution
|
|
118
|
+
|
|
119
|
+
3. **COORDINATION PHASE**
|
|
120
|
+
- Use consensus for critical decisions
|
|
121
|
+
- Aggregate results from workers
|
|
122
|
+
- Resolve conflicts using ${consensusAlgorithm} consensus
|
|
123
|
+
- Share learnings across the hive
|
|
124
|
+
|
|
125
|
+
4. **COMPLETION PHASE**
|
|
126
|
+
- Verify all subtasks are complete
|
|
127
|
+
- Consolidate results
|
|
128
|
+
- Store learnings in collective memory
|
|
129
|
+
- Report final status
|
|
130
|
+
|
|
131
|
+
🎯 YOUR OBJECTIVE:
|
|
132
|
+
${objective}
|
|
133
|
+
|
|
134
|
+
💡 COORDINATION TIPS:
|
|
135
|
+
• Use mcp__ruflo__hive-mind_broadcast for swarm-wide announcements
|
|
136
|
+
• Check worker status regularly with mcp__ruflo__hive-mind_status
|
|
137
|
+
• Store important decisions in shared memory for persistence
|
|
138
|
+
• Use consensus for any decisions affecting multiple workers
|
|
139
|
+
• Use mcp__ruflo__task_assign to assign tasks to workers, then mcp__ruflo__task_complete when done
|
|
140
|
+
|
|
141
|
+
🚀 BEGIN HIVE MIND COORDINATION NOW!
|
|
142
|
+
Start by checking the current hive status and then proceed with the objective.
|
|
143
|
+
`;
|
|
91
144
|
}
|
|
92
145
|
/**
|
|
93
146
|
* Spawn Claude Code with Hive Mind coordination instructions
|
|
94
147
|
* Ported from v2.7.47 spawnClaudeCodeInstances function
|
|
95
148
|
*/
|
|
96
|
-
function spawnClaudeCodeInstance(swarmId, swarmName, objective, workers, flags) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
149
|
+
async function spawnClaudeCodeInstance(swarmId, swarmName, objective, workers, flags) {
|
|
150
|
+
output.writeln();
|
|
151
|
+
output.writeln(output.bold('🚀 Launching Claude Code with Hive Mind Coordination'));
|
|
152
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
153
|
+
const spinner = output.createSpinner({ text: 'Preparing Hive Mind coordination prompt...', spinner: 'dots' });
|
|
154
|
+
spinner.start();
|
|
155
|
+
try {
|
|
156
|
+
// Generate comprehensive Hive Mind prompt
|
|
157
|
+
const workerGroups = groupWorkersByType(workers);
|
|
158
|
+
const hiveMindPrompt = generateHiveMindPrompt(swarmId, swarmName, objective, workers, workerGroups, flags);
|
|
159
|
+
spinner.succeed('Hive Mind coordination prompt ready!');
|
|
160
|
+
// Display coordination summary
|
|
161
|
+
output.writeln();
|
|
162
|
+
output.writeln(output.bold('🧠 Hive Mind Configuration'));
|
|
163
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
164
|
+
output.printList([
|
|
165
|
+
`Swarm ID: ${output.highlight(swarmId)}`,
|
|
166
|
+
`Objective: ${output.highlight(objective)}`,
|
|
167
|
+
`Queen Type: ${output.highlight(flags.queenType || 'strategic')}`,
|
|
168
|
+
`Worker Count: ${output.highlight(String(workers.length))}`,
|
|
169
|
+
`Worker Types: ${output.highlight(Object.keys(workerGroups).join(', '))}`,
|
|
170
|
+
`Consensus: ${output.highlight(flags.consensus || 'byzantine')}`,
|
|
171
|
+
`MCP Tools: ${output.success('Full Claude-Flow integration enabled')}`
|
|
172
|
+
]);
|
|
173
|
+
// Ensure sessions directory exists
|
|
174
|
+
const sessionsDir = join('.hive-mind', 'sessions');
|
|
175
|
+
await mkdir(sessionsDir, { recursive: true });
|
|
176
|
+
const promptFile = join(sessionsDir, `hive-mind-prompt-${swarmId}.txt`);
|
|
177
|
+
await writeFile(promptFile, hiveMindPrompt, 'utf8');
|
|
178
|
+
output.writeln();
|
|
179
|
+
output.printSuccess(`Hive Mind prompt saved to: ${promptFile}`);
|
|
180
|
+
// Check if claude command exists
|
|
181
|
+
let claudeAvailable = false;
|
|
182
|
+
try {
|
|
183
|
+
execSync('which claude', { stdio: 'ignore' });
|
|
184
|
+
claudeAvailable = true;
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
output.writeln();
|
|
188
|
+
output.printWarning('Claude Code CLI not found in PATH');
|
|
189
|
+
output.writeln(output.dim('Install it with: npm install -g @anthropic-ai/claude-code'));
|
|
190
|
+
output.writeln(output.dim('Falling back to displaying instructions...'));
|
|
191
|
+
}
|
|
192
|
+
const dryRun = flags.dryRun || flags['dry-run'];
|
|
193
|
+
if (claudeAvailable && !dryRun) {
|
|
194
|
+
// Build arguments - flags first, then prompt
|
|
195
|
+
const claudeArgs = [];
|
|
196
|
+
// Check for non-interactive mode
|
|
197
|
+
const isNonInteractive = flags['non-interactive'] || flags.nonInteractive;
|
|
198
|
+
if (isNonInteractive) {
|
|
199
|
+
claudeArgs.push('-p'); // Print mode
|
|
200
|
+
claudeArgs.push('--output-format', 'stream-json');
|
|
201
|
+
claudeArgs.push('--verbose');
|
|
202
|
+
output.printInfo('Running in non-interactive mode');
|
|
203
|
+
}
|
|
204
|
+
// Add auto-permission flag unless explicitly disabled
|
|
205
|
+
const skipPermissions = flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions'];
|
|
206
|
+
if (skipPermissions) {
|
|
207
|
+
claudeArgs.push('--dangerously-skip-permissions');
|
|
208
|
+
if (!isNonInteractive) {
|
|
209
|
+
output.printWarning('Using --dangerously-skip-permissions for seamless hive-mind execution');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Add the prompt as the LAST argument
|
|
213
|
+
claudeArgs.push(hiveMindPrompt);
|
|
214
|
+
output.writeln();
|
|
215
|
+
output.printInfo('Launching Claude Code...');
|
|
216
|
+
output.writeln(output.dim('Press Ctrl+C to pause the session'));
|
|
217
|
+
// Spawn claude with properly ordered arguments
|
|
218
|
+
const claudeProcess = childSpawn('claude', claudeArgs, {
|
|
219
|
+
stdio: 'inherit',
|
|
220
|
+
shell: false,
|
|
221
|
+
});
|
|
222
|
+
// Set up SIGINT handler for session management
|
|
223
|
+
let isExiting = false;
|
|
224
|
+
const sigintHandler = () => {
|
|
225
|
+
if (isExiting)
|
|
226
|
+
return;
|
|
227
|
+
isExiting = true;
|
|
228
|
+
output.writeln();
|
|
229
|
+
output.writeln();
|
|
230
|
+
output.printWarning('Pausing session and terminating Claude Code...');
|
|
231
|
+
if (claudeProcess && !claudeProcess.killed) {
|
|
232
|
+
claudeProcess.kill('SIGTERM');
|
|
233
|
+
}
|
|
234
|
+
output.writeln();
|
|
235
|
+
output.printSuccess('Session paused');
|
|
236
|
+
output.writeln(output.dim(`Prompt file saved at: ${promptFile}`));
|
|
237
|
+
output.writeln(output.dim('To resume, run claude with the saved prompt file'));
|
|
238
|
+
process.exit(0);
|
|
239
|
+
};
|
|
240
|
+
process.on('SIGINT', sigintHandler);
|
|
241
|
+
process.on('SIGTERM', sigintHandler);
|
|
242
|
+
// Handle process exit
|
|
243
|
+
claudeProcess.on('exit', (code) => {
|
|
244
|
+
// Clean up signal handlers
|
|
245
|
+
process.removeListener('SIGINT', sigintHandler);
|
|
246
|
+
process.removeListener('SIGTERM', sigintHandler);
|
|
247
|
+
if (code === 0) {
|
|
134
248
|
output.writeln();
|
|
135
|
-
output.printSuccess(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
execSync('which claude', { stdio: 'ignore' });
|
|
139
|
-
claudeAvailable = true;
|
|
140
|
-
}
|
|
141
|
-
catch (_c) {
|
|
142
|
-
output.writeln();
|
|
143
|
-
output.printWarning('Claude Code CLI not found in PATH');
|
|
144
|
-
output.writeln(output.dim('Install it with: npm install -g @anthropic-ai/claude-code'));
|
|
145
|
-
output.writeln(output.dim('Falling back to displaying instructions...'));
|
|
146
|
-
}
|
|
147
|
-
dryRun = flags.dryRun || flags['dry-run'];
|
|
148
|
-
if (claudeAvailable && !dryRun) {
|
|
149
|
-
claudeArgs = [];
|
|
150
|
-
isNonInteractive = flags['non-interactive'] || flags.nonInteractive;
|
|
151
|
-
if (isNonInteractive) {
|
|
152
|
-
claudeArgs.push('-p'); // Print mode
|
|
153
|
-
claudeArgs.push('--output-format', 'stream-json');
|
|
154
|
-
claudeArgs.push('--verbose');
|
|
155
|
-
output.printInfo('Running in non-interactive mode');
|
|
156
|
-
}
|
|
157
|
-
skipPermissions = flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions'];
|
|
158
|
-
if (skipPermissions) {
|
|
159
|
-
claudeArgs.push('--dangerously-skip-permissions');
|
|
160
|
-
if (!isNonInteractive) {
|
|
161
|
-
output.printWarning('Using --dangerously-skip-permissions for seamless hive-mind execution');
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
// Add the prompt as the LAST argument
|
|
165
|
-
claudeArgs.push(hiveMindPrompt);
|
|
166
|
-
output.writeln();
|
|
167
|
-
output.printInfo('Launching Claude Code...');
|
|
168
|
-
output.writeln(output.dim('Press Ctrl+C to pause the session'));
|
|
169
|
-
claudeProcess_1 = childSpawn('claude', claudeArgs, {
|
|
170
|
-
stdio: 'inherit',
|
|
171
|
-
shell: false
|
|
172
|
-
});
|
|
173
|
-
isExiting_1 = false;
|
|
174
|
-
sigintHandler_1 = function () {
|
|
175
|
-
if (isExiting_1)
|
|
176
|
-
return;
|
|
177
|
-
isExiting_1 = true;
|
|
178
|
-
output.writeln();
|
|
179
|
-
output.writeln();
|
|
180
|
-
output.printWarning('Pausing session and terminating Claude Code...');
|
|
181
|
-
if (claudeProcess_1 && !claudeProcess_1.killed) {
|
|
182
|
-
claudeProcess_1.kill('SIGTERM');
|
|
183
|
-
}
|
|
184
|
-
output.writeln();
|
|
185
|
-
output.printSuccess('Session paused');
|
|
186
|
-
output.writeln(output.dim("Prompt file saved at: " + promptFile_1));
|
|
187
|
-
output.writeln(output.dim('To resume, run claude with the saved prompt file'));
|
|
188
|
-
process.exit(0);
|
|
189
|
-
};
|
|
190
|
-
process.on('SIGINT', sigintHandler_1);
|
|
191
|
-
process.on('SIGTERM', sigintHandler_1);
|
|
192
|
-
// Handle process exit
|
|
193
|
-
claudeProcess_1.on('exit', function (code) {
|
|
194
|
-
// Clean up signal handlers
|
|
195
|
-
process.removeListener('SIGINT', sigintHandler_1);
|
|
196
|
-
process.removeListener('SIGTERM', sigintHandler_1);
|
|
197
|
-
if (code === 0) {
|
|
198
|
-
output.writeln();
|
|
199
|
-
output.printSuccess('Claude Code completed successfully');
|
|
200
|
-
}
|
|
201
|
-
else if (code !== null) {
|
|
202
|
-
output.writeln();
|
|
203
|
-
output.printError("Claude Code exited with code " + code);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
output.writeln();
|
|
207
|
-
output.printSuccess('Claude Code launched with Hive Mind coordination');
|
|
208
|
-
output.printInfo('The Queen coordinator will orchestrate all worker agents');
|
|
209
|
-
output.writeln(output.dim("Prompt file saved at: " + promptFile_1));
|
|
210
|
-
return [2 /*return*/, { success: true, promptFile: promptFile_1 }];
|
|
211
|
-
}
|
|
212
|
-
else if (dryRun) {
|
|
213
|
-
output.writeln();
|
|
214
|
-
output.printInfo('Dry run - would execute Claude Code with prompt:');
|
|
215
|
-
output.writeln(output.dim("Prompt length: " + hiveMindPrompt.length + " characters"));
|
|
216
|
-
output.writeln();
|
|
217
|
-
output.writeln(output.dim('First 500 characters of prompt:'));
|
|
218
|
-
output.writeln(output.highlight(hiveMindPrompt.substring(0, 500) + '...'));
|
|
219
|
-
output.writeln();
|
|
220
|
-
output.writeln(output.dim("Full prompt saved to: " + promptFile_1));
|
|
221
|
-
return [2 /*return*/, { success: true, promptFile: promptFile_1 }];
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
// Claude not available - show instructions
|
|
225
|
-
output.writeln();
|
|
226
|
-
output.writeln(output.bold('📋 Manual Execution Instructions:'));
|
|
227
|
-
output.writeln(output.dim('─'.repeat(50)));
|
|
228
|
-
output.printList([
|
|
229
|
-
'Install Claude Code: npm install -g @anthropic-ai/claude-code',
|
|
230
|
-
"Run with saved prompt: claude < " + promptFile_1,
|
|
231
|
-
"Or copy manually: cat " + promptFile_1 + " | claude",
|
|
232
|
-
"With auto-permissions: claude --dangerously-skip-permissions < " + promptFile_1
|
|
233
|
-
]);
|
|
234
|
-
return [2 /*return*/, { success: true, promptFile: promptFile_1 }];
|
|
235
|
-
}
|
|
236
|
-
return [3 /*break*/, 9];
|
|
237
|
-
case 4:
|
|
238
|
-
error_1 = _b.sent();
|
|
239
|
-
spinner.fail('Failed to prepare Claude Code coordination');
|
|
240
|
-
errorMessage = error_1 instanceof Error ? error_1.message : String(error_1);
|
|
241
|
-
output.printError("Error: " + errorMessage);
|
|
242
|
-
_b.label = 5;
|
|
243
|
-
case 5:
|
|
244
|
-
_b.trys.push([5, 7, , 8]);
|
|
245
|
-
promptFile = "hive-mind-prompt-" + swarmId + "-fallback.txt";
|
|
246
|
-
workerGroups = groupWorkersByType(workers);
|
|
247
|
-
hiveMindPrompt = generateHiveMindPrompt(swarmId, swarmName, objective, workers, workerGroups, flags);
|
|
248
|
-
return [4 /*yield*/, writeFile(promptFile, hiveMindPrompt, 'utf8')];
|
|
249
|
-
case 6:
|
|
250
|
-
_b.sent();
|
|
249
|
+
output.printSuccess('Claude Code completed successfully');
|
|
250
|
+
}
|
|
251
|
+
else if (code !== null) {
|
|
251
252
|
output.writeln();
|
|
252
|
-
output.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
253
|
+
output.printError(`Claude Code exited with code ${code}`);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
output.writeln();
|
|
257
|
+
output.printSuccess('Claude Code launched with Hive Mind coordination');
|
|
258
|
+
output.printInfo('The Queen coordinator will orchestrate all worker agents');
|
|
259
|
+
output.writeln(output.dim(`Prompt file saved at: ${promptFile}`));
|
|
260
|
+
return { success: true, promptFile };
|
|
261
|
+
}
|
|
262
|
+
else if (dryRun) {
|
|
263
|
+
output.writeln();
|
|
264
|
+
output.printInfo('Dry run - would execute Claude Code with prompt:');
|
|
265
|
+
output.writeln(output.dim(`Prompt length: ${hiveMindPrompt.length} characters`));
|
|
266
|
+
output.writeln();
|
|
267
|
+
output.writeln(output.dim('First 500 characters of prompt:'));
|
|
268
|
+
output.writeln(output.highlight(hiveMindPrompt.substring(0, 500) + '...'));
|
|
269
|
+
output.writeln();
|
|
270
|
+
output.writeln(output.dim(`Full prompt saved to: ${promptFile}`));
|
|
271
|
+
return { success: true, promptFile };
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// Claude not available - show instructions
|
|
275
|
+
output.writeln();
|
|
276
|
+
output.writeln(output.bold('📋 Manual Execution Instructions:'));
|
|
277
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
278
|
+
output.printList([
|
|
279
|
+
'Install Claude Code: npm install -g @anthropic-ai/claude-code',
|
|
280
|
+
`Run with saved prompt: claude < ${promptFile}`,
|
|
281
|
+
`Or copy manually: cat ${promptFile} | claude`,
|
|
282
|
+
`With auto-permissions: claude --dangerously-skip-permissions < ${promptFile}`
|
|
283
|
+
]);
|
|
284
|
+
return { success: true, promptFile };
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
spinner.fail('Failed to prepare Claude Code coordination');
|
|
289
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
290
|
+
output.printError(`Error: ${errorMessage}`);
|
|
291
|
+
// Try to save prompt as fallback
|
|
292
|
+
try {
|
|
293
|
+
const promptFile = `hive-mind-prompt-${swarmId}-fallback.txt`;
|
|
294
|
+
const workerGroups = groupWorkersByType(workers);
|
|
295
|
+
const hiveMindPrompt = generateHiveMindPrompt(swarmId, swarmName, objective, workers, workerGroups, flags);
|
|
296
|
+
await writeFile(promptFile, hiveMindPrompt, 'utf8');
|
|
297
|
+
output.writeln();
|
|
298
|
+
output.printSuccess(`Prompt saved to: ${promptFile}`);
|
|
299
|
+
output.writeln(output.dim('You can run Claude Code manually with the saved prompt'));
|
|
300
|
+
return { success: false, promptFile, error: errorMessage };
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return { success: false, error: errorMessage };
|
|
304
|
+
}
|
|
305
|
+
}
|
|
263
306
|
}
|
|
264
307
|
// Init subcommand
|
|
265
|
-
|
|
308
|
+
const initCommand = {
|
|
266
309
|
name: 'init',
|
|
267
310
|
description: 'Initialize a hive mind',
|
|
268
311
|
options: [
|
|
@@ -271,124 +314,107 @@ var initCommand = {
|
|
|
271
314
|
short: 't',
|
|
272
315
|
description: 'Hive topology',
|
|
273
316
|
type: 'string',
|
|
274
|
-
choices: TOPOLOGIES.map(
|
|
275
|
-
|
|
317
|
+
choices: TOPOLOGIES.map(t => t.value),
|
|
318
|
+
default: 'hierarchical-mesh'
|
|
276
319
|
},
|
|
277
320
|
{
|
|
278
321
|
name: 'consensus',
|
|
279
322
|
short: 'c',
|
|
280
323
|
description: 'Consensus strategy',
|
|
281
324
|
type: 'string',
|
|
282
|
-
choices: CONSENSUS_STRATEGIES.map(
|
|
283
|
-
|
|
325
|
+
choices: CONSENSUS_STRATEGIES.map(s => s.value),
|
|
326
|
+
default: 'byzantine'
|
|
284
327
|
},
|
|
285
328
|
{
|
|
286
329
|
name: 'max-agents',
|
|
287
330
|
short: 'm',
|
|
288
331
|
description: 'Maximum agents',
|
|
289
332
|
type: 'number',
|
|
290
|
-
|
|
333
|
+
default: 15
|
|
291
334
|
},
|
|
292
335
|
{
|
|
293
336
|
name: 'persist',
|
|
294
337
|
short: 'p',
|
|
295
338
|
description: 'Enable persistent state',
|
|
296
339
|
type: 'boolean',
|
|
297
|
-
|
|
340
|
+
default: true
|
|
298
341
|
},
|
|
299
342
|
{
|
|
300
343
|
name: 'memory-backend',
|
|
301
344
|
description: 'Memory backend (agentdb, sqlite, hybrid)',
|
|
302
345
|
type: 'string',
|
|
303
|
-
|
|
346
|
+
default: 'hybrid'
|
|
304
347
|
}
|
|
305
348
|
],
|
|
306
349
|
examples: [
|
|
307
350
|
{ command: 'claude-flow hive-mind init -t hierarchical-mesh', description: 'Init hierarchical mesh' },
|
|
308
351
|
{ command: 'claude-flow hive-mind init -c byzantine -m 20', description: 'Init with Byzantine consensus' }
|
|
309
352
|
],
|
|
310
|
-
action:
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
};
|
|
345
|
-
output.writeln();
|
|
346
|
-
output.writeln(output.bold('Initializing Hive Mind'));
|
|
347
|
-
spinner = output.createSpinner({ text: 'Setting up hive infrastructure...', spinner: 'dots' });
|
|
348
|
-
spinner.start();
|
|
349
|
-
_f.label = 5;
|
|
350
|
-
case 5:
|
|
351
|
-
_f.trys.push([5, 7, , 8]);
|
|
352
|
-
return [4 /*yield*/, callMCPTool('hive-mind_init', config)];
|
|
353
|
-
case 6:
|
|
354
|
-
result = _f.sent();
|
|
355
|
-
spinner.succeed('Hive Mind initialized');
|
|
356
|
-
if (ctx.flags.format === 'json') {
|
|
357
|
-
output.printJson(result);
|
|
358
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
359
|
-
}
|
|
360
|
-
output.writeln();
|
|
361
|
-
output.printBox([
|
|
362
|
-
"Hive ID: " + ((_a = result.hiveId) !== null && _a !== void 0 ? _a : 'default'),
|
|
363
|
-
"Queen ID: " + ((_b = result.queenId) !== null && _b !== void 0 ? _b : 'N/A'),
|
|
364
|
-
"Topology: " + ((_c = result.topology) !== null && _c !== void 0 ? _c : config.topology),
|
|
365
|
-
"Consensus: " + ((_d = result.consensus) !== null && _d !== void 0 ? _d : config.consensus),
|
|
366
|
-
"Max Agents: " + config.maxAgents,
|
|
367
|
-
"Memory: " + config.memoryBackend,
|
|
368
|
-
"Status: " + output.success((_e = result.status) !== null && _e !== void 0 ? _e : 'initialized')
|
|
369
|
-
].join('\n'), 'Hive Mind Configuration');
|
|
370
|
-
output.writeln();
|
|
371
|
-
output.printInfo('Queen agent is ready to coordinate worker agents');
|
|
372
|
-
output.writeln(output.dim(' Use "claude-flow hive-mind spawn" to add workers'));
|
|
373
|
-
output.writeln(output.dim(' Use "claude-flow hive-mind spawn --claude" to launch Claude Code'));
|
|
374
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
375
|
-
case 7:
|
|
376
|
-
error_2 = _f.sent();
|
|
377
|
-
spinner.fail('Failed to initialize');
|
|
378
|
-
if (error_2 instanceof MCPClientError) {
|
|
379
|
-
output.printError("Init error: " + error_2.message);
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
output.printError("Unexpected error: " + String(error_2));
|
|
383
|
-
}
|
|
384
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
385
|
-
case 8: return [2 /*return*/];
|
|
353
|
+
action: async (ctx) => {
|
|
354
|
+
let topology = ctx.flags.topology;
|
|
355
|
+
let consensus = ctx.flags.consensus;
|
|
356
|
+
if (ctx.interactive && !ctx.flags.topology) {
|
|
357
|
+
topology = await select({
|
|
358
|
+
message: 'Select hive topology:',
|
|
359
|
+
options: TOPOLOGIES,
|
|
360
|
+
default: 'hierarchical-mesh'
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
if (ctx.interactive && !ctx.flags.consensus) {
|
|
364
|
+
consensus = await select({
|
|
365
|
+
message: 'Select consensus strategy:',
|
|
366
|
+
options: CONSENSUS_STRATEGIES,
|
|
367
|
+
default: 'byzantine'
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
const config = {
|
|
371
|
+
topology: topology || 'hierarchical-mesh',
|
|
372
|
+
consensus: consensus || 'byzantine',
|
|
373
|
+
maxAgents: ctx.flags.maxAgents || 15,
|
|
374
|
+
persist: ctx.flags.persist,
|
|
375
|
+
memoryBackend: ctx.flags.memoryBackend || 'hybrid'
|
|
376
|
+
};
|
|
377
|
+
output.writeln();
|
|
378
|
+
output.writeln(output.bold('Initializing Hive Mind'));
|
|
379
|
+
const spinner = output.createSpinner({ text: 'Setting up hive infrastructure...', spinner: 'dots' });
|
|
380
|
+
spinner.start();
|
|
381
|
+
try {
|
|
382
|
+
const result = await callMCPTool('hive-mind_init', config);
|
|
383
|
+
spinner.succeed('Hive Mind initialized');
|
|
384
|
+
if (ctx.flags.format === 'json') {
|
|
385
|
+
output.printJson(result);
|
|
386
|
+
return { success: true, data: result };
|
|
386
387
|
}
|
|
387
|
-
|
|
388
|
-
|
|
388
|
+
output.writeln();
|
|
389
|
+
output.printBox([
|
|
390
|
+
`Hive ID: ${result.hiveId ?? 'default'}`,
|
|
391
|
+
`Queen ID: ${result.queenId ?? 'N/A'}`,
|
|
392
|
+
`Topology: ${result.topology ?? config.topology}`,
|
|
393
|
+
`Consensus: ${result.consensus ?? config.consensus}`,
|
|
394
|
+
`Max Agents: ${config.maxAgents}`,
|
|
395
|
+
`Memory: ${config.memoryBackend}`,
|
|
396
|
+
`Status: ${output.success(result.status ?? 'initialized')}`
|
|
397
|
+
].join('\n'), 'Hive Mind Configuration');
|
|
398
|
+
output.writeln();
|
|
399
|
+
output.printInfo('Queen agent is ready to coordinate worker agents');
|
|
400
|
+
output.writeln(output.dim(' Use "claude-flow hive-mind spawn" to add workers'));
|
|
401
|
+
output.writeln(output.dim(' Use "claude-flow hive-mind spawn --claude" to launch Claude Code'));
|
|
402
|
+
return { success: true, data: result };
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
spinner.fail('Failed to initialize');
|
|
406
|
+
if (error instanceof MCPClientError) {
|
|
407
|
+
output.printError(`Init error: ${error.message}`);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
output.printError(`Unexpected error: ${String(error)}`);
|
|
411
|
+
}
|
|
412
|
+
return { success: false, exitCode: 1 };
|
|
413
|
+
}
|
|
414
|
+
}
|
|
389
415
|
};
|
|
390
416
|
// Spawn subcommand - UPDATED with --claude flag
|
|
391
|
-
|
|
417
|
+
const spawnCommand = {
|
|
392
418
|
name: 'spawn',
|
|
393
419
|
description: 'Spawn worker agents into the hive (use --claude to launch Claude Code)',
|
|
394
420
|
options: [
|
|
@@ -397,7 +423,7 @@ var spawnCommand = {
|
|
|
397
423
|
short: 'n',
|
|
398
424
|
description: 'Number of workers to spawn',
|
|
399
425
|
type: 'number',
|
|
400
|
-
|
|
426
|
+
default: 1
|
|
401
427
|
},
|
|
402
428
|
{
|
|
403
429
|
name: 'role',
|
|
@@ -405,28 +431,28 @@ var spawnCommand = {
|
|
|
405
431
|
description: 'Worker role (worker, specialist, scout)',
|
|
406
432
|
type: 'string',
|
|
407
433
|
choices: ['worker', 'specialist', 'scout'],
|
|
408
|
-
|
|
434
|
+
default: 'worker'
|
|
409
435
|
},
|
|
410
436
|
{
|
|
411
437
|
name: 'type',
|
|
412
438
|
short: 't',
|
|
413
439
|
description: 'Agent type',
|
|
414
440
|
type: 'string',
|
|
415
|
-
|
|
441
|
+
default: 'worker'
|
|
416
442
|
},
|
|
417
443
|
{
|
|
418
444
|
name: 'prefix',
|
|
419
445
|
short: 'p',
|
|
420
446
|
description: 'Prefix for worker IDs',
|
|
421
447
|
type: 'string',
|
|
422
|
-
|
|
448
|
+
default: 'hive-worker'
|
|
423
449
|
},
|
|
424
450
|
// NEW: --claude flag for launching Claude Code
|
|
425
451
|
{
|
|
426
452
|
name: 'claude',
|
|
427
453
|
description: 'Launch Claude Code with hive-mind coordination prompt',
|
|
428
454
|
type: 'boolean',
|
|
429
|
-
|
|
455
|
+
default: false
|
|
430
456
|
},
|
|
431
457
|
{
|
|
432
458
|
name: 'objective',
|
|
@@ -438,25 +464,25 @@ var spawnCommand = {
|
|
|
438
464
|
name: 'dangerously-skip-permissions',
|
|
439
465
|
description: 'Skip permission prompts in Claude Code (use with caution)',
|
|
440
466
|
type: 'boolean',
|
|
441
|
-
|
|
467
|
+
default: true
|
|
442
468
|
},
|
|
443
469
|
{
|
|
444
470
|
name: 'no-auto-permissions',
|
|
445
471
|
description: 'Disable automatic permission skipping',
|
|
446
472
|
type: 'boolean',
|
|
447
|
-
|
|
473
|
+
default: false
|
|
448
474
|
},
|
|
449
475
|
{
|
|
450
476
|
name: 'dry-run',
|
|
451
477
|
description: 'Show what would be done without launching Claude Code',
|
|
452
478
|
type: 'boolean',
|
|
453
|
-
|
|
479
|
+
default: false
|
|
454
480
|
},
|
|
455
481
|
{
|
|
456
482
|
name: 'non-interactive',
|
|
457
483
|
description: 'Run Claude Code in non-interactive mode',
|
|
458
484
|
type: 'boolean',
|
|
459
|
-
|
|
485
|
+
default: false
|
|
460
486
|
}
|
|
461
487
|
],
|
|
462
488
|
examples: [
|
|
@@ -466,116 +492,104 @@ var spawnCommand = {
|
|
|
466
492
|
{ command: 'claude-flow hive-mind spawn --claude -o "Build a REST API"', description: 'Launch Claude Code with objective' },
|
|
467
493
|
{ command: 'claude-flow hive-mind spawn -n 5 --claude -o "Research AI patterns"', description: 'Spawn workers and launch Claude Code' }
|
|
468
494
|
],
|
|
469
|
-
action:
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
495
|
+
action: async (ctx) => {
|
|
496
|
+
// Parse count with fallback to default
|
|
497
|
+
const count = ctx.flags.count || 1;
|
|
498
|
+
const role = ctx.flags.role || 'worker';
|
|
499
|
+
const agentType = ctx.flags.type || 'worker';
|
|
500
|
+
const prefix = ctx.flags.prefix || 'hive-worker';
|
|
501
|
+
const launchClaude = ctx.flags.claude;
|
|
502
|
+
let objective = ctx.flags.objective || ctx.args.join(' ');
|
|
503
|
+
output.printInfo(`Spawning ${count} ${role} agent(s)...`);
|
|
504
|
+
try {
|
|
505
|
+
const result = await callMCPTool('hive-mind_spawn', {
|
|
506
|
+
count,
|
|
507
|
+
role,
|
|
508
|
+
agentType,
|
|
509
|
+
prefix,
|
|
510
|
+
});
|
|
511
|
+
// Check for errors from MCP tool
|
|
512
|
+
if (!result.success) {
|
|
513
|
+
output.printError(result.error || 'Failed to spawn workers');
|
|
514
|
+
return { success: false, exitCode: 1 };
|
|
515
|
+
}
|
|
516
|
+
if (ctx.flags.format === 'json' && !launchClaude) {
|
|
517
|
+
output.printJson(result);
|
|
518
|
+
return { success: true, data: result };
|
|
519
|
+
}
|
|
520
|
+
output.writeln();
|
|
521
|
+
// Transform workers array to display format
|
|
522
|
+
const displayData = (result.workers || []).map(w => ({
|
|
523
|
+
id: w.agentId,
|
|
524
|
+
role: w.role,
|
|
525
|
+
status: 'idle',
|
|
526
|
+
joinedAt: new Date(w.joinedAt).toLocaleTimeString()
|
|
527
|
+
}));
|
|
528
|
+
output.printTable({
|
|
529
|
+
columns: [
|
|
530
|
+
{ key: 'id', header: 'Agent ID', width: 30 },
|
|
531
|
+
{ key: 'role', header: 'Role', width: 12 },
|
|
532
|
+
{ key: 'status', header: 'Status', width: 10, format: formatAgentStatus },
|
|
533
|
+
{ key: 'joinedAt', header: 'Joined', width: 12 }
|
|
534
|
+
],
|
|
535
|
+
data: displayData
|
|
536
|
+
});
|
|
537
|
+
output.writeln();
|
|
538
|
+
output.printSuccess(`Spawned ${result.spawned} agent(s)`);
|
|
539
|
+
output.writeln(output.dim(` Total workers in hive: ${result.totalWorkers}`));
|
|
540
|
+
// NEW: Handle --claude flag
|
|
541
|
+
if (launchClaude) {
|
|
542
|
+
// Get objective if not provided
|
|
543
|
+
if (!objective && ctx.interactive) {
|
|
544
|
+
objective = await input({
|
|
545
|
+
message: 'Enter the objective for the hive mind:',
|
|
546
|
+
validate: (v) => v.length > 0 || 'Objective is required when using --claude'
|
|
516
547
|
});
|
|
548
|
+
}
|
|
549
|
+
if (!objective) {
|
|
517
550
|
output.writeln();
|
|
518
|
-
output.
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
case 3:
|
|
527
|
-
objective = _b.sent();
|
|
528
|
-
_b.label = 4;
|
|
529
|
-
case 4:
|
|
530
|
-
if (!objective) {
|
|
531
|
-
output.writeln();
|
|
532
|
-
output.printWarning('No objective provided. Using default objective.');
|
|
533
|
-
objective = 'Coordinate the hive mind workers to complete tasks efficiently.';
|
|
534
|
-
}
|
|
535
|
-
swarmId = result.hiveId || 'default';
|
|
536
|
-
swarmName = 'Hive Mind Swarm';
|
|
537
|
-
_b.label = 5;
|
|
538
|
-
case 5:
|
|
539
|
-
_b.trys.push([5, 7, , 8]);
|
|
540
|
-
return [4 /*yield*/, callMCPTool('hive-mind_status', { includeWorkers: false })];
|
|
541
|
-
case 6:
|
|
542
|
-
statusResult = _b.sent();
|
|
551
|
+
output.printWarning('No objective provided. Using default objective.');
|
|
552
|
+
objective = 'Coordinate the hive mind workers to complete tasks efficiently.';
|
|
553
|
+
}
|
|
554
|
+
// Get hive status for swarm info
|
|
555
|
+
let swarmId = result.hiveId || 'default';
|
|
556
|
+
let swarmName = 'Hive Mind Swarm';
|
|
557
|
+
try {
|
|
558
|
+
const statusResult = await callMCPTool('hive-mind_status', { includeWorkers: false });
|
|
543
559
|
swarmId = statusResult.hiveId || swarmId;
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
572
|
-
case 12: return [2 /*return*/];
|
|
560
|
+
}
|
|
561
|
+
catch {
|
|
562
|
+
// Use defaults if status call fails
|
|
563
|
+
}
|
|
564
|
+
// Convert workers to expected format
|
|
565
|
+
const workers = (result.workers || []).map(w => ({
|
|
566
|
+
agentId: w.agentId,
|
|
567
|
+
role: w.role,
|
|
568
|
+
type: agentType,
|
|
569
|
+
joinedAt: w.joinedAt
|
|
570
|
+
}));
|
|
571
|
+
// Launch Claude Code with hive mind prompt
|
|
572
|
+
const claudeResult = await spawnClaudeCodeInstance(swarmId, swarmName, objective, workers, ctx.flags);
|
|
573
|
+
if (!claudeResult.success) {
|
|
574
|
+
return { success: false, exitCode: 1, data: { spawn: result, claude: claudeResult } };
|
|
575
|
+
}
|
|
576
|
+
return { success: true, data: { spawn: result, claude: claudeResult } };
|
|
577
|
+
}
|
|
578
|
+
return { success: true, data: result };
|
|
579
|
+
}
|
|
580
|
+
catch (error) {
|
|
581
|
+
if (error instanceof MCPClientError) {
|
|
582
|
+
output.printError(`Spawn error: ${error.message}`);
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
output.printError(`Unexpected error: ${String(error)}`);
|
|
573
586
|
}
|
|
574
|
-
|
|
575
|
-
|
|
587
|
+
return { success: false, exitCode: 1 };
|
|
588
|
+
}
|
|
589
|
+
}
|
|
576
590
|
};
|
|
577
591
|
// Status subcommand
|
|
578
|
-
|
|
592
|
+
const statusCommand = {
|
|
579
593
|
name: 'status',
|
|
580
594
|
description: 'Show hive mind status',
|
|
581
595
|
options: [
|
|
@@ -584,135 +598,125 @@ var statusCommand = {
|
|
|
584
598
|
short: 'd',
|
|
585
599
|
description: 'Show detailed metrics',
|
|
586
600
|
type: 'boolean',
|
|
587
|
-
|
|
601
|
+
default: false
|
|
588
602
|
},
|
|
589
603
|
{
|
|
590
604
|
name: 'watch',
|
|
591
605
|
short: 'w',
|
|
592
606
|
description: 'Watch for changes',
|
|
593
607
|
type: 'boolean',
|
|
594
|
-
|
|
608
|
+
default: false
|
|
595
609
|
}
|
|
596
610
|
],
|
|
597
|
-
action:
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
700
|
-
case 3:
|
|
701
|
-
error_4 = _1.sent();
|
|
702
|
-
if (error_4 instanceof MCPClientError) {
|
|
703
|
-
output.printError("Status error: " + error_4.message);
|
|
704
|
-
}
|
|
705
|
-
else {
|
|
706
|
-
output.printError("Unexpected error: " + String(error_4));
|
|
707
|
-
}
|
|
708
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
709
|
-
case 4: return [2 /*return*/];
|
|
611
|
+
action: async (ctx) => {
|
|
612
|
+
const detailed = ctx.flags.detailed;
|
|
613
|
+
try {
|
|
614
|
+
const result = await callMCPTool('hive-mind_status', {
|
|
615
|
+
includeMetrics: detailed,
|
|
616
|
+
includeWorkers: true,
|
|
617
|
+
});
|
|
618
|
+
if (ctx.flags.format === 'json') {
|
|
619
|
+
output.printJson(result);
|
|
620
|
+
return { success: true, data: result };
|
|
621
|
+
}
|
|
622
|
+
// Handle both simple and complex response formats - cast to flexible type
|
|
623
|
+
const flexResult = result;
|
|
624
|
+
const hiveId = result.hiveId ?? flexResult.id ?? 'default';
|
|
625
|
+
const status = result.status ?? (flexResult.initialized ? 'running' : 'stopped');
|
|
626
|
+
const queen = result.queen ?? { id: 'N/A', status: 'unknown', load: 0, tasksQueued: 0 };
|
|
627
|
+
const flexQueen = queen;
|
|
628
|
+
const queenId = typeof queen === 'object' ? (queen.id ?? flexQueen.agentId ?? 'N/A') : String(queen);
|
|
629
|
+
const queenLoad = typeof queen === 'object' ? (queen.load ?? 0) : 0;
|
|
630
|
+
const queenTasks = typeof queen === 'object' ? (queen.tasksQueued ?? 0) : 0;
|
|
631
|
+
const queenStatus = typeof queen === 'object' ? (queen.status ?? 'active') : 'active';
|
|
632
|
+
output.writeln();
|
|
633
|
+
output.printBox([
|
|
634
|
+
`Hive ID: ${hiveId}`,
|
|
635
|
+
`Status: ${formatHiveStatus(String(status))}`,
|
|
636
|
+
`Topology: ${result.topology ?? 'mesh'}`,
|
|
637
|
+
`Consensus: ${result.consensus ?? 'byzantine'}`,
|
|
638
|
+
'',
|
|
639
|
+
`Queen: ${queenId}`,
|
|
640
|
+
` Status: ${formatAgentStatus(queenStatus)}`,
|
|
641
|
+
` Load: ${(queenLoad * 100).toFixed(1)}%`,
|
|
642
|
+
` Queued Tasks: ${queenTasks}`
|
|
643
|
+
].join('\n'), 'Hive Mind Status');
|
|
644
|
+
// Handle workers array - could be worker objects or just IDs
|
|
645
|
+
const workers = result.workers ?? [];
|
|
646
|
+
const workerData = Array.isArray(workers) ? workers.map(w => {
|
|
647
|
+
if (typeof w === 'string') {
|
|
648
|
+
return { id: w, type: 'worker', status: 'idle', currentTask: '-', tasksCompleted: 0 };
|
|
649
|
+
}
|
|
650
|
+
const flexWorker = w;
|
|
651
|
+
return {
|
|
652
|
+
id: w.id ?? flexWorker.agentId ?? 'unknown',
|
|
653
|
+
type: w.type ?? flexWorker.agentType ?? 'worker',
|
|
654
|
+
status: w.status ?? 'idle',
|
|
655
|
+
currentTask: w.currentTask ?? '-',
|
|
656
|
+
tasksCompleted: w.tasksCompleted ?? 0
|
|
657
|
+
};
|
|
658
|
+
}) : [];
|
|
659
|
+
output.writeln();
|
|
660
|
+
output.writeln(output.bold('Worker Agents'));
|
|
661
|
+
if (workerData.length === 0) {
|
|
662
|
+
output.printInfo('No workers in hive. Use "claude-flow hive-mind spawn" to add workers.');
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
output.printTable({
|
|
666
|
+
columns: [
|
|
667
|
+
{ key: 'id', header: 'ID', width: 20 },
|
|
668
|
+
{ key: 'type', header: 'Type', width: 12 },
|
|
669
|
+
{ key: 'status', header: 'Status', width: 10, format: formatAgentStatus },
|
|
670
|
+
{ key: 'currentTask', header: 'Current Task', width: 20, format: (v) => String(v || '-') },
|
|
671
|
+
{ key: 'tasksCompleted', header: 'Completed', width: 10, align: 'right' }
|
|
672
|
+
],
|
|
673
|
+
data: workerData
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
if (detailed) {
|
|
677
|
+
const metrics = result.metrics ?? { totalTasks: 0, completedTasks: 0, failedTasks: 0, avgTaskTime: 0, consensusRounds: 0, memoryUsage: '0 MB' };
|
|
678
|
+
output.writeln();
|
|
679
|
+
output.writeln(output.bold('Metrics'));
|
|
680
|
+
output.printTable({
|
|
681
|
+
columns: [
|
|
682
|
+
{ key: 'metric', header: 'Metric', width: 20 },
|
|
683
|
+
{ key: 'value', header: 'Value', width: 15, align: 'right' }
|
|
684
|
+
],
|
|
685
|
+
data: [
|
|
686
|
+
{ metric: 'Total Tasks', value: metrics.totalTasks ?? 0 },
|
|
687
|
+
{ metric: 'Completed', value: metrics.completedTasks ?? 0 },
|
|
688
|
+
{ metric: 'Failed', value: metrics.failedTasks ?? 0 },
|
|
689
|
+
{ metric: 'Avg Task Time', value: `${(metrics.avgTaskTime ?? 0).toFixed(1)}ms` },
|
|
690
|
+
{ metric: 'Consensus Rounds', value: metrics.consensusRounds ?? 0 },
|
|
691
|
+
{ metric: 'Memory Usage', value: metrics.memoryUsage ?? '0 MB' }
|
|
692
|
+
]
|
|
693
|
+
});
|
|
694
|
+
const health = result.health ?? { overall: 'healthy', queen: 'healthy', workers: 'healthy', consensus: 'healthy', memory: 'healthy' };
|
|
695
|
+
output.writeln();
|
|
696
|
+
output.writeln(output.bold('Health'));
|
|
697
|
+
output.printList([
|
|
698
|
+
`Overall: ${formatHealth(health.overall ?? 'healthy')}`,
|
|
699
|
+
`Queen: ${formatHealth(health.queen ?? 'healthy')}`,
|
|
700
|
+
`Workers: ${formatHealth(health.workers ?? 'healthy')}`,
|
|
701
|
+
`Consensus: ${formatHealth(health.consensus ?? 'healthy')}`,
|
|
702
|
+
`Memory: ${formatHealth(health.memory ?? 'healthy')}`
|
|
703
|
+
]);
|
|
704
|
+
}
|
|
705
|
+
return { success: true, data: result };
|
|
706
|
+
}
|
|
707
|
+
catch (error) {
|
|
708
|
+
if (error instanceof MCPClientError) {
|
|
709
|
+
output.printError(`Status error: ${error.message}`);
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
output.printError(`Unexpected error: ${String(error)}`);
|
|
710
713
|
}
|
|
711
|
-
|
|
712
|
-
|
|
714
|
+
return { success: false, exitCode: 1 };
|
|
715
|
+
}
|
|
716
|
+
}
|
|
713
717
|
};
|
|
714
718
|
// Task subcommand
|
|
715
|
-
|
|
719
|
+
const taskCommand = {
|
|
716
720
|
name: 'task',
|
|
717
721
|
description: 'Submit tasks to the hive',
|
|
718
722
|
options: [
|
|
@@ -728,93 +732,80 @@ var taskCommand = {
|
|
|
728
732
|
description: 'Task priority',
|
|
729
733
|
type: 'string',
|
|
730
734
|
choices: ['low', 'normal', 'high', 'critical'],
|
|
731
|
-
|
|
735
|
+
default: 'normal'
|
|
732
736
|
},
|
|
733
737
|
{
|
|
734
738
|
name: 'require-consensus',
|
|
735
739
|
short: 'c',
|
|
736
740
|
description: 'Require consensus for completion',
|
|
737
741
|
type: 'boolean',
|
|
738
|
-
|
|
742
|
+
default: false
|
|
739
743
|
},
|
|
740
744
|
{
|
|
741
745
|
name: 'timeout',
|
|
742
746
|
description: 'Task timeout in seconds',
|
|
743
747
|
type: 'number',
|
|
744
|
-
|
|
748
|
+
default: 300
|
|
745
749
|
}
|
|
746
750
|
],
|
|
747
751
|
examples: [
|
|
748
752
|
{ command: 'claude-flow hive-mind task -d "Implement auth module"', description: 'Submit task' },
|
|
749
753
|
{ command: 'claude-flow hive-mind task -d "Security review" -p critical -c', description: 'Critical task with consensus' }
|
|
750
754
|
],
|
|
751
|
-
action:
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
return [4 /*yield*/, callMCPTool('hive-mind_task', {
|
|
778
|
-
description: description,
|
|
779
|
-
priority: priority,
|
|
780
|
-
requireConsensus: requireConsensus,
|
|
781
|
-
timeout: timeout
|
|
782
|
-
})];
|
|
783
|
-
case 4:
|
|
784
|
-
result = _a.sent();
|
|
785
|
-
if (ctx.flags.format === 'json') {
|
|
786
|
-
output.printJson(result);
|
|
787
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
788
|
-
}
|
|
789
|
-
output.writeln();
|
|
790
|
-
output.printBox([
|
|
791
|
-
"Task ID: " + result.taskId,
|
|
792
|
-
"Status: " + formatAgentStatus(result.status),
|
|
793
|
-
"Priority: " + formatPriority(priority),
|
|
794
|
-
"Assigned: " + result.assignedTo.join(', '),
|
|
795
|
-
"Consensus: " + (result.requiresConsensus ? 'Yes' : 'No'),
|
|
796
|
-
"Est. Time: " + result.estimatedTime
|
|
797
|
-
].join('\n'), 'Task Submitted');
|
|
798
|
-
output.writeln();
|
|
799
|
-
output.printSuccess('Task submitted to hive');
|
|
800
|
-
output.writeln(output.dim(" Track with: claude-flow hive-mind task-status " + result.taskId));
|
|
801
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
802
|
-
case 5:
|
|
803
|
-
error_5 = _a.sent();
|
|
804
|
-
if (error_5 instanceof MCPClientError) {
|
|
805
|
-
output.printError("Task submission error: " + error_5.message);
|
|
806
|
-
}
|
|
807
|
-
else {
|
|
808
|
-
output.printError("Unexpected error: " + String(error_5));
|
|
809
|
-
}
|
|
810
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
811
|
-
case 6: return [2 /*return*/];
|
|
755
|
+
action: async (ctx) => {
|
|
756
|
+
let description = ctx.flags.description || ctx.args.join(' ');
|
|
757
|
+
if (!description && ctx.interactive) {
|
|
758
|
+
description = await input({
|
|
759
|
+
message: 'Task description:',
|
|
760
|
+
validate: (v) => v.length > 0 || 'Description is required'
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
if (!description) {
|
|
764
|
+
output.printError('Task description is required');
|
|
765
|
+
return { success: false, exitCode: 1 };
|
|
766
|
+
}
|
|
767
|
+
const priority = ctx.flags.priority;
|
|
768
|
+
const requireConsensus = ctx.flags.requireConsensus;
|
|
769
|
+
const timeout = ctx.flags.timeout;
|
|
770
|
+
output.printInfo('Submitting task to hive...');
|
|
771
|
+
try {
|
|
772
|
+
const result = await callMCPTool('hive-mind_task', {
|
|
773
|
+
description,
|
|
774
|
+
priority,
|
|
775
|
+
requireConsensus,
|
|
776
|
+
timeout,
|
|
777
|
+
});
|
|
778
|
+
if (ctx.flags.format === 'json') {
|
|
779
|
+
output.printJson(result);
|
|
780
|
+
return { success: true, data: result };
|
|
812
781
|
}
|
|
813
|
-
|
|
814
|
-
|
|
782
|
+
output.writeln();
|
|
783
|
+
output.printBox([
|
|
784
|
+
`Task ID: ${result.taskId}`,
|
|
785
|
+
`Status: ${formatAgentStatus(result.status)}`,
|
|
786
|
+
`Priority: ${formatPriority(priority)}`,
|
|
787
|
+
`Assigned: ${result.assignedTo.join(', ')}`,
|
|
788
|
+
`Consensus: ${result.requiresConsensus ? 'Yes' : 'No'}`,
|
|
789
|
+
`Est. Time: ${result.estimatedTime}`
|
|
790
|
+
].join('\n'), 'Task Submitted');
|
|
791
|
+
output.writeln();
|
|
792
|
+
output.printSuccess('Task submitted to hive');
|
|
793
|
+
output.writeln(output.dim(` Track with: claude-flow hive-mind task-status ${result.taskId}`));
|
|
794
|
+
return { success: true, data: result };
|
|
795
|
+
}
|
|
796
|
+
catch (error) {
|
|
797
|
+
if (error instanceof MCPClientError) {
|
|
798
|
+
output.printError(`Task submission error: ${error.message}`);
|
|
799
|
+
}
|
|
800
|
+
else {
|
|
801
|
+
output.printError(`Unexpected error: ${String(error)}`);
|
|
802
|
+
}
|
|
803
|
+
return { success: false, exitCode: 1 };
|
|
804
|
+
}
|
|
805
|
+
}
|
|
815
806
|
};
|
|
816
807
|
// Optimize memory subcommand
|
|
817
|
-
|
|
808
|
+
const optimizeMemoryCommand = {
|
|
818
809
|
name: 'optimize-memory',
|
|
819
810
|
description: 'Optimize hive memory and patterns',
|
|
820
811
|
options: [
|
|
@@ -823,305 +814,245 @@ var optimizeMemoryCommand = {
|
|
|
823
814
|
short: 'a',
|
|
824
815
|
description: 'Aggressive optimization',
|
|
825
816
|
type: 'boolean',
|
|
826
|
-
|
|
817
|
+
default: false
|
|
827
818
|
},
|
|
828
819
|
{
|
|
829
820
|
name: 'threshold',
|
|
830
821
|
description: 'Quality threshold for pattern retention',
|
|
831
822
|
type: 'number',
|
|
832
|
-
|
|
823
|
+
default: 0.7
|
|
833
824
|
}
|
|
834
825
|
],
|
|
835
|
-
action:
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
case 3:
|
|
879
|
-
error_6 = _a.sent();
|
|
880
|
-
spinner.fail('Optimization failed');
|
|
881
|
-
if (error_6 instanceof MCPClientError) {
|
|
882
|
-
output.printError("Optimization error: " + error_6.message);
|
|
883
|
-
}
|
|
884
|
-
else {
|
|
885
|
-
output.printError("Unexpected error: " + String(error_6));
|
|
886
|
-
}
|
|
887
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
888
|
-
case 4: return [2 /*return*/];
|
|
826
|
+
action: async (ctx) => {
|
|
827
|
+
const aggressive = ctx.flags.aggressive;
|
|
828
|
+
const threshold = ctx.flags.threshold;
|
|
829
|
+
output.printInfo('Optimizing hive memory...');
|
|
830
|
+
const spinner = output.createSpinner({ text: 'Analyzing patterns...', spinner: 'dots' });
|
|
831
|
+
spinner.start();
|
|
832
|
+
try {
|
|
833
|
+
const result = await callMCPTool('hive-mind_optimize-memory', {
|
|
834
|
+
aggressive,
|
|
835
|
+
qualityThreshold: threshold,
|
|
836
|
+
});
|
|
837
|
+
spinner.succeed('Memory optimized');
|
|
838
|
+
if (ctx.flags.format === 'json') {
|
|
839
|
+
output.printJson(result);
|
|
840
|
+
return { success: true, data: result };
|
|
841
|
+
}
|
|
842
|
+
output.writeln();
|
|
843
|
+
output.printTable({
|
|
844
|
+
columns: [
|
|
845
|
+
{ key: 'metric', header: 'Metric', width: 20 },
|
|
846
|
+
{ key: 'before', header: 'Before', width: 15, align: 'right' },
|
|
847
|
+
{ key: 'after', header: 'After', width: 15, align: 'right' }
|
|
848
|
+
],
|
|
849
|
+
data: [
|
|
850
|
+
{ metric: 'Patterns', before: result.before.patterns, after: result.after.patterns },
|
|
851
|
+
{ metric: 'Memory', before: result.before.memory, after: result.after.memory }
|
|
852
|
+
]
|
|
853
|
+
});
|
|
854
|
+
output.writeln();
|
|
855
|
+
output.printList([
|
|
856
|
+
`Patterns removed: ${result.removed}`,
|
|
857
|
+
`Patterns consolidated: ${result.consolidated}`,
|
|
858
|
+
`Optimization time: ${result.timeMs}ms`
|
|
859
|
+
]);
|
|
860
|
+
return { success: true, data: result };
|
|
861
|
+
}
|
|
862
|
+
catch (error) {
|
|
863
|
+
spinner.fail('Optimization failed');
|
|
864
|
+
if (error instanceof MCPClientError) {
|
|
865
|
+
output.printError(`Optimization error: ${error.message}`);
|
|
866
|
+
}
|
|
867
|
+
else {
|
|
868
|
+
output.printError(`Unexpected error: ${String(error)}`);
|
|
889
869
|
}
|
|
890
|
-
|
|
891
|
-
|
|
870
|
+
return { success: false, exitCode: 1 };
|
|
871
|
+
}
|
|
872
|
+
}
|
|
892
873
|
};
|
|
893
874
|
// Join subcommand
|
|
894
|
-
|
|
875
|
+
const joinCommand = {
|
|
895
876
|
name: 'join',
|
|
896
877
|
description: 'Join an agent to the hive mind',
|
|
897
878
|
options: [
|
|
898
879
|
{ name: 'agent-id', short: 'a', description: 'Agent ID to join', type: 'string' },
|
|
899
|
-
{ name: 'role', short: 'r', description: 'Agent role (worker, specialist, scout)', type: 'string',
|
|
880
|
+
{ name: 'role', short: 'r', description: 'Agent role (worker, specialist, scout)', type: 'string', default: 'worker' }
|
|
900
881
|
],
|
|
901
|
-
action:
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
case 1:
|
|
913
|
-
_a.trys.push([1, 3, , 4]);
|
|
914
|
-
return [4 /*yield*/, callMCPTool('hive-mind_join', { agentId: agentId, role: ctx.flags.role })];
|
|
915
|
-
case 2:
|
|
916
|
-
result = _a.sent();
|
|
917
|
-
if (!result.success) {
|
|
918
|
-
output.printError(result.error || 'Failed');
|
|
919
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
920
|
-
}
|
|
921
|
-
output.printSuccess("Agent " + agentId + " joined hive (" + result.totalWorkers + " workers)");
|
|
922
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
923
|
-
case 3:
|
|
924
|
-
error_7 = _a.sent();
|
|
925
|
-
output.printError("Join error: " + (error_7 instanceof MCPClientError ? error_7.message : String(error_7)));
|
|
926
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
927
|
-
case 4: return [2 /*return*/];
|
|
882
|
+
action: async (ctx) => {
|
|
883
|
+
const agentId = ctx.args[0] || ctx.flags['agent-id'] || ctx.flags.agentId;
|
|
884
|
+
if (!agentId) {
|
|
885
|
+
output.printError('Agent ID is required. Use --agent-id or -a flag, or provide as argument.');
|
|
886
|
+
return { success: false, exitCode: 1 };
|
|
887
|
+
}
|
|
888
|
+
try {
|
|
889
|
+
const result = await callMCPTool('hive-mind_join', { agentId, role: ctx.flags.role });
|
|
890
|
+
if (!result.success) {
|
|
891
|
+
output.printError(result.error || 'Failed');
|
|
892
|
+
return { success: false, exitCode: 1 };
|
|
928
893
|
}
|
|
929
|
-
|
|
930
|
-
|
|
894
|
+
output.printSuccess(`Agent ${agentId} joined hive (${result.totalWorkers} workers)`);
|
|
895
|
+
return { success: true, data: result };
|
|
896
|
+
}
|
|
897
|
+
catch (error) {
|
|
898
|
+
output.printError(`Join error: ${error instanceof MCPClientError ? error.message : String(error)}`);
|
|
899
|
+
return { success: false, exitCode: 1 };
|
|
900
|
+
}
|
|
901
|
+
}
|
|
931
902
|
};
|
|
932
903
|
// Leave subcommand
|
|
933
|
-
|
|
904
|
+
const leaveCommand = {
|
|
934
905
|
name: 'leave',
|
|
935
906
|
description: 'Remove an agent from the hive mind',
|
|
936
907
|
options: [{ name: 'agent-id', short: 'a', description: 'Agent ID to remove', type: 'string' }],
|
|
937
|
-
action:
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
case 1:
|
|
949
|
-
_a.trys.push([1, 3, , 4]);
|
|
950
|
-
return [4 /*yield*/, callMCPTool('hive-mind_leave', { agentId: agentId })];
|
|
951
|
-
case 2:
|
|
952
|
-
result = _a.sent();
|
|
953
|
-
if (!result.success) {
|
|
954
|
-
output.printError(result.error || 'Failed');
|
|
955
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
956
|
-
}
|
|
957
|
-
output.printSuccess("Agent " + agentId + " left hive (" + result.remainingWorkers + " remaining)");
|
|
958
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
959
|
-
case 3:
|
|
960
|
-
error_8 = _a.sent();
|
|
961
|
-
output.printError("Leave error: " + (error_8 instanceof MCPClientError ? error_8.message : String(error_8)));
|
|
962
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
963
|
-
case 4: return [2 /*return*/];
|
|
908
|
+
action: async (ctx) => {
|
|
909
|
+
const agentId = ctx.args[0] || ctx.flags['agent-id'] || ctx.flags.agentId;
|
|
910
|
+
if (!agentId) {
|
|
911
|
+
output.printError('Agent ID required.');
|
|
912
|
+
return { success: false, exitCode: 1 };
|
|
913
|
+
}
|
|
914
|
+
try {
|
|
915
|
+
const result = await callMCPTool('hive-mind_leave', { agentId });
|
|
916
|
+
if (!result.success) {
|
|
917
|
+
output.printError(result.error || 'Failed');
|
|
918
|
+
return { success: false, exitCode: 1 };
|
|
964
919
|
}
|
|
965
|
-
|
|
966
|
-
|
|
920
|
+
output.printSuccess(`Agent ${agentId} left hive (${result.remainingWorkers} remaining)`);
|
|
921
|
+
return { success: true, data: result };
|
|
922
|
+
}
|
|
923
|
+
catch (error) {
|
|
924
|
+
output.printError(`Leave error: ${error instanceof MCPClientError ? error.message : String(error)}`);
|
|
925
|
+
return { success: false, exitCode: 1 };
|
|
926
|
+
}
|
|
927
|
+
}
|
|
967
928
|
};
|
|
968
929
|
// Consensus subcommand
|
|
969
|
-
|
|
930
|
+
const consensusCommand = {
|
|
970
931
|
name: 'consensus',
|
|
971
932
|
description: 'Manage consensus proposals and voting',
|
|
972
933
|
options: [
|
|
973
|
-
{ name: 'action', short: 'a', description: 'Consensus action', type: 'string', choices: ['propose', 'vote', 'status', 'list'],
|
|
934
|
+
{ name: 'action', short: 'a', description: 'Consensus action', type: 'string', choices: ['propose', 'vote', 'status', 'list'], default: 'list' },
|
|
974
935
|
{ name: 'proposal-id', short: 'p', description: 'Proposal ID', type: 'string' },
|
|
975
936
|
{ name: 'type', short: 't', description: 'Proposal type', type: 'string' },
|
|
976
937
|
{ name: 'value', description: 'Proposal value', type: 'string' },
|
|
977
938
|
{ name: 'vote', short: 'v', description: 'Vote (yes/no)', type: 'string' },
|
|
978
939
|
{ name: 'voter-id', description: 'Voter agent ID', type: 'string' }
|
|
979
940
|
],
|
|
980
|
-
action:
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
pending = result.pending || [];
|
|
999
|
-
if (pending.length === 0)
|
|
1000
|
-
output.printInfo('No pending proposals');
|
|
1001
|
-
else
|
|
1002
|
-
output.printTable({ columns: [{ key: 'proposalId', header: 'ID', width: 30 }, { key: 'type', header: 'Type', width: 12 }], data: pending });
|
|
1003
|
-
}
|
|
1004
|
-
else if (action === 'propose') {
|
|
1005
|
-
output.printSuccess("Proposal created: " + result.proposalId);
|
|
1006
|
-
}
|
|
1007
|
-
else if (action === 'vote') {
|
|
1008
|
-
output.printSuccess("Vote recorded (For: " + result.votesFor + ", Against: " + result.votesAgainst + ")");
|
|
1009
|
-
}
|
|
1010
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
1011
|
-
case 3:
|
|
1012
|
-
error_9 = _a.sent();
|
|
1013
|
-
output.printError("Consensus error: " + (error_9 instanceof MCPClientError ? error_9.message : String(error_9)));
|
|
1014
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
1015
|
-
case 4: return [2 /*return*/];
|
|
941
|
+
action: async (ctx) => {
|
|
942
|
+
const action = ctx.flags.action || 'list';
|
|
943
|
+
try {
|
|
944
|
+
const result = await callMCPTool('hive-mind_consensus', { action, proposalId: ctx.flags.proposalId, type: ctx.flags.type, value: ctx.flags.value, vote: ctx.flags.vote === 'yes', voterId: ctx.flags.voterId });
|
|
945
|
+
if (ctx.flags.format === 'json') {
|
|
946
|
+
output.printJson(result);
|
|
947
|
+
return { success: true, data: result };
|
|
948
|
+
}
|
|
949
|
+
if (action === 'list') {
|
|
950
|
+
output.writeln(output.bold('\nPending Proposals'));
|
|
951
|
+
const pending = result.pending || [];
|
|
952
|
+
if (pending.length === 0)
|
|
953
|
+
output.printInfo('No pending proposals');
|
|
954
|
+
else
|
|
955
|
+
output.printTable({ columns: [{ key: 'proposalId', header: 'ID', width: 30 }, { key: 'type', header: 'Type', width: 12 }], data: pending });
|
|
956
|
+
}
|
|
957
|
+
else if (action === 'propose') {
|
|
958
|
+
output.printSuccess(`Proposal created: ${result.proposalId}`);
|
|
1016
959
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
960
|
+
else if (action === 'vote') {
|
|
961
|
+
output.printSuccess(`Vote recorded (For: ${result.votesFor}, Against: ${result.votesAgainst})`);
|
|
962
|
+
}
|
|
963
|
+
return { success: true, data: result };
|
|
964
|
+
}
|
|
965
|
+
catch (error) {
|
|
966
|
+
output.printError(`Consensus error: ${error instanceof MCPClientError ? error.message : String(error)}`);
|
|
967
|
+
return { success: false, exitCode: 1 };
|
|
968
|
+
}
|
|
969
|
+
}
|
|
1019
970
|
};
|
|
1020
971
|
// Broadcast subcommand
|
|
1021
|
-
|
|
972
|
+
const broadcastCommand = {
|
|
1022
973
|
name: 'broadcast',
|
|
1023
974
|
description: 'Broadcast a message to all workers in the hive',
|
|
1024
975
|
options: [
|
|
1025
976
|
{ name: 'message', short: 'm', description: 'Message to broadcast', type: 'string', required: true },
|
|
1026
|
-
{ name: 'priority', short: 'p', description: 'Message priority', type: 'string', choices: ['low', 'normal', 'high', 'critical'],
|
|
977
|
+
{ name: 'priority', short: 'p', description: 'Message priority', type: 'string', choices: ['low', 'normal', 'high', 'critical'], default: 'normal' },
|
|
1027
978
|
{ name: 'from', short: 'f', description: 'Sender agent ID', type: 'string' }
|
|
1028
979
|
],
|
|
1029
|
-
action:
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
case 1:
|
|
1041
|
-
_a.trys.push([1, 3, , 4]);
|
|
1042
|
-
return [4 /*yield*/, callMCPTool('hive-mind_broadcast', { message: message, priority: ctx.flags.priority, fromId: ctx.flags.from })];
|
|
1043
|
-
case 2:
|
|
1044
|
-
result = _a.sent();
|
|
1045
|
-
if (!result.success) {
|
|
1046
|
-
output.printError(result.error || 'Failed');
|
|
1047
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
1048
|
-
}
|
|
1049
|
-
output.printSuccess("Message broadcast to " + result.recipients + " workers (ID: " + result.messageId + ")");
|
|
1050
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
1051
|
-
case 3:
|
|
1052
|
-
error_10 = _a.sent();
|
|
1053
|
-
output.printError("Broadcast error: " + (error_10 instanceof MCPClientError ? error_10.message : String(error_10)));
|
|
1054
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
1055
|
-
case 4: return [2 /*return*/];
|
|
980
|
+
action: async (ctx) => {
|
|
981
|
+
const message = ctx.args.join(' ') || ctx.flags.message;
|
|
982
|
+
if (!message) {
|
|
983
|
+
output.printError('Message required. Use --message or -m flag.');
|
|
984
|
+
return { success: false, exitCode: 1 };
|
|
985
|
+
}
|
|
986
|
+
try {
|
|
987
|
+
const result = await callMCPTool('hive-mind_broadcast', { message, priority: ctx.flags.priority, fromId: ctx.flags.from });
|
|
988
|
+
if (!result.success) {
|
|
989
|
+
output.printError(result.error || 'Failed');
|
|
990
|
+
return { success: false, exitCode: 1 };
|
|
1056
991
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
992
|
+
output.printSuccess(`Message broadcast to ${result.recipients} workers (ID: ${result.messageId})`);
|
|
993
|
+
return { success: true, data: result };
|
|
994
|
+
}
|
|
995
|
+
catch (error) {
|
|
996
|
+
output.printError(`Broadcast error: ${error instanceof MCPClientError ? error.message : String(error)}`);
|
|
997
|
+
return { success: false, exitCode: 1 };
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1059
1000
|
};
|
|
1060
1001
|
// Memory subcommand
|
|
1061
|
-
|
|
1002
|
+
const memorySubCommand = {
|
|
1062
1003
|
name: 'memory',
|
|
1063
1004
|
description: 'Access hive shared memory',
|
|
1064
1005
|
options: [
|
|
1065
|
-
{ name: 'action', short: 'a', description: 'Memory action', type: 'string', choices: ['get', 'set', 'delete', 'list'],
|
|
1006
|
+
{ name: 'action', short: 'a', description: 'Memory action', type: 'string', choices: ['get', 'set', 'delete', 'list'], default: 'list' },
|
|
1066
1007
|
{ name: 'key', short: 'k', description: 'Memory key', type: 'string' },
|
|
1067
1008
|
{ name: 'value', short: 'v', description: 'Value to store', type: 'string' }
|
|
1068
1009
|
],
|
|
1069
|
-
action:
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
output.printList(keys.map(function (k) { return output.highlight(k); }));
|
|
1102
|
-
}
|
|
1103
|
-
else if (action === 'get') {
|
|
1104
|
-
output.writeln(output.bold("\nKey: " + key));
|
|
1105
|
-
output.writeln(result.exists ? "Value: " + JSON.stringify(result.value, null, 2) : 'Key not found');
|
|
1106
|
-
}
|
|
1107
|
-
else if (action === 'set') {
|
|
1108
|
-
output.printSuccess("Set " + key + " in shared memory");
|
|
1109
|
-
}
|
|
1110
|
-
else if (action === 'delete') {
|
|
1111
|
-
output.printSuccess(result.deleted ? "Deleted " + key : "Key " + key + " did not exist");
|
|
1112
|
-
}
|
|
1113
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
1114
|
-
case 3:
|
|
1115
|
-
error_11 = _a.sent();
|
|
1116
|
-
output.printError("Memory error: " + (error_11 instanceof MCPClientError ? error_11.message : String(error_11)));
|
|
1117
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
1118
|
-
case 4: return [2 /*return*/];
|
|
1010
|
+
action: async (ctx) => {
|
|
1011
|
+
const action = ctx.flags.action || 'list';
|
|
1012
|
+
const key = ctx.flags.key;
|
|
1013
|
+
const value = ctx.flags.value;
|
|
1014
|
+
if ((action === 'get' || action === 'delete') && !key) {
|
|
1015
|
+
output.printError('Key required for get/delete.');
|
|
1016
|
+
return { success: false, exitCode: 1 };
|
|
1017
|
+
}
|
|
1018
|
+
if (action === 'set' && (!key || value === undefined)) {
|
|
1019
|
+
output.printError('Key and value required for set.');
|
|
1020
|
+
return { success: false, exitCode: 1 };
|
|
1021
|
+
}
|
|
1022
|
+
try {
|
|
1023
|
+
const result = await callMCPTool('hive-mind_memory', { action, key, value });
|
|
1024
|
+
if (ctx.flags.format === 'json') {
|
|
1025
|
+
output.printJson(result);
|
|
1026
|
+
return { success: true, data: result };
|
|
1027
|
+
}
|
|
1028
|
+
if (action === 'list') {
|
|
1029
|
+
const keys = result.keys || [];
|
|
1030
|
+
output.writeln(output.bold(`\nShared Memory (${result.count} keys)`));
|
|
1031
|
+
if (keys.length === 0)
|
|
1032
|
+
output.printInfo('No keys in shared memory');
|
|
1033
|
+
else
|
|
1034
|
+
output.printList(keys.map(k => output.highlight(k)));
|
|
1035
|
+
}
|
|
1036
|
+
else if (action === 'get') {
|
|
1037
|
+
output.writeln(output.bold(`\nKey: ${key}`));
|
|
1038
|
+
output.writeln(result.exists ? `Value: ${JSON.stringify(result.value, null, 2)}` : 'Key not found');
|
|
1039
|
+
}
|
|
1040
|
+
else if (action === 'set') {
|
|
1041
|
+
output.printSuccess(`Set ${key} in shared memory`);
|
|
1119
1042
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1043
|
+
else if (action === 'delete') {
|
|
1044
|
+
output.printSuccess(result.deleted ? `Deleted ${key}` : `Key ${key} did not exist`);
|
|
1045
|
+
}
|
|
1046
|
+
return { success: true, data: result };
|
|
1047
|
+
}
|
|
1048
|
+
catch (error) {
|
|
1049
|
+
output.printError(`Memory error: ${error instanceof MCPClientError ? error.message : String(error)}`);
|
|
1050
|
+
return { success: false, exitCode: 1 };
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1122
1053
|
};
|
|
1123
1054
|
// Shutdown subcommand
|
|
1124
|
-
|
|
1055
|
+
const shutdownCommand = {
|
|
1125
1056
|
name: 'shutdown',
|
|
1126
1057
|
description: 'Shutdown the hive mind',
|
|
1127
1058
|
options: [
|
|
@@ -1130,73 +1061,60 @@ var shutdownCommand = {
|
|
|
1130
1061
|
short: 'f',
|
|
1131
1062
|
description: 'Force shutdown',
|
|
1132
1063
|
type: 'boolean',
|
|
1133
|
-
|
|
1064
|
+
default: false
|
|
1134
1065
|
},
|
|
1135
1066
|
{
|
|
1136
1067
|
name: 'save-state',
|
|
1137
1068
|
short: 's',
|
|
1138
1069
|
description: 'Save state before shutdown',
|
|
1139
1070
|
type: 'boolean',
|
|
1140
|
-
|
|
1071
|
+
default: true
|
|
1141
1072
|
}
|
|
1142
1073
|
],
|
|
1143
|
-
action:
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
})];
|
|
1155
|
-
case 1:
|
|
1156
|
-
confirmed = _a.sent();
|
|
1157
|
-
if (!confirmed) {
|
|
1158
|
-
output.printInfo('Operation cancelled');
|
|
1159
|
-
return [2 /*return*/, { success: true }];
|
|
1160
|
-
}
|
|
1161
|
-
_a.label = 2;
|
|
1162
|
-
case 2:
|
|
1163
|
-
output.printInfo('Shutting down hive mind...');
|
|
1164
|
-
spinner = output.createSpinner({ text: 'Graceful shutdown in progress...', spinner: 'dots' });
|
|
1165
|
-
spinner.start();
|
|
1166
|
-
_a.label = 3;
|
|
1167
|
-
case 3:
|
|
1168
|
-
_a.trys.push([3, 5, , 6]);
|
|
1169
|
-
return [4 /*yield*/, callMCPTool('hive-mind_shutdown', {
|
|
1170
|
-
force: force,
|
|
1171
|
-
saveState: saveState
|
|
1172
|
-
})];
|
|
1173
|
-
case 4:
|
|
1174
|
-
result = _a.sent();
|
|
1175
|
-
spinner.succeed('Hive mind shutdown complete');
|
|
1176
|
-
output.writeln();
|
|
1177
|
-
output.printList([
|
|
1178
|
-
"Agents terminated: " + result.agentsTerminated,
|
|
1179
|
-
"State saved: " + (result.stateSaved ? 'Yes' : 'No'),
|
|
1180
|
-
"Shutdown time: " + result.shutdownTime
|
|
1181
|
-
]);
|
|
1182
|
-
return [2 /*return*/, { success: true, data: result }];
|
|
1183
|
-
case 5:
|
|
1184
|
-
error_12 = _a.sent();
|
|
1185
|
-
spinner.fail('Shutdown failed');
|
|
1186
|
-
if (error_12 instanceof MCPClientError) {
|
|
1187
|
-
output.printError("Shutdown error: " + error_12.message);
|
|
1188
|
-
}
|
|
1189
|
-
else {
|
|
1190
|
-
output.printError("Unexpected error: " + String(error_12));
|
|
1191
|
-
}
|
|
1192
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
1193
|
-
case 6: return [2 /*return*/];
|
|
1074
|
+
action: async (ctx) => {
|
|
1075
|
+
const force = ctx.flags.force;
|
|
1076
|
+
const saveState = ctx.flags.saveState;
|
|
1077
|
+
if (!force && ctx.interactive) {
|
|
1078
|
+
const confirmed = await confirm({
|
|
1079
|
+
message: 'Shutdown the hive mind? All agents will be terminated.',
|
|
1080
|
+
default: false
|
|
1081
|
+
});
|
|
1082
|
+
if (!confirmed) {
|
|
1083
|
+
output.printInfo('Operation cancelled');
|
|
1084
|
+
return { success: true };
|
|
1194
1085
|
}
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1086
|
+
}
|
|
1087
|
+
output.printInfo('Shutting down hive mind...');
|
|
1088
|
+
const spinner = output.createSpinner({ text: 'Graceful shutdown in progress...', spinner: 'dots' });
|
|
1089
|
+
spinner.start();
|
|
1090
|
+
try {
|
|
1091
|
+
const result = await callMCPTool('hive-mind_shutdown', {
|
|
1092
|
+
force,
|
|
1093
|
+
saveState,
|
|
1094
|
+
});
|
|
1095
|
+
spinner.succeed('Hive mind shutdown complete');
|
|
1096
|
+
output.writeln();
|
|
1097
|
+
output.printList([
|
|
1098
|
+
`Agents terminated: ${result.agentsTerminated}`,
|
|
1099
|
+
`State saved: ${result.stateSaved ? 'Yes' : 'No'}`,
|
|
1100
|
+
`Shutdown time: ${result.shutdownTime}`
|
|
1101
|
+
]);
|
|
1102
|
+
return { success: true, data: result };
|
|
1103
|
+
}
|
|
1104
|
+
catch (error) {
|
|
1105
|
+
spinner.fail('Shutdown failed');
|
|
1106
|
+
if (error instanceof MCPClientError) {
|
|
1107
|
+
output.printError(`Shutdown error: ${error.message}`);
|
|
1108
|
+
}
|
|
1109
|
+
else {
|
|
1110
|
+
output.printError(`Unexpected error: ${String(error)}`);
|
|
1111
|
+
}
|
|
1112
|
+
return { success: false, exitCode: 1 };
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1197
1115
|
};
|
|
1198
1116
|
// Main hive-mind command
|
|
1199
|
-
export
|
|
1117
|
+
export const hiveMindCommand = {
|
|
1200
1118
|
name: 'hive-mind',
|
|
1201
1119
|
aliases: ['hive'],
|
|
1202
1120
|
description: 'Queen-led consensus-based multi-agent coordination',
|
|
@@ -1208,48 +1126,46 @@ export var hiveMindCommand = {
|
|
|
1208
1126
|
{ command: 'claude-flow hive-mind spawn --claude -o "Build a feature"', description: 'Launch Claude Code with hive mind' },
|
|
1209
1127
|
{ command: 'claude-flow hive-mind task -d "Build feature"', description: 'Submit task' }
|
|
1210
1128
|
],
|
|
1211
|
-
action:
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
output.
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
});
|
|
1248
|
-
}); }
|
|
1129
|
+
action: async () => {
|
|
1130
|
+
output.writeln();
|
|
1131
|
+
output.writeln(output.bold('Hive Mind - Consensus-Based Multi-Agent Coordination'));
|
|
1132
|
+
output.writeln();
|
|
1133
|
+
output.writeln('Usage: claude-flow hive-mind <subcommand> [options]');
|
|
1134
|
+
output.writeln();
|
|
1135
|
+
output.writeln('Subcommands:');
|
|
1136
|
+
output.printList([
|
|
1137
|
+
`${output.highlight('init')} - Initialize hive mind`,
|
|
1138
|
+
`${output.highlight('spawn')} - Spawn worker agents (use --claude to launch Claude Code)`,
|
|
1139
|
+
`${output.highlight('status')} - Show hive status`,
|
|
1140
|
+
`${output.highlight('task')} - Submit task to hive`,
|
|
1141
|
+
`${output.highlight('join')} - Join an agent to the hive`,
|
|
1142
|
+
`${output.highlight('leave')} - Remove an agent from the hive`,
|
|
1143
|
+
`${output.highlight('consensus')} - Manage consensus proposals`,
|
|
1144
|
+
`${output.highlight('broadcast')} - Broadcast message to workers`,
|
|
1145
|
+
`${output.highlight('memory')} - Access shared memory`,
|
|
1146
|
+
`${output.highlight('optimize-memory')} - Optimize patterns and memory`,
|
|
1147
|
+
`${output.highlight('shutdown')} - Shutdown the hive`
|
|
1148
|
+
]);
|
|
1149
|
+
output.writeln();
|
|
1150
|
+
output.writeln('Features:');
|
|
1151
|
+
output.printList([
|
|
1152
|
+
'Queen-led hierarchical coordination',
|
|
1153
|
+
'Byzantine fault tolerant consensus',
|
|
1154
|
+
'HNSW-accelerated pattern matching',
|
|
1155
|
+
'Cross-session memory persistence',
|
|
1156
|
+
'Automatic load balancing',
|
|
1157
|
+
output.success('NEW: --claude flag to launch interactive Claude Code sessions')
|
|
1158
|
+
]);
|
|
1159
|
+
output.writeln();
|
|
1160
|
+
output.writeln('Quick Start with Claude Code:');
|
|
1161
|
+
output.writeln(output.dim(' claude-flow hive-mind init'));
|
|
1162
|
+
output.writeln(output.dim(' claude-flow hive-mind spawn -n 5 --claude -o "Your objective here"'));
|
|
1163
|
+
return { success: true };
|
|
1164
|
+
}
|
|
1249
1165
|
};
|
|
1250
1166
|
// Helper functions
|
|
1251
1167
|
function formatAgentStatus(status) {
|
|
1252
|
-
|
|
1168
|
+
const statusStr = String(status);
|
|
1253
1169
|
switch (statusStr) {
|
|
1254
1170
|
case 'active':
|
|
1255
1171
|
case 'ready':
|