claude-flow-novice 1.3.0 → 1.3.2

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 (305) hide show
  1. package/.claude-flow-novice/preferences/generation.json +147 -0
  2. package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
  3. package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
  4. package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
  5. package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
  6. package/.claude-flow-novice/preferences/project-local.json +91 -0
  7. package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
  8. package/.claude-flow-novice/preferences/team-shared.json +195 -0
  9. package/.claude-flow-novice/preferences/user-global.json +247 -0
  10. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
  11. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
  12. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
  13. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
  14. package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
  15. package/CLAUDE.md +81 -0
  16. package/README-NPM.md +0 -0
  17. package/package.json +11 -7
  18. package/scripts/build/README.md +167 -0
  19. package/scripts/build/build-config.js +27 -0
  20. package/scripts/build/build-prompt-copier.sh +30 -0
  21. package/scripts/build/performance-monitor.js +869 -0
  22. package/scripts/build/prepare-publish.js +150 -0
  23. package/scripts/build/typescript-fixer.js +621 -0
  24. package/scripts/build/unified-builder.sh +428 -0
  25. package/scripts/build/update-bin-version.js +32 -0
  26. package/scripts/dev/README.md +264 -0
  27. package/scripts/dev/claude-flow-wrapper.sh +35 -0
  28. package/scripts/dev/claude-monitor.py +419 -0
  29. package/scripts/dev/claude-sparc.sh +562 -0
  30. package/scripts/dev/claude-wrapper.sh +17 -0
  31. package/scripts/dev/demo-phase3-compliance.js +172 -0
  32. package/scripts/dev/demo-task-system.ts +224 -0
  33. package/scripts/dev/deployment-validator.js +315 -0
  34. package/scripts/dev/spawn-claude-terminal.sh +32 -0
  35. package/scripts/dev/start-portal.sh +506 -0
  36. package/scripts/dev/start-web-ui.js +15 -0
  37. package/scripts/dev/stop-portal.sh +311 -0
  38. package/scripts/dev/validate-examples.ts +288 -0
  39. package/scripts/dev/validate-phase2.cjs +451 -0
  40. package/scripts/dev/validate-phase2.js +785 -0
  41. package/scripts/dev/validate-phase3.cjs +208 -0
  42. package/scripts/dev/validate-security-remediation.js +1 -0
  43. package/scripts/legacy/README.md +272 -0
  44. package/scripts/legacy/batch-fix-ts.sh +54 -0
  45. package/scripts/legacy/build-migration.sh +105 -0
  46. package/scripts/legacy/build-monitor.js +209 -0
  47. package/scripts/legacy/build-with-filter.sh +84 -0
  48. package/scripts/legacy/build-workaround.sh +71 -0
  49. package/scripts/legacy/fix-ts-advanced.js +358 -0
  50. package/scripts/legacy/fix-ts-final.sh +50 -0
  51. package/scripts/legacy/fix-ts-targeted.sh +49 -0
  52. package/scripts/legacy/fix-typescript-errors.js +305 -0
  53. package/scripts/legacy/force-build.sh +63 -0
  54. package/scripts/legacy/optimize-performance.js +400 -0
  55. package/scripts/legacy/performance-monitor.js +263 -0
  56. package/scripts/legacy/performance-monitoring.js +532 -0
  57. package/scripts/legacy/performance-test-runner.js +645 -0
  58. package/scripts/legacy/quick-fix-ts.js +281 -0
  59. package/scripts/legacy/safe-build.sh +63 -0
  60. package/scripts/migration/README.md +434 -0
  61. package/scripts/migration/install-arm64.js +78 -0
  62. package/scripts/migration/install.js +83 -0
  63. package/scripts/migration/migrate-hooks.js +173 -0
  64. package/scripts/migration/migration-examples.ts +318 -0
  65. package/scripts/optimization/build-optimizer.js +438 -0
  66. package/scripts/optimization/config-validator.js +761 -0
  67. package/scripts/optimization/test-optimization.js +432 -0
  68. package/scripts/optimization/unified-activation.js +839 -0
  69. package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
  70. package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
  71. package/scripts/performance/test-enhanced-backend.sh +504 -0
  72. package/scripts/performance-test-runner.js +698 -0
  73. package/scripts/security/README.md +339 -0
  74. package/scripts/security/install-git-hooks.sh +132 -0
  75. package/scripts/security/ruv-swarm-safe.js +74 -0
  76. package/scripts/test/README.md +236 -0
  77. package/scripts/test/check-links.ts +274 -0
  78. package/scripts/test/check-performance-regression.ts +168 -0
  79. package/scripts/test/coverage-report.ts +692 -0
  80. package/scripts/test/generate-swarm-tests.js +633 -0
  81. package/scripts/test/integration-test-validation.cjs +253 -0
  82. package/scripts/test/load-test-swarm.js +576 -0
  83. package/scripts/test/run-phase3-compliance-tests.js +427 -0
  84. package/scripts/test/test-batch-tasks.ts +29 -0
  85. package/scripts/test/test-byzantine-resolution.js +246 -0
  86. package/scripts/test/test-claude-spawn-options.sh +63 -0
  87. package/scripts/test/test-cli-wizard.js +331 -0
  88. package/scripts/test/test-comprehensive.js +401 -0
  89. package/scripts/test/test-coordination-features.ts +238 -0
  90. package/scripts/test/test-fallback-systems.js +276 -0
  91. package/scripts/test/test-init-command.ts +302 -0
  92. package/scripts/test/test-mcp.ts +251 -0
  93. package/scripts/test/test-runner.ts +568 -0
  94. package/scripts/test/test-swarm-integration.sh +92 -0
  95. package/scripts/test/test-swarm.ts +142 -0
  96. package/scripts/test/validation-summary.ts +408 -0
  97. package/scripts/utils/README.md +261 -0
  98. package/scripts/utils/clean-build-artifacts.sh +94 -0
  99. package/scripts/utils/cleanup-root.sh +69 -0
  100. package/scripts/utils/fix-cliffy-imports.js +307 -0
  101. package/scripts/utils/fix-duplicate-imports.js +114 -0
  102. package/scripts/utils/fix-error-handling.cjs +70 -0
  103. package/scripts/utils/fix-import-paths.js +104 -0
  104. package/scripts/utils/fix-imports.js +116 -0
  105. package/scripts/utils/fix-shebang.js +78 -0
  106. package/scripts/utils/fix-test-modules.js +27 -0
  107. package/scripts/utils/fix-timezone-issue-246.js +200 -0
  108. package/scripts/utils/fix-ts-comprehensive.py +182 -0
  109. package/scripts/utils/fix-ts-targeted-batch.js +250 -0
  110. package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
  111. package/scripts/utils/simple-test-fixer.js +190 -0
  112. package/scripts/utils/validate-metrics-structure.cjs +144 -0
  113. package/scripts/verify-mcp-server.js +86 -0
  114. package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
  115. package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
  116. package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
  117. package/src/cli/simple-commands/__tests__/task.test.js +8 -0
  118. package/src/cli/simple-commands/agent.js +216 -0
  119. package/src/cli/simple-commands/analysis.js +570 -0
  120. package/src/cli/simple-commands/automation-executor.js +1603 -0
  121. package/src/cli/simple-commands/automation.js +627 -0
  122. package/src/cli/simple-commands/batch-manager.js +338 -0
  123. package/src/cli/simple-commands/claude-telemetry.js +311 -0
  124. package/src/cli/simple-commands/claude-track.js +102 -0
  125. package/src/cli/simple-commands/concurrent-display.js +348 -0
  126. package/src/cli/simple-commands/config.js +319 -0
  127. package/src/cli/simple-commands/coordination.js +307 -0
  128. package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
  129. package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
  130. package/src/cli/simple-commands/fix-hook-variables.js +363 -0
  131. package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
  132. package/src/cli/simple-commands/github/github-api.js +624 -0
  133. package/src/cli/simple-commands/github/init.js +543 -0
  134. package/src/cli/simple-commands/github.js +377 -0
  135. package/src/cli/simple-commands/goal.js +145 -0
  136. package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
  137. package/src/cli/simple-commands/hive-mind/communication.js +740 -0
  138. package/src/cli/simple-commands/hive-mind/core.js +1031 -0
  139. package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
  140. package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
  141. package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
  142. package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
  143. package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
  144. package/src/cli/simple-commands/hive-mind/queen.js +809 -0
  145. package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
  146. package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
  147. package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
  148. package/src/cli/simple-commands/hive-mind.js +3112 -0
  149. package/src/cli/simple-commands/hive.js +140 -0
  150. package/src/cli/simple-commands/hook-safety.js +671 -0
  151. package/src/cli/simple-commands/hooks.js +1268 -0
  152. package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
  153. package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
  154. package/src/cli/simple-commands/init/README.md +106 -0
  155. package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
  156. package/src/cli/simple-commands/init/agent-copier.js +347 -0
  157. package/src/cli/simple-commands/init/batch-init.js +663 -0
  158. package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
  159. package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
  160. package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
  161. package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
  162. package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
  163. package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
  164. package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
  165. package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
  166. package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
  167. package/src/cli/simple-commands/init/help.js +110 -0
  168. package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
  169. package/src/cli/simple-commands/init/index.js +1953 -0
  170. package/src/cli/simple-commands/init/performance-monitor.js +344 -0
  171. package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
  172. package/src/cli/simple-commands/init/rollback/index.js +399 -0
  173. package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
  174. package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
  175. package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
  176. package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
  177. package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
  178. package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
  179. package/src/cli/simple-commands/init/sparc-structure.js +68 -0
  180. package/src/cli/simple-commands/init/template-copier.js +640 -0
  181. package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
  182. package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
  183. package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
  184. package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
  185. package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
  186. package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
  187. package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
  188. package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
  189. package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
  190. package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
  191. package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
  192. package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
  193. package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
  194. package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
  195. package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
  196. package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
  197. package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
  198. package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
  199. package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
  200. package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
  201. package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
  202. package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
  203. package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
  204. package/src/cli/simple-commands/init/templates/coordination.md +16 -0
  205. package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
  206. package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
  207. package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
  208. package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
  209. package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
  210. package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
  211. package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
  212. package/src/cli/simple-commands/init/templates/settings.json +109 -0
  213. package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
  214. package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
  215. package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
  216. package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
  217. package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
  218. package/src/cli/simple-commands/init/validation/index.js +388 -0
  219. package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
  220. package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
  221. package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
  222. package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
  223. package/src/cli/simple-commands/init.js +4 -0
  224. package/src/cli/simple-commands/mcp-health.js +163 -0
  225. package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
  226. package/src/cli/simple-commands/mcp.js +420 -0
  227. package/src/cli/simple-commands/memory-consolidation.js +631 -0
  228. package/src/cli/simple-commands/memory.js +345 -0
  229. package/src/cli/simple-commands/migrate-hooks.js +63 -0
  230. package/src/cli/simple-commands/monitor.js +417 -0
  231. package/src/cli/simple-commands/neural.js +148 -0
  232. package/src/cli/simple-commands/pair-autofix-only.js +755 -0
  233. package/src/cli/simple-commands/pair-basic.js +751 -0
  234. package/src/cli/simple-commands/pair-old.js +623 -0
  235. package/src/cli/simple-commands/pair-working.js +849 -0
  236. package/src/cli/simple-commands/pair.js +849 -0
  237. package/src/cli/simple-commands/performance-hooks.js +149 -0
  238. package/src/cli/simple-commands/performance-metrics.js +601 -0
  239. package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
  240. package/src/cli/simple-commands/process-ui.js +274 -0
  241. package/src/cli/simple-commands/realtime-update-system.js +659 -0
  242. package/src/cli/simple-commands/sparc/architecture.js +1750 -0
  243. package/src/cli/simple-commands/sparc/commands.js +575 -0
  244. package/src/cli/simple-commands/sparc/completion.js +1831 -0
  245. package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
  246. package/src/cli/simple-commands/sparc/index.js +321 -0
  247. package/src/cli/simple-commands/sparc/phase-base.js +430 -0
  248. package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
  249. package/src/cli/simple-commands/sparc/refinement.js +1856 -0
  250. package/src/cli/simple-commands/sparc/specification.js +736 -0
  251. package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
  252. package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
  253. package/src/cli/simple-commands/sparc-modes/code.js +148 -0
  254. package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
  255. package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
  256. package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
  257. package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
  258. package/src/cli/simple-commands/sparc-modes/index.js +201 -0
  259. package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
  260. package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
  261. package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
  262. package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
  263. package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
  264. package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
  265. package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
  266. package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
  267. package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
  268. package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
  269. package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
  270. package/src/cli/simple-commands/sparc.js +530 -0
  271. package/src/cli/simple-commands/start-ui.js +147 -0
  272. package/src/cli/simple-commands/start-wrapper.js +285 -0
  273. package/src/cli/simple-commands/start.js +2 -0
  274. package/src/cli/simple-commands/status.js +303 -0
  275. package/src/cli/simple-commands/stream-chain-clean.js +221 -0
  276. package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
  277. package/src/cli/simple-commands/stream-chain-real.js +408 -0
  278. package/src/cli/simple-commands/stream-chain-working.js +323 -0
  279. package/src/cli/simple-commands/stream-chain.js +491 -0
  280. package/src/cli/simple-commands/stream-processor.js +340 -0
  281. package/src/cli/simple-commands/swarm-executor.js +253 -0
  282. package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
  283. package/src/cli/simple-commands/swarm-ui.js +741 -0
  284. package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
  285. package/src/cli/simple-commands/swarm.js +2277 -0
  286. package/src/cli/simple-commands/task.js +228 -0
  287. package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
  288. package/src/cli/simple-commands/timestamp-fix.js +104 -0
  289. package/src/cli/simple-commands/token-tracker.js +372 -0
  290. package/src/cli/simple-commands/tool-execution-framework.js +555 -0
  291. package/src/cli/simple-commands/train-and-stream.js +354 -0
  292. package/src/cli/simple-commands/training-pipeline.js +874 -0
  293. package/src/cli/simple-commands/training.js +288 -0
  294. package/src/cli/simple-commands/verification-hooks.js +336 -0
  295. package/src/cli/simple-commands/verification-integration.js +464 -0
  296. package/src/cli/simple-commands/verification-training-integration.js +646 -0
  297. package/src/cli/simple-commands/verification.js +551 -0
  298. package/src/cli/simple-commands/web-server.js +929 -0
  299. package/src/cli/simple-commands/webui-validator.js +136 -0
  300. package/src/language/README.md +503 -0
  301. package/src/language/claude-md-generator.js +618 -0
  302. package/src/language/cli.js +422 -0
  303. package/src/language/example.js +347 -0
  304. package/src/language/integration-system.js +619 -0
  305. package/src/language/language-detector.js +581 -0
@@ -0,0 +1,821 @@
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
+
6
+ // Simple color utilities
7
+ 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`,
18
+ };
19
+
20
+ 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' },
27
+ ];
28
+
29
+ // View modes
30
+ const VIEWS = {
31
+ PROCESSES: 'processes',
32
+ STATUS: 'status',
33
+ ORCHESTRATION: 'orchestration',
34
+ MEMORY: 'memory',
35
+ LOGS: 'logs',
36
+ HELP: 'help',
37
+ };
38
+
39
+ 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) {
126
+ this.render();
127
+ }
128
+ }
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;
158
+ }
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++;
213
+ }
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();
296
+ }
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`));
343
+ }
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`));
416
+ }
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`;
476
+ }
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('?');
494
+ }
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);
591
+ }
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;
611
+ }
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;
644
+ }
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
+ }
679
+ }
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
+ );
690
+ }
691
+ break;
692
+ }
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;
708
+ }
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;
721
+ }
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
+ }
750
+ }
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);
759
+ }
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
+ }
797
+ }
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
+ }
807
+ }
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
+ }
817
+
818
+ export async function launchEnhancedUI() {
819
+ const ui = new EnhancedProcessUI();
820
+ await ui.start();
821
+ }