claude-flow-novice 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli/commands/guidance.js +487 -668
- package/dist/src/cli/commands/index-validate.js +18 -29
- package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
- package/dist/src/cli/commands/neural-goal-init.js +92 -125
- package/dist/src/cli/commands/swarm-exec.js +317 -393
- package/dist/src/cli/commands/swarm.js +1 -1
- package/dist/src/cli/commands/validate-framework.js +983 -1100
- package/dist/src/cli/commands/validate.js +144 -223
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
- package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
- package/dist/src/cli/simple-commands/agent.js +157 -193
- package/dist/src/cli/simple-commands/analysis.js +336 -446
- package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
- package/dist/src/cli/simple-commands/automation.js +481 -469
- package/dist/src/cli/simple-commands/batch-manager.js +261 -313
- package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
- package/dist/src/cli/simple-commands/claude-track.js +68 -90
- package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
- package/dist/src/cli/simple-commands/config.js +245 -290
- package/dist/src/cli/simple-commands/coordination.js +182 -234
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
- package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
- package/dist/src/cli/simple-commands/github/github-api.js +535 -574
- package/dist/src/cli/simple-commands/github/init.js +276 -303
- package/dist/src/cli/simple-commands/github.js +222 -247
- package/dist/src/cli/simple-commands/goal.js +51 -63
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
- package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
- package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
- package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
- package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
- package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
- package/dist/src/cli/simple-commands/hive.js +90 -79
- package/dist/src/cli/simple-commands/hook-safety.js +431 -521
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
- package/dist/src/cli/simple-commands/hooks.js +1064 -1204
- package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
- package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
- package/dist/src/cli/simple-commands/init/help.js +104 -107
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
- package/dist/src/cli/simple-commands/init/index.js +1510 -1759
- package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
- package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
- package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
- package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
- package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
- package/dist/src/cli/simple-commands/init.js +1 -2
- package/dist/src/cli/simple-commands/mcp-health.js +131 -158
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
- package/dist/src/cli/simple-commands/mcp.js +345 -400
- package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
- package/dist/src/cli/simple-commands/memory.js +247 -311
- package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
- package/dist/src/cli/simple-commands/monitor.js +294 -363
- package/dist/src/cli/simple-commands/neural.js +51 -65
- package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
- package/dist/src/cli/simple-commands/pair-basic.js +528 -656
- package/dist/src/cli/simple-commands/pair-old.js +430 -543
- package/dist/src/cli/simple-commands/pair-working.js +615 -751
- package/dist/src/cli/simple-commands/pair.js +615 -751
- package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
- package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
- package/dist/src/cli/simple-commands/process-ui.js +230 -254
- package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
- package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
- package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
- package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
- package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
- package/dist/src/cli/simple-commands/sparc/index.js +241 -298
- package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
- package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
- package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
- package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/index.js +47 -55
- package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/swarm.js +101 -87
- package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
- package/dist/src/cli/simple-commands/sparc.js +465 -493
- package/dist/src/cli/simple-commands/start-ui.js +108 -132
- package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +254 -275
- package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
- package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
- package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
- package/dist/src/cli/simple-commands/stream-chain.js +260 -318
- package/dist/src/cli/simple-commands/stream-processor.js +290 -315
- package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
- package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
- package/dist/src/cli/simple-commands/swarm.js +887 -1082
- package/dist/src/cli/simple-commands/task.js +161 -206
- package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
- package/dist/src/cli/simple-commands/token-tracker.js +258 -316
- package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
- package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
- package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
- package/dist/src/cli/simple-commands/training.js +170 -227
- package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
- package/dist/src/cli/simple-commands/verification-integration.js +389 -417
- package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
- package/dist/src/cli/simple-commands/verification.js +493 -513
- package/dist/src/cli/simple-commands/web-server.js +766 -836
- package/dist/src/cli/simple-commands/webui-validator.js +106 -124
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
- package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
- package/dist/src/coordination/iteration-tracker.js +363 -454
- package/dist/src/enterprise/analytics-manager.js +1135 -0
- package/dist/src/enterprise/audit-manager.js +1115 -0
- package/dist/src/enterprise/cloud-manager.js +891 -0
- package/dist/src/enterprise/deployment-manager.js +966 -0
- package/dist/src/enterprise/index.js +6 -0
- package/dist/src/enterprise/project-manager.js +584 -0
- package/dist/src/enterprise/security-manager.js +991 -0
- package/dist/src/index.js +1 -1
- package/dist/src/mcp/DEPRECATED.js +46 -60
- package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
- package/dist/src/mcp/implementations/agent-tracker.js +114 -128
- package/dist/src/mcp/implementations/daa-tools.js +292 -350
- package/dist/src/mcp/implementations/workflow-tools.js +329 -361
- package/dist/src/mcp/mcp-config-manager.js +1183 -1331
- package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
- package/dist/src/mcp/mcp-server-novice.js +11 -17
- package/dist/src/mcp/mcp-server-sdk.js +11 -17
- package/dist/src/mcp/mcp-server.js +1620 -1484
- package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
- package/dist/src/memory/advanced-serializer.js +609 -589
- package/dist/src/memory/enhanced-examples.js +220 -305
- package/dist/src/memory/enhanced-memory.js +295 -336
- package/dist/src/memory/enhanced-session-serializer.js +408 -492
- package/dist/src/memory/fallback-memory-system.js +900 -1021
- package/dist/src/memory/fallback-store.js +93 -131
- package/dist/src/memory/high-performance-serialization.js +592 -730
- package/dist/src/memory/in-memory-store.js +161 -213
- package/dist/src/memory/index.js +123 -157
- package/dist/src/memory/lock-free-structures.js +578 -764
- package/dist/src/memory/memory-mapped-persistence.js +585 -766
- package/dist/src/memory/memory-pressure-manager.js +569 -707
- package/dist/src/memory/migration.js +358 -445
- package/dist/src/memory/shared-memory.js +641 -768
- package/dist/src/memory/sqlite-store.js +245 -325
- package/dist/src/memory/sqlite-wrapper.js +122 -151
- package/dist/src/memory/swarm-memory.js +470 -603
- package/dist/src/memory/test-example.js +126 -134
- package/dist/src/memory/ultra-fast-memory-store.js +622 -821
- package/dist/src/memory/unified-memory-manager.js +356 -437
- package/dist/src/migration/index.js +92 -0
- package/dist/src/migration/logger.js +121 -0
- package/dist/src/migration/migration-analyzer.js +268 -0
- package/dist/src/migration/migration-runner.js +522 -0
- package/dist/src/migration/migration-validator.js +285 -0
- package/dist/src/migration/progress-reporter.js +150 -0
- package/dist/src/migration/rollback-manager.js +321 -0
- package/dist/src/migration/tests/migration-system.test.js +7 -0
- package/dist/src/migration/types.js +3 -0
- package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
- package/dist/src/swarm/__tests__/integration.test.js +227 -0
- package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
- package/dist/src/swarm/advanced-orchestrator.js +1095 -0
- package/dist/src/swarm/claude-code-interface.js +961 -0
- package/dist/src/swarm/claude-flow-executor.js +229 -0
- package/dist/src/swarm/consensus-coordinator.js +475 -0
- package/dist/src/swarm/coordinator.js +2993 -0
- package/dist/src/swarm/direct-executor.js +1180 -0
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
- package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
- package/dist/src/swarm/executor-v2.js +322 -0
- package/dist/src/swarm/executor.js +815 -0
- package/dist/src/swarm/hive-mind-integration.js +703 -0
- package/dist/src/swarm/index.js +41 -0
- package/dist/src/swarm/json-output-aggregator.js +267 -0
- package/dist/src/swarm/large-scale-coordinator.js +542 -0
- package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
- package/dist/src/swarm/memory.js +1117 -0
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
- package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
- package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
- package/dist/src/swarm/optimizations/connection-pool.js +244 -0
- package/dist/src/swarm/optimizations/index.js +28 -0
- package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
- package/dist/src/swarm/optimizations/ttl-map.js +234 -0
- package/dist/src/swarm/prompt-cli.js +200 -0
- package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
- package/dist/src/swarm/prompt-copier.js +381 -0
- package/dist/src/swarm/prompt-manager.js +295 -0
- package/dist/src/swarm/prompt-utils.js +310 -0
- package/dist/src/swarm/result-aggregator.js +718 -0
- package/dist/src/swarm/sparc-executor.js +1568 -0
- package/dist/src/swarm/strategies/auto.js +758 -0
- package/dist/src/swarm/strategies/base.js +128 -0
- package/dist/src/swarm/strategies/research.js +914 -0
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
- package/dist/src/swarm/types.js +52 -0
- package/dist/src/swarm/workers/copy-worker.js +56 -0
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
- package/dist/src/utils/github-cli-safe.js +56 -64
- package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
- package/dist/src/utils/npx-isolated-cache.js +104 -119
- package/dist/src/utils/preference-manager.js +622 -652
- package/dist/src/utils/timezone-utils.js +86 -105
- package/dist/src/validators/epic-config-schema.js +214 -0
- package/dist/src/validators/index.js +10 -0
- package/dist/src/validators/swarm-init-validator.js +259 -0
- package/dist/src/validators/todowrite-batching-validator.js +215 -0
- package/dist/src/validators/todowrite-integration.js +187 -0
- package/package.json +2 -2
|
@@ -1,741 +1,661 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Enhanced Swarm UI with real-time monitoring and control
|
|
5
4
|
* Uses blessed for terminal UI
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const blessed = require('blessed');
|
|
5
|
+
*/ const blessed = require('blessed');
|
|
9
6
|
const fs = require('fs').promises;
|
|
10
7
|
const path = require('path');
|
|
11
8
|
const { spawn } = require('child_process');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
-
|
|
346
|
-
|
|
347
|
-
this.executeCommand(value);
|
|
348
|
-
this.commandBox.clearValue();
|
|
349
|
-
this.screen.render();
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
// Focus management
|
|
353
|
-
this.screen.key(['tab'], () => {
|
|
354
|
-
this.screen.focusNext();
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
this.screen.key(['S-tab'], () => {
|
|
358
|
-
this.screen.focusPrevious();
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
async startMonitoring() {
|
|
363
|
-
this.log('Starting swarm monitoring...');
|
|
364
|
-
|
|
365
|
-
// Update interval
|
|
366
|
-
this.updateInterval = setInterval(() => {
|
|
367
|
-
this.updateSwarmData();
|
|
368
|
-
}, 2000);
|
|
369
|
-
|
|
370
|
-
// Initial update
|
|
371
|
-
await this.updateSwarmData();
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
async updateSwarmData() {
|
|
375
|
-
try {
|
|
376
|
-
// Load swarm data from file system
|
|
377
|
-
const swarmRunsDir = './swarm-runs';
|
|
378
|
-
|
|
379
|
-
try {
|
|
380
|
-
const runs = await fs.readdir(swarmRunsDir);
|
|
381
|
-
this.swarmData.objectives = [];
|
|
382
|
-
this.swarmData.agents = [];
|
|
383
|
-
this.swarmData.tasks = [];
|
|
384
|
-
|
|
385
|
-
for (const runDir of runs) {
|
|
386
|
-
const configPath = path.join(swarmRunsDir, runDir, 'config.json');
|
|
387
|
-
try {
|
|
388
|
-
const configData = await fs.readFile(configPath, 'utf-8');
|
|
389
|
-
const config = JSON.parse(configData);
|
|
390
|
-
|
|
391
|
-
this.swarmData.objectives.push({
|
|
392
|
-
id: config.swarmId,
|
|
393
|
-
description: config.objective,
|
|
394
|
-
status: 'running',
|
|
395
|
-
startTime: config.startTime,
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
// Load agents
|
|
399
|
-
const agentsDir = path.join(swarmRunsDir, runDir, 'agents');
|
|
9
|
+
let SwarmUI = class SwarmUI {
|
|
10
|
+
async init() {
|
|
11
|
+
// Create blessed screen
|
|
12
|
+
this.screen = blessed.screen({
|
|
13
|
+
smartCSR: true,
|
|
14
|
+
title: 'Claude Flow - Swarm Control Center'
|
|
15
|
+
});
|
|
16
|
+
this.createLayout();
|
|
17
|
+
this.bindEvents();
|
|
18
|
+
this.startMonitoring();
|
|
19
|
+
this.screen.render();
|
|
20
|
+
}
|
|
21
|
+
createLayout() {
|
|
22
|
+
// Main container
|
|
23
|
+
const mainBox = blessed.box({
|
|
24
|
+
parent: this.screen,
|
|
25
|
+
top: 0,
|
|
26
|
+
left: 0,
|
|
27
|
+
width: '100%',
|
|
28
|
+
height: '100%',
|
|
29
|
+
border: {
|
|
30
|
+
type: 'line'
|
|
31
|
+
},
|
|
32
|
+
style: {
|
|
33
|
+
border: {
|
|
34
|
+
fg: 'cyan'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
// Header
|
|
39
|
+
this.headerBox = blessed.box({
|
|
40
|
+
parent: mainBox,
|
|
41
|
+
top: 0,
|
|
42
|
+
left: 0,
|
|
43
|
+
width: '100%',
|
|
44
|
+
height: 3,
|
|
45
|
+
content: '{center}🐝 Claude Flow Swarm Control Center{/center}',
|
|
46
|
+
tags: true,
|
|
47
|
+
style: {
|
|
48
|
+
fg: 'white',
|
|
49
|
+
bg: 'blue'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
// Status bar
|
|
53
|
+
this.statusBox = blessed.box({
|
|
54
|
+
parent: mainBox,
|
|
55
|
+
top: 2,
|
|
56
|
+
left: 0,
|
|
57
|
+
width: '100%',
|
|
58
|
+
height: 1,
|
|
59
|
+
content: 'Status: Initializing...',
|
|
60
|
+
style: {
|
|
61
|
+
fg: 'yellow'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
// Left panel - Objectives and Agents
|
|
65
|
+
const leftPanel = blessed.box({
|
|
66
|
+
parent: mainBox,
|
|
67
|
+
top: 3,
|
|
68
|
+
left: 0,
|
|
69
|
+
width: '30%',
|
|
70
|
+
height: '70%',
|
|
71
|
+
border: {
|
|
72
|
+
type: 'line'
|
|
73
|
+
},
|
|
74
|
+
label: ' Objectives & Agents ',
|
|
75
|
+
style: {
|
|
76
|
+
border: {
|
|
77
|
+
fg: 'green'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// Objectives list
|
|
82
|
+
this.objectivesList = blessed.list({
|
|
83
|
+
parent: leftPanel,
|
|
84
|
+
top: 0,
|
|
85
|
+
left: 0,
|
|
86
|
+
width: '100%',
|
|
87
|
+
height: '50%',
|
|
88
|
+
label: ' Objectives ',
|
|
89
|
+
items: [
|
|
90
|
+
'No objectives'
|
|
91
|
+
],
|
|
92
|
+
keys: true,
|
|
93
|
+
vi: true,
|
|
94
|
+
mouse: true,
|
|
95
|
+
style: {
|
|
96
|
+
selected: {
|
|
97
|
+
bg: 'blue'
|
|
98
|
+
},
|
|
99
|
+
item: {
|
|
100
|
+
fg: 'white'
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
// Agents list
|
|
105
|
+
this.agentsList = blessed.list({
|
|
106
|
+
parent: leftPanel,
|
|
107
|
+
top: '50%',
|
|
108
|
+
left: 0,
|
|
109
|
+
width: '100%',
|
|
110
|
+
height: '50%',
|
|
111
|
+
label: ' Agents ',
|
|
112
|
+
items: [
|
|
113
|
+
'No agents'
|
|
114
|
+
],
|
|
115
|
+
keys: true,
|
|
116
|
+
vi: true,
|
|
117
|
+
mouse: true,
|
|
118
|
+
style: {
|
|
119
|
+
selected: {
|
|
120
|
+
bg: 'green'
|
|
121
|
+
},
|
|
122
|
+
item: {
|
|
123
|
+
fg: 'white'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// Center panel - Tasks and Details
|
|
128
|
+
const centerPanel = blessed.box({
|
|
129
|
+
parent: mainBox,
|
|
130
|
+
top: 3,
|
|
131
|
+
left: '30%',
|
|
132
|
+
width: '40%',
|
|
133
|
+
height: '70%',
|
|
134
|
+
border: {
|
|
135
|
+
type: 'line'
|
|
136
|
+
},
|
|
137
|
+
label: ' Tasks & Details ',
|
|
138
|
+
style: {
|
|
139
|
+
border: {
|
|
140
|
+
fg: 'yellow'
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
// Tasks list
|
|
145
|
+
this.tasksList = blessed.list({
|
|
146
|
+
parent: centerPanel,
|
|
147
|
+
top: 0,
|
|
148
|
+
left: 0,
|
|
149
|
+
width: '100%',
|
|
150
|
+
height: '50%',
|
|
151
|
+
label: ' Tasks ',
|
|
152
|
+
items: [
|
|
153
|
+
'No tasks'
|
|
154
|
+
],
|
|
155
|
+
keys: true,
|
|
156
|
+
vi: true,
|
|
157
|
+
mouse: true,
|
|
158
|
+
style: {
|
|
159
|
+
selected: {
|
|
160
|
+
bg: 'yellow',
|
|
161
|
+
fg: 'black'
|
|
162
|
+
},
|
|
163
|
+
item: {
|
|
164
|
+
fg: 'white'
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
// Task details
|
|
169
|
+
this.taskDetails = blessed.box({
|
|
170
|
+
parent: centerPanel,
|
|
171
|
+
top: '50%',
|
|
172
|
+
left: 0,
|
|
173
|
+
width: '100%',
|
|
174
|
+
height: '50%',
|
|
175
|
+
label: ' Task Details ',
|
|
176
|
+
content: 'Select a task to view details',
|
|
177
|
+
scrollable: true,
|
|
178
|
+
alwaysScroll: true,
|
|
179
|
+
keys: true,
|
|
180
|
+
vi: true,
|
|
181
|
+
mouse: true,
|
|
182
|
+
style: {
|
|
183
|
+
fg: 'white'
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
// Right panel - Logs and Controls
|
|
187
|
+
const rightPanel = blessed.box({
|
|
188
|
+
parent: mainBox,
|
|
189
|
+
top: 3,
|
|
190
|
+
left: '70%',
|
|
191
|
+
width: '30%',
|
|
192
|
+
height: '70%',
|
|
193
|
+
border: {
|
|
194
|
+
type: 'line'
|
|
195
|
+
},
|
|
196
|
+
label: ' Logs & Controls ',
|
|
197
|
+
style: {
|
|
198
|
+
border: {
|
|
199
|
+
fg: 'magenta'
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
// Activity logs
|
|
204
|
+
this.logBox = blessed.log({
|
|
205
|
+
parent: rightPanel,
|
|
206
|
+
top: 0,
|
|
207
|
+
left: 0,
|
|
208
|
+
width: '100%',
|
|
209
|
+
height: '60%',
|
|
210
|
+
label: ' Activity Log ',
|
|
211
|
+
tags: true,
|
|
212
|
+
mouse: true,
|
|
213
|
+
scrollable: true,
|
|
214
|
+
alwaysScroll: true,
|
|
215
|
+
style: {
|
|
216
|
+
fg: 'white'
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
// Control buttons
|
|
220
|
+
this.controlBox = blessed.box({
|
|
221
|
+
parent: rightPanel,
|
|
222
|
+
top: '60%',
|
|
223
|
+
left: 0,
|
|
224
|
+
width: '100%',
|
|
225
|
+
height: '40%',
|
|
226
|
+
label: ' Controls '
|
|
227
|
+
});
|
|
228
|
+
// Create objective button
|
|
229
|
+
this.createButton = blessed.button({
|
|
230
|
+
parent: this.controlBox,
|
|
231
|
+
top: 1,
|
|
232
|
+
left: 1,
|
|
233
|
+
width: '90%',
|
|
234
|
+
height: 3,
|
|
235
|
+
content: 'Create Objective',
|
|
236
|
+
align: 'center',
|
|
237
|
+
style: {
|
|
238
|
+
bg: 'blue',
|
|
239
|
+
fg: 'white',
|
|
240
|
+
focus: {
|
|
241
|
+
bg: 'red'
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
// Stop swarm button
|
|
246
|
+
this.stopButton = blessed.button({
|
|
247
|
+
parent: this.controlBox,
|
|
248
|
+
top: 5,
|
|
249
|
+
left: 1,
|
|
250
|
+
width: '90%',
|
|
251
|
+
height: 3,
|
|
252
|
+
content: 'Stop Swarm',
|
|
253
|
+
align: 'center',
|
|
254
|
+
style: {
|
|
255
|
+
bg: 'red',
|
|
256
|
+
fg: 'white',
|
|
257
|
+
focus: {
|
|
258
|
+
bg: 'yellow',
|
|
259
|
+
fg: 'black'
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
// Bottom panel - Command input
|
|
264
|
+
this.commandBox = blessed.textbox({
|
|
265
|
+
parent: mainBox,
|
|
266
|
+
bottom: 0,
|
|
267
|
+
left: 0,
|
|
268
|
+
width: '100%',
|
|
269
|
+
height: 3,
|
|
270
|
+
label: ' Command Input (Press Enter to execute) ',
|
|
271
|
+
keys: true,
|
|
272
|
+
mouse: true,
|
|
273
|
+
inputOnFocus: true,
|
|
274
|
+
style: {
|
|
275
|
+
border: {
|
|
276
|
+
fg: 'cyan'
|
|
277
|
+
},
|
|
278
|
+
fg: 'white'
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
bindEvents() {
|
|
283
|
+
// Screen events
|
|
284
|
+
this.screen.key([
|
|
285
|
+
'escape',
|
|
286
|
+
'q',
|
|
287
|
+
'C-c'
|
|
288
|
+
], ()=>{
|
|
289
|
+
this.cleanup();
|
|
290
|
+
process.exit(0);
|
|
291
|
+
});
|
|
292
|
+
// Objective selection
|
|
293
|
+
this.objectivesList.on('select', (item, index)=>{
|
|
294
|
+
this.selectedObjective = this.swarmData.objectives[index];
|
|
295
|
+
this.updateTasksList();
|
|
296
|
+
this.log(`Selected objective: ${this.selectedObjective?.description || 'Unknown'}`);
|
|
297
|
+
});
|
|
298
|
+
// Task selection
|
|
299
|
+
this.tasksList.on('select', (item, index)=>{
|
|
300
|
+
const task = this.swarmData.tasks[index];
|
|
301
|
+
if (task) {
|
|
302
|
+
this.updateTaskDetails(task);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
// Create objective button
|
|
306
|
+
this.createButton.on('press', ()=>{
|
|
307
|
+
this.promptCreateObjective();
|
|
308
|
+
});
|
|
309
|
+
// Stop swarm button
|
|
310
|
+
this.stopButton.on('press', ()=>{
|
|
311
|
+
this.stopSwarm();
|
|
312
|
+
});
|
|
313
|
+
// Command input
|
|
314
|
+
this.commandBox.on('submit', (value)=>{
|
|
315
|
+
this.executeCommand(value);
|
|
316
|
+
this.commandBox.clearValue();
|
|
317
|
+
this.screen.render();
|
|
318
|
+
});
|
|
319
|
+
// Focus management
|
|
320
|
+
this.screen.key([
|
|
321
|
+
'tab'
|
|
322
|
+
], ()=>{
|
|
323
|
+
this.screen.focusNext();
|
|
324
|
+
});
|
|
325
|
+
this.screen.key([
|
|
326
|
+
'S-tab'
|
|
327
|
+
], ()=>{
|
|
328
|
+
this.screen.focusPrevious();
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
async startMonitoring() {
|
|
332
|
+
this.log('Starting swarm monitoring...');
|
|
333
|
+
// Update interval
|
|
334
|
+
this.updateInterval = setInterval(()=>{
|
|
335
|
+
this.updateSwarmData();
|
|
336
|
+
}, 2000);
|
|
337
|
+
// Initial update
|
|
338
|
+
await this.updateSwarmData();
|
|
339
|
+
}
|
|
340
|
+
async updateSwarmData() {
|
|
341
|
+
try {
|
|
342
|
+
// Load swarm data from file system
|
|
343
|
+
const swarmRunsDir = './swarm-runs';
|
|
400
344
|
try {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
345
|
+
const runs = await fs.readdir(swarmRunsDir);
|
|
346
|
+
this.swarmData.objectives = [];
|
|
347
|
+
this.swarmData.agents = [];
|
|
348
|
+
this.swarmData.tasks = [];
|
|
349
|
+
for (const runDir of runs){
|
|
350
|
+
const configPath = path.join(swarmRunsDir, runDir, 'config.json');
|
|
351
|
+
try {
|
|
352
|
+
const configData = await fs.readFile(configPath, 'utf-8');
|
|
353
|
+
const config = JSON.parse(configData);
|
|
354
|
+
this.swarmData.objectives.push({
|
|
355
|
+
id: config.swarmId,
|
|
356
|
+
description: config.objective,
|
|
357
|
+
status: 'running',
|
|
358
|
+
startTime: config.startTime
|
|
359
|
+
});
|
|
360
|
+
// Load agents
|
|
361
|
+
const agentsDir = path.join(swarmRunsDir, runDir, 'agents');
|
|
362
|
+
try {
|
|
363
|
+
const agents = await fs.readdir(agentsDir);
|
|
364
|
+
for (const agentDir of agents){
|
|
365
|
+
const taskPath = path.join(agentsDir, agentDir, 'task.json');
|
|
366
|
+
try {
|
|
367
|
+
const taskData = await fs.readFile(taskPath, 'utf-8');
|
|
368
|
+
const task = JSON.parse(taskData);
|
|
369
|
+
this.swarmData.agents.push({
|
|
370
|
+
id: task.agentId,
|
|
371
|
+
swarmId: config.swarmId,
|
|
372
|
+
status: task.status || 'active',
|
|
373
|
+
task: task.task
|
|
374
|
+
});
|
|
375
|
+
this.swarmData.tasks.push(task);
|
|
376
|
+
} catch (e) {
|
|
377
|
+
// Skip invalid task files
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
} catch (e) {
|
|
381
|
+
// No agents directory
|
|
382
|
+
}
|
|
383
|
+
} catch (e) {
|
|
384
|
+
// Skip invalid config files
|
|
385
|
+
}
|
|
418
386
|
}
|
|
419
|
-
|
|
387
|
+
this.updateDisplay();
|
|
420
388
|
} catch (e) {
|
|
421
|
-
|
|
389
|
+
// No swarm runs directory
|
|
390
|
+
this.swarmData.status = 'idle';
|
|
422
391
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
392
|
+
} catch (error) {
|
|
393
|
+
this.log(`Error updating swarm data: ${error.message}`, 'error');
|
|
426
394
|
}
|
|
427
|
-
|
|
428
|
-
this.updateDisplay();
|
|
429
|
-
} catch (e) {
|
|
430
|
-
// No swarm runs directory
|
|
431
|
-
this.swarmData.status = 'idle';
|
|
432
|
-
}
|
|
433
|
-
} catch (error) {
|
|
434
|
-
this.log(`Error updating swarm data: ${error.message}`, 'error');
|
|
435
395
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
// Update agents list
|
|
457
|
-
const agentItems = this.swarmData.agents.map(
|
|
458
|
-
(agent) => `${agent.status === 'active' ? '🤖' : '💤'} ${agent.id.substring(0, 15)}...`,
|
|
459
|
-
);
|
|
460
|
-
this.agentsList.setItems(agentItems.length > 0 ? agentItems : ['No agents']);
|
|
461
|
-
|
|
462
|
-
// Update tasks list if objective is selected
|
|
463
|
-
if (this.selectedObjective) {
|
|
464
|
-
this.updateTasksList();
|
|
396
|
+
updateDisplay() {
|
|
397
|
+
// Update status
|
|
398
|
+
const activeObjectives = this.swarmData.objectives.filter((o)=>o.status === 'running').length;
|
|
399
|
+
const activeAgents = this.swarmData.agents.filter((a)=>a.status === 'active').length;
|
|
400
|
+
this.statusBox.setContent(`Status: ${this.swarmData.status} | ` + `Objectives: ${activeObjectives} | ` + `Agents: ${activeAgents} | ` + `Tasks: ${this.swarmData.tasks.length}`);
|
|
401
|
+
// Update objectives list
|
|
402
|
+
const objectiveItems = this.swarmData.objectives.map((obj)=>`${obj.status === 'running' ? '🟢' : '🔴'} ${obj.description.substring(0, 25)}...`);
|
|
403
|
+
this.objectivesList.setItems(objectiveItems.length > 0 ? objectiveItems : [
|
|
404
|
+
'No objectives'
|
|
405
|
+
]);
|
|
406
|
+
// Update agents list
|
|
407
|
+
const agentItems = this.swarmData.agents.map((agent)=>`${agent.status === 'active' ? '🤖' : '💤'} ${agent.id.substring(0, 15)}...`);
|
|
408
|
+
this.agentsList.setItems(agentItems.length > 0 ? agentItems : [
|
|
409
|
+
'No agents'
|
|
410
|
+
]);
|
|
411
|
+
// Update tasks list if objective is selected
|
|
412
|
+
if (this.selectedObjective) {
|
|
413
|
+
this.updateTasksList();
|
|
414
|
+
}
|
|
415
|
+
this.screen.render();
|
|
465
416
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
failed: '❌',
|
|
483
|
-
pending: '⏳',
|
|
484
|
-
}[task.status] || '❓';
|
|
485
|
-
|
|
486
|
-
return `${statusIcon} ${task.task?.type || 'Unknown'}: ${task.task?.description?.substring(0, 20) || 'No description'}...`;
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
this.tasksList.setItems(taskItems.length > 0 ? taskItems : ['No tasks']);
|
|
490
|
-
this.screen.render();
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
updateTaskDetails(task) {
|
|
494
|
-
const details = [
|
|
495
|
-
`Task ID: ${task.agentId}`,
|
|
496
|
-
`Swarm ID: ${task.swarmId}`,
|
|
497
|
-
`Type: ${task.task?.type || 'Unknown'}`,
|
|
498
|
-
`Description: ${task.task?.description || 'No description'}`,
|
|
499
|
-
`Status: ${task.status || 'Unknown'}`,
|
|
500
|
-
`Start Time: ${task.startTime || 'Not started'}`,
|
|
501
|
-
'',
|
|
502
|
-
'Task Data:',
|
|
503
|
-
JSON.stringify(task.task, null, 2),
|
|
504
|
-
].join('\n');
|
|
505
|
-
|
|
506
|
-
this.taskDetails.setContent(details);
|
|
507
|
-
this.screen.render();
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
promptCreateObjective() {
|
|
511
|
-
// Create a prompt box
|
|
512
|
-
const promptBox = blessed.prompt({
|
|
513
|
-
parent: this.screen,
|
|
514
|
-
top: 'center',
|
|
515
|
-
left: 'center',
|
|
516
|
-
width: 60,
|
|
517
|
-
height: 10,
|
|
518
|
-
label: ' Create New Objective ',
|
|
519
|
-
content: 'Enter objective description:',
|
|
520
|
-
border: {
|
|
521
|
-
type: 'line',
|
|
522
|
-
},
|
|
523
|
-
style: {
|
|
524
|
-
border: {
|
|
525
|
-
fg: 'cyan',
|
|
526
|
-
},
|
|
527
|
-
},
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
promptBox.input('Enter objective:', '', (err, value) => {
|
|
531
|
-
if (!err && value) {
|
|
532
|
-
this.createObjective(value);
|
|
533
|
-
}
|
|
534
|
-
promptBox.destroy();
|
|
535
|
-
this.screen.render();
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
this.screen.render();
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
async createObjective(description) {
|
|
542
|
-
try {
|
|
543
|
-
this.log(`Creating objective: ${description}`);
|
|
544
|
-
|
|
545
|
-
// Execute swarm command
|
|
546
|
-
const args = ['swarm', description, '--ui', '--monitor'];
|
|
547
|
-
const process = spawn('claude-flow', args, {
|
|
548
|
-
detached: true,
|
|
549
|
-
stdio: 'ignore',
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
process.unref();
|
|
553
|
-
|
|
554
|
-
// Track the process for later termination
|
|
555
|
-
const processId = `swarm-${Date.now()}`;
|
|
556
|
-
this.activeProcesses.set(processId, process);
|
|
557
|
-
|
|
558
|
-
this.log(`Launched swarm with PID: ${process.pid} (ID: ${processId})`);
|
|
559
|
-
|
|
560
|
-
// Update data after a delay
|
|
561
|
-
setTimeout(() => {
|
|
562
|
-
this.updateSwarmData();
|
|
563
|
-
}, 2000);
|
|
564
|
-
} catch (error) {
|
|
565
|
-
this.log(`Error creating objective: ${error.message}`, 'error');
|
|
417
|
+
updateTasksList() {
|
|
418
|
+
if (!this.selectedObjective) return;
|
|
419
|
+
const objectiveTasks = this.swarmData.tasks.filter((task)=>task.swarmId === this.selectedObjective.id);
|
|
420
|
+
const taskItems = objectiveTasks.map((task)=>{
|
|
421
|
+
const statusIcon = {
|
|
422
|
+
active: '🔄',
|
|
423
|
+
completed: '✅',
|
|
424
|
+
failed: '❌',
|
|
425
|
+
pending: '⏳'
|
|
426
|
+
}[task.status] || '❓';
|
|
427
|
+
return `${statusIcon} ${task.task?.type || 'Unknown'}: ${task.task?.description?.substring(0, 20) || 'No description'}...`;
|
|
428
|
+
});
|
|
429
|
+
this.tasksList.setItems(taskItems.length > 0 ? taskItems : [
|
|
430
|
+
'No tasks'
|
|
431
|
+
]);
|
|
432
|
+
this.screen.render();
|
|
566
433
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
434
|
+
updateTaskDetails(task) {
|
|
435
|
+
const details = [
|
|
436
|
+
`Task ID: ${task.agentId}`,
|
|
437
|
+
`Swarm ID: ${task.swarmId}`,
|
|
438
|
+
`Type: ${task.task?.type || 'Unknown'}`,
|
|
439
|
+
`Description: ${task.task?.description || 'No description'}`,
|
|
440
|
+
`Status: ${task.status || 'Unknown'}`,
|
|
441
|
+
`Start Time: ${task.startTime || 'Not started'}`,
|
|
442
|
+
'',
|
|
443
|
+
'Task Data:',
|
|
444
|
+
JSON.stringify(task.task, null, 2)
|
|
445
|
+
].join('\n');
|
|
446
|
+
this.taskDetails.setContent(details);
|
|
447
|
+
this.screen.render();
|
|
448
|
+
}
|
|
449
|
+
promptCreateObjective() {
|
|
450
|
+
// Create a prompt box
|
|
451
|
+
const promptBox = blessed.prompt({
|
|
452
|
+
parent: this.screen,
|
|
453
|
+
top: 'center',
|
|
454
|
+
left: 'center',
|
|
455
|
+
width: 60,
|
|
456
|
+
height: 10,
|
|
457
|
+
label: ' Create New Objective ',
|
|
458
|
+
content: 'Enter objective description:',
|
|
459
|
+
border: {
|
|
460
|
+
type: 'line'
|
|
461
|
+
},
|
|
462
|
+
style: {
|
|
463
|
+
border: {
|
|
464
|
+
fg: 'cyan'
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
promptBox.input('Enter objective:', '', (err, value)=>{
|
|
469
|
+
if (!err && value) {
|
|
470
|
+
this.createObjective(value);
|
|
471
|
+
}
|
|
472
|
+
promptBox.destroy();
|
|
473
|
+
this.screen.render();
|
|
474
|
+
});
|
|
475
|
+
this.screen.render();
|
|
476
|
+
}
|
|
477
|
+
async createObjective(description) {
|
|
578
478
|
try {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
479
|
+
this.log(`Creating objective: ${description}`);
|
|
480
|
+
// Execute swarm command
|
|
481
|
+
const args = [
|
|
482
|
+
'swarm',
|
|
483
|
+
description,
|
|
484
|
+
'--ui',
|
|
485
|
+
'--monitor'
|
|
486
|
+
];
|
|
487
|
+
const process1 = spawn('claude-flow', args, {
|
|
488
|
+
detached: true,
|
|
489
|
+
stdio: 'ignore'
|
|
490
|
+
});
|
|
491
|
+
process1.unref();
|
|
492
|
+
// Track the process for later termination
|
|
493
|
+
const processId = `swarm-${Date.now()}`;
|
|
494
|
+
this.activeProcesses.set(processId, process1);
|
|
495
|
+
this.log(`Launched swarm with PID: ${process1.pid} (ID: ${processId})`);
|
|
496
|
+
// Update data after a delay
|
|
497
|
+
setTimeout(()=>{
|
|
498
|
+
this.updateSwarmData();
|
|
499
|
+
}, 2000);
|
|
500
|
+
} catch (error) {
|
|
501
|
+
this.log(`Error creating objective: ${error.message}`, 'error');
|
|
588
502
|
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
// Clear the tracked processes
|
|
592
|
-
this.activeProcesses.clear();
|
|
593
|
-
|
|
594
|
-
// Also find and stop any orphaned processes
|
|
595
|
-
await this.stopOrphanedProcesses();
|
|
596
|
-
|
|
597
|
-
this.log(`Swarm operations stopped (${stoppedCount} processes terminated)`);
|
|
598
|
-
|
|
599
|
-
// Update display
|
|
600
|
-
this.swarmData.status = 'stopped';
|
|
601
|
-
this.updateDisplay();
|
|
602
|
-
} catch (error) {
|
|
603
|
-
this.log(`Error stopping swarm: ${error.message}`, 'error');
|
|
604
503
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
pids.forEach((pid) => {
|
|
624
|
-
exec(`taskkill /F /PID ${pid}`, (killError) => {
|
|
625
|
-
if (!killError) {
|
|
626
|
-
this.log(`Stopped orphaned process PID: ${pid}`);
|
|
504
|
+
async stopSwarm() {
|
|
505
|
+
this.log('Stopping all swarm operations...');
|
|
506
|
+
try {
|
|
507
|
+
// Cross-platform process termination
|
|
508
|
+
let stoppedCount = 0;
|
|
509
|
+
// First, try to stop tracked processes
|
|
510
|
+
for (const [processId, process1] of this.activeProcesses){
|
|
511
|
+
try {
|
|
512
|
+
// Use process.kill() for cross-platform compatibility
|
|
513
|
+
if (process1.pid && !process1.killed) {
|
|
514
|
+
process1.kill('SIGTERM');
|
|
515
|
+
stoppedCount++;
|
|
516
|
+
this.log(`Stopped process ${processId} (PID: ${process1.pid})`);
|
|
517
|
+
}
|
|
518
|
+
} catch (err) {
|
|
519
|
+
// Process might already be dead
|
|
520
|
+
this.log(`Process ${processId} already terminated`, 'warn');
|
|
627
521
|
}
|
|
628
|
-
});
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
},
|
|
632
|
-
);
|
|
633
|
-
} else {
|
|
634
|
-
// Unix-like systems: Use ps and grep
|
|
635
|
-
exec('ps aux | grep "claude-flow-novice swarm" | grep -v grep', (error, stdout) => {
|
|
636
|
-
if (!error && stdout) {
|
|
637
|
-
const lines = stdout.split('\n').filter((line) => line.trim());
|
|
638
|
-
lines.forEach((line) => {
|
|
639
|
-
const parts = line.split(/\s+/);
|
|
640
|
-
const pid = parts[1];
|
|
641
|
-
if (pid && /^\d+$/.test(pid)) {
|
|
642
|
-
try {
|
|
643
|
-
process.kill(parseInt(pid), 'SIGTERM');
|
|
644
|
-
this.log(`Stopped orphaned process PID: ${pid}`);
|
|
645
|
-
} catch (killError) {
|
|
646
|
-
// Process might not exist or no permission
|
|
647
|
-
}
|
|
648
522
|
}
|
|
649
|
-
|
|
523
|
+
// Clear the tracked processes
|
|
524
|
+
this.activeProcesses.clear();
|
|
525
|
+
// Also find and stop any orphaned processes
|
|
526
|
+
await this.stopOrphanedProcesses();
|
|
527
|
+
this.log(`Swarm operations stopped (${stoppedCount} processes terminated)`);
|
|
528
|
+
// Update display
|
|
529
|
+
this.swarmData.status = 'stopped';
|
|
530
|
+
this.updateDisplay();
|
|
531
|
+
} catch (error) {
|
|
532
|
+
this.log(`Error stopping swarm: ${error.message}`, 'error');
|
|
650
533
|
}
|
|
651
|
-
});
|
|
652
534
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
535
|
+
async stopOrphanedProcesses() {
|
|
536
|
+
// Cross-platform approach to find and stop orphaned processes
|
|
537
|
+
const { exec } = require('child_process');
|
|
538
|
+
const os = require('os');
|
|
539
|
+
if (os.platform() === 'win32') {
|
|
540
|
+
// Windows: Use wmic to find and kill processes
|
|
541
|
+
exec('wmic process where "commandline like \'%claude-flow-novice swarm%\'" get processid', (error, stdout)=>{
|
|
542
|
+
if (!error && stdout) {
|
|
543
|
+
const pids = stdout.split('\n').map((line)=>line.trim()).filter((line)=>/^\d+$/.test(line));
|
|
544
|
+
pids.forEach((pid)=>{
|
|
545
|
+
exec(`taskkill /F /PID ${pid}`, (killError)=>{
|
|
546
|
+
if (!killError) {
|
|
547
|
+
this.log(`Stopped orphaned process PID: ${pid}`);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
});
|
|
663
553
|
} else {
|
|
664
|
-
|
|
665
|
-
|
|
554
|
+
// Unix-like systems: Use ps and grep
|
|
555
|
+
exec('ps aux | grep "claude-flow-novice swarm" | grep -v grep', (error, stdout)=>{
|
|
556
|
+
if (!error && stdout) {
|
|
557
|
+
const lines = stdout.split('\n').filter((line)=>line.trim());
|
|
558
|
+
lines.forEach((line)=>{
|
|
559
|
+
const parts = line.split(/\s+/);
|
|
560
|
+
const pid = parts[1];
|
|
561
|
+
if (pid && /^\d+$/.test(pid)) {
|
|
562
|
+
try {
|
|
563
|
+
process.kill(parseInt(pid), 'SIGTERM');
|
|
564
|
+
this.log(`Stopped orphaned process PID: ${pid}`);
|
|
565
|
+
} catch (killError) {
|
|
566
|
+
// Process might not exist or no permission
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
});
|
|
666
572
|
}
|
|
667
|
-
});
|
|
668
|
-
} catch (error) {
|
|
669
|
-
this.log(`Failed to execute command: ${error.message}`, 'error');
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
log(message, level = 'info') {
|
|
674
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
675
|
-
const levelColors = {
|
|
676
|
-
info: 'white',
|
|
677
|
-
warn: 'yellow',
|
|
678
|
-
error: 'red',
|
|
679
|
-
success: 'green',
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
const coloredMessage = `{${levelColors[level] || 'white'}-fg}[${timestamp}] ${message}{/}`;
|
|
683
|
-
|
|
684
|
-
this.logBuffer.push(coloredMessage);
|
|
685
|
-
if (this.logBuffer.length > this.maxLogLines) {
|
|
686
|
-
this.logBuffer.shift();
|
|
687
573
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
574
|
+
async executeCommand(command) {
|
|
575
|
+
this.log(`Executing command: ${command}`);
|
|
576
|
+
try {
|
|
577
|
+
const { exec } = require('child_process');
|
|
578
|
+
exec(command, (error, stdout, stderr)=>{
|
|
579
|
+
if (error) {
|
|
580
|
+
this.log(`Command error: ${error.message}`, 'error');
|
|
581
|
+
} else {
|
|
582
|
+
if (stdout) this.log(`Output: ${stdout.trim()}`);
|
|
583
|
+
if (stderr) this.log(`Error: ${stderr.trim()}`, 'warn');
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
} catch (error) {
|
|
587
|
+
this.log(`Failed to execute command: ${error.message}`, 'error');
|
|
588
|
+
}
|
|
692
589
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
590
|
+
log(message, level = 'info') {
|
|
591
|
+
const timestamp = new Date().toLocaleTimeString();
|
|
592
|
+
const levelColors = {
|
|
593
|
+
info: 'white',
|
|
594
|
+
warn: 'yellow',
|
|
595
|
+
error: 'red',
|
|
596
|
+
success: 'green'
|
|
597
|
+
};
|
|
598
|
+
const coloredMessage = `{${levelColors[level] || 'white'}-fg}[${timestamp}] ${message}{/}`;
|
|
599
|
+
this.logBuffer.push(coloredMessage);
|
|
600
|
+
if (this.logBuffer.length > this.maxLogLines) {
|
|
601
|
+
this.logBuffer.shift();
|
|
602
|
+
}
|
|
603
|
+
if (this.logBox) {
|
|
604
|
+
this.logBox.log(coloredMessage);
|
|
605
|
+
this.screen.render();
|
|
606
|
+
}
|
|
698
607
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
608
|
+
cleanup() {
|
|
609
|
+
if (this.updateInterval) {
|
|
610
|
+
clearInterval(this.updateInterval);
|
|
611
|
+
}
|
|
612
|
+
// Clean up any remaining processes
|
|
613
|
+
for (const [processId, process1] of this.activeProcesses){
|
|
614
|
+
try {
|
|
615
|
+
if (process1.pid && !process1.killed) {
|
|
616
|
+
process1.kill('SIGTERM');
|
|
617
|
+
}
|
|
618
|
+
} catch (err) {
|
|
619
|
+
// Ignore errors during cleanup
|
|
620
|
+
}
|
|
705
621
|
}
|
|
706
|
-
|
|
707
|
-
// Ignore errors during cleanup
|
|
708
|
-
}
|
|
622
|
+
this.activeProcesses.clear();
|
|
709
623
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
624
|
+
constructor(){
|
|
625
|
+
this.screen = null;
|
|
626
|
+
this.swarmData = {
|
|
627
|
+
objectives: [],
|
|
628
|
+
agents: [],
|
|
629
|
+
tasks: [],
|
|
630
|
+
status: 'idle'
|
|
631
|
+
};
|
|
632
|
+
this.selectedObjective = null;
|
|
633
|
+
this.updateInterval = null;
|
|
634
|
+
this.logBuffer = [];
|
|
635
|
+
this.maxLogLines = 100;
|
|
636
|
+
this.activeProcesses = new Map(); // Track active processes for cross-platform termination
|
|
637
|
+
}
|
|
638
|
+
};
|
|
714
639
|
// Main execution
|
|
715
640
|
async function main() {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
}
|
|
641
|
+
const ui = new SwarmUI();
|
|
642
|
+
try {
|
|
643
|
+
await ui.init();
|
|
644
|
+
} catch (error) {
|
|
645
|
+
console.error('Failed to initialize Swarm UI:', error);
|
|
646
|
+
process.exit(1);
|
|
647
|
+
}
|
|
724
648
|
}
|
|
725
|
-
|
|
726
649
|
// Handle uncaught exceptions
|
|
727
|
-
process.on('uncaughtException', (error)
|
|
728
|
-
|
|
729
|
-
|
|
650
|
+
process.on('uncaughtException', (error)=>{
|
|
651
|
+
console.error('Uncaught exception:', error);
|
|
652
|
+
process.exit(1);
|
|
730
653
|
});
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
process.exit(1);
|
|
654
|
+
process.on('unhandledRejection', (error)=>{
|
|
655
|
+
console.error('Unhandled rejection:', error);
|
|
656
|
+
process.exit(1);
|
|
735
657
|
});
|
|
736
|
-
|
|
737
658
|
if (require.main === module) {
|
|
738
|
-
|
|
659
|
+
main();
|
|
739
660
|
}
|
|
740
|
-
|
|
741
661
|
module.exports = SwarmUI;
|