@monoes/monomindcli 1.18.15 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (511) hide show
  1. package/.claude/agents/core/researcher.md +29 -24
  2. package/.claude/agents/github/code-review-swarm.md +1 -1
  3. package/.claude/agents/github/github-modes.md +1 -1
  4. package/.claude/agents/github/issue-tracker.md +1 -3
  5. package/.claude/agents/github/multi-repo-swarm.md +1 -1
  6. package/.claude/agents/github/pr-manager.md +1 -3
  7. package/.claude/agents/github/project-board-sync.md +1 -1
  8. package/.claude/agents/github/release-manager.md +1 -1
  9. package/.claude/agents/github/repo-architect.md +4 -12
  10. package/.claude/agents/github/swarm-issue.md +1 -1
  11. package/.claude/agents/github/swarm-pr.md +1 -1
  12. package/.claude/agents/github/sync-coordinator.md +1 -1
  13. package/.claude/agents/github/workflow-automation.md +1 -1
  14. package/.claude/agents/goal/goal-planner.md +1 -2
  15. package/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
  16. package/.claude/agents/testing/production-validator.md +8 -7
  17. package/.claude/agents/testing/testing-evidence-collector.md +3 -1
  18. package/.claude/commands/github/issue-tracker.md +0 -2
  19. package/.claude/commands/github/pr-manager.md +0 -2
  20. package/.claude/commands/github/repo-architect.md +3 -10
  21. package/.claude/commands/mastermind/code-review.md +4 -4
  22. package/.claude/commands/mastermind/help.md +5 -5
  23. package/.claude/commands/mastermind/okf-export.md +14 -0
  24. package/.claude/commands/mastermind/okf-import.md +15 -0
  25. package/.claude/commands/workflows/README.md +0 -1
  26. package/.claude/commands/workflows/workflow-create.md +0 -1
  27. package/.claude/commands/workflows/workflow-execute.md +1 -3
  28. package/.claude/commands/workflows/workflow-export.md +0 -2
  29. package/.claude/helpers/handlers/agent-start-handler.cjs +28 -36
  30. package/.claude/helpers/handlers/capture-handler.cjs +110 -0
  31. package/.claude/helpers/handlers/edit-handler.cjs +15 -0
  32. package/.claude/helpers/handlers/gates-handler.cjs +2 -8
  33. package/.claude/helpers/handlers/route-handler.cjs +314 -245
  34. package/.claude/helpers/handlers/session-handler.cjs +182 -163
  35. package/.claude/helpers/handlers/session-restore-handler.cjs +95 -53
  36. package/.claude/helpers/handlers/task-handler.cjs +17 -160
  37. package/.claude/helpers/hook-handler.cjs +153 -16
  38. package/.claude/helpers/intelligence.cjs +255 -15
  39. package/.claude/helpers/learning-service.mjs +1 -0
  40. package/.claude/helpers/mastermind-activate.cjs +33 -51
  41. package/.claude/helpers/monolean-activate.cjs +13 -3
  42. package/.claude/helpers/monolean-propagate.cjs +7 -3
  43. package/.claude/helpers/router.cjs +122 -11
  44. package/.claude/helpers/skill-registry.json +0 -189
  45. package/.claude/skills/github-toolkit/SKILL.md +60 -0
  46. package/.claude/skills/hive-mind-advanced/SKILL.md +0 -15
  47. package/.claude/skills/hooks-automation/SKILL.md +0 -1
  48. package/.claude/skills/mastermind-skills/_protocol.md +1 -1
  49. package/.claude/skills/mastermind-skills/architect.md +5 -6
  50. package/.claude/skills/mastermind-skills/autodev.md +8 -5
  51. package/.claude/skills/mastermind-skills/build.md +1 -2
  52. package/.claude/skills/mastermind-skills/review.md +8 -5
  53. package/.claude/skills/mastermind-skills/techport.md +37 -3
  54. package/.claude/skills/memory-toolkit/SKILL.md +75 -0
  55. package/.claude/skills/monodesign/document.md +9 -6
  56. package/.claude/skills/monodesign/extract.md +1 -1
  57. package/.claude/skills/monodesign/reference/document.md +1 -1
  58. package/.claude/skills/monodesign/reference/live.md +1 -1
  59. package/.claude/skills/monolean/SKILL.md +1 -1
  60. package/.claude/skills/specialagent/SKILL.md +2 -4
  61. package/.claude/skills/swarm-advanced/SKILL.md +0 -1
  62. package/README.md +2 -5
  63. package/bin/mcp-server.js +11 -1
  64. package/dist/src/autopilot-state.d.ts.map +1 -1
  65. package/dist/src/autopilot-state.js +4 -5
  66. package/dist/src/autopilot-state.js.map +1 -1
  67. package/dist/src/browser/dashboard/server.d.ts.map +1 -1
  68. package/dist/src/browser/dashboard/server.js +69 -1
  69. package/dist/src/browser/dashboard/server.js.map +1 -1
  70. package/dist/src/browser/dashboard/ui.html +214 -1764
  71. package/dist/src/capabilities/index.d.ts +0 -2
  72. package/dist/src/capabilities/index.d.ts.map +1 -1
  73. package/dist/src/capabilities/index.js +0 -1
  74. package/dist/src/capabilities/index.js.map +1 -1
  75. package/dist/src/commands/agent-lifecycle.d.ts.map +1 -1
  76. package/dist/src/commands/agent-lifecycle.js +2 -6
  77. package/dist/src/commands/agent-lifecycle.js.map +1 -1
  78. package/dist/src/commands/agent-ops.d.ts +1 -2
  79. package/dist/src/commands/agent-ops.d.ts.map +1 -1
  80. package/dist/src/commands/agent-ops.js +1 -59
  81. package/dist/src/commands/agent-ops.js.map +1 -1
  82. package/dist/src/commands/agent.d.ts.map +1 -1
  83. package/dist/src/commands/agent.js +2 -3
  84. package/dist/src/commands/agent.js.map +1 -1
  85. package/dist/src/commands/analyze-diff.js +1 -1
  86. package/dist/src/commands/analyze-diff.js.map +1 -1
  87. package/dist/src/commands/analyze.d.ts +0 -4
  88. package/dist/src/commands/analyze.d.ts.map +1 -1
  89. package/dist/src/commands/analyze.js +1 -29
  90. package/dist/src/commands/analyze.js.map +1 -1
  91. package/dist/src/commands/browse-action.d.ts.map +1 -1
  92. package/dist/src/commands/browse-action.js +94 -2
  93. package/dist/src/commands/browse-action.js.map +1 -1
  94. package/dist/src/commands/completions.d.ts.map +1 -1
  95. package/dist/src/commands/completions.js +12 -76
  96. package/dist/src/commands/completions.js.map +1 -1
  97. package/dist/src/commands/config.d.ts.map +1 -1
  98. package/dist/src/commands/config.js +0 -6
  99. package/dist/src/commands/config.js.map +1 -1
  100. package/dist/src/commands/doctor-project-checks.d.ts +13 -3
  101. package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
  102. package/dist/src/commands/doctor-project-checks.js +131 -23
  103. package/dist/src/commands/doctor-project-checks.js.map +1 -1
  104. package/dist/src/commands/doctor.d.ts.map +1 -1
  105. package/dist/src/commands/doctor.js +6 -5
  106. package/dist/src/commands/doctor.js.map +1 -1
  107. package/dist/src/commands/guidance.d.ts +5 -1
  108. package/dist/src/commands/guidance.d.ts.map +1 -1
  109. package/dist/src/commands/guidance.js +11 -556
  110. package/dist/src/commands/guidance.js.map +1 -1
  111. package/dist/src/commands/hive-mind-comms.d.ts.map +1 -1
  112. package/dist/src/commands/hive-mind-comms.js +11 -4
  113. package/dist/src/commands/hive-mind-comms.js.map +1 -1
  114. package/dist/src/commands/hive-mind-helpers.js +2 -2
  115. package/dist/src/commands/hive-mind-helpers.js.map +1 -1
  116. package/dist/src/commands/hive-mind-ops.d.ts +1 -3
  117. package/dist/src/commands/hive-mind-ops.d.ts.map +1 -1
  118. package/dist/src/commands/hive-mind-ops.js +2 -116
  119. package/dist/src/commands/hive-mind-ops.js.map +1 -1
  120. package/dist/src/commands/hive-mind.d.ts +4 -4
  121. package/dist/src/commands/hive-mind.d.ts.map +1 -1
  122. package/dist/src/commands/hive-mind.js +11 -11
  123. package/dist/src/commands/hive-mind.js.map +1 -1
  124. package/dist/src/commands/hooks-coverage-commands.d.ts.map +1 -1
  125. package/dist/src/commands/hooks-coverage-commands.js +8 -7
  126. package/dist/src/commands/hooks-coverage-commands.js.map +1 -1
  127. package/dist/src/commands/hooks-coverage-gaps.js +1 -1
  128. package/dist/src/commands/hooks-coverage-gaps.js.map +1 -1
  129. package/dist/src/commands/hooks-coverage-routing.js +2 -2
  130. package/dist/src/commands/hooks-coverage-routing.js.map +1 -1
  131. package/dist/src/commands/hooks-extended-commands.d.ts +0 -3
  132. package/dist/src/commands/hooks-extended-commands.d.ts.map +1 -1
  133. package/dist/src/commands/hooks-extended-commands.js +0 -307
  134. package/dist/src/commands/hooks-extended-commands.js.map +1 -1
  135. package/dist/src/commands/hooks-formatting.d.ts +1 -5
  136. package/dist/src/commands/hooks-formatting.d.ts.map +1 -1
  137. package/dist/src/commands/hooks-formatting.js +1 -18
  138. package/dist/src/commands/hooks-formatting.js.map +1 -1
  139. package/dist/src/commands/hooks-workers.d.ts +1 -1
  140. package/dist/src/commands/hooks-workers.d.ts.map +1 -1
  141. package/dist/src/commands/hooks-workers.js +82 -330
  142. package/dist/src/commands/hooks-workers.js.map +1 -1
  143. package/dist/src/commands/hooks.d.ts.map +1 -1
  144. package/dist/src/commands/hooks.js +1 -12
  145. package/dist/src/commands/hooks.js.map +1 -1
  146. package/dist/src/commands/index.d.ts +2 -55
  147. package/dist/src/commands/index.d.ts.map +1 -1
  148. package/dist/src/commands/index.js +23 -216
  149. package/dist/src/commands/index.js.map +1 -1
  150. package/dist/src/commands/init-wizard.d.ts.map +1 -1
  151. package/dist/src/commands/init-wizard.js +3 -5
  152. package/dist/src/commands/init-wizard.js.map +1 -1
  153. package/dist/src/commands/init.d.ts.map +1 -1
  154. package/dist/src/commands/init.js +4 -24
  155. package/dist/src/commands/init.js.map +1 -1
  156. package/dist/src/commands/mcp.d.ts.map +1 -1
  157. package/dist/src/commands/mcp.js +32 -4
  158. package/dist/src/commands/mcp.js.map +1 -1
  159. package/dist/src/commands/memory-admin.d.ts +1 -2
  160. package/dist/src/commands/memory-admin.d.ts.map +1 -1
  161. package/dist/src/commands/memory-admin.js +1 -118
  162. package/dist/src/commands/memory-admin.js.map +1 -1
  163. package/dist/src/commands/memory-transfer.d.ts +1 -2
  164. package/dist/src/commands/memory-transfer.d.ts.map +1 -1
  165. package/dist/src/commands/memory-transfer.js +5 -171
  166. package/dist/src/commands/memory-transfer.js.map +1 -1
  167. package/dist/src/commands/memory.d.ts.map +1 -1
  168. package/dist/src/commands/memory.js +3 -6
  169. package/dist/src/commands/memory.js.map +1 -1
  170. package/dist/src/commands/neural-core.d.ts +3 -1
  171. package/dist/src/commands/neural-core.d.ts.map +1 -1
  172. package/dist/src/commands/neural-core.js +154 -15
  173. package/dist/src/commands/neural-core.js.map +1 -1
  174. package/dist/src/commands/neural-optimize.d.ts.map +1 -1
  175. package/dist/src/commands/neural-optimize.js +13 -15
  176. package/dist/src/commands/neural-optimize.js.map +1 -1
  177. package/dist/src/commands/neural-registry.d.ts +1 -1
  178. package/dist/src/commands/neural-registry.js +14 -14
  179. package/dist/src/commands/neural-registry.js.map +1 -1
  180. package/dist/src/commands/neural.d.ts +1 -1
  181. package/dist/src/commands/neural.js +6 -6
  182. package/dist/src/commands/neural.js.map +1 -1
  183. package/dist/src/commands/performance.d.ts.map +1 -1
  184. package/dist/src/commands/performance.js +68 -58
  185. package/dist/src/commands/performance.js.map +1 -1
  186. package/dist/src/commands/providers.d.ts.map +1 -1
  187. package/dist/src/commands/providers.js +77 -117
  188. package/dist/src/commands/providers.js.map +1 -1
  189. package/dist/src/commands/search-universal.d.ts +7 -1
  190. package/dist/src/commands/search-universal.d.ts.map +1 -1
  191. package/dist/src/commands/search-universal.js +59 -5
  192. package/dist/src/commands/search-universal.js.map +1 -1
  193. package/dist/src/commands/security-cve.d.ts.map +1 -1
  194. package/dist/src/commands/security-cve.js +3 -5
  195. package/dist/src/commands/security-cve.js.map +1 -1
  196. package/dist/src/commands/security-misc.d.ts +0 -1
  197. package/dist/src/commands/security-misc.d.ts.map +1 -1
  198. package/dist/src/commands/security-misc.js +69 -45
  199. package/dist/src/commands/security-misc.js.map +1 -1
  200. package/dist/src/commands/security.d.ts.map +1 -1
  201. package/dist/src/commands/security.js +2 -4
  202. package/dist/src/commands/security.js.map +1 -1
  203. package/dist/src/commands/session.d.ts.map +1 -1
  204. package/dist/src/commands/session.js +137 -281
  205. package/dist/src/commands/session.js.map +1 -1
  206. package/dist/src/commands/start.d.ts.map +1 -1
  207. package/dist/src/commands/start.js +2 -59
  208. package/dist/src/commands/start.js.map +1 -1
  209. package/dist/src/commands/status.d.ts.map +1 -1
  210. package/dist/src/commands/status.js +18 -29
  211. package/dist/src/commands/status.js.map +1 -1
  212. package/dist/src/commands/swarm.d.ts.map +1 -1
  213. package/dist/src/commands/swarm.js +113 -66
  214. package/dist/src/commands/swarm.js.map +1 -1
  215. package/dist/src/commands/task.d.ts.map +1 -1
  216. package/dist/src/commands/task.js +2 -49
  217. package/dist/src/commands/task.js.map +1 -1
  218. package/dist/src/consensus/audit-writer.d.ts.map +1 -1
  219. package/dist/src/consensus/audit-writer.js +43 -1
  220. package/dist/src/consensus/audit-writer.js.map +1 -1
  221. package/dist/src/consensus/tally.d.ts +19 -0
  222. package/dist/src/consensus/tally.d.ts.map +1 -0
  223. package/dist/src/consensus/tally.js +34 -0
  224. package/dist/src/consensus/tally.js.map +1 -0
  225. package/dist/src/index.d.ts +3 -2
  226. package/dist/src/index.d.ts.map +1 -1
  227. package/dist/src/index.js +13 -9
  228. package/dist/src/index.js.map +1 -1
  229. package/dist/src/init/claudemd-generator.d.ts.map +1 -1
  230. package/dist/src/init/claudemd-generator.js +10 -14
  231. package/dist/src/init/claudemd-generator.js.map +1 -1
  232. package/dist/src/init/executor.d.ts.map +1 -1
  233. package/dist/src/init/executor.js +42 -100
  234. package/dist/src/init/executor.js.map +1 -1
  235. package/dist/src/init/helpers-generator.d.ts.map +1 -1
  236. package/dist/src/init/helpers-generator.js +2 -22
  237. package/dist/src/init/helpers-generator.js.map +1 -1
  238. package/dist/src/init/settings-generator.d.ts.map +1 -1
  239. package/dist/src/init/settings-generator.js +0 -13
  240. package/dist/src/init/settings-generator.js.map +1 -1
  241. package/dist/src/init/statusline-generator.d.ts.map +1 -1
  242. package/dist/src/init/statusline-generator.js +62 -0
  243. package/dist/src/init/statusline-generator.js.map +1 -1
  244. package/dist/src/init/types.d.ts +3 -9
  245. package/dist/src/init/types.d.ts.map +1 -1
  246. package/dist/src/init/types.js +0 -5
  247. package/dist/src/init/types.js.map +1 -1
  248. package/dist/src/knowledge/document-pipeline.d.ts.map +1 -1
  249. package/dist/src/knowledge/document-pipeline.js +18 -8
  250. package/dist/src/knowledge/document-pipeline.js.map +1 -1
  251. package/dist/src/mcp-client.d.ts.map +1 -1
  252. package/dist/src/mcp-client.js +0 -8
  253. package/dist/src/mcp-client.js.map +1 -1
  254. package/dist/src/mcp-server.d.ts.map +1 -1
  255. package/dist/src/mcp-server.js +14 -0
  256. package/dist/src/mcp-server.js.map +1 -1
  257. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
  258. package/dist/src/mcp-tools/agent-tools.js +0 -17
  259. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  260. package/dist/src/mcp-tools/coherence/causal-infer.d.ts +5 -5
  261. package/dist/src/mcp-tools/coherence/causal-infer.d.ts.map +1 -1
  262. package/dist/src/mcp-tools/coherence/causal-infer.js +32 -46
  263. package/dist/src/mcp-tools/coherence/causal-infer.js.map +1 -1
  264. package/dist/src/mcp-tools/coherence/coherence-check.d.ts.map +1 -1
  265. package/dist/src/mcp-tools/coherence/coherence-check.js +1 -19
  266. package/dist/src/mcp-tools/coherence/coherence-check.js.map +1 -1
  267. package/dist/src/mcp-tools/coherence/consensus-verify.d.ts +2 -3
  268. package/dist/src/mcp-tools/coherence/consensus-verify.d.ts.map +1 -1
  269. package/dist/src/mcp-tools/coherence/consensus-verify.js +22 -20
  270. package/dist/src/mcp-tools/coherence/consensus-verify.js.map +1 -1
  271. package/dist/src/mcp-tools/coherence/memory-gate.d.ts +3 -2
  272. package/dist/src/mcp-tools/coherence/memory-gate.d.ts.map +1 -1
  273. package/dist/src/mcp-tools/coherence/memory-gate.js +32 -19
  274. package/dist/src/mcp-tools/coherence/memory-gate.js.map +1 -1
  275. package/dist/src/mcp-tools/coherence/quantum-topology.d.ts +4 -4
  276. package/dist/src/mcp-tools/coherence/quantum-topology.d.ts.map +1 -1
  277. package/dist/src/mcp-tools/coherence/quantum-topology.js +11 -17
  278. package/dist/src/mcp-tools/coherence/quantum-topology.js.map +1 -1
  279. package/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +2 -3
  280. package/dist/src/mcp-tools/coherence/spectral-analyze.d.ts.map +1 -1
  281. package/dist/src/mcp-tools/coherence/spectral-analyze.js +51 -32
  282. package/dist/src/mcp-tools/coherence/spectral-analyze.js.map +1 -1
  283. package/dist/src/mcp-tools/coherence/types.d.ts +8 -11
  284. package/dist/src/mcp-tools/coherence/types.d.ts.map +1 -1
  285. package/dist/src/mcp-tools/coherence/types.js +3 -18
  286. package/dist/src/mcp-tools/coherence/types.js.map +1 -1
  287. package/dist/src/mcp-tools/embeddings-tools.d.ts.map +1 -1
  288. package/dist/src/mcp-tools/embeddings-tools.js +1 -7
  289. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  290. package/dist/src/mcp-tools/graphify-tools.js +2 -2
  291. package/dist/src/mcp-tools/graphify-tools.js.map +1 -1
  292. package/dist/src/mcp-tools/guidance-tools.d.ts.map +1 -1
  293. package/dist/src/mcp-tools/guidance-tools.js +9 -19
  294. package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
  295. package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -1
  296. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
  297. package/dist/src/mcp-tools/hive-mind-tools.js +198 -40
  298. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  299. package/dist/src/mcp-tools/hooks-advanced.d.ts +18 -0
  300. package/dist/src/mcp-tools/hooks-advanced.d.ts.map +1 -0
  301. package/dist/src/mcp-tools/hooks-advanced.js +25 -0
  302. package/dist/src/mcp-tools/hooks-advanced.js.map +1 -0
  303. package/dist/src/mcp-tools/hooks-intelligence.d.ts +4 -8
  304. package/dist/src/mcp-tools/hooks-intelligence.d.ts.map +1 -1
  305. package/dist/src/mcp-tools/hooks-intelligence.js +33 -482
  306. package/dist/src/mcp-tools/hooks-intelligence.js.map +1 -1
  307. package/dist/src/mcp-tools/hooks-routing.d.ts +1 -3
  308. package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
  309. package/dist/src/mcp-tools/hooks-routing.js +96 -202
  310. package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
  311. package/dist/src/mcp-tools/hooks-synthesis.d.ts +31 -0
  312. package/dist/src/mcp-tools/hooks-synthesis.d.ts.map +1 -0
  313. package/dist/src/mcp-tools/hooks-synthesis.js +196 -0
  314. package/dist/src/mcp-tools/hooks-synthesis.js.map +1 -0
  315. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  316. package/dist/src/mcp-tools/hooks-tools.js +10 -11
  317. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  318. package/dist/src/mcp-tools/index.d.ts +0 -3
  319. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  320. package/dist/src/mcp-tools/index.js +0 -4
  321. package/dist/src/mcp-tools/index.js.map +1 -1
  322. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  323. package/dist/src/mcp-tools/memory-tools.js +24 -9
  324. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  325. package/dist/src/mcp-tools/monograph-tools.d.ts +6 -0
  326. package/dist/src/mcp-tools/monograph-tools.d.ts.map +1 -1
  327. package/dist/src/mcp-tools/monograph-tools.js +370 -95
  328. package/dist/src/mcp-tools/monograph-tools.js.map +1 -1
  329. package/dist/src/mcp-tools/neural-tools.d.ts +8 -9
  330. package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
  331. package/dist/src/mcp-tools/neural-tools.js +249 -539
  332. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  333. package/dist/src/mcp-tools/performance-tools.d.ts.map +1 -1
  334. package/dist/src/mcp-tools/performance-tools.js +5 -17
  335. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  336. package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +2 -2
  337. package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js.map +1 -1
  338. package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
  339. package/dist/src/mcp-tools/quality-tools.d.ts +7 -2
  340. package/dist/src/mcp-tools/quality-tools.d.ts.map +1 -1
  341. package/dist/src/mcp-tools/quality-tools.js +7 -257
  342. package/dist/src/mcp-tools/quality-tools.js.map +1 -1
  343. package/dist/src/mcp-tools/security-tools.d.ts.map +1 -1
  344. package/dist/src/mcp-tools/security-tools.js +103 -0
  345. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  346. package/dist/src/memory/intelligence.d.ts +9 -9
  347. package/dist/src/memory/intelligence.d.ts.map +1 -1
  348. package/dist/src/memory/intelligence.js +71 -59
  349. package/dist/src/memory/intelligence.js.map +1 -1
  350. package/dist/src/memory/memory-bridge.d.ts +1 -0
  351. package/dist/src/memory/memory-bridge.d.ts.map +1 -1
  352. package/dist/src/memory/memory-bridge.js +47 -5
  353. package/dist/src/memory/memory-bridge.js.map +1 -1
  354. package/dist/src/memory/memory-read.d.ts.map +1 -1
  355. package/dist/src/memory/memory-read.js +1 -19
  356. package/dist/src/memory/memory-read.js.map +1 -1
  357. package/dist/src/suggest.d.ts.map +1 -1
  358. package/dist/src/suggest.js +1 -12
  359. package/dist/src/suggest.js.map +1 -1
  360. package/dist/src/transfer/store/discovery.d.ts +3 -2
  361. package/dist/src/transfer/store/discovery.d.ts.map +1 -1
  362. package/dist/src/transfer/store/discovery.js +22 -70
  363. package/dist/src/transfer/store/discovery.js.map +1 -1
  364. package/dist/src/update/checker.d.ts.map +1 -1
  365. package/dist/src/update/checker.js +0 -1
  366. package/dist/src/update/checker.js.map +1 -1
  367. package/dist/src/utils/cosine-similarity.d.ts +22 -0
  368. package/dist/src/utils/cosine-similarity.d.ts.map +1 -0
  369. package/dist/src/utils/cosine-similarity.js +38 -0
  370. package/dist/src/utils/cosine-similarity.js.map +1 -0
  371. package/dist/src/utils/input-guards.d.ts +51 -0
  372. package/dist/src/utils/input-guards.d.ts.map +1 -0
  373. package/dist/src/utils/input-guards.js +223 -0
  374. package/dist/src/utils/input-guards.js.map +1 -0
  375. package/dist/src/utils/json-file.d.ts +33 -0
  376. package/dist/src/utils/json-file.d.ts.map +1 -0
  377. package/dist/src/utils/json-file.js +57 -0
  378. package/dist/src/utils/json-file.js.map +1 -0
  379. package/dist/tsconfig.tsbuildinfo +1 -1
  380. package/package.json +9 -6
  381. package/scripts/sync-claude-assets.sh +16 -20
  382. package/.claude/agents/generated/case-analyst.md +0 -50
  383. package/.claude/agents/generated/channel-intelligence-director.md +0 -87
  384. package/.claude/agents/generated/chief-growth-officer.md +0 -88
  385. package/.claude/agents/generated/churn-analyst.md +0 -53
  386. package/.claude/agents/generated/code-reviewer.md +0 -55
  387. package/.claude/agents/generated/code-validator.md +0 -57
  388. package/.claude/agents/generated/complexity-scanner.md +0 -56
  389. package/.claude/agents/generated/content-seo-strategist.md +0 -90
  390. package/.claude/agents/generated/copy-editor.md +0 -45
  391. package/.claude/agents/generated/court-reporter.md +0 -50
  392. package/.claude/agents/generated/defender.md +0 -51
  393. package/.claude/agents/generated/devbot-orchestrator.md +0 -58
  394. package/.claude/agents/generated/devbot-planner.md +0 -63
  395. package/.claude/agents/generated/developer-community-strategist.md +0 -91
  396. package/.claude/agents/generated/editor-in-chief.md +0 -45
  397. package/.claude/agents/generated/fact-checker.md +0 -45
  398. package/.claude/agents/generated/impact-assessor.md +0 -54
  399. package/.claude/agents/generated/judge.md +0 -51
  400. package/.claude/agents/generated/outreach-partnership-strategist.md +0 -90
  401. package/.claude/agents/generated/prosecutor.md +0 -51
  402. package/.claude/agents/generated/reporter.md +0 -45
  403. package/.claude/agents/generated/social-media-strategist.md +0 -91
  404. package/.claude/agents/generated/video-visual-strategist.md +0 -90
  405. package/.claude/agents/reengineer-squad/boss.md +0 -113
  406. package/.claude/agents/reengineer-squad/critic-architect.md +0 -132
  407. package/.claude/agents/reengineer-squad/git-manager.md +0 -145
  408. package/.claude/agents/reengineer-squad/idea-generator.md +0 -95
  409. package/.claude/agents/reengineer-squad/implementer.md +0 -112
  410. package/.claude/agents/reengineer-squad/integration-planner.md +0 -112
  411. package/.claude/agents/reengineer-squad/source-analyst.md +0 -103
  412. package/.claude/agents/reengineer-squad/target-analyst.md +0 -118
  413. package/.claude/agents/reengineer-squad/tester.md +0 -105
  414. package/.claude/agents/sparc/architecture.md +0 -453
  415. package/.claude/agents/sparc/pseudocode.md +0 -299
  416. package/.claude/agents/sparc/refinement.md +0 -504
  417. package/.claude/agents/sparc/specification.md +0 -258
  418. package/.claude/agents/templates/implementer-sparc-coder.md +0 -231
  419. package/.claude/commands/sparc/analyzer.md +0 -35
  420. package/.claude/commands/sparc/architect.md +0 -36
  421. package/.claude/commands/sparc/ask.md +0 -56
  422. package/.claude/commands/sparc/batch-executor.md +0 -37
  423. package/.claude/commands/sparc/code.md +0 -48
  424. package/.claude/commands/sparc/coder.md +0 -37
  425. package/.claude/commands/sparc/debug.md +0 -42
  426. package/.claude/commands/sparc/debugger.md +0 -37
  427. package/.claude/commands/sparc/designer.md +0 -36
  428. package/.claude/commands/sparc/devops.md +0 -68
  429. package/.claude/commands/sparc/docs-writer.md +0 -39
  430. package/.claude/commands/sparc/documenter.md +0 -37
  431. package/.claude/commands/sparc/innovator.md +0 -37
  432. package/.claude/commands/sparc/integration.md +0 -42
  433. package/.claude/commands/sparc/mcp.md +0 -76
  434. package/.claude/commands/sparc/memory-manager.md +0 -57
  435. package/.claude/commands/sparc/optimizer.md +0 -37
  436. package/.claude/commands/sparc/orchestrator.md +0 -70
  437. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +0 -42
  438. package/.claude/commands/sparc/refinement-optimization-mode.md +0 -42
  439. package/.claude/commands/sparc/researcher.md +0 -37
  440. package/.claude/commands/sparc/reviewer.md +0 -37
  441. package/.claude/commands/sparc/security-review.md +0 -39
  442. package/.claude/commands/sparc/sparc-modes.md +0 -120
  443. package/.claude/commands/sparc/sparc.md +0 -71
  444. package/.claude/commands/sparc/spec-pseudocode.md +0 -39
  445. package/.claude/commands/sparc/supabase-admin.md +0 -301
  446. package/.claude/commands/sparc/swarm-coordinator.md +0 -50
  447. package/.claude/commands/sparc/tdd.md +0 -37
  448. package/.claude/commands/sparc/tester.md +0 -37
  449. package/.claude/commands/sparc/tutorial.md +0 -38
  450. package/.claude/commands/sparc/workflow-manager.md +0 -37
  451. package/.claude/commands/sparc.md +0 -112
  452. package/.claude/helpers/auto-memory-hook.mjs +0 -503
  453. package/.claude/skills/sparc-methodology/SKILL.md +0 -950
  454. package/dist/src/capabilities/enrichment.d.ts +0 -44
  455. package/dist/src/capabilities/enrichment.d.ts.map +0 -1
  456. package/dist/src/capabilities/enrichment.js +0 -141
  457. package/dist/src/capabilities/enrichment.js.map +0 -1
  458. package/dist/src/commands/analyze-boundaries.d.ts +0 -14
  459. package/dist/src/commands/analyze-boundaries.d.ts.map +0 -1
  460. package/dist/src/commands/analyze-boundaries.js +0 -295
  461. package/dist/src/commands/analyze-boundaries.js.map +0 -1
  462. package/dist/src/commands/analyze-graph.d.ts +0 -14
  463. package/dist/src/commands/analyze-graph.d.ts.map +0 -1
  464. package/dist/src/commands/analyze-graph.js +0 -304
  465. package/dist/src/commands/analyze-graph.js.map +0 -1
  466. package/dist/src/commands/claims.d.ts +0 -10
  467. package/dist/src/commands/claims.d.ts.map +0 -1
  468. package/dist/src/commands/claims.js +0 -650
  469. package/dist/src/commands/claims.js.map +0 -1
  470. package/dist/src/commands/daemon.d.ts +0 -8
  471. package/dist/src/commands/daemon.d.ts.map +0 -1
  472. package/dist/src/commands/daemon.js +0 -681
  473. package/dist/src/commands/daemon.js.map +0 -1
  474. package/dist/src/commands/deployment.d.ts +0 -10
  475. package/dist/src/commands/deployment.d.ts.map +0 -1
  476. package/dist/src/commands/deployment.js +0 -706
  477. package/dist/src/commands/deployment.js.map +0 -1
  478. package/dist/src/commands/enrich.d.ts +0 -10
  479. package/dist/src/commands/enrich.d.ts.map +0 -1
  480. package/dist/src/commands/enrich.js +0 -58
  481. package/dist/src/commands/enrich.js.map +0 -1
  482. package/dist/src/commands/issues.d.ts +0 -21
  483. package/dist/src/commands/issues.d.ts.map +0 -1
  484. package/dist/src/commands/issues.js +0 -575
  485. package/dist/src/commands/issues.js.map +0 -1
  486. package/dist/src/commands/workflow.d.ts +0 -8
  487. package/dist/src/commands/workflow.d.ts.map +0 -1
  488. package/dist/src/commands/workflow.js +0 -677
  489. package/dist/src/commands/workflow.js.map +0 -1
  490. package/dist/src/mcp-tools/workflow-tools.d.ts +0 -8
  491. package/dist/src/mcp-tools/workflow-tools.d.ts.map +0 -1
  492. package/dist/src/mcp-tools/workflow-tools.js +0 -717
  493. package/dist/src/mcp-tools/workflow-tools.js.map +0 -1
  494. package/dist/src/services/claim-service.d.ts +0 -198
  495. package/dist/src/services/claim-service.d.ts.map +0 -1
  496. package/dist/src/services/claim-service.js +0 -890
  497. package/dist/src/services/claim-service.js.map +0 -1
  498. package/dist/src/services/headless-worker-executor.d.ts +0 -311
  499. package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
  500. package/dist/src/services/headless-worker-executor.js +0 -1183
  501. package/dist/src/services/headless-worker-executor.js.map +0 -1
  502. package/dist/src/services/worker-daemon.d.ts +0 -248
  503. package/dist/src/services/worker-daemon.d.ts.map +0 -1
  504. package/dist/src/services/worker-daemon.js +0 -1417
  505. package/dist/src/services/worker-daemon.js.map +0 -1
  506. package/dist/src/ui/.monomind/capture/active-run.json +0 -1
  507. package/dist/src/ui/.monomind/orgs/system-trial-qa/runs/real-events-1782290897.convs.jsonl +0 -3
  508. package/dist/src/ui/.monomind/orgs/system-trial-qa/runs/real-events-1782290897.jsonl +0 -11
  509. package/dist/src/ui/.monomind/orgs/system-trial-qa/runs/rigid-qa-restart-1782288201.jsonl +0 -540
  510. package/dist/src/ui/.monomind/orgs/system-trial-qa-threads.jsonl +0 -3
  511. package/dist/src/ui/.monomind/orgs/test-event-fix/runs/rigid-qa-restart-1782288201.jsonl +0 -2
@@ -1,539 +1,12 @@
1
1
  /**
2
2
  * CLI Guidance Command
3
- * Guidance Control Plane - compile, retrieve, enforce, optimize
3
+ *
4
+ * Wires the enforcement gates (destructive-ops + secrets) into Claude Code hooks.
5
+ * The gates themselves live in .claude/helpers/handlers/gates-handler.cjs — a
6
+ * self-contained regex table that runs on every PreToolUse. This command only
7
+ * registers the hook entries in .claude/settings.json.
4
8
  */
5
9
  import { output } from '../output.js';
6
- // compile subcommand
7
- const compileCommand = {
8
- name: 'compile',
9
- description: 'Compile CLAUDE.md into a policy bundle (constitution + shards + manifest)',
10
- options: [
11
- { name: 'root', short: 'r', type: 'string', description: 'Root guidance file path', default: './CLAUDE.md' },
12
- { name: 'local', short: 'l', type: 'string', description: 'Local guidance overlay file path' },
13
- { name: 'output', short: 'o', type: 'string', description: 'Output directory for compiled bundle' },
14
- { name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
15
- ],
16
- examples: [
17
- { command: 'monomind guidance compile', description: 'Compile default CLAUDE.md' },
18
- { command: 'monomind guidance compile -r ./CLAUDE.md -l ./CLAUDE.local.md', description: 'Compile with local overlay' },
19
- { command: 'monomind guidance compile --json', description: 'Output compiled bundle as JSON' },
20
- ],
21
- action: async (ctx) => {
22
- const rootPath = ctx.flags.root || './CLAUDE.md';
23
- const localPath = ctx.flags.local;
24
- const jsonOutput = ctx.flags.json === true;
25
- output.writeln();
26
- output.writeln(output.bold('Guidance Compiler'));
27
- output.writeln(output.dim('─'.repeat(50)));
28
- try {
29
- const { readFile } = await import('node:fs/promises');
30
- const { existsSync } = await import('node:fs');
31
- if (!existsSync(rootPath)) {
32
- output.writeln(output.error(`Root guidance file not found: ${rootPath}`));
33
- return { success: false, message: `File not found: ${rootPath}` };
34
- }
35
- const rootContent = await readFile(rootPath, 'utf-8');
36
- let localContent;
37
- if (localPath && existsSync(localPath)) {
38
- localContent = await readFile(localPath, 'utf-8');
39
- }
40
- const { GuidanceCompiler } = await import('@monomind/guidance/compiler');
41
- const compiler = new GuidanceCompiler();
42
- const bundle = compiler.compile(rootContent, localContent);
43
- if (jsonOutput) {
44
- output.writeln(JSON.stringify(bundle, null, 2));
45
- }
46
- else {
47
- output.writeln(output.success('Compiled successfully'));
48
- output.writeln();
49
- output.writeln(` Constitution rules: ${output.bold(String(bundle.constitution.rules.length))}`);
50
- output.writeln(` Constitution hash: ${output.dim(bundle.constitution.hash)}`);
51
- output.writeln(` Shard count: ${output.bold(String(bundle.shards.length))}`);
52
- output.writeln(` Total rules: ${output.bold(String(bundle.manifest.totalRules))}`);
53
- output.writeln(` Compiled at: ${output.dim(new Date(bundle.manifest.compiledAt).toISOString())}`);
54
- if (localContent) {
55
- output.writeln(` Local overlay: ${output.success('applied')}`);
56
- }
57
- output.writeln();
58
- output.writeln(output.dim('Rule summary:'));
59
- for (const rule of bundle.manifest.rules.slice(0, 10)) {
60
- const risk = rule.riskClass === 'critical' ? output.error(rule.riskClass) :
61
- rule.riskClass === 'high' ? output.warning(rule.riskClass) :
62
- output.dim(rule.riskClass);
63
- output.writeln(` ${output.bold(rule.id)} [${risk}] ${rule.source.slice(0, 60)}${rule.source.length > 60 ? '...' : ''}`);
64
- }
65
- if (bundle.manifest.rules.length > 10) {
66
- output.writeln(output.dim(` ... and ${bundle.manifest.rules.length - 10} more`));
67
- }
68
- }
69
- return { success: true, data: bundle };
70
- }
71
- catch (error) {
72
- const msg = error instanceof Error ? error.message : String(error);
73
- output.writeln(output.error(`Compilation failed: ${msg}`));
74
- return { success: false, message: msg };
75
- }
76
- },
77
- };
78
- // retrieve subcommand
79
- const retrieveCommand = {
80
- name: 'retrieve',
81
- description: 'Retrieve task-relevant guidance shards for a given task description',
82
- options: [
83
- { name: 'task', short: 't', type: 'string', description: 'Task description', required: true },
84
- { name: 'root', short: 'r', type: 'string', description: 'Root guidance file path', default: './CLAUDE.md' },
85
- { name: 'local', short: 'l', type: 'string', description: 'Local overlay file path' },
86
- { name: 'max-shards', short: 'n', type: 'number', description: 'Maximum number of shards to retrieve', default: '5' },
87
- { name: 'intent', short: 'i', type: 'string', description: 'Override detected intent' },
88
- { name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
89
- ],
90
- examples: [
91
- { command: 'monomind guidance retrieve -t "Fix SQL injection in user search"', description: 'Retrieve guidance for a security task' },
92
- { command: 'monomind guidance retrieve -t "Add unit tests" -n 3', description: 'Retrieve top 3 shards for testing' },
93
- ],
94
- action: async (ctx) => {
95
- const task = ctx.flags.task;
96
- const rootPath = ctx.flags.root || './CLAUDE.md';
97
- const localPath = ctx.flags.local;
98
- const maxShards = parseInt(ctx.flags['max-shards'] || '5', 10);
99
- const intentOverride = ctx.flags.intent;
100
- const jsonOutput = ctx.flags.json === true;
101
- if (!task) {
102
- output.writeln(output.error('Task description is required (-t "...")'));
103
- return { success: false, message: 'Missing task description' };
104
- }
105
- output.writeln();
106
- output.writeln(output.bold('Guidance Retriever'));
107
- output.writeln(output.dim('─'.repeat(50)));
108
- try {
109
- const { readFile } = await import('node:fs/promises');
110
- const { existsSync } = await import('node:fs');
111
- const { GuidanceCompiler } = await import('@monomind/guidance/compiler');
112
- const { ShardRetriever, HashEmbeddingProvider } = await import('@monomind/guidance/retriever');
113
- if (!existsSync(rootPath)) {
114
- output.writeln(output.error(`Root guidance file not found: ${rootPath}`));
115
- return { success: false, message: `File not found: ${rootPath}` };
116
- }
117
- const rootContent = await readFile(rootPath, 'utf-8');
118
- let localContent;
119
- if (localPath && existsSync(localPath)) {
120
- localContent = await readFile(localPath, 'utf-8');
121
- }
122
- const compiler = new GuidanceCompiler();
123
- const bundle = compiler.compile(rootContent, localContent);
124
- const retriever = new ShardRetriever(new HashEmbeddingProvider(128));
125
- await retriever.loadBundle(bundle);
126
- const result = await retriever.retrieve({
127
- taskDescription: task,
128
- maxShards,
129
- intent: intentOverride,
130
- });
131
- if (jsonOutput) {
132
- output.writeln(JSON.stringify(result, null, 2));
133
- }
134
- else {
135
- output.writeln(` Detected intent: ${output.bold(result.detectedIntent)}`);
136
- output.writeln(` Retrieval time: ${output.dim(result.latencyMs + 'ms')}`);
137
- output.writeln(` Constitution: ${output.bold(String(result.constitution.rules.length))} rules`);
138
- output.writeln(` Shards: ${output.bold(String(result.shards.length))} retrieved`);
139
- output.writeln();
140
- if (result.shards.length > 0) {
141
- output.writeln(output.dim('Retrieved shards:'));
142
- for (const shard of result.shards) {
143
- output.writeln(` ${output.bold(shard.shard.rule.id)} [${shard.shard.rule.riskClass}] ${shard.shard.rule.text.slice(0, 60)}`);
144
- }
145
- }
146
- output.writeln();
147
- output.writeln(output.dim('Policy text preview:'));
148
- const lines = result.policyText.split('\n').slice(0, 15);
149
- for (const line of lines) {
150
- output.writeln(` ${line}`);
151
- }
152
- if (result.policyText.split('\n').length > 15) {
153
- output.writeln(output.dim(' ...'));
154
- }
155
- }
156
- return { success: true, data: result };
157
- }
158
- catch (error) {
159
- const msg = error instanceof Error ? error.message : String(error);
160
- output.writeln(output.error(`Retrieval failed: ${msg}`));
161
- return { success: false, message: msg };
162
- }
163
- },
164
- };
165
- // gates subcommand
166
- const gatesCommand = {
167
- name: 'gates',
168
- description: 'Evaluate enforcement gates against a command or content',
169
- options: [
170
- { name: 'command', short: 'c', type: 'string', description: 'Command to evaluate' },
171
- { name: 'content', type: 'string', description: 'Content to check for secrets' },
172
- { name: 'tool', short: 't', type: 'string', description: 'Tool name to check against allowlist' },
173
- { name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
174
- ],
175
- examples: [
176
- { command: 'monomind guidance gates -c "rm -rf /tmp"', description: 'Check if a command is destructive' },
177
- { command: 'monomind guidance gates --content "api_key=sk-abc123..."', description: 'Check content for secrets' },
178
- ],
179
- action: async (ctx) => {
180
- const command = ctx.flags.command;
181
- const content = ctx.flags.content;
182
- const tool = ctx.flags.tool;
183
- const jsonOutput = ctx.flags.json === true;
184
- output.writeln();
185
- output.writeln(output.bold('Enforcement Gates'));
186
- output.writeln(output.dim('─'.repeat(50)));
187
- try {
188
- const { EnforcementGates } = await import('@monomind/guidance/gates');
189
- const gates = new EnforcementGates();
190
- const results = [];
191
- if (command) {
192
- const gateResults = gates.evaluateCommand(command);
193
- results.push({ type: 'command', result: gateResults });
194
- }
195
- if (content) {
196
- const secretResult = gates.evaluateSecrets(content);
197
- results.push({ type: 'secrets', result: secretResult });
198
- }
199
- if (tool) {
200
- const toolResult = gates.evaluateToolAllowlist(tool);
201
- // evaluateToolAllowlist returns null when allowedTools is empty (no allowlist configured)
202
- if (toolResult === null) {
203
- output.writeln(output.warning(` tool-allowlist: no tools configured — all tools pass by default. Use a GuidanceControlPlane with allowedTools to restrict.`));
204
- }
205
- results.push({ type: 'tool-allowlist', result: toolResult });
206
- }
207
- if (results.length === 0) {
208
- output.writeln(output.warning('No input provided. Use -c, --content, or -t to evaluate.'));
209
- return { success: false, message: 'No input' };
210
- }
211
- if (jsonOutput) {
212
- output.writeln(JSON.stringify(results, null, 2));
213
- }
214
- else {
215
- for (const { type, result } of results) {
216
- output.writeln(` ${output.bold(type)}:`);
217
- if (result === null) {
218
- output.writeln(` ${output.success('ALLOW')} - No gate triggered`);
219
- }
220
- else if (Array.isArray(result)) {
221
- if (result.length === 0) {
222
- output.writeln(` ${output.success('ALLOW')} - All gates passed`);
223
- }
224
- else {
225
- for (const r of result) {
226
- const color = r.decision === 'block' ? output.error.bind(output) :
227
- r.decision === 'require-confirmation' ? output.warning.bind(output) :
228
- output.dim.bind(output);
229
- output.writeln(` ${color(r.decision.toUpperCase())} [${r.gateName}] ${r.reason}`);
230
- if (r.remediation) {
231
- output.writeln(` Remediation: ${output.dim(r.remediation)}`);
232
- }
233
- }
234
- }
235
- }
236
- else {
237
- const color = result.decision === 'block' ? output.error.bind(output) :
238
- result.decision === 'require-confirmation' ? output.warning.bind(output) :
239
- output.dim.bind(output);
240
- output.writeln(` ${color(result.decision.toUpperCase())} [${result.gateName}] ${result.reason}`);
241
- if (result.remediation) {
242
- output.writeln(` Remediation: ${output.dim(result.remediation)}`);
243
- }
244
- }
245
- }
246
- }
247
- return { success: true, data: results };
248
- }
249
- catch (error) {
250
- const msg = error instanceof Error ? error.message : String(error);
251
- output.writeln(output.error(`Gate evaluation failed: ${msg}`));
252
- return { success: false, message: msg };
253
- }
254
- },
255
- };
256
- // status subcommand
257
- const statusCommand = {
258
- name: 'status',
259
- description: 'Show guidance control plane status and metrics',
260
- options: [
261
- { name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
262
- ],
263
- action: async (ctx) => {
264
- const jsonOutput = ctx.flags.json === true;
265
- output.writeln();
266
- output.writeln(output.bold('Guidance Control Plane Status'));
267
- output.writeln(output.dim('─'.repeat(50)));
268
- try {
269
- const { existsSync } = await import('node:fs');
270
- const rootExists = existsSync('./CLAUDE.md');
271
- const localExists = existsSync('./CLAUDE.local.md');
272
- const statusData = {
273
- rootGuidance: rootExists ? 'found' : 'not found',
274
- localOverlay: localExists ? 'found' : 'not configured',
275
- dataDir: existsSync('./.monomind/guidance') ? 'exists' : 'not created',
276
- };
277
- if (jsonOutput) {
278
- output.writeln(JSON.stringify(statusData, null, 2));
279
- }
280
- else {
281
- output.writeln(` Root guidance: ${rootExists ? output.success('CLAUDE.md found') : output.warning('CLAUDE.md not found')}`);
282
- output.writeln(` Local overlay: ${localExists ? output.success('CLAUDE.local.md found') : output.dim('not configured')}`);
283
- output.writeln(` Data directory: ${statusData.dataDir === 'exists' ? output.success('exists') : output.dim('not created')}`);
284
- if (rootExists) {
285
- const { readFile } = await import('node:fs/promises');
286
- const { GuidanceCompiler } = await import('@monomind/guidance/compiler');
287
- const rootContent = await readFile('./CLAUDE.md', 'utf-8');
288
- const compiler = new GuidanceCompiler();
289
- const bundle = compiler.compile(rootContent);
290
- output.writeln();
291
- output.writeln(output.dim('Compiled bundle:'));
292
- output.writeln(` Constitution rules: ${output.bold(String(bundle.constitution.rules.length))}`);
293
- output.writeln(` Shard count: ${output.bold(String(bundle.shards.length))}`);
294
- output.writeln(` Total rules: ${output.bold(String(bundle.manifest.totalRules))}`);
295
- output.writeln(` Hash: ${output.dim(bundle.constitution.hash)}`);
296
- }
297
- }
298
- return { success: true, data: statusData };
299
- }
300
- catch (error) {
301
- const msg = error instanceof Error ? error.message : String(error);
302
- output.writeln(output.error(`Status check failed: ${msg}`));
303
- return { success: false, message: msg };
304
- }
305
- },
306
- };
307
- // optimize subcommand
308
- const optimizeCommand = {
309
- name: 'optimize',
310
- description: 'Analyze and optimize a CLAUDE.md file for structure, coverage, and enforceability',
311
- options: [
312
- { name: 'root', short: 'r', type: 'string', description: 'Root guidance file path', default: './CLAUDE.md' },
313
- { name: 'local', short: 'l', type: 'string', description: 'Local overlay file path' },
314
- { name: 'apply', short: 'a', type: 'boolean', description: 'Apply optimizations to the file', default: 'false' },
315
- { name: 'context-size', short: 's', type: 'string', description: 'Target context size: compact, standard, full', default: 'standard' },
316
- { name: 'target-score', type: 'number', description: 'Target composite score (0-100)', default: '90' },
317
- { name: 'max-iterations', type: 'number', description: 'Maximum optimization iterations', default: '5' },
318
- { name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
319
- ],
320
- examples: [
321
- { command: 'monomind guidance optimize', description: 'Analyze current CLAUDE.md and show suggestions' },
322
- { command: 'monomind guidance optimize --apply', description: 'Apply optimizations to CLAUDE.md' },
323
- { command: 'monomind guidance optimize -s compact --apply', description: 'Optimize for compact context window' },
324
- { command: 'monomind guidance optimize --target-score 95', description: 'Optimize until score reaches 95' },
325
- ],
326
- action: async (ctx) => {
327
- const rootPath = ctx.flags.root || './CLAUDE.md';
328
- const localPath = ctx.flags.local;
329
- const applyChanges = ctx.flags.apply === true;
330
- const contextSize = (ctx.flags['context-size'] || 'standard');
331
- const targetScore = parseInt(ctx.flags['target-score'] || '90', 10);
332
- const maxIterations = parseInt(ctx.flags['max-iterations'] || '5', 10);
333
- const jsonOutput = ctx.flags.json === true;
334
- output.writeln();
335
- output.writeln(output.bold('Guidance Optimizer'));
336
- output.writeln(output.dim('─'.repeat(50)));
337
- try {
338
- const { readFile, writeFile } = await import('node:fs/promises');
339
- const { existsSync } = await import('node:fs');
340
- if (!existsSync(rootPath)) {
341
- output.writeln(output.error(`Root guidance file not found: ${rootPath}`));
342
- return { success: false, message: `File not found: ${rootPath}` };
343
- }
344
- const rootContent = await readFile(rootPath, 'utf-8');
345
- let localContent;
346
- if (localPath && existsSync(localPath)) {
347
- localContent = await readFile(localPath, 'utf-8');
348
- }
349
- // Step 1: Analyze current state
350
- const { analyze, formatReport, optimizeForSize, formatBenchmark } = await import('@monomind/guidance/analyzer');
351
- const analysis = analyze(rootContent, localContent);
352
- if (jsonOutput && !applyChanges) {
353
- output.writeln(JSON.stringify(analysis, null, 2));
354
- return { success: true, data: analysis };
355
- }
356
- // Show current analysis
357
- output.writeln(formatReport(analysis));
358
- output.writeln();
359
- if (analysis.compositeScore >= targetScore) {
360
- output.writeln(output.success(`Score ${analysis.compositeScore}/100 already meets target ${targetScore}. No optimization needed.`));
361
- return { success: true, data: analysis };
362
- }
363
- // Step 2: Run optimization
364
- output.writeln(output.dim(`Optimizing (target: ${targetScore}, context: ${contextSize}, max iterations: ${maxIterations})...`));
365
- const result = optimizeForSize(rootContent, {
366
- contextSize,
367
- localContent,
368
- maxIterations,
369
- targetScore,
370
- });
371
- if (jsonOutput) {
372
- output.writeln(JSON.stringify({
373
- before: analysis,
374
- after: result.benchmark.after,
375
- delta: result.benchmark.delta,
376
- steps: result.appliedSteps,
377
- }, null, 2));
378
- return { success: true, data: result };
379
- }
380
- // Show benchmark comparison
381
- output.writeln();
382
- output.writeln(formatBenchmark(result.benchmark));
383
- output.writeln();
384
- if (result.appliedSteps.length > 0) {
385
- output.writeln(`Applied ${output.bold(String(result.appliedSteps.length))} optimization steps:`);
386
- for (const step of result.appliedSteps) {
387
- output.writeln(` ${output.success('+')} ${step}`);
388
- }
389
- output.writeln();
390
- }
391
- // Step 3: Apply if requested
392
- if (applyChanges) {
393
- await writeFile(rootPath, result.optimized, 'utf-8');
394
- output.writeln(output.success(`Optimized CLAUDE.md written to ${rootPath}`));
395
- output.writeln(` Before: ${analysis.compositeScore}/100 (${analysis.grade})`);
396
- output.writeln(` After: ${result.benchmark.after.compositeScore}/100 (${result.benchmark.after.grade})`);
397
- output.writeln(` Delta: ${result.benchmark.delta >= 0 ? '+' : ''}${result.benchmark.delta}`);
398
- }
399
- else {
400
- output.writeln(output.warning('Dry run - use --apply to write changes.'));
401
- output.writeln(` Projected: ${analysis.compositeScore} → ${result.benchmark.after.compositeScore}/100`);
402
- }
403
- return { success: true, data: result };
404
- }
405
- catch (error) {
406
- const msg = error instanceof Error ? error.message : String(error);
407
- output.writeln(output.error(`Optimization failed: ${msg}`));
408
- return { success: false, message: msg };
409
- }
410
- },
411
- };
412
- // ab-test subcommand
413
- const abTestCommand = {
414
- name: 'ab-test',
415
- description: 'Run A/B behavioral comparison between two CLAUDE.md versions',
416
- options: [
417
- { name: 'config-a', short: 'a', type: 'string', description: 'Path to Config A (baseline CLAUDE.md). Defaults to no guidance.' },
418
- { name: 'config-b', short: 'b', type: 'string', description: 'Path to Config B (candidate CLAUDE.md)', default: './CLAUDE.md' },
419
- { name: 'tasks', short: 't', type: 'string', description: 'Path to custom task JSON file (array of ABTask objects)' },
420
- { name: 'work-dir', short: 'w', type: 'string', description: 'Working directory for test execution' },
421
- { name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
422
- ],
423
- examples: [
424
- { command: 'monomind guidance ab-test', description: 'Run default A/B test (no guidance vs ./CLAUDE.md)' },
425
- { command: 'monomind guidance ab-test -a old.md -b new.md', description: 'Compare two CLAUDE.md versions' },
426
- { command: 'monomind guidance ab-test --tasks custom-tasks.json', description: 'Run with custom test tasks' },
427
- { command: 'monomind guidance ab-test --json', description: 'Output full report as JSON' },
428
- ],
429
- action: async (ctx) => {
430
- const configAPath = ctx.flags['config-a'];
431
- const configBPath = ctx.flags['config-b'] || './CLAUDE.md';
432
- const tasksPath = ctx.flags.tasks;
433
- const workDir = ctx.flags['work-dir'];
434
- const jsonOutput = ctx.flags.json === true;
435
- output.writeln();
436
- output.writeln(output.bold('A/B Behavioral Benchmark'));
437
- output.writeln(output.dim('─'.repeat(50)));
438
- try {
439
- const { readFile } = await import('node:fs/promises');
440
- const { existsSync } = await import('node:fs');
441
- const { abBenchmark, getDefaultABTasks } = await import('@monomind/guidance/analyzer');
442
- // Load Config B (candidate) content
443
- if (!existsSync(configBPath)) {
444
- output.writeln(output.error(`Config B file not found: ${configBPath}`));
445
- return { success: false, message: `File not found: ${configBPath}` };
446
- }
447
- const configBContent = await readFile(configBPath, 'utf-8');
448
- // Optionally load Config A for display context
449
- let configALabel = 'No control plane (baseline)';
450
- if (configAPath) {
451
- if (!existsSync(configAPath)) {
452
- output.writeln(output.error(`Config A file not found: ${configAPath}`));
453
- return { success: false, message: `File not found: ${configAPath}` };
454
- }
455
- configALabel = configAPath;
456
- }
457
- // Load custom tasks if provided
458
- let customTasks;
459
- if (tasksPath) {
460
- if (!existsSync(tasksPath)) {
461
- output.writeln(output.error(`Tasks file not found: ${tasksPath}`));
462
- return { success: false, message: `File not found: ${tasksPath}` };
463
- }
464
- // Size guard: a multi-MB tasks file would be buffered in full before
465
- // JSON.parse runs. Cap at 10 MB — any legitimate task list is far smaller.
466
- const { statSync, lstatSync } = await import('node:fs');
467
- const tasksLstat = lstatSync(tasksPath);
468
- if (tasksLstat.isSymbolicLink()) {
469
- output.writeln(output.error(`Symlinks are not allowed as task files: ${tasksPath}`));
470
- return { success: false, message: 'Symlink not allowed as tasks file' };
471
- }
472
- const MAX_TASKS_FILE_BYTES = 10 * 1024 * 1024; // 10 MB
473
- if (tasksLstat.size > MAX_TASKS_FILE_BYTES) {
474
- output.writeln(output.error(`Tasks file too large (max 10 MB): ${tasksPath}`));
475
- return { success: false, message: 'Tasks file too large' };
476
- }
477
- const tasksJson = await readFile(tasksPath, 'utf-8');
478
- customTasks = JSON.parse(tasksJson);
479
- output.writeln(` Custom tasks: ${output.bold(String(customTasks.length))} loaded from ${tasksPath}`);
480
- }
481
- output.writeln(` Config A: ${output.dim(configALabel)}`);
482
- output.writeln(` Config B: ${output.dim(configBPath)}`);
483
- output.writeln(` Tasks: ${output.dim(customTasks ? `${customTasks.length} custom` : `${getDefaultABTasks().length} default`)}`);
484
- output.writeln();
485
- output.writeln(output.dim('Running benchmark...'));
486
- // Run the A/B benchmark
487
- const report = await abBenchmark(configBContent, {
488
- tasks: customTasks,
489
- workDir,
490
- });
491
- if (jsonOutput) {
492
- output.writeln(JSON.stringify({
493
- configA: { label: configALabel, metrics: report.configA.metrics },
494
- configB: { label: configBPath, metrics: report.configB.metrics },
495
- compositeDelta: report.compositeDelta,
496
- classDeltas: report.classDeltas,
497
- categoryShift: report.categoryShift,
498
- taskResults: {
499
- configA: report.configA.taskResults.map(r => ({
500
- taskId: r.taskId, taskClass: r.taskClass, passed: r.passed,
501
- violations: r.violations.length, toolCalls: r.toolCalls,
502
- })),
503
- configB: report.configB.taskResults.map(r => ({
504
- taskId: r.taskId, taskClass: r.taskClass, passed: r.passed,
505
- violations: r.violations.length, toolCalls: r.toolCalls,
506
- })),
507
- },
508
- }, null, 2));
509
- return { success: true, data: report };
510
- }
511
- // Print formatted report
512
- output.writeln(report.report);
513
- output.writeln();
514
- // Summary verdict
515
- const delta = report.compositeDelta;
516
- if (delta > 0.05) {
517
- output.writeln(output.success(`Config B is better (+${delta} composite delta)`));
518
- }
519
- else if (delta < -0.05) {
520
- output.writeln(output.error(`Config B is worse (${delta} composite delta)`));
521
- }
522
- else {
523
- output.writeln(output.warning(`No significant difference (${delta} composite delta)`));
524
- }
525
- if (report.categoryShift) {
526
- output.writeln(output.success('Category shift detected: 3+ task classes improved by 20%+'));
527
- }
528
- return { success: true, data: report };
529
- }
530
- catch (error) {
531
- const msg = error instanceof Error ? error.message : String(error);
532
- output.writeln(output.error(`A/B benchmark failed: ${msg}`));
533
- return { success: false, message: msg };
534
- }
535
- },
536
- };
537
10
  // setup subcommand
538
11
  const setupCommand = {
539
12
  name: 'setup',
@@ -659,42 +132,24 @@ const setupCommand = {
659
132
  // Main guidance command
660
133
  export const guidanceCommand = {
661
134
  name: 'guidance',
662
- description: 'Guidance Control Plane - compile, retrieve, enforce, and optimize guidance rules',
135
+ description: 'Wire enforcement gates (destructive-ops + secrets) into Claude Code hooks',
663
136
  aliases: ['guide', 'policy'],
664
- subcommands: [
665
- compileCommand,
666
- retrieveCommand,
667
- gatesCommand,
668
- statusCommand,
669
- optimizeCommand,
670
- abTestCommand,
671
- setupCommand,
672
- ],
137
+ subcommands: [setupCommand],
673
138
  options: [],
674
139
  examples: [
675
- { command: 'monomind guidance compile', description: 'Compile CLAUDE.md into policy bundle' },
676
- { command: 'monomind guidance retrieve -t "Fix auth bug"', description: 'Retrieve relevant guidance' },
677
- { command: 'monomind guidance gates -c "rm -rf /"', description: 'Check enforcement gates' },
678
- { command: 'monomind guidance status', description: 'Show control plane status' },
679
- { command: 'monomind guidance optimize', description: 'Analyze and optimize CLAUDE.md' },
680
- { command: 'monomind guidance ab-test', description: 'Run A/B behavioral comparison' },
681
140
  { command: 'monomind guidance setup', description: 'Wire enforcement gates into Claude Code hooks' },
141
+ { command: 'monomind guidance setup --dry-run', description: 'Preview changes without writing' },
682
142
  ],
683
143
  action: async (ctx) => {
684
144
  output.writeln();
685
- output.writeln(output.bold('Guidance Control Plane'));
145
+ output.writeln(output.bold('Guidance Gates'));
686
146
  output.writeln(output.dim('─'.repeat(50)));
687
147
  output.writeln();
688
148
  output.writeln('Available subcommands:');
689
- output.writeln(` ${output.bold('compile')} Compile CLAUDE.md into policy bundle`);
690
- output.writeln(` ${output.bold('retrieve')} Retrieve task-relevant guidance shards`);
691
- output.writeln(` ${output.bold('gates')} Evaluate enforcement gates`);
692
- output.writeln(` ${output.bold('status')} Show control plane status`);
693
- output.writeln(` ${output.bold('optimize')} Analyze and optimize CLAUDE.md`);
694
- output.writeln(` ${output.bold('ab-test')} Run A/B behavioral comparison`);
695
149
  output.writeln(` ${output.bold('setup')} Wire enforcement gates into Claude Code hooks`);
696
150
  output.writeln();
697
- output.writeln(output.dim('Use monomind guidance <subcommand> --help for details'));
151
+ output.writeln(output.dim('Gate enforcement runs in .claude/helpers/handlers/gates-handler.cjs on every PreToolUse.'));
152
+ output.writeln(output.dim('Use monomind guidance setup --help for details'));
698
153
  return { success: true };
699
154
  },
700
155
  };