@monoes/monomindcli 1.11.12 → 1.11.14

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 (434) hide show
  1. package/.claude/commands/mastermind/idea.md +1 -1
  2. package/.claude/commands/mastermind/master.md +1 -1
  3. package/.claude/skills/mastermind/_protocol.md +4 -4
  4. package/.claude/skills/mastermind/architect.md +4 -7
  5. package/.claude/skills/mastermind/autodev.md +2 -4
  6. package/.claude/skills/mastermind/build.md +3 -3
  7. package/.claude/skills/mastermind/content.md +3 -3
  8. package/.claude/skills/mastermind/createorg.md +2 -2
  9. package/.claude/skills/mastermind/finance.md +3 -3
  10. package/.claude/skills/mastermind/idea.md +0 -8
  11. package/.claude/skills/mastermind/marketing.md +3 -3
  12. package/.claude/skills/mastermind/monitor.md +2 -2
  13. package/.claude/skills/mastermind/ops.md +3 -3
  14. package/.claude/skills/mastermind/release.md +3 -3
  15. package/.claude/skills/mastermind/research.md +3 -3
  16. package/.claude/skills/mastermind/review.md +3 -3
  17. package/.claude/skills/mastermind/sales.md +3 -3
  18. package/README.md +286 -129
  19. package/dist/src/agents/halt-signal.d.ts +25 -0
  20. package/dist/src/agents/halt-signal.d.ts.map +1 -0
  21. package/dist/src/agents/halt-signal.js +76 -0
  22. package/dist/src/agents/halt-signal.js.map +1 -0
  23. package/dist/src/agents/index.d.ts +18 -0
  24. package/dist/src/agents/index.d.ts.map +1 -0
  25. package/dist/src/agents/index.js +13 -0
  26. package/dist/src/agents/index.js.map +1 -0
  27. package/dist/src/agents/managed-agent.d.ts +41 -0
  28. package/dist/src/agents/managed-agent.d.ts.map +1 -0
  29. package/dist/src/agents/managed-agent.js +69 -0
  30. package/dist/src/agents/managed-agent.js.map +1 -0
  31. package/dist/src/agents/prompt-experiment.d.ts +23 -0
  32. package/dist/src/agents/prompt-experiment.d.ts.map +1 -0
  33. package/dist/src/agents/prompt-experiment.js +49 -0
  34. package/dist/src/agents/prompt-experiment.js.map +1 -0
  35. package/dist/src/agents/prompt-version-manager.d.ts +22 -0
  36. package/dist/src/agents/prompt-version-manager.d.ts.map +1 -0
  37. package/dist/src/agents/prompt-version-manager.js +80 -0
  38. package/dist/src/agents/prompt-version-manager.js.map +1 -0
  39. package/dist/src/agents/registry-query.d.ts +71 -0
  40. package/dist/src/agents/registry-query.d.ts.map +1 -0
  41. package/dist/src/agents/registry-query.js +125 -0
  42. package/dist/src/agents/registry-query.js.map +1 -0
  43. package/dist/src/agents/score-decay.d.ts +19 -0
  44. package/dist/src/agents/score-decay.d.ts.map +1 -0
  45. package/dist/src/agents/score-decay.js +22 -0
  46. package/dist/src/agents/score-decay.js.map +1 -0
  47. package/dist/src/agents/shared-instructions-loader.d.ts +13 -0
  48. package/dist/src/agents/shared-instructions-loader.d.ts.map +1 -0
  49. package/dist/src/agents/shared-instructions-loader.js +40 -0
  50. package/dist/src/agents/shared-instructions-loader.js.map +1 -0
  51. package/dist/src/agents/specialization-scorer.d.ts +54 -0
  52. package/dist/src/agents/specialization-scorer.d.ts.map +1 -0
  53. package/dist/src/agents/specialization-scorer.js +212 -0
  54. package/dist/src/agents/specialization-scorer.js.map +1 -0
  55. package/dist/src/agents/termination-watcher.d.ts +30 -0
  56. package/dist/src/agents/termination-watcher.d.ts.map +1 -0
  57. package/dist/src/agents/termination-watcher.js +84 -0
  58. package/dist/src/agents/termination-watcher.js.map +1 -0
  59. package/dist/src/agents/trigger-index.d.ts +20 -0
  60. package/dist/src/agents/trigger-index.d.ts.map +1 -0
  61. package/dist/src/agents/trigger-index.js +38 -0
  62. package/dist/src/agents/trigger-index.js.map +1 -0
  63. package/dist/src/agents/trigger-scanner.d.ts +64 -0
  64. package/dist/src/agents/trigger-scanner.d.ts.map +1 -0
  65. package/dist/src/agents/trigger-scanner.js +308 -0
  66. package/dist/src/agents/trigger-scanner.js.map +1 -0
  67. package/dist/src/agents/version-diff.d.ts +18 -0
  68. package/dist/src/agents/version-diff.d.ts.map +1 -0
  69. package/dist/src/agents/version-diff.js +64 -0
  70. package/dist/src/agents/version-diff.js.map +1 -0
  71. package/dist/src/agents/version-store.d.ts +60 -0
  72. package/dist/src/agents/version-store.d.ts.map +1 -0
  73. package/dist/src/agents/version-store.js +235 -0
  74. package/dist/src/agents/version-store.js.map +1 -0
  75. package/dist/src/benchmarks/pretrain/index.d.ts +45 -0
  76. package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
  77. package/dist/src/benchmarks/pretrain/index.js +404 -0
  78. package/dist/src/benchmarks/pretrain/index.js.map +1 -0
  79. package/dist/src/commands/agent-wasm.d.ts +14 -0
  80. package/dist/src/commands/agent-wasm.d.ts.map +1 -0
  81. package/dist/src/commands/agent-wasm.js +333 -0
  82. package/dist/src/commands/agent-wasm.js.map +1 -0
  83. package/dist/src/commands/doctor.d.ts.map +1 -1
  84. package/dist/src/commands/doctor.js +118 -13
  85. package/dist/src/commands/doctor.js.map +1 -1
  86. package/dist/src/commands/embeddings.d.ts.map +1 -0
  87. package/dist/src/commands/embeddings.js.map +1 -0
  88. package/dist/src/commands/ui.js +68 -0
  89. package/dist/src/consensus/index.d.ts +7 -0
  90. package/dist/src/consensus/index.d.ts.map +1 -0
  91. package/dist/src/consensus/index.js +6 -0
  92. package/dist/src/consensus/index.js.map +1 -0
  93. package/dist/src/context/context-provider.d.ts +44 -0
  94. package/dist/src/context/context-provider.d.ts.map +1 -0
  95. package/dist/src/context/context-provider.js +25 -0
  96. package/dist/src/context/context-provider.js.map +1 -0
  97. package/dist/src/context/git-state-provider.d.ts +12 -0
  98. package/dist/src/context/git-state-provider.d.ts.map +1 -0
  99. package/dist/src/context/git-state-provider.js +34 -0
  100. package/dist/src/context/git-state-provider.js.map +1 -0
  101. package/dist/src/context/index.d.ts +12 -0
  102. package/dist/src/context/index.d.ts.map +1 -0
  103. package/dist/src/context/index.js +12 -0
  104. package/dist/src/context/index.js.map +1 -0
  105. package/dist/src/context/project-conventions-provider.d.ts +15 -0
  106. package/dist/src/context/project-conventions-provider.d.ts.map +1 -0
  107. package/dist/src/context/project-conventions-provider.js +19 -0
  108. package/dist/src/context/project-conventions-provider.js.map +1 -0
  109. package/dist/src/context/prompt-assembler.d.ts +26 -0
  110. package/dist/src/context/prompt-assembler.d.ts.map +1 -0
  111. package/dist/src/context/prompt-assembler.js +93 -0
  112. package/dist/src/context/prompt-assembler.js.map +1 -0
  113. package/dist/src/context/task-history-provider.d.ts +24 -0
  114. package/dist/src/context/task-history-provider.d.ts.map +1 -0
  115. package/dist/src/context/task-history-provider.js +32 -0
  116. package/dist/src/context/task-history-provider.js.map +1 -0
  117. package/dist/src/context/user-preferences-provider.d.ts +14 -0
  118. package/dist/src/context/user-preferences-provider.d.ts.map +1 -0
  119. package/dist/src/context/user-preferences-provider.js +27 -0
  120. package/dist/src/context/user-preferences-provider.js.map +1 -0
  121. package/dist/src/dlq/dlq-reader.d.ts +31 -0
  122. package/dist/src/dlq/dlq-reader.d.ts.map +1 -0
  123. package/dist/src/dlq/dlq-reader.js +81 -0
  124. package/dist/src/dlq/dlq-reader.js.map +1 -0
  125. package/dist/src/dlq/dlq-writer.d.ts +24 -0
  126. package/dist/src/dlq/dlq-writer.d.ts.map +1 -0
  127. package/dist/src/dlq/dlq-writer.js +65 -0
  128. package/dist/src/dlq/dlq-writer.js.map +1 -0
  129. package/dist/src/dlq/index.d.ts +10 -0
  130. package/dist/src/dlq/index.d.ts.map +1 -0
  131. package/dist/src/dlq/index.js +7 -0
  132. package/dist/src/dlq/index.js.map +1 -0
  133. package/dist/src/eval/dataset-manager.d.ts +33 -0
  134. package/dist/src/eval/dataset-manager.d.ts.map +1 -0
  135. package/dist/src/eval/dataset-manager.js +107 -0
  136. package/dist/src/eval/dataset-manager.js.map +1 -0
  137. package/dist/src/eval/dataset-runner.d.ts +23 -0
  138. package/dist/src/eval/dataset-runner.d.ts.map +1 -0
  139. package/dist/src/eval/dataset-runner.js +59 -0
  140. package/dist/src/eval/dataset-runner.js.map +1 -0
  141. package/dist/src/eval/index.d.ts +10 -0
  142. package/dist/src/eval/index.d.ts.map +1 -0
  143. package/dist/src/eval/index.js +7 -0
  144. package/dist/src/eval/index.js.map +1 -0
  145. package/dist/src/eval/trace-collector.d.ts +40 -0
  146. package/dist/src/eval/trace-collector.d.ts.map +1 -0
  147. package/dist/src/eval/trace-collector.js +102 -0
  148. package/dist/src/eval/trace-collector.js.map +1 -0
  149. package/dist/src/graph/enrich.mjs +362 -0
  150. package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  151. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
  152. package/dist/src/infrastructure/in-memory-repositories.js +264 -0
  153. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -0
  154. package/dist/src/init/statusline-generator.js +3 -3
  155. package/dist/src/interactive/interrupt.d.ts +22 -0
  156. package/dist/src/interactive/interrupt.d.ts.map +1 -0
  157. package/dist/src/interactive/interrupt.js +71 -0
  158. package/dist/src/interactive/interrupt.js.map +1 -0
  159. package/dist/src/mcp/deprecation-injector.d.ts +25 -0
  160. package/dist/src/mcp/deprecation-injector.d.ts.map +1 -0
  161. package/dist/src/mcp/deprecation-injector.js +48 -0
  162. package/dist/src/mcp/deprecation-injector.js.map +1 -0
  163. package/dist/src/mcp/tool-registry.d.ts +61 -0
  164. package/dist/src/mcp/tool-registry.d.ts.map +1 -0
  165. package/dist/src/mcp/tool-registry.js +246 -0
  166. package/dist/src/mcp/tool-registry.js.map +1 -0
  167. package/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
  168. package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +1 -0
  169. package/dist/src/mcp-tools/wasm-agent-tools.js +230 -0
  170. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -0
  171. package/dist/src/model/complexity-scorer.d.ts +21 -0
  172. package/dist/src/model/complexity-scorer.d.ts.map +1 -0
  173. package/dist/src/model/complexity-scorer.js +106 -0
  174. package/dist/src/model/complexity-scorer.js.map +1 -0
  175. package/dist/src/model/index.d.ts +4 -0
  176. package/dist/src/model/index.d.ts.map +1 -0
  177. package/dist/src/model/index.js +4 -0
  178. package/dist/src/model/index.js.map +1 -0
  179. package/dist/src/model/model-settings.d.ts +22 -0
  180. package/dist/src/model/model-settings.d.ts.map +1 -0
  181. package/dist/src/model/model-settings.js +33 -0
  182. package/dist/src/model/model-settings.js.map +1 -0
  183. package/dist/src/model/model-tier-resolver.d.ts +24 -0
  184. package/dist/src/model/model-tier-resolver.d.ts.map +1 -0
  185. package/dist/src/model/model-tier-resolver.js +65 -0
  186. package/dist/src/model/model-tier-resolver.js.map +1 -0
  187. package/dist/src/monovector/capabilities.d.ts +34 -0
  188. package/dist/src/monovector/capabilities.d.ts.map +1 -0
  189. package/dist/src/monovector/capabilities.js +37 -0
  190. package/dist/src/monovector/capabilities.js.map +1 -0
  191. package/dist/src/observability/replay-reader.d.ts +1 -1
  192. package/dist/src/observability/replay-reader.d.ts.map +1 -1
  193. package/dist/src/orchestration/index.d.ts +7 -0
  194. package/dist/src/orchestration/index.d.ts.map +1 -0
  195. package/dist/src/orchestration/index.js +6 -0
  196. package/dist/src/orchestration/index.js.map +1 -0
  197. package/dist/src/orchestration/mode-dispatcher.d.ts +11 -0
  198. package/dist/src/orchestration/mode-dispatcher.d.ts.map +1 -0
  199. package/dist/src/orchestration/mode-dispatcher.js +31 -0
  200. package/dist/src/orchestration/mode-dispatcher.js.map +1 -0
  201. package/dist/src/orchestration/routing-modes.d.ts +68 -0
  202. package/dist/src/orchestration/routing-modes.d.ts.map +1 -0
  203. package/dist/src/orchestration/routing-modes.js +180 -0
  204. package/dist/src/orchestration/routing-modes.js.map +1 -0
  205. package/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
  206. package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +1 -0
  207. package/dist/src/plugins/tests/demo-plugin-store.js +126 -0
  208. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -0
  209. package/dist/src/plugins/tests/standalone-test.d.ts +12 -0
  210. package/dist/src/plugins/tests/standalone-test.d.ts.map +1 -0
  211. package/dist/src/plugins/tests/standalone-test.js +188 -0
  212. package/dist/src/plugins/tests/standalone-test.js.map +1 -0
  213. package/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
  214. package/dist/src/plugins/tests/test-plugin-store.d.ts.map +1 -0
  215. package/dist/src/plugins/tests/test-plugin-store.js +206 -0
  216. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -0
  217. package/dist/src/runtime/headless.d.ts +60 -0
  218. package/dist/src/runtime/headless.d.ts.map +1 -0
  219. package/dist/src/runtime/headless.js +284 -0
  220. package/dist/src/runtime/headless.js.map +1 -0
  221. package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
  222. package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
  223. package/dist/src/services/agentic-flow-bridge.js +95 -0
  224. package/dist/src/services/agentic-flow-bridge.js.map +1 -0
  225. package/dist/src/services/container-worker-pool.d.ts +197 -0
  226. package/dist/src/services/container-worker-pool.d.ts.map +1 -0
  227. package/dist/src/services/container-worker-pool.js +623 -0
  228. package/dist/src/services/container-worker-pool.js.map +1 -0
  229. package/dist/src/services/index.d.ts +13 -0
  230. package/dist/src/services/index.d.ts.map +1 -0
  231. package/dist/src/services/index.js +11 -0
  232. package/dist/src/services/index.js.map +1 -0
  233. package/dist/src/services/worker-queue.d.ts +201 -0
  234. package/dist/src/services/worker-queue.d.ts.map +1 -0
  235. package/dist/src/services/worker-queue.js +594 -0
  236. package/dist/src/services/worker-queue.js.map +1 -0
  237. package/dist/src/swarm/communication-graph.d.ts +25 -0
  238. package/dist/src/swarm/communication-graph.d.ts.map +1 -0
  239. package/dist/src/swarm/communication-graph.js +77 -0
  240. package/dist/src/swarm/communication-graph.js.map +1 -0
  241. package/dist/src/swarm/flow-enforcer.d.ts +31 -0
  242. package/dist/src/swarm/flow-enforcer.d.ts.map +1 -0
  243. package/dist/src/swarm/flow-enforcer.js +61 -0
  244. package/dist/src/swarm/flow-enforcer.js.map +1 -0
  245. package/dist/src/swarm/flow-visualizer.d.ts +19 -0
  246. package/dist/src/swarm/flow-visualizer.d.ts.map +1 -0
  247. package/dist/src/swarm/flow-visualizer.js +68 -0
  248. package/dist/src/swarm/flow-visualizer.js.map +1 -0
  249. package/dist/src/transfer/deploy-seraphine.d.ts +13 -0
  250. package/dist/src/transfer/deploy-seraphine.d.ts.map +1 -0
  251. package/dist/src/transfer/deploy-seraphine.js +205 -0
  252. package/dist/src/transfer/deploy-seraphine.js.map +1 -0
  253. package/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
  254. package/dist/src/transfer/store/tests/standalone-test.d.ts.map +1 -0
  255. package/dist/src/transfer/store/tests/standalone-test.js +190 -0
  256. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -0
  257. package/dist/src/transfer/test-seraphine.d.ts +6 -0
  258. package/dist/src/transfer/test-seraphine.d.ts.map +1 -0
  259. package/dist/src/transfer/test-seraphine.js +105 -0
  260. package/dist/src/transfer/test-seraphine.js.map +1 -0
  261. package/dist/src/transfer/tests/test-store.d.ts +7 -0
  262. package/dist/src/transfer/tests/test-store.d.ts.map +1 -0
  263. package/dist/src/transfer/tests/test-store.js +214 -0
  264. package/dist/src/transfer/tests/test-store.js.map +1 -0
  265. package/dist/src/ui/collector.mjs +755 -0
  266. package/dist/src/ui/dashboard.html +10639 -0
  267. package/dist/src/ui/data/agent-avatars.html +763 -0
  268. package/dist/src/ui/data/agent-avatars.json +966 -0
  269. package/dist/src/ui/data/avatars/account-strategist.svg +58 -0
  270. package/dist/src/ui/data/avatars/accounts-payable.svg +54 -0
  271. package/dist/src/ui/data/avatars/adaptive-coordinator.svg +55 -0
  272. package/dist/src/ui/data/avatars/adaptive-coordinator2.svg +54 -0
  273. package/dist/src/ui/data/avatars/ai-citation.svg +57 -0
  274. package/dist/src/ui/data/avatars/ai-engineer.svg +61 -0
  275. package/dist/src/ui/data/avatars/analytics-reporter.svg +53 -0
  276. package/dist/src/ui/data/avatars/api-tester.svg +53 -0
  277. package/dist/src/ui/data/avatars/architecture.svg +54 -0
  278. package/dist/src/ui/data/avatars/automation-governance.svg +55 -0
  279. package/dist/src/ui/data/avatars/backend-dev.svg +53 -0
  280. package/dist/src/ui/data/avatars/benchmarker.svg +54 -0
  281. package/dist/src/ui/data/avatars/blockchain-auditor.svg +53 -0
  282. package/dist/src/ui/data/avatars/byzantine-coord.svg +57 -0
  283. package/dist/src/ui/data/avatars/case-analyst.svg +57 -0
  284. package/dist/src/ui/data/avatars/cicd-engineer.svg +55 -0
  285. package/dist/src/ui/data/avatars/cloud-architect.svg +54 -0
  286. package/dist/src/ui/data/avatars/code-review-swarm.svg +57 -0
  287. package/dist/src/ui/data/avatars/coder-v119.svg +57 -0
  288. package/dist/src/ui/data/avatars/coder.svg +58 -0
  289. package/dist/src/ui/data/avatars/collective-coord.svg +54 -0
  290. package/dist/src/ui/data/avatars/compliance-auditor.svg +58 -0
  291. package/dist/src/ui/data/avatars/consensus-coordinator.svg +54 -0
  292. package/dist/src/ui/data/avatars/content-creator.svg +54 -0
  293. package/dist/src/ui/data/avatars/crdt-synchronizer.svg +53 -0
  294. package/dist/src/ui/data/avatars/cro-specialist.svg +58 -0
  295. package/dist/src/ui/data/avatars/data-consolidator.svg +54 -0
  296. package/dist/src/ui/data/avatars/data-engineer.svg +53 -0
  297. package/dist/src/ui/data/avatars/database-optimizer.svg +61 -0
  298. package/dist/src/ui/data/avatars/deal-strategist.svg +54 -0
  299. package/dist/src/ui/data/avatars/defender.svg +53 -0
  300. package/dist/src/ui/data/avatars/devops-automator.svg +56 -0
  301. package/dist/src/ui/data/avatars/discovery-coach.svg +54 -0
  302. package/dist/src/ui/data/avatars/email-marketing.svg +57 -0
  303. package/dist/src/ui/data/avatars/embedded-firmware.svg +61 -0
  304. package/dist/src/ui/data/avatars/evidence-collector.svg +57 -0
  305. package/dist/src/ui/data/avatars/experiment-tracker.svg +53 -0
  306. package/dist/src/ui/data/avatars/feedback-synthesizer.svg +54 -0
  307. package/dist/src/ui/data/avatars/finance-tracker.svg +54 -0
  308. package/dist/src/ui/data/avatars/frontend-developer.svg +54 -0
  309. package/dist/src/ui/data/avatars/game-audio-engineer.svg +59 -0
  310. package/dist/src/ui/data/avatars/game-designer.svg +54 -0
  311. package/dist/src/ui/data/avatars/gossip-coordinator.svg +54 -0
  312. package/dist/src/ui/data/avatars/hierarchical-coord.svg +54 -0
  313. package/dist/src/ui/data/avatars/incident-commander.svg +57 -0
  314. package/dist/src/ui/data/avatars/infrastructure.svg +54 -0
  315. package/dist/src/ui/data/avatars/input-validator.svg +53 -0
  316. package/dist/src/ui/data/avatars/ios-developer.svg +54 -0
  317. package/dist/src/ui/data/avatars/issue-tracker.svg +53 -0
  318. package/dist/src/ui/data/avatars/judge.svg +55 -0
  319. package/dist/src/ui/data/avatars/launch-strategist.svg +54 -0
  320. package/dist/src/ui/data/avatars/legal-compliance.svg +53 -0
  321. package/dist/src/ui/data/avatars/level-designer.svg +53 -0
  322. package/dist/src/ui/data/avatars/load-balancer.svg +57 -0
  323. package/dist/src/ui/data/avatars/mcp-builder.svg +53 -0
  324. package/dist/src/ui/data/avatars/memory-coordinator.svg +55 -0
  325. package/dist/src/ui/data/avatars/mesh-coordinator.svg +55 -0
  326. package/dist/src/ui/data/avatars/ml-developer.svg +58 -0
  327. package/dist/src/ui/data/avatars/mobile-app-builder.svg +53 -0
  328. package/dist/src/ui/data/avatars/mobile-dev.svg +54 -0
  329. package/dist/src/ui/data/avatars/model-qa.svg +58 -0
  330. package/dist/src/ui/data/avatars/narrative-designer.svg +58 -0
  331. package/dist/src/ui/data/avatars/outbound-strategist.svg +55 -0
  332. package/dist/src/ui/data/avatars/path-validator.svg +54 -0
  333. package/dist/src/ui/data/avatars/payment-agent.svg +53 -0
  334. package/dist/src/ui/data/avatars/perf-analyzer.svg +58 -0
  335. package/dist/src/ui/data/avatars/pipeline-analyst.svg +54 -0
  336. package/dist/src/ui/data/avatars/planner.svg +55 -0
  337. package/dist/src/ui/data/avatars/pr-manager.svg +54 -0
  338. package/dist/src/ui/data/avatars/pricing-strategist.svg +54 -0
  339. package/dist/src/ui/data/avatars/product-manager.svg +54 -0
  340. package/dist/src/ui/data/avatars/production-validator.svg +54 -0
  341. package/dist/src/ui/data/avatars/project-shepherd.svg +54 -0
  342. package/dist/src/ui/data/avatars/proposal-strategist.svg +54 -0
  343. package/dist/src/ui/data/avatars/prosecutor.svg +57 -0
  344. package/dist/src/ui/data/avatars/pseudocode.svg +53 -0
  345. package/dist/src/ui/data/avatars/queen-coordinator.svg +55 -0
  346. package/dist/src/ui/data/avatars/quorum-manager.svg +53 -0
  347. package/dist/src/ui/data/avatars/raft-manager.svg +53 -0
  348. package/dist/src/ui/data/avatars/reality-checker.svg +58 -0
  349. package/dist/src/ui/data/avatars/recruitment.svg +58 -0
  350. package/dist/src/ui/data/avatars/refinement.svg +53 -0
  351. package/dist/src/ui/data/avatars/release-manager.svg +54 -0
  352. package/dist/src/ui/data/avatars/repo-architect.svg +54 -0
  353. package/dist/src/ui/data/avatars/researcher.svg +58 -0
  354. package/dist/src/ui/data/avatars/resource-allocator.svg +53 -0
  355. package/dist/src/ui/data/avatars/reviewer.svg +53 -0
  356. package/dist/src/ui/data/avatars/safe-executor.svg +53 -0
  357. package/dist/src/ui/data/avatars/sales-coach.svg +53 -0
  358. package/dist/src/ui/data/avatars/sales-engineer.svg +58 -0
  359. package/dist/src/ui/data/avatars/scout-explorer.svg +58 -0
  360. package/dist/src/ui/data/avatars/security-architect.svg +54 -0
  361. package/dist/src/ui/data/avatars/security-auditor.svg +55 -0
  362. package/dist/src/ui/data/avatars/senior-developer.svg +58 -0
  363. package/dist/src/ui/data/avatars/senior-pm.svg +58 -0
  364. package/dist/src/ui/data/avatars/seo-specialist.svg +57 -0
  365. package/dist/src/ui/data/avatars/social-media.svg +54 -0
  366. package/dist/src/ui/data/avatars/solidity-engineer.svg +58 -0
  367. package/dist/src/ui/data/avatars/sparc-coder.svg +58 -0
  368. package/dist/src/ui/data/avatars/sparc-coord.svg +56 -0
  369. package/dist/src/ui/data/avatars/specification.svg +57 -0
  370. package/dist/src/ui/data/avatars/sprint-prioritizer.svg +53 -0
  371. package/dist/src/ui/data/avatars/sre.svg +54 -0
  372. package/dist/src/ui/data/avatars/studio-operations.svg +53 -0
  373. package/dist/src/ui/data/avatars/studio-producer.svg +55 -0
  374. package/dist/src/ui/data/avatars/support-responder.svg +56 -0
  375. package/dist/src/ui/data/avatars/system-architect.svg +54 -0
  376. package/dist/src/ui/data/avatars/task-orchestrator.svg +56 -0
  377. package/dist/src/ui/data/avatars/technical-artist.svg +53 -0
  378. package/dist/src/ui/data/avatars/technical-writer.svg +59 -0
  379. package/dist/src/ui/data/avatars/tester.svg +53 -0
  380. package/dist/src/ui/data/avatars/threat-detection.svg +61 -0
  381. package/dist/src/ui/data/avatars/trend-researcher.svg +54 -0
  382. package/dist/src/ui/data/avatars/trial-director.svg +55 -0
  383. package/dist/src/ui/data/avatars/unity-architect.svg +54 -0
  384. package/dist/src/ui/data/avatars/visionos-engineer.svg +57 -0
  385. package/dist/src/ui/data/avatars/worker-specialist.svg +55 -0
  386. package/dist/src/ui/data/avatars/workflow-architect.svg +57 -0
  387. package/dist/src/ui/data/avatars/workflow-automation.svg +54 -0
  388. package/dist/src/ui/data/avatars/zk-steward.svg +54 -0
  389. package/dist/src/ui/data/mastermind-events.jsonl +59 -0
  390. package/dist/src/ui/data/mastermind-sessions.json +1 -0
  391. package/dist/src/ui/orgs.html +1360 -0
  392. package/dist/src/ui/server.mjs +4336 -0
  393. package/dist/src/workflow/condition-evaluator.d.ts +10 -0
  394. package/dist/src/workflow/condition-evaluator.d.ts.map +1 -0
  395. package/dist/src/workflow/condition-evaluator.js +82 -0
  396. package/dist/src/workflow/condition-evaluator.js.map +1 -0
  397. package/dist/src/workflow/context-resolver.d.ts +12 -0
  398. package/dist/src/workflow/context-resolver.d.ts.map +1 -0
  399. package/dist/src/workflow/context-resolver.js +23 -0
  400. package/dist/src/workflow/context-resolver.js.map +1 -0
  401. package/dist/src/workflow/dag-builder.d.ts +17 -0
  402. package/dist/src/workflow/dag-builder.d.ts.map +1 -0
  403. package/dist/src/workflow/dag-builder.js +129 -0
  404. package/dist/src/workflow/dag-builder.js.map +1 -0
  405. package/dist/src/workflow/dag-executor.d.ts +9 -0
  406. package/dist/src/workflow/dag-executor.d.ts.map +1 -0
  407. package/dist/src/workflow/dag-executor.js +116 -0
  408. package/dist/src/workflow/dag-executor.js.map +1 -0
  409. package/dist/src/workflow/dag-types.d.ts +41 -0
  410. package/dist/src/workflow/dag-types.d.ts.map +1 -0
  411. package/dist/src/workflow/dag-types.js +8 -0
  412. package/dist/src/workflow/dag-types.js.map +1 -0
  413. package/dist/src/workflow/dsl-parser.d.ts +12 -0
  414. package/dist/src/workflow/dsl-parser.d.ts.map +1 -0
  415. package/dist/src/workflow/dsl-parser.js +20 -0
  416. package/dist/src/workflow/dsl-parser.js.map +1 -0
  417. package/dist/src/workflow/dsl-schema.d.ts +165 -0
  418. package/dist/src/workflow/dsl-schema.d.ts.map +1 -0
  419. package/dist/src/workflow/dsl-schema.js +82 -0
  420. package/dist/src/workflow/dsl-schema.js.map +1 -0
  421. package/dist/src/workflow/index.d.ts +13 -0
  422. package/dist/src/workflow/index.d.ts.map +1 -0
  423. package/dist/src/workflow/index.js +11 -0
  424. package/dist/src/workflow/index.js.map +1 -0
  425. package/dist/src/workflow/template-engine.d.ts +11 -0
  426. package/dist/src/workflow/template-engine.d.ts.map +1 -0
  427. package/dist/src/workflow/template-engine.js +40 -0
  428. package/dist/src/workflow/template-engine.js.map +1 -0
  429. package/dist/src/workflow/workflow-executor.d.ts +29 -0
  430. package/dist/src/workflow/workflow-executor.d.ts.map +1 -0
  431. package/dist/src/workflow/workflow-executor.js +227 -0
  432. package/dist/src/workflow/workflow-executor.js.map +1 -0
  433. package/dist/tsconfig.tsbuildinfo +1 -1
  434. package/package.json +9 -9
@@ -0,0 +1,755 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
4
+
5
+ // ---------------------------------------------------------------------------
6
+ // Helpers
7
+ // ---------------------------------------------------------------------------
8
+
9
+ function readJSON(filePath) {
10
+ try {
11
+ const raw = fs.readFileSync(filePath, 'utf8');
12
+ return JSON.parse(raw);
13
+ } catch {
14
+ return null;
15
+ }
16
+ }
17
+
18
+ function readJSONL(filePath, last) {
19
+ try {
20
+ const raw = fs.readFileSync(filePath, 'utf8');
21
+ const lines = raw.split('\n').filter(Boolean);
22
+ const slice = last != null ? lines.slice(-last) : lines;
23
+ return slice.map(line => {
24
+ try {
25
+ return JSON.parse(line);
26
+ } catch {
27
+ return null;
28
+ }
29
+ }).filter(Boolean);
30
+ } catch {
31
+ return [];
32
+ }
33
+ }
34
+
35
+ function countJSONLLines(filePath) {
36
+ try {
37
+ const raw = fs.readFileSync(filePath, 'utf8');
38
+ return raw.split('\n').filter(Boolean).length;
39
+ } catch {
40
+ return 0;
41
+ }
42
+ }
43
+
44
+ function fileExists(filePath) {
45
+ try {
46
+ fs.accessSync(filePath);
47
+ return true;
48
+ } catch {
49
+ return false;
50
+ }
51
+ }
52
+
53
+ function fileStat(filePath) {
54
+ try {
55
+ return fs.statSync(filePath);
56
+ } catch {
57
+ return null;
58
+ }
59
+ }
60
+
61
+ function listDir(dirPath) {
62
+ try {
63
+ return fs.readdirSync(dirPath);
64
+ } catch {
65
+ return [];
66
+ }
67
+ }
68
+
69
+ // ---------------------------------------------------------------------------
70
+ // Section collectors
71
+ // ---------------------------------------------------------------------------
72
+
73
+ function collectProject(projectDir) {
74
+ let name = path.basename(projectDir);
75
+ const pkgPath = path.join(projectDir, 'package.json');
76
+ const pkg = readJSON(pkgPath);
77
+ if (pkg && pkg.name) {
78
+ name = pkg.name;
79
+ }
80
+ return { dir: projectDir, name };
81
+ }
82
+
83
+ function getClaudeProjectSessionsDir(projectDir) {
84
+ // Claude Code stores sessions in ~/.claude/projects/<slug>/ not in the project itself
85
+ const homeDir = os.homedir();
86
+ const slug = projectDir.replace(/\//g, '-');
87
+ const globalSessions = path.join(homeDir, '.claude', 'projects', slug);
88
+ if (fs.existsSync(globalSessions)) return globalSessions;
89
+ // Fallback to local .claude/sessions
90
+ return path.join(projectDir, '.claude', 'sessions');
91
+ }
92
+
93
+ function collectSessions(projectDir) {
94
+ const sessionsDir = getClaudeProjectSessionsDir(projectDir);
95
+ const entries = listDir(sessionsDir);
96
+ const list = entries
97
+ .filter(f => f.endsWith('.json') || f.endsWith('.jsonl'))
98
+ .map(f => {
99
+ const filePath = path.join(sessionsDir, f);
100
+ const stat = fileStat(filePath);
101
+ const id = path.basename(f, path.extname(f));
102
+ return {
103
+ id,
104
+ file: filePath,
105
+ mtime: stat ? stat.mtimeMs : null,
106
+ size: stat ? stat.size : null
107
+ };
108
+ })
109
+ .sort((a, b) => (b.mtime || 0) - (a.mtime || 0));
110
+
111
+ const memFiles = collectMemoryFiles(projectDir);
112
+
113
+ return {
114
+ list,
115
+ count: list.length,
116
+ palace: {
117
+ count: memFiles.length
118
+ }
119
+ };
120
+ }
121
+
122
+ const _appendedSwarmIds = new Set();
123
+
124
+ function collectSwarm(projectDir) {
125
+ const base = path.join(projectDir, '.monomind');
126
+ const state = readJSON(path.join(base, 'swarm', 'swarm-state.json')) || {};
127
+ const dotSwarmState = readJSON(path.join(projectDir, '.swarm', 'state.json')) || {};
128
+ const merged = { ...dotSwarmState, ...state };
129
+
130
+ const terminalStatuses = ['stopped', 'terminated', 'completed', 'error'];
131
+ const swarmId = merged.swarmId || merged.id;
132
+ if (swarmId && terminalStatuses.includes(merged.status) && !_appendedSwarmIds.has(swarmId)) {
133
+ _appendedSwarmIds.add(swarmId);
134
+ const agents = (merged.agents || merged.agentPlan || []).map(a => ({
135
+ id: a.id || a.type || a.role,
136
+ type: a.type || a.role || '?',
137
+ role: a.role || 'worker',
138
+ tasksCompleted: a.tasksCompleted || a.count || 0,
139
+ tasksFailed: a.tasksFailed || 0,
140
+ messageCount: a.messageCount || 0,
141
+ utilization: a.utilization || 0,
142
+ }));
143
+ const entry = {
144
+ swarmId,
145
+ topology: merged.topology || '—',
146
+ consensus: merged.consensus || '—',
147
+ strategy: merged.strategy || '—',
148
+ status: merged.status,
149
+ agents,
150
+ messages: merged.messages || [],
151
+ errors: merged.errors || [],
152
+ findings: merged.findings || [],
153
+ taskCount: merged.taskCount || 0,
154
+ completedTasks: merged.completedTasks || 0,
155
+ failedTasks: merged.failedTasks || 0,
156
+ startedAt: merged.startedAt || merged.createdAt || new Date().toISOString(),
157
+ endedAt: merged.stoppedAt || merged.endedAt || new Date().toISOString(),
158
+ durationMs: 0,
159
+ };
160
+ if (entry.startedAt && entry.endedAt) {
161
+ entry.durationMs = new Date(entry.endedAt).getTime() - new Date(entry.startedAt).getTime();
162
+ }
163
+ try { appendSwarmHistory(projectDir, entry); } catch {}
164
+ }
165
+
166
+ return {
167
+ state: merged,
168
+ activity: readJSON(path.join(base, 'metrics', 'swarm-activity.json')) || {},
169
+ suggestion: {},
170
+ config: readJSON(path.join(base, 'swarm-config.json')) || {},
171
+ };
172
+ }
173
+
174
+ function collectSwarmHistory(projectDir) {
175
+ const historyPath = path.join(projectDir, '.monomind', 'swarm', 'history.jsonl');
176
+ const byId = new Map();
177
+
178
+ // 1. Persisted history (if any swarm ever appended on terminal status)
179
+ for (const e of readJSONL(historyPath)) {
180
+ const id = e && (e.swarmId || e.id);
181
+ if (id) byId.set(id, e);
182
+ }
183
+
184
+ // 2. Derive from the live swarm-state.json. The writer stores a NESTED
185
+ // { swarms: { <id>: {...} } } map, but collectSwarm() only appends to
186
+ // history.jsonl when a FLAT top-level swarmId/status is present — which
187
+ // this format never has. So without this fallback the tab is empty even
188
+ // though swarms exist. Derive entries directly from the map here.
189
+ try {
190
+ const state = readJSON(path.join(projectDir, '.monomind', 'swarm', 'swarm-state.json')) || {};
191
+ const swarmsMap = state.swarms || (state.swarmId ? { [state.swarmId]: state } : {});
192
+ for (const [key, s] of Object.entries(swarmsMap)) {
193
+ if (!s || typeof s !== 'object') continue;
194
+ const sid = s.swarmId || s.id || key;
195
+ if (byId.has(sid)) continue; // a real history entry wins over derived
196
+ const cfg = s.config || {};
197
+ const agents = Array.isArray(s.agents) ? s.agents : [];
198
+ byId.set(sid, {
199
+ swarmId: sid,
200
+ topology: s.topology || cfg.topology || '—',
201
+ consensus: s.consensus || cfg.consensusMechanism || '—',
202
+ strategy: s.strategy || cfg.strategy || '—',
203
+ status: s.status || 'unknown',
204
+ agentCount: agents.length || s.maxAgents || cfg.maxAgents || 0,
205
+ agents,
206
+ taskCount: Array.isArray(s.tasks) ? s.tasks.length : (s.taskCount || 0),
207
+ startedAt: s.createdAt || s.startedAt || null,
208
+ endedAt: s.updatedAt || s.endedAt || null,
209
+ derived: true,
210
+ });
211
+ }
212
+ } catch {}
213
+
214
+ // newest-first
215
+ return Array.from(byId.values()).sort((a, b) =>
216
+ new Date(b.startedAt || 0).getTime() - new Date(a.startedAt || 0).getTime());
217
+ }
218
+
219
+ function appendSwarmHistory(projectDir, entry) {
220
+ const dir = path.join(projectDir, '.monomind', 'swarm');
221
+ if (!fs.existsSync(dir)) {
222
+ fs.mkdirSync(dir, { recursive: true });
223
+ }
224
+ const historyPath = path.join(dir, 'history.jsonl');
225
+ fs.appendFileSync(historyPath, JSON.stringify(entry) + '\n');
226
+ }
227
+
228
+ function collectSwarmEvents(projectDir, opts = {}) {
229
+ const eventsPath = path.join(projectDir, '.monomind', 'swarm', 'events.jsonl');
230
+ const events = readJSONL(eventsPath, opts.last || null);
231
+ if (opts.swarmId) return events.filter(e => e.swarmId === opts.swarmId);
232
+ if (opts.agentId) return events.filter(e => e.agentId === opts.agentId);
233
+ return events;
234
+ }
235
+
236
+ function getSwarmDataSize(projectDir) {
237
+ const dir = path.join(projectDir, '.monomind', 'swarm');
238
+ let totalBytes = 0;
239
+ let fileCount = 0;
240
+ const files = ['history.jsonl', 'events.jsonl'];
241
+ for (const f of files) {
242
+ const stat = fileStat(path.join(dir, f));
243
+ if (stat) { totalBytes += stat.size; fileCount++; }
244
+ }
245
+ return { totalBytes, fileCount, humanSize: totalBytes < 1024 ? totalBytes + ' B' : totalBytes < 1048576 ? (totalBytes / 1024).toFixed(1) + ' KB' : (totalBytes / 1048576).toFixed(1) + ' MB' };
246
+ }
247
+
248
+ function cleanSwarmData(projectDir) {
249
+ const dir = path.join(projectDir, '.monomind', 'swarm');
250
+ const files = ['history.jsonl', 'events.jsonl'];
251
+ let removed = 0;
252
+ for (const f of files) {
253
+ const fp = path.join(dir, f);
254
+ try { fs.unlinkSync(fp); removed++; } catch {}
255
+ }
256
+ _appendedSwarmIds.clear();
257
+ return { removed, files };
258
+ }
259
+
260
+ function collectAgents(projectDir) {
261
+ const base = path.join(projectDir, '.monomind');
262
+ const regsDir = path.join(base, 'agents', 'registrations');
263
+ const regFiles = listDir(regsDir).filter(f => f.endsWith('.json'));
264
+ const registrations = regFiles.map(f => {
265
+ return readJSON(path.join(regsDir, f));
266
+ }).filter(Boolean);
267
+
268
+ const registry = readJSON(path.join(base, 'registry.json')) || {};
269
+
270
+ return {
271
+ registrations,
272
+ registry,
273
+ count: registrations.length
274
+ };
275
+ }
276
+
277
+ const _TOK_PRICES = {
278
+ 'claude-opus-4-6': { in: 5e-6, out: 25e-6, cw: 6.25e-6, cr: 0.5e-6 },
279
+ 'claude-opus-4': { in: 15e-6, out: 75e-6, cw: 18.75e-6,cr: 1.5e-6 },
280
+ 'claude-sonnet-4-6': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
281
+ 'claude-sonnet-4-5': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
282
+ 'claude-sonnet-4': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
283
+ 'claude-3-7-sonnet': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
284
+ 'claude-3-5-sonnet': { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 },
285
+ 'claude-haiku-4-5': { in: 1e-6, out: 5e-6, cw: 1.25e-6, cr: 0.1e-6 },
286
+ 'claude-3-5-haiku': { in: 0.8e-6, out: 4e-6, cw: 1e-6, cr: 0.08e-6 },
287
+ };
288
+ function _tokPrice(model) {
289
+ const k = (model || '').replace(/@.*$/, '').replace(/-\d{8}$/, '');
290
+ if (_TOK_PRICES[k]) return _TOK_PRICES[k];
291
+ for (const p of Object.keys(_TOK_PRICES)) { if (k.startsWith(p) || k.includes(p)) return _TOK_PRICES[p]; }
292
+ return { in: 3e-6, out: 15e-6, cw: 3.75e-6, cr: 0.3e-6 }; // sonnet default
293
+ }
294
+ function _tokCost(model, usage) {
295
+ const p = _tokPrice(model);
296
+ return (usage.input_tokens || 0) * p.in
297
+ + (usage.output_tokens || 0) * p.out
298
+ + (usage.cache_creation_input_tokens || 0) * p.cw
299
+ + (usage.cache_read_input_tokens || 0) * p.cr;
300
+ }
301
+
302
+ function collectTokens(projectDir, days = 14) {
303
+ const base = path.join(projectDir, '.monomind', 'metrics');
304
+ const summary = readJSON(path.join(base, 'token-summary.json')) || {};
305
+
306
+ // Scan session JSONLs to build daily chart data and per-session rows
307
+ const sessionsDir = getClaudeProjectSessionsDir(projectDir);
308
+ const jsonlFiles = listDir(sessionsDir).filter(f => f.endsWith('.jsonl'));
309
+
310
+ const dailyMap = {}; // date-string → { cost, calls, tokensIn, tokensOut }
311
+ const rows = []; // per-session summary
312
+ let totalTokensIn = 0, totalTokensOut = 0;
313
+
314
+ // Cutoff: look back `days` days
315
+ const cutoff = Date.now() - days * 24 * 60 * 60 * 1000;
316
+
317
+ for (const fname of jsonlFiles) {
318
+ const fpath = path.join(sessionsDir, fname);
319
+ let stat;
320
+ try { stat = fs.statSync(fpath); } catch { continue; }
321
+ // Skip sessions that couldn't have data in the window (mtime heuristic)
322
+ if (stat.mtimeMs < cutoff - 7 * 24 * 60 * 60 * 1000) continue;
323
+
324
+ let content;
325
+ try { content = fs.readFileSync(fpath, 'utf8'); } catch { continue; }
326
+
327
+ const lines = content.split('\n');
328
+ let sessTokensIn = 0, sessTokensOut = 0, sessCost = 0, sessCalls = 0;
329
+ let sessLastPrompt = '';
330
+
331
+ for (const line of lines) {
332
+ if (!line.trim()) continue;
333
+ let entry;
334
+ try { entry = JSON.parse(line); } catch { continue; }
335
+
336
+ // Capture last user prompt for session label
337
+ if (entry.type === 'user') {
338
+ const txt = Array.isArray(entry.message?.content)
339
+ ? (entry.message.content.find(b => b.type === 'text')?.text || '').slice(0, 60)
340
+ : String(entry.message?.content || '').slice(0, 60);
341
+ if (txt.trim()) sessLastPrompt = txt.trim();
342
+ }
343
+
344
+ if (entry.type === 'assistant' && entry.message?.usage) {
345
+ const usage = entry.message.usage;
346
+ const model = entry.message.model || '';
347
+ const cost = _tokCost(model, usage);
348
+ const tokIn = (usage.input_tokens || 0) + (usage.cache_creation_input_tokens || 0) + (usage.cache_read_input_tokens || 0);
349
+ const tokOut = usage.output_tokens || 0;
350
+ const ts = entry.timestamp || '';
351
+ const day = ts.slice(0, 10); // "YYYY-MM-DD"
352
+
353
+ if (day && day >= new Date(cutoff).toISOString().slice(0, 10)) {
354
+ if (!dailyMap[day]) dailyMap[day] = { cost: 0, calls: 0, tokensIn: 0, tokensOut: 0 };
355
+ dailyMap[day].cost += cost;
356
+ dailyMap[day].calls++;
357
+ dailyMap[day].tokensIn += tokIn;
358
+ dailyMap[day].tokensOut += tokOut;
359
+ }
360
+
361
+ sessTokensIn += tokIn;
362
+ sessTokensOut += tokOut;
363
+ sessCost += cost;
364
+ sessCalls++;
365
+ totalTokensIn += tokIn;
366
+ totalTokensOut += tokOut;
367
+ }
368
+ }
369
+
370
+ if (sessCalls > 0) {
371
+ rows.push({
372
+ id: fname.replace('.jsonl', ''),
373
+ session: sessLastPrompt || fname.replace('.jsonl', '').slice(0, 20),
374
+ calls: sessCalls,
375
+ tokens: sessTokensIn + sessTokensOut,
376
+ cost: sessCost,
377
+ });
378
+ }
379
+ }
380
+
381
+ // Build sorted daily array
382
+ const daily = Object.keys(dailyMap).sort().slice(-days).map(d => ({
383
+ date: d,
384
+ label: d.slice(5), // "MM-DD"
385
+ cost: dailyMap[d].cost,
386
+ calls: dailyMap[d].calls,
387
+ tokensIn: dailyMap[d].tokensIn,
388
+ tokensOut: dailyMap[d].tokensOut,
389
+ }));
390
+
391
+ // Sort rows by cost descending
392
+ rows.sort((a, b) => b.cost - a.cost);
393
+
394
+ const totalTokens = totalTokensIn + totalTokensOut;
395
+ if (totalTokens > 0) summary.totalTokens = totalTokens;
396
+
397
+ return { summary, daily, rows };
398
+ }
399
+
400
+ function collectHooks(projectDir) {
401
+ const base = path.join(projectDir, '.monomind');
402
+ const lastRoute = readJSON(path.join(base, 'last-route.json')) || {};
403
+ const feedback = readJSONL(path.join(base, 'routing-feedback.jsonl'), 10);
404
+
405
+ const workerDispatchDir = path.join(base, 'worker-dispatch');
406
+ const workerDispatch = listDir(workerDispatchDir).filter(f => f.startsWith('pending-') && f.endsWith('.json'));
407
+
408
+ return { lastRoute, feedback, workerDispatch };
409
+ }
410
+
411
+ function collectKnowledge(projectDir) {
412
+ const base = path.join(projectDir, '.monomind');
413
+ const chunksPath = path.join(base, 'knowledge', 'chunks.jsonl');
414
+ const skillsPath = path.join(base, 'skills.jsonl');
415
+
416
+ // Read chunks.jsonl once; derive count and recent slice together
417
+ let chunks = 0;
418
+ let recent = [];
419
+ try {
420
+ const raw = fs.readFileSync(chunksPath, 'utf8');
421
+ const lines = raw.split('\n').filter(Boolean);
422
+ chunks = lines.length;
423
+ recent = lines.slice(-5).map(line => { try { return JSON.parse(line); } catch { return null; } }).filter(Boolean);
424
+ } catch {}
425
+ const skills = countJSONLLines(skillsPath);
426
+
427
+ return { chunks, skills, recent };
428
+ }
429
+
430
+ function collectMetrics(projectDir) {
431
+ const base = path.join(projectDir, '.monomind');
432
+ const swarmActivity = readJSON(path.join(base, 'metrics', 'swarm-activity.json')) || {};
433
+ const tokenSummary = readJSON(path.join(base, 'metrics', 'token-summary.json')) || {};
434
+
435
+ // Derive routing stats from feedback log (cap at 1000 to avoid reading unbounded file)
436
+ const feedbackAll = readJSONL(path.join(base, 'routing-feedback.jsonl'), 1000);
437
+ const routingTotal = feedbackAll.length;
438
+ let routingConfSum = 0, routingConfCount = 0;
439
+ const agentCounts = {};
440
+ for (const fb of feedbackAll) {
441
+ if (fb.confidence != null) { routingConfSum += fb.confidence; routingConfCount++; }
442
+ const a = fb.suggestedAgent || fb.agent;
443
+ if (a) agentCounts[a] = (agentCounts[a] || 0) + 1;
444
+ }
445
+ const avgConf = routingConfCount > 0 ? Math.round((routingConfSum / routingConfCount) * 100) : null;
446
+ const topAgent = Object.entries(agentCounts).sort((a, b) => b[1] - a[1])[0];
447
+
448
+ return {
449
+ routing: {
450
+ total: routingTotal,
451
+ avgConfidence: avgConf,
452
+ topAgent: topAgent ? topAgent[0] : null,
453
+ topAgentCount: topAgent ? topAgent[1] : null,
454
+ },
455
+ swarm: {
456
+ active: swarmActivity.swarm && swarmActivity.swarm.active,
457
+ agentCount: swarmActivity.swarm && swarmActivity.swarm.agent_count,
458
+ lastActive: swarmActivity.timestamp || null,
459
+ },
460
+ tokens: {
461
+ todayCost: tokenSummary.todayCost,
462
+ todayCalls: tokenSummary.todayCalls,
463
+ monthCost: tokenSummary.monthCost,
464
+ monthCalls: tokenSummary.monthCalls,
465
+ },
466
+ security: readJSON(path.join(base, 'security', 'audit-status.json')) || {}
467
+ };
468
+ }
469
+
470
+ function collectTriggers(projectDir) {
471
+ return readJSON(path.join(projectDir, '.monomind', 'trigger-index.json')) || {};
472
+ }
473
+
474
+ function collectMemoryFiles(projectDir) {
475
+ const homeDir = os.homedir();
476
+ const slug = path.resolve(projectDir).replace(/\//g, '-');
477
+ const memDir = path.join(homeDir, '.claude', 'projects', slug, 'memory');
478
+ let files = [];
479
+ try { files = fs.readdirSync(memDir).filter(f => f.endsWith('.md') && f !== 'MEMORY.md'); } catch {}
480
+ return files.map(fname => {
481
+ const fp = path.join(memDir, fname);
482
+ let raw = ''; try { raw = fs.readFileSync(fp, 'utf8').replace(/\r\n/g, '\n'); } catch {}
483
+ let name = fname.replace('.md', ''), description = '', type = 'project';
484
+ const fm = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
485
+ if (fm) {
486
+ for (const line of fm[1].split('\n')) {
487
+ const m2 = line.match(/^(\w+):\s*(.+)$/);
488
+ if (m2) {
489
+ if (m2[1] === 'name') name = m2[2].trim();
490
+ if (m2[1] === 'description') description = m2[2].trim();
491
+ if (m2[1] === 'type') type = m2[2].trim();
492
+ }
493
+ }
494
+ }
495
+ let stat = null; try { stat = fs.statSync(fp); } catch {}
496
+ return { filename: fname, name, description, type, mtime: stat ? stat.mtimeMs : null };
497
+ }).sort((a, b) => (b.mtime || 0) - (a.mtime || 0));
498
+ }
499
+
500
+ // Probe candidate paths in priority order, return first existing file's stat
501
+ function probeFile(...candidates) {
502
+ for (const p of candidates) {
503
+ const s = fileStat(p);
504
+ if (s && s.size > 0) return { path: p, size: s.size };
505
+ }
506
+ return null;
507
+ }
508
+
509
+ function collectMemory(projectDir) {
510
+ const d = path.resolve(projectDir);
511
+ const monomindDir = path.join(d, '.monomind');
512
+
513
+ // AgentDB — check all known locations across different init styles
514
+ const dbCandidates = [
515
+ path.join(d, 'data', 'memory.db'), // custom --path ./data/memory.db
516
+ path.join(d, '.swarm', 'memory.db'), // default init path
517
+ path.join(monomindDir, 'memory.db'), // legacy .monomind path
518
+ path.join(d, '.claude', 'memory.db'), // .claude dir (some setups)
519
+ ];
520
+ const dbHit = probeFile(...dbCandidates);
521
+ const dbSize = dbHit ? dbHit.size : 0;
522
+ const dbPath = dbHit ? dbHit.path : null;
523
+
524
+ // HNSW — lives alongside the DB or at the .swarm default
525
+ const hnswCandidates = dbPath ? [
526
+ path.join(path.dirname(dbPath), 'memory.graph'), // alongside DB (hybrid backend)
527
+ path.join(path.dirname(dbPath), 'hnsw.index'), // default init name
528
+ ] : [
529
+ path.join(d, 'data', 'memory.graph'),
530
+ path.join(d, '.swarm', 'hnsw.index'),
531
+ ];
532
+ const hnswHit = probeFile(...hnswCandidates);
533
+ const hnsw = !!hnswHit;
534
+
535
+ // MonoVector DB
536
+ const monovectorHit = probeFile(
537
+ path.join(monomindDir, 'data', 'monovector.db'),
538
+ path.join(d, 'data', 'monovector.db'),
539
+ );
540
+ const monovectorSize = monovectorHit ? monovectorHit.size : 0;
541
+ const monovectorExists = !!monovectorHit;
542
+
543
+ let monovectorPatterns = 0;
544
+ const ranked = readJSON(path.join(monomindDir, 'data', 'ranked-context.json'));
545
+ if (ranked && ranked.entries) monovectorPatterns = ranked.entries.length;
546
+
547
+ const files = collectMemoryFiles(projectDir);
548
+
549
+ return { dbSize, dbPath, hnsw, monovectorSize, monovectorExists, monovectorPatterns, files, count: files.length };
550
+ }
551
+
552
+ function collectSystem() {
553
+ return {
554
+ nodeVersion: process.version,
555
+ uptime: process.uptime(),
556
+ platform: process.platform,
557
+ memoryMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
558
+ };
559
+ }
560
+
561
+ // ---------------------------------------------------------------------------
562
+ // Global: all projects on this machine (~/.claude/projects/)
563
+ // ---------------------------------------------------------------------------
564
+
565
+ function slugToPath(slug) {
566
+ return resolveSlugPath(slug);
567
+ }
568
+
569
+ // Reconstruct the real filesystem path from a Claude project slug.
570
+ // Slugs encode the path with every '/' replaced by '-', which is lossy when
571
+ // directory names contain literal hyphens (e.g. /Desktop/agent-f/accounting).
572
+ // Strategy: naive replace first; if not found, greedy DFS through the filesystem
573
+ // trying longest-possible segment (with embedded hyphens) at each level.
574
+ function resolveSlugPath(slug) {
575
+ const naive = '/' + slug.replace(/^-/, '').replace(/-/g, '/');
576
+ try { if (fs.existsSync(naive)) return naive; } catch {}
577
+
578
+ const tokens = slug.replace(/^-/, '').split('-').filter(Boolean);
579
+
580
+ function walk(idx, dir) {
581
+ if (idx === tokens.length) return dir;
582
+ // Try longest span first (greedy) so "agent-f" is preferred over "agent"+"f"
583
+ for (let end = tokens.length; end > idx; end--) {
584
+ const segment = tokens.slice(idx, end).join('-');
585
+ const candidate = path.join(dir, segment);
586
+ try {
587
+ if (fs.statSync(candidate).isDirectory()) {
588
+ const result = walk(end, candidate);
589
+ if (result !== null) return result;
590
+ }
591
+ } catch {}
592
+ }
593
+ return null;
594
+ }
595
+
596
+ return walk(0, '/') || naive;
597
+ }
598
+
599
+ let _apCache = null;
600
+ let _apCacheTs = 0;
601
+ const AP_TTL = 5_000;
602
+
603
+ export function collectAllProjects() {
604
+ const now = Date.now();
605
+ if (_apCache !== null && now - _apCacheTs < AP_TTL) return _apCache;
606
+ const homeDir = os.homedir();
607
+ const projectsRoot = path.join(homeDir, '.claude', 'projects');
608
+ const result = [];
609
+
610
+ let slugs = [];
611
+ try { slugs = fs.readdirSync(projectsRoot); } catch { return result; }
612
+
613
+ for (const slug of slugs) {
614
+ const projectClaudeDir = path.join(projectsRoot, slug);
615
+ let stat;
616
+ try { stat = fs.statSync(projectClaudeDir); } catch { continue; }
617
+ if (!stat.isDirectory()) continue;
618
+
619
+ // Find session files (.jsonl) and subdirs (session folders)
620
+ let entries = [];
621
+ try { entries = fs.readdirSync(projectClaudeDir); } catch { continue; }
622
+
623
+ const sessionFiles = entries.filter(e => e.endsWith('.jsonl'));
624
+ const sessions = sessionFiles.map(f => {
625
+ const fp = path.join(projectClaudeDir, f);
626
+ let fstat = null;
627
+ try { fstat = fs.statSync(fp); } catch {}
628
+ // Peek at first line for model/type info
629
+ let firstTurn = null;
630
+ try {
631
+ const buf = Buffer.alloc(512);
632
+ const fd = fs.openSync(fp, 'r');
633
+ try {
634
+ fs.readSync(fd, buf, 0, 512, 0);
635
+ } finally {
636
+ fs.closeSync(fd);
637
+ }
638
+ const line = buf.toString('utf8').split('\n')[0];
639
+ firstTurn = JSON.parse(line);
640
+ } catch {}
641
+ return {
642
+ id: path.basename(f, '.jsonl'),
643
+ file: fp,
644
+ mtime: fstat ? fstat.mtimeMs : null,
645
+ size: fstat ? fstat.size : null,
646
+ lines: null, // skip line count for perf
647
+ model: firstTurn && firstTurn.model ? firstTurn.model : null,
648
+ };
649
+ }).sort((a, b) => (b.mtime || 0) - (a.mtime || 0));
650
+
651
+ // Resolve the actual filesystem path (handles hyphens in directory names)
652
+ const diskPath = resolveSlugPath(slug);
653
+ const parts = diskPath.split('/').filter(Boolean);
654
+ const name = parts[parts.length - 1] || slug;
655
+ const exists = fs.existsSync(diskPath);
656
+
657
+ // Last activity = most recent session mtime
658
+ const lastActivity = sessions.length ? sessions[0].mtime : null;
659
+
660
+ // Count auto-memory files from ~/.claude/projects/<slug>/memory/
661
+ let memoryCount = 0;
662
+ try {
663
+ const memDir = path.join(os.homedir(), '.claude', 'projects', slug, 'memory');
664
+ if (fs.existsSync(memDir)) {
665
+ memoryCount = fs.readdirSync(memDir).filter(f => f.endsWith('.md') && f !== 'MEMORY.md').length;
666
+ }
667
+ } catch {}
668
+
669
+ result.push({
670
+ slug,
671
+ name,
672
+ path: diskPath,
673
+ exists,
674
+ sessionCount: sessions.length,
675
+ sessions: sessions.slice(0, 5), // top 5 most recent
676
+ lastActivity,
677
+ memoryCount,
678
+ totalSize: sessions.reduce((sum, s) => sum + (s.size || 0), 0),
679
+ });
680
+ }
681
+
682
+ // Sort by most recently active
683
+ result.sort((a, b) => (b.lastActivity || 0) - (a.lastActivity || 0));
684
+ _apCache = result;
685
+ _apCacheTs = Date.now();
686
+ return result;
687
+ }
688
+
689
+ // ---------------------------------------------------------------------------
690
+ // Public API
691
+ // ---------------------------------------------------------------------------
692
+
693
+ export function collectAll(projectDir) {
694
+ const resolvedDir = path.resolve(projectDir);
695
+
696
+ return {
697
+ timestamp: Date.now(),
698
+ project: collectProject(resolvedDir),
699
+ sessions: collectSessions(resolvedDir),
700
+ swarm: collectSwarm(resolvedDir),
701
+ agents: collectAgents(resolvedDir),
702
+ tokens: collectTokens(resolvedDir),
703
+ hooks: collectHooks(resolvedDir),
704
+ knowledge: collectKnowledge(resolvedDir),
705
+ metrics: collectMetrics(resolvedDir),
706
+ triggers: collectTriggers(resolvedDir),
707
+ memory: collectMemory(resolvedDir),
708
+ system: collectSystem(),
709
+ allProjects: collectAllProjects(),
710
+ };
711
+ }
712
+
713
+ export { collectProject, collectSessions, collectSwarm, collectSwarmHistory, appendSwarmHistory, collectSwarmEvents, getSwarmDataSize, cleanSwarmData, collectAgents, collectTokens, collectHooks, collectKnowledge, collectMetrics, collectMemory, collectMemoryFiles, collectSystem };
714
+
715
+ export function getWatchPaths(projectDir) {
716
+ const resolvedDir = path.resolve(projectDir);
717
+ const m = path.join(resolvedDir, '.monomind');
718
+ const c = path.join(resolvedDir, '.claude');
719
+
720
+ return [
721
+ // Swarm
722
+ path.join(m, 'swarm', 'swarm-state.json'),
723
+ path.join(m, 'swarm', 'history.jsonl'),
724
+ path.join(m, 'swarm-config.json'),
725
+ // Metrics
726
+ path.join(m, 'metrics', 'swarm-activity.json'),
727
+ path.join(m, 'metrics', 'token-summary.json'),
728
+ path.join(m, 'metrics', 'token-sessions.json'),
729
+ path.join(m, 'metrics', 'ddd-progress.json'),
730
+ path.join(m, 'metrics', 'learning.json'),
731
+ // Agents
732
+ path.join(m, 'registry.json'),
733
+ path.join(m, 'agents', 'registrations'),
734
+ // Hooks / routing
735
+ path.join(m, 'last-route.json'),
736
+ path.join(m, 'routing-feedback.jsonl'),
737
+ path.join(m, 'worker-dispatch'),
738
+ // Knowledge
739
+ path.join(m, 'knowledge', 'chunks.jsonl'),
740
+ path.join(m, 'skills.jsonl'),
741
+ // Security
742
+ path.join(m, 'security', 'audit-status.json'),
743
+ // Triggers & memory — watch all candidate locations
744
+ path.join(m, 'trigger-index.json'),
745
+ path.join(resolvedDir, 'data', 'memory.db'),
746
+ path.join(resolvedDir, 'data', 'memory.graph'),
747
+ path.join(resolvedDir, '.swarm', 'memory.db'),
748
+ path.join(resolvedDir, '.swarm', 'hnsw.index'),
749
+ path.join(m, 'memory.db'),
750
+ path.join(m, 'data', 'monovector.db'),
751
+ path.join(m, 'data', 'ranked-context.json'),
752
+ // Sessions
753
+ path.join(c, 'sessions')
754
+ ];
755
+ }