@miller-tech/uap 1.0.0

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 (660) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +888 -0
  3. package/dist/analyzers/index.d.ts +3 -0
  4. package/dist/analyzers/index.d.ts.map +1 -0
  5. package/dist/analyzers/index.js +684 -0
  6. package/dist/analyzers/index.js.map +1 -0
  7. package/dist/benchmarks/agents/naive-agent.d.ts +60 -0
  8. package/dist/benchmarks/agents/naive-agent.d.ts.map +1 -0
  9. package/dist/benchmarks/agents/naive-agent.js +144 -0
  10. package/dist/benchmarks/agents/naive-agent.js.map +1 -0
  11. package/dist/benchmarks/agents/uap-agent.d.ts +167 -0
  12. package/dist/benchmarks/agents/uap-agent.d.ts.map +1 -0
  13. package/dist/benchmarks/agents/uap-agent.js +437 -0
  14. package/dist/benchmarks/agents/uap-agent.js.map +1 -0
  15. package/dist/benchmarks/benchmark.d.ts +328 -0
  16. package/dist/benchmarks/benchmark.d.ts.map +1 -0
  17. package/dist/benchmarks/benchmark.js +112 -0
  18. package/dist/benchmarks/benchmark.js.map +1 -0
  19. package/dist/benchmarks/execution-verifier.d.ts +41 -0
  20. package/dist/benchmarks/execution-verifier.d.ts.map +1 -0
  21. package/dist/benchmarks/execution-verifier.js +340 -0
  22. package/dist/benchmarks/execution-verifier.js.map +1 -0
  23. package/dist/benchmarks/hierarchical-prompting.d.ts +37 -0
  24. package/dist/benchmarks/hierarchical-prompting.d.ts.map +1 -0
  25. package/dist/benchmarks/hierarchical-prompting.js +246 -0
  26. package/dist/benchmarks/hierarchical-prompting.js.map +1 -0
  27. package/dist/benchmarks/improved-benchmark.d.ts +89 -0
  28. package/dist/benchmarks/improved-benchmark.d.ts.map +1 -0
  29. package/dist/benchmarks/improved-benchmark.js +585 -0
  30. package/dist/benchmarks/improved-benchmark.js.map +1 -0
  31. package/dist/benchmarks/index.d.ts +11 -0
  32. package/dist/benchmarks/index.d.ts.map +1 -0
  33. package/dist/benchmarks/index.js +11 -0
  34. package/dist/benchmarks/index.js.map +1 -0
  35. package/dist/benchmarks/model-integration.d.ts +111 -0
  36. package/dist/benchmarks/model-integration.d.ts.map +1 -0
  37. package/dist/benchmarks/model-integration.js +904 -0
  38. package/dist/benchmarks/model-integration.js.map +1 -0
  39. package/dist/benchmarks/multi-turn-agent.d.ts +44 -0
  40. package/dist/benchmarks/multi-turn-agent.d.ts.map +1 -0
  41. package/dist/benchmarks/multi-turn-agent.js +254 -0
  42. package/dist/benchmarks/multi-turn-agent.js.map +1 -0
  43. package/dist/benchmarks/multi-turn-loop.d.ts +57 -0
  44. package/dist/benchmarks/multi-turn-loop.d.ts.map +1 -0
  45. package/dist/benchmarks/multi-turn-loop.js +167 -0
  46. package/dist/benchmarks/multi-turn-loop.js.map +1 -0
  47. package/dist/benchmarks/tasks.d.ts +19 -0
  48. package/dist/benchmarks/tasks.d.ts.map +1 -0
  49. package/dist/benchmarks/tasks.js +435 -0
  50. package/dist/benchmarks/tasks.js.map +1 -0
  51. package/dist/bin/cli.d.ts +3 -0
  52. package/dist/bin/cli.d.ts.map +1 -0
  53. package/dist/bin/cli.js +546 -0
  54. package/dist/bin/cli.js.map +1 -0
  55. package/dist/bin/llama-server-optimize.d.ts +18 -0
  56. package/dist/bin/llama-server-optimize.d.ts.map +1 -0
  57. package/dist/bin/llama-server-optimize.js +708 -0
  58. package/dist/bin/llama-server-optimize.js.map +1 -0
  59. package/dist/bin/policy.d.ts +3 -0
  60. package/dist/bin/policy.d.ts.map +1 -0
  61. package/dist/bin/policy.js +143 -0
  62. package/dist/bin/policy.js.map +1 -0
  63. package/dist/bin/tool-calls.d.ts +3 -0
  64. package/dist/bin/tool-calls.d.ts.map +1 -0
  65. package/dist/bin/tool-calls.js +4 -0
  66. package/dist/bin/tool-calls.js.map +1 -0
  67. package/dist/browser/index.d.ts +2 -0
  68. package/dist/browser/index.d.ts.map +1 -0
  69. package/dist/browser/index.js +2 -0
  70. package/dist/browser/index.js.map +1 -0
  71. package/dist/browser/web-browser.d.ts +30 -0
  72. package/dist/browser/web-browser.d.ts.map +1 -0
  73. package/dist/browser/web-browser.js +93 -0
  74. package/dist/browser/web-browser.js.map +1 -0
  75. package/dist/cli/agent.d.ts +20 -0
  76. package/dist/cli/agent.d.ts.map +1 -0
  77. package/dist/cli/agent.js +474 -0
  78. package/dist/cli/agent.js.map +1 -0
  79. package/dist/cli/analyze.d.ts +7 -0
  80. package/dist/cli/analyze.d.ts.map +1 -0
  81. package/dist/cli/analyze.js +103 -0
  82. package/dist/cli/analyze.js.map +1 -0
  83. package/dist/cli/completion-gates.d.ts +51 -0
  84. package/dist/cli/completion-gates.d.ts.map +1 -0
  85. package/dist/cli/completion-gates.js +201 -0
  86. package/dist/cli/completion-gates.js.map +1 -0
  87. package/dist/cli/compliance.d.ts +8 -0
  88. package/dist/cli/compliance.d.ts.map +1 -0
  89. package/dist/cli/compliance.js +509 -0
  90. package/dist/cli/compliance.js.map +1 -0
  91. package/dist/cli/coord.d.ts +7 -0
  92. package/dist/cli/coord.d.ts.map +1 -0
  93. package/dist/cli/coord.js +138 -0
  94. package/dist/cli/coord.js.map +1 -0
  95. package/dist/cli/dashboard.d.ts +21 -0
  96. package/dist/cli/dashboard.d.ts.map +1 -0
  97. package/dist/cli/dashboard.js +1508 -0
  98. package/dist/cli/dashboard.js.map +1 -0
  99. package/dist/cli/deploy.d.ts +19 -0
  100. package/dist/cli/deploy.d.ts.map +1 -0
  101. package/dist/cli/deploy.js +387 -0
  102. package/dist/cli/deploy.js.map +1 -0
  103. package/dist/cli/droids.d.ts +9 -0
  104. package/dist/cli/droids.d.ts.map +1 -0
  105. package/dist/cli/droids.js +227 -0
  106. package/dist/cli/droids.js.map +1 -0
  107. package/dist/cli/generate.d.ts +17 -0
  108. package/dist/cli/generate.d.ts.map +1 -0
  109. package/dist/cli/generate.js +432 -0
  110. package/dist/cli/generate.js.map +1 -0
  111. package/dist/cli/hooks.d.ts +9 -0
  112. package/dist/cli/hooks.d.ts.map +1 -0
  113. package/dist/cli/hooks.js +464 -0
  114. package/dist/cli/hooks.js.map +1 -0
  115. package/dist/cli/init.d.ts +12 -0
  116. package/dist/cli/init.d.ts.map +1 -0
  117. package/dist/cli/init.js +364 -0
  118. package/dist/cli/init.js.map +1 -0
  119. package/dist/cli/mcp-router.d.ts +16 -0
  120. package/dist/cli/mcp-router.d.ts.map +1 -0
  121. package/dist/cli/mcp-router.js +143 -0
  122. package/dist/cli/mcp-router.js.map +1 -0
  123. package/dist/cli/memory.d.ts +24 -0
  124. package/dist/cli/memory.d.ts.map +1 -0
  125. package/dist/cli/memory.js +885 -0
  126. package/dist/cli/memory.js.map +1 -0
  127. package/dist/cli/model.d.ts +15 -0
  128. package/dist/cli/model.d.ts.map +1 -0
  129. package/dist/cli/model.js +290 -0
  130. package/dist/cli/model.js.map +1 -0
  131. package/dist/cli/patterns.d.ts +26 -0
  132. package/dist/cli/patterns.d.ts.map +1 -0
  133. package/dist/cli/patterns.js +862 -0
  134. package/dist/cli/patterns.js.map +1 -0
  135. package/dist/cli/rtk-validation.d.ts +9 -0
  136. package/dist/cli/rtk-validation.d.ts.map +1 -0
  137. package/dist/cli/rtk-validation.js +9 -0
  138. package/dist/cli/rtk-validation.js.map +1 -0
  139. package/dist/cli/rtk.d.ts +34 -0
  140. package/dist/cli/rtk.d.ts.map +1 -0
  141. package/dist/cli/rtk.js +401 -0
  142. package/dist/cli/rtk.js.map +1 -0
  143. package/dist/cli/schema-diff.d.ts +7 -0
  144. package/dist/cli/schema-diff.d.ts.map +1 -0
  145. package/dist/cli/schema-diff.js +11 -0
  146. package/dist/cli/schema-diff.js.map +1 -0
  147. package/dist/cli/setup-mcp-router.d.ts +8 -0
  148. package/dist/cli/setup-mcp-router.d.ts.map +1 -0
  149. package/dist/cli/setup-mcp-router.js +163 -0
  150. package/dist/cli/setup-mcp-router.js.map +1 -0
  151. package/dist/cli/setup-wizard.d.ts +2 -0
  152. package/dist/cli/setup-wizard.d.ts.map +1 -0
  153. package/dist/cli/setup-wizard.js +806 -0
  154. package/dist/cli/setup-wizard.js.map +1 -0
  155. package/dist/cli/setup.d.ts +15 -0
  156. package/dist/cli/setup.d.ts.map +1 -0
  157. package/dist/cli/setup.js +154 -0
  158. package/dist/cli/setup.js.map +1 -0
  159. package/dist/cli/sync.d.ts +8 -0
  160. package/dist/cli/sync.d.ts.map +1 -0
  161. package/dist/cli/sync.js +395 -0
  162. package/dist/cli/sync.js.map +1 -0
  163. package/dist/cli/task.d.ts +33 -0
  164. package/dist/cli/task.d.ts.map +1 -0
  165. package/dist/cli/task.js +672 -0
  166. package/dist/cli/task.js.map +1 -0
  167. package/dist/cli/tool-calls.d.ts +20 -0
  168. package/dist/cli/tool-calls.d.ts.map +1 -0
  169. package/dist/cli/tool-calls.js +605 -0
  170. package/dist/cli/tool-calls.js.map +1 -0
  171. package/dist/cli/uap.d.ts +10 -0
  172. package/dist/cli/uap.d.ts.map +1 -0
  173. package/dist/cli/uap.js +398 -0
  174. package/dist/cli/uap.js.map +1 -0
  175. package/dist/cli/update.d.ts +10 -0
  176. package/dist/cli/update.d.ts.map +1 -0
  177. package/dist/cli/update.js +300 -0
  178. package/dist/cli/update.js.map +1 -0
  179. package/dist/cli/visualize.d.ts +77 -0
  180. package/dist/cli/visualize.d.ts.map +1 -0
  181. package/dist/cli/visualize.js +287 -0
  182. package/dist/cli/visualize.js.map +1 -0
  183. package/dist/cli/worktree.d.ts +9 -0
  184. package/dist/cli/worktree.d.ts.map +1 -0
  185. package/dist/cli/worktree.js +213 -0
  186. package/dist/cli/worktree.js.map +1 -0
  187. package/dist/coordination/adaptive-patterns.d.ts +65 -0
  188. package/dist/coordination/adaptive-patterns.d.ts.map +1 -0
  189. package/dist/coordination/adaptive-patterns.js +108 -0
  190. package/dist/coordination/adaptive-patterns.js.map +1 -0
  191. package/dist/coordination/auto-agent.d.ts +82 -0
  192. package/dist/coordination/auto-agent.d.ts.map +1 -0
  193. package/dist/coordination/auto-agent.js +145 -0
  194. package/dist/coordination/auto-agent.js.map +1 -0
  195. package/dist/coordination/capability-router.d.ts +79 -0
  196. package/dist/coordination/capability-router.d.ts.map +1 -0
  197. package/dist/coordination/capability-router.js +334 -0
  198. package/dist/coordination/capability-router.js.map +1 -0
  199. package/dist/coordination/database.d.ts +13 -0
  200. package/dist/coordination/database.d.ts.map +1 -0
  201. package/dist/coordination/database.js +136 -0
  202. package/dist/coordination/database.js.map +1 -0
  203. package/dist/coordination/deploy-batcher.d.ts +122 -0
  204. package/dist/coordination/deploy-batcher.d.ts.map +1 -0
  205. package/dist/coordination/deploy-batcher.js +718 -0
  206. package/dist/coordination/deploy-batcher.js.map +1 -0
  207. package/dist/coordination/droid-validator.d.ts +59 -0
  208. package/dist/coordination/droid-validator.d.ts.map +1 -0
  209. package/dist/coordination/droid-validator.js +142 -0
  210. package/dist/coordination/droid-validator.js.map +1 -0
  211. package/dist/coordination/index.d.ts +10 -0
  212. package/dist/coordination/index.d.ts.map +1 -0
  213. package/dist/coordination/index.js +10 -0
  214. package/dist/coordination/index.js.map +1 -0
  215. package/dist/coordination/pattern-router.d.ts +50 -0
  216. package/dist/coordination/pattern-router.d.ts.map +1 -0
  217. package/dist/coordination/pattern-router.js +118 -0
  218. package/dist/coordination/pattern-router.js.map +1 -0
  219. package/dist/coordination/service.d.ts +81 -0
  220. package/dist/coordination/service.d.ts.map +1 -0
  221. package/dist/coordination/service.js +619 -0
  222. package/dist/coordination/service.js.map +1 -0
  223. package/dist/coordination/worktree-enforcer.d.ts +22 -0
  224. package/dist/coordination/worktree-enforcer.d.ts.map +1 -0
  225. package/dist/coordination/worktree-enforcer.js +71 -0
  226. package/dist/coordination/worktree-enforcer.js.map +1 -0
  227. package/dist/generators/claude-md.d.ts +3 -0
  228. package/dist/generators/claude-md.d.ts.map +1 -0
  229. package/dist/generators/claude-md.js +1020 -0
  230. package/dist/generators/claude-md.js.map +1 -0
  231. package/dist/generators/template-loader.d.ts +105 -0
  232. package/dist/generators/template-loader.d.ts.map +1 -0
  233. package/dist/generators/template-loader.js +291 -0
  234. package/dist/generators/template-loader.js.map +1 -0
  235. package/dist/index.d.ts +49 -0
  236. package/dist/index.d.ts.map +1 -0
  237. package/dist/index.js +63 -0
  238. package/dist/index.js.map +1 -0
  239. package/dist/mcp-router/config/parser.d.ts +9 -0
  240. package/dist/mcp-router/config/parser.d.ts.map +1 -0
  241. package/dist/mcp-router/config/parser.js +174 -0
  242. package/dist/mcp-router/config/parser.js.map +1 -0
  243. package/dist/mcp-router/executor/client.d.ts +31 -0
  244. package/dist/mcp-router/executor/client.d.ts.map +1 -0
  245. package/dist/mcp-router/executor/client.js +189 -0
  246. package/dist/mcp-router/executor/client.js.map +1 -0
  247. package/dist/mcp-router/index.d.ts +22 -0
  248. package/dist/mcp-router/index.d.ts.map +1 -0
  249. package/dist/mcp-router/index.js +18 -0
  250. package/dist/mcp-router/index.js.map +1 -0
  251. package/dist/mcp-router/output-compressor.d.ts +26 -0
  252. package/dist/mcp-router/output-compressor.d.ts.map +1 -0
  253. package/dist/mcp-router/output-compressor.js +236 -0
  254. package/dist/mcp-router/output-compressor.js.map +1 -0
  255. package/dist/mcp-router/search/fuzzy.d.ts +26 -0
  256. package/dist/mcp-router/search/fuzzy.d.ts.map +1 -0
  257. package/dist/mcp-router/search/fuzzy.js +94 -0
  258. package/dist/mcp-router/search/fuzzy.js.map +1 -0
  259. package/dist/mcp-router/server.d.ts +50 -0
  260. package/dist/mcp-router/server.d.ts.map +1 -0
  261. package/dist/mcp-router/server.js +229 -0
  262. package/dist/mcp-router/server.js.map +1 -0
  263. package/dist/mcp-router/session-stats.d.ts +37 -0
  264. package/dist/mcp-router/session-stats.d.ts.map +1 -0
  265. package/dist/mcp-router/session-stats.js +56 -0
  266. package/dist/mcp-router/session-stats.js.map +1 -0
  267. package/dist/mcp-router/tools/discover.d.ts +37 -0
  268. package/dist/mcp-router/tools/discover.d.ts.map +1 -0
  269. package/dist/mcp-router/tools/discover.js +65 -0
  270. package/dist/mcp-router/tools/discover.js.map +1 -0
  271. package/dist/mcp-router/tools/execute.d.ts +43 -0
  272. package/dist/mcp-router/tools/execute.d.ts.map +1 -0
  273. package/dist/mcp-router/tools/execute.js +144 -0
  274. package/dist/mcp-router/tools/execute.js.map +1 -0
  275. package/dist/mcp-router/types.d.ts +62 -0
  276. package/dist/mcp-router/types.d.ts.map +1 -0
  277. package/dist/mcp-router/types.js +6 -0
  278. package/dist/mcp-router/types.js.map +1 -0
  279. package/dist/memory/adaptive-context.d.ts +149 -0
  280. package/dist/memory/adaptive-context.d.ts.map +1 -0
  281. package/dist/memory/adaptive-context.js +1095 -0
  282. package/dist/memory/adaptive-context.js.map +1 -0
  283. package/dist/memory/agent-scoped-memory.d.ts +67 -0
  284. package/dist/memory/agent-scoped-memory.d.ts.map +1 -0
  285. package/dist/memory/agent-scoped-memory.js +126 -0
  286. package/dist/memory/agent-scoped-memory.js.map +1 -0
  287. package/dist/memory/ambiguity-detector.d.ts +54 -0
  288. package/dist/memory/ambiguity-detector.d.ts.map +1 -0
  289. package/dist/memory/ambiguity-detector.js +401 -0
  290. package/dist/memory/ambiguity-detector.js.map +1 -0
  291. package/dist/memory/backends/base.d.ts +18 -0
  292. package/dist/memory/backends/base.d.ts.map +1 -0
  293. package/dist/memory/backends/base.js +2 -0
  294. package/dist/memory/backends/base.js.map +1 -0
  295. package/dist/memory/backends/factory.d.ts +4 -0
  296. package/dist/memory/backends/factory.d.ts.map +1 -0
  297. package/dist/memory/backends/factory.js +53 -0
  298. package/dist/memory/backends/factory.js.map +1 -0
  299. package/dist/memory/backends/github.d.ts +27 -0
  300. package/dist/memory/backends/github.d.ts.map +1 -0
  301. package/dist/memory/backends/github.js +134 -0
  302. package/dist/memory/backends/github.js.map +1 -0
  303. package/dist/memory/backends/qdrant-cloud.d.ts +32 -0
  304. package/dist/memory/backends/qdrant-cloud.d.ts.map +1 -0
  305. package/dist/memory/backends/qdrant-cloud.js +167 -0
  306. package/dist/memory/backends/qdrant-cloud.js.map +1 -0
  307. package/dist/memory/context-compressor.d.ts +116 -0
  308. package/dist/memory/context-compressor.d.ts.map +1 -0
  309. package/dist/memory/context-compressor.js +430 -0
  310. package/dist/memory/context-compressor.js.map +1 -0
  311. package/dist/memory/context-pruner.d.ts +55 -0
  312. package/dist/memory/context-pruner.d.ts.map +1 -0
  313. package/dist/memory/context-pruner.js +85 -0
  314. package/dist/memory/context-pruner.js.map +1 -0
  315. package/dist/memory/correction-propagator.d.ts +44 -0
  316. package/dist/memory/correction-propagator.d.ts.map +1 -0
  317. package/dist/memory/correction-propagator.js +156 -0
  318. package/dist/memory/correction-propagator.js.map +1 -0
  319. package/dist/memory/daily-log.d.ts +67 -0
  320. package/dist/memory/daily-log.d.ts.map +1 -0
  321. package/dist/memory/daily-log.js +143 -0
  322. package/dist/memory/daily-log.js.map +1 -0
  323. package/dist/memory/dynamic-retrieval.d.ts +112 -0
  324. package/dist/memory/dynamic-retrieval.d.ts.map +1 -0
  325. package/dist/memory/dynamic-retrieval.js +908 -0
  326. package/dist/memory/dynamic-retrieval.js.map +1 -0
  327. package/dist/memory/embeddings.d.ts +172 -0
  328. package/dist/memory/embeddings.d.ts.map +1 -0
  329. package/dist/memory/embeddings.js +780 -0
  330. package/dist/memory/embeddings.js.map +1 -0
  331. package/dist/memory/generic-uap-patterns.d.ts +7 -0
  332. package/dist/memory/generic-uap-patterns.d.ts.map +1 -0
  333. package/dist/memory/generic-uap-patterns.js +43 -0
  334. package/dist/memory/generic-uap-patterns.js.map +1 -0
  335. package/dist/memory/hierarchical-memory.d.ts +141 -0
  336. package/dist/memory/hierarchical-memory.d.ts.map +1 -0
  337. package/dist/memory/hierarchical-memory.js +485 -0
  338. package/dist/memory/hierarchical-memory.js.map +1 -0
  339. package/dist/memory/knowledge-graph.d.ts +98 -0
  340. package/dist/memory/knowledge-graph.d.ts.map +1 -0
  341. package/dist/memory/knowledge-graph.js +275 -0
  342. package/dist/memory/knowledge-graph.js.map +1 -0
  343. package/dist/memory/memory-consolidator.d.ts +124 -0
  344. package/dist/memory/memory-consolidator.d.ts.map +1 -0
  345. package/dist/memory/memory-consolidator.js +514 -0
  346. package/dist/memory/memory-consolidator.js.map +1 -0
  347. package/dist/memory/memory-maintenance.d.ts +39 -0
  348. package/dist/memory/memory-maintenance.d.ts.map +1 -0
  349. package/dist/memory/memory-maintenance.js +336 -0
  350. package/dist/memory/memory-maintenance.js.map +1 -0
  351. package/dist/memory/model-router.d.ts +105 -0
  352. package/dist/memory/model-router.d.ts.map +1 -0
  353. package/dist/memory/model-router.js +474 -0
  354. package/dist/memory/model-router.js.map +1 -0
  355. package/dist/memory/multi-view-memory.d.ts +134 -0
  356. package/dist/memory/multi-view-memory.d.ts.map +1 -0
  357. package/dist/memory/multi-view-memory.js +430 -0
  358. package/dist/memory/multi-view-memory.js.map +1 -0
  359. package/dist/memory/predictive-memory.d.ts +79 -0
  360. package/dist/memory/predictive-memory.d.ts.map +1 -0
  361. package/dist/memory/predictive-memory.js +294 -0
  362. package/dist/memory/predictive-memory.js.map +1 -0
  363. package/dist/memory/prepopulate.d.ts +76 -0
  364. package/dist/memory/prepopulate.d.ts.map +1 -0
  365. package/dist/memory/prepopulate.js +832 -0
  366. package/dist/memory/prepopulate.js.map +1 -0
  367. package/dist/memory/semantic-compression.d.ts +77 -0
  368. package/dist/memory/semantic-compression.d.ts.map +1 -0
  369. package/dist/memory/semantic-compression.js +359 -0
  370. package/dist/memory/semantic-compression.js.map +1 -0
  371. package/dist/memory/serverless-qdrant.d.ts +102 -0
  372. package/dist/memory/serverless-qdrant.d.ts.map +1 -0
  373. package/dist/memory/serverless-qdrant.js +369 -0
  374. package/dist/memory/serverless-qdrant.js.map +1 -0
  375. package/dist/memory/short-term/factory.d.ts +26 -0
  376. package/dist/memory/short-term/factory.d.ts.map +1 -0
  377. package/dist/memory/short-term/factory.js +28 -0
  378. package/dist/memory/short-term/factory.js.map +1 -0
  379. package/dist/memory/short-term/indexeddb.d.ts +25 -0
  380. package/dist/memory/short-term/indexeddb.d.ts.map +1 -0
  381. package/dist/memory/short-term/indexeddb.js +64 -0
  382. package/dist/memory/short-term/indexeddb.js.map +1 -0
  383. package/dist/memory/short-term/schema.d.ts +6 -0
  384. package/dist/memory/short-term/schema.d.ts.map +1 -0
  385. package/dist/memory/short-term/schema.js +141 -0
  386. package/dist/memory/short-term/schema.js.map +1 -0
  387. package/dist/memory/short-term/sqlite.d.ts +64 -0
  388. package/dist/memory/short-term/sqlite.d.ts.map +1 -0
  389. package/dist/memory/short-term/sqlite.js +274 -0
  390. package/dist/memory/short-term/sqlite.js.map +1 -0
  391. package/dist/memory/speculative-cache.d.ts +111 -0
  392. package/dist/memory/speculative-cache.d.ts.map +1 -0
  393. package/dist/memory/speculative-cache.js +457 -0
  394. package/dist/memory/speculative-cache.js.map +1 -0
  395. package/dist/memory/task-classifier.d.ts +40 -0
  396. package/dist/memory/task-classifier.d.ts.map +1 -0
  397. package/dist/memory/task-classifier.js +342 -0
  398. package/dist/memory/task-classifier.js.map +1 -0
  399. package/dist/memory/terminal-bench-knowledge.d.ts +48 -0
  400. package/dist/memory/terminal-bench-knowledge.d.ts.map +1 -0
  401. package/dist/memory/terminal-bench-knowledge.js +622 -0
  402. package/dist/memory/terminal-bench-knowledge.js.map +1 -0
  403. package/dist/memory/write-gate.d.ts +39 -0
  404. package/dist/memory/write-gate.d.ts.map +1 -0
  405. package/dist/memory/write-gate.js +190 -0
  406. package/dist/memory/write-gate.js.map +1 -0
  407. package/dist/models/api-client.d.ts +46 -0
  408. package/dist/models/api-client.d.ts.map +1 -0
  409. package/dist/models/api-client.js +182 -0
  410. package/dist/models/api-client.js.map +1 -0
  411. package/dist/models/execution-profiles.d.ts +64 -0
  412. package/dist/models/execution-profiles.d.ts.map +1 -0
  413. package/dist/models/execution-profiles.js +403 -0
  414. package/dist/models/execution-profiles.js.map +1 -0
  415. package/dist/models/executor.d.ts +130 -0
  416. package/dist/models/executor.d.ts.map +1 -0
  417. package/dist/models/executor.js +382 -0
  418. package/dist/models/executor.js.map +1 -0
  419. package/dist/models/index.d.ts +19 -0
  420. package/dist/models/index.d.ts.map +1 -0
  421. package/dist/models/index.js +23 -0
  422. package/dist/models/index.js.map +1 -0
  423. package/dist/models/plan-validator.d.ts +37 -0
  424. package/dist/models/plan-validator.d.ts.map +1 -0
  425. package/dist/models/plan-validator.js +179 -0
  426. package/dist/models/plan-validator.js.map +1 -0
  427. package/dist/models/planner.d.ts +73 -0
  428. package/dist/models/planner.d.ts.map +1 -0
  429. package/dist/models/planner.js +375 -0
  430. package/dist/models/planner.js.map +1 -0
  431. package/dist/models/router.d.ts +96 -0
  432. package/dist/models/router.d.ts.map +1 -0
  433. package/dist/models/router.js +523 -0
  434. package/dist/models/router.js.map +1 -0
  435. package/dist/models/types.d.ts +370 -0
  436. package/dist/models/types.d.ts.map +1 -0
  437. package/dist/models/types.js +232 -0
  438. package/dist/models/types.js.map +1 -0
  439. package/dist/models/unified-router.d.ts +152 -0
  440. package/dist/models/unified-router.d.ts.map +1 -0
  441. package/dist/models/unified-router.js +313 -0
  442. package/dist/models/unified-router.js.map +1 -0
  443. package/dist/policies/convert-policy-to-claude.d.ts +3 -0
  444. package/dist/policies/convert-policy-to-claude.d.ts.map +1 -0
  445. package/dist/policies/convert-policy-to-claude.js +87 -0
  446. package/dist/policies/convert-policy-to-claude.js.map +1 -0
  447. package/dist/policies/database-manager.d.ts +27 -0
  448. package/dist/policies/database-manager.d.ts.map +1 -0
  449. package/dist/policies/database-manager.js +198 -0
  450. package/dist/policies/database-manager.js.map +1 -0
  451. package/dist/policies/enforced-tool-router.d.ts +53 -0
  452. package/dist/policies/enforced-tool-router.d.ts.map +1 -0
  453. package/dist/policies/enforced-tool-router.js +80 -0
  454. package/dist/policies/enforced-tool-router.js.map +1 -0
  455. package/dist/policies/index.d.ts +10 -0
  456. package/dist/policies/index.d.ts.map +1 -0
  457. package/dist/policies/index.js +8 -0
  458. package/dist/policies/index.js.map +1 -0
  459. package/dist/policies/policy-gate.d.ts +59 -0
  460. package/dist/policies/policy-gate.d.ts.map +1 -0
  461. package/dist/policies/policy-gate.js +171 -0
  462. package/dist/policies/policy-gate.js.map +1 -0
  463. package/dist/policies/policy-memory.d.ts +18 -0
  464. package/dist/policies/policy-memory.d.ts.map +1 -0
  465. package/dist/policies/policy-memory.js +126 -0
  466. package/dist/policies/policy-memory.js.map +1 -0
  467. package/dist/policies/policy-tools.d.ts +11 -0
  468. package/dist/policies/policy-tools.d.ts.map +1 -0
  469. package/dist/policies/policy-tools.js +66 -0
  470. package/dist/policies/policy-tools.js.map +1 -0
  471. package/dist/policies/schemas/policy.d.ts +69 -0
  472. package/dist/policies/schemas/policy.d.ts.map +1 -0
  473. package/dist/policies/schemas/policy.js +31 -0
  474. package/dist/policies/schemas/policy.js.map +1 -0
  475. package/dist/tasks/coordination.d.ts +83 -0
  476. package/dist/tasks/coordination.d.ts.map +1 -0
  477. package/dist/tasks/coordination.js +291 -0
  478. package/dist/tasks/coordination.js.map +1 -0
  479. package/dist/tasks/database.d.ts +19 -0
  480. package/dist/tasks/database.d.ts.map +1 -0
  481. package/dist/tasks/database.js +149 -0
  482. package/dist/tasks/database.js.map +1 -0
  483. package/dist/tasks/decoder-gate.d.ts +64 -0
  484. package/dist/tasks/decoder-gate.d.ts.map +1 -0
  485. package/dist/tasks/decoder-gate.js +268 -0
  486. package/dist/tasks/decoder-gate.js.map +1 -0
  487. package/dist/tasks/index.d.ts +6 -0
  488. package/dist/tasks/index.d.ts.map +1 -0
  489. package/dist/tasks/index.js +6 -0
  490. package/dist/tasks/index.js.map +1 -0
  491. package/dist/tasks/service.d.ts +40 -0
  492. package/dist/tasks/service.d.ts.map +1 -0
  493. package/dist/tasks/service.js +671 -0
  494. package/dist/tasks/service.js.map +1 -0
  495. package/dist/tasks/types.d.ts +238 -0
  496. package/dist/tasks/types.d.ts.map +1 -0
  497. package/dist/tasks/types.js +74 -0
  498. package/dist/tasks/types.js.map +1 -0
  499. package/dist/telemetry/index.d.ts +2 -0
  500. package/dist/telemetry/index.d.ts.map +1 -0
  501. package/dist/telemetry/index.js +2 -0
  502. package/dist/telemetry/index.js.map +1 -0
  503. package/dist/telemetry/session-telemetry.d.ts +56 -0
  504. package/dist/telemetry/session-telemetry.d.ts.map +1 -0
  505. package/dist/telemetry/session-telemetry.js +807 -0
  506. package/dist/telemetry/session-telemetry.js.map +1 -0
  507. package/dist/types/analysis.d.ts +82 -0
  508. package/dist/types/analysis.d.ts.map +1 -0
  509. package/dist/types/analysis.js +2 -0
  510. package/dist/types/analysis.js.map +1 -0
  511. package/dist/types/config.d.ts +3324 -0
  512. package/dist/types/config.d.ts.map +1 -0
  513. package/dist/types/config.js +418 -0
  514. package/dist/types/config.js.map +1 -0
  515. package/dist/types/coordination.d.ts +240 -0
  516. package/dist/types/coordination.d.ts.map +1 -0
  517. package/dist/types/coordination.js +43 -0
  518. package/dist/types/coordination.js.map +1 -0
  519. package/dist/types/index.d.ts +4 -0
  520. package/dist/types/index.d.ts.map +1 -0
  521. package/dist/types/index.js +4 -0
  522. package/dist/types/index.js.map +1 -0
  523. package/dist/uap-droids-strict.d.ts +59 -0
  524. package/dist/uap-droids-strict.d.ts.map +1 -0
  525. package/dist/uap-droids-strict.js +200 -0
  526. package/dist/uap-droids-strict.js.map +1 -0
  527. package/dist/utils/config-manager.d.ts +30 -0
  528. package/dist/utils/config-manager.d.ts.map +1 -0
  529. package/dist/utils/config-manager.js +41 -0
  530. package/dist/utils/config-manager.js.map +1 -0
  531. package/dist/utils/fetch-with-retry.d.ts +5 -0
  532. package/dist/utils/fetch-with-retry.d.ts.map +1 -0
  533. package/dist/utils/fetch-with-retry.js +61 -0
  534. package/dist/utils/fetch-with-retry.js.map +1 -0
  535. package/dist/utils/merge-claude-md.d.ts +28 -0
  536. package/dist/utils/merge-claude-md.d.ts.map +1 -0
  537. package/dist/utils/merge-claude-md.js +342 -0
  538. package/dist/utils/merge-claude-md.js.map +1 -0
  539. package/dist/utils/rate-limiter.d.ts +58 -0
  540. package/dist/utils/rate-limiter.d.ts.map +1 -0
  541. package/dist/utils/rate-limiter.js +100 -0
  542. package/dist/utils/rate-limiter.js.map +1 -0
  543. package/dist/utils/string-similarity.d.ts +37 -0
  544. package/dist/utils/string-similarity.d.ts.map +1 -0
  545. package/dist/utils/string-similarity.js +114 -0
  546. package/dist/utils/string-similarity.js.map +1 -0
  547. package/dist/utils/validate-json.d.ts +51 -0
  548. package/dist/utils/validate-json.d.ts.map +1 -0
  549. package/dist/utils/validate-json.js +94 -0
  550. package/dist/utils/validate-json.js.map +1 -0
  551. package/docs/INDEX.md +66 -0
  552. package/docs/architecture/MULTI_MODEL.md +224 -0
  553. package/docs/architecture/SYSTEM_ANALYSIS.md +1117 -0
  554. package/docs/architecture/UAP_COMPLIANCE.md +217 -0
  555. package/docs/architecture/UAP_PROTOCOL.md +339 -0
  556. package/docs/architecture/UAP_STRICT_DROIDS.md +172 -0
  557. package/docs/archive/BALLS_MODE_SELF_ANALYSIS.md +260 -0
  558. package/docs/archive/FAILING_TASKS_SOLUTION_PLAN.md +668 -0
  559. package/docs/archive/JINJA2-SYSTEM-MESSAGE-FIX.md +209 -0
  560. package/docs/archive/NPM-PUBLISH-V0.9.1.md +240 -0
  561. package/docs/archive/OPTIMIZATION_OPTIONS.md +334 -0
  562. package/docs/archive/SETUP_IMPROVEMENTS.md +213 -0
  563. package/docs/archive/UAP_GENERIC_OPTIMIZATION_PLAN.md +270 -0
  564. package/docs/archive/UAP_V103_PATTERN_DESIGN.md +315 -0
  565. package/docs/archive/UAP_V104_COMPLIANCE_DESIGN.md +223 -0
  566. package/docs/archive/changelog/2026-03-10_uap-100-compliance.md +77 -0
  567. package/docs/archive/changelog/2026-03-10_uap-full-system-verification.md +109 -0
  568. package/docs/benchmarks/ACCURACY_ANALYSIS.md +471 -0
  569. package/docs/benchmarks/TOKEN_OPTIMIZATION.md +572 -0
  570. package/docs/benchmarks/VALIDATION_PLAN.md +568 -0
  571. package/docs/benchmarks/VALIDATION_RESULTS.md +161 -0
  572. package/docs/deployment/DEPLOYMENT.md +895 -0
  573. package/docs/deployment/DEPLOYMENT_STRATEGIES.md +518 -0
  574. package/docs/deployment/DEPLOY_BATCHER_ANALYSIS.md +856 -0
  575. package/docs/deployment/DEPLOY_BATCHING.md +273 -0
  576. package/docs/deployment/DEPLOY_BUCKETING_ANALYSIS.md +420 -0
  577. package/docs/deployment/QWEN35_LLAMA_CPP.md +265 -0
  578. package/docs/getting-started/INTEGRATION.md +449 -0
  579. package/docs/getting-started/OVERVIEW.md +344 -0
  580. package/docs/getting-started/SETUP.md +203 -0
  581. package/docs/integrations/MCP_ROUTER_SETUP.md +445 -0
  582. package/docs/integrations/RTK_INTEGRATION.md +468 -0
  583. package/docs/operations/TROUBLESHOOTING.md +660 -0
  584. package/docs/reference/API_REFERENCE.md +903 -0
  585. package/docs/reference/FEATURES.md +472 -0
  586. package/docs/reference/HARNESS-MATRIX.md +318 -0
  587. package/docs/reference/UAP_CLI_REFERENCE.md +600 -0
  588. package/docs/research/BEHAVIORAL_PATTERNS.md +228 -0
  589. package/docs/research/DOMAIN_STRATEGIES.md +316 -0
  590. package/docs/research/MEMORY_SYSTEMS_COMPARISON.md +812 -0
  591. package/docs/research/PATTERN_ANALYSIS_2026-01-18.md +436 -0
  592. package/docs/research/PERFORMANCE_ANALYSIS_2026-01-18.md +209 -0
  593. package/docs/research/PERFORMANCE_TEST_PLAN.md +383 -0
  594. package/docs/research/TERMINAL_BENCH_LEARNINGS.md +217 -0
  595. package/package.json +113 -0
  596. package/scripts/README.md +161 -0
  597. package/templates/CLAUDE.template.md +10 -0
  598. package/templates/CLAUDE_ARCHITECTURE.template.md +103 -0
  599. package/templates/CLAUDE_CODING.template.md +127 -0
  600. package/templates/CLAUDE_DROIDS.template.md +109 -0
  601. package/templates/CLAUDE_MEMORY.template.md +131 -0
  602. package/templates/CLAUDE_WORKFLOWS.template.md +139 -0
  603. package/templates/PROJECT.template.md +209 -0
  604. package/templates/SCHEMA.md +57 -0
  605. package/templates/archive/CLAUDE.template.root-v6.md +534 -0
  606. package/templates/archive/CLAUDE.template.v6.md +534 -0
  607. package/templates/hooks/forgecode/pre-compact.sh +68 -0
  608. package/templates/hooks/forgecode/session-start.sh +169 -0
  609. package/templates/hooks/forgecode.plugin.sh +128 -0
  610. package/templates/hooks/pre-compact.sh +74 -0
  611. package/templates/hooks/session-start.sh +366 -0
  612. package/tools/agents/README.md +224 -0
  613. package/tools/agents/UAP/README.md +386 -0
  614. package/tools/agents/UAP/__init__.py +9 -0
  615. package/tools/agents/UAP/cli.py +901 -0
  616. package/tools/agents/UAP/compliance_verify.sh +108 -0
  617. package/tools/agents/UAP/full_verification.sh +126 -0
  618. package/tools/agents/UAP/version.py +32 -0
  619. package/tools/agents/benchmarks/benchmark_memory_systems.py +730 -0
  620. package/tools/agents/benchmarks/results/benchmark_20260106_064817.json +170 -0
  621. package/tools/agents/benchmarks/results/benchmark_20260106_064817.md +51 -0
  622. package/tools/agents/config/chat_template.jinja +77 -0
  623. package/tools/agents/config/tool-call-schema.json +19 -0
  624. package/tools/agents/config/tool-call.gbnf +58 -0
  625. package/tools/agents/docker/Dockerfile.python +52 -0
  626. package/tools/agents/docker/Dockerfile.ubuntu +55 -0
  627. package/tools/agents/docker-compose.qdrant.yml +24 -0
  628. package/tools/agents/install-opencode-local.sh.j2 +135 -0
  629. package/tools/agents/migrations/apply.py +256 -0
  630. package/tools/agents/opencode_uap_agent.py +1505 -0
  631. package/tools/agents/plugin/README.md +91 -0
  632. package/tools/agents/plugin/index.ts +46 -0
  633. package/tools/agents/plugin/pre-compact.sh +68 -0
  634. package/tools/agents/plugin/session-start.sh +175 -0
  635. package/tools/agents/plugin/uap-commands.ts +45 -0
  636. package/tools/agents/plugin/uap-droids.ts +54 -0
  637. package/tools/agents/plugin/uap-patterns.ts +54 -0
  638. package/tools/agents/plugin/uap-skills.ts +52 -0
  639. package/tools/agents/plugins/uap-enforce.ts +314 -0
  640. package/tools/agents/scripts/__pycache__/tool_call_wrapper.cpython-313.pyc +0 -0
  641. package/tools/agents/scripts/chat_template_verifier.py +343 -0
  642. package/tools/agents/scripts/fix-qwen-template.js +38 -0
  643. package/tools/agents/scripts/fix_qwen_chat_template.py +316 -0
  644. package/tools/agents/scripts/generate_lora_training_data.py +412 -0
  645. package/tools/agents/scripts/init_qdrant.py +151 -0
  646. package/tools/agents/scripts/memory_migration.py +560 -0
  647. package/tools/agents/scripts/migrate_memory_to_qdrant.py +110 -0
  648. package/tools/agents/scripts/prepare_lora.sh +512 -0
  649. package/tools/agents/scripts/query_memory.py +200 -0
  650. package/tools/agents/scripts/qwen-tool-call-test.js +38 -0
  651. package/tools/agents/scripts/qwen-tool-call-wrapper.js +38 -0
  652. package/tools/agents/scripts/qwen_tool_call_test.py +464 -0
  653. package/tools/agents/scripts/qwen_tool_call_wrapper.py +686 -0
  654. package/tools/agents/scripts/start-services.sh +96 -0
  655. package/tools/agents/scripts/tool-choice-proxy.cjs +296 -0
  656. package/tools/agents/scripts/tool_call_test.py +656 -0
  657. package/tools/agents/scripts/tool_call_wrapper.py +799 -0
  658. package/tools/agents/tests/test_uap_compliance.py +257 -0
  659. package/tools/agents/uap_agent.py +122 -0
  660. package/tools/agents/uap_agent_install.sh +12 -0
@@ -0,0 +1,1508 @@
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import { existsSync, statSync, readFileSync, readdirSync } from 'fs';
4
+ import { join } from 'path';
5
+ import { execSync } from 'child_process';
6
+ import Database from 'better-sqlite3';
7
+ import { TaskService } from '../tasks/service.js';
8
+ import { CoordinationService } from '../coordination/service.js';
9
+ import { SQLiteShortTermMemory } from '../memory/short-term/sqlite.js';
10
+ import { progressBar, stackedBar, stackedBarLegend, horizontalBarChart, table, tree, box, sectionHeader, keyValue, miniGauge, statusBadge, divider, bulletList, columns, } from './visualize.js';
11
+ import { STATUS_ICONS, TYPE_ICONS, PRIORITY_LABELS } from '../tasks/types.js';
12
+ import { globalSessionStats } from '../mcp-router/session-stats.js';
13
+ export async function dashboardCommand(action, options = {}) {
14
+ switch (action) {
15
+ case 'overview':
16
+ await showOverview(options);
17
+ break;
18
+ case 'tasks':
19
+ await showTaskDashboard(options);
20
+ break;
21
+ case 'agents':
22
+ await showAgentDashboard(options);
23
+ break;
24
+ case 'memory':
25
+ await showMemoryDashboard(options);
26
+ break;
27
+ case 'progress':
28
+ await showProgressDashboard(options);
29
+ break;
30
+ case 'stats':
31
+ await showStatsDashboard(options);
32
+ break;
33
+ case 'session':
34
+ await showSessionDashboard(options);
35
+ break;
36
+ case 'benchmark':
37
+ showDashboard();
38
+ break;
39
+ }
40
+ }
41
+ async function showOverview(_options) {
42
+ const spinner = ora('Loading dashboard...').start();
43
+ try {
44
+ const taskService = new TaskService();
45
+ const coordService = new CoordinationService();
46
+ const stats = taskService.getStats();
47
+ const coordStatus = coordService.getStatus();
48
+ spinner.stop();
49
+ console.log('');
50
+ console.log(chalk.bold.cyan(' UAP Dashboard'));
51
+ console.log(divider(60));
52
+ console.log('');
53
+ // Task completion progress
54
+ const completedTasks = stats.byStatus.done + stats.byStatus.wont_do;
55
+ const activeTasks = stats.total - completedTasks;
56
+ console.log(sectionHeader('Task Progress'));
57
+ console.log('');
58
+ console.log(` ${progressBar(completedTasks, stats.total, 40, {
59
+ label: 'Completion',
60
+ filled: chalk.green,
61
+ })}`);
62
+ console.log('');
63
+ // Status breakdown bar
64
+ const statusSegments = [
65
+ { value: stats.byStatus.done, color: chalk.green, label: `Done ${STATUS_ICONS.done}` },
66
+ {
67
+ value: stats.byStatus.in_progress,
68
+ color: chalk.cyan,
69
+ label: `In Progress ${STATUS_ICONS.in_progress}`,
70
+ },
71
+ { value: stats.byStatus.open, color: chalk.white, label: `Open ${STATUS_ICONS.open}` },
72
+ { value: stats.byStatus.blocked, color: chalk.red, label: `Blocked ${STATUS_ICONS.blocked}` },
73
+ {
74
+ value: stats.byStatus.wont_do,
75
+ color: chalk.dim,
76
+ label: `Won't Do ${STATUS_ICONS.wont_do}`,
77
+ },
78
+ ];
79
+ console.log(` ${stackedBar(statusSegments, stats.total, 50)}`);
80
+ console.log(` ${stackedBarLegend(statusSegments)}`);
81
+ console.log('');
82
+ // Two-column layout: Priority vs Type
83
+ const priorityLines = [
84
+ chalk.bold(' By Priority'),
85
+ ...horizontalBarChart([
86
+ { label: 'P0 Critical', value: stats.byPriority[0], color: chalk.red },
87
+ { label: 'P1 High', value: stats.byPriority[1], color: chalk.yellow },
88
+ { label: 'P2 Medium', value: stats.byPriority[2], color: chalk.blue },
89
+ { label: 'P3 Low', value: stats.byPriority[3], color: chalk.dim },
90
+ { label: 'P4 Backlog', value: stats.byPriority[4], color: chalk.dim },
91
+ ], { maxWidth: 20, maxLabelWidth: 14 }),
92
+ ];
93
+ const typeData = Object.entries(stats.byType).filter(([, count]) => count > 0);
94
+ const typeLines = [
95
+ chalk.bold(' By Type'),
96
+ ...horizontalBarChart(typeData.map(([type, count]) => ({
97
+ label: `${TYPE_ICONS[type]} ${type}`,
98
+ value: count,
99
+ color: chalk.magenta,
100
+ })), { maxWidth: 20, maxLabelWidth: 14 }),
101
+ ];
102
+ const combined = columns(priorityLines, typeLines, { gap: 6, leftWidth: 42 });
103
+ for (const line of combined)
104
+ console.log(line);
105
+ console.log('');
106
+ // Agent Status
107
+ console.log(sectionHeader('Agents & Coordination'));
108
+ console.log('');
109
+ const agentItems = coordStatus.activeAgents.map((a) => ({
110
+ text: `${chalk.cyan(a.name)} ${statusBadge(a.status)}${a.currentTask ? chalk.dim(` working on ${a.currentTask}`) : ''}`,
111
+ status: a.status === 'active' ? 'ok' : 'warn',
112
+ }));
113
+ if (agentItems.length > 0) {
114
+ for (const line of bulletList(agentItems))
115
+ console.log(line);
116
+ }
117
+ else {
118
+ console.log(chalk.dim(' No active agents'));
119
+ }
120
+ console.log('');
121
+ for (const line of keyValue([
122
+ ['Active Agents', coordStatus.activeAgents.length],
123
+ ['Resource Claims', coordStatus.activeClaims.length],
124
+ ['Pending Deploys', coordStatus.pendingDeploys.length],
125
+ ['Unread Messages', coordStatus.pendingMessages],
126
+ ]))
127
+ console.log(line);
128
+ // Memory summary
129
+ console.log('');
130
+ console.log(sectionHeader('Memory'));
131
+ console.log('');
132
+ const cwd = process.cwd();
133
+ const dbPath = join(cwd, 'agents/data/memory/short_term.db');
134
+ const memoryItems = [];
135
+ if (existsSync(dbPath)) {
136
+ const dbStats = statSync(dbPath);
137
+ const sizeKB = Math.round(dbStats.size / 1024);
138
+ memoryItems.push({
139
+ text: `Short-term: ${chalk.bold(sizeKB + ' KB')} ${chalk.dim(`(modified ${dbStats.mtime.toLocaleDateString()})`)}`,
140
+ status: 'ok',
141
+ });
142
+ }
143
+ else {
144
+ memoryItems.push({ text: 'Short-term: Not initialized', status: 'warn' });
145
+ }
146
+ let qdrantRunning = false;
147
+ try {
148
+ const dockerStatus = execSync('docker ps --filter name=qdrant --format "{{.Status}}"', {
149
+ encoding: 'utf-8',
150
+ stdio: ['pipe', 'pipe', 'pipe'],
151
+ }).trim();
152
+ if (dockerStatus) {
153
+ memoryItems.push({
154
+ text: `Qdrant: ${chalk.bold('Running')} ${chalk.dim(dockerStatus)}`,
155
+ status: 'ok',
156
+ });
157
+ qdrantRunning = true;
158
+ }
159
+ else {
160
+ memoryItems.push({ text: 'Qdrant: Stopped', status: 'warn' });
161
+ }
162
+ }
163
+ catch {
164
+ memoryItems.push({ text: 'Qdrant: Not available', status: 'warn' });
165
+ }
166
+ for (const line of bulletList(memoryItems))
167
+ console.log(line);
168
+ // Summary box
169
+ console.log('');
170
+ const summaryContent = [
171
+ `Tasks: ${chalk.bold(stats.total)} total, ${chalk.green(completedTasks + ' done')}, ${chalk.yellow(activeTasks + ' active')}`,
172
+ `Agents: ${chalk.bold(coordStatus.activeAgents.length)} active`,
173
+ `Memory: ${existsSync(dbPath) ? chalk.green('SQLite') : chalk.dim('None')} / ${qdrantRunning ? chalk.green('Qdrant') : chalk.dim('No Qdrant')}`,
174
+ ];
175
+ for (const line of box('Summary', summaryContent, { borderColor: chalk.cyan })) {
176
+ console.log(` ${line}`);
177
+ }
178
+ console.log('');
179
+ }
180
+ catch (error) {
181
+ spinner.fail('Failed to load dashboard');
182
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
183
+ }
184
+ }
185
+ async function showTaskDashboard(options) {
186
+ const spinner = ora('Loading task dashboard...').start();
187
+ try {
188
+ const service = new TaskService();
189
+ const stats = service.getStats();
190
+ const allTasks = service.list({});
191
+ const readyTasks = service.ready();
192
+ const blockedTasks = service.blocked();
193
+ spinner.stop();
194
+ console.log('');
195
+ console.log(chalk.bold.cyan(' Task Dashboard'));
196
+ console.log(divider(60));
197
+ console.log('');
198
+ // Completion gauge
199
+ const done = stats.byStatus.done + stats.byStatus.wont_do;
200
+ console.log(` ${chalk.bold('Completion')} ${miniGauge(done, stats.total, 20)} ${chalk.bold(Math.round((done / Math.max(stats.total, 1)) * 100) + '%')} ${chalk.dim(`(${done}/${stats.total})`)}`);
201
+ console.log(` ${chalk.bold('In Flight ')} ${miniGauge(stats.byStatus.in_progress, stats.total, 20)} ${chalk.dim(`${stats.byStatus.in_progress} tasks`)}`);
202
+ console.log(` ${chalk.bold('Blocked ')} ${miniGauge(stats.byStatus.blocked, stats.total, 20)} ${chalk.dim(`${stats.byStatus.blocked} tasks`)}`);
203
+ console.log('');
204
+ // Status stacked bar
205
+ console.log(sectionHeader('Status Distribution'));
206
+ console.log('');
207
+ const segments = [
208
+ { value: stats.byStatus.done, color: chalk.green, label: 'Done' },
209
+ { value: stats.byStatus.in_progress, color: chalk.cyan, label: 'In Progress' },
210
+ { value: stats.byStatus.open, color: chalk.white, label: 'Open' },
211
+ { value: stats.byStatus.blocked, color: chalk.red, label: 'Blocked' },
212
+ { value: stats.byStatus.wont_do, color: chalk.dim, label: "Won't Do" },
213
+ ];
214
+ console.log(` ${stackedBar(segments, stats.total, 50)}`);
215
+ console.log(` ${stackedBarLegend(segments)}`);
216
+ console.log('');
217
+ // Priority chart
218
+ console.log(sectionHeader('Priority Breakdown'));
219
+ console.log('');
220
+ for (const line of horizontalBarChart([
221
+ { label: 'P0 Critical', value: stats.byPriority[0], color: chalk.red },
222
+ { label: 'P1 High', value: stats.byPriority[1], color: chalk.yellow },
223
+ { label: 'P2 Medium', value: stats.byPriority[2], color: chalk.blue },
224
+ { label: 'P3 Low', value: stats.byPriority[3], color: chalk.dim },
225
+ { label: 'P4 Backlog', value: stats.byPriority[4], color: chalk.dim },
226
+ ], { maxWidth: 35, maxLabelWidth: 14 })) {
227
+ console.log(line);
228
+ }
229
+ console.log('');
230
+ // Type chart
231
+ const typeData = Object.entries(stats.byType).filter(([, count]) => count > 0);
232
+ if (typeData.length > 0) {
233
+ console.log(sectionHeader('Type Breakdown'));
234
+ console.log('');
235
+ for (const line of horizontalBarChart(typeData.map(([type, count]) => ({
236
+ label: `${TYPE_ICONS[type]} ${type}`,
237
+ value: count,
238
+ color: chalk.magenta,
239
+ })), { maxWidth: 35, maxLabelWidth: 14 })) {
240
+ console.log(line);
241
+ }
242
+ console.log('');
243
+ }
244
+ // Ready tasks table
245
+ if (readyTasks.length > 0) {
246
+ console.log(sectionHeader('Ready to Work'));
247
+ console.log('');
248
+ const readyRows = readyTasks.slice(0, 10).map((t) => ({
249
+ id: t.id,
250
+ priority: `P${t.priority}`,
251
+ type: TYPE_ICONS[t.type],
252
+ title: t.title.slice(0, 40) + (t.title.length > 40 ? '...' : ''),
253
+ }));
254
+ for (const line of table(readyRows, [
255
+ { key: 'id', header: 'ID', width: 10, color: chalk.cyan },
256
+ { key: 'priority', header: 'Pri', width: 5 },
257
+ { key: 'type', header: 'T', width: 3 },
258
+ { key: 'title', header: 'Title', width: 42 },
259
+ ])) {
260
+ console.log(line);
261
+ }
262
+ if (readyTasks.length > 10) {
263
+ console.log(chalk.dim(` ... and ${readyTasks.length - 10} more`));
264
+ }
265
+ console.log('');
266
+ }
267
+ // Blocked tasks
268
+ if (blockedTasks.length > 0) {
269
+ console.log(sectionHeader('Blocked Tasks'));
270
+ console.log('');
271
+ for (const t of blockedTasks.slice(0, 5)) {
272
+ console.log(` ${chalk.red(STATUS_ICONS.blocked)} ${chalk.cyan(t.id)} ${t.title}`);
273
+ if (t.blockedBy.length > 0) {
274
+ console.log(chalk.red(` Blocked by: ${t.blockedBy.join(', ')}`));
275
+ }
276
+ }
277
+ console.log('');
278
+ }
279
+ // In-progress tasks
280
+ const inProgress = allTasks.filter((t) => t.status === 'in_progress');
281
+ if (inProgress.length > 0) {
282
+ console.log(sectionHeader('In Progress'));
283
+ console.log('');
284
+ for (const t of inProgress) {
285
+ console.log(` ${chalk.cyan(STATUS_ICONS.in_progress)} ${chalk.cyan(t.id)} ${t.title}`);
286
+ if (t.assignee)
287
+ console.log(chalk.dim(` Assigned: ${t.assignee}`));
288
+ }
289
+ console.log('');
290
+ }
291
+ // Task hierarchy tree (epics with children)
292
+ const epics = allTasks.filter((t) => t.type === 'epic' && t.status !== 'done' && t.status !== 'wont_do');
293
+ if (epics.length > 0 && !options.compact) {
294
+ console.log(sectionHeader('Task Hierarchy'));
295
+ console.log('');
296
+ for (const epic of epics.slice(0, 3)) {
297
+ const children = allTasks.filter((t) => t.parentId === epic.id);
298
+ const epicNode = {
299
+ label: `${chalk.bold(epic.title)} ${chalk.dim(epic.id)}`,
300
+ status: STATUS_ICONS[epic.status],
301
+ children: children.map((c) => ({
302
+ label: `${c.title} ${chalk.dim(c.id)}`,
303
+ status: STATUS_ICONS[c.status],
304
+ meta: `P${c.priority} ${c.type}`,
305
+ })),
306
+ };
307
+ for (const line of tree(epicNode))
308
+ console.log(line);
309
+ }
310
+ console.log('');
311
+ }
312
+ }
313
+ catch (error) {
314
+ spinner.fail('Failed to load task dashboard');
315
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
316
+ }
317
+ }
318
+ async function showAgentDashboard(_options) {
319
+ const spinner = ora('Loading agent dashboard...').start();
320
+ try {
321
+ const coordService = new CoordinationService();
322
+ const status = coordService.getStatus();
323
+ const activeWork = coordService.getActiveWork();
324
+ spinner.stop();
325
+ console.log('');
326
+ console.log(chalk.bold.cyan(' Agent Dashboard'));
327
+ console.log(divider(60));
328
+ console.log('');
329
+ // Agent count and status
330
+ console.log(sectionHeader('Active Agents'));
331
+ console.log('');
332
+ if (status.activeAgents.length === 0) {
333
+ console.log(chalk.dim(' No active agents registered'));
334
+ }
335
+ else {
336
+ const agentRows = status.activeAgents.map((a) => ({
337
+ name: a.name,
338
+ status: statusBadge(a.status),
339
+ task: a.currentTask || chalk.dim('idle'),
340
+ heartbeat: chalk.dim(a.lastHeartbeat.slice(11, 19)),
341
+ }));
342
+ for (const line of table(agentRows, [
343
+ { key: 'name', header: 'Agent', width: 18, color: chalk.cyan },
344
+ { key: 'status', header: 'Status', width: 16 },
345
+ { key: 'task', header: 'Current Task', width: 20 },
346
+ { key: 'heartbeat', header: 'Last Beat', width: 10 },
347
+ ])) {
348
+ console.log(line);
349
+ }
350
+ }
351
+ console.log('');
352
+ // Resource claims
353
+ console.log(sectionHeader('Resource Claims'));
354
+ console.log('');
355
+ if (status.activeClaims.length === 0) {
356
+ console.log(chalk.dim(' No active resource claims'));
357
+ }
358
+ else {
359
+ for (const claim of status.activeClaims) {
360
+ const lockIcon = claim.claimType === 'exclusive' ? chalk.red('EXCL') : chalk.green('SHARED');
361
+ console.log(` ${lockIcon} ${chalk.yellow(claim.resource)}`);
362
+ console.log(chalk.dim(` Agent: ${claim.agentId.slice(0, 8)}...`));
363
+ }
364
+ }
365
+ console.log('');
366
+ // Active work visualization
367
+ if (activeWork.length > 0) {
368
+ console.log(sectionHeader('Active Work'));
369
+ console.log('');
370
+ const grouped = new Map();
371
+ for (const work of activeWork) {
372
+ const existing = grouped.get(work.resource) || [];
373
+ existing.push(work);
374
+ grouped.set(work.resource, existing);
375
+ }
376
+ for (const [resource, works] of grouped) {
377
+ const hasConflict = works.length > 1;
378
+ const icon = hasConflict ? chalk.red('!!') : chalk.green('OK');
379
+ console.log(` ${icon} ${chalk.bold(resource)}`);
380
+ for (const w of works) {
381
+ console.log(` ${chalk.cyan(w.agentName || w.agentId.slice(0, 8))} ${chalk.dim(w.intentType)}`);
382
+ }
383
+ }
384
+ console.log('');
385
+ }
386
+ // Deploy queue
387
+ console.log(sectionHeader('Deploy Queue'));
388
+ console.log('');
389
+ if (status.pendingDeploys.length === 0) {
390
+ console.log(chalk.dim(' No pending deploys'));
391
+ }
392
+ else {
393
+ console.log(` ${chalk.bold(String(status.pendingDeploys.length))} pending deploy action(s)`);
394
+ const grouped = new Map();
395
+ for (const d of status.pendingDeploys) {
396
+ grouped.set(d.actionType, (grouped.get(d.actionType) || 0) + 1);
397
+ }
398
+ for (const line of horizontalBarChart([...grouped.entries()].map(([type, count]) => ({
399
+ label: type,
400
+ value: count,
401
+ color: chalk.yellow,
402
+ })), { maxWidth: 20, maxLabelWidth: 12 })) {
403
+ console.log(line);
404
+ }
405
+ }
406
+ console.log('');
407
+ // Summary
408
+ for (const line of keyValue([
409
+ ['Total Agents', status.activeAgents.length],
410
+ ['Resource Claims', status.activeClaims.length],
411
+ ['Active Work Items', activeWork.length],
412
+ ['Pending Deploys', status.pendingDeploys.length],
413
+ ['Unread Messages', status.pendingMessages],
414
+ ]))
415
+ console.log(line);
416
+ console.log('');
417
+ }
418
+ catch (error) {
419
+ spinner.fail('Failed to load agent dashboard');
420
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
421
+ }
422
+ }
423
+ async function showMemoryDashboard(_options) {
424
+ const spinner = ora('Loading memory dashboard...').start();
425
+ try {
426
+ const cwd = process.cwd();
427
+ const dbPath = join(cwd, 'agents/data/memory/short_term.db');
428
+ spinner.stop();
429
+ console.log('');
430
+ console.log(chalk.bold.cyan(' Memory Dashboard'));
431
+ console.log(divider(60));
432
+ console.log('');
433
+ // Short-term memory
434
+ console.log(sectionHeader('Short-Term Memory (SQLite)'));
435
+ console.log('');
436
+ if (existsSync(dbPath)) {
437
+ const dbStats = statSync(dbPath);
438
+ const sizeKB = Math.round(dbStats.size / 1024);
439
+ try {
440
+ const shortTermDb = new SQLiteShortTermMemory({
441
+ dbPath,
442
+ projectId: 'dashboard',
443
+ maxEntries: 9999,
444
+ });
445
+ const count = await shortTermDb.count();
446
+ await shortTermDb.close();
447
+ for (const line of keyValue([
448
+ ['Status', 'Active'],
449
+ ['Entries', count],
450
+ ['Size', `${sizeKB} KB`],
451
+ ['Last Modified', dbStats.mtime.toLocaleDateString()],
452
+ ['Path', dbPath],
453
+ ]))
454
+ console.log(line);
455
+ console.log('');
456
+ console.log(` ${chalk.bold('Capacity')} ${miniGauge(count, 50, 20)} ${chalk.dim(`${count}/50 entries`)}`);
457
+ }
458
+ catch {
459
+ console.log(` ${statusBadge('active')} ${chalk.dim(`${sizeKB} KB`)}`);
460
+ }
461
+ }
462
+ else {
463
+ console.log(` ${statusBadge('not_available')} Not initialized`);
464
+ }
465
+ console.log('');
466
+ // Qdrant status
467
+ console.log(sectionHeader('Long-Term Memory (Qdrant)'));
468
+ console.log('');
469
+ try {
470
+ const dockerStatus = execSync('docker ps --filter name=qdrant --format "{{.Status}}"', {
471
+ encoding: 'utf-8',
472
+ stdio: ['pipe', 'pipe', 'pipe'],
473
+ }).trim();
474
+ if (dockerStatus) {
475
+ console.log(` ${statusBadge('running')} ${chalk.dim(dockerStatus)}`);
476
+ try {
477
+ const dockerInspect = execSync('docker inspect --format "{{.Config.Image}}" uap-qdrant 2>/dev/null || docker inspect --format "{{.Config.Image}}" qdrant 2>/dev/null', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
478
+ if (dockerInspect) {
479
+ console.log(chalk.dim(` Image: ${dockerInspect}`));
480
+ }
481
+ }
482
+ catch {
483
+ /* ignore */
484
+ }
485
+ console.log(chalk.dim(' Endpoint: http://localhost:6333'));
486
+ }
487
+ else {
488
+ console.log(` ${statusBadge('stopped')} Container not running`);
489
+ console.log(chalk.dim(' Start with: uap memory start'));
490
+ }
491
+ }
492
+ catch {
493
+ console.log(` ${statusBadge('not_available')} Docker not available`);
494
+ }
495
+ console.log('');
496
+ // Embeddings
497
+ console.log(sectionHeader('Embeddings (Ollama)'));
498
+ console.log('');
499
+ try {
500
+ const ollamaResponse = await fetch('http://localhost:11434/api/tags', {
501
+ method: 'GET',
502
+ signal: AbortSignal.timeout(2000),
503
+ });
504
+ if (ollamaResponse.ok) {
505
+ const ollamaData = (await ollamaResponse.json());
506
+ const embedModels = ollamaData.models?.filter((m) => m.name.includes('embed') || m.name.includes('nomic')) ||
507
+ [];
508
+ if (embedModels.length > 0) {
509
+ console.log(` ${statusBadge('active')}`);
510
+ for (const model of embedModels) {
511
+ const sizeMB = Math.round((model.size || 0) / 1024 / 1024);
512
+ console.log(` ${chalk.cyan(model.name)} ${chalk.dim(`${sizeMB} MB`)}`);
513
+ }
514
+ }
515
+ else {
516
+ console.log(` ${statusBadge('not_available')} No embedding models found`);
517
+ console.log(chalk.dim(' Install: ollama pull nomic-embed-text'));
518
+ }
519
+ }
520
+ else {
521
+ console.log(` ${statusBadge('stopped')} Not responding`);
522
+ }
523
+ }
524
+ catch {
525
+ console.log(` ${statusBadge('not_available')} Ollama not running`);
526
+ console.log(chalk.dim(' Install from https://ollama.ai'));
527
+ }
528
+ // Memory layers summary
529
+ console.log('');
530
+ console.log(sectionHeader('Memory Layer Architecture'));
531
+ console.log('');
532
+ const layers = {
533
+ label: chalk.bold('UAP Memory System'),
534
+ children: [
535
+ {
536
+ label: 'L1 Working Memory',
537
+ status: existsSync(dbPath) ? chalk.green('ON') : chalk.red('OFF'),
538
+ meta: 'SQLite, <1ms',
539
+ },
540
+ {
541
+ label: 'L2 Session Memory',
542
+ status: existsSync(dbPath) ? chalk.green('ON') : chalk.red('OFF'),
543
+ meta: 'SQLite, <5ms',
544
+ },
545
+ {
546
+ label: 'L3 Semantic Memory',
547
+ status: chalk.yellow('?'),
548
+ meta: 'Qdrant, ~50ms',
549
+ },
550
+ {
551
+ label: 'L4 Knowledge Graph',
552
+ status: existsSync(dbPath) ? chalk.green('ON') : chalk.red('OFF'),
553
+ meta: 'SQLite entities/rels',
554
+ },
555
+ ],
556
+ };
557
+ for (const line of tree(layers))
558
+ console.log(line);
559
+ console.log('');
560
+ }
561
+ catch (error) {
562
+ spinner.fail('Failed to load memory dashboard');
563
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
564
+ }
565
+ }
566
+ async function showProgressDashboard(_options) {
567
+ const spinner = ora('Loading progress dashboard...').start();
568
+ try {
569
+ const service = new TaskService();
570
+ const stats = service.getStats();
571
+ const allTasks = service.list({});
572
+ spinner.stop();
573
+ console.log('');
574
+ console.log(chalk.bold.cyan(' Progress Dashboard'));
575
+ console.log(divider(60));
576
+ console.log('');
577
+ const total = stats.total;
578
+ const done = stats.byStatus.done;
579
+ const wontDo = stats.byStatus.wont_do;
580
+ const inProgress = stats.byStatus.in_progress;
581
+ const blocked = stats.byStatus.blocked;
582
+ const open = stats.byStatus.open;
583
+ const completed = done + wontDo;
584
+ // Big completion percentage
585
+ const pct = total > 0 ? Math.round((completed / total) * 100) : 0;
586
+ const bigNum = pct >= 80 ? chalk.green : pct >= 50 ? chalk.yellow : chalk.red;
587
+ console.log(` ${bigNum(chalk.bold(`${pct}%`))} ${chalk.dim('complete')}`);
588
+ console.log('');
589
+ console.log(` ${progressBar(completed, total, 50, {
590
+ showPercent: false,
591
+ showCount: false,
592
+ filled: pct >= 80 ? chalk.green : pct >= 50 ? chalk.yellow : chalk.red,
593
+ })}`);
594
+ console.log('');
595
+ // Flow breakdown
596
+ console.log(sectionHeader('Task Flow'));
597
+ console.log('');
598
+ console.log(` ${chalk.white('Open')} ${progressBar(open, total, 30, { filled: chalk.white, showPercent: true, showCount: true })}`);
599
+ console.log(` ${chalk.cyan('In Progress')} ${progressBar(inProgress, total, 30, { filled: chalk.cyan, showPercent: true, showCount: true })}`);
600
+ console.log(` ${chalk.red('Blocked')} ${progressBar(blocked, total, 30, { filled: chalk.red, showPercent: true, showCount: true })}`);
601
+ console.log(` ${chalk.green('Done')} ${progressBar(done, total, 30, { filled: chalk.green, showPercent: true, showCount: true })}`);
602
+ if (wontDo > 0) {
603
+ console.log(` ${chalk.dim("Won't Do")} ${progressBar(wontDo, total, 30, { filled: chalk.dim, showPercent: true, showCount: true })}`);
604
+ }
605
+ console.log('');
606
+ // Per-priority progress
607
+ console.log(sectionHeader('Progress by Priority'));
608
+ console.log('');
609
+ for (let p = 0; p <= 4; p++) {
610
+ const priority = p;
611
+ const priorityTasks = allTasks.filter((t) => t.priority === priority);
612
+ const priorityDone = priorityTasks.filter((t) => t.status === 'done' || t.status === 'wont_do').length;
613
+ const priorityTotal = priorityTasks.length;
614
+ if (priorityTotal > 0) {
615
+ const color = p === 0 ? chalk.red : p === 1 ? chalk.yellow : p === 2 ? chalk.blue : chalk.dim;
616
+ const label = PRIORITY_LABELS[priority].padEnd(14);
617
+ console.log(` ${color(label)} ${progressBar(priorityDone, priorityTotal, 25, {
618
+ filled: color,
619
+ showPercent: true,
620
+ showCount: true,
621
+ })}`);
622
+ }
623
+ }
624
+ console.log('');
625
+ // Per-type progress
626
+ const typeData = Object.entries(stats.byType).filter(([, count]) => count > 0);
627
+ if (typeData.length > 0) {
628
+ console.log(sectionHeader('Progress by Type'));
629
+ console.log('');
630
+ for (const [type, typeTotal] of typeData) {
631
+ const typeDone = allTasks.filter((t) => t.type === type && (t.status === 'done' || t.status === 'wont_do')).length;
632
+ const label = `${TYPE_ICONS[type]} ${type}`.padEnd(14);
633
+ console.log(` ${label} ${progressBar(typeDone, typeTotal, 25, {
634
+ filled: chalk.magenta,
635
+ showPercent: true,
636
+ showCount: true,
637
+ })}`);
638
+ }
639
+ console.log('');
640
+ }
641
+ // Velocity indicator (recent completions)
642
+ const now = new Date();
643
+ const recentDone = allTasks.filter((t) => {
644
+ if (t.status !== 'done' || !t.closedAt)
645
+ return false;
646
+ const closedDate = new Date(t.closedAt);
647
+ const daysDiff = (now.getTime() - closedDate.getTime()) / (1000 * 60 * 60 * 24);
648
+ return daysDiff <= 7;
649
+ });
650
+ const recentCreated = allTasks.filter((t) => {
651
+ const createdDate = new Date(t.createdAt);
652
+ const daysDiff = (now.getTime() - createdDate.getTime()) / (1000 * 60 * 60 * 24);
653
+ return daysDiff <= 7;
654
+ });
655
+ console.log(sectionHeader('Velocity (Last 7 Days)'));
656
+ console.log('');
657
+ for (const line of keyValue([
658
+ ['Completed', `${recentDone.length} tasks`],
659
+ ['Created', `${recentCreated.length} tasks`],
660
+ [
661
+ 'Net Progress',
662
+ `${recentDone.length - recentCreated.length > 0 ? '+' : ''}${recentDone.length - recentCreated.length}`,
663
+ ],
664
+ ]))
665
+ console.log(line);
666
+ console.log('');
667
+ // Summary box
668
+ const summaryLines = [
669
+ `${chalk.bold(String(total))} total tasks`,
670
+ `${chalk.green(String(completed))} completed ${chalk.dim(`(${pct}%)`)}`,
671
+ `${chalk.cyan(String(inProgress))} in progress`,
672
+ `${blocked > 0 ? chalk.red(String(blocked) + ' blocked') : chalk.dim('0 blocked')}`,
673
+ `${chalk.dim(String(open))} open / awaiting`,
674
+ ];
675
+ for (const line of box('Summary', summaryLines, { borderColor: chalk.cyan })) {
676
+ console.log(` ${line}`);
677
+ }
678
+ console.log('');
679
+ }
680
+ catch (error) {
681
+ spinner.fail('Failed to load progress dashboard');
682
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
683
+ }
684
+ }
685
+ function formatBytes(bytes) {
686
+ if (bytes < 1024)
687
+ return `${bytes} B`;
688
+ if (bytes < 1024 * 1024)
689
+ return `${(bytes / 1024).toFixed(1)} KB`;
690
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
691
+ }
692
+ function formatDuration(ms) {
693
+ if (ms < 60000)
694
+ return `${(ms / 1000).toFixed(1)} sec`;
695
+ return `${(ms / 60000).toFixed(1)} min`;
696
+ }
697
+ async function showStatsDashboard(_options) {
698
+ const summary = globalSessionStats.getSummary();
699
+ console.log('');
700
+ console.log(chalk.bold.cyan(' Session Stats'));
701
+ console.log(divider(60));
702
+ console.log('');
703
+ const estimatedTokens = Math.round(summary.totalContextBytes / 4);
704
+ for (const line of keyValue([
705
+ ['Uptime', formatDuration(summary.uptimeMs)],
706
+ ['Tool calls', String(summary.totalCalls)],
707
+ [
708
+ 'Context used',
709
+ `${formatBytes(summary.totalContextBytes)} (~${estimatedTokens.toLocaleString()} tokens)`,
710
+ ],
711
+ ['Raw data processed', formatBytes(summary.totalRawBytes)],
712
+ ['Savings ratio', `${summary.savingsRatio}x (${summary.savingsPercent} reduction)`],
713
+ ]))
714
+ console.log(line);
715
+ if (summary.byTool.length > 0) {
716
+ console.log('');
717
+ console.log(sectionHeader('Per-Tool Breakdown'));
718
+ console.log('');
719
+ const rows = summary.byTool.map((t) => [
720
+ chalk.white(t.tool),
721
+ `${t.calls} call${t.calls !== 1 ? 's' : ''}`,
722
+ formatBytes(t.contextBytes),
723
+ ]);
724
+ for (const row of rows) {
725
+ console.log(` ${row[0].padEnd(35)} ${row[1].padEnd(12)} ${row[2]}`);
726
+ }
727
+ }
728
+ if (summary.totalCalls === 0) {
729
+ console.log('');
730
+ console.log(chalk.dim(' No tool calls recorded yet. Stats populate when MCP Router processes requests.'));
731
+ }
732
+ console.log('');
733
+ }
734
+ // ==================== Session Dashboard ====================
735
+ async function showSessionDashboard(options) {
736
+ if (options.compact) {
737
+ compactSessionSummary();
738
+ return;
739
+ }
740
+ const spinner = ora('Loading session dashboard...').start();
741
+ try {
742
+ const cwd = process.cwd();
743
+ // ── Gather data from all sources ──
744
+ const memDbPath = join(cwd, 'agents/data/memory/short_term.db');
745
+ const coordDbPath = join(cwd, 'agents/data/coordination/coordination.db');
746
+ const taskDbPath = join(cwd, '.uap/tasks/tasks.db');
747
+ // Package version
748
+ let version = '?';
749
+ try {
750
+ const pkg = JSON.parse(readFileSync(join(cwd, 'package.json'), 'utf-8'));
751
+ version = pkg.version || '?';
752
+ }
753
+ catch {
754
+ /* ignore */
755
+ }
756
+ // Git info
757
+ let gitBranch = '?';
758
+ let gitDirty = 0;
759
+ let gitAhead = 0;
760
+ let lastCommit = '';
761
+ try {
762
+ gitBranch = execSync('git branch --show-current', {
763
+ encoding: 'utf-8',
764
+ cwd,
765
+ stdio: ['pipe', 'pipe', 'pipe'],
766
+ }).trim();
767
+ gitDirty = execSync('git status --porcelain', {
768
+ encoding: 'utf-8',
769
+ cwd,
770
+ stdio: ['pipe', 'pipe', 'pipe'],
771
+ })
772
+ .trim()
773
+ .split('\n')
774
+ .filter(Boolean).length;
775
+ gitAhead =
776
+ parseInt(execSync('git rev-list --count @{u}..HEAD 2>/dev/null || echo 0', {
777
+ encoding: 'utf-8',
778
+ cwd,
779
+ stdio: ['pipe', 'pipe', 'pipe'],
780
+ }).trim(), 10) || 0;
781
+ lastCommit = execSync('git log -1 --format="%h %s" 2>/dev/null', {
782
+ encoding: 'utf-8',
783
+ cwd,
784
+ stdio: ['pipe', 'pipe', 'pipe'],
785
+ }).trim();
786
+ }
787
+ catch {
788
+ /* ignore */
789
+ }
790
+ // Memory stats
791
+ let memEntries = 0;
792
+ let memSizeKB = 0;
793
+ let recentMemories = [];
794
+ if (existsSync(memDbPath)) {
795
+ try {
796
+ const memDb = new Database(memDbPath, { readonly: true });
797
+ memEntries = memDb.prepare('SELECT COUNT(*) as c FROM memories').get().c;
798
+ memSizeKB = Math.round(statSync(memDbPath).size / 1024);
799
+ recentMemories = memDb
800
+ .prepare("SELECT type, substr(content, 1, 80) as content FROM memories WHERE timestamp >= datetime('now', '-1 day') ORDER BY id DESC LIMIT 5")
801
+ .all();
802
+ memDb.close();
803
+ }
804
+ catch {
805
+ /* ignore */
806
+ }
807
+ }
808
+ // Session memories (open loops)
809
+ let sessionMemCount = 0;
810
+ let openLoops = [];
811
+ if (existsSync(memDbPath)) {
812
+ try {
813
+ const memDb = new Database(memDbPath, { readonly: true });
814
+ const tables = memDb
815
+ .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='session_memories'")
816
+ .all();
817
+ if (tables.length > 0) {
818
+ sessionMemCount = memDb.prepare('SELECT COUNT(*) as c FROM session_memories').get().c;
819
+ openLoops = memDb
820
+ .prepare("SELECT content FROM session_memories WHERE type IN ('action','goal','decision') AND importance >= 7 ORDER BY id DESC LIMIT 5")
821
+ .all();
822
+ }
823
+ memDb.close();
824
+ }
825
+ catch {
826
+ /* ignore */
827
+ }
828
+ }
829
+ // Coordination stats
830
+ let activeAgents = 0;
831
+ let activeClaims = 0;
832
+ let pendingDeploys = 0;
833
+ if (existsSync(coordDbPath)) {
834
+ try {
835
+ const coordDb = new Database(coordDbPath, { readonly: true });
836
+ activeAgents = coordDb
837
+ .prepare("SELECT COUNT(*) as c FROM agent_registry WHERE status='active'")
838
+ .get().c;
839
+ activeClaims = coordDb.prepare('SELECT COUNT(*) as c FROM work_claims').get().c;
840
+ pendingDeploys = coordDb
841
+ .prepare("SELECT COUNT(*) as c FROM deploy_queue WHERE status='pending'")
842
+ .get().c;
843
+ coordDb.close();
844
+ }
845
+ catch {
846
+ /* ignore */
847
+ }
848
+ }
849
+ // Task stats
850
+ let taskTotal = 0;
851
+ let taskOpen = 0;
852
+ let taskProgress = 0;
853
+ let taskBlocked = 0;
854
+ let taskDone = 0;
855
+ let activeTasks = [];
856
+ if (existsSync(taskDbPath)) {
857
+ try {
858
+ const taskDb = new Database(taskDbPath, { readonly: true });
859
+ taskTotal = taskDb.prepare('SELECT COUNT(*) as c FROM tasks').get().c;
860
+ taskOpen = taskDb.prepare("SELECT COUNT(*) as c FROM tasks WHERE status='open'").get().c;
861
+ taskProgress = taskDb.prepare("SELECT COUNT(*) as c FROM tasks WHERE status='in_progress'").get().c;
862
+ taskBlocked = taskDb.prepare("SELECT COUNT(*) as c FROM tasks WHERE status='blocked'").get().c;
863
+ taskDone = taskDb
864
+ .prepare("SELECT COUNT(*) as c FROM tasks WHERE status='done' OR status='wont_do'")
865
+ .get().c;
866
+ activeTasks = taskDb
867
+ .prepare("SELECT id, title, priority FROM tasks WHERE status='in_progress' ORDER BY priority ASC LIMIT 5")
868
+ .all();
869
+ taskDb.close();
870
+ }
871
+ catch {
872
+ /* ignore */
873
+ }
874
+ }
875
+ // Qdrant status
876
+ let qdrantStatus = 'Stopped';
877
+ let qdrantUptime = '';
878
+ try {
879
+ const dockerOut = execSync('docker ps --filter name=qdrant --format "{{.Status}}"', {
880
+ encoding: 'utf-8',
881
+ stdio: ['pipe', 'pipe', 'pipe'],
882
+ }).trim();
883
+ if (dockerOut) {
884
+ qdrantStatus = 'Running';
885
+ qdrantUptime = dockerOut;
886
+ }
887
+ }
888
+ catch {
889
+ /* ignore */
890
+ }
891
+ // Patterns
892
+ let patternCount = 0;
893
+ let patternNames = [];
894
+ const patternIndexPath = join(cwd, '.factory/patterns/index.json');
895
+ if (existsSync(patternIndexPath)) {
896
+ try {
897
+ const patternData = JSON.parse(readFileSync(patternIndexPath, 'utf-8'));
898
+ const patterns = patternData.patterns || [];
899
+ patternCount = patterns.length;
900
+ patternNames = patterns
901
+ .slice(0, 5)
902
+ .map((p) => p.title || p.name || p.abbreviation || `P${p.id}` || '?');
903
+ }
904
+ catch {
905
+ /* ignore */
906
+ }
907
+ }
908
+ // Skills
909
+ let skillNames = [];
910
+ const skillDirs = [join(cwd, '.claude/skills'), join(cwd, '.factory/skills')];
911
+ for (const dir of skillDirs) {
912
+ if (existsSync(dir)) {
913
+ try {
914
+ const entries = readdirSync(dir, { withFileTypes: true });
915
+ for (const entry of entries) {
916
+ if (entry.isDirectory() && existsSync(join(dir, entry.name, 'SKILL.md'))) {
917
+ skillNames.push(entry.name);
918
+ }
919
+ }
920
+ }
921
+ catch {
922
+ /* ignore */
923
+ }
924
+ }
925
+ }
926
+ // Droids
927
+ let droidNames = [];
928
+ const droidDir = join(cwd, '.factory/droids');
929
+ if (existsSync(droidDir)) {
930
+ try {
931
+ const entries = readdirSync(droidDir).filter((f) => f.endsWith('.md') && !f.startsWith('test-droid-'));
932
+ droidNames = entries.map((f) => f.replace('.md', ''));
933
+ }
934
+ catch {
935
+ /* ignore */
936
+ }
937
+ }
938
+ // Worktrees
939
+ let worktreeCount = 0;
940
+ const worktreeDir = join(cwd, '.worktrees');
941
+ if (existsSync(worktreeDir)) {
942
+ try {
943
+ worktreeCount = readdirSync(worktreeDir, { withFileTypes: true }).filter((e) => e.isDirectory()).length;
944
+ }
945
+ catch {
946
+ /* ignore */
947
+ }
948
+ }
949
+ spinner.stop();
950
+ // ── Render ──
951
+ console.log('');
952
+ console.log(chalk.bold.cyan(' UAP Session Dashboard'));
953
+ console.log(divider(62));
954
+ console.log('');
955
+ // System info
956
+ console.log(sectionHeader('System'));
957
+ console.log('');
958
+ for (const line of keyValue([
959
+ ['Version', `v${version}`],
960
+ [
961
+ 'Branch',
962
+ `${gitBranch}${gitDirty > 0 ? chalk.yellow(` (${gitDirty} uncommitted)`) : chalk.green(' (clean)')}`,
963
+ ],
964
+ ['Ahead', gitAhead > 0 ? chalk.yellow(`${gitAhead} commits`) : chalk.dim('up to date')],
965
+ ['Last Commit', lastCommit.length > 55 ? lastCommit.slice(0, 55) + '...' : lastCommit],
966
+ ]))
967
+ console.log(line);
968
+ console.log('');
969
+ // Task progress
970
+ console.log(sectionHeader('Tasks'));
971
+ console.log('');
972
+ if (taskTotal > 0) {
973
+ const pct = Math.round((taskDone / taskTotal) * 100);
974
+ console.log(` ${progressBar(taskDone, taskTotal, 30, {
975
+ label: 'Progress',
976
+ filled: pct >= 80 ? chalk.green : pct >= 50 ? chalk.yellow : chalk.white,
977
+ })}`);
978
+ console.log('');
979
+ const segments = [
980
+ { value: taskDone, color: chalk.green, label: 'Done' },
981
+ { value: taskProgress, color: chalk.cyan, label: 'Active' },
982
+ { value: taskOpen, color: chalk.white, label: 'Open' },
983
+ { value: taskBlocked, color: chalk.red, label: 'Blocked' },
984
+ ];
985
+ console.log(` ${stackedBar(segments, taskTotal, 40)}`);
986
+ console.log(` ${stackedBarLegend(segments)}`);
987
+ console.log('');
988
+ if (activeTasks.length > 0) {
989
+ console.log(chalk.dim(' Active:'));
990
+ for (const t of activeTasks) {
991
+ console.log(` ${chalk.cyan(t.id)} P${t.priority} ${t.title.slice(0, 45)}${t.title.length > 45 ? '...' : ''}`);
992
+ }
993
+ console.log('');
994
+ }
995
+ }
996
+ else {
997
+ console.log(chalk.dim(' No tasks tracked. Create with: uap task create --title "..."'));
998
+ console.log('');
999
+ }
1000
+ // Memory layers
1001
+ console.log(sectionHeader('Memory System'));
1002
+ console.log('');
1003
+ const memItems = [
1004
+ {
1005
+ text: `L1 Working Memory: ${chalk.bold(memEntries + ' entries')} ${chalk.dim(`(${memSizeKB} KB)`)}`,
1006
+ status: existsSync(memDbPath) ? 'ok' : 'warn',
1007
+ },
1008
+ {
1009
+ text: `L2 Session Memory: ${chalk.bold(sessionMemCount + ' entries')} ${openLoops.length > 0 ? chalk.yellow(`(${openLoops.length} open loops)`) : ''}`,
1010
+ status: sessionMemCount > 0 ? 'ok' : 'info',
1011
+ },
1012
+ {
1013
+ text: `L3 Semantic Memory: ${qdrantStatus === 'Running' ? chalk.green('Qdrant ' + qdrantUptime) : chalk.dim('Qdrant stopped')}`,
1014
+ status: qdrantStatus === 'Running' ? 'ok' : 'warn',
1015
+ },
1016
+ {
1017
+ text: `L4 Knowledge Graph: ${existsSync(memDbPath) ? chalk.green('Active') : chalk.dim('Not initialized')}`,
1018
+ status: existsSync(memDbPath) ? 'ok' : 'warn',
1019
+ },
1020
+ ];
1021
+ for (const line of bulletList(memItems))
1022
+ console.log(line);
1023
+ if (recentMemories.length > 0) {
1024
+ console.log('');
1025
+ console.log(chalk.dim(' Recent memories (24h):'));
1026
+ for (const mem of recentMemories.slice(0, 3)) {
1027
+ console.log(` ${chalk.dim(mem.type + ':')} ${mem.content}`);
1028
+ }
1029
+ }
1030
+ console.log('');
1031
+ // Coordination
1032
+ console.log(sectionHeader('Coordination'));
1033
+ console.log('');
1034
+ for (const line of keyValue([
1035
+ ['Active Agents', activeAgents > 0 ? chalk.green(String(activeAgents)) : chalk.dim('0')],
1036
+ ['Resource Claims', activeClaims > 0 ? chalk.yellow(String(activeClaims)) : chalk.dim('0')],
1037
+ [
1038
+ 'Pending Deploys',
1039
+ pendingDeploys > 0 ? chalk.yellow(String(pendingDeploys)) : chalk.dim('0'),
1040
+ ],
1041
+ ['Worktrees', worktreeCount > 0 ? chalk.yellow(String(worktreeCount)) : chalk.dim('0')],
1042
+ ]))
1043
+ console.log(line);
1044
+ console.log('');
1045
+ // Patterns & Skills
1046
+ console.log(sectionHeader('Intelligence'));
1047
+ console.log('');
1048
+ if (patternCount > 0) {
1049
+ console.log(` ${chalk.blue('Patterns')} ${chalk.bold(String(patternCount))} loaded`);
1050
+ if (patternNames.length > 0) {
1051
+ for (const name of patternNames) {
1052
+ console.log(` ${chalk.dim('-')} ${name}`);
1053
+ }
1054
+ if (patternCount > 5)
1055
+ console.log(chalk.dim(` ... and ${patternCount - 5} more`));
1056
+ }
1057
+ }
1058
+ else {
1059
+ console.log(chalk.dim(' Patterns: None loaded'));
1060
+ }
1061
+ console.log('');
1062
+ if (skillNames.length > 0) {
1063
+ console.log(` ${chalk.green('Skills')} ${chalk.bold(String(skillNames.length))} available`);
1064
+ for (const name of skillNames) {
1065
+ console.log(` ${chalk.dim('-')} ${name}`);
1066
+ }
1067
+ }
1068
+ else {
1069
+ console.log(chalk.dim(' Skills: None configured'));
1070
+ }
1071
+ console.log('');
1072
+ if (droidNames.length > 0) {
1073
+ console.log(` ${chalk.magenta('Droids')} ${chalk.bold(String(droidNames.length))} registered`);
1074
+ for (const name of droidNames.slice(0, 5)) {
1075
+ console.log(` ${chalk.dim('-')} ${name}`);
1076
+ }
1077
+ if (droidNames.length > 5)
1078
+ console.log(chalk.dim(` ... and ${droidNames.length - 5} more`));
1079
+ }
1080
+ else {
1081
+ console.log(chalk.dim(' Droids: None registered'));
1082
+ }
1083
+ console.log('');
1084
+ // Policies
1085
+ console.log(sectionHeader('Policies'));
1086
+ console.log('');
1087
+ const policyItems = [
1088
+ { text: 'IaC State Parity', status: 'ok' },
1089
+ { text: 'Mandatory File Backup', status: 'ok' },
1090
+ ];
1091
+ const imgPolicyPath = join(cwd, 'policies/image-asset-verification.md');
1092
+ if (existsSync(imgPolicyPath)) {
1093
+ policyItems.push({ text: 'Image & Asset Verification', status: 'info' });
1094
+ }
1095
+ for (const line of bulletList(policyItems))
1096
+ console.log(line);
1097
+ console.log('');
1098
+ // Open loops
1099
+ if (openLoops.length > 0) {
1100
+ console.log(sectionHeader('Open Loops'));
1101
+ console.log('');
1102
+ for (const loop of openLoops) {
1103
+ console.log(` ${chalk.yellow('>')} ${loop.content.slice(0, 70)}${loop.content.length > 70 ? '...' : ''}`);
1104
+ }
1105
+ console.log('');
1106
+ }
1107
+ // Summary box
1108
+ const summaryLines = [
1109
+ `v${version} on ${chalk.cyan(gitBranch)}${gitDirty > 0 ? chalk.yellow(' *') : ''}`,
1110
+ `${chalk.bold(String(taskTotal))} tasks (${taskDone} done, ${taskProgress} active, ${taskBlocked} blocked)`,
1111
+ `${chalk.bold(String(memEntries))} memories | Qdrant: ${qdrantStatus === 'Running' ? chalk.green('ON') : chalk.dim('OFF')}`,
1112
+ `${patternCount} patterns | ${skillNames.length} skills | ${droidNames.length} droids`,
1113
+ ];
1114
+ for (const line of box('UAP Session', summaryLines, { borderColor: chalk.cyan })) {
1115
+ console.log(` ${line}`);
1116
+ }
1117
+ console.log('');
1118
+ }
1119
+ catch (error) {
1120
+ spinner.fail('Failed to load session dashboard');
1121
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
1122
+ }
1123
+ }
1124
+ // ==================== Compact Session Summary (for post-task / pre-compact) ====================
1125
+ /**
1126
+ * Renders a compact session summary panel.
1127
+ * Used after task completion and before context compaction to give
1128
+ * the agent (and user) a quick snapshot of UAP operational state.
1129
+ */
1130
+ export function compactSessionSummary() {
1131
+ const cwd = process.cwd();
1132
+ const memDbPath = join(cwd, 'agents/data/memory/short_term.db');
1133
+ const coordDbPath = join(cwd, 'agents/data/coordination/coordination.db');
1134
+ const taskDbPath = join(cwd, '.uap/tasks/tasks.db');
1135
+ // Version
1136
+ let version = '?';
1137
+ try {
1138
+ const pkg = JSON.parse(readFileSync(join(cwd, 'package.json'), 'utf-8'));
1139
+ version = pkg.version || '?';
1140
+ }
1141
+ catch {
1142
+ /* ignore */
1143
+ }
1144
+ // Git
1145
+ let gitBranch = '?';
1146
+ let gitDirty = 0;
1147
+ try {
1148
+ gitBranch = execSync('git branch --show-current', {
1149
+ encoding: 'utf-8',
1150
+ cwd,
1151
+ stdio: ['pipe', 'pipe', 'pipe'],
1152
+ }).trim();
1153
+ gitDirty = execSync('git status --porcelain', {
1154
+ encoding: 'utf-8',
1155
+ cwd,
1156
+ stdio: ['pipe', 'pipe', 'pipe'],
1157
+ })
1158
+ .trim()
1159
+ .split('\n')
1160
+ .filter(Boolean).length;
1161
+ }
1162
+ catch {
1163
+ /* ignore */
1164
+ }
1165
+ // Tasks
1166
+ let taskTotal = 0;
1167
+ let taskDone = 0;
1168
+ let taskProgress = 0;
1169
+ let taskBlocked = 0;
1170
+ let taskOpen = 0;
1171
+ if (existsSync(taskDbPath)) {
1172
+ try {
1173
+ const db = new Database(taskDbPath, { readonly: true });
1174
+ taskTotal = db.prepare('SELECT COUNT(*) as c FROM tasks').get().c;
1175
+ taskDone = db
1176
+ .prepare("SELECT COUNT(*) as c FROM tasks WHERE status='done' OR status='wont_do'")
1177
+ .get().c;
1178
+ taskProgress = db.prepare("SELECT COUNT(*) as c FROM tasks WHERE status='in_progress'").get().c;
1179
+ taskBlocked = db.prepare("SELECT COUNT(*) as c FROM tasks WHERE status='blocked'").get().c;
1180
+ taskOpen = db.prepare("SELECT COUNT(*) as c FROM tasks WHERE status='open'").get().c;
1181
+ db.close();
1182
+ }
1183
+ catch {
1184
+ /* ignore */
1185
+ }
1186
+ }
1187
+ // Memory
1188
+ let memEntries = 0;
1189
+ if (existsSync(memDbPath)) {
1190
+ try {
1191
+ const db = new Database(memDbPath, { readonly: true });
1192
+ memEntries = db.prepare('SELECT COUNT(*) as c FROM memories').get().c;
1193
+ db.close();
1194
+ }
1195
+ catch {
1196
+ /* ignore */
1197
+ }
1198
+ }
1199
+ // Agents
1200
+ let activeAgents = 0;
1201
+ if (existsSync(coordDbPath)) {
1202
+ try {
1203
+ const db = new Database(coordDbPath, { readonly: true });
1204
+ activeAgents = db.prepare("SELECT COUNT(*) as c FROM agent_registry WHERE status='active'").get().c;
1205
+ db.close();
1206
+ }
1207
+ catch {
1208
+ /* ignore */
1209
+ }
1210
+ }
1211
+ // Qdrant
1212
+ let qdrantOn = false;
1213
+ try {
1214
+ const out = execSync('docker ps --filter name=qdrant --format "{{.Status}}"', {
1215
+ encoding: 'utf-8',
1216
+ stdio: ['pipe', 'pipe', 'pipe'],
1217
+ }).trim();
1218
+ qdrantOn = !!out;
1219
+ }
1220
+ catch {
1221
+ /* ignore */
1222
+ }
1223
+ // Patterns, Skills, Droids counts
1224
+ let patternCount = 0;
1225
+ let skillCount = 0;
1226
+ let droidCount = 0;
1227
+ try {
1228
+ const pi = join(cwd, '.factory/patterns/index.json');
1229
+ if (existsSync(pi)) {
1230
+ patternCount = JSON.parse(readFileSync(pi, 'utf-8')).patterns?.length || 0;
1231
+ }
1232
+ }
1233
+ catch {
1234
+ /* ignore */
1235
+ }
1236
+ for (const dir of [join(cwd, '.claude/skills'), join(cwd, '.factory/skills')]) {
1237
+ if (existsSync(dir)) {
1238
+ try {
1239
+ skillCount += readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && existsSync(join(dir, e.name, 'SKILL.md'))).length;
1240
+ }
1241
+ catch {
1242
+ /* ignore */
1243
+ }
1244
+ }
1245
+ }
1246
+ const dd = join(cwd, '.factory/droids');
1247
+ if (existsSync(dd)) {
1248
+ try {
1249
+ droidCount = readdirSync(dd).filter((f) => f.endsWith('.md') && !f.startsWith('test-droid-')).length;
1250
+ }
1251
+ catch {
1252
+ /* ignore */
1253
+ }
1254
+ }
1255
+ // Build task progress bar
1256
+ const barW = 20;
1257
+ const pct = taskTotal > 0 ? Math.round((taskDone / taskTotal) * 100) : 0;
1258
+ const filledW = taskTotal > 0 ? Math.round((taskDone / taskTotal) * barW) : 0;
1259
+ const pctColor = pct >= 80 ? chalk.green : pct >= 50 ? chalk.yellow : chalk.white;
1260
+ const taskBar = chalk.green('\u2588'.repeat(filledW)) + chalk.dim('\u2591'.repeat(barW - filledW));
1261
+ // Render compact box
1262
+ const W = 58;
1263
+ // W used for box width below
1264
+ console.log('');
1265
+ console.log(chalk.cyan(` \u256D${'─'.repeat(W)}\u256E`));
1266
+ console.log(chalk.cyan(` │`) +
1267
+ chalk.bold.white(` UAP v${version}`) +
1268
+ chalk.dim(` on ${gitBranch}${gitDirty > 0 ? ' *' : ''}`) +
1269
+ ' '.repeat(Math.max(0, W - 12 - version.length - gitBranch.length - (gitDirty > 0 ? 2 : 0))) +
1270
+ chalk.cyan(`│`));
1271
+ console.log(chalk.cyan(` ├${'─'.repeat(W)}┤`));
1272
+ // Task line
1273
+ if (taskTotal > 0) {
1274
+ const taskLine = ` ${taskBar} ${pctColor(pct + '%')} ${chalk.dim(`${taskDone}/${taskTotal}`)} ${chalk.green(taskDone + '\u2713')} ${chalk.cyan(taskProgress + '\u25D0')} ${taskBlocked > 0 ? chalk.red(taskBlocked + '\u2744') + ' ' : ''}${chalk.dim(taskOpen + '\u25CB')}`;
1275
+ // Use raw length estimation for padding
1276
+ const rawLen = ` ${'█'.repeat(barW)} ${pct}% ${taskDone}/${taskTotal} ${taskDone}✓ ${taskProgress}◐ ${taskBlocked > 0 ? taskBlocked + '❄ ' : ''}${taskOpen}○`;
1277
+ console.log(chalk.cyan(` │`) + taskLine + ' '.repeat(Math.max(0, W - rawLen.length)) + chalk.cyan(`│`));
1278
+ }
1279
+ else {
1280
+ console.log(chalk.cyan(` │`) + chalk.dim(' No tasks tracked') + ' '.repeat(W - 18) + chalk.cyan(`│`));
1281
+ }
1282
+ // Memory + Qdrant line
1283
+ const memLine = ` Mem: ${memEntries} entries Qdrant: ${qdrantOn ? 'ON' : 'OFF'} Agents: ${activeAgents}`;
1284
+ console.log(chalk.cyan(` │`) +
1285
+ (qdrantOn ? chalk.white(memLine) : chalk.dim(memLine)) +
1286
+ ' '.repeat(Math.max(0, W - memLine.length)) +
1287
+ chalk.cyan(`│`));
1288
+ // Intelligence line
1289
+ const intLine = ` ${patternCount}P ${skillCount}S ${droidCount}D L1:ON L2:ON L3:${qdrantOn ? 'ON' : '?'} L4:ON`;
1290
+ console.log(chalk.cyan(` │`) +
1291
+ chalk.dim(intLine) +
1292
+ ' '.repeat(Math.max(0, W - intLine.length)) +
1293
+ chalk.cyan(`│`));
1294
+ console.log(chalk.cyan(` \u2570${'─'.repeat(W)}\u256F`));
1295
+ console.log('');
1296
+ }
1297
+ // ==================== Real-Time Benchmark Dashboard ====================
1298
+ /**
1299
+ * Show a real-time benchmark dashboard with memory, model routing,
1300
+ * deploy batch, and pattern success stats from local databases.
1301
+ *
1302
+ * Uses simple ASCII formatting with no external dependencies beyond chalk.
1303
+ */
1304
+ export function showDashboard() {
1305
+ const cwd = process.cwd();
1306
+ // Database paths
1307
+ const shortTermDbPath = join(cwd, 'agents/data/memory/short_term.db');
1308
+ const coordDbPath = join(cwd, 'agents/data/coordination/coordination.db');
1309
+ const modelDbPath = join(cwd, 'agents/data/memory/model_fingerprints.db');
1310
+ const patternIndexPath = join(cwd, '.factory/patterns/index.json');
1311
+ const W = 60;
1312
+ const sep = '─'.repeat(W);
1313
+ console.log('');
1314
+ console.log(chalk.bold.cyan(' Real-Time Benchmark Dashboard'));
1315
+ console.log(` ${sep}`);
1316
+ console.log('');
1317
+ // ── Memory Stats ──
1318
+ console.log(chalk.bold(' Memory Stats'));
1319
+ console.log(` ${chalk.dim('─'.repeat(W - 2))}`);
1320
+ let shortTermCount = 0;
1321
+ let sessionCount = 0;
1322
+ let entityCount = 0;
1323
+ let relationCount = 0;
1324
+ let shortTermSizeKB = 0;
1325
+ if (existsSync(shortTermDbPath)) {
1326
+ try {
1327
+ const db = new Database(shortTermDbPath, { readonly: true });
1328
+ shortTermSizeKB = Math.round(statSync(shortTermDbPath).size / 1024);
1329
+ shortTermCount = db.prepare('SELECT COUNT(*) as c FROM memories').get().c;
1330
+ // Session memories
1331
+ const hasSessions = db
1332
+ .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='session_memories'")
1333
+ .all();
1334
+ if (hasSessions.length > 0) {
1335
+ sessionCount = db.prepare('SELECT COUNT(*) as c FROM session_memories').get().c;
1336
+ }
1337
+ // Knowledge graph entities
1338
+ const hasEntities = db
1339
+ .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='entities'")
1340
+ .all();
1341
+ if (hasEntities.length > 0) {
1342
+ entityCount = db.prepare('SELECT COUNT(*) as c FROM entities').get().c;
1343
+ }
1344
+ const hasRelations = db
1345
+ .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='relationships'")
1346
+ .all();
1347
+ if (hasRelations.length > 0) {
1348
+ relationCount = db.prepare('SELECT COUNT(*) as c FROM relationships').get().c;
1349
+ }
1350
+ db.close();
1351
+ }
1352
+ catch {
1353
+ /* ignore db errors */
1354
+ }
1355
+ }
1356
+ const memRows = [
1357
+ ['Short-term memories', String(shortTermCount)],
1358
+ ['Session memories', String(sessionCount)],
1359
+ ['KG entities', String(entityCount)],
1360
+ ['KG relationships', String(relationCount)],
1361
+ ['DB size', `${shortTermSizeKB} KB`],
1362
+ ];
1363
+ for (const [label, value] of memRows) {
1364
+ console.log(` ${chalk.white(label.padEnd(25))} ${chalk.bold(value)}`);
1365
+ }
1366
+ console.log('');
1367
+ // ── Model Routing Stats ──
1368
+ console.log(chalk.bold(' Model Routing Stats'));
1369
+ console.log(` ${chalk.dim('─'.repeat(W - 2))}`);
1370
+ if (existsSync(modelDbPath)) {
1371
+ try {
1372
+ const db = new Database(modelDbPath, { readonly: true });
1373
+ const tables = db
1374
+ .prepare("SELECT name FROM sqlite_master WHERE type='table'")
1375
+ .all();
1376
+ const tableNames = tables.map((t) => t.name);
1377
+ if (tableNames.includes('model_fingerprints')) {
1378
+ const fpCount = db.prepare('SELECT COUNT(*) as c FROM model_fingerprints').get().c;
1379
+ console.log(` ${chalk.white('Fingerprints'.padEnd(25))} ${chalk.bold(String(fpCount))}`);
1380
+ // Try to get distinct models
1381
+ try {
1382
+ const models = db
1383
+ .prepare('SELECT DISTINCT model_id FROM model_fingerprints ORDER BY model_id LIMIT 10')
1384
+ .all();
1385
+ if (models.length > 0) {
1386
+ console.log(` ${chalk.white('Tracked models'.padEnd(25))} ${chalk.bold(String(models.length))}`);
1387
+ for (const m of models.slice(0, 5)) {
1388
+ console.log(` ${chalk.dim('-')} ${m.model_id}`);
1389
+ }
1390
+ if (models.length > 5)
1391
+ console.log(chalk.dim(` ... and ${models.length - 5} more`));
1392
+ }
1393
+ }
1394
+ catch {
1395
+ /* schema variation */
1396
+ }
1397
+ }
1398
+ if (tableNames.includes('routing_decisions')) {
1399
+ const routeCount = db.prepare('SELECT COUNT(*) as c FROM routing_decisions').get().c;
1400
+ console.log(` ${chalk.white('Routing decisions'.padEnd(25))} ${chalk.bold(String(routeCount))}`);
1401
+ }
1402
+ db.close();
1403
+ }
1404
+ catch {
1405
+ console.log(chalk.dim(' Could not read model fingerprints DB'));
1406
+ }
1407
+ }
1408
+ else {
1409
+ console.log(chalk.dim(' No model fingerprints DB found'));
1410
+ }
1411
+ console.log('');
1412
+ // ── Deploy Batch Stats ──
1413
+ console.log(chalk.bold(' Deploy Batch Stats'));
1414
+ console.log(` ${chalk.dim('─'.repeat(W - 2))}`);
1415
+ let deployPending = 0;
1416
+ let deployCompleted = 0;
1417
+ let deployFailed = 0;
1418
+ let batchCount = 0;
1419
+ if (existsSync(coordDbPath)) {
1420
+ try {
1421
+ const db = new Database(coordDbPath, { readonly: true });
1422
+ const hasDQ = db
1423
+ .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='deploy_queue'")
1424
+ .all();
1425
+ if (hasDQ.length > 0) {
1426
+ deployPending = db.prepare("SELECT COUNT(*) as c FROM deploy_queue WHERE status='pending'").get().c;
1427
+ deployCompleted = db
1428
+ .prepare("SELECT COUNT(*) as c FROM deploy_queue WHERE status='completed' OR status='batched'")
1429
+ .get().c;
1430
+ deployFailed = db.prepare("SELECT COUNT(*) as c FROM deploy_queue WHERE status='failed'").get().c;
1431
+ }
1432
+ const hasDB = db
1433
+ .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='deploy_batches'")
1434
+ .all();
1435
+ if (hasDB.length > 0) {
1436
+ batchCount = db.prepare('SELECT COUNT(*) as c FROM deploy_batches').get()
1437
+ .c;
1438
+ }
1439
+ db.close();
1440
+ }
1441
+ catch {
1442
+ /* ignore */
1443
+ }
1444
+ }
1445
+ const deployTotal = deployPending + deployCompleted + deployFailed;
1446
+ const deployRows = [
1447
+ ['Pending', String(deployPending)],
1448
+ ['Completed', String(deployCompleted)],
1449
+ ['Failed', String(deployFailed)],
1450
+ ['Total actions', String(deployTotal)],
1451
+ ['Batches', String(batchCount)],
1452
+ ];
1453
+ for (const [label, value] of deployRows) {
1454
+ const color = label === 'Failed' && deployFailed > 0
1455
+ ? chalk.red
1456
+ : label === 'Pending' && deployPending > 0
1457
+ ? chalk.yellow
1458
+ : chalk.white;
1459
+ console.log(` ${color(label.padEnd(25))} ${chalk.bold(value)}`);
1460
+ }
1461
+ console.log('');
1462
+ // ── Pattern Success Rates ──
1463
+ console.log(chalk.bold(' Pattern Success Rates'));
1464
+ console.log(` ${chalk.dim('─'.repeat(W - 2))}`);
1465
+ if (existsSync(patternIndexPath)) {
1466
+ try {
1467
+ const raw = readFileSync(patternIndexPath, 'utf-8');
1468
+ const data = JSON.parse(raw);
1469
+ const patterns = data.patterns || [];
1470
+ const active = patterns.filter((p) => p.active !== false);
1471
+ const withRates = active.filter((p) => typeof p.successRate === 'number');
1472
+ console.log(` ${chalk.white('Total patterns'.padEnd(25))} ${chalk.bold(String(patterns.length))}`);
1473
+ console.log(` ${chalk.white('Active'.padEnd(25))} ${chalk.bold(String(active.length))}`);
1474
+ if (withRates.length > 0) {
1475
+ const avgRate = withRates.reduce((sum, p) => sum + (p.successRate || 0), 0) / withRates.length;
1476
+ console.log(` ${chalk.white('Avg success rate'.padEnd(25))} ${chalk.bold(avgRate.toFixed(1) + '%')}`);
1477
+ console.log('');
1478
+ // Show top patterns by success rate
1479
+ const sorted = [...withRates].sort((a, b) => (b.successRate || 0) - (a.successRate || 0));
1480
+ for (const p of sorted.slice(0, 8)) {
1481
+ const name = p.title || p.name || p.abbreviation || `P${p.id}` || '?';
1482
+ const rate = p.successRate || 0;
1483
+ const barLen = Math.round(rate / 5);
1484
+ const bar = chalk.green('\u2588'.repeat(barLen)) + chalk.dim('\u2591'.repeat(20 - barLen));
1485
+ console.log(` ${name.slice(0, 22).padEnd(22)} ${bar} ${rate.toFixed(0)}%`);
1486
+ }
1487
+ if (sorted.length > 8) {
1488
+ console.log(chalk.dim(` ... and ${sorted.length - 8} more`));
1489
+ }
1490
+ }
1491
+ else {
1492
+ console.log(chalk.dim(' No success rate data tracked'));
1493
+ }
1494
+ }
1495
+ catch {
1496
+ console.log(chalk.dim(' Could not parse patterns index'));
1497
+ }
1498
+ }
1499
+ else {
1500
+ console.log(chalk.dim(' No patterns index found'));
1501
+ }
1502
+ console.log('');
1503
+ console.log(` ${sep}`);
1504
+ console.log(chalk.dim(' Run: uap dashboard overview for full project dashboard'));
1505
+ console.log(chalk.dim(' Run: uap dashboard session for session context'));
1506
+ console.log('');
1507
+ }
1508
+ //# sourceMappingURL=dashboard.js.map