claude-flow-novice 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/dist/src/cli/commands/guidance.js +487 -668
  2. package/dist/src/cli/commands/index-validate.js +18 -29
  3. package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
  4. package/dist/src/cli/commands/neural-goal-init.js +92 -125
  5. package/dist/src/cli/commands/swarm-exec.js +317 -393
  6. package/dist/src/cli/commands/swarm.js +1 -1
  7. package/dist/src/cli/commands/validate-framework.js +983 -1100
  8. package/dist/src/cli/commands/validate.js +144 -223
  9. package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
  10. package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
  11. package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
  12. package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
  13. package/dist/src/cli/simple-commands/agent.js +157 -193
  14. package/dist/src/cli/simple-commands/analysis.js +336 -446
  15. package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
  16. package/dist/src/cli/simple-commands/automation.js +481 -469
  17. package/dist/src/cli/simple-commands/batch-manager.js +261 -313
  18. package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
  19. package/dist/src/cli/simple-commands/claude-track.js +68 -90
  20. package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
  21. package/dist/src/cli/simple-commands/config.js +245 -290
  22. package/dist/src/cli/simple-commands/coordination.js +182 -234
  23. package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
  24. package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
  25. package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
  26. package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
  27. package/dist/src/cli/simple-commands/github/github-api.js +535 -574
  28. package/dist/src/cli/simple-commands/github/init.js +276 -303
  29. package/dist/src/cli/simple-commands/github.js +222 -247
  30. package/dist/src/cli/simple-commands/goal.js +51 -63
  31. package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
  32. package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
  33. package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
  34. package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
  35. package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
  36. package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
  37. package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
  38. package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
  39. package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
  40. package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
  41. package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
  42. package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
  43. package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
  44. package/dist/src/cli/simple-commands/hive.js +90 -79
  45. package/dist/src/cli/simple-commands/hook-safety.js +431 -521
  46. package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
  47. package/dist/src/cli/simple-commands/hooks.js +1064 -1204
  48. package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
  49. package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
  50. package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
  51. package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
  52. package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
  53. package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
  54. package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
  55. package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
  56. package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
  57. package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
  58. package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
  59. package/dist/src/cli/simple-commands/init/help.js +104 -107
  60. package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
  61. package/dist/src/cli/simple-commands/init/index.js +1510 -1759
  62. package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
  63. package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
  64. package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
  65. package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
  66. package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
  67. package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
  68. package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
  69. package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
  70. package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
  71. package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
  72. package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
  73. package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
  74. package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
  75. package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
  76. package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
  77. package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
  78. package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
  79. package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
  80. package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
  81. package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
  82. package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
  83. package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
  84. package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
  85. package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
  86. package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
  87. package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
  88. package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
  89. package/dist/src/cli/simple-commands/init.js +1 -2
  90. package/dist/src/cli/simple-commands/mcp-health.js +131 -158
  91. package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
  92. package/dist/src/cli/simple-commands/mcp.js +345 -400
  93. package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
  94. package/dist/src/cli/simple-commands/memory.js +247 -311
  95. package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
  96. package/dist/src/cli/simple-commands/monitor.js +294 -363
  97. package/dist/src/cli/simple-commands/neural.js +51 -65
  98. package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
  99. package/dist/src/cli/simple-commands/pair-basic.js +528 -656
  100. package/dist/src/cli/simple-commands/pair-old.js +430 -543
  101. package/dist/src/cli/simple-commands/pair-working.js +615 -751
  102. package/dist/src/cli/simple-commands/pair.js +615 -751
  103. package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
  104. package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
  105. package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
  106. package/dist/src/cli/simple-commands/process-ui.js +230 -254
  107. package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
  108. package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
  109. package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
  110. package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
  111. package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
  112. package/dist/src/cli/simple-commands/sparc/index.js +241 -298
  113. package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
  114. package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
  115. package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
  116. package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
  117. package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
  118. package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
  119. package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
  120. package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
  121. package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
  122. package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
  123. package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
  124. package/dist/src/cli/simple-commands/sparc-modes/index.js +47 -55
  125. package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
  126. package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
  127. package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
  128. package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
  129. package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
  130. package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
  131. package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
  132. package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
  133. package/dist/src/cli/simple-commands/sparc-modes/swarm.js +101 -87
  134. package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
  135. package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
  136. package/dist/src/cli/simple-commands/sparc.js +465 -493
  137. package/dist/src/cli/simple-commands/start-ui.js +108 -132
  138. package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
  139. package/dist/src/cli/simple-commands/start.js +1 -1
  140. package/dist/src/cli/simple-commands/status.js +254 -275
  141. package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
  142. package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
  143. package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
  144. package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
  145. package/dist/src/cli/simple-commands/stream-chain.js +260 -318
  146. package/dist/src/cli/simple-commands/stream-processor.js +290 -315
  147. package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
  148. package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
  149. package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
  150. package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
  151. package/dist/src/cli/simple-commands/swarm.js +887 -1082
  152. package/dist/src/cli/simple-commands/task.js +161 -206
  153. package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
  154. package/dist/src/cli/simple-commands/token-tracker.js +258 -316
  155. package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
  156. package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
  157. package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
  158. package/dist/src/cli/simple-commands/training.js +170 -227
  159. package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
  160. package/dist/src/cli/simple-commands/verification-integration.js +389 -417
  161. package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
  162. package/dist/src/cli/simple-commands/verification.js +493 -513
  163. package/dist/src/cli/simple-commands/web-server.js +766 -836
  164. package/dist/src/cli/simple-commands/webui-validator.js +106 -124
  165. package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
  166. package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
  167. package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
  168. package/dist/src/coordination/iteration-tracker.js +363 -454
  169. package/dist/src/enterprise/analytics-manager.js +1135 -0
  170. package/dist/src/enterprise/audit-manager.js +1115 -0
  171. package/dist/src/enterprise/cloud-manager.js +891 -0
  172. package/dist/src/enterprise/deployment-manager.js +966 -0
  173. package/dist/src/enterprise/index.js +6 -0
  174. package/dist/src/enterprise/project-manager.js +584 -0
  175. package/dist/src/enterprise/security-manager.js +991 -0
  176. package/dist/src/index.js +1 -1
  177. package/dist/src/mcp/DEPRECATED.js +46 -60
  178. package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
  179. package/dist/src/mcp/implementations/agent-tracker.js +114 -128
  180. package/dist/src/mcp/implementations/daa-tools.js +292 -350
  181. package/dist/src/mcp/implementations/workflow-tools.js +329 -361
  182. package/dist/src/mcp/mcp-config-manager.js +1183 -1331
  183. package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
  184. package/dist/src/mcp/mcp-server-novice.js +11 -17
  185. package/dist/src/mcp/mcp-server-sdk.js +11 -17
  186. package/dist/src/mcp/mcp-server.js +1620 -1484
  187. package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
  188. package/dist/src/memory/advanced-serializer.js +609 -589
  189. package/dist/src/memory/enhanced-examples.js +220 -305
  190. package/dist/src/memory/enhanced-memory.js +295 -336
  191. package/dist/src/memory/enhanced-session-serializer.js +408 -492
  192. package/dist/src/memory/fallback-memory-system.js +900 -1021
  193. package/dist/src/memory/fallback-store.js +93 -131
  194. package/dist/src/memory/high-performance-serialization.js +592 -730
  195. package/dist/src/memory/in-memory-store.js +161 -213
  196. package/dist/src/memory/index.js +123 -157
  197. package/dist/src/memory/lock-free-structures.js +578 -764
  198. package/dist/src/memory/memory-mapped-persistence.js +585 -766
  199. package/dist/src/memory/memory-pressure-manager.js +569 -707
  200. package/dist/src/memory/migration.js +358 -445
  201. package/dist/src/memory/shared-memory.js +641 -768
  202. package/dist/src/memory/sqlite-store.js +245 -325
  203. package/dist/src/memory/sqlite-wrapper.js +122 -151
  204. package/dist/src/memory/swarm-memory.js +470 -603
  205. package/dist/src/memory/test-example.js +126 -134
  206. package/dist/src/memory/ultra-fast-memory-store.js +622 -821
  207. package/dist/src/memory/unified-memory-manager.js +356 -437
  208. package/dist/src/migration/index.js +92 -0
  209. package/dist/src/migration/logger.js +121 -0
  210. package/dist/src/migration/migration-analyzer.js +268 -0
  211. package/dist/src/migration/migration-runner.js +522 -0
  212. package/dist/src/migration/migration-validator.js +285 -0
  213. package/dist/src/migration/progress-reporter.js +150 -0
  214. package/dist/src/migration/rollback-manager.js +321 -0
  215. package/dist/src/migration/tests/migration-system.test.js +7 -0
  216. package/dist/src/migration/types.js +3 -0
  217. package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
  218. package/dist/src/swarm/__tests__/integration.test.js +227 -0
  219. package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
  220. package/dist/src/swarm/advanced-orchestrator.js +1095 -0
  221. package/dist/src/swarm/claude-code-interface.js +961 -0
  222. package/dist/src/swarm/claude-flow-executor.js +229 -0
  223. package/dist/src/swarm/consensus-coordinator.js +475 -0
  224. package/dist/src/swarm/coordinator.js +2993 -0
  225. package/dist/src/swarm/direct-executor.js +1180 -0
  226. package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
  227. package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
  228. package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
  229. package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
  230. package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
  231. package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
  232. package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
  233. package/dist/src/swarm/executor-v2.js +322 -0
  234. package/dist/src/swarm/executor.js +815 -0
  235. package/dist/src/swarm/hive-mind-integration.js +703 -0
  236. package/dist/src/swarm/index.js +41 -0
  237. package/dist/src/swarm/json-output-aggregator.js +267 -0
  238. package/dist/src/swarm/large-scale-coordinator.js +542 -0
  239. package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
  240. package/dist/src/swarm/memory.js +1117 -0
  241. package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
  242. package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
  243. package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
  244. package/dist/src/swarm/optimizations/connection-pool.js +244 -0
  245. package/dist/src/swarm/optimizations/index.js +28 -0
  246. package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
  247. package/dist/src/swarm/optimizations/ttl-map.js +234 -0
  248. package/dist/src/swarm/prompt-cli.js +200 -0
  249. package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
  250. package/dist/src/swarm/prompt-copier.js +381 -0
  251. package/dist/src/swarm/prompt-manager.js +295 -0
  252. package/dist/src/swarm/prompt-utils.js +310 -0
  253. package/dist/src/swarm/result-aggregator.js +718 -0
  254. package/dist/src/swarm/sparc-executor.js +1568 -0
  255. package/dist/src/swarm/strategies/auto.js +758 -0
  256. package/dist/src/swarm/strategies/base.js +128 -0
  257. package/dist/src/swarm/strategies/research.js +914 -0
  258. package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
  259. package/dist/src/swarm/types.js +52 -0
  260. package/dist/src/swarm/workers/copy-worker.js +56 -0
  261. package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
  262. package/dist/src/utils/github-cli-safe.js +56 -64
  263. package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
  264. package/dist/src/utils/npx-isolated-cache.js +104 -119
  265. package/dist/src/utils/preference-manager.js +622 -652
  266. package/dist/src/utils/timezone-utils.js +86 -105
  267. package/dist/src/validators/epic-config-schema.js +214 -0
  268. package/dist/src/validators/index.js +10 -0
  269. package/dist/src/validators/swarm-init-validator.js +259 -0
  270. package/dist/src/validators/todowrite-batching-validator.js +215 -0
  271. package/dist/src/validators/todowrite-integration.js +187 -0
  272. package/package.json +2 -2
@@ -1,821 +1,742 @@
1
1
  // process-ui-enhanced.js - Enhanced process management UI with multiple views - v2.0.0-alpha.83
2
- import { printSuccess, printError, printWarning, printInfo } from '../utils.js';
3
- import { compat } from '../runtime-detector.js';
4
- import SwarmWebUIIntegration from './swarm-webui-integration.js';
5
-
2
+ import { printSuccess } from "../utils.js";
3
+ import { compat } from "../runtime-detector.js";
4
+ import SwarmWebUIIntegration from "./swarm-webui-integration.js";
6
5
  // Simple color utilities
7
6
  const colors = {
8
- cyan: (text) => `\x1b[36m${text}\x1b[0m`,
9
- gray: (text) => `\x1b[90m${text}\x1b[0m`,
10
- white: (text) => `\x1b[37m${text}\x1b[0m`,
11
- yellow: (text) => `\x1b[33m${text}\x1b[0m`,
12
- green: (text) => `\x1b[32m${text}\x1b[0m`,
13
- red: (text) => `\x1b[31m${text}\x1b[0m`,
14
- blue: (text) => `\x1b[34m${text}\x1b[0m`,
15
- magenta: (text) => `\x1b[35m${text}\x1b[0m`,
16
- bold: (text) => `\x1b[1m${text}\x1b[0m`,
17
- dim: (text) => `\x1b[2m${text}\x1b[0m`,
7
+ cyan: (text)=>`\x1b[36m${text}\x1b[0m`,
8
+ gray: (text)=>`\x1b[90m${text}\x1b[0m`,
9
+ white: (text)=>`\x1b[37m${text}\x1b[0m`,
10
+ yellow: (text)=>`\x1b[33m${text}\x1b[0m`,
11
+ green: (text)=>`\x1b[32m${text}\x1b[0m`,
12
+ red: (text)=>`\x1b[31m${text}\x1b[0m`,
13
+ blue: (text)=>`\x1b[34m${text}\x1b[0m`,
14
+ magenta: (text)=>`\x1b[35m${text}\x1b[0m`,
15
+ bold: (text)=>`\x1b[1m${text}\x1b[0m`,
16
+ dim: (text)=>`\x1b[2m${text}\x1b[0m`
18
17
  };
19
-
20
18
  const PROCESSES = [
21
- { id: 'event-bus', name: 'Event Bus', description: 'Central event distribution system' },
22
- { id: 'orchestrator', name: 'Orchestrator', description: 'Main coordination engine' },
23
- { id: 'memory-manager', name: 'Memory Manager', description: 'Persistent memory system' },
24
- { id: 'terminal-pool', name: 'Terminal Pool', description: 'Terminal session management' },
25
- { id: 'mcp-server', name: 'MCP Server', description: 'Model Context Protocol server' },
26
- { id: 'coordinator', name: 'Coordinator', description: 'Task coordination service' },
19
+ {
20
+ id: 'event-bus',
21
+ name: 'Event Bus',
22
+ description: 'Central event distribution system'
23
+ },
24
+ {
25
+ id: 'orchestrator',
26
+ name: 'Orchestrator',
27
+ description: 'Main coordination engine'
28
+ },
29
+ {
30
+ id: 'memory-manager',
31
+ name: 'Memory Manager',
32
+ description: 'Persistent memory system'
33
+ },
34
+ {
35
+ id: 'terminal-pool',
36
+ name: 'Terminal Pool',
37
+ description: 'Terminal session management'
38
+ },
39
+ {
40
+ id: 'mcp-server',
41
+ name: 'MCP Server',
42
+ description: 'Model Context Protocol server'
43
+ },
44
+ {
45
+ id: 'coordinator',
46
+ name: 'Coordinator',
47
+ description: 'Task coordination service'
48
+ }
27
49
  ];
28
-
29
50
  // View modes
30
51
  const VIEWS = {
31
- PROCESSES: 'processes',
32
- STATUS: 'status',
33
- ORCHESTRATION: 'orchestration',
34
- MEMORY: 'memory',
35
- LOGS: 'logs',
36
- HELP: 'help',
52
+ PROCESSES: 'processes',
53
+ STATUS: 'status',
54
+ ORCHESTRATION: 'orchestration',
55
+ MEMORY: 'memory',
56
+ LOGS: 'logs',
57
+ HELP: 'help'
37
58
  };
38
-
39
59
  export class EnhancedProcessUI {
40
- constructor() {
41
- this.processes = new Map();
42
- this.running = true;
43
- this.selectedIndex = 0;
44
- this.currentView = VIEWS.PROCESSES;
45
- this.agents = [];
46
- this.tasks = [];
47
- this.memoryStats = {
48
- totalEntries: 0,
49
- totalSize: 0,
50
- namespaces: [],
51
- };
52
- this.logs = [];
53
- this.systemStats = {
54
- uptime: 0,
55
- totalTasks: 0,
56
- completedTasks: 0,
57
- activeAgents: 0,
58
- memoryUsage: 0,
59
- cpuUsage: 0,
60
- };
61
-
62
- // Initialize swarm integration
63
- this.swarmIntegration = new SwarmWebUIIntegration(this);
64
-
65
- // Initialize process states
66
- PROCESSES.forEach((p) => {
67
- this.processes.set(p.id, {
68
- ...p,
69
- status: 'stopped',
70
- pid: null,
71
- uptime: 0,
72
- cpu: Math.random() * 5,
73
- memory: Math.random() * 100,
74
- });
75
- });
76
-
77
- // Start system uptime counter
78
- setInterval(() => {
79
- this.systemStats.uptime++;
80
- }, 1000);
81
-
82
- // Initialize swarm (this will create mock data)
83
- this.initializeSwarm();
84
- }
85
-
86
- async initializeSwarm() {
87
- // Initialize swarm with mock data
88
- await this.swarmIntegration.initializeSwarm('hierarchical', 8);
89
-
90
- // Mock memory namespaces
91
- this.memoryStats = {
92
- totalEntries: 42,
93
- totalSize: '156.3 KB',
94
- namespaces: [
95
- { name: 'sparc', entries: 15, size: '45.2 KB' },
96
- { name: 'agents', entries: 12, size: '38.7 KB' },
97
- { name: 'tasks', entries: 8, size: '24.1 KB' },
98
- { name: 'system', entries: 7, size: '48.3 KB' },
99
- ],
100
- };
101
-
102
- // Initial logs
103
- this.logs = [
104
- { time: new Date(), level: 'info', message: 'System initialized' },
105
- { time: new Date(), level: 'success', message: 'All processes ready' },
106
- { time: new Date(), level: 'success', message: 'Swarm orchestration active' },
107
- ];
108
- }
109
-
110
- async start() {
111
- // Clear screen
112
- console.clear();
113
-
114
- // Show welcome
115
- printSuccess('🧠 Claude-Flow Process Management UI v2.0.0-alpha.80');
116
- console.log('─'.repeat(80));
117
- console.log();
118
-
119
- // Initial render
120
- this.render();
121
-
122
- // Main UI loop
123
- while (this.running) {
124
- await this.handleInput();
125
- if (this.running) {
60
+ async initializeSwarm() {
61
+ // Initialize swarm with mock data
62
+ await this.swarmIntegration.initializeSwarm('hierarchical', 8);
63
+ // Mock memory namespaces
64
+ this.memoryStats = {
65
+ totalEntries: 42,
66
+ totalSize: '156.3 KB',
67
+ namespaces: [
68
+ {
69
+ name: 'sparc',
70
+ entries: 15,
71
+ size: '45.2 KB'
72
+ },
73
+ {
74
+ name: 'agents',
75
+ entries: 12,
76
+ size: '38.7 KB'
77
+ },
78
+ {
79
+ name: 'tasks',
80
+ entries: 8,
81
+ size: '24.1 KB'
82
+ },
83
+ {
84
+ name: 'system',
85
+ entries: 7,
86
+ size: '48.3 KB'
87
+ }
88
+ ]
89
+ };
90
+ // Initial logs
91
+ this.logs = [
92
+ {
93
+ time: new Date(),
94
+ level: 'info',
95
+ message: 'System initialized'
96
+ },
97
+ {
98
+ time: new Date(),
99
+ level: 'success',
100
+ message: 'All processes ready'
101
+ },
102
+ {
103
+ time: new Date(),
104
+ level: 'success',
105
+ message: 'Swarm orchestration active'
106
+ }
107
+ ];
108
+ }
109
+ async start() {
110
+ // Clear screen
111
+ console.clear();
112
+ // Show welcome
113
+ printSuccess('🧠 Claude-Flow Process Management UI v2.0.0-alpha.80');
114
+ console.log('─'.repeat(80));
115
+ console.log();
116
+ // Initial render
126
117
  this.render();
127
- }
118
+ // Main UI loop
119
+ while(this.running){
120
+ await this.handleInput();
121
+ if (this.running) {
122
+ this.render();
123
+ }
124
+ }
128
125
  }
129
- }
130
-
131
- render() {
132
- // Clear screen and move cursor to top
133
- console.log('\x1b[2J\x1b[H');
134
-
135
- // Header with navigation
136
- this.renderHeader();
137
-
138
- // Main content based on current view
139
- switch (this.currentView) {
140
- case VIEWS.PROCESSES:
141
- this.renderProcessView();
142
- break;
143
- case VIEWS.STATUS:
144
- this.renderStatusView();
145
- break;
146
- case VIEWS.ORCHESTRATION:
147
- this.renderOrchestrationView();
148
- break;
149
- case VIEWS.MEMORY:
150
- this.renderMemoryView();
151
- break;
152
- case VIEWS.LOGS:
153
- this.renderLogsView();
154
- break;
155
- case VIEWS.HELP:
156
- this.renderHelpView();
157
- break;
126
+ render() {
127
+ // Clear screen and move cursor to top
128
+ console.log('\x1b[2J\x1b[H');
129
+ // Header with navigation
130
+ this.renderHeader();
131
+ // Main content based on current view
132
+ switch(this.currentView){
133
+ case VIEWS.PROCESSES:
134
+ this.renderProcessView();
135
+ break;
136
+ case VIEWS.STATUS:
137
+ this.renderStatusView();
138
+ break;
139
+ case VIEWS.ORCHESTRATION:
140
+ this.renderOrchestrationView();
141
+ break;
142
+ case VIEWS.MEMORY:
143
+ this.renderMemoryView();
144
+ break;
145
+ case VIEWS.LOGS:
146
+ this.renderLogsView();
147
+ break;
148
+ case VIEWS.HELP:
149
+ this.renderHelpView();
150
+ break;
151
+ }
152
+ // Footer with controls
153
+ this.renderFooter();
158
154
  }
159
-
160
- // Footer with controls
161
- this.renderFooter();
162
- }
163
-
164
- renderHeader() {
165
- console.log(colors.cyan(colors.bold('🧠 Claude-Flow Process Manager')));
166
- console.log(colors.gray('─'.repeat(80)));
167
-
168
- // Navigation tabs
169
- const tabs = [
170
- { key: '1', view: VIEWS.PROCESSES, label: 'Processes' },
171
- { key: '2', view: VIEWS.STATUS, label: 'Status' },
172
- { key: '3', view: VIEWS.ORCHESTRATION, label: 'Orchestration' },
173
- { key: '4', view: VIEWS.MEMORY, label: 'Memory' },
174
- { key: '5', view: VIEWS.LOGS, label: 'Logs' },
175
- { key: '6', view: VIEWS.HELP, label: 'Help' },
176
- ];
177
-
178
- let tabLine = '';
179
- tabs.forEach((tab) => {
180
- const isActive = this.currentView === tab.view;
181
- const label = isActive ? colors.yellow(`[${tab.label}]`) : colors.gray(`${tab.label}`);
182
- tabLine += ` ${colors.bold(tab.key)}:${label}`;
183
- });
184
-
185
- console.log(tabLine);
186
- console.log(colors.gray('─'.repeat(80)));
187
- console.log();
188
- }
189
-
190
- renderProcessView() {
191
- console.log(colors.white(colors.bold('Process Management')));
192
- console.log();
193
-
194
- let index = 0;
195
- for (const [id, process] of this.processes) {
196
- const selected = index === this.selectedIndex;
197
- const prefix = selected ? colors.yellow('▶ ') : ' ';
198
- const status = this.getStatusIcon(process.status);
199
- const name = selected ? colors.yellow(process.name) : colors.white(process.name);
200
-
201
- console.log(`${prefix}${status} ${name}`);
202
- console.log(` ${colors.gray(process.description)}`);
203
-
204
- if (process.status === 'running') {
205
- const stats = colors.dim(
206
- `PID: ${process.pid} | Uptime: ${this.formatUptime(process.uptime)} | CPU: ${process.cpu.toFixed(1)}% | Mem: ${process.memory.toFixed(0)}MB`,
207
- );
208
- console.log(` ${stats}`);
209
- }
210
- console.log();
211
-
212
- index++;
155
+ renderHeader() {
156
+ console.log(colors.cyan(colors.bold('🧠 Claude-Flow Process Manager')));
157
+ console.log(colors.gray('─'.repeat(80)));
158
+ // Navigation tabs
159
+ const tabs = [
160
+ {
161
+ key: '1',
162
+ view: VIEWS.PROCESSES,
163
+ label: 'Processes'
164
+ },
165
+ {
166
+ key: '2',
167
+ view: VIEWS.STATUS,
168
+ label: 'Status'
169
+ },
170
+ {
171
+ key: '3',
172
+ view: VIEWS.ORCHESTRATION,
173
+ label: 'Orchestration'
174
+ },
175
+ {
176
+ key: '4',
177
+ view: VIEWS.MEMORY,
178
+ label: 'Memory'
179
+ },
180
+ {
181
+ key: '5',
182
+ view: VIEWS.LOGS,
183
+ label: 'Logs'
184
+ },
185
+ {
186
+ key: '6',
187
+ view: VIEWS.HELP,
188
+ label: 'Help'
189
+ }
190
+ ];
191
+ let tabLine = '';
192
+ tabs.forEach((tab)=>{
193
+ const isActive = this.currentView === tab.view;
194
+ const label = isActive ? colors.yellow(`[${tab.label}]`) : colors.gray(`${tab.label}`);
195
+ tabLine += ` ${colors.bold(tab.key)}:${label}`;
196
+ });
197
+ console.log(tabLine);
198
+ console.log(colors.gray('─'.repeat(80)));
199
+ console.log();
213
200
  }
214
-
215
- // Quick stats
216
- const running = Array.from(this.processes.values()).filter(
217
- (p) => p.status === 'running',
218
- ).length;
219
- console.log(colors.gray('─'.repeat(80)));
220
- console.log(
221
- colors.white(
222
- `Total: ${this.processes.size} | Running: ${colors.green(running)} | Stopped: ${colors.gray(this.processes.size - running)}`,
223
- ),
224
- );
225
- }
226
-
227
- renderStatusView() {
228
- console.log(colors.white(colors.bold('System Status')));
229
- console.log();
230
-
231
- // System overview
232
- console.log(colors.cyan('📊 System Overview'));
233
- console.log(` Uptime: ${colors.green(this.formatUptime(this.systemStats.uptime))}`);
234
- console.log(` Process Health: ${this.getHealthBar()}`);
235
- console.log();
236
-
237
- // Resource usage
238
- console.log(colors.cyan('💻 Resource Usage'));
239
- console.log(
240
- ` CPU Usage: ${this.getUsageBar(this.systemStats.cpuUsage, 100)} ${this.systemStats.cpuUsage}%`,
241
- );
242
- console.log(
243
- ` Memory: ${this.getUsageBar(this.systemStats.memoryUsage, 100)} ${this.systemStats.memoryUsage}%`,
244
- );
245
- console.log();
246
-
247
- // Activity metrics
248
- console.log(colors.cyan('📈 Activity Metrics'));
249
- console.log(
250
- ` Active Agents: ${colors.yellow(this.agents.filter((a) => a.status === 'working').length)}/${this.agents.length}`,
251
- );
252
- console.log(` Total Tasks: ${this.tasks.length}`);
253
- console.log(
254
- ` Completed: ${colors.green(this.tasks.filter((t) => t.status === 'completed').length)}`,
255
- );
256
- console.log(
257
- ` In Progress: ${colors.yellow(this.tasks.filter((t) => t.status === 'in_progress').length)}`,
258
- );
259
- console.log(
260
- ` Pending: ${colors.gray(this.tasks.filter((t) => t.status === 'pending').length)}`,
261
- );
262
- console.log();
263
-
264
- // Recent events
265
- console.log(colors.cyan('🔔 Recent Events'));
266
- this.logs.slice(-3).forEach((log) => {
267
- const time = log.time.toLocaleTimeString();
268
- const icon = log.level === 'success' ? '✓' : log.level === 'warning' ? '⚠' : 'ℹ';
269
- const color =
270
- log.level === 'success'
271
- ? colors.green
272
- : log.level === 'warning'
273
- ? colors.yellow
274
- : colors.blue;
275
- console.log(` ${colors.gray(time)} ${color(icon)} ${log.message}`);
276
- });
277
- }
278
-
279
- renderOrchestrationView() {
280
- console.log(colors.white(colors.bold('Swarm Orchestration Management')));
281
- console.log();
282
-
283
- // Swarm metrics
284
- const metrics = this.swarmIntegration.getSwarmMetrics();
285
- if (metrics) {
286
- console.log(colors.cyan('🐝 Swarm Status'));
287
- console.log(` Swarm ID: ${colors.yellow(metrics.swarmId)}`);
288
- console.log(
289
- ` Agents: ${colors.green(metrics.agents.active)}/${metrics.agents.total} active`,
290
- );
291
- console.log(
292
- ` Tasks: ${colors.yellow(metrics.tasks.inProgress)} in progress, ${colors.green(metrics.tasks.completed)} completed`,
293
- );
294
- console.log(` Efficiency: ${metrics.efficiency}%`);
295
- console.log();
201
+ renderProcessView() {
202
+ console.log(colors.white(colors.bold('Process Management')));
203
+ console.log();
204
+ let index = 0;
205
+ for (const [id, process] of this.processes){
206
+ const selected = index === this.selectedIndex;
207
+ const prefix = selected ? colors.yellow('▶ ') : ' ';
208
+ const status = this.getStatusIcon(process.status);
209
+ const name = selected ? colors.yellow(process.name) : colors.white(process.name);
210
+ console.log(`${prefix}${status} ${name}`);
211
+ console.log(` ${colors.gray(process.description)}`);
212
+ if (process.status === 'running') {
213
+ const stats = colors.dim(`PID: ${process.pid} | Uptime: ${this.formatUptime(process.uptime)} | CPU: ${process.cpu.toFixed(1)}% | Mem: ${process.memory.toFixed(0)}MB`);
214
+ console.log(` ${stats}`);
215
+ }
216
+ console.log();
217
+ index++;
218
+ }
219
+ // Quick stats
220
+ const running = Array.from(this.processes.values()).filter((p)=>p.status === 'running').length;
221
+ console.log(colors.gray('─'.repeat(80)));
222
+ console.log(colors.white(`Total: ${this.processes.size} | Running: ${colors.green(running)} | Stopped: ${colors.gray(this.processes.size - running)}`));
296
223
  }
297
-
298
- // Agents section
299
- console.log(colors.cyan('🤖 Active Agents'));
300
- console.log();
301
- this.agents.forEach((agent, index) => {
302
- const selected = this.currentView === VIEWS.ORCHESTRATION && index === this.selectedIndex;
303
- const prefix = selected ? colors.yellow('▶ ') : ' ';
304
- const statusIcon = agent.status === 'working' ? colors.green('●') : colors.gray('○');
305
- const name = selected ? colors.yellow(agent.name) : colors.white(agent.name);
306
-
307
- console.log(`${prefix}${statusIcon} ${name} (${agent.type})`);
308
- console.log(` ID: ${agent.id} | Tasks: ${agent.tasks} | Status: ${agent.status}`);
309
- if (agent.capabilities && agent.capabilities.length > 0) {
310
- console.log(` Capabilities: ${colors.dim(agent.capabilities.join(', '))}`);
311
- }
312
- console.log();
313
- });
314
-
315
- console.log(colors.gray(''.repeat(40)));
316
-
317
- // Tasks section
318
- console.log(colors.cyan('📋 Task Queue'));
319
- console.log();
320
- this.tasks.slice(0, 5).forEach((task) => {
321
- const statusColor =
322
- task.status === 'completed'
323
- ? colors.green
324
- : task.status === 'in_progress'
325
- ? colors.yellow
326
- : colors.gray;
327
- const status = statusColor(`[${task.status}]`);
328
- const priority =
329
- task.priority === 'high'
330
- ? colors.red(`[${task.priority}]`)
331
- : task.priority === 'medium'
332
- ? colors.yellow(`[${task.priority}]`)
333
- : colors.gray(`[${task.priority}]`);
334
- console.log(` ${status} ${priority} ${task.description}`);
335
- if (task.assignedTo) {
336
- const agent = this.agents.find((a) => a.id === task.assignedTo);
337
- console.log(` Assigned to: ${agent ? agent.name : task.assignedTo}`);
338
- }
339
- });
340
-
341
- if (this.tasks.length > 5) {
342
- console.log(colors.gray(` ... and ${this.tasks.length - 5} more tasks`));
224
+ renderStatusView() {
225
+ console.log(colors.white(colors.bold('System Status')));
226
+ console.log();
227
+ // System overview
228
+ console.log(colors.cyan('📊 System Overview'));
229
+ console.log(` Uptime: ${colors.green(this.formatUptime(this.systemStats.uptime))}`);
230
+ console.log(` Process Health: ${this.getHealthBar()}`);
231
+ console.log();
232
+ // Resource usage
233
+ console.log(colors.cyan('💻 Resource Usage'));
234
+ console.log(` CPU Usage: ${this.getUsageBar(this.systemStats.cpuUsage, 100)} ${this.systemStats.cpuUsage}%`);
235
+ console.log(` Memory: ${this.getUsageBar(this.systemStats.memoryUsage, 100)} ${this.systemStats.memoryUsage}%`);
236
+ console.log();
237
+ // Activity metrics
238
+ console.log(colors.cyan('📈 Activity Metrics'));
239
+ console.log(` Active Agents: ${colors.yellow(this.agents.filter((a)=>a.status === 'working').length)}/${this.agents.length}`);
240
+ console.log(` Total Tasks: ${this.tasks.length}`);
241
+ console.log(` Completed: ${colors.green(this.tasks.filter((t)=>t.status === 'completed').length)}`);
242
+ console.log(` In Progress: ${colors.yellow(this.tasks.filter((t)=>t.status === 'in_progress').length)}`);
243
+ console.log(` Pending: ${colors.gray(this.tasks.filter((t)=>t.status === 'pending').length)}`);
244
+ console.log();
245
+ // Recent events
246
+ console.log(colors.cyan('🔔 Recent Events'));
247
+ this.logs.slice(-3).forEach((log)=>{
248
+ const time = log.time.toLocaleTimeString();
249
+ const icon = log.level === 'success' ? '✓' : log.level === 'warning' ? '⚠' : 'ℹ';
250
+ const color = log.level === 'success' ? colors.green : log.level === 'warning' ? colors.yellow : colors.blue;
251
+ console.log(` ${colors.gray(time)} ${color(icon)} ${log.message}`);
252
+ });
343
253
  }
344
- }
345
-
346
- renderMemoryView() {
347
- console.log(colors.white(colors.bold('Memory Bank Management')));
348
- console.log();
349
-
350
- // Overview
351
- console.log(colors.cyan('💾 Memory Overview'));
352
- console.log(` Total Entries: ${colors.yellow(this.memoryStats.totalEntries)}`);
353
- console.log(` Total Size: ${colors.yellow(this.memoryStats.totalSize)}`);
354
- console.log();
355
-
356
- // Namespaces
357
- console.log(colors.cyan('📁 Namespaces'));
358
- console.log();
359
- this.memoryStats.namespaces.forEach((ns, index) => {
360
- const selected = this.currentView === VIEWS.MEMORY && index === this.selectedIndex;
361
- const prefix = selected ? colors.yellow('▶ ') : ' ';
362
- const name = selected ? colors.yellow(ns.name) : colors.white(ns.name);
363
-
364
- console.log(`${prefix}${name}`);
365
- console.log(` Entries: ${ns.entries} | Size: ${ns.size}`);
366
- console.log();
367
- });
368
-
369
- // Recent operations
370
- console.log(colors.gray('─'.repeat(40)));
371
- console.log(colors.cyan('🔄 Recent Operations'));
372
- console.log(` ${colors.green('')} Stored: config.api.key`);
373
- console.log(` ${colors.blue('↓')} Retrieved: sparc.modes`);
374
- console.log(` ${colors.yellow('✎')} Updated: agent.status`);
375
- }
376
-
377
- renderLogsView() {
378
- console.log(colors.white(colors.bold('System Logs')));
379
- console.log();
380
-
381
- // Log filters
382
- console.log(colors.cyan('🔍 Filters: ') + colors.gray('[A]ll [I]nfo [W]arning [E]rror'));
383
- console.log(colors.gray('─'.repeat(80)));
384
- console.log();
385
-
386
- // Display logs
387
- const displayLogs = this.logs.slice(-15);
388
- displayLogs.forEach((log) => {
389
- const time = log.time.toLocaleTimeString();
390
- let icon, color;
391
-
392
- switch (log.level) {
393
- case 'success':
394
- icon = '✓';
395
- color = colors.green;
396
- break;
397
- case 'warning':
398
- icon = '⚠';
399
- color = colors.yellow;
400
- break;
401
- case 'error':
402
- icon = '✗';
403
- color = colors.red;
404
- break;
405
- default:
406
- icon = 'ℹ';
407
- color = colors.blue;
408
- }
409
-
410
- console.log(`${colors.gray(time)} ${color(icon)} ${log.message}`);
411
- });
412
-
413
- if (this.logs.length > 15) {
414
- console.log();
415
- console.log(colors.gray(`Showing last 15 of ${this.logs.length} logs`));
254
+ renderOrchestrationView() {
255
+ console.log(colors.white(colors.bold('Swarm Orchestration Management')));
256
+ console.log();
257
+ // Swarm metrics
258
+ const metrics = this.swarmIntegration.getSwarmMetrics();
259
+ if (metrics) {
260
+ console.log(colors.cyan('🐝 Swarm Status'));
261
+ console.log(` Swarm ID: ${colors.yellow(metrics.swarmId)}`);
262
+ console.log(` Agents: ${colors.green(metrics.agents.active)}/${metrics.agents.total} active`);
263
+ console.log(` Tasks: ${colors.yellow(metrics.tasks.inProgress)} in progress, ${colors.green(metrics.tasks.completed)} completed`);
264
+ console.log(` Efficiency: ${metrics.efficiency}%`);
265
+ console.log();
266
+ }
267
+ // Agents section
268
+ console.log(colors.cyan('🤖 Active Agents'));
269
+ console.log();
270
+ this.agents.forEach((agent, index)=>{
271
+ const selected = this.currentView === VIEWS.ORCHESTRATION && index === this.selectedIndex;
272
+ const prefix = selected ? colors.yellow('▶ ') : ' ';
273
+ const statusIcon = agent.status === 'working' ? colors.green('●') : colors.gray('○');
274
+ const name = selected ? colors.yellow(agent.name) : colors.white(agent.name);
275
+ console.log(`${prefix}${statusIcon} ${name} (${agent.type})`);
276
+ console.log(` ID: ${agent.id} | Tasks: ${agent.tasks} | Status: ${agent.status}`);
277
+ if (agent.capabilities && agent.capabilities.length > 0) {
278
+ console.log(` Capabilities: ${colors.dim(agent.capabilities.join(', '))}`);
279
+ }
280
+ console.log();
281
+ });
282
+ console.log(colors.gray(''.repeat(40)));
283
+ // Tasks section
284
+ console.log(colors.cyan('📋 Task Queue'));
285
+ console.log();
286
+ this.tasks.slice(0, 5).forEach((task)=>{
287
+ const statusColor = task.status === 'completed' ? colors.green : task.status === 'in_progress' ? colors.yellow : colors.gray;
288
+ const status = statusColor(`[${task.status}]`);
289
+ const priority = task.priority === 'high' ? colors.red(`[${task.priority}]`) : task.priority === 'medium' ? colors.yellow(`[${task.priority}]`) : colors.gray(`[${task.priority}]`);
290
+ console.log(` ${status} ${priority} ${task.description}`);
291
+ if (task.assignedTo) {
292
+ const agent = this.agents.find((a)=>a.id === task.assignedTo);
293
+ console.log(` Assigned to: ${agent ? agent.name : task.assignedTo}`);
294
+ }
295
+ });
296
+ if (this.tasks.length > 5) {
297
+ console.log(colors.gray(` ... and ${this.tasks.length - 5} more tasks`));
298
+ }
416
299
  }
417
- }
418
-
419
- renderHelpView() {
420
- console.log(colors.white(colors.bold('Help & Documentation')));
421
- console.log();
422
-
423
- console.log(colors.cyan('🎯 Navigation'));
424
- console.log(` ${colors.yellow('1-6')} Switch between views`);
425
- console.log(` ${colors.yellow('Tab')} Cycle through views`);
426
- console.log(` ${colors.yellow('↑/↓')} Navigate items (when available)`);
427
- console.log();
428
-
429
- console.log(colors.cyan('⚡ Process Controls'));
430
- console.log(` ${colors.yellow('Space')} Toggle selected process`);
431
- console.log(` ${colors.yellow('A')} Start all processes`);
432
- console.log(` ${colors.yellow('Z')} Stop all processes`);
433
- console.log(` ${colors.yellow('R')} Restart all processes`);
434
- console.log();
435
-
436
- console.log(colors.cyan('🤖 Swarm Orchestration'));
437
- console.log(` ${colors.yellow('N')} Spawn new agent`);
438
- console.log(` ${colors.yellow('T')} Create new task`);
439
- console.log(` ${colors.yellow('D')} Complete task`);
440
- console.log(` ${colors.yellow('S')} Show swarm metrics`);
441
- console.log();
442
-
443
- console.log(colors.cyan('💾 Memory Operations'));
444
- console.log(` ${colors.yellow('S')} Store new entry`);
445
- console.log(` ${colors.yellow('G')} Get/search entries`);
446
- console.log(` ${colors.yellow('C')} Clear namespace`);
447
- console.log();
448
-
449
- console.log(colors.cyan('🔧 Other'));
450
- console.log(` ${colors.yellow('L')} Clear logs`);
451
- console.log(` ${colors.yellow('H/?')} Show this help`);
452
- console.log(` ${colors.yellow('Q')} Quit`);
453
- }
454
-
455
- renderFooter() {
456
- console.log();
457
- console.log(colors.gray('─'.repeat(80)));
458
-
459
- // Context-sensitive controls
460
- let controls = '';
461
- switch (this.currentView) {
462
- case VIEWS.PROCESSES:
463
- controls = `${colors.yellow('Space')} Toggle | ${colors.yellow('A')} Start All | ${colors.yellow('Z')} Stop All | ${colors.yellow('R')} Restart`;
464
- break;
465
- case VIEWS.ORCHESTRATION:
466
- controls = `${colors.yellow('N')} New Agent | ${colors.yellow('T')} New Task | ${colors.yellow('D')} Complete | ${colors.yellow('S')} Metrics`;
467
- break;
468
- case VIEWS.MEMORY:
469
- controls = `${colors.yellow('S')} Store | ${colors.yellow('G')} Get | ${colors.yellow('C')} Clear`;
470
- break;
471
- case VIEWS.LOGS:
472
- controls = `${colors.yellow('L')} Clear | ${colors.yellow('F')} Filter`;
473
- break;
474
- default:
475
- controls = `${colors.yellow('Tab')} Next View | ${colors.yellow('?')} Help`;
300
+ renderMemoryView() {
301
+ console.log(colors.white(colors.bold('Memory Bank Management')));
302
+ console.log();
303
+ // Overview
304
+ console.log(colors.cyan('💾 Memory Overview'));
305
+ console.log(` Total Entries: ${colors.yellow(this.memoryStats.totalEntries)}`);
306
+ console.log(` Total Size: ${colors.yellow(this.memoryStats.totalSize)}`);
307
+ console.log();
308
+ // Namespaces
309
+ console.log(colors.cyan('📁 Namespaces'));
310
+ console.log();
311
+ this.memoryStats.namespaces.forEach((ns, index)=>{
312
+ const selected = this.currentView === VIEWS.MEMORY && index === this.selectedIndex;
313
+ const prefix = selected ? colors.yellow('') : ' ';
314
+ const name = selected ? colors.yellow(ns.name) : colors.white(ns.name);
315
+ console.log(`${prefix}${name}`);
316
+ console.log(` Entries: ${ns.entries} | Size: ${ns.size}`);
317
+ console.log();
318
+ });
319
+ // Recent operations
320
+ console.log(colors.gray(''.repeat(40)));
321
+ console.log(colors.cyan('🔄 Recent Operations'));
322
+ console.log(` ${colors.green('')} Stored: config.api.key`);
323
+ console.log(` ${colors.blue('')} Retrieved: sparc.modes`);
324
+ console.log(` ${colors.yellow('✎')} Updated: agent.status`);
476
325
  }
477
-
478
- console.log(`${controls} | ${colors.yellow('Q')} Quit`);
479
- console.log(colors.gray('─'.repeat(80)));
480
- }
481
-
482
- getStatusIcon(status) {
483
- switch (status) {
484
- case 'running':
485
- return colors.green('●');
486
- case 'stopped':
487
- return colors.gray('○');
488
- case 'error':
489
- return colors.red('✗');
490
- case 'starting':
491
- return colors.yellow('');
492
- default:
493
- return colors.gray('?');
326
+ renderLogsView() {
327
+ console.log(colors.white(colors.bold('System Logs')));
328
+ console.log();
329
+ // Log filters
330
+ console.log(colors.cyan('🔍 Filters: ') + colors.gray('[A]ll [I]nfo [W]arning [E]rror'));
331
+ console.log(colors.gray('─'.repeat(80)));
332
+ console.log();
333
+ // Display logs
334
+ const displayLogs = this.logs.slice(-15);
335
+ displayLogs.forEach((log)=>{
336
+ const time = log.time.toLocaleTimeString();
337
+ let icon, color;
338
+ switch(log.level){
339
+ case 'success':
340
+ icon = '';
341
+ color = colors.green;
342
+ break;
343
+ case 'warning':
344
+ icon = '⚠';
345
+ color = colors.yellow;
346
+ break;
347
+ case 'error':
348
+ icon = '✗';
349
+ color = colors.red;
350
+ break;
351
+ default:
352
+ icon = 'ℹ';
353
+ color = colors.blue;
354
+ }
355
+ console.log(`${colors.gray(time)} ${color(icon)} ${log.message}`);
356
+ });
357
+ if (this.logs.length > 15) {
358
+ console.log();
359
+ console.log(colors.gray(`Showing last 15 of ${this.logs.length} logs`));
360
+ }
494
361
  }
495
- }
496
-
497
- getHealthBar() {
498
- const running = Array.from(this.processes.values()).filter(
499
- (p) => p.status === 'running',
500
- ).length;
501
- const total = this.processes.size;
502
- const percentage = (running / total) * 100;
503
- const filled = Math.round(percentage / 10);
504
- const bar = '█'.repeat(filled) + ''.repeat(10 - filled);
505
- const color = percentage >= 80 ? colors.green : percentage >= 50 ? colors.yellow : colors.red;
506
- return color(bar) + ` ${percentage.toFixed(0)}%`;
507
- }
508
-
509
- getUsageBar(value, max) {
510
- const percentage = (value / max) * 100;
511
- const filled = Math.round(percentage / 10);
512
- const bar = '▓'.repeat(filled) + ''.repeat(10 - filled);
513
- const color = percentage >= 80 ? colors.red : percentage >= 50 ? colors.yellow : colors.green;
514
- return color(bar);
515
- }
516
-
517
- formatUptime(seconds) {
518
- if (seconds < 60) return `${seconds}s`;
519
- if (seconds < 3600) return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
520
- const hours = Math.floor(seconds / 3600);
521
- const minutes = Math.floor((seconds % 3600) / 60);
522
- return `${hours}h ${minutes}m`;
523
- }
524
-
525
- async handleInput() {
526
- const terminal = compat.terminal;
527
-
528
- await terminal.write('\nCommand: ');
529
-
530
- const buf = new Uint8Array(1024);
531
- const n = await terminal.read(buf);
532
- if (n === null) return;
533
-
534
- const rawInput = terminal.decoder.decode(buf.subarray(0, n)).trim();
535
- const input = rawInput.split('\n')[0].toLowerCase();
536
-
537
- // Global commands
538
- switch (input) {
539
- case 'q':
540
- case 'quit':
541
- this.running = false;
542
- console.clear();
543
- printSuccess('Goodbye!');
544
- compat.terminal.exit(0);
545
- break;
546
-
547
- case '1':
548
- this.currentView = VIEWS.PROCESSES;
549
- this.selectedIndex = 0;
550
- break;
551
-
552
- case '2':
553
- this.currentView = VIEWS.STATUS;
554
- this.selectedIndex = 0;
555
- break;
556
-
557
- case '3':
558
- this.currentView = VIEWS.ORCHESTRATION;
559
- this.selectedIndex = 0;
560
- break;
561
-
562
- case '4':
563
- this.currentView = VIEWS.MEMORY;
564
- this.selectedIndex = 0;
565
- break;
566
-
567
- case '5':
568
- this.currentView = VIEWS.LOGS;
569
- this.selectedIndex = 0;
570
- break;
571
-
572
- case '6':
573
- case '?':
574
- case 'h':
575
- case 'help':
576
- this.currentView = VIEWS.HELP;
577
- break;
578
-
579
- case 'tab':
580
- case '\t':
581
- // Cycle through views
582
- const viewKeys = Object.values(VIEWS);
583
- const currentIndex = viewKeys.indexOf(this.currentView);
584
- this.currentView = viewKeys[(currentIndex + 1) % viewKeys.length];
585
- this.selectedIndex = 0;
586
- break;
587
-
588
- default:
589
- // View-specific commands
590
- await this.handleViewSpecificInput(input);
362
+ renderHelpView() {
363
+ console.log(colors.white(colors.bold('Help & Documentation')));
364
+ console.log();
365
+ console.log(colors.cyan('🎯 Navigation'));
366
+ console.log(` ${colors.yellow('1-6')} Switch between views`);
367
+ console.log(` ${colors.yellow('Tab')} Cycle through views`);
368
+ console.log(` ${colors.yellow('↑/↓')} Navigate items (when available)`);
369
+ console.log();
370
+ console.log(colors.cyan('⚡ Process Controls'));
371
+ console.log(` ${colors.yellow('Space')} Toggle selected process`);
372
+ console.log(` ${colors.yellow('A')} Start all processes`);
373
+ console.log(` ${colors.yellow('Z')} Stop all processes`);
374
+ console.log(` ${colors.yellow('R')} Restart all processes`);
375
+ console.log();
376
+ console.log(colors.cyan('🤖 Swarm Orchestration'));
377
+ console.log(` ${colors.yellow('N')} Spawn new agent`);
378
+ console.log(` ${colors.yellow('T')} Create new task`);
379
+ console.log(` ${colors.yellow('D')} Complete task`);
380
+ console.log(` ${colors.yellow('S')} Show swarm metrics`);
381
+ console.log();
382
+ console.log(colors.cyan('💾 Memory Operations'));
383
+ console.log(` ${colors.yellow('S')} Store new entry`);
384
+ console.log(` ${colors.yellow('G')} Get/search entries`);
385
+ console.log(` ${colors.yellow('C')} Clear namespace`);
386
+ console.log();
387
+ console.log(colors.cyan('🔧 Other'));
388
+ console.log(` ${colors.yellow('L')} Clear logs`);
389
+ console.log(` ${colors.yellow('H/?')} Show this help`);
390
+ console.log(` ${colors.yellow('Q')} Quit`);
591
391
  }
592
-
593
- // Update system stats
594
- this.updateSystemStats();
595
- }
596
-
597
- async handleViewSpecificInput(input) {
598
- switch (this.currentView) {
599
- case VIEWS.PROCESSES:
600
- await this.handleProcessInput(input);
601
- break;
602
- case VIEWS.ORCHESTRATION:
603
- await this.handleOrchestrationInput(input);
604
- break;
605
- case VIEWS.MEMORY:
606
- await this.handleMemoryInput(input);
607
- break;
608
- case VIEWS.LOGS:
609
- await this.handleLogsInput(input);
610
- break;
392
+ renderFooter() {
393
+ console.log();
394
+ console.log(colors.gray('─'.repeat(80)));
395
+ // Context-sensitive controls
396
+ let controls = '';
397
+ switch(this.currentView){
398
+ case VIEWS.PROCESSES:
399
+ controls = `${colors.yellow('Space')} Toggle | ${colors.yellow('A')} Start All | ${colors.yellow('Z')} Stop All | ${colors.yellow('R')} Restart`;
400
+ break;
401
+ case VIEWS.ORCHESTRATION:
402
+ controls = `${colors.yellow('N')} New Agent | ${colors.yellow('T')} New Task | ${colors.yellow('D')} Complete | ${colors.yellow('S')} Metrics`;
403
+ break;
404
+ case VIEWS.MEMORY:
405
+ controls = `${colors.yellow('S')} Store | ${colors.yellow('G')} Get | ${colors.yellow('C')} Clear`;
406
+ break;
407
+ case VIEWS.LOGS:
408
+ controls = `${colors.yellow('L')} Clear | ${colors.yellow('F')} Filter`;
409
+ break;
410
+ default:
411
+ controls = `${colors.yellow('Tab')} Next View | ${colors.yellow('?')} Help`;
412
+ }
413
+ console.log(`${controls} | ${colors.yellow('Q')} Quit`);
414
+ console.log(colors.gray('─'.repeat(80)));
611
415
  }
612
- }
613
-
614
- async handleProcessInput(input) {
615
- switch (input) {
616
- case 'a':
617
- await this.startAll();
618
- break;
619
-
620
- case 'z':
621
- await this.stopAll();
622
- break;
623
-
624
- case 'r':
625
- await this.restartAll();
626
- break;
627
-
628
- case ' ':
629
- case 'space':
630
- case 'enter':
631
- case '':
632
- await this.toggleSelected();
633
- break;
634
-
635
- case 'up':
636
- case 'k':
637
- this.selectedIndex = Math.max(0, this.selectedIndex - 1);
638
- break;
639
-
640
- case 'down':
641
- case 'j':
642
- this.selectedIndex = Math.min(this.processes.size - 1, this.selectedIndex + 1);
643
- break;
416
+ getStatusIcon(status) {
417
+ switch(status){
418
+ case 'running':
419
+ return colors.green('●');
420
+ case 'stopped':
421
+ return colors.gray('○');
422
+ case 'error':
423
+ return colors.red('✗');
424
+ case 'starting':
425
+ return colors.yellow('◐');
426
+ default:
427
+ return colors.gray('?');
428
+ }
644
429
  }
645
- }
646
-
647
- async handleOrchestrationInput(input) {
648
- switch (input) {
649
- case 'n':
650
- // Spawn new agent
651
- const agentTypes = ['researcher', 'coder', 'analyst', 'coordinator', 'tester'];
652
- const randomType = agentTypes[Math.floor(Math.random() * agentTypes.length)];
653
- await this.swarmIntegration.spawnAgent(randomType);
654
- break;
655
-
656
- case 't':
657
- // Create new task
658
- const sampleTasks = [
659
- 'Implement new feature',
660
- 'Fix critical bug',
661
- 'Optimize performance',
662
- 'Update documentation',
663
- 'Review code quality',
664
- ];
665
- const randomTask = sampleTasks[Math.floor(Math.random() * sampleTasks.length)];
666
- await this.swarmIntegration.createTask(randomTask, 'medium');
667
- break;
668
-
669
- case 'd':
670
- // Complete selected task (simulate)
671
- if (this.tasks.length > 0) {
672
- const pendingTasks = this.tasks.filter((t) => t.status === 'in_progress');
673
- if (pendingTasks.length > 0) {
674
- const taskToComplete = pendingTasks[0];
675
- await this.swarmIntegration.completeTask(taskToComplete.id);
676
- } else {
677
- this.addLog('info', 'No in-progress tasks to complete');
678
- }
430
+ getHealthBar() {
431
+ const running = Array.from(this.processes.values()).filter((p)=>p.status === 'running').length;
432
+ const total = this.processes.size;
433
+ const percentage = running / total * 100;
434
+ const filled = Math.round(percentage / 10);
435
+ const bar = '█'.repeat(filled) + '░'.repeat(10 - filled);
436
+ const color = percentage >= 80 ? colors.green : percentage >= 50 ? colors.yellow : colors.red;
437
+ return color(bar) + ` ${percentage.toFixed(0)}%`;
438
+ }
439
+ getUsageBar(value, max) {
440
+ const percentage = value / max * 100;
441
+ const filled = Math.round(percentage / 10);
442
+ const bar = '▓'.repeat(filled) + '░'.repeat(10 - filled);
443
+ const color = percentage >= 80 ? colors.red : percentage >= 50 ? colors.yellow : colors.green;
444
+ return color(bar);
445
+ }
446
+ formatUptime(seconds) {
447
+ if (seconds < 60) return `${seconds}s`;
448
+ if (seconds < 3600) return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
449
+ const hours = Math.floor(seconds / 3600);
450
+ const minutes = Math.floor(seconds % 3600 / 60);
451
+ return `${hours}h ${minutes}m`;
452
+ }
453
+ async handleInput() {
454
+ const terminal = compat.terminal;
455
+ await terminal.write('\nCommand: ');
456
+ const buf = new Uint8Array(1024);
457
+ const n = await terminal.read(buf);
458
+ if (n === null) return;
459
+ const rawInput = terminal.decoder.decode(buf.subarray(0, n)).trim();
460
+ const input = rawInput.split('\n')[0].toLowerCase();
461
+ // Global commands
462
+ switch(input){
463
+ case 'q':
464
+ case 'quit':
465
+ this.running = false;
466
+ console.clear();
467
+ printSuccess('Goodbye!');
468
+ compat.terminal.exit(0);
469
+ break;
470
+ case '1':
471
+ this.currentView = VIEWS.PROCESSES;
472
+ this.selectedIndex = 0;
473
+ break;
474
+ case '2':
475
+ this.currentView = VIEWS.STATUS;
476
+ this.selectedIndex = 0;
477
+ break;
478
+ case '3':
479
+ this.currentView = VIEWS.ORCHESTRATION;
480
+ this.selectedIndex = 0;
481
+ break;
482
+ case '4':
483
+ this.currentView = VIEWS.MEMORY;
484
+ this.selectedIndex = 0;
485
+ break;
486
+ case '5':
487
+ this.currentView = VIEWS.LOGS;
488
+ this.selectedIndex = 0;
489
+ break;
490
+ case '6':
491
+ case '?':
492
+ case 'h':
493
+ case 'help':
494
+ this.currentView = VIEWS.HELP;
495
+ break;
496
+ case 'tab':
497
+ case '\t':
498
+ // Cycle through views
499
+ const viewKeys = Object.values(VIEWS);
500
+ const currentIndex = viewKeys.indexOf(this.currentView);
501
+ this.currentView = viewKeys[(currentIndex + 1) % viewKeys.length];
502
+ this.selectedIndex = 0;
503
+ break;
504
+ default:
505
+ // View-specific commands
506
+ await this.handleViewSpecificInput(input);
679
507
  }
680
- break;
681
-
682
- case 's':
683
- // Show swarm metrics
684
- const metrics = this.swarmIntegration.getSwarmMetrics();
685
- if (metrics) {
686
- this.addLog(
687
- 'info',
688
- `Swarm efficiency: ${metrics.efficiency}% (${metrics.tasks.completed}/${metrics.tasks.total} tasks completed)`,
689
- );
508
+ // Update system stats
509
+ this.updateSystemStats();
510
+ }
511
+ async handleViewSpecificInput(input) {
512
+ switch(this.currentView){
513
+ case VIEWS.PROCESSES:
514
+ await this.handleProcessInput(input);
515
+ break;
516
+ case VIEWS.ORCHESTRATION:
517
+ await this.handleOrchestrationInput(input);
518
+ break;
519
+ case VIEWS.MEMORY:
520
+ await this.handleMemoryInput(input);
521
+ break;
522
+ case VIEWS.LOGS:
523
+ await this.handleLogsInput(input);
524
+ break;
690
525
  }
691
- break;
692
526
  }
693
- }
694
-
695
- async handleMemoryInput(input) {
696
- switch (input) {
697
- case 's':
698
- this.addLog('info', 'Memory storage not yet implemented');
699
- break;
700
-
701
- case 'g':
702
- this.addLog('info', 'Memory retrieval not yet implemented');
703
- break;
704
-
705
- case 'c':
706
- this.addLog('warning', 'Memory clearing not yet implemented');
707
- break;
527
+ async handleProcessInput(input) {
528
+ switch(input){
529
+ case 'a':
530
+ await this.startAll();
531
+ break;
532
+ case 'z':
533
+ await this.stopAll();
534
+ break;
535
+ case 'r':
536
+ await this.restartAll();
537
+ break;
538
+ case ' ':
539
+ case 'space':
540
+ case 'enter':
541
+ case '':
542
+ await this.toggleSelected();
543
+ break;
544
+ case 'up':
545
+ case 'k':
546
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
547
+ break;
548
+ case 'down':
549
+ case 'j':
550
+ this.selectedIndex = Math.min(this.processes.size - 1, this.selectedIndex + 1);
551
+ break;
552
+ }
708
553
  }
709
- }
710
-
711
- async handleLogsInput(input) {
712
- switch (input) {
713
- case 'l':
714
- this.logs = [];
715
- this.addLog('info', 'Logs cleared');
716
- break;
717
-
718
- case 'f':
719
- this.addLog('info', 'Log filtering not yet implemented');
720
- break;
554
+ async handleOrchestrationInput(input) {
555
+ switch(input){
556
+ case 'n':
557
+ // Spawn new agent
558
+ const agentTypes = [
559
+ 'researcher',
560
+ 'coder',
561
+ 'analyst',
562
+ 'coordinator',
563
+ 'tester'
564
+ ];
565
+ const randomType = agentTypes[Math.floor(Math.random() * agentTypes.length)];
566
+ await this.swarmIntegration.spawnAgent(randomType);
567
+ break;
568
+ case 't':
569
+ // Create new task
570
+ const sampleTasks = [
571
+ 'Implement new feature',
572
+ 'Fix critical bug',
573
+ 'Optimize performance',
574
+ 'Update documentation',
575
+ 'Review code quality'
576
+ ];
577
+ const randomTask = sampleTasks[Math.floor(Math.random() * sampleTasks.length)];
578
+ await this.swarmIntegration.createTask(randomTask, 'medium');
579
+ break;
580
+ case 'd':
581
+ // Complete selected task (simulate)
582
+ if (this.tasks.length > 0) {
583
+ const pendingTasks = this.tasks.filter((t)=>t.status === 'in_progress');
584
+ if (pendingTasks.length > 0) {
585
+ const taskToComplete = pendingTasks[0];
586
+ await this.swarmIntegration.completeTask(taskToComplete.id);
587
+ } else {
588
+ this.addLog('info', 'No in-progress tasks to complete');
589
+ }
590
+ }
591
+ break;
592
+ case 's':
593
+ // Show swarm metrics
594
+ const metrics = this.swarmIntegration.getSwarmMetrics();
595
+ if (metrics) {
596
+ this.addLog('info', `Swarm efficiency: ${metrics.efficiency}% (${metrics.tasks.completed}/${metrics.tasks.total} tasks completed)`);
597
+ }
598
+ break;
599
+ }
600
+ }
601
+ async handleMemoryInput(input) {
602
+ switch(input){
603
+ case 's':
604
+ this.addLog('info', 'Memory storage not yet implemented');
605
+ break;
606
+ case 'g':
607
+ this.addLog('info', 'Memory retrieval not yet implemented');
608
+ break;
609
+ case 'c':
610
+ this.addLog('warning', 'Memory clearing not yet implemented');
611
+ break;
612
+ }
613
+ }
614
+ async handleLogsInput(input) {
615
+ switch(input){
616
+ case 'l':
617
+ this.logs = [];
618
+ this.addLog('info', 'Logs cleared');
619
+ break;
620
+ case 'f':
621
+ this.addLog('info', 'Log filtering not yet implemented');
622
+ break;
623
+ }
624
+ }
625
+ addLog(level, message) {
626
+ this.logs.push({
627
+ time: new Date(),
628
+ level,
629
+ message
630
+ });
721
631
  }
722
- }
723
-
724
- addLog(level, message) {
725
- this.logs.push({
726
- time: new Date(),
727
- level,
728
- message,
729
- });
730
- }
731
-
732
- updateSystemStats() {
733
- // Update random stats for demo
734
- this.systemStats.cpuUsage = Math.min(
735
- 100,
736
- Math.max(0, this.systemStats.cpuUsage + (Math.random() - 0.5) * 10),
737
- );
738
- this.systemStats.memoryUsage = Math.min(
739
- 100,
740
- Math.max(0, this.systemStats.memoryUsage + (Math.random() - 0.5) * 5),
741
- );
742
-
743
- // Update process stats
744
- for (const [id, process] of this.processes) {
745
- if (process.status === 'running') {
746
- process.uptime++;
747
- process.cpu = Math.min(100, Math.max(0, process.cpu + (Math.random() - 0.5) * 2));
748
- process.memory = Math.min(200, Math.max(10, process.memory + (Math.random() - 0.5) * 5));
749
- }
632
+ updateSystemStats() {
633
+ // Update random stats for demo
634
+ this.systemStats.cpuUsage = Math.min(100, Math.max(0, this.systemStats.cpuUsage + (Math.random() - 0.5) * 10));
635
+ this.systemStats.memoryUsage = Math.min(100, Math.max(0, this.systemStats.memoryUsage + (Math.random() - 0.5) * 5));
636
+ // Update process stats
637
+ for (const [id, process] of this.processes){
638
+ if (process.status === 'running') {
639
+ process.uptime++;
640
+ process.cpu = Math.min(100, Math.max(0, process.cpu + (Math.random() - 0.5) * 2));
641
+ process.memory = Math.min(200, Math.max(10, process.memory + (Math.random() - 0.5) * 5));
642
+ }
643
+ }
644
+ }
645
+ async toggleSelected() {
646
+ const process = Array.from(this.processes.values())[this.selectedIndex];
647
+ if (process.status === 'stopped') {
648
+ await this.startProcess(process.id);
649
+ } else {
650
+ await this.stopProcess(process.id);
651
+ }
652
+ }
653
+ async startProcess(id) {
654
+ const process = this.processes.get(id);
655
+ if (!process) return;
656
+ this.addLog('info', `Starting ${process.name}...`);
657
+ process.status = 'starting';
658
+ await new Promise((resolve)=>setTimeout(resolve, 500));
659
+ process.status = 'running';
660
+ process.pid = Math.floor(Math.random() * 10000) + 1000;
661
+ process.uptime = 0;
662
+ this.addLog('success', `${process.name} started successfully`);
750
663
  }
751
- }
752
-
753
- async toggleSelected() {
754
- const process = Array.from(this.processes.values())[this.selectedIndex];
755
- if (process.status === 'stopped') {
756
- await this.startProcess(process.id);
757
- } else {
758
- await this.stopProcess(process.id);
664
+ async stopProcess(id) {
665
+ const process = this.processes.get(id);
666
+ if (!process) return;
667
+ this.addLog('info', `Stopping ${process.name}...`);
668
+ process.status = 'stopped';
669
+ process.pid = null;
670
+ process.uptime = 0;
671
+ await new Promise((resolve)=>setTimeout(resolve, 300));
672
+ this.addLog('success', `${process.name} stopped`);
759
673
  }
760
- }
761
-
762
- async startProcess(id) {
763
- const process = this.processes.get(id);
764
- if (!process) return;
765
-
766
- this.addLog('info', `Starting ${process.name}...`);
767
- process.status = 'starting';
768
-
769
- await new Promise((resolve) => setTimeout(resolve, 500));
770
-
771
- process.status = 'running';
772
- process.pid = Math.floor(Math.random() * 10000) + 1000;
773
- process.uptime = 0;
774
-
775
- this.addLog('success', `${process.name} started successfully`);
776
- }
777
-
778
- async stopProcess(id) {
779
- const process = this.processes.get(id);
780
- if (!process) return;
781
-
782
- this.addLog('info', `Stopping ${process.name}...`);
783
- process.status = 'stopped';
784
- process.pid = null;
785
- process.uptime = 0;
786
-
787
- await new Promise((resolve) => setTimeout(resolve, 300));
788
- this.addLog('success', `${process.name} stopped`);
789
- }
790
-
791
- async startAll() {
792
- this.addLog('info', 'Starting all processes...');
793
- for (const [id, process] of this.processes) {
794
- if (process.status === 'stopped') {
795
- await this.startProcess(id);
796
- }
674
+ async startAll() {
675
+ this.addLog('info', 'Starting all processes...');
676
+ for (const [id, process] of this.processes){
677
+ if (process.status === 'stopped') {
678
+ await this.startProcess(id);
679
+ }
680
+ }
681
+ this.addLog('success', 'All processes started');
682
+ }
683
+ async stopAll() {
684
+ this.addLog('info', 'Stopping all processes...');
685
+ for (const [id, process] of this.processes){
686
+ if (process.status === 'running') {
687
+ await this.stopProcess(id);
688
+ }
689
+ }
690
+ this.addLog('success', 'All processes stopped');
797
691
  }
798
- this.addLog('success', 'All processes started');
799
- }
800
-
801
- async stopAll() {
802
- this.addLog('info', 'Stopping all processes...');
803
- for (const [id, process] of this.processes) {
804
- if (process.status === 'running') {
805
- await this.stopProcess(id);
806
- }
692
+ async restartAll() {
693
+ await this.stopAll();
694
+ await new Promise((resolve)=>setTimeout(resolve, 500));
695
+ await this.startAll();
696
+ }
697
+ constructor(){
698
+ this.processes = new Map();
699
+ this.running = true;
700
+ this.selectedIndex = 0;
701
+ this.currentView = VIEWS.PROCESSES;
702
+ this.agents = [];
703
+ this.tasks = [];
704
+ this.memoryStats = {
705
+ totalEntries: 0,
706
+ totalSize: 0,
707
+ namespaces: []
708
+ };
709
+ this.logs = [];
710
+ this.systemStats = {
711
+ uptime: 0,
712
+ totalTasks: 0,
713
+ completedTasks: 0,
714
+ activeAgents: 0,
715
+ memoryUsage: 0,
716
+ cpuUsage: 0
717
+ };
718
+ // Initialize swarm integration
719
+ this.swarmIntegration = new SwarmWebUIIntegration(this);
720
+ // Initialize process states
721
+ PROCESSES.forEach((p)=>{
722
+ this.processes.set(p.id, {
723
+ ...p,
724
+ status: 'stopped',
725
+ pid: null,
726
+ uptime: 0,
727
+ cpu: Math.random() * 5,
728
+ memory: Math.random() * 100
729
+ });
730
+ });
731
+ // Start system uptime counter
732
+ setInterval(()=>{
733
+ this.systemStats.uptime++;
734
+ }, 1000);
735
+ // Initialize swarm (this will create mock data)
736
+ this.initializeSwarm();
807
737
  }
808
- this.addLog('success', 'All processes stopped');
809
- }
810
-
811
- async restartAll() {
812
- await this.stopAll();
813
- await new Promise((resolve) => setTimeout(resolve, 500));
814
- await this.startAll();
815
- }
816
738
  }
817
-
818
739
  export async function launchEnhancedUI() {
819
- const ui = new EnhancedProcessUI();
820
- await ui.start();
740
+ const ui = new EnhancedProcessUI();
741
+ await ui.start();
821
742
  }