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,1038 @@
1
+ /**
2
+ * Enhanced Web UI Complete - Full Integration
3
+ * Combines all MCP tools with enhanced UI views and real-time updates
4
+ * Provides access to all 87 Claude-Flow MCP tools through a comprehensive interface
5
+ */
6
+
7
+ import { printSuccess, printError, printWarning, printInfo } from '../utils.js';
8
+ import { compat } from '../runtime-detector.js';
9
+ import SwarmWebUIIntegration from './swarm-webui-integration.js';
10
+ import MCPIntegrationLayer from './mcp-integration-layer.js';
11
+ import ToolExecutionFramework from './tool-execution-framework.js';
12
+ import { EnhancedUIViews, ENHANCED_VIEWS } from './enhanced-ui-views.js';
13
+ import RealtimeUpdateSystem from './realtime-update-system.js';
14
+
15
+ // Enhanced view modes with all tool categories
16
+ const ALL_VIEWS = {
17
+ ...ENHANCED_VIEWS,
18
+ // Add any additional views if needed
19
+ };
20
+
21
+ export class EnhancedWebUIComplete {
22
+ constructor() {
23
+ this.processes = new Map();
24
+ this.running = true;
25
+ this.selectedIndex = 0;
26
+ this.currentView = ALL_VIEWS.PROCESSES;
27
+ this.agents = [];
28
+ this.tasks = [];
29
+ this.memoryStats = {
30
+ totalEntries: 0,
31
+ totalSize: 0,
32
+ namespaces: [],
33
+ };
34
+ this.logs = [];
35
+ this.systemStats = {
36
+ uptime: 0,
37
+ totalTasks: 0,
38
+ completedTasks: 0,
39
+ activeAgents: 0,
40
+ memoryUsage: 0,
41
+ cpuUsage: 0,
42
+ };
43
+
44
+ // Enhanced components
45
+ this.mcpIntegration = null;
46
+ this.toolFramework = null;
47
+ this.enhancedViews = null;
48
+ this.realtimeUpdates = null;
49
+
50
+ // Input handling
51
+ this.inputBuffer = '';
52
+ this.commandHistory = [];
53
+ this.historyIndex = -1;
54
+
55
+ // Colors for consistent styling
56
+ this.colors = {
57
+ cyan: (text) => `\x1b[36m${text}\x1b[0m`,
58
+ gray: (text) => `\x1b[90m${text}\x1b[0m`,
59
+ white: (text) => `\x1b[37m${text}\x1b[0m`,
60
+ yellow: (text) => `\x1b[33m${text}\x1b[0m`,
61
+ green: (text) => `\x1b[32m${text}\x1b[0m`,
62
+ red: (text) => `\x1b[31m${text}\x1b[0m`,
63
+ blue: (text) => `\x1b[34m${text}\x1b[0m`,
64
+ magenta: (text) => `\x1b[35m${text}\x1b[0m`,
65
+ bold: (text) => `\x1b[1m${text}\x1b[0m`,
66
+ dim: (text) => `\x1b[2m${text}\x1b[0m`,
67
+ };
68
+
69
+ this.initializeEnhancedUI();
70
+ }
71
+
72
+ /**
73
+ * Initialize all enhanced UI components
74
+ */
75
+ async initializeEnhancedUI() {
76
+ try {
77
+ // Initialize original swarm integration
78
+ this.swarmIntegration = new SwarmWebUIIntegration(this);
79
+
80
+ // Initialize MCP integration layer
81
+ this.mcpIntegration = new MCPIntegrationLayer(this);
82
+
83
+ // Initialize tool execution framework
84
+ this.toolFramework = new ToolExecutionFramework(this);
85
+
86
+ // Initialize enhanced UI views
87
+ this.enhancedViews = new EnhancedUIViews(this);
88
+
89
+ // Initialize real-time update system
90
+ this.realtimeUpdates = new RealtimeUpdateSystem(this);
91
+
92
+ // Initialize default processes
93
+ this.initializeProcesses();
94
+
95
+ // Initialize mock data
96
+ await this.initializeSystemData();
97
+
98
+ // Start system monitoring
99
+ this.startSystemMonitoring();
100
+
101
+ this.addLog('success', '🚀 Enhanced Web UI fully initialized with all 87 MCP tools');
102
+ } catch (error) {
103
+ this.addLog('error', `Failed to initialize enhanced UI: ${error.message}`);
104
+ throw error;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Initialize system processes
110
+ */
111
+ initializeProcesses() {
112
+ const PROCESSES = [
113
+ { id: 'event-bus', name: 'Event Bus', description: 'Central event distribution system' },
114
+ { id: 'orchestrator', name: 'Orchestrator', description: 'Main coordination engine' },
115
+ { id: 'memory-manager', name: 'Memory Manager', description: 'Persistent memory system' },
116
+ { id: 'terminal-pool', name: 'Terminal Pool', description: 'Terminal session management' },
117
+ { id: 'mcp-server', name: 'MCP Server', description: 'Model Context Protocol server' },
118
+ { id: 'coordinator', name: 'Coordinator', description: 'Task coordination service' },
119
+ { id: 'neural-engine', name: 'Neural Engine', description: 'Neural network processing' },
120
+ { id: 'analysis-service', name: 'Analysis Service', description: 'Performance analysis' },
121
+ { id: 'workflow-engine', name: 'Workflow Engine', description: 'Automation workflows' },
122
+ { id: 'github-connector', name: 'GitHub Connector', description: 'GitHub integration' },
123
+ { id: 'daa-controller', name: 'DAA Controller', description: 'Dynamic agent architecture' },
124
+ ];
125
+
126
+ PROCESSES.forEach((p) => {
127
+ this.processes.set(p.id, {
128
+ ...p,
129
+ status: 'running', // Start most services as running
130
+ pid: Math.floor(Math.random() * 50000) + 1000,
131
+ uptime: Math.floor(Math.random() * 86400), // Random uptime up to 24h
132
+ cpu: Math.random() * 5,
133
+ memory: Math.random() * 100,
134
+ });
135
+ });
136
+ }
137
+
138
+ /**
139
+ * Initialize system data
140
+ */
141
+ async initializeSystemData() {
142
+ // Initialize swarm
143
+ await this.swarmIntegration.initializeSwarm('hierarchical', 8);
144
+
145
+ // Initialize memory stats
146
+ this.memoryStats = {
147
+ totalEntries: 156,
148
+ totalSize: '2.3 MB',
149
+ namespaces: [
150
+ { name: 'neural', entries: 42, size: '856 KB' },
151
+ { name: 'swarm', entries: 35, size: '645 KB' },
152
+ { name: 'analysis', entries: 28, size: '423 KB' },
153
+ { name: 'workflow', entries: 24, size: '298 KB' },
154
+ { name: 'github', entries: 15, size: '156 KB' },
155
+ { name: 'system', entries: 12, size: '89 KB' },
156
+ ],
157
+ };
158
+
159
+ // Initialize logs
160
+ this.logs = [
161
+ {
162
+ time: new Date(),
163
+ level: 'success',
164
+ message: '🧠 Neural engine initialized with 27 models',
165
+ },
166
+ {
167
+ time: new Date(),
168
+ level: 'success',
169
+ message: '🐝 Swarm orchestration active with hierarchical topology',
170
+ },
171
+ {
172
+ time: new Date(),
173
+ level: 'info',
174
+ message: '📊 Analysis service monitoring 13 performance metrics',
175
+ },
176
+ {
177
+ time: new Date(),
178
+ level: 'success',
179
+ message: '🔄 Workflow engine loaded 11 automation tools',
180
+ },
181
+ {
182
+ time: new Date(),
183
+ level: 'info',
184
+ message: '🐙 GitHub connector established with 8 integration tools',
185
+ },
186
+ {
187
+ time: new Date(),
188
+ level: 'success',
189
+ message: '🤖 DAA controller managing 8 dynamic agent tools',
190
+ },
191
+ {
192
+ time: new Date(),
193
+ level: 'success',
194
+ message: '💾 Memory system active with 12 persistence tools',
195
+ },
196
+ {
197
+ time: new Date(),
198
+ level: 'success',
199
+ message: '🛠️ System utilities loaded 8 management tools',
200
+ },
201
+ ];
202
+
203
+ // Start uptime counter
204
+ setInterval(() => {
205
+ this.systemStats.uptime++;
206
+ // Update process uptimes
207
+ this.processes.forEach((process) => {
208
+ if (process.status === 'running') {
209
+ process.uptime++;
210
+ }
211
+ });
212
+ }, 1000);
213
+ }
214
+
215
+ /**
216
+ * Start system monitoring
217
+ */
218
+ startSystemMonitoring() {
219
+ setInterval(() => {
220
+ // Update system stats
221
+ this.systemStats.cpuUsage = Math.max(
222
+ 0,
223
+ this.systemStats.cpuUsage + (Math.random() - 0.5) * 2,
224
+ );
225
+ this.systemStats.memoryUsage = Math.max(
226
+ 0,
227
+ this.systemStats.memoryUsage + (Math.random() - 0.5) * 3,
228
+ );
229
+
230
+ // Update process stats
231
+ this.processes.forEach((process) => {
232
+ if (process.status === 'running') {
233
+ process.cpu = Math.max(0, process.cpu + (Math.random() - 0.5) * 1);
234
+ process.memory = Math.max(0, process.memory + (Math.random() - 0.5) * 5);
235
+ }
236
+ });
237
+
238
+ // Emit performance metrics for real-time updates
239
+ if (this.realtimeUpdates) {
240
+ this.realtimeUpdates.emit('system_stats_update', {
241
+ cpuUsage: this.systemStats.cpuUsage,
242
+ memoryUsage: this.systemStats.memoryUsage,
243
+ processCount: this.processes.size,
244
+ });
245
+ }
246
+ }, 5000);
247
+ }
248
+
249
+ /**
250
+ * Start the enhanced UI
251
+ */
252
+ async start() {
253
+ // Clear screen
254
+ console.clear();
255
+
256
+ // Show enhanced welcome
257
+ printSuccess('🧠 Claude-Flow Enhanced Web UI v2.0.0');
258
+ printInfo('🔧 Comprehensive MCP Tool Integration - 87 Tools Available');
259
+ console.log('─'.repeat(80));
260
+ console.log();
261
+
262
+ // Show tool categories summary
263
+ this.showToolCategoriesSummary();
264
+
265
+ // Initial render
266
+ this.render();
267
+
268
+ // Setup input handling
269
+ this.setupInputHandling();
270
+
271
+ // Main UI loop
272
+ while (this.running) {
273
+ await this.handleInput();
274
+ if (this.running) {
275
+ this.render();
276
+ }
277
+ }
278
+ }
279
+
280
+ /**
281
+ * Show tool categories summary at startup
282
+ */
283
+ showToolCategoriesSummary() {
284
+ const categories = [
285
+ { name: 'Swarm Coordination', count: 12, icon: '🐝' },
286
+ { name: 'Neural Networks', count: 15, icon: '🧠' },
287
+ { name: 'Memory & Persistence', count: 12, icon: '💾' },
288
+ { name: 'Analysis & Monitoring', count: 13, icon: '📊' },
289
+ { name: 'Workflow & Automation', count: 11, icon: '🔄' },
290
+ { name: 'GitHub Integration', count: 8, icon: '🐙' },
291
+ { name: 'Dynamic Agents (DAA)', count: 8, icon: '🤖' },
292
+ { name: 'System & Utilities', count: 8, icon: '🛠️' },
293
+ ];
294
+
295
+ console.log(this.colors.cyan('📂 Available Tool Categories:'));
296
+ categories.forEach((cat) => {
297
+ console.log(
298
+ ` ${cat.icon} ${this.colors.white(cat.name)}: ${this.colors.yellow(cat.count)} tools`,
299
+ );
300
+ });
301
+ console.log();
302
+ console.log(this.colors.green(`Total: ${this.colors.bold('87')} MCP tools ready for use`));
303
+ console.log();
304
+ }
305
+
306
+ /**
307
+ * Setup input handling for enhanced features
308
+ */
309
+ setupInputHandling() {
310
+ // Enable raw input mode for better key handling
311
+ if (process.stdin.setRawMode) {
312
+ process.stdin.setRawMode(true);
313
+ }
314
+ process.stdin.resume();
315
+ }
316
+
317
+ /**
318
+ * Enhanced render method
319
+ */
320
+ render() {
321
+ // Clear screen and move cursor to top
322
+ console.log('\x1b[2J\x1b[H');
323
+
324
+ // Header with enhanced navigation
325
+ this.renderEnhancedHeader();
326
+
327
+ // Main content based on current view
328
+ switch (this.currentView) {
329
+ case ALL_VIEWS.PROCESSES:
330
+ this.renderProcessView();
331
+ break;
332
+ case ALL_VIEWS.STATUS:
333
+ this.renderStatusView();
334
+ break;
335
+ case ALL_VIEWS.ORCHESTRATION:
336
+ this.renderOrchestrationView();
337
+ break;
338
+ case ALL_VIEWS.MEMORY:
339
+ this.renderMemoryView();
340
+ break;
341
+ case ALL_VIEWS.LOGS:
342
+ this.renderLogsView();
343
+ break;
344
+ case ALL_VIEWS.NEURAL:
345
+ this.enhancedViews.renderNeuralView();
346
+ break;
347
+ case ALL_VIEWS.ANALYSIS:
348
+ this.enhancedViews.renderAnalysisView();
349
+ break;
350
+ case ALL_VIEWS.WORKFLOW:
351
+ this.enhancedViews.renderWorkflowView();
352
+ break;
353
+ case ALL_VIEWS.GITHUB:
354
+ this.enhancedViews.renderGitHubView();
355
+ break;
356
+ case ALL_VIEWS.DAA:
357
+ this.enhancedViews.renderDAAView();
358
+ break;
359
+ case ALL_VIEWS.SYSTEM:
360
+ this.enhancedViews.renderSystemView();
361
+ break;
362
+ case ALL_VIEWS.TOOLS:
363
+ this.enhancedViews.renderToolsView();
364
+ break;
365
+ case ALL_VIEWS.HELP:
366
+ this.renderEnhancedHelpView();
367
+ break;
368
+ }
369
+
370
+ // Enhanced footer with more controls
371
+ this.renderEnhancedFooter();
372
+ }
373
+
374
+ /**
375
+ * Render enhanced header with all navigation options
376
+ */
377
+ renderEnhancedHeader() {
378
+ console.log(this.colors.cyan(this.colors.bold('🧠 Claude-Flow Enhanced Web UI v2.0.0')));
379
+ console.log(this.colors.gray('─'.repeat(80)));
380
+
381
+ // Main navigation tabs (row 1)
382
+ const mainTabs = [
383
+ { key: '1', view: ALL_VIEWS.PROCESSES, label: 'Processes' },
384
+ { key: '2', view: ALL_VIEWS.STATUS, label: 'Status' },
385
+ { key: '3', view: ALL_VIEWS.ORCHESTRATION, label: 'Orchestration' },
386
+ { key: '4', view: ALL_VIEWS.MEMORY, label: 'Memory' },
387
+ { key: '5', view: ALL_VIEWS.LOGS, label: 'Logs' },
388
+ ];
389
+
390
+ let mainTabLine = '';
391
+ mainTabs.forEach((tab) => {
392
+ const isActive = this.currentView === tab.view;
393
+ const label = isActive
394
+ ? this.colors.yellow(`[${tab.label}]`)
395
+ : this.colors.gray(`${tab.label}`);
396
+ mainTabLine += ` ${this.colors.bold(tab.key)}:${label}`;
397
+ });
398
+
399
+ console.log(mainTabLine);
400
+
401
+ // Enhanced tool tabs (row 2)
402
+ const toolTabs = [
403
+ { key: '6', view: ALL_VIEWS.NEURAL, label: 'Neural', icon: '🧠' },
404
+ { key: '7', view: ALL_VIEWS.ANALYSIS, label: 'Analysis', icon: '📊' },
405
+ { key: '8', view: ALL_VIEWS.WORKFLOW, label: 'Workflow', icon: '🔄' },
406
+ { key: '9', view: ALL_VIEWS.GITHUB, label: 'GitHub', icon: '🐙' },
407
+ { key: '0', view: ALL_VIEWS.DAA, label: 'DAA', icon: '🤖' },
408
+ ];
409
+
410
+ let toolTabLine = '';
411
+ toolTabs.forEach((tab) => {
412
+ const isActive = this.currentView === tab.view;
413
+ const label = isActive
414
+ ? this.colors.yellow(`[${tab.icon}${tab.label}]`)
415
+ : this.colors.gray(`${tab.icon}${tab.label}`);
416
+ toolTabLine += ` ${this.colors.bold(tab.key)}:${label}`;
417
+ });
418
+
419
+ console.log(toolTabLine);
420
+
421
+ // Additional tabs (row 3)
422
+ const additionalTabs = [
423
+ { key: 't', view: ALL_VIEWS.TOOLS, label: 'Tools', icon: '🎛️' },
424
+ { key: 's', view: ALL_VIEWS.SYSTEM, label: 'System', icon: '🛠️' },
425
+ { key: 'h', view: ALL_VIEWS.HELP, label: 'Help', icon: '❓' },
426
+ ];
427
+
428
+ let additionalTabLine = '';
429
+ additionalTabs.forEach((tab) => {
430
+ const isActive = this.currentView === tab.view;
431
+ const label = isActive
432
+ ? this.colors.yellow(`[${tab.icon}${tab.label}]`)
433
+ : this.colors.gray(`${tab.icon}${tab.label}`);
434
+ additionalTabLine += ` ${this.colors.bold(tab.key)}:${label}`;
435
+ });
436
+
437
+ console.log(additionalTabLine);
438
+ console.log(this.colors.gray('─'.repeat(80)));
439
+ console.log();
440
+ }
441
+
442
+ /**
443
+ * Render enhanced help view
444
+ */
445
+ renderEnhancedHelpView() {
446
+ console.log(this.colors.white(this.colors.bold('❓ Enhanced Web UI Help')));
447
+ console.log();
448
+
449
+ console.log(this.colors.cyan('🗝️ Navigation Keys:'));
450
+ console.log(' 1-5: Main views (Processes, Status, Orchestration, Memory, Logs)');
451
+ console.log(' 6-0: Tool categories (Neural, Analysis, Workflow, GitHub, DAA)');
452
+ console.log(' t: Tool execution center');
453
+ console.log(' s: System utilities');
454
+ console.log(' h: This help screen');
455
+ console.log();
456
+
457
+ console.log(this.colors.cyan('🔧 Tool Categories:'));
458
+ console.log(' 🧠 Neural (15 tools): Training, prediction, model management');
459
+ console.log(' 📊 Analysis (13 tools): Performance reports, monitoring, metrics');
460
+ console.log(' 🔄 Workflow (11 tools): Automation, pipelines, scheduling');
461
+ console.log(' 🐙 GitHub (8 tools): Repository management, PR automation');
462
+ console.log(' 🤖 DAA (8 tools): Dynamic agent architecture');
463
+ console.log(' 🛠️ System (8 tools): Configuration, security, diagnostics');
464
+ console.log(' 🐝 Swarm (12 tools): Agent coordination, task orchestration');
465
+ console.log(' 💾 Memory (12 tools): Persistence, caching, namespaces');
466
+ console.log();
467
+
468
+ console.log(this.colors.cyan('⚡ Quick Actions:'));
469
+ console.log(' r: Run custom tool (from any view)');
470
+ console.log(' w: Execute workflow');
471
+ console.log(' b: Batch tool execution');
472
+ console.log(' c: Clear screen');
473
+ console.log(' q: Quit application');
474
+ console.log();
475
+
476
+ console.log(this.colors.cyan('💡 Features:'));
477
+ console.log(' • Real-time updates and monitoring');
478
+ console.log(' • Comprehensive MCP tool integration');
479
+ console.log(' • Batch and workflow execution');
480
+ console.log(' • Performance tracking and analysis');
481
+ console.log(' • Memory management and persistence');
482
+ console.log(' • GitHub integration and automation');
483
+ console.log(' • Dynamic agent architecture');
484
+ console.log(' • Neural network management');
485
+ }
486
+
487
+ /**
488
+ * Render enhanced footer
489
+ */
490
+ renderEnhancedFooter() {
491
+ console.log();
492
+ console.log(this.colors.gray('─'.repeat(80)));
493
+
494
+ // Status line
495
+ const mcpStatus = this.mcpIntegration ? this.mcpIntegration.getStatus() : null;
496
+ const toolStatus = this.toolFramework ? this.toolFramework.getStatus() : null;
497
+
498
+ let statusLine = `🧠 Claude-Flow Enhanced UI | `;
499
+ statusLine += `MCP: ${mcpStatus?.mcpAvailable ? this.colors.green('✓') : this.colors.red('✗')} | `;
500
+ statusLine += `Tools: ${this.colors.yellow(mcpStatus?.totalTools || 87)} | `;
501
+ statusLine += `Active: ${this.colors.blue(toolStatus?.currentExecutions || 0)} | `;
502
+ statusLine += `Queued: ${this.colors.cyan(toolStatus?.queuedExecutions || 0)} | `;
503
+ statusLine += `Uptime: ${this.colors.white(this.formatUptime(this.systemStats.uptime))}`;
504
+
505
+ console.log(statusLine);
506
+
507
+ // Controls line
508
+ let controlsLine = `${this.colors.gray('Controls:')} `;
509
+ controlsLine += `${this.colors.yellow('r')}=Run Tool | `;
510
+ controlsLine += `${this.colors.yellow('w')}=Workflow | `;
511
+ controlsLine += `${this.colors.yellow('b')}=Batch | `;
512
+ controlsLine += `${this.colors.yellow('c')}=Clear | `;
513
+ controlsLine += `${this.colors.yellow('q')}=Quit | `;
514
+ controlsLine += `${this.colors.yellow('↑↓')}=Navigate`;
515
+
516
+ console.log(controlsLine);
517
+ }
518
+
519
+ /**
520
+ * Enhanced input handling
521
+ */
522
+ async handleInput() {
523
+ return new Promise((resolve) => {
524
+ const onData = async (chunk) => {
525
+ const key = chunk.toString();
526
+
527
+ // Remove listener
528
+ process.stdin.removeListener('data', onData);
529
+
530
+ try {
531
+ // Handle navigation keys
532
+ if (await this.handleNavigationInput(key)) {
533
+ resolve();
534
+ return;
535
+ }
536
+
537
+ // Handle enhanced view input
538
+ if (await this.handleEnhancedViewInput(key)) {
539
+ resolve();
540
+ return;
541
+ }
542
+
543
+ // Handle global commands
544
+ if (await this.handleGlobalCommands(key)) {
545
+ resolve();
546
+ return;
547
+ }
548
+
549
+ // Handle original input
550
+ await this.handleOriginalInput(key);
551
+ } catch (error) {
552
+ this.addLog('error', `Input handling error: ${error.message}`);
553
+ }
554
+
555
+ resolve();
556
+ };
557
+
558
+ process.stdin.once('data', onData);
559
+ });
560
+ }
561
+
562
+ /**
563
+ * Handle navigation input
564
+ */
565
+ async handleNavigationInput(key) {
566
+ const navigationMap = {
567
+ 1: ALL_VIEWS.PROCESSES,
568
+ 2: ALL_VIEWS.STATUS,
569
+ 3: ALL_VIEWS.ORCHESTRATION,
570
+ 4: ALL_VIEWS.MEMORY,
571
+ 5: ALL_VIEWS.LOGS,
572
+ 6: ALL_VIEWS.NEURAL,
573
+ 7: ALL_VIEWS.ANALYSIS,
574
+ 8: ALL_VIEWS.WORKFLOW,
575
+ 9: ALL_VIEWS.GITHUB,
576
+ 0: ALL_VIEWS.DAA,
577
+ t: ALL_VIEWS.TOOLS,
578
+ s: ALL_VIEWS.SYSTEM,
579
+ h: ALL_VIEWS.HELP,
580
+ };
581
+
582
+ if (navigationMap[key]) {
583
+ this.currentView = navigationMap[key];
584
+ this.selectedIndex = 0;
585
+ this.addLog('info', `Switched to ${this.currentView} view`);
586
+ return true;
587
+ }
588
+
589
+ return false;
590
+ }
591
+
592
+ /**
593
+ * Handle enhanced view input
594
+ */
595
+ async handleEnhancedViewInput(key) {
596
+ if (this.enhancedViews) {
597
+ return await this.enhancedViews.handleEnhancedInput(key, this.currentView);
598
+ }
599
+ return false;
600
+ }
601
+
602
+ /**
603
+ * Handle global commands
604
+ */
605
+ async handleGlobalCommands(key) {
606
+ switch (key) {
607
+ case 'r':
608
+ await this.promptRunTool();
609
+ return true;
610
+ case 'w':
611
+ await this.promptRunWorkflow();
612
+ return true;
613
+ case 'b':
614
+ await this.promptBatchExecution();
615
+ return true;
616
+ case 'c':
617
+ console.clear();
618
+ return true;
619
+ case 'q':
620
+ case '\x03': // Ctrl+C
621
+ await this.shutdown();
622
+ return true;
623
+ }
624
+
625
+ return false;
626
+ }
627
+
628
+ /**
629
+ * Prompt for tool execution
630
+ */
631
+ async promptRunTool() {
632
+ // In a real implementation, this would show an interactive prompt
633
+ // For now, execute a sample tool
634
+ this.addLog('info', 'Tool execution prompt (demo)');
635
+
636
+ try {
637
+ const result = await this.toolFramework.executeTool('features_detect');
638
+ this.addLog('success', 'Tool executed successfully');
639
+ this.enhancedViews.displayToolResult(result);
640
+ } catch (error) {
641
+ this.addLog('error', `Tool execution failed: ${error.message}`);
642
+ }
643
+ }
644
+
645
+ /**
646
+ * Prompt for workflow execution
647
+ */
648
+ async promptRunWorkflow() {
649
+ this.addLog('info', 'Executing sample workflow...');
650
+
651
+ try {
652
+ const result = await this.toolFramework.executePredefinedWorkflow('performance_analysis');
653
+ this.addLog('success', 'Workflow completed successfully');
654
+ } catch (error) {
655
+ this.addLog('error', `Workflow failed: ${error.message}`);
656
+ }
657
+ }
658
+
659
+ /**
660
+ * Prompt for batch execution
661
+ */
662
+ async promptBatchExecution() {
663
+ this.addLog('info', 'Executing sample batch...');
664
+
665
+ const batchTools = [
666
+ { toolName: 'swarm_status' },
667
+ { toolName: 'neural_status' },
668
+ { toolName: 'memory_usage', parameters: { action: 'list' } },
669
+ ];
670
+
671
+ try {
672
+ const result = await this.toolFramework.executeToolsBatch(batchTools, { parallel: true });
673
+ this.addLog(
674
+ 'success',
675
+ `Batch completed: ${result.summary.successful}/${result.summary.total} successful`,
676
+ );
677
+ } catch (error) {
678
+ this.addLog('error', `Batch execution failed: ${error.message}`);
679
+ }
680
+ }
681
+
682
+ /**
683
+ * Handle original input for backward compatibility
684
+ */
685
+ async handleOriginalInput(key) {
686
+ // Handle original process view navigation
687
+ if (this.currentView === ALL_VIEWS.PROCESSES) {
688
+ switch (key) {
689
+ case '\x1b[A': // Up arrow
690
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
691
+ break;
692
+ case '\x1b[B': // Down arrow
693
+ this.selectedIndex = Math.min(this.processes.size - 1, this.selectedIndex + 1);
694
+ break;
695
+ case ' ':
696
+ case '\r':
697
+ await this.toggleSelectedProcess();
698
+ break;
699
+ }
700
+ }
701
+ }
702
+
703
+ /**
704
+ * Toggle selected process status
705
+ */
706
+ async toggleSelectedProcess() {
707
+ const processes = Array.from(this.processes.values());
708
+ const selected = processes[this.selectedIndex];
709
+
710
+ if (selected) {
711
+ if (selected.status === 'running') {
712
+ selected.status = 'stopped';
713
+ selected.pid = null;
714
+ this.addLog('warning', `Stopped ${selected.name}`);
715
+ } else {
716
+ selected.status = 'running';
717
+ selected.pid = Math.floor(Math.random() * 50000) + 1000;
718
+ this.addLog('success', `Started ${selected.name}`);
719
+ }
720
+ }
721
+ }
722
+
723
+ /**
724
+ * Add log entry with enhanced formatting
725
+ */
726
+ addLog(level, message) {
727
+ const logEntry = {
728
+ time: new Date(),
729
+ level,
730
+ message,
731
+ };
732
+
733
+ this.logs.unshift(logEntry);
734
+
735
+ // Keep only last 100 logs
736
+ if (this.logs.length > 100) {
737
+ this.logs = this.logs.slice(0, 100);
738
+ }
739
+
740
+ // Emit log event for real-time updates
741
+ if (this.realtimeUpdates) {
742
+ this.realtimeUpdates.emit('log_added', logEntry);
743
+ }
744
+ }
745
+
746
+ /**
747
+ * Render process view (original)
748
+ */
749
+ renderProcessView() {
750
+ console.log(this.colors.white(this.colors.bold('Process Management')));
751
+ console.log();
752
+
753
+ let index = 0;
754
+ for (const [id, process] of this.processes) {
755
+ const selected = index === this.selectedIndex;
756
+ const prefix = selected ? this.colors.yellow('▶ ') : ' ';
757
+ const status = this.getStatusIcon(process.status);
758
+ const name = selected ? this.colors.yellow(process.name) : this.colors.white(process.name);
759
+
760
+ console.log(`${prefix}${status} ${name}`);
761
+ console.log(` ${this.colors.gray(process.description)}`);
762
+
763
+ if (process.status === 'running') {
764
+ const stats = this.colors.dim(
765
+ `PID: ${process.pid} | Uptime: ${this.formatUptime(process.uptime)} | CPU: ${process.cpu.toFixed(1)}% | Mem: ${process.memory.toFixed(0)}MB`,
766
+ );
767
+ console.log(` ${stats}`);
768
+ }
769
+ console.log();
770
+
771
+ index++;
772
+ }
773
+
774
+ // Enhanced stats
775
+ const running = Array.from(this.processes.values()).filter(
776
+ (p) => p.status === 'running',
777
+ ).length;
778
+ console.log(this.colors.gray('─'.repeat(80)));
779
+ console.log(
780
+ this.colors.white(
781
+ `Total: ${this.processes.size} | Running: ${this.colors.green(running)} | Stopped: ${this.colors.gray(this.processes.size - running)}`,
782
+ ),
783
+ );
784
+ console.log(
785
+ this.colors.cyan(
786
+ `Enhanced: ${this.colors.yellow('87 MCP tools')} available across ${this.colors.yellow('8 categories')}`,
787
+ ),
788
+ );
789
+ }
790
+
791
+ /**
792
+ * Render status view with enhanced metrics
793
+ */
794
+ renderStatusView() {
795
+ console.log(this.colors.white(this.colors.bold('Enhanced System Status')));
796
+ console.log();
797
+
798
+ // System overview
799
+ console.log(this.colors.cyan('📊 System Overview'));
800
+ console.log(` Uptime: ${this.colors.green(this.formatUptime(this.systemStats.uptime))}`);
801
+ console.log(` Process Health: ${this.getHealthBar()}`);
802
+ console.log(` MCP Tools: ${this.colors.yellow('87')} available`);
803
+ console.log(` Tool Categories: ${this.colors.blue('8')} active`);
804
+ console.log();
805
+
806
+ // Enhanced resource usage
807
+ console.log(this.colors.cyan('💻 Resource Usage'));
808
+ console.log(
809
+ ` CPU Usage: ${this.getUsageBar(this.systemStats.cpuUsage, 100)} ${this.systemStats.cpuUsage.toFixed(1)}%`,
810
+ );
811
+ console.log(
812
+ ` Memory: ${this.getUsageBar(this.systemStats.memoryUsage, 100)} ${this.systemStats.memoryUsage.toFixed(1)}%`,
813
+ );
814
+ console.log();
815
+
816
+ // Enhanced activity metrics
817
+ console.log(this.colors.cyan('📈 Enhanced Activity Metrics'));
818
+ console.log(
819
+ ` Active Agents: ${this.colors.yellow(this.agents.filter((a) => a.status === 'working').length)}/${this.agents.length}`,
820
+ );
821
+ console.log(` Total Tasks: ${this.tasks.length}`);
822
+ console.log(` Tool Executions: ${this.colors.green('Running')}`);
823
+ console.log(` Real-time Updates: ${this.colors.green('Active')}`);
824
+ console.log();
825
+
826
+ // Tool status
827
+ const mcpStatus = this.mcpIntegration ? this.mcpIntegration.getStatus() : null;
828
+ if (mcpStatus) {
829
+ console.log(this.colors.cyan('🔧 Tool System Status'));
830
+ console.log(
831
+ ` MCP Connection: ${mcpStatus.mcpAvailable ? this.colors.green('Connected') : this.colors.red('Mock Mode')}`,
832
+ );
833
+ console.log(` Active Executions: ${this.colors.yellow(mcpStatus.activeExecutions || 0)}`);
834
+ console.log(` Cache Size: ${this.colors.blue(mcpStatus.cacheSize || 0)} entries`);
835
+ console.log();
836
+ }
837
+
838
+ // Recent events
839
+ console.log(this.colors.cyan('🔔 Recent Events'));
840
+ this.logs.slice(0, 5).forEach((log) => {
841
+ const time = log.time.toLocaleTimeString();
842
+ const icon =
843
+ log.level === 'success'
844
+ ? '✓'
845
+ : log.level === 'warning'
846
+ ? '⚠'
847
+ : log.level === 'error'
848
+ ? '❌'
849
+ : 'ℹ';
850
+ const color =
851
+ log.level === 'success'
852
+ ? this.colors.green
853
+ : log.level === 'warning'
854
+ ? this.colors.yellow
855
+ : log.level === 'error'
856
+ ? this.colors.red
857
+ : this.colors.blue;
858
+ console.log(` ${this.colors.gray(time)} ${color(icon)} ${log.message}`);
859
+ });
860
+ }
861
+
862
+ /**
863
+ * Render orchestration view (enhanced)
864
+ */
865
+ renderOrchestrationView() {
866
+ console.log(this.colors.white(this.colors.bold('Enhanced Swarm Orchestration')));
867
+ console.log();
868
+
869
+ // Enhanced swarm metrics
870
+ const metrics = this.swarmIntegration.getSwarmMetrics();
871
+ if (metrics) {
872
+ console.log(this.colors.cyan('🐝 Swarm Status'));
873
+ console.log(` Swarm ID: ${this.colors.yellow(metrics.swarmId)}`);
874
+ console.log(` Topology: ${this.colors.blue('hierarchical')} (optimized)`);
875
+ console.log(
876
+ ` Agents: ${this.colors.green(metrics.agents.active)}/${metrics.agents.total} active`,
877
+ );
878
+ console.log(
879
+ ` Tasks: ${this.colors.yellow(metrics.tasks.inProgress)} in progress, ${this.colors.green(metrics.tasks.completed)} completed`,
880
+ );
881
+ console.log(` Efficiency: ${this.colors.green(metrics.efficiency + '%')}`);
882
+ console.log(` Coordination Tools: ${this.colors.cyan('12')} available`);
883
+ console.log();
884
+ }
885
+
886
+ // Enhanced agents section
887
+ console.log(this.colors.cyan('🤖 Enhanced Agent Pool'));
888
+ console.log();
889
+ this.agents.forEach((agent, index) => {
890
+ const selected = this.currentView === ALL_VIEWS.ORCHESTRATION && index === this.selectedIndex;
891
+ const prefix = selected ? this.colors.yellow('▶ ') : ' ';
892
+ const statusIcon =
893
+ agent.status === 'working' ? this.colors.green('●') : this.colors.gray('○');
894
+ const name = selected ? this.colors.yellow(agent.name) : this.colors.white(agent.name);
895
+
896
+ console.log(`${prefix}${statusIcon} ${name} (${agent.type})`);
897
+ console.log(` ID: ${agent.id} | Tasks: ${agent.tasks} | Status: ${agent.status}`);
898
+ if (agent.capabilities && agent.capabilities.length > 0) {
899
+ console.log(` Capabilities: ${this.colors.dim(agent.capabilities.join(', '))}`);
900
+ }
901
+ console.log();
902
+ });
903
+
904
+ console.log(this.colors.gray('─'.repeat(40)));
905
+ console.log(
906
+ this.colors.cyan('⚡ Quick Actions: [1-9] Execute swarm tools | [r] Run custom tool'),
907
+ );
908
+ }
909
+
910
+ /**
911
+ * Render memory view (enhanced)
912
+ */
913
+ renderMemoryView() {
914
+ console.log(this.colors.white(this.colors.bold('Enhanced Memory Management')));
915
+ console.log();
916
+
917
+ // Enhanced memory overview
918
+ console.log(this.colors.cyan('💾 Memory Overview'));
919
+ console.log(` Total Entries: ${this.colors.yellow(this.memoryStats.totalEntries)}`);
920
+ console.log(` Total Size: ${this.colors.blue(this.memoryStats.totalSize)}`);
921
+ console.log(` Namespaces: ${this.colors.green(this.memoryStats.namespaces.length)}`);
922
+ console.log(` Persistence Tools: ${this.colors.cyan('12')} available`);
923
+ console.log();
924
+
925
+ // Enhanced namespace details
926
+ console.log(this.colors.cyan('📂 Namespace Details'));
927
+ this.memoryStats.namespaces.forEach((ns) => {
928
+ const usageBar = this.getUsageBar(ns.entries, 100);
929
+ console.log(
930
+ ` ${this.colors.white(ns.name.padEnd(12))} ${usageBar} ${this.colors.yellow(ns.entries)} entries (${this.colors.blue(ns.size)})`,
931
+ );
932
+ });
933
+
934
+ console.log();
935
+ console.log(this.colors.cyan('⚡ Memory Tools Available:'));
936
+ console.log(` ${this.colors.gray('• Store/Retrieve operations')}`);
937
+ console.log(` ${this.colors.gray('• Backup and restore')}`);
938
+ console.log(` ${this.colors.gray('• Cross-session persistence')}`);
939
+ console.log(` ${this.colors.gray('• Memory analytics and compression')}`);
940
+ }
941
+
942
+ /**
943
+ * Render logs view (enhanced)
944
+ */
945
+ renderLogsView() {
946
+ console.log(this.colors.white(this.colors.bold('Enhanced System Logs')));
947
+ console.log();
948
+
949
+ console.log(this.colors.cyan(`📋 Recent Activity (${this.logs.length} total entries)`));
950
+ console.log();
951
+
952
+ this.logs.slice(0, 15).forEach((log) => {
953
+ const time = log.time.toLocaleTimeString();
954
+ const icon =
955
+ log.level === 'success'
956
+ ? this.colors.green('✅')
957
+ : log.level === 'warning'
958
+ ? this.colors.yellow('⚠️')
959
+ : log.level === 'error'
960
+ ? this.colors.red('❌')
961
+ : this.colors.blue('ℹ️');
962
+
963
+ console.log(`${this.colors.gray(time)} ${icon} ${log.message}`);
964
+ });
965
+
966
+ console.log();
967
+ console.log(this.colors.gray('─'.repeat(80)));
968
+ console.log(
969
+ this.colors.cyan(
970
+ '🔍 Log Analysis Tools Available: Pattern detection, error analysis, usage statistics',
971
+ ),
972
+ );
973
+ }
974
+
975
+ /**
976
+ * Utility methods
977
+ */
978
+ getStatusIcon(status) {
979
+ return status === 'running' ? this.colors.green('●') : this.colors.gray('○');
980
+ }
981
+
982
+ formatUptime(seconds) {
983
+ const hours = Math.floor(seconds / 3600);
984
+ const minutes = Math.floor((seconds % 3600) / 60);
985
+ const secs = seconds % 60;
986
+ return `${hours}h ${minutes}m ${secs}s`;
987
+ }
988
+
989
+ getHealthBar() {
990
+ const running = Array.from(this.processes.values()).filter(
991
+ (p) => p.status === 'running',
992
+ ).length;
993
+ const total = this.processes.size;
994
+ const percentage = (running / total) * 100;
995
+ return this.getUsageBar(percentage, 100);
996
+ }
997
+
998
+ getUsageBar(value, max, width = 20) {
999
+ const percentage = Math.min((value / max) * 100, 100);
1000
+ const filled = Math.round((percentage / 100) * width);
1001
+ const empty = width - filled;
1002
+
1003
+ const color =
1004
+ percentage > 80 ? this.colors.red : percentage > 60 ? this.colors.yellow : this.colors.green;
1005
+ return color('█'.repeat(filled)) + this.colors.gray('░'.repeat(empty));
1006
+ }
1007
+
1008
+ /**
1009
+ * Shutdown the enhanced UI
1010
+ */
1011
+ async shutdown() {
1012
+ console.log();
1013
+ this.addLog('info', 'Shutting down Enhanced Web UI...');
1014
+
1015
+ // Cleanup enhanced components
1016
+ if (this.enhancedViews) {
1017
+ this.enhancedViews.cleanup();
1018
+ }
1019
+
1020
+ if (this.realtimeUpdates) {
1021
+ this.realtimeUpdates.cleanup();
1022
+ }
1023
+
1024
+ // Reset terminal
1025
+ if (process.stdin.setRawMode) {
1026
+ process.stdin.setRawMode(false);
1027
+ }
1028
+ process.stdin.pause();
1029
+
1030
+ this.running = false;
1031
+
1032
+ console.log();
1033
+ printSuccess('👋 Enhanced Web UI shutdown complete');
1034
+ process.exit(0);
1035
+ }
1036
+ }
1037
+
1038
+ export default EnhancedWebUIComplete;