monomind 1.11.13 → 1.12.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 (389) hide show
  1. package/.claude/agents/generated/channel-intelligence-director.md +87 -0
  2. package/.claude/agents/generated/chief-growth-officer.md +88 -0
  3. package/.claude/agents/generated/content-seo-strategist.md +90 -0
  4. package/.claude/agents/generated/developer-community-strategist.md +91 -0
  5. package/.claude/agents/generated/outreach-partnership-strategist.md +90 -0
  6. package/.claude/agents/generated/social-media-strategist.md +91 -0
  7. package/.claude/agents/generated/video-visual-strategist.md +90 -0
  8. package/.claude/commands/mastermind/idea.md +1 -1
  9. package/.claude/helpers/auto-memory-hook.mjs +13 -4
  10. package/.claude/helpers/control-start.cjs +5 -0
  11. package/.claude/helpers/event-logger.cjs +114 -0
  12. package/.claude/helpers/handlers/adr-draft-handler.cjs +19 -5
  13. package/.claude/helpers/handlers/agent-start-handler.cjs +13 -4
  14. package/.claude/helpers/handlers/compact-handler.cjs +2 -0
  15. package/.claude/helpers/handlers/edit-handler.cjs +1 -1
  16. package/.claude/helpers/handlers/gates-handler.cjs +3 -0
  17. package/.claude/helpers/handlers/graph-status-handler.cjs +14 -8
  18. package/.claude/helpers/handlers/loops-status-handler.cjs +5 -2
  19. package/.claude/helpers/handlers/route-handler.cjs +13 -6
  20. package/.claude/helpers/handlers/session-handler.cjs +11 -4
  21. package/.claude/helpers/handlers/session-restore-handler.cjs +21 -11
  22. package/.claude/helpers/handlers/task-handler.cjs +13 -5
  23. package/.claude/helpers/intelligence.cjs +7 -2
  24. package/.claude/helpers/loop-tracker.cjs +15 -3
  25. package/.claude/helpers/memory.cjs +6 -1
  26. package/.claude/helpers/router.cjs +5 -2
  27. package/.claude/helpers/session.cjs +2 -0
  28. package/.claude/helpers/statusline.cjs +10 -2
  29. package/.claude/helpers/utils/micro-agents.cjs +20 -4
  30. package/.claude/scheduled_tasks.lock +1 -1
  31. package/.claude/settings.json +92 -1
  32. package/.claude/skills/mastermind/_protocol.md +23 -13
  33. package/.claude/skills/mastermind/architect.md +6 -9
  34. package/.claude/skills/mastermind/build.md +3 -3
  35. package/.claude/skills/mastermind/content.md +3 -3
  36. package/.claude/skills/mastermind/createorg.md +2 -2
  37. package/.claude/skills/mastermind/finance.md +3 -3
  38. package/.claude/skills/mastermind/idea.md +5 -3
  39. package/.claude/skills/mastermind/marketing.md +3 -3
  40. package/.claude/skills/mastermind/monitor.md +2 -2
  41. package/.claude/skills/mastermind/release.md +3 -3
  42. package/.claude/skills/mastermind/research.md +3 -3
  43. package/.claude/skills/mastermind/review.md +3 -3
  44. package/.claude/skills/mastermind/runorg.md +153 -86
  45. package/.claude/skills/mastermind/sales.md +3 -3
  46. package/README.md +286 -129
  47. package/package.json +19 -2
  48. package/packages/@monomind/cli/README.md +286 -129
  49. package/packages/@monomind/cli/bundled-graph/dist/src/build.js +73 -0
  50. package/packages/@monomind/cli/bundled-graph/dist/src/cluster.js +120 -0
  51. package/packages/@monomind/cli/bundled-graph/package.json +57 -0
  52. package/packages/@monomind/cli/dist/src/agents/halt-signal.d.ts +25 -0
  53. package/packages/@monomind/cli/dist/src/agents/halt-signal.js +76 -0
  54. package/packages/@monomind/cli/dist/src/agents/index.d.ts +18 -0
  55. package/packages/@monomind/cli/dist/src/agents/index.js +13 -0
  56. package/packages/@monomind/cli/dist/src/agents/managed-agent.d.ts +41 -0
  57. package/packages/@monomind/cli/dist/src/agents/managed-agent.js +69 -0
  58. package/packages/@monomind/cli/dist/src/agents/prompt-experiment.d.ts +23 -0
  59. package/packages/@monomind/cli/dist/src/agents/prompt-experiment.js +49 -0
  60. package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.d.ts +22 -0
  61. package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.js +80 -0
  62. package/packages/@monomind/cli/dist/src/agents/registry-builder.js +2 -0
  63. package/packages/@monomind/cli/dist/src/agents/registry-query.d.ts +71 -0
  64. package/packages/@monomind/cli/dist/src/agents/registry-query.js +125 -0
  65. package/packages/@monomind/cli/dist/src/agents/score-decay.d.ts +19 -0
  66. package/packages/@monomind/cli/dist/src/agents/score-decay.js +22 -0
  67. package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.d.ts +13 -0
  68. package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.js +40 -0
  69. package/packages/@monomind/cli/dist/src/agents/specialization-scorer.d.ts +54 -0
  70. package/packages/@monomind/cli/dist/src/agents/specialization-scorer.js +212 -0
  71. package/packages/@monomind/cli/dist/src/agents/termination-watcher.d.ts +30 -0
  72. package/packages/@monomind/cli/dist/src/agents/termination-watcher.js +84 -0
  73. package/packages/@monomind/cli/dist/src/agents/trigger-index.d.ts +20 -0
  74. package/packages/@monomind/cli/dist/src/agents/trigger-index.js +38 -0
  75. package/packages/@monomind/cli/dist/src/agents/trigger-scanner.d.ts +64 -0
  76. package/packages/@monomind/cli/dist/src/agents/trigger-scanner.js +308 -0
  77. package/packages/@monomind/cli/dist/src/agents/version-diff.d.ts +18 -0
  78. package/packages/@monomind/cli/dist/src/agents/version-diff.js +64 -0
  79. package/packages/@monomind/cli/dist/src/agents/version-store.d.ts +60 -0
  80. package/packages/@monomind/cli/dist/src/agents/version-store.js +235 -0
  81. package/packages/@monomind/cli/dist/src/autopilot-state.js +10 -5
  82. package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.js +13 -0
  83. package/packages/@monomind/cli/dist/src/benchmarks/metric-evaluators.js +20 -9
  84. package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.d.ts +45 -0
  85. package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.js +404 -0
  86. package/packages/@monomind/cli/dist/src/browser/actions.js +10 -3
  87. package/packages/@monomind/cli/dist/src/browser/browser.js +12 -2
  88. package/packages/@monomind/cli/dist/src/browser/cdp.js +21 -3
  89. package/packages/@monomind/cli/dist/src/browser/har.js +27 -5
  90. package/packages/@monomind/cli/dist/src/commands/agent-wasm.d.ts +14 -0
  91. package/packages/@monomind/cli/dist/src/commands/agent-wasm.js +333 -0
  92. package/packages/@monomind/cli/dist/src/commands/agent.js +11 -8
  93. package/packages/@monomind/cli/dist/src/commands/analyze.js +36 -21
  94. package/packages/@monomind/cli/dist/src/commands/autopilot.js +12 -4
  95. package/packages/@monomind/cli/dist/src/commands/benchmark.js +51 -8
  96. package/packages/@monomind/cli/dist/src/commands/browse.js +5 -2
  97. package/packages/@monomind/cli/dist/src/commands/claims.js +29 -11
  98. package/packages/@monomind/cli/dist/src/commands/cleanup.js +25 -5
  99. package/packages/@monomind/cli/dist/src/commands/config.js +15 -7
  100. package/packages/@monomind/cli/dist/src/commands/daemon.js +6 -0
  101. package/packages/@monomind/cli/dist/src/commands/deployment.js +34 -19
  102. package/packages/@monomind/cli/dist/src/commands/doctor.js +151 -20
  103. package/packages/@monomind/cli/dist/src/commands/guidance.js +15 -2
  104. package/packages/@monomind/cli/dist/src/commands/hive-mind.js +37 -14
  105. package/packages/@monomind/cli/dist/src/commands/hooks.js +42 -25
  106. package/packages/@monomind/cli/dist/src/commands/init.js +9 -4
  107. package/packages/@monomind/cli/dist/src/commands/issues.js +29 -26
  108. package/packages/@monomind/cli/dist/src/commands/mcp.js +11 -5
  109. package/packages/@monomind/cli/dist/src/commands/memory.js +10 -0
  110. package/packages/@monomind/cli/dist/src/commands/migrate.js +5 -5
  111. package/packages/@monomind/cli/dist/src/commands/monograph.js +18 -5
  112. package/packages/@monomind/cli/dist/src/commands/monovector/backup.js +8 -2
  113. package/packages/@monomind/cli/dist/src/commands/monovector/benchmark.js +20 -7
  114. package/packages/@monomind/cli/dist/src/commands/monovector/import.js +15 -0
  115. package/packages/@monomind/cli/dist/src/commands/monovector/migrate.js +4 -1
  116. package/packages/@monomind/cli/dist/src/commands/monovector/optimize.js +11 -0
  117. package/packages/@monomind/cli/dist/src/commands/monovector/setup.js +11 -1
  118. package/packages/@monomind/cli/dist/src/commands/neural.js +1 -1
  119. package/packages/@monomind/cli/dist/src/commands/performance.js +20 -7
  120. package/packages/@monomind/cli/dist/src/commands/platforms.js +90 -8
  121. package/packages/@monomind/cli/dist/src/commands/plugins.js +12 -5
  122. package/packages/@monomind/cli/dist/src/commands/process.js +33 -10
  123. package/packages/@monomind/cli/dist/src/commands/progress.js +5 -3
  124. package/packages/@monomind/cli/dist/src/commands/providers.js +5 -5
  125. package/packages/@monomind/cli/dist/src/commands/replay.js +8 -2
  126. package/packages/@monomind/cli/dist/src/commands/route.js +27 -7
  127. package/packages/@monomind/cli/dist/src/commands/security.js +4 -0
  128. package/packages/@monomind/cli/dist/src/commands/session.js +12 -1
  129. package/packages/@monomind/cli/dist/src/commands/start.js +11 -4
  130. package/packages/@monomind/cli/dist/src/commands/status.js +7 -4
  131. package/packages/@monomind/cli/dist/src/commands/swarm.js +27 -13
  132. package/packages/@monomind/cli/dist/src/commands/task.js +26 -11
  133. package/packages/@monomind/cli/dist/src/commands/tokens.js +7 -2
  134. package/packages/@monomind/cli/dist/src/commands/transfer-store.js +36 -22
  135. package/packages/@monomind/cli/dist/src/commands/ui.js +68 -0
  136. package/packages/@monomind/cli/dist/src/commands/update.js +15 -3
  137. package/packages/@monomind/cli/dist/src/commands/workflow.js +39 -6
  138. package/packages/@monomind/cli/dist/src/consensus/audit-writer.js +18 -7
  139. package/packages/@monomind/cli/dist/src/consensus/index.d.ts +7 -0
  140. package/packages/@monomind/cli/dist/src/consensus/index.js +6 -0
  141. package/packages/@monomind/cli/dist/src/consensus/vote-signer.js +25 -8
  142. package/packages/@monomind/cli/dist/src/context/context-provider.d.ts +44 -0
  143. package/packages/@monomind/cli/dist/src/context/context-provider.js +25 -0
  144. package/packages/@monomind/cli/dist/src/context/git-state-provider.d.ts +12 -0
  145. package/packages/@monomind/cli/dist/src/context/git-state-provider.js +34 -0
  146. package/packages/@monomind/cli/dist/src/context/index.d.ts +12 -0
  147. package/packages/@monomind/cli/dist/src/context/index.js +12 -0
  148. package/packages/@monomind/cli/dist/src/context/project-conventions-provider.d.ts +15 -0
  149. package/packages/@monomind/cli/dist/src/context/project-conventions-provider.js +19 -0
  150. package/packages/@monomind/cli/dist/src/context/prompt-assembler.d.ts +26 -0
  151. package/packages/@monomind/cli/dist/src/context/prompt-assembler.js +93 -0
  152. package/packages/@monomind/cli/dist/src/context/task-history-provider.d.ts +24 -0
  153. package/packages/@monomind/cli/dist/src/context/task-history-provider.js +32 -0
  154. package/packages/@monomind/cli/dist/src/context/user-preferences-provider.d.ts +14 -0
  155. package/packages/@monomind/cli/dist/src/context/user-preferences-provider.js +27 -0
  156. package/packages/@monomind/cli/dist/src/dlq/dlq-reader.d.ts +31 -0
  157. package/packages/@monomind/cli/dist/src/dlq/dlq-reader.js +81 -0
  158. package/packages/@monomind/cli/dist/src/dlq/dlq-writer.d.ts +24 -0
  159. package/packages/@monomind/cli/dist/src/dlq/dlq-writer.js +65 -0
  160. package/packages/@monomind/cli/dist/src/dlq/index.d.ts +10 -0
  161. package/packages/@monomind/cli/dist/src/dlq/index.js +7 -0
  162. package/packages/@monomind/cli/dist/src/eval/dataset-manager.d.ts +33 -0
  163. package/packages/@monomind/cli/dist/src/eval/dataset-manager.js +107 -0
  164. package/packages/@monomind/cli/dist/src/eval/dataset-runner.d.ts +23 -0
  165. package/packages/@monomind/cli/dist/src/eval/dataset-runner.js +59 -0
  166. package/packages/@monomind/cli/dist/src/eval/index.d.ts +10 -0
  167. package/packages/@monomind/cli/dist/src/eval/index.js +7 -0
  168. package/packages/@monomind/cli/dist/src/eval/trace-collector.d.ts +40 -0
  169. package/packages/@monomind/cli/dist/src/eval/trace-collector.js +102 -0
  170. package/packages/@monomind/cli/dist/src/index.js +7 -3
  171. package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  172. package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.js +264 -0
  173. package/packages/@monomind/cli/dist/src/init/executor.js +14 -11
  174. package/packages/@monomind/cli/dist/src/init/shared-instructions-generator.js +20 -4
  175. package/packages/@monomind/cli/dist/src/init/statusline-generator.js +33 -12
  176. package/packages/@monomind/cli/dist/src/interactive/interrupt.d.ts +22 -0
  177. package/packages/@monomind/cli/dist/src/interactive/interrupt.js +71 -0
  178. package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.d.ts +25 -0
  179. package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.js +48 -0
  180. package/packages/@monomind/cli/dist/src/mcp/tool-registry.d.ts +61 -0
  181. package/packages/@monomind/cli/dist/src/mcp/tool-registry.js +246 -0
  182. package/packages/@monomind/cli/dist/src/mcp-tools/a2a-tools.js +98 -13
  183. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +16 -3
  184. package/packages/@monomind/cli/dist/src/mcp-tools/analyze-tools.js +80 -17
  185. package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.js +84 -22
  186. package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.js +35 -7
  187. package/packages/@monomind/cli/dist/src/mcp-tools/config-tools.js +82 -17
  188. package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.js +37 -4
  189. package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.js +49 -7
  190. package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +45 -18
  191. package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +75 -25
  192. package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +32 -10
  193. package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +91 -20
  194. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +188 -29
  195. package/packages/@monomind/cli/dist/src/mcp-tools/memory-tools.js +25 -7
  196. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +11 -2
  197. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +148 -26
  198. package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +44 -9
  199. package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +45 -10
  200. package/packages/@monomind/cli/dist/src/mcp-tools/progress-tools.js +7 -4
  201. package/packages/@monomind/cli/dist/src/mcp-tools/request-tracker.js +15 -1
  202. package/packages/@monomind/cli/dist/src/mcp-tools/security-tools.js +61 -9
  203. package/packages/@monomind/cli/dist/src/mcp-tools/session-tools.js +45 -14
  204. package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +15 -3
  205. package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +14 -7
  206. package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.js +52 -10
  207. package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +40 -6
  208. package/packages/@monomind/cli/dist/src/mcp-tools/transfer-tools.js +37 -4
  209. package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
  210. package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.js +230 -0
  211. package/packages/@monomind/cli/dist/src/mcp-tools/workflow-tools.js +29 -6
  212. package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.js +26 -10
  213. package/packages/@monomind/cli/dist/src/memory/intelligence.js +80 -19
  214. package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +21 -2
  215. package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +67 -3
  216. package/packages/@monomind/cli/dist/src/memory/sona-optimizer.js +14 -4
  217. package/packages/@monomind/cli/dist/src/model/complexity-scorer.d.ts +21 -0
  218. package/packages/@monomind/cli/dist/src/model/complexity-scorer.js +106 -0
  219. package/packages/@monomind/cli/dist/src/model/index.d.ts +4 -0
  220. package/packages/@monomind/cli/dist/src/model/index.js +4 -0
  221. package/packages/@monomind/cli/dist/src/model/model-settings.d.ts +22 -0
  222. package/packages/@monomind/cli/dist/src/model/model-settings.js +33 -0
  223. package/packages/@monomind/cli/dist/src/model/model-tier-resolver.d.ts +24 -0
  224. package/packages/@monomind/cli/dist/src/model/model-tier-resolver.js +65 -0
  225. package/packages/@monomind/cli/dist/src/monovector/capabilities.d.ts +34 -0
  226. package/packages/@monomind/cli/dist/src/monovector/capabilities.js +37 -0
  227. package/packages/@monomind/cli/dist/src/monovector/command-outcomes.js +43 -7
  228. package/packages/@monomind/cli/dist/src/monovector/coverage-router.js +8 -4
  229. package/packages/@monomind/cli/dist/src/monovector/coverage-tools.js +6 -3
  230. package/packages/@monomind/cli/dist/src/monovector/diff-classifier.js +13 -0
  231. package/packages/@monomind/cli/dist/src/monovector/route-outcomes.d.ts +2 -1
  232. package/packages/@monomind/cli/dist/src/monovector/route-outcomes.js +46 -4
  233. package/packages/@monomind/cli/dist/src/observability/replay-reader.d.ts +1 -1
  234. package/packages/@monomind/cli/dist/src/orchestration/index.d.ts +7 -0
  235. package/packages/@monomind/cli/dist/src/orchestration/index.js +6 -0
  236. package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.d.ts +11 -0
  237. package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.js +31 -0
  238. package/packages/@monomind/cli/dist/src/orchestration/routing-modes.d.ts +68 -0
  239. package/packages/@monomind/cli/dist/src/orchestration/routing-modes.js +180 -0
  240. package/packages/@monomind/cli/dist/src/plugins/manager.js +8 -3
  241. package/packages/@monomind/cli/dist/src/plugins/store/discovery.js +46 -2
  242. package/packages/@monomind/cli/dist/src/plugins/store/search.js +5 -4
  243. package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
  244. package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.js +126 -0
  245. package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.d.ts +12 -0
  246. package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.js +188 -0
  247. package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
  248. package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.js +206 -0
  249. package/packages/@monomind/cli/dist/src/production/circuit-breaker.js +17 -3
  250. package/packages/@monomind/cli/dist/src/production/error-handler.js +3 -0
  251. package/packages/@monomind/cli/dist/src/production/monitoring.js +20 -3
  252. package/packages/@monomind/cli/dist/src/production/rate-limiter.js +13 -4
  253. package/packages/@monomind/cli/dist/src/production/retry.js +17 -9
  254. package/packages/@monomind/cli/dist/src/routing/embed-worker.js +6 -2
  255. package/packages/@monomind/cli/dist/src/routing/embedder.js +0 -0
  256. package/packages/@monomind/cli/dist/src/routing/llm-caller.js +13 -2
  257. package/packages/@monomind/cli/dist/src/routing/route-layer-factory.js +18 -3
  258. package/packages/@monomind/cli/dist/src/runtime/headless.d.ts +60 -0
  259. package/packages/@monomind/cli/dist/src/runtime/headless.js +284 -0
  260. package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.d.ts +50 -0
  261. package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.js +95 -0
  262. package/packages/@monomind/cli/dist/src/services/claim-service.d.ts +1 -0
  263. package/packages/@monomind/cli/dist/src/services/claim-service.js +8 -0
  264. package/packages/@monomind/cli/dist/src/services/config-file-manager.js +14 -2
  265. package/packages/@monomind/cli/dist/src/services/container-worker-pool.d.ts +197 -0
  266. package/packages/@monomind/cli/dist/src/services/container-worker-pool.js +623 -0
  267. package/packages/@monomind/cli/dist/src/services/headless-worker-executor.js +18 -2
  268. package/packages/@monomind/cli/dist/src/services/index.d.ts +13 -0
  269. package/packages/@monomind/cli/dist/src/services/index.js +11 -0
  270. package/packages/@monomind/cli/dist/src/services/worker-daemon.js +53 -12
  271. package/packages/@monomind/cli/dist/src/services/worker-queue.d.ts +201 -0
  272. package/packages/@monomind/cli/dist/src/services/worker-queue.js +594 -0
  273. package/packages/@monomind/cli/dist/src/swarm/communication-graph.d.ts +25 -0
  274. package/packages/@monomind/cli/dist/src/swarm/communication-graph.js +77 -0
  275. package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.d.ts +31 -0
  276. package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.js +61 -0
  277. package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.d.ts +19 -0
  278. package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.js +68 -0
  279. package/packages/@monomind/cli/dist/src/transfer/anonymization/index.d.ts +0 -3
  280. package/packages/@monomind/cli/dist/src/transfer/anonymization/index.js +16 -1
  281. package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.d.ts +13 -0
  282. package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.js +205 -0
  283. package/packages/@monomind/cli/dist/src/transfer/export.js +8 -0
  284. package/packages/@monomind/cli/dist/src/transfer/ipfs/upload.js +33 -3
  285. package/packages/@monomind/cli/dist/src/transfer/serialization/cfp.js +9 -3
  286. package/packages/@monomind/cli/dist/src/transfer/storage/gcs.js +37 -3
  287. package/packages/@monomind/cli/dist/src/transfer/store/discovery.js +45 -3
  288. package/packages/@monomind/cli/dist/src/transfer/store/download.js +5 -0
  289. package/packages/@monomind/cli/dist/src/transfer/store/publish.js +13 -1
  290. package/packages/@monomind/cli/dist/src/transfer/store/registry.d.ts +8 -0
  291. package/packages/@monomind/cli/dist/src/transfer/store/registry.js +30 -5
  292. package/packages/@monomind/cli/dist/src/transfer/store/search.js +20 -5
  293. package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
  294. package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.js +190 -0
  295. package/packages/@monomind/cli/dist/src/transfer/test-seraphine.d.ts +6 -0
  296. package/packages/@monomind/cli/dist/src/transfer/test-seraphine.js +105 -0
  297. package/packages/@monomind/cli/dist/src/transfer/tests/test-store.d.ts +7 -0
  298. package/packages/@monomind/cli/dist/src/transfer/tests/test-store.js +214 -0
  299. package/packages/@monomind/cli/dist/src/update/checker.js +59 -7
  300. package/packages/@monomind/cli/dist/src/update/executor.js +50 -3
  301. package/packages/@monomind/cli/dist/src/update/index.js +18 -1
  302. package/packages/@monomind/cli/dist/src/update/rate-limiter.d.ts +6 -0
  303. package/packages/@monomind/cli/dist/src/update/rate-limiter.js +79 -7
  304. package/packages/@monomind/cli/dist/src/update/validator.js +52 -1
  305. package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.d.ts +10 -0
  306. package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.js +82 -0
  307. package/packages/@monomind/cli/dist/src/workflow/context-resolver.d.ts +12 -0
  308. package/packages/@monomind/cli/dist/src/workflow/context-resolver.js +23 -0
  309. package/packages/@monomind/cli/dist/src/workflow/dag-builder.d.ts +17 -0
  310. package/packages/@monomind/cli/dist/src/workflow/dag-builder.js +129 -0
  311. package/packages/@monomind/cli/dist/src/workflow/dag-executor.d.ts +9 -0
  312. package/packages/@monomind/cli/dist/src/workflow/dag-executor.js +116 -0
  313. package/packages/@monomind/cli/dist/src/workflow/dag-types.d.ts +41 -0
  314. package/packages/@monomind/cli/dist/src/workflow/dag-types.js +8 -0
  315. package/packages/@monomind/cli/dist/src/workflow/dsl-parser.d.ts +12 -0
  316. package/packages/@monomind/cli/dist/src/workflow/dsl-parser.js +20 -0
  317. package/packages/@monomind/cli/dist/src/workflow/dsl-schema.d.ts +165 -0
  318. package/packages/@monomind/cli/dist/src/workflow/dsl-schema.js +82 -0
  319. package/packages/@monomind/cli/dist/src/workflow/index.d.ts +13 -0
  320. package/packages/@monomind/cli/dist/src/workflow/index.js +11 -0
  321. package/packages/@monomind/cli/dist/src/workflow/template-engine.d.ts +11 -0
  322. package/packages/@monomind/cli/dist/src/workflow/template-engine.js +40 -0
  323. package/packages/@monomind/cli/dist/src/workflow/workflow-executor.d.ts +29 -0
  324. package/packages/@monomind/cli/dist/src/workflow/workflow-executor.js +227 -0
  325. package/packages/@monomind/cli/package.json +9 -10
  326. package/packages/@monomind/guidance/dist/adversarial.d.ts +284 -0
  327. package/packages/@monomind/guidance/dist/adversarial.js +572 -0
  328. package/packages/@monomind/guidance/dist/analyzer.d.ts +530 -0
  329. package/packages/@monomind/guidance/dist/analyzer.js +2518 -0
  330. package/packages/@monomind/guidance/dist/artifacts.d.ts +283 -0
  331. package/packages/@monomind/guidance/dist/artifacts.js +356 -0
  332. package/packages/@monomind/guidance/dist/authority.d.ts +290 -0
  333. package/packages/@monomind/guidance/dist/authority.js +558 -0
  334. package/packages/@monomind/guidance/dist/capabilities.d.ts +209 -0
  335. package/packages/@monomind/guidance/dist/capabilities.js +485 -0
  336. package/packages/@monomind/guidance/dist/coherence.d.ts +233 -0
  337. package/packages/@monomind/guidance/dist/coherence.js +372 -0
  338. package/packages/@monomind/guidance/dist/compiler.d.ts +87 -0
  339. package/packages/@monomind/guidance/dist/compiler.js +419 -0
  340. package/packages/@monomind/guidance/dist/conformance-kit.d.ts +225 -0
  341. package/packages/@monomind/guidance/dist/conformance-kit.js +629 -0
  342. package/packages/@monomind/guidance/dist/continue-gate.d.ts +214 -0
  343. package/packages/@monomind/guidance/dist/continue-gate.js +353 -0
  344. package/packages/@monomind/guidance/dist/crypto-utils.d.ts +17 -0
  345. package/packages/@monomind/guidance/dist/crypto-utils.js +24 -0
  346. package/packages/@monomind/guidance/dist/evolution.d.ts +282 -0
  347. package/packages/@monomind/guidance/dist/evolution.js +500 -0
  348. package/packages/@monomind/guidance/dist/gates.d.ts +79 -0
  349. package/packages/@monomind/guidance/dist/gates.js +302 -0
  350. package/packages/@monomind/guidance/dist/gateway.d.ts +206 -0
  351. package/packages/@monomind/guidance/dist/gateway.js +452 -0
  352. package/packages/@monomind/guidance/dist/generators.d.ts +153 -0
  353. package/packages/@monomind/guidance/dist/generators.js +682 -0
  354. package/packages/@monomind/guidance/dist/headless.d.ts +177 -0
  355. package/packages/@monomind/guidance/dist/headless.js +342 -0
  356. package/packages/@monomind/guidance/dist/hooks.d.ts +109 -0
  357. package/packages/@monomind/guidance/dist/hooks.js +347 -0
  358. package/packages/@monomind/guidance/dist/index.d.ts +205 -0
  359. package/packages/@monomind/guidance/dist/index.js +321 -0
  360. package/packages/@monomind/guidance/dist/ledger.d.ts +162 -0
  361. package/packages/@monomind/guidance/dist/ledger.js +375 -0
  362. package/packages/@monomind/guidance/dist/manifest-validator.d.ts +289 -0
  363. package/packages/@monomind/guidance/dist/manifest-validator.js +838 -0
  364. package/packages/@monomind/guidance/dist/memory-gate.d.ts +222 -0
  365. package/packages/@monomind/guidance/dist/memory-gate.js +382 -0
  366. package/packages/@monomind/guidance/dist/meta-governance.d.ts +265 -0
  367. package/packages/@monomind/guidance/dist/meta-governance.js +348 -0
  368. package/packages/@monomind/guidance/dist/optimizer.d.ts +104 -0
  369. package/packages/@monomind/guidance/dist/optimizer.js +329 -0
  370. package/packages/@monomind/guidance/dist/persistence.d.ts +189 -0
  371. package/packages/@monomind/guidance/dist/persistence.js +464 -0
  372. package/packages/@monomind/guidance/dist/proof.d.ts +185 -0
  373. package/packages/@monomind/guidance/dist/proof.js +238 -0
  374. package/packages/@monomind/guidance/dist/retriever.d.ts +116 -0
  375. package/packages/@monomind/guidance/dist/retriever.js +394 -0
  376. package/packages/@monomind/guidance/dist/ruvbot-integration.d.ts +370 -0
  377. package/packages/@monomind/guidance/dist/ruvbot-integration.js +738 -0
  378. package/packages/@monomind/guidance/dist/temporal.d.ts +426 -0
  379. package/packages/@monomind/guidance/dist/temporal.js +658 -0
  380. package/packages/@monomind/guidance/dist/trust.d.ts +283 -0
  381. package/packages/@monomind/guidance/dist/trust.js +473 -0
  382. package/packages/@monomind/guidance/dist/truth-anchors.d.ts +276 -0
  383. package/packages/@monomind/guidance/dist/truth-anchors.js +488 -0
  384. package/packages/@monomind/guidance/dist/types.d.ts +378 -0
  385. package/packages/@monomind/guidance/dist/types.js +10 -0
  386. package/packages/@monomind/guidance/dist/uncertainty.d.ts +372 -0
  387. package/packages/@monomind/guidance/dist/uncertainty.js +619 -0
  388. package/packages/@monomind/guidance/dist/wasm-kernel.d.ts +48 -0
  389. package/packages/@monomind/guidance/dist/wasm-kernel.js +158 -0
@@ -0,0 +1,264 @@
1
+ /**
2
+ * In-Memory Repositories - CLI Infrastructure
3
+ *
4
+ * Lightweight in-memory implementations for CLI use.
5
+ *
6
+ * @module v1/cli/infrastructure
7
+ */
8
+ /**
9
+ * In-Memory Agent Repository
10
+ */
11
+ export class InMemoryAgentRepository {
12
+ agents = new Map();
13
+ initialized = false;
14
+ async initialize() {
15
+ this.initialized = true;
16
+ }
17
+ async shutdown() {
18
+ this.agents.clear();
19
+ this.initialized = false;
20
+ }
21
+ async clear() {
22
+ this.agents.clear();
23
+ }
24
+ async save(agent) {
25
+ this.agents.set(agent.id, agent);
26
+ }
27
+ async findById(id) {
28
+ return this.agents.get(id) ?? null;
29
+ }
30
+ async findByName(name) {
31
+ for (const agent of this.agents.values()) {
32
+ if (agent.name === name)
33
+ return agent;
34
+ }
35
+ return null;
36
+ }
37
+ async delete(id) {
38
+ return this.agents.delete(id);
39
+ }
40
+ async exists(id) {
41
+ return this.agents.has(id);
42
+ }
43
+ async saveMany(agents) {
44
+ for (const agent of agents) {
45
+ this.agents.set(agent.id, agent);
46
+ }
47
+ }
48
+ async findByIds(ids) {
49
+ return ids.map((id) => this.agents.get(id)).filter((a) => a !== undefined);
50
+ }
51
+ async deleteMany(ids) {
52
+ let deleted = 0;
53
+ for (const id of ids) {
54
+ if (this.agents.delete(id))
55
+ deleted++;
56
+ }
57
+ return deleted;
58
+ }
59
+ async findAll(options) {
60
+ let result = Array.from(this.agents.values());
61
+ if (options?.status)
62
+ result = result.filter((a) => a.status === options.status);
63
+ if (options?.role)
64
+ result = result.filter((a) => a.role === options.role);
65
+ if (options?.domain)
66
+ result = result.filter((a) => a.domain === options.domain);
67
+ if (options?.limit)
68
+ result = result.slice(0, options.limit);
69
+ return result;
70
+ }
71
+ async findByStatus(status) {
72
+ return this.findAll({ status });
73
+ }
74
+ async findByRole(role) {
75
+ return this.findAll({ role });
76
+ }
77
+ async findByDomain(domain) {
78
+ return this.findAll({ domain });
79
+ }
80
+ async findByParent(parentId) {
81
+ return Array.from(this.agents.values()).filter((a) => a.parentId === parentId);
82
+ }
83
+ async findByCapability(capability) {
84
+ return Array.from(this.agents.values()).filter((a) => a.hasCapability(capability));
85
+ }
86
+ async findAvailable() {
87
+ return Array.from(this.agents.values()).filter((a) => a.isAvailable());
88
+ }
89
+ async getStatistics() {
90
+ const agents = Array.from(this.agents.values());
91
+ const byStatus = {
92
+ idle: 0,
93
+ active: 0,
94
+ busy: 0,
95
+ paused: 0,
96
+ terminated: 0,
97
+ error: 0,
98
+ };
99
+ const byRole = {};
100
+ const byDomain = {};
101
+ let totalCompleted = 0;
102
+ let totalUtilization = 0;
103
+ for (const agent of agents) {
104
+ byStatus[agent.status]++;
105
+ byRole[agent.role] = (byRole[agent.role] ?? 0) + 1;
106
+ byDomain[agent.domain] = (byDomain[agent.domain] ?? 0) + 1;
107
+ totalCompleted += agent.completedTaskCount;
108
+ totalUtilization += agent.getUtilization();
109
+ }
110
+ return {
111
+ total: agents.length,
112
+ byStatus,
113
+ byRole,
114
+ byDomain,
115
+ totalTasksCompleted: totalCompleted,
116
+ averageUtilization: agents.length > 0 ? totalUtilization / agents.length : 0,
117
+ };
118
+ }
119
+ async count(options) {
120
+ return (await this.findAll(options)).length;
121
+ }
122
+ }
123
+ /**
124
+ * In-Memory Task Repository
125
+ */
126
+ export class InMemoryTaskRepository {
127
+ tasks = new Map();
128
+ initialized = false;
129
+ async initialize() {
130
+ this.initialized = true;
131
+ }
132
+ async shutdown() {
133
+ this.tasks.clear();
134
+ this.initialized = false;
135
+ }
136
+ async clear() {
137
+ this.tasks.clear();
138
+ }
139
+ async save(task) {
140
+ this.tasks.set(task.id, task);
141
+ }
142
+ async findById(id) {
143
+ return this.tasks.get(id) ?? null;
144
+ }
145
+ async delete(id) {
146
+ return this.tasks.delete(id);
147
+ }
148
+ async exists(id) {
149
+ return this.tasks.has(id);
150
+ }
151
+ async saveMany(tasks) {
152
+ for (const task of tasks) {
153
+ this.tasks.set(task.id, task);
154
+ }
155
+ }
156
+ async findByIds(ids) {
157
+ return ids.map((id) => this.tasks.get(id)).filter((t) => t !== undefined);
158
+ }
159
+ async deleteMany(ids) {
160
+ let deleted = 0;
161
+ for (const id of ids) {
162
+ if (this.tasks.delete(id))
163
+ deleted++;
164
+ }
165
+ return deleted;
166
+ }
167
+ async findAll(options) {
168
+ let result = Array.from(this.tasks.values());
169
+ if (options?.status)
170
+ result = result.filter((t) => t.status === options.status);
171
+ if (options?.priority)
172
+ result = result.filter((t) => t.priority === options.priority);
173
+ if (options?.type)
174
+ result = result.filter((t) => t.type === options.type);
175
+ if (options?.assignedAgentId)
176
+ result = result.filter((t) => t.assignedAgentId === options.assignedAgentId);
177
+ if (options?.limit)
178
+ result = result.slice(0, options.limit);
179
+ return result;
180
+ }
181
+ async findByStatus(status) {
182
+ return this.findAll({ status });
183
+ }
184
+ async findByPriority(priority) {
185
+ return this.findAll({ priority });
186
+ }
187
+ async findByAgent(agentId) {
188
+ return this.findAll({ assignedAgentId: agentId });
189
+ }
190
+ async findPending() {
191
+ return this.findByStatus('pending');
192
+ }
193
+ async findQueued() {
194
+ return this.findByStatus('queued');
195
+ }
196
+ async findRunning() {
197
+ return this.findByStatus('running');
198
+ }
199
+ async findTimedOut() {
200
+ return Array.from(this.tasks.values()).filter((t) => t.isTimedOut());
201
+ }
202
+ async getNextTask(agentCapabilities) {
203
+ const queued = await this.findQueued();
204
+ if (queued.length === 0)
205
+ return null;
206
+ queued.sort((a, b) => a.comparePriority(b));
207
+ return queued[0];
208
+ }
209
+ async getTaskQueue(limit = 10) {
210
+ const queued = await this.findQueued();
211
+ queued.sort((a, b) => a.comparePriority(b));
212
+ return queued.slice(0, limit);
213
+ }
214
+ async getStatistics() {
215
+ const tasks = Array.from(this.tasks.values());
216
+ const byStatus = {
217
+ pending: 0,
218
+ queued: 0,
219
+ assigned: 0,
220
+ running: 0,
221
+ completed: 0,
222
+ failed: 0,
223
+ cancelled: 0,
224
+ };
225
+ const byPriority = {
226
+ critical: 0,
227
+ high: 0,
228
+ normal: 0,
229
+ low: 0,
230
+ };
231
+ const byType = {};
232
+ let totalDuration = 0;
233
+ let completedCount = 0;
234
+ let failedCount = 0;
235
+ let retryTotal = 0;
236
+ for (const task of tasks) {
237
+ byStatus[task.status]++;
238
+ byPriority[task.priority]++;
239
+ byType[task.type] = (byType[task.type] ?? 0) + 1;
240
+ if (task.status === 'completed') {
241
+ completedCount++;
242
+ const duration = task.getExecutionDuration();
243
+ if (duration)
244
+ totalDuration += duration;
245
+ }
246
+ if (task.status === 'failed')
247
+ failedCount++;
248
+ retryTotal += task.retryCount;
249
+ }
250
+ return {
251
+ total: tasks.length,
252
+ byStatus,
253
+ byPriority,
254
+ byType,
255
+ averageExecutionTime: completedCount > 0 ? totalDuration / completedCount : 0,
256
+ successRate: tasks.length > 0 ? completedCount / tasks.length : 0,
257
+ retryRate: tasks.length > 0 ? retryTotal / tasks.length : 0,
258
+ };
259
+ }
260
+ async count(options) {
261
+ return (await this.findAll(options)).length;
262
+ }
263
+ }
264
+ //# sourceMappingURL=in-memory-repositories.js.map
@@ -10,6 +10,7 @@ import { dirname } from 'path';
10
10
  // ESM-compatible __dirname
11
11
  const __filename = fileURLToPath(import.meta.url);
12
12
  const __dirname = dirname(__filename);
13
+ const MAX_EXEC_FILE_BYTES = 10 * 1024 * 1024; // 10 MB
13
14
  /**
14
15
  * Atomic write helper — writes to a sibling .tmp file then renames into place.
15
16
  * SIGINT or crash during a partial write would otherwise corrupt user-critical
@@ -205,7 +206,7 @@ function cleanupLegacyTools(targetDir) {
205
206
  }
206
207
  // Clean ruv-swarm from .mcp.json and fix old MCP package name
207
208
  const mcpJsonPath = path.join(targetDir, '.mcp.json');
208
- if (fs.existsSync(mcpJsonPath)) {
209
+ if (fs.existsSync(mcpJsonPath) && fs.statSync(mcpJsonPath).size <= MAX_EXEC_FILE_BYTES) {
209
210
  try {
210
211
  const mcp = JSON.parse(fs.readFileSync(mcpJsonPath, 'utf-8'));
211
212
  let mcpChanged = false;
@@ -226,7 +227,7 @@ function cleanupLegacyTools(targetDir) {
226
227
  }
227
228
  // Clean ruv-swarm from .claude/settings.json hooks and fix MCP package name
228
229
  const settingsPath = path.join(targetDir, '.claude', 'settings.json');
229
- if (fs.existsSync(settingsPath)) {
230
+ if (fs.existsSync(settingsPath) && fs.statSync(settingsPath).size <= MAX_EXEC_FILE_BYTES) {
230
231
  try {
231
232
  const raw = fs.readFileSync(settingsPath, 'utf-8');
232
233
  const settings = JSON.parse(raw);
@@ -449,8 +450,8 @@ async function startDaemonBackground(targetDir, result) {
449
450
  const { execSync } = await import('child_process');
450
451
  // Check if daemon is already running
451
452
  const pidFile = path.join(targetDir, '.monomind', 'daemon.pid');
452
- const { existsSync, readFileSync } = await import('fs');
453
- if (existsSync(pidFile)) {
453
+ const { existsSync, readFileSync, statSync: statSyncPid } = await import('fs');
454
+ if (existsSync(pidFile) && statSyncPid(pidFile).size <= 1024) {
454
455
  const pid = parseInt(readFileSync(pidFile, 'utf8').trim(), 10);
455
456
  try {
456
457
  process.kill(pid, 0);
@@ -798,7 +799,7 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
798
799
  // 3. Merge settings if requested
799
800
  if (upgradeSettings) {
800
801
  const settingsPath = path.join(targetDir, '.claude', 'settings.json');
801
- if (fs.existsSync(settingsPath)) {
802
+ if (fs.existsSync(settingsPath) && fs.statSync(settingsPath).size <= MAX_EXEC_FILE_BYTES) {
802
803
  try {
803
804
  const existingSettings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
804
805
  const mergedSettings = mergeSettingsForUpgrade(existingSettings);
@@ -951,7 +952,7 @@ async function createDirectories(targetDir, options, result) {
951
952
  async function writeSettings(targetDir, options, result) {
952
953
  const settingsPath = path.join(targetDir, '.claude', 'settings.json');
953
954
  const generated = JSON.parse(generateSettingsJson(options));
954
- if (fs.existsSync(settingsPath) && !options.force) {
955
+ if (fs.existsSync(settingsPath) && !options.force && fs.statSync(settingsPath).size <= MAX_EXEC_FILE_BYTES) {
955
956
  // Merge hooks/env/permissions into existing settings instead of skipping
956
957
  try {
957
958
  const existing = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
@@ -1493,7 +1494,7 @@ daemon.pid
1493
1494
  // A blanket ignore prevents config, metrics, and knowledge graph from being committed.
1494
1495
  // We remove any bare `.monomind/` or `**/.monomind/` lines and add specific excludes instead.
1495
1496
  const projectGitignorePath = path.join(targetDir, '.gitignore');
1496
- if (fs.existsSync(projectGitignorePath)) {
1497
+ if (fs.existsSync(projectGitignorePath) && fs.statSync(projectGitignorePath).size <= MAX_EXEC_FILE_BYTES) {
1497
1498
  const existing = fs.readFileSync(projectGitignorePath, 'utf-8');
1498
1499
  const blanketPattern = /^(\*\*\/)?\.monomind\/?\s*$/gm;
1499
1500
  if (blanketPattern.test(existing)) {
@@ -2060,7 +2061,7 @@ async function writeClaudeMd(targetDir, options, result) {
2060
2061
  if (!fs.existsSync(globalClaudeDir)) {
2061
2062
  fs.mkdirSync(globalClaudeDir, { recursive: true });
2062
2063
  }
2063
- if (fs.existsSync(globalClaudeMd)) {
2064
+ if (fs.existsSync(globalClaudeMd) && fs.statSync(globalClaudeMd).size <= MAX_EXEC_FILE_BYTES) {
2064
2065
  const existing = fs.readFileSync(globalClaudeMd, 'utf-8');
2065
2066
  if (!existing.includes('Monomind Integration')) {
2066
2067
  fs.appendFileSync(globalClaudeMd, monomindBlock);
@@ -2082,7 +2083,7 @@ async function writeClaudeMd(targetDir, options, result) {
2082
2083
  fs.mkdirSync(globalClaudeDir, { recursive: true });
2083
2084
  }
2084
2085
  let globalSettings = {};
2085
- if (fs.existsSync(globalSettingsPath)) {
2086
+ if (fs.existsSync(globalSettingsPath) && fs.statSync(globalSettingsPath).size <= MAX_EXEC_FILE_BYTES) {
2086
2087
  try {
2087
2088
  globalSettings = JSON.parse(fs.readFileSync(globalSettingsPath, 'utf-8'));
2088
2089
  }
@@ -2227,7 +2228,9 @@ function _registerMonomindProject(dir) {
2227
2228
  const registryPath = path.join(os.homedir(), '.monomind-projects.json');
2228
2229
  let reg = { projects: [] };
2229
2230
  try {
2230
- reg = JSON.parse(fs.readFileSync(registryPath, 'utf-8'));
2231
+ if (fs.existsSync(registryPath) && fs.statSync(registryPath).size <= MAX_EXEC_FILE_BYTES) {
2232
+ reg = JSON.parse(fs.readFileSync(registryPath, 'utf-8'));
2233
+ }
2231
2234
  }
2232
2235
  catch { }
2233
2236
  if (!Array.isArray(reg.projects))
@@ -2260,7 +2263,7 @@ export function findMonomindProjects(maxDepth = 3) {
2260
2263
  ].filter(r => fs.existsSync(r));
2261
2264
  // Also check known-projects registry if it exists
2262
2265
  const registryPath = path.join(home, '.monomind-projects.json');
2263
- if (fs.existsSync(registryPath)) {
2266
+ if (fs.existsSync(registryPath) && fs.statSync(registryPath).size <= MAX_EXEC_FILE_BYTES) {
2264
2267
  try {
2265
2268
  const reg = JSON.parse(fs.readFileSync(registryPath, 'utf-8'));
2266
2269
  if (Array.isArray(reg.projects)) {
@@ -8,8 +8,12 @@
8
8
  import * as fs from 'node:fs';
9
9
  import * as path from 'node:path';
10
10
  import { execFileSync } from 'node:child_process';
11
+ const MAX_JSON_READ_BYTES = 10 * 1024 * 1024; // 10 MB
12
+ const MAX_TEXT_READ_BYTES = 2 * 1024 * 1024; // 2 MB for plain-text config files
11
13
  function readJSON(p) {
12
14
  try {
15
+ if (!fs.existsSync(p) || fs.statSync(p).size > MAX_JSON_READ_BYTES)
16
+ return null;
13
17
  return JSON.parse(fs.readFileSync(p, 'utf-8'));
14
18
  }
15
19
  catch {
@@ -166,7 +170,10 @@ export function detectProjectProfile(cwd) {
166
170
  profile.language = 'rust';
167
171
  profile.packageManager = 'cargo';
168
172
  try {
169
- const cargo = fs.readFileSync(path.join(cwd, 'Cargo.toml'), 'utf-8');
173
+ const cargoPath = path.join(cwd, 'Cargo.toml');
174
+ if (fs.statSync(cargoPath).size > MAX_TEXT_READ_BYTES)
175
+ throw new Error('too large');
176
+ const cargo = fs.readFileSync(cargoPath, 'utf-8');
170
177
  const nameM = cargo.match(/^name\s*=\s*"([^"]+)"/m);
171
178
  if (nameM)
172
179
  profile.name = nameM[1];
@@ -191,7 +198,10 @@ export function detectProjectProfile(cwd) {
191
198
  else
192
199
  profile.packageManager = 'pip';
193
200
  try {
194
- const pp = fs.readFileSync(path.join(cwd, 'pyproject.toml'), 'utf-8');
201
+ const ppPath = path.join(cwd, 'pyproject.toml');
202
+ if (fs.existsSync(ppPath) && fs.statSync(ppPath).size > MAX_TEXT_READ_BYTES)
203
+ throw new Error('too large');
204
+ const pp = fs.readFileSync(ppPath, 'utf-8');
195
205
  if (pp.includes('fastapi') || pp.includes('FastAPI'))
196
206
  profile.framework.push('fastapi');
197
207
  if (pp.includes('django'))
@@ -210,7 +220,10 @@ export function detectProjectProfile(cwd) {
210
220
  profile.language = 'go';
211
221
  profile.packageManager = 'unknown'; // go mod doesn't have a separate PM
212
222
  try {
213
- const gomod = fs.readFileSync(path.join(cwd, 'go.mod'), 'utf-8');
223
+ const gomodPath = path.join(cwd, 'go.mod');
224
+ if (fs.statSync(gomodPath).size > MAX_TEXT_READ_BYTES)
225
+ throw new Error('too large');
226
+ const gomod = fs.readFileSync(gomodPath, 'utf-8');
214
227
  if (gomod.includes('gin-gonic/gin'))
215
228
  profile.framework.push('gin');
216
229
  if (gomod.includes('labstack/echo'))
@@ -236,7 +249,10 @@ export function detectProjectProfile(cwd) {
236
249
  }
237
250
  // ── CLAUDE.md conventions extraction ──────────────────────────────────────
238
251
  try {
239
- const claudeMd = fs.readFileSync(path.join(cwd, 'CLAUDE.md'), 'utf-8');
252
+ const claudeMdPath = path.join(cwd, 'CLAUDE.md');
253
+ if (fs.existsSync(claudeMdPath) && fs.statSync(claudeMdPath).size > MAX_TEXT_READ_BYTES)
254
+ throw new Error('too large');
255
+ const claudeMd = fs.readFileSync(claudeMdPath, 'utf-8');
240
256
  profile.maxFileLines = extractMaxFileLines(claudeMd);
241
257
  }
242
258
  catch { /* skip */ }
@@ -62,6 +62,8 @@ function getVersion() {
62
62
  ];
63
63
  for (const p of walkCandidates) {
64
64
  try {
65
+ const pkgStat = safeStat(p);
66
+ if (!pkgStat || pkgStat.size > 1024 * 1024) continue;
65
67
  const pkg = JSON.parse(fs.readFileSync(p, 'utf-8'));
66
68
  if (pkg.version && (pkg.name === 'monomind' || pkg.name === '@monomind/cli' || (pkg.name || '').startsWith('@monomind'))) {
67
69
  return \`v\${pkg.version}\`;
@@ -72,7 +74,10 @@ function getVersion() {
72
74
  try {
73
75
  const { execSync } = require('child_process');
74
76
  const prefix = execSync('npm config get prefix', { encoding: 'utf-8', timeout: 2000 }).trim();
75
- const pkg = JSON.parse(fs.readFileSync(path.join(prefix, 'lib', 'node_modules', 'monomind', 'package.json'), 'utf-8'));
77
+ const globalPkgPath = path.join(prefix, 'lib', 'node_modules', 'monomind', 'package.json');
78
+ const globalPkgStat = safeStat(globalPkgPath);
79
+ if (!globalPkgStat || globalPkgStat.size > 1024 * 1024) throw new Error('too large');
80
+ const pkg = JSON.parse(fs.readFileSync(globalPkgPath, 'utf-8'));
76
81
  if (pkg.version) return \`v\${pkg.version}\`;
77
82
  } catch { /* ignore */ }
78
83
  return 'v1.0.6';
@@ -113,9 +118,11 @@ function safeExec(cmd, timeoutMs = 2000) {
113
118
  }
114
119
 
115
120
  // Safe JSON file reader (returns null on failure)
121
+ // Refuses to load files > 10 MB to prevent OOM on corrupted/oversized stores.
122
+ const MAX_JSON_READ_BYTES = 10 * 1024 * 1024;
116
123
  function readJSON(filePath) {
117
124
  try {
118
- if (fs.existsSync(filePath)) {
125
+ if (fs.existsSync(filePath) && fs.statSync(filePath).size <= MAX_JSON_READ_BYTES) {
119
126
  return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
120
127
  }
121
128
  } catch { /* ignore */ }
@@ -227,6 +234,8 @@ function getModelFromSessionJSONL() {
227
234
  if (files.length === 0) return null;
228
235
 
229
236
  const sessionFile = path.join(projectsDir, files[0].f);
237
+ const sessionStat = safeStat(sessionFile);
238
+ if (!sessionStat || sessionStat.size > 50 * 1024 * 1024) return null; // skip > 50 MB
230
239
  const raw = fs.readFileSync(sessionFile, 'utf-8');
231
240
  const lines = raw.split('\\n').filter(Boolean);
232
241
 
@@ -557,7 +566,8 @@ function getHooksStatus() {
557
566
  function getActiveAgent() {
558
567
  const routeFile = path.join(CWD, '.monomind', 'last-route.json');
559
568
  try {
560
- if (!fs.existsSync(routeFile)) return null;
569
+ const routeStat = safeStat(routeFile);
570
+ if (!routeStat || routeStat.size > MAX_JSON_READ_BYTES) return null;
561
571
  const data = JSON.parse(fs.readFileSync(routeFile, 'utf-8'));
562
572
  if (!data || !data.agent) return null;
563
573
 
@@ -590,7 +600,7 @@ function getAgentDBStats() {
590
600
  // 1. Count real entries from auto-memory-store.json
591
601
  const storePath = path.join(CWD, '.monomind', 'data', 'auto-memory-store.json');
592
602
  const storeStat = safeStat(storePath);
593
- if (storeStat) {
603
+ if (storeStat && storeStat.size <= MAX_JSON_READ_BYTES) {
594
604
  dbSizeKB += storeStat.size / 1024;
595
605
  try {
596
606
  const store = JSON.parse(fs.readFileSync(storePath, 'utf-8'));
@@ -804,12 +814,14 @@ function getKnowledgeStats() {
804
814
  const skillsPath = path.join(CWD, '.monomind', 'skills.jsonl');
805
815
  let chunks = 0, skills = 0;
806
816
  try {
807
- if (fs.existsSync(chunksPath)) {
817
+ const chunksStat = safeStat(chunksPath);
818
+ if (chunksStat && chunksStat.size <= MAX_JSON_READ_BYTES) {
808
819
  chunks = fs.readFileSync(chunksPath, 'utf-8').split('\\n').filter(Boolean).length;
809
820
  }
810
821
  } catch { /* ignore */ }
811
822
  try {
812
- if (fs.existsSync(skillsPath)) {
823
+ const skillsStat = safeStat(skillsPath);
824
+ if (skillsStat && skillsStat.size <= MAX_JSON_READ_BYTES) {
813
825
  skills = fs.readFileSync(skillsPath, 'utf-8').split('\\n').filter(Boolean).length;
814
826
  }
815
827
  } catch { /* ignore */ }
@@ -819,7 +831,8 @@ function getKnowledgeStats() {
819
831
  function getTriggerStats() {
820
832
  const indexPath = path.join(CWD, '.monomind', 'trigger-index.json');
821
833
  try {
822
- if (!fs.existsSync(indexPath)) return { triggers: 0, agents: 0 };
834
+ const idxStat = safeStat(indexPath);
835
+ if (!idxStat || idxStat.size > MAX_JSON_READ_BYTES) return { triggers: 0, agents: 0 };
823
836
  const raw = JSON.parse(fs.readFileSync(indexPath, 'utf-8'));
824
837
  const idx = raw.index || raw;
825
838
  const triggers = Object.keys(idx).length;
@@ -832,7 +845,8 @@ function getTriggerStats() {
832
845
  function getHookLatency() {
833
846
  const p = path.join(CWD, '.monomind', 'metrics', 'hook-latency.json');
834
847
  try {
835
- if (!fs.existsSync(p)) return null;
848
+ const latStat = safeStat(p);
849
+ if (!latStat || latStat.size > MAX_JSON_READ_BYTES) return null;
836
850
  const d = JSON.parse(fs.readFileSync(p, 'utf-8'));
837
851
  const perPrompt = ['route'];
838
852
  let totalMs = 0; let count = 0;
@@ -854,7 +868,8 @@ function getHookLatency() {
854
868
  function getGraphUsage() {
855
869
  const usagePath = path.join(CWD, '.monomind', 'metrics', 'graph-usage.json');
856
870
  try {
857
- if (!fs.existsSync(usagePath)) return null;
871
+ const usageStat = safeStat(usagePath);
872
+ if (!usageStat || usageStat.size > MAX_JSON_READ_BYTES) return null;
858
873
  const d = JSON.parse(fs.readFileSync(usagePath, 'utf-8'));
859
874
  const graphWins = (d.monograph_call || 0) + (d.preresolve_hit || 0)
860
875
  + (d.graph_assist_search || 0) + (d.graph_assist_neighbors || 0);
@@ -919,7 +934,10 @@ function getHILPending() {
919
934
  const files = fs.readdirSync(loopsDir).filter(f => f.endsWith('-hil.md'));
920
935
  for (const f of files) {
921
936
  try {
922
- const txt = fs.readFileSync(path.join(loopsDir, f), 'utf-8');
937
+ const hilPath = path.join(loopsDir, f);
938
+ const hilStat = safeStat(hilPath);
939
+ if (!hilStat || hilStat.size > 512 * 1024) continue; // skip > 512 KB
940
+ const txt = fs.readFileSync(hilPath, 'utf-8');
923
941
  const answered = /^[ \\t]*>[ \\t]+\\S/m.test(txt);
924
942
  if (!answered) pending++;
925
943
  } catch { /* ignore */ }
@@ -969,7 +987,9 @@ function getSIBudget() {
969
987
  const SI_LIMIT = 1500;
970
988
  const siPath = path.join(CWD, '.agents', 'shared_instructions.md');
971
989
  try {
972
- if (!fs.existsSync(siPath)) return null;
990
+ const siStat = safeStat(siPath);
991
+ if (!siStat) return null;
992
+ if (siStat.size > 2 * 1024 * 1024) return null; // skip > 2 MB
973
993
  const len = fs.readFileSync(siPath, 'utf-8').length;
974
994
  return { len, pct: Math.round((len / SI_LIMIT) * 100), limit: SI_LIMIT };
975
995
  } catch { return null; }
@@ -1180,7 +1200,8 @@ const MODE_FILE = path.join(CWD, '.monomind', 'statusline-mode.txt');
1180
1200
 
1181
1201
  function readMode() {
1182
1202
  try {
1183
- if (fs.existsSync(MODE_FILE)) {
1203
+ const modeStat = safeStat(MODE_FILE);
1204
+ if (modeStat && modeStat.size <= 1024) {
1184
1205
  return fs.readFileSync(MODE_FILE, 'utf-8').trim();
1185
1206
  }
1186
1207
  } catch { /* ignore */ }
@@ -0,0 +1,22 @@
1
+ export type InterruptDecision = 'approved' | 'rejected' | 'edited';
2
+ export interface InterruptPromptResult {
3
+ decision: InterruptDecision;
4
+ editedTask?: string;
5
+ }
6
+ export interface InterruptConfig {
7
+ interruptBefore: string[];
8
+ confidenceThreshold?: number;
9
+ autoApprove?: boolean;
10
+ }
11
+ export declare class InterruptRegistry {
12
+ private config;
13
+ load(config: InterruptConfig): void;
14
+ shouldInterrupt(agentSlug: string, confidence?: number): boolean;
15
+ getConfig(): InterruptConfig;
16
+ }
17
+ export declare const interruptRegistry: InterruptRegistry;
18
+ export declare class InterruptController {
19
+ prompt(agentSlug: string, taskDescription: string, checkpointId: string): Promise<InterruptPromptResult>;
20
+ }
21
+ export declare const interruptController: InterruptController;
22
+ //# sourceMappingURL=interrupt.d.ts.map
@@ -0,0 +1,71 @@
1
+ import * as readline from 'node:readline';
2
+ export class InterruptRegistry {
3
+ config = { interruptBefore: [] };
4
+ load(config) {
5
+ this.config = config;
6
+ }
7
+ shouldInterrupt(agentSlug, confidence) {
8
+ if (this.config.autoApprove)
9
+ return false;
10
+ if (this.config.interruptBefore.includes(agentSlug))
11
+ return true;
12
+ if (confidence !== undefined &&
13
+ this.config.confidenceThreshold !== undefined &&
14
+ confidence < this.config.confidenceThreshold) {
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+ getConfig() {
20
+ return { ...this.config };
21
+ }
22
+ }
23
+ export const interruptRegistry = new InterruptRegistry();
24
+ export class InterruptController {
25
+ async prompt(agentSlug, taskDescription, checkpointId) {
26
+ // Non-TTY / CI mode
27
+ if (!process.stdin.isTTY || process.env.CI_AUTO_APPROVE === '1') {
28
+ return { decision: 'approved' };
29
+ }
30
+ const rl = readline.createInterface({
31
+ input: process.stdin,
32
+ output: process.stdout,
33
+ });
34
+ // Strip control characters from interpolated fields. ANSI escape sequences
35
+ // in any of these fields would let a malicious agent or LLM-generated task
36
+ // description redraw the screen and trick the user into approving an
37
+ // entirely different action than the one shown — defeating this very gate.
38
+ const safe = (s) => String(s ?? '').replace(/[\x00-\x1f\x7f-\x9f]/g, '?').slice(0, 500);
39
+ console.log('\n' + '='.repeat(60));
40
+ console.log('[MONOMIND] Interrupt — Human approval required');
41
+ console.log(` Agent: ${safe(agentSlug)}`);
42
+ console.log(` Task: ${safe(taskDescription)}`);
43
+ console.log(` Checkpoint: ${safe(checkpointId)}`);
44
+ console.log('='.repeat(60));
45
+ console.log(' Options: [y] approve [n] reject [e] edit task');
46
+ return new Promise((resolve) => {
47
+ rl.question(' Choice (y/n/e): ', (answer) => {
48
+ rl.close();
49
+ const trimmed = answer.trim().toLowerCase();
50
+ if (trimmed === 'y' || trimmed === 'yes') {
51
+ resolve({ decision: 'approved' });
52
+ }
53
+ else if (trimmed === 'e' || trimmed === 'edit') {
54
+ const rl2 = readline.createInterface({
55
+ input: process.stdin,
56
+ output: process.stdout,
57
+ });
58
+ rl2.question(' New task description: ', (newTask) => {
59
+ rl2.close();
60
+ resolve({ decision: 'edited', editedTask: newTask });
61
+ });
62
+ }
63
+ else {
64
+ resolve({ decision: 'rejected' });
65
+ }
66
+ });
67
+ });
68
+ }
69
+ }
70
+ export const interruptController = new InterruptController();
71
+ //# sourceMappingURL=interrupt.js.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Deprecation Injector (Task 31)
3
+ *
4
+ * Injects deprecation warnings into MCP tool responses when the
5
+ * invoked tool has been marked as deprecated in the ToolRegistry.
6
+ */
7
+ import type { ToolRegistry } from './tool-registry.js';
8
+ /**
9
+ * Injects deprecation metadata into MCP responses.
10
+ */
11
+ export declare class DeprecationInjector {
12
+ private readonly registry;
13
+ constructor(registry: ToolRegistry);
14
+ /**
15
+ * If `toolName` is deprecated, augment the response with a warning.
16
+ *
17
+ * Returns the original response unmodified when the tool is not
18
+ * deprecated. When deprecated, adds `_deprecation` metadata.
19
+ *
20
+ * Warning format:
21
+ * [DEPRECATED] Tool "<name>" is deprecated. <message>. Use "<successor>" instead.
22
+ */
23
+ inject(response: Record<string, unknown>, toolName: string): Record<string, unknown>;
24
+ }
25
+ //# sourceMappingURL=deprecation-injector.d.ts.map