@cleocode/cleo 2026.10.3 → 2026.10.5-rc.ci.672

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 (352) hide show
  1. package/README.md +7 -0
  2. package/bin/cleo.js +11 -1
  3. package/dist/cli/adapter-OUQRSFZL.js +159 -0
  4. package/dist/cli/add-4SRRJL4U.js +443 -0
  5. package/dist/cli/add-batch-TSWICA5J.js +164 -0
  6. package/dist/cli/admin-L3F6CDYH.js +1428 -0
  7. package/dist/cli/admin-YMU55YCU.js +341 -0
  8. package/dist/cli/adr-XESRMFMP.js +172 -0
  9. package/dist/cli/agent-TAFPIYUU.js +2404 -0
  10. package/dist/cli/agent-outputs-HVJJIPS4.js +84 -0
  11. package/dist/cli/analyze-YQ22QVGW.js +49 -0
  12. package/dist/cli/archive-W5XX6AH7.js +65 -0
  13. package/dist/cli/archive-stats-HP2KPAJU.js +101 -0
  14. package/dist/cli/attention-7JBDCRZX.js +124 -0
  15. package/dist/cli/attention-ZXZANHKC.js +168 -0
  16. package/dist/cli/audit-ICA2SEFN.js +122 -0
  17. package/dist/cli/auth-DXIG5OG7.js +491 -0
  18. package/dist/cli/backfill-LBSYBWLR.js +156 -0
  19. package/dist/cli/backup-NUGBZ7NA.js +588 -0
  20. package/dist/cli/backup-inspect-PDRXI45A.js +26 -0
  21. package/dist/cli/backup-recover-TVKAPERB.js +29 -0
  22. package/dist/cli/blockers-ZOPCGHDW.js +55 -0
  23. package/dist/cli/brain-EJOBKL4A.js +397 -0
  24. package/dist/cli/briefing-RDQJ6WHS.js +213 -0
  25. package/dist/cli/caamp-Z3XPKEHB.js +181 -0
  26. package/dist/cli/cancel-S7EHLCJN.js +85 -0
  27. package/dist/cli/canon-NPF5RODM.js +142 -0
  28. package/dist/cli/canon-docs-2GTOLF7Y.js +26 -0
  29. package/dist/cli/cant-CHNN6O57.js +239 -0
  30. package/dist/cli/changeset-RYPHPN2B.js +246 -0
  31. package/dist/cli/check-C67YAU7W.js +759 -0
  32. package/dist/cli/check-DHMURGHC.js +924 -0
  33. package/dist/cli/checkpoint-UWDFOGYQ.js +128 -0
  34. package/dist/cli/chunk-22YPFZYB.js +91 -0
  35. package/dist/cli/chunk-2MGFDMDF.js +272 -0
  36. package/dist/cli/chunk-47JYZAMS.js +30 -0
  37. package/dist/cli/chunk-4JYHPP4C.js +76 -0
  38. package/dist/cli/chunk-4PEODTHY.js +278 -0
  39. package/dist/cli/chunk-4RGSNUUP.js +950 -0
  40. package/dist/cli/chunk-4VASFLUW.js +35 -0
  41. package/dist/cli/chunk-5PNI276X.js +124 -0
  42. package/dist/cli/chunk-6JSJNYH2.js +114 -0
  43. package/dist/cli/chunk-6N6WGLXE.js +63 -0
  44. package/dist/cli/chunk-75UH3BLS.js +210 -0
  45. package/dist/cli/chunk-7ACK4EIN.js +92 -0
  46. package/dist/cli/chunk-7NMKLVMI.js +107 -0
  47. package/dist/cli/chunk-7SINJXB6.js +110 -0
  48. package/dist/cli/chunk-7UARFJYS.js +46 -0
  49. package/dist/cli/chunk-7ZYPQV4N.js +90 -0
  50. package/dist/cli/chunk-AQCYT3L4.js +72 -0
  51. package/dist/cli/chunk-BQK6XTOH.js +57 -0
  52. package/dist/cli/chunk-C3B7C43W.js +16 -0
  53. package/dist/cli/chunk-CAPAGD5E.js +98 -0
  54. package/dist/cli/chunk-CHGEDCKG.js +77 -0
  55. package/dist/cli/chunk-COXFJ3PT.js +74 -0
  56. package/dist/cli/chunk-D7BAQNV2.js +55 -0
  57. package/dist/cli/chunk-EIUXVHNF.js +258 -0
  58. package/dist/cli/chunk-EUGB6P5V.js +173 -0
  59. package/dist/cli/chunk-EW2CKNNZ.js +304 -0
  60. package/dist/cli/chunk-FSKN4DWC.js +108 -0
  61. package/dist/cli/chunk-FVKLULL7.js +48 -0
  62. package/dist/cli/chunk-GAGUBU4Z.js +280 -0
  63. package/dist/cli/chunk-GKRFH2YG.js +171 -0
  64. package/dist/cli/chunk-GRU74UE4.js +270 -0
  65. package/dist/cli/chunk-GZFVDR44.js +320 -0
  66. package/dist/cli/chunk-HFLLZE6A.js +83 -0
  67. package/dist/cli/chunk-HXRXT3XU.js +78 -0
  68. package/dist/cli/chunk-IIOGUY3B.js +258 -0
  69. package/dist/cli/chunk-ILWWL462.js +60 -0
  70. package/dist/cli/chunk-J5USPJKZ.js +48 -0
  71. package/dist/cli/chunk-KEQS36GD.js +88 -0
  72. package/dist/cli/chunk-L7ONYSV6.js +2497 -0
  73. package/dist/cli/chunk-LVGIFMCV.js +163 -0
  74. package/dist/cli/chunk-NEFMQYLE.js +656 -0
  75. package/dist/cli/chunk-NU6CQQVB.js +4501 -0
  76. package/dist/cli/chunk-OILHT47L.js +252 -0
  77. package/dist/cli/chunk-PKKZPOOP.js +352 -0
  78. package/dist/cli/chunk-PN4WW5VX.js +66 -0
  79. package/dist/cli/chunk-PSJ33WVO.js +56 -0
  80. package/dist/cli/chunk-QA6T2LQ5.js +71 -0
  81. package/dist/cli/chunk-QJJWWCIC.js +288 -0
  82. package/dist/cli/chunk-QKMBWYAS.js +93 -0
  83. package/dist/cli/chunk-QWNKLLLG.js +84 -0
  84. package/dist/cli/chunk-QWUFFDL3.js +85 -0
  85. package/dist/cli/chunk-QY76BRUZ.js +35 -0
  86. package/dist/cli/chunk-R45KVF5Y.js +117 -0
  87. package/dist/cli/chunk-RRKP7HLU.js +66 -0
  88. package/dist/cli/chunk-SXXOC6KZ.js +209 -0
  89. package/dist/cli/chunk-T6GZJYL3.js +108 -0
  90. package/dist/cli/chunk-TLQ37HRE.js +67 -0
  91. package/dist/cli/chunk-TPTNEJZJ.js +52 -0
  92. package/dist/cli/chunk-TYC7G5LF.js +100 -0
  93. package/dist/cli/chunk-UWCZY52R.js +766 -0
  94. package/dist/cli/chunk-VB3LDPL5.js +46 -0
  95. package/dist/cli/chunk-VLEYOOPH.js +31 -0
  96. package/dist/cli/chunk-W3JLYKKY.js +140 -0
  97. package/dist/cli/chunk-WWCYZYSN.js +56 -0
  98. package/dist/cli/chunk-XA5WISNV.js +52 -0
  99. package/dist/cli/chunk-XHRZ7OYZ.js +132 -0
  100. package/dist/cli/chunk-XLPMIGJJ.js +148 -0
  101. package/dist/cli/chunk-YY66LFZF.js +29 -0
  102. package/dist/cli/chunk-ZMGDZMSJ.js +210 -0
  103. package/dist/cli/claim-IGOG2QOC.js +97 -0
  104. package/dist/cli/classify-MG4N7GMQ.js +117 -0
  105. package/dist/cli/cli-A23Q335V.js +51 -0
  106. package/dist/cli/cloud-SILYJVKO.js +731 -0
  107. package/dist/cli/cockpit-RZKLGYPN.js +790 -0
  108. package/dist/cli/code-H2FQCVMW.js +178 -0
  109. package/dist/cli/complete-JLX7NBI4.js +35 -0
  110. package/dist/cli/complexity-OKV7PVZH.js +57 -0
  111. package/dist/cli/compliance-QMGZHJNQ.js +277 -0
  112. package/dist/cli/conduit-4H32UYEA.js +308 -0
  113. package/dist/cli/conduit-EY54WTZA.js +535 -0
  114. package/dist/cli/config-TDYOC7XO.js +519 -0
  115. package/dist/cli/consensus-4XCOFPPT.js +122 -0
  116. package/dist/cli/context-FN4YTGHD.js +142 -0
  117. package/dist/cli/contribution-7RWFBJLC.js +112 -0
  118. package/dist/cli/curator-HKZJCVRL.js +139 -0
  119. package/dist/cli/current-B2NU7V3G.js +43 -0
  120. package/dist/cli/daemon-GBD4TVCD.js +452 -0
  121. package/dist/cli/dash-IGDANIE5.js +71 -0
  122. package/dist/cli/decide-26SXC2V6.js +416 -0
  123. package/dist/cli/decompose-LQ76TEZG.js +78 -0
  124. package/dist/cli/decomposition-WFRWNUSJ.js +122 -0
  125. package/dist/cli/delete-T5DUQHOX.js +69 -0
  126. package/dist/cli/deps-UTPZJBXL.js +462 -0
  127. package/dist/cli/detect-FFZSMVDT.js +46 -0
  128. package/dist/cli/detect-drift-TVCJOFYJ.js +408 -0
  129. package/dist/cli/diagnostics-GN5CVD3N.js +93 -0
  130. package/dist/cli/diagnostics-ZNBKH6GX.js +133 -0
  131. package/dist/cli/docs-CLQKEEUK.js +1710 -0
  132. package/dist/cli/docs-DPPDFTWR.js +3098 -0
  133. package/dist/cli/doctor-GPENOP4N.js +1270 -0
  134. package/dist/cli/doctor-ac-bindings-S3IOEFP4.js +26 -0
  135. package/dist/cli/doctor-acceptance-drift-VNFKPBSQ.js +26 -0
  136. package/dist/cli/doctor-credentials-A5H4JMTF.js +26 -0
  137. package/dist/cli/doctor-db-substrate-FGCISE4Z.js +27 -0
  138. package/dist/cli/doctor-dep-cycles-BKKKHHYG.js +26 -0
  139. package/dist/cli/doctor-exodus-ND2DH2KP.js +26 -0
  140. package/dist/cli/doctor-exodus-residue-4EMRYMEQ.js +26 -0
  141. package/dist/cli/doctor-fk-check-VY3RIQV3.js +26 -0
  142. package/dist/cli/doctor-global-delivery-JN6IGHUL.js +26 -0
  143. package/dist/cli/doctor-heavy-command-hook-XSN44WXU.js +26 -0
  144. package/dist/cli/doctor-legacy-backups-QAG5NHYP.js +26 -0
  145. package/dist/cli/doctor-legacy-reaper-CIRGFE6R.js +26 -0
  146. package/dist/cli/doctor-malformed-ids-WL7HT4TB.js +26 -0
  147. package/dist/cli/doctor-manifest-rows-SMQCKJ2T.js +26 -0
  148. package/dist/cli/doctor-memory-guard-LJDOJG76.js +26 -0
  149. package/dist/cli/doctor-migrations-ETQPFNUP.js +26 -0
  150. package/dist/cli/doctor-nexus-residency-A4JMKBEJ.js +26 -0
  151. package/dist/cli/doctor-project-identity-FFQJ5LNX.js +26 -0
  152. package/dist/cli/doctor-projects-MFUTKRHP.js +30 -0
  153. package/dist/cli/doctor-projects-registry-76X6VTGM.js +26 -0
  154. package/dist/cli/doctor-release-readiness-QJCOPFTK.js +26 -0
  155. package/dist/cli/doctor-repair-AU76FIKY.js +26 -0
  156. package/dist/cli/doctor-row-identity-KW6JYZQE.js +26 -0
  157. package/dist/cli/doctor-skill-fixtures-G3T7JUHS.js +26 -0
  158. package/dist/cli/doctor-split-brain-FUW6L7FS.js +26 -0
  159. package/dist/cli/doctor-superseded-store-DUHGSBLC.js +26 -0
  160. package/dist/cli/doctor-sync-journal-SXMUIKF7.js +26 -0
  161. package/dist/cli/doctor-sync-triggers-6WNJZFRM.js +26 -0
  162. package/dist/cli/doctor-tool-locks-66LSLUBN.js +26 -0
  163. package/dist/cli/doctor-twin-collapse-AYBYBFC4.js +26 -0
  164. package/dist/cli/doctor-worktree-stores-C5XEH5OG.js +26 -0
  165. package/dist/cli/done-R64XRZ32.js +196 -0
  166. package/dist/cli/dynamic-RR4HB7BB.js +29 -0
  167. package/dist/cli/entities-3JIHDIOK.js +361 -0
  168. package/dist/cli/event-45KEWV5H.js +372 -0
  169. package/dist/cli/exists-BEDZS5RI.js +65 -0
  170. package/dist/cli/exodus-DUX62344.js +401 -0
  171. package/dist/cli/export-C5PQIQ5O.js +93 -0
  172. package/dist/cli/export-tasks-CUXDZPJB.js +97 -0
  173. package/dist/cli/federation-ESM35EGG.js +145 -0
  174. package/dist/cli/find-5EUZHHQJ.js +178 -0
  175. package/dist/cli/focus-6AH4KLRO.js +368 -0
  176. package/dist/cli/focus-ANKAIRO5.js +56 -0
  177. package/dist/cli/gateway-2GW2KTK3.js +77 -0
  178. package/dist/cli/gateway-auto-start-EDK7XI6E.js +36 -0
  179. package/dist/cli/gc-CTOQLUSA.js +291 -0
  180. package/dist/cli/go-YJPNHHYT.js +206 -0
  181. package/dist/cli/goal-4GW4G77D.js +213 -0
  182. package/dist/cli/grade-25WSZH4X.js +57 -0
  183. package/dist/cli/graph-JUO3TMF3.js +879 -0
  184. package/dist/cli/history-NACNUQTC.js +138 -0
  185. package/dist/cli/hook-UF7J7R6D.js +57 -0
  186. package/dist/cli/hook-entry.js +244 -19
  187. package/dist/cli/hygiene-3QZ2NI7P.js +55 -0
  188. package/dist/cli/import-7ESGL5SS.js +89 -0
  189. package/dist/cli/import-tasks-FLE2RPBR.js +109 -0
  190. package/dist/cli/index.js +601 -94637
  191. package/dist/cli/init-AN4DZ2XO.js +40 -0
  192. package/dist/cli/inject-HQWA5GWY.js +83 -0
  193. package/dist/cli/install-global-YQV4W5OG.js +95 -0
  194. package/dist/cli/intelligence-OFFNQGHE.js +238 -0
  195. package/dist/cli/intelligence-QIC4SN4X.js +182 -0
  196. package/dist/cli/issue-P5RNMRDG.js +159 -0
  197. package/dist/cli/janitor-ZNCFQ7E3.js +111 -0
  198. package/dist/cli/labels-ORBM3T57.js +88 -0
  199. package/dist/cli/lifecycle-MHR22TVI.js +273 -0
  200. package/dist/cli/list-LB6GCYYU.js +109 -0
  201. package/dist/cli/llm-H7LZWQKX.js +130 -0
  202. package/dist/cli/llm-OTJWPMGI.js +704 -0
  203. package/dist/cli/llm-cost-MLMXEAR4.js +25 -0
  204. package/dist/cli/llm-stream-AAEUNKRP.js +27 -0
  205. package/dist/cli/log-W2A5M2NA.js +76 -0
  206. package/dist/cli/login-SIXFFZSP.js +45 -0
  207. package/dist/cli/logout-G3KVLQQM.js +74 -0
  208. package/dist/cli/manifest-G4T6EBSI.js +354 -0
  209. package/dist/cli/map-VU5M72TK.js +53 -0
  210. package/dist/cli/memory-2E27G2G5.js +1952 -0
  211. package/dist/cli/memory-IAEYKXG6.js +1895 -0
  212. package/dist/cli/migrate-agents-v2-A52QIYNJ.js +33 -0
  213. package/dist/cli/migrate-claude-mem-TPDW3R4Z.js +206 -0
  214. package/dist/cli/next-SVH4LIDY.js +57 -0
  215. package/dist/cli/nexus-FPQV2EAF.js +1059 -0
  216. package/dist/cli/nexus-XSFXN5E6.js +2924 -0
  217. package/dist/cli/ops-K6LHY5J6.js +52 -0
  218. package/dist/cli/orchestrate-CZ2J6W3L.js +1650 -0
  219. package/dist/cli/orchestrate-HURUCQFT.js +950 -0
  220. package/dist/cli/otel-JCNPVJLZ.js +188 -0
  221. package/dist/cli/phase-VDFRASSO.js +221 -0
  222. package/dist/cli/pipeline-TCZPOEDR.js +697 -0
  223. package/dist/cli/pivot-V5MSQZ7L.js +88 -0
  224. package/dist/cli/plan-SQUGCKSM.js +49 -0
  225. package/dist/cli/playbook-L47GLDQD.js +230 -0
  226. package/dist/cli/playbook-NJVO4R6P.js +33 -0
  227. package/dist/cli/project-YZEC7GYF.js +331 -0
  228. package/dist/cli/promote-FINF4HVK.js +53 -0
  229. package/dist/cli/provenance-3TUWVBFR.js +141 -0
  230. package/dist/cli/provenance-YZG33JGM.js +129 -0
  231. package/dist/cli/provider-23JVLLG3.js +213 -0
  232. package/dist/cli/reason-FHN54O7O.js +138 -0
  233. package/dist/cli/reconcile-MOM5T4AX.js +128 -0
  234. package/dist/cli/refresh-memory-3OSTRAVK.js +45 -0
  235. package/dist/cli/relates-6FWUFUS2.js +260 -0
  236. package/dist/cli/release-G2DPSG5M.js +347 -0
  237. package/dist/cli/release-URX6JHZ2.js +525 -0
  238. package/dist/cli/remote-VIULU2T5.js +279 -0
  239. package/dist/cli/renderers-TGSW77J4.js +37 -0
  240. package/dist/cli/reorder-UIPN6TQY.js +87 -0
  241. package/dist/cli/reparent-ALOWWUIU.js +59 -0
  242. package/dist/cli/req-RH2Y3H7A.js +130 -0
  243. package/dist/cli/research-G2Y72HRC.js +366 -0
  244. package/dist/cli/restore-VBR5XNML.js +470 -0
  245. package/dist/cli/revert-32LDNSGP.js +240 -0
  246. package/dist/cli/roadmap-LFU3AG7D.js +62 -0
  247. package/dist/cli/run-HXRILSR7.js +245 -0
  248. package/dist/cli/safestop-Z5UC7NGQ.js +89 -0
  249. package/dist/cli/saga-Y6FZS6AM.js +286 -0
  250. package/dist/cli/schema-OOOKLWUE.js +195 -0
  251. package/dist/cli/self-update-26SOTJMH.js +504 -0
  252. package/dist/cli/selfimprove-4SMOCLUV.js +89 -0
  253. package/dist/cli/selfimprove-EB4RQLP4.js +139 -0
  254. package/dist/cli/sentient-QPETVE53.js +254 -0
  255. package/dist/cli/sentient-RGMWR4XJ.js +1088 -0
  256. package/dist/cli/sequence-H7DSAJPF.js +94 -0
  257. package/dist/cli/service-EK5MGB2D.js +156 -0
  258. package/dist/cli/service-GLOMZWPQ.js +437 -0
  259. package/dist/cli/session-HYUXAQGC.js +708 -0
  260. package/dist/cli/session-N5ISU56W.js +568 -0
  261. package/dist/cli/setup-L3YYV53D.js +323 -0
  262. package/dist/cli/show-364V3KY2.js +123 -0
  263. package/dist/cli/skill-F2KR6HW5.js +84 -0
  264. package/dist/cli/skills-FS3DCP6E.js +929 -0
  265. package/dist/cli/smoke-provider-SKUFMZXU.js +218 -0
  266. package/dist/cli/snapshot-EGXEQ5PR.js +120 -0
  267. package/dist/cli/src-LYLXHXHH.js +80 -0
  268. package/dist/cli/start-6DXOCCKL.js +68 -0
  269. package/dist/cli/stats-UVUQEGYC.js +96 -0
  270. package/dist/cli/status-XLKYLN42.js +157 -0
  271. package/dist/cli/sticky-VSTQ2I2O.js +264 -0
  272. package/dist/cli/sticky-XZXZDCFW.js +339 -0
  273. package/dist/cli/stop-VNOAFWNB.js +43 -0
  274. package/dist/cli/sync-YYPARW3A.js +155 -0
  275. package/dist/cli/tasks-C24KHTFF.js +1118 -0
  276. package/dist/cli/tasks-LBJC7CZV.js +175 -0
  277. package/dist/cli/telemetry-CU7W5WAY.js +120 -0
  278. package/dist/cli/templates-G42JBUY4.js +609 -0
  279. package/dist/cli/testing-HSRITHEY.js +147 -0
  280. package/dist/cli/token-J74E7TSU.js +221 -0
  281. package/dist/cli/tools-BI74W7VE.js +652 -0
  282. package/dist/cli/transcript-RGK7RSGQ.js +440 -0
  283. package/dist/cli/tui-BPUFHYKK.js +51 -0
  284. package/dist/cli/update-2KQWA27S.js +478 -0
  285. package/dist/cli/update-check-entry.js +124 -0
  286. package/dist/cli/update-notice-6SQ6WPQG.js +68 -0
  287. package/dist/cli/upgrade-E2MJAPC7.js +136 -0
  288. package/dist/cli/upgrade-XRSQ4RWH.js +243 -0
  289. package/dist/cli/verify-WASRGDBA.js +191 -0
  290. package/dist/cli/web-NJ3P67EU.js +275 -0
  291. package/dist/cli/workgraph-OHJ2VKJD.js +232 -0
  292. package/dist/cli/worktree-FVQLORFY.js +371 -0
  293. package/dist/cli/worktree-ZJ6JTQNG.js +287 -0
  294. package/package.json +13 -13
  295. package/studio-dist/client/_app/immutable/chunks/{DMj27Pxj.js → AH7dIemv.js} +1 -1
  296. package/studio-dist/client/_app/immutable/chunks/{Dc2owyvE.js → BDgH40i3.js} +1 -1
  297. package/studio-dist/client/_app/immutable/chunks/BXDCSJ7U.js +1 -0
  298. package/studio-dist/client/_app/immutable/chunks/{qq3pe1aT.js → Gg4iYl59.js} +1 -1
  299. package/studio-dist/client/_app/immutable/entry/{app.CHWXLeE9.js → app.DUDNK-37.js} +2 -2
  300. package/studio-dist/client/_app/immutable/entry/start.DNmZ0pA4.js +1 -0
  301. package/studio-dist/client/_app/immutable/nodes/{0.DmKQGvFh.js → 0.DWqP3ail.js} +1 -1
  302. package/studio-dist/client/_app/immutable/nodes/{1.DqJk_REO.js → 1.CZGVUP5B.js} +1 -1
  303. package/studio-dist/client/_app/immutable/nodes/{15.GUy6kdW1.js → 15.DGaflZRS.js} +1 -1
  304. package/studio-dist/client/_app/immutable/nodes/{16.CcnKZ8f9.js → 16.uYlarGXl.js} +1 -1
  305. package/studio-dist/client/_app/immutable/nodes/{17.DAlQF3lQ.js → 17.CZMR0E47.js} +1 -1
  306. package/studio-dist/client/_app/immutable/nodes/{18.vQFr-vFj.js → 18.CBC-AKH_.js} +1 -1
  307. package/studio-dist/client/_app/immutable/nodes/{20.GVOj5j_r.js → 20.BGi43MvQ.js} +1 -1
  308. package/studio-dist/client/_app/immutable/nodes/{24.2-wC6DOh.js → 24.Dv8ftCyR.js} +1 -1
  309. package/studio-dist/client/_app/immutable/nodes/25.DQPVlTDQ.js +39 -0
  310. package/studio-dist/client/_app/immutable/nodes/{26.C3rNqzZF.js → 26.Cl800304.js} +1 -1
  311. package/studio-dist/client/_app/immutable/nodes/{3.b-7pzc3M.js → 3.D_fQKj9f.js} +1 -1
  312. package/studio-dist/client/_app/version.json +1 -1
  313. package/studio-dist/server/chunks/{0-BaCce-O1.js → 0-BpOagOst.js} +3 -3
  314. package/studio-dist/server/chunks/1-D0oRGR-C.js +9 -0
  315. package/studio-dist/server/chunks/{15-DRMOSIC9.js → 15-BcjHz7Tv.js} +3 -3
  316. package/studio-dist/server/chunks/{16-BulXhoZZ.js → 16-CXm8TUk7.js} +3 -3
  317. package/studio-dist/server/chunks/{17-DUEOCM0H.js → 17-mSgUK-cp.js} +3 -3
  318. package/studio-dist/server/chunks/{18-DP7Q8zPs.js → 18-BtfnIw1d.js} +3 -3
  319. package/studio-dist/server/chunks/{20-9ta6MI7q.js → 20-By1e4QDS.js} +3 -3
  320. package/studio-dist/server/chunks/{24-DysdL1ab.js → 24-0i2YLVxG.js} +3 -3
  321. package/studio-dist/server/chunks/{dist-CdoCt9zT.js → 25-DPsrqbrh.js} +797 -10736
  322. package/studio-dist/server/chunks/{26-Df4YXgg0.js → 26-P0XkOibm.js} +3 -3
  323. package/studio-dist/server/chunks/{3-BEhOhYpL.js → 3-WudjUK7e.js} +3 -3
  324. package/studio-dist/server/chunks/{_layout.svelte-CnLcXYG-.js → _layout.svelte-D9m81Rle.js} +4 -4
  325. package/studio-dist/server/chunks/{_page.svelte-DGhXqeRc.js → _page.svelte-2PDLOF83.js} +3 -3
  326. package/studio-dist/server/chunks/{_page.svelte-Dv8tmDEC.js → _page.svelte-BjE3jm2K.js} +3 -3
  327. package/studio-dist/server/chunks/{_page.svelte-C0qgUvzA.js → _page.svelte-Clc0vmiZ.js} +4 -4
  328. package/studio-dist/server/chunks/{_page.svelte-ui7LnWkL.js → _page.svelte-DABdRT3h.js} +3 -3
  329. package/studio-dist/server/chunks/{_page.svelte-HUqTICJR.js → _page.svelte-DG3PjiHj.js} +3 -3
  330. package/studio-dist/server/chunks/{_page.svelte-DzcZljiy.js → _page.svelte-Edy9CaE8.js} +20 -7
  331. package/studio-dist/server/chunks/{_page.svelte-DOl0DGOO.js → _page.svelte-Hrf3-ZR8.js} +3 -3
  332. package/studio-dist/server/chunks/{_page.svelte-Da4q5l93.js → _page.svelte-VB4O4Nl5.js} +3 -3
  333. package/studio-dist/server/chunks/{_page.svelte-CbyEPj2j.js → _page.svelte-d3jEgjsI.js} +3 -3
  334. package/studio-dist/server/chunks/{_server.ts-P4wVVksg.js → _server.ts-BcRFsyo3.js} +4 -5
  335. package/studio-dist/server/chunks/{_server.ts-Cr57EKWf.js → _server.ts-CEWpIFrj.js} +6 -5
  336. package/studio-dist/server/chunks/{_server.ts-CnKVmf_s.js → _server.ts-CLVdVIF9.js} +2 -2
  337. package/studio-dist/server/chunks/{_server.ts-C0evMKCk.js → _server.ts-D_j7aSy5.js} +6 -5
  338. package/studio-dist/server/chunks/{_server.ts-2BazvYRP.js → _server.ts-QEZF8h2q.js} +4 -5
  339. package/studio-dist/server/chunks/{client-CPM4LrO2.js → client-Kp1dP1od.js} +2 -2
  340. package/studio-dist/server/chunks/{error.svelte-ShcZo43D.js → error.svelte-WOCioJVX.js} +3 -3
  341. package/studio-dist/server/chunks/{hooks.server-D2qbf3Zp.js → hooks.server-DH9zkIrJ.js} +3 -1
  342. package/studio-dist/server/chunks/{http-BiQjEmVU.js → http-DT5kxaWk.js} +5 -4
  343. package/studio-dist/server/chunks/{internal-Cgsrya1j.js → internal-z0vqd5_u.js} +3 -3
  344. package/studio-dist/server/chunks/operations-registry-DdzmYzqX.js +10584 -0
  345. package/studio-dist/server/chunks/{stores-BGrpEDMK.js → stores-s2kaL315.js} +2 -2
  346. package/studio-dist/server/index.js +1 -1
  347. package/studio-dist/server/manifest.js +17 -17
  348. package/studio-dist/client/_app/immutable/chunks/Bw6J8NDM.js +0 -1
  349. package/studio-dist/client/_app/immutable/entry/start.C9bwPpvc.js +0 -1
  350. package/studio-dist/client/_app/immutable/nodes/25.D1vYaH8g.js +0 -39
  351. package/studio-dist/server/chunks/1-CVo7Nk6d.js +0 -9
  352. package/studio-dist/server/chunks/25-CYsps38R.js +0 -366
@@ -0,0 +1,1428 @@
1
+ (() => {
2
+ const _installed = Symbol.for('cleocode.cli.sqliteWarningFilter');
3
+ if (globalThis[_installed]) return;
4
+ globalThis[_installed] = true;
5
+ const _origEmitWarning = process.emitWarning;
6
+ process.emitWarning = function(warning, type, code, ctor) {
7
+ if (typeof warning === 'object' && warning.name === 'ExperimentalWarning' && typeof warning.message === 'string' && /SQLite is an experimental feature/i.test(warning.message)) {
8
+ return;
9
+ }
10
+ if (typeof warning === 'string' && /SQLite is an experimental feature/i.test(warning)) {
11
+ return;
12
+ }
13
+ return _origEmitWarning.call(process, warning, type, code, ctor);
14
+ };
15
+ })();
16
+ import {
17
+ OPERATIONS
18
+ } from "./chunk-4VASFLUW.js";
19
+ import {
20
+ defineTypedHandler,
21
+ lafsError,
22
+ lafsSuccess,
23
+ typedDispatch
24
+ } from "./chunk-QWNKLLLG.js";
25
+ import {
26
+ lazyOperation
27
+ } from "./chunk-TYC7G5LF.js";
28
+ import {
29
+ dispatchMeta,
30
+ envelopeToEngineResult,
31
+ getListParams,
32
+ handleErrorResult,
33
+ unsupportedOp,
34
+ wrapResult
35
+ } from "./chunk-XHRZ7OYZ.js";
36
+
37
+ // packages/cleo/src/dispatch/domains/admin.ts
38
+ import { computeHelp } from "@cleocode/core/admin/help";
39
+ import { getContextWindow } from "@cleocode/core/context/index";
40
+ import { configDomainHandler } from "@cleocode/core/dispatch/config-domain-handler";
41
+ import { getLogger } from "@cleocode/core/logger";
42
+ import { paginate } from "@cleocode/core/pagination";
43
+ import { getProjectRoot } from "@cleocode/core/project-scope";
44
+ import { getDefaultSnapshotPath } from "@cleocode/core/snapshot/index";
45
+ import {
46
+ createGlobalBackup,
47
+ listGlobalBackups,
48
+ listSystemBackups,
49
+ restoreBackupById,
50
+ createBackup as systemCreateBackup
51
+ } from "@cleocode/core/system/backup";
52
+ import { getSystemPaths } from "@cleocode/core/system/platform-paths";
53
+ var checkSequence = lazyOperation(
54
+ async () => (await import("@cleocode/core/sequence/index")).checkSequence
55
+ );
56
+ var cleanupSystem = lazyOperation(
57
+ async () => (await import("@cleocode/core/system/cleanup")).cleanupSystem
58
+ );
59
+ var clearTokenUsage = lazyOperation(
60
+ async () => (await import("@cleocode/core/metrics/token-service")).clearTokenUsage
61
+ );
62
+ var configGet = lazyOperation(
63
+ async () => (await import("@cleocode/core/config/engine-ops")).configGet
64
+ );
65
+ var configListPresets = lazyOperation(
66
+ async () => (await import("@cleocode/core/config/engine-ops")).configListPresets
67
+ );
68
+ var configSet = lazyOperation(
69
+ async () => (await import("@cleocode/core/config/engine-ops")).configSet
70
+ );
71
+ var configSetPreset = lazyOperation(
72
+ async () => (await import("@cleocode/core/config/engine-ops")).configSetPreset
73
+ );
74
+ var coreDoctorReport = lazyOperation(
75
+ async () => (await import("@cleocode/core/system/health")).coreDoctorReport
76
+ );
77
+ var deleteTokenUsage = lazyOperation(
78
+ async () => (await import("@cleocode/core/metrics/token-service")).deleteTokenUsage
79
+ );
80
+ var ensureCleoOsHub = lazyOperation(
81
+ async () => (await import("@cleocode/core/scaffold/global-scaffold")).ensureCleoOsHub
82
+ );
83
+ var exportSnapshot = lazyOperation(
84
+ async () => (await import("@cleocode/core/snapshot/index")).exportSnapshot
85
+ );
86
+ var exportTasks = lazyOperation(
87
+ async () => (await import("@cleocode/core/admin/export")).exportTasks
88
+ );
89
+ var exportTasksPackage = lazyOperation(
90
+ async () => (await import("@cleocode/core/admin/export-tasks")).exportTasksPackage
91
+ );
92
+ var fileRestore = lazyOperation(
93
+ async () => (await import("@cleocode/core/system/backup")).fileRestore
94
+ );
95
+ var findAdrs = lazyOperation(async () => (await import("@cleocode/core/adrs/find")).findAdrs);
96
+ var generateInjection = lazyOperation(
97
+ async () => (await import("@cleocode/core/system/inject-generate")).generateInjection
98
+ );
99
+ var getDashboard = lazyOperation(
100
+ async () => (await import("@cleocode/core/stats/index")).getDashboard
101
+ );
102
+ var getMigrationStatus = lazyOperation(
103
+ async () => (await import("@cleocode/core/system/migrate")).getMigrationStatus
104
+ );
105
+ var getProjectStatsExtended = lazyOperation(
106
+ async () => (await import("@cleocode/core/stats/index")).getProjectStatsExtended
107
+ );
108
+ var getRoadmap = lazyOperation(
109
+ async () => (await import("@cleocode/core/roadmap/index")).getRoadmap
110
+ );
111
+ var getRuntimeDiagnostics = lazyOperation(
112
+ async () => (await import("@cleocode/core/system/runtime")).getRuntimeDiagnostics
113
+ );
114
+ var getSystemHealth = lazyOperation(
115
+ async () => (await import("@cleocode/core/system/health")).getSystemHealth
116
+ );
117
+ var getTaskAccessor = lazyOperation(
118
+ async () => (await import("@cleocode/core/store/data-accessor")).getTaskAccessor
119
+ );
120
+ var getVersion = lazyOperation(
121
+ async () => (await import("@cleocode/core/init/engine-ops")).getVersion
122
+ );
123
+ var importSnapshot = lazyOperation(
124
+ async () => (await import("@cleocode/core/snapshot/index")).importSnapshot
125
+ );
126
+ var importTasks = lazyOperation(
127
+ async () => (await import("@cleocode/core/admin/import")).importTasks
128
+ );
129
+ var importTasksPackage = lazyOperation(
130
+ async () => (await import("@cleocode/core/admin/import-tasks")).importTasksPackage
131
+ );
132
+ var initProject = lazyOperation(
133
+ async () => (await import("@cleocode/core/init/engine-ops")).initProject
134
+ );
135
+ var listAdrs = lazyOperation(async () => (await import("@cleocode/core/adrs/list")).listAdrs);
136
+ var listTokenUsage = lazyOperation(
137
+ async () => (await import("@cleocode/core/metrics/token-service")).listTokenUsage
138
+ );
139
+ var mapCodebase = lazyOperation(
140
+ async () => (await import("@cleocode/core/codebase-map/index")).mapCodebase
141
+ );
142
+ var queryAuditLog = lazyOperation(
143
+ async () => (await import("@cleocode/core/system/audit")).queryAuditLog
144
+ );
145
+ var readSnapshot = lazyOperation(
146
+ async () => (await import("@cleocode/core/snapshot/index")).readSnapshot
147
+ );
148
+ var recordTokenExchange = lazyOperation(
149
+ async () => (await import("@cleocode/core/metrics/token-service")).recordTokenExchange
150
+ );
151
+ var runDoctorFixes = lazyOperation(
152
+ async () => (await import("@cleocode/core/system/health")).runDoctorFixes
153
+ );
154
+ var safestop = lazyOperation(
155
+ async () => (await import("@cleocode/core/system/safestop")).safestop
156
+ );
157
+ var sessionContextInject = lazyOperation(
158
+ async () => (await import("@cleocode/core/session/engine-ops")).sessionContextInject
159
+ );
160
+ var showAdr = lazyOperation(async () => (await import("@cleocode/core/adrs/show")).showAdr);
161
+ var showSequence = lazyOperation(
162
+ async () => (await import("@cleocode/core/sequence/index")).showSequence
163
+ );
164
+ var showTokenUsage = lazyOperation(
165
+ async () => (await import("@cleocode/core/metrics/token-service")).showTokenUsage
166
+ );
167
+ var summarizeTokenUsage = lazyOperation(
168
+ async () => (await import("@cleocode/core/metrics/token-service")).summarizeTokenUsage
169
+ );
170
+ var syncAdrsToDb = lazyOperation(
171
+ async () => (await import("@cleocode/core/adrs/sync")).syncAdrsToDb
172
+ );
173
+ var systemHooksMatrix = lazyOperation(
174
+ async () => (await import("@cleocode/core/hooks/engine-ops")).systemHooksMatrix
175
+ );
176
+ var validateAllAdrs = lazyOperation(
177
+ async () => (await import("@cleocode/core/adrs/validate")).validateAllAdrs
178
+ );
179
+ var writeSnapshot = lazyOperation(
180
+ async () => (await import("@cleocode/core/snapshot/index")).writeSnapshot
181
+ );
182
+ var SMOKE_PROBES = [
183
+ { domain: "admin", operation: "version" },
184
+ { domain: "tasks", operation: "find", params: { query: "__smoke_probe__", limit: 1 } },
185
+ { domain: "session", operation: "status" },
186
+ { domain: "memory", operation: "find", params: { query: "__smoke_probe__" } },
187
+ { domain: "pipeline", operation: "list" },
188
+ { domain: "check", operation: "schema" },
189
+ { domain: "tools", operation: "list", params: { limit: 1 } },
190
+ { domain: "sticky", operation: "list", params: { limit: 1 } },
191
+ { domain: "nexus", operation: "status" },
192
+ { domain: "orchestrate", operation: "status" },
193
+ { domain: "adapter", operation: "list" }
194
+ ];
195
+ async function runSystemSmoke() {
196
+ const { dispatchRaw } = await import("./cli-A23Q335V.js");
197
+ const totalStart = Date.now();
198
+ const probes = [];
199
+ for (const probe of SMOKE_PROBES) {
200
+ const start = Date.now();
201
+ try {
202
+ const response = await dispatchRaw("query", probe.domain, probe.operation, probe.params);
203
+ const elapsed = Date.now() - start;
204
+ if (response.success) {
205
+ probes.push({
206
+ domain: probe.domain,
207
+ operation: probe.operation,
208
+ status: "pass",
209
+ timeMs: elapsed
210
+ });
211
+ } else {
212
+ const code = response.error?.code ?? "";
213
+ const isCrash = code === "E_INTERNAL" || code === "E_NO_HANDLER";
214
+ probes.push({
215
+ domain: probe.domain,
216
+ operation: probe.operation,
217
+ status: isCrash ? "fail" : "pass",
218
+ timeMs: elapsed,
219
+ ...isCrash ? { error: response.error?.message } : {}
220
+ });
221
+ }
222
+ } catch (err) {
223
+ probes.push({
224
+ domain: probe.domain,
225
+ operation: probe.operation,
226
+ status: "fail",
227
+ timeMs: Date.now() - start,
228
+ error: err instanceof Error ? `${err.constructor.name}: ${err.message}` : String(err)
229
+ });
230
+ }
231
+ }
232
+ const dbChecks = [];
233
+ {
234
+ const start = Date.now();
235
+ try {
236
+ const { getDb, getNativeDb } = await import("@cleocode/core/store/sqlite");
237
+ const projectRoot = getProjectRoot();
238
+ await getDb(projectRoot);
239
+ const nativeDb = getNativeDb(projectRoot);
240
+ if (nativeDb) {
241
+ const result = nativeDb.prepare("PRAGMA integrity_check").get();
242
+ const ok = result?.integrity_check === "ok";
243
+ dbChecks.push({
244
+ domain: "db",
245
+ operation: "tasks.db",
246
+ status: ok ? "pass" : "fail",
247
+ timeMs: Date.now() - start,
248
+ ...!ok ? { error: "SQLite integrity check failed" } : {}
249
+ });
250
+ } else {
251
+ dbChecks.push({
252
+ domain: "db",
253
+ operation: "tasks.db",
254
+ status: "fail",
255
+ timeMs: Date.now() - start,
256
+ error: "Native DB handle unavailable"
257
+ });
258
+ }
259
+ } catch (err) {
260
+ dbChecks.push({
261
+ domain: "db",
262
+ operation: "tasks.db",
263
+ status: "fail",
264
+ timeMs: Date.now() - start,
265
+ error: err instanceof Error ? err.message : String(err)
266
+ });
267
+ }
268
+ }
269
+ {
270
+ const start = Date.now();
271
+ try {
272
+ const { getBrainDb } = await import("@cleocode/core/store/memory-sqlite");
273
+ const projectRoot = getProjectRoot();
274
+ const brainDb = await getBrainDb(projectRoot);
275
+ if (brainDb) {
276
+ dbChecks.push({
277
+ domain: "db",
278
+ operation: "brain.db",
279
+ status: "pass",
280
+ timeMs: Date.now() - start
281
+ });
282
+ } else {
283
+ dbChecks.push({
284
+ domain: "db",
285
+ operation: "brain.db",
286
+ status: "fail",
287
+ timeMs: Date.now() - start,
288
+ error: "brain.db not initialized"
289
+ });
290
+ }
291
+ } catch (err) {
292
+ dbChecks.push({
293
+ domain: "db",
294
+ operation: "brain.db",
295
+ status: "fail",
296
+ timeMs: Date.now() - start,
297
+ error: err instanceof Error ? err.message : String(err)
298
+ });
299
+ }
300
+ }
301
+ {
302
+ const start = Date.now();
303
+ try {
304
+ const migrationStatus = await getMigrationStatus(getProjectRoot());
305
+ const hasPending = migrationStatus.migrations.some(
306
+ (m) => !m.applied
307
+ );
308
+ dbChecks.push({
309
+ domain: "db",
310
+ operation: "migrations",
311
+ status: hasPending ? "fail" : "pass",
312
+ timeMs: Date.now() - start,
313
+ ...hasPending ? {
314
+ error: `Unapplied migrations detected (${migrationStatus.from} \u2192 ${migrationStatus.to}). Run: cleo upgrade`
315
+ } : {}
316
+ });
317
+ } catch (err) {
318
+ dbChecks.push({
319
+ domain: "db",
320
+ operation: "migrations",
321
+ status: "fail",
322
+ timeMs: Date.now() - start,
323
+ error: err instanceof Error ? err.message : String(err)
324
+ });
325
+ }
326
+ }
327
+ const allProbes = [...probes, ...dbChecks];
328
+ const totalMs = Date.now() - totalStart;
329
+ const passed = allProbes.filter((p) => p.status === "pass").length;
330
+ const failed = allProbes.filter((p) => p.status === "fail").length;
331
+ const skipped = allProbes.filter((p) => p.status === "skip").length;
332
+ return { probes, dbChecks, passed, failed, skipped, totalMs };
333
+ }
334
+ var _adminTypedHandler = defineTypedHandler("admin", {
335
+ // -------------------------------------------------------------------------
336
+ // Query ops
337
+ // -------------------------------------------------------------------------
338
+ version: async (_params) => {
339
+ const projectRoot = getProjectRoot();
340
+ const result = await getVersion(projectRoot);
341
+ if (!result.success) {
342
+ return lafsError(
343
+ String(result.error?.code ?? "E_INTERNAL"),
344
+ result.error?.message ?? "Unknown error",
345
+ "version"
346
+ );
347
+ }
348
+ return lafsSuccess(result.data ?? { version: "" }, "version");
349
+ },
350
+ health: async (params) => {
351
+ const projectRoot = getProjectRoot();
352
+ if (params.mode === "diagnose") {
353
+ try {
354
+ const data = await coreDoctorReport(projectRoot);
355
+ return lafsSuccess(
356
+ data ?? { healthy: false, errors: 0, warnings: 0, checks: [] },
357
+ "health"
358
+ );
359
+ } catch (err) {
360
+ return lafsError("E_INTERNAL", err instanceof Error ? err.message : String(err), "health");
361
+ }
362
+ }
363
+ try {
364
+ const data = await getSystemHealth(projectRoot, { detailed: params.detailed });
365
+ return lafsSuccess(
366
+ data ?? { overall: "error", checks: [], version: "", installation: "degraded" },
367
+ "health"
368
+ );
369
+ } catch (err) {
370
+ return lafsError("E_INTERNAL", err instanceof Error ? err.message : String(err), "health");
371
+ }
372
+ },
373
+ "config.show": async (params) => {
374
+ const projectRoot = getProjectRoot();
375
+ const result = await configGet(projectRoot, params.key);
376
+ if (!result.success) {
377
+ return lafsError(
378
+ String(result.error?.code ?? "E_INTERNAL"),
379
+ result.error?.message ?? "Unknown error",
380
+ "config.show"
381
+ );
382
+ }
383
+ return lafsSuccess(result.data ?? {}, "config.show");
384
+ },
385
+ "config.presets": async (_params) => {
386
+ const result = await configListPresets();
387
+ if (!result.success) {
388
+ return lafsError(
389
+ String(result.error?.code ?? "E_INTERNAL"),
390
+ result.error?.message ?? "Unknown error",
391
+ "config.presets"
392
+ );
393
+ }
394
+ return lafsSuccess(result.data ?? { presets: [] }, "config.presets");
395
+ },
396
+ // T11917 — config-as-domain. Delegate to the CORE ConfigDomainHandler, which
397
+ // routes through the ConfigManifest cascade resolver (resolveCleoConfig /
398
+ // getConfigValue / validateConfig). The CLI handler only wraps the
399
+ // EngineResult into the LAFS envelope.
400
+ "config.get": async (params) => {
401
+ const projectRoot = getProjectRoot();
402
+ const result = await configDomainHandler.get(projectRoot, params.key, params.scope);
403
+ if (!result.success) {
404
+ return lafsError(result.error.code, result.error.message, "config.get");
405
+ }
406
+ return lafsSuccess(result.data, "config.get");
407
+ },
408
+ "config.list": async (params) => {
409
+ const projectRoot = getProjectRoot();
410
+ const result = await configDomainHandler.list(projectRoot, params.scope);
411
+ if (!result.success) {
412
+ return lafsError(result.error.code, result.error.message, "config.list");
413
+ }
414
+ return lafsSuccess(result.data, "config.list");
415
+ },
416
+ "config.validate": async (params) => {
417
+ const projectRoot = getProjectRoot();
418
+ const result = await configDomainHandler.validate(projectRoot, params.scope);
419
+ if (!result.success) {
420
+ return lafsError(result.error.code, result.error.message, "config.validate");
421
+ }
422
+ return lafsSuccess(result.data, "config.validate");
423
+ },
424
+ stats: async (params) => {
425
+ const projectRoot = getProjectRoot();
426
+ try {
427
+ const data = await getProjectStatsExtended(projectRoot, { period: params.period });
428
+ return lafsSuccess(data, "stats");
429
+ } catch (err) {
430
+ return lafsError("E_INTERNAL", err instanceof Error ? err.message : String(err), "stats");
431
+ }
432
+ },
433
+ context: async (params) => {
434
+ const projectRoot = getProjectRoot();
435
+ try {
436
+ const data = getContextWindow(
437
+ projectRoot,
438
+ params.session !== void 0 ? { session: params.session } : void 0
439
+ );
440
+ return lafsSuccess(data, "context");
441
+ } catch (err) {
442
+ return lafsError("E_INTERNAL", err instanceof Error ? err.message : String(err), "context");
443
+ }
444
+ },
445
+ "context.pull": async (params) => {
446
+ const projectRoot = getProjectRoot();
447
+ const taskId = params.taskId;
448
+ try {
449
+ const [{ getTaskAccessor: getTaskAccessor2 }, { getLastHandoff }, { retrieveWithBudget }] = await Promise.all([
450
+ import("@cleocode/core/store/data-accessor"),
451
+ import("@cleocode/core/sessions/handoff"),
452
+ import("@cleocode/core/memory/retrieval/search")
453
+ ]);
454
+ const accessor = await getTaskAccessor2(projectRoot);
455
+ const task = await accessor.loadSingleTask(taskId);
456
+ if (!task) {
457
+ return lafsError("E_NOT_FOUND", `Task ${taskId} not found`, "context.pull");
458
+ }
459
+ const queryParts = [task.title, task.description].filter(
460
+ (v) => typeof v === "string" && v.trim().length > 0
461
+ );
462
+ const query = queryParts.join(" ");
463
+ const TOKEN_BUDGET = 800;
464
+ const [memoriesResult, lastHandoffResult] = await Promise.all([
465
+ retrieveWithBudget(projectRoot, query, TOKEN_BUDGET).catch(() => ({
466
+ entries: [],
467
+ tokensUsed: 0,
468
+ tokensRemaining: TOKEN_BUDGET,
469
+ excluded: 0
470
+ })),
471
+ getLastHandoff(projectRoot).catch(() => null)
472
+ ]);
473
+ const topMemories = memoriesResult.entries.slice(0, 5);
474
+ return lafsSuccess(
475
+ {
476
+ task: {
477
+ id: task.id,
478
+ title: task.title,
479
+ status: task.status,
480
+ acceptance: task.acceptance ?? []
481
+ },
482
+ relevantMemory: topMemories.map((e) => ({
483
+ id: e.id,
484
+ type: e.memoryType ?? "unknown",
485
+ summary: e.title
486
+ })),
487
+ lastHandoff: lastHandoffResult?.handoff?.note?.substring(0, 200) ?? null,
488
+ meta: {
489
+ memoryTokensUsed: memoriesResult.tokensUsed,
490
+ memoryEntriesExcluded: memoriesResult.excluded
491
+ }
492
+ },
493
+ "context.pull"
494
+ );
495
+ } catch (err) {
496
+ return lafsError(
497
+ "E_INTERNAL",
498
+ err instanceof Error ? err.message : String(err),
499
+ "context.pull"
500
+ );
501
+ }
502
+ },
503
+ runtime: async (params) => {
504
+ try {
505
+ const data = await getRuntimeDiagnostics({ detailed: params.detailed ?? false });
506
+ return lafsSuccess(data, "runtime");
507
+ } catch (err) {
508
+ return lafsError("E_INTERNAL", err instanceof Error ? err.message : String(err), "runtime");
509
+ }
510
+ },
511
+ paths: async (_params) => {
512
+ const projectRoot = getProjectRoot();
513
+ try {
514
+ const data = getSystemPaths(projectRoot);
515
+ return lafsSuccess(data, "paths");
516
+ } catch (err) {
517
+ return lafsError(
518
+ "E_PATHS_RESOLVE_FAILED",
519
+ err instanceof Error ? err.message : String(err),
520
+ "paths"
521
+ );
522
+ }
523
+ },
524
+ job: async (params) => {
525
+ const { getJobManager } = await import("@cleocode/runtime/gateway");
526
+ const action = params.action ?? "status";
527
+ if (action === "list") {
528
+ const mgr = getJobManager();
529
+ if (!mgr) {
530
+ return lafsError(
531
+ "E_NOT_AVAILABLE",
532
+ "Job manager not available. Background jobs require a running CLEO daemon or long-lived process.",
533
+ "job"
534
+ );
535
+ }
536
+ const allJobs = mgr.listJobs();
537
+ const filteredJobs = params.status ? mgr.listJobs(params.status) : allJobs;
538
+ const { limit, offset } = getListParams({ limit: params.limit, offset: params.offset });
539
+ const page = paginate(filteredJobs, limit, offset);
540
+ return lafsSuccess(
541
+ {
542
+ jobs: page.items,
543
+ count: filteredJobs.length,
544
+ total: allJobs.length,
545
+ filtered: filteredJobs.length
546
+ },
547
+ "job"
548
+ );
549
+ }
550
+ const manager = getJobManager();
551
+ if (!manager) {
552
+ return lafsError(
553
+ "E_NOT_AVAILABLE",
554
+ "Job manager not available. Background jobs require a running CLEO daemon or long-lived process.",
555
+ "job"
556
+ );
557
+ }
558
+ const jobId = params.jobId;
559
+ if (!jobId) {
560
+ return lafsError("E_INVALID_INPUT", "jobId is required", "job");
561
+ }
562
+ const job = manager.getJob(jobId);
563
+ if (!job) {
564
+ return lafsError("E_NOT_FOUND", `Job ${jobId} not found`, "job");
565
+ }
566
+ return lafsSuccess(job, "job");
567
+ },
568
+ dash: async (params) => {
569
+ const projectRoot = getProjectRoot();
570
+ try {
571
+ const accessor = await getTaskAccessor(projectRoot);
572
+ const raw = await getDashboard(
573
+ { cwd: projectRoot, blockedTasksLimit: params.blockedTasksLimit },
574
+ accessor
575
+ );
576
+ const data = raw;
577
+ const summary = data.summary;
578
+ return lafsSuccess(
579
+ {
580
+ project: data.project,
581
+ currentPhase: data.currentPhase,
582
+ summary: {
583
+ pending: summary.pending,
584
+ active: summary.active,
585
+ blocked: summary.blocked,
586
+ done: summary.done,
587
+ cancelled: summary.cancelled ?? 0,
588
+ total: summary.total,
589
+ archived: summary.archived ?? 0,
590
+ grandTotal: summary.grandTotal ?? summary.total
591
+ },
592
+ taskWork: data.focus ?? data.taskWork,
593
+ activeSession: data.activeSession ?? null,
594
+ highPriority: data.highPriority,
595
+ blockedTasks: data.blockedTasks,
596
+ recentCompletions: data.recentCompletions ?? [],
597
+ topLabels: data.topLabels
598
+ },
599
+ "dash"
600
+ );
601
+ } catch (err) {
602
+ return lafsError(
603
+ "E_NOT_INITIALIZED",
604
+ err instanceof Error ? err.message : String(err),
605
+ "dash"
606
+ );
607
+ }
608
+ },
609
+ log: async (params) => {
610
+ const projectRoot = getProjectRoot();
611
+ try {
612
+ const data = await queryAuditLog(projectRoot, {
613
+ operation: params.operation,
614
+ taskId: params.taskId,
615
+ since: params.since,
616
+ until: params.until,
617
+ limit: params.limit,
618
+ offset: params.offset
619
+ });
620
+ return lafsSuccess(data, "log");
621
+ } catch (err) {
622
+ return lafsError("E_FILE_ERROR", err instanceof Error ? err.message : String(err), "log");
623
+ }
624
+ },
625
+ sequence: async (params) => {
626
+ const projectRoot = getProjectRoot();
627
+ const action = params.action;
628
+ if (action && action !== "show" && action !== "check") {
629
+ return lafsError("E_INVALID_INPUT", "action must be show or check", "sequence");
630
+ }
631
+ try {
632
+ if (action === "check") {
633
+ const data = await checkSequence(projectRoot);
634
+ return lafsSuccess(data, "sequence");
635
+ }
636
+ const seq = await showSequence(projectRoot);
637
+ return lafsSuccess(
638
+ {
639
+ counter: Number(seq.counter ?? 0),
640
+ lastId: String(seq.lastId ?? ""),
641
+ checksum: String(seq.checksum ?? ""),
642
+ nextId: String(seq.nextId ?? "")
643
+ },
644
+ "sequence"
645
+ );
646
+ } catch (err) {
647
+ return lafsError("E_NOT_FOUND", err instanceof Error ? err.message : String(err), "sequence");
648
+ }
649
+ },
650
+ help: async (params) => {
651
+ const tier = params.tier ?? 0;
652
+ const verbose = params.verbose === true;
653
+ const helpResult = computeHelp(OPERATIONS, tier, verbose);
654
+ return lafsSuccess(helpResult, "help");
655
+ },
656
+ "adr.find": async (params) => {
657
+ const projectRoot = getProjectRoot();
658
+ if (params.query) {
659
+ const result2 = await findAdrs(projectRoot, params);
660
+ return lafsSuccess(result2, "adr.find");
661
+ }
662
+ const { limit, offset } = getListParams({ limit: params.limit, offset: params.offset });
663
+ const result = await listAdrs(projectRoot, { ...params, limit, offset });
664
+ return lafsSuccess(
665
+ {
666
+ ...result,
667
+ page: paginate(Array.from({ length: result.filtered }), limit, offset).page
668
+ },
669
+ "adr.find"
670
+ );
671
+ },
672
+ "adr.show": async (params) => {
673
+ const projectRoot = getProjectRoot();
674
+ const adr = await showAdr(projectRoot, params);
675
+ if (!adr) {
676
+ return lafsError("E_NOT_FOUND", `ADR not found: ${params.adrId}`, "adr.show");
677
+ }
678
+ return lafsSuccess(adr, "adr.show");
679
+ },
680
+ token: async (params) => {
681
+ const projectRoot = getProjectRoot();
682
+ const action = params.action ?? "summary";
683
+ if (action === "show") {
684
+ const tokenId = params.tokenId;
685
+ if (!tokenId) {
686
+ return lafsError("E_INVALID_INPUT", "tokenId is required", "token");
687
+ }
688
+ const result2 = await showTokenUsage(projectRoot, { id: tokenId });
689
+ if (!result2) {
690
+ return lafsError("E_NOT_FOUND", `Token usage record not found: ${tokenId}`, "token");
691
+ }
692
+ return lafsSuccess(result2, "token");
693
+ }
694
+ if (action === "list") {
695
+ const { limit, offset } = getListParams({ limit: params.limit, offset: params.offset });
696
+ const result2 = await listTokenUsage(projectRoot, {
697
+ provider: params.provider,
698
+ transport: params.transport,
699
+ gateway: params.gateway,
700
+ domain: params.domain,
701
+ operation: params.operationName,
702
+ sessionId: params.sessionId,
703
+ taskId: params.taskId,
704
+ method: params.method,
705
+ confidence: params.confidence,
706
+ requestId: params.requestId,
707
+ since: params.since,
708
+ until: params.until,
709
+ limit,
710
+ offset
711
+ });
712
+ return lafsSuccess(
713
+ {
714
+ records: result2.records,
715
+ total: result2.total,
716
+ filtered: result2.filtered
717
+ },
718
+ "token"
719
+ );
720
+ }
721
+ const result = await summarizeTokenUsage(projectRoot, {
722
+ provider: params.provider,
723
+ transport: params.transport,
724
+ gateway: params.gateway,
725
+ domain: params.domain,
726
+ operation: params.operationName,
727
+ sessionId: params.sessionId,
728
+ taskId: params.taskId,
729
+ method: params.method,
730
+ confidence: params.confidence,
731
+ requestId: params.requestId,
732
+ since: params.since,
733
+ until: params.until
734
+ });
735
+ return lafsSuccess(result, "token");
736
+ },
737
+ backup: async (params) => {
738
+ const projectRoot = getProjectRoot();
739
+ try {
740
+ const scope = params.scope ?? "all";
741
+ const backups = [
742
+ ...scope === "global" ? [] : listSystemBackups(projectRoot),
743
+ ...scope === "project" ? [] : listGlobalBackups()
744
+ ].sort((a, b) => b.timestamp.localeCompare(a.timestamp));
745
+ return lafsSuccess({ backups, count: backups.length }, "backup");
746
+ } catch (err) {
747
+ return lafsError("E_GENERAL", err instanceof Error ? err.message : String(err), "backup");
748
+ }
749
+ },
750
+ export: async (params) => {
751
+ const projectRoot = getProjectRoot();
752
+ if (params.scope === "snapshot") {
753
+ const snapshot = await exportSnapshot(projectRoot);
754
+ const outputPath = params.output ?? getDefaultSnapshotPath(projectRoot);
755
+ await writeSnapshot(snapshot, outputPath);
756
+ return lafsSuccess(
757
+ {
758
+ exported: true,
759
+ taskCount: snapshot._meta.taskCount,
760
+ outputPath,
761
+ checksum: snapshot._meta.checksum
762
+ },
763
+ "export"
764
+ );
765
+ }
766
+ if (params.scope === "tasks") {
767
+ const result2 = await exportTasksPackage(projectRoot, params);
768
+ return lafsSuccess(result2, "export");
769
+ }
770
+ const result = await exportTasks(projectRoot, params);
771
+ return lafsSuccess(result, "export");
772
+ },
773
+ map: async (params) => {
774
+ const projectRoot = getProjectRoot();
775
+ try {
776
+ const data = await mapCodebase(projectRoot, { focus: params.focus, storeToBrain: false });
777
+ return lafsSuccess(data, "map");
778
+ } catch (err) {
779
+ return lafsError("E_GENERAL", err instanceof Error ? err.message : String(err), "map");
780
+ }
781
+ },
782
+ roadmap: async (params) => {
783
+ const projectRoot = getProjectRoot();
784
+ try {
785
+ const accessor = await getTaskAccessor(projectRoot);
786
+ const data = await getRoadmap(
787
+ {
788
+ includeHistory: params.includeHistory,
789
+ upcomingOnly: params.upcomingOnly,
790
+ cwd: projectRoot
791
+ },
792
+ accessor
793
+ );
794
+ return lafsSuccess(data, "roadmap");
795
+ } catch (err) {
796
+ return lafsError(
797
+ "E_NOT_INITIALIZED",
798
+ err instanceof Error ? err.message : String(err),
799
+ "roadmap"
800
+ );
801
+ }
802
+ },
803
+ smoke: async (_params) => {
804
+ const smokeResult = await runSystemSmoke();
805
+ if (smokeResult.failed === 0) {
806
+ return lafsSuccess(smokeResult, "smoke");
807
+ }
808
+ return lafsError(
809
+ "E_SMOKE_FAILURES",
810
+ `${smokeResult.failed} probe(s) failed smoke test`,
811
+ "smoke"
812
+ );
813
+ },
814
+ "smoke.provider": async (params) => {
815
+ const { smokeProvider } = await import("./smoke-provider-SKUFMZXU.js");
816
+ const result = await smokeProvider(params.provider);
817
+ if (!result.success) {
818
+ return lafsError(
819
+ String(result.error?.code ?? "E_INTERNAL"),
820
+ result.error?.message ?? "Unknown error",
821
+ "smoke.provider"
822
+ );
823
+ }
824
+ return lafsSuccess(result.data, "smoke.provider");
825
+ },
826
+ "hooks.matrix": async (params) => {
827
+ const result = await systemHooksMatrix({
828
+ providerIds: params.providerIds,
829
+ detectProvider: params.detectProvider !== false
830
+ });
831
+ if (!result.success) {
832
+ return lafsError(
833
+ String(result.error?.code ?? "E_INTERNAL"),
834
+ result.error?.message ?? "Unknown error",
835
+ "hooks.matrix"
836
+ );
837
+ }
838
+ return lafsSuccess(result.data, "hooks.matrix");
839
+ },
840
+ // -------------------------------------------------------------------------
841
+ // Mutate ops
842
+ // -------------------------------------------------------------------------
843
+ init: async (params) => {
844
+ const projectRoot = getProjectRoot();
845
+ const result = await initProject(projectRoot, {
846
+ projectName: params.projectName,
847
+ force: params.force,
848
+ mapCodebase: params.mapCodebase
849
+ });
850
+ if (!result.success) {
851
+ return lafsError(
852
+ String(result.error?.code ?? "E_INTERNAL"),
853
+ result.error?.message ?? "Unknown error",
854
+ "init"
855
+ );
856
+ }
857
+ return lafsSuccess(result.data, "init");
858
+ },
859
+ "scaffold-hub": async (_params) => {
860
+ try {
861
+ const data = await ensureCleoOsHub();
862
+ return lafsSuccess(data, "scaffold-hub");
863
+ } catch (err) {
864
+ return lafsError(
865
+ "E_SCAFFOLD_HUB_FAILED",
866
+ err instanceof Error ? err.message : String(err),
867
+ "scaffold-hub"
868
+ );
869
+ }
870
+ },
871
+ "health.mutate": async (params) => {
872
+ const projectRoot = getProjectRoot();
873
+ if (params.mode === "diagnose") {
874
+ try {
875
+ const data = await coreDoctorReport(projectRoot);
876
+ return lafsSuccess(
877
+ data ?? { healthy: false, errors: 0, warnings: 0, checks: [] },
878
+ "health.mutate"
879
+ );
880
+ } catch (err) {
881
+ return lafsError(
882
+ "E_INTERNAL",
883
+ err instanceof Error ? err.message : String(err),
884
+ "health.mutate"
885
+ );
886
+ }
887
+ }
888
+ try {
889
+ const data = await runDoctorFixes(projectRoot);
890
+ return lafsSuccess(data, "health.mutate");
891
+ } catch (err) {
892
+ return lafsError(
893
+ "E_INTERNAL",
894
+ err instanceof Error ? err.message : String(err),
895
+ "health.mutate"
896
+ );
897
+ }
898
+ },
899
+ "config.set": async (params) => {
900
+ const projectRoot = getProjectRoot();
901
+ if (!params.key) {
902
+ return lafsError("E_INVALID_INPUT", "key is required", "config.set");
903
+ }
904
+ const result = await configSet(projectRoot, params.key, params.value);
905
+ if (!result.success) {
906
+ return lafsError(
907
+ String(result.error?.code ?? "E_INTERNAL"),
908
+ result.error?.message ?? "Unknown error",
909
+ "config.set"
910
+ );
911
+ }
912
+ return lafsSuccess(result.data, "config.set");
913
+ },
914
+ "config.set-preset": async (params) => {
915
+ const projectRoot = getProjectRoot();
916
+ const result = await configSetPreset(projectRoot, params.preset);
917
+ if (!result.success) {
918
+ return lafsError(
919
+ String(result.error?.code ?? "E_INTERNAL"),
920
+ result.error?.message ?? "Unknown error",
921
+ "config.set-preset"
922
+ );
923
+ }
924
+ return lafsSuccess(result.data, "config.set-preset");
925
+ },
926
+ // T11917 — config-as-domain. Remove a key via the CORE ConfigDomainHandler
927
+ // (ConfigManifest cascade writeback). Idempotent: removing an absent key
928
+ // succeeds with removed=false.
929
+ "config.unset": async (params) => {
930
+ const projectRoot = getProjectRoot();
931
+ const result = await configDomainHandler.unset(projectRoot, params.key, params.global);
932
+ if (!result.success) {
933
+ return lafsError(result.error.code, result.error.message, "config.unset");
934
+ }
935
+ return lafsSuccess(result.data, "config.unset");
936
+ },
937
+ "backup.mutate": async (params) => {
938
+ const projectRoot = getProjectRoot();
939
+ const action = params.action;
940
+ if (action === "restore") {
941
+ const backupId = params.backupId;
942
+ if (!backupId) {
943
+ return lafsError("E_INVALID_INPUT", "backupId is required", "backup.mutate");
944
+ }
945
+ try {
946
+ const data = await restoreBackupById(projectRoot, {
947
+ backupId,
948
+ ...params.scope ? { scope: params.scope } : {},
949
+ force: params.force,
950
+ confirmOwnerStore: params.confirmOwnerStore,
951
+ // T12680: the invocation directory; core never falls back to it.
952
+ cwd: process.cwd()
953
+ });
954
+ return lafsSuccess(data, "backup.mutate");
955
+ } catch (err) {
956
+ return lafsError(
957
+ "E_RESTORE_FAILED",
958
+ err instanceof Error ? err.message : String(err),
959
+ "backup.mutate"
960
+ );
961
+ }
962
+ }
963
+ if (action === "restore.file") {
964
+ const file = params.file;
965
+ if (!file) {
966
+ return lafsError("E_INVALID_INPUT", "file is required", "backup.mutate");
967
+ }
968
+ try {
969
+ const data = await fileRestore(projectRoot, file, {
970
+ dryRun: params.dryRun,
971
+ confirmOwnerStore: params.confirmOwnerStore,
972
+ // T12680: the invocation directory; core never falls back to it.
973
+ cwd: process.cwd()
974
+ });
975
+ return lafsSuccess(data, "backup.mutate");
976
+ } catch (err) {
977
+ return lafsError(
978
+ "E_GENERAL",
979
+ err instanceof Error ? err.message : String(err),
980
+ "backup.mutate"
981
+ );
982
+ }
983
+ }
984
+ try {
985
+ const data = await systemCreateBackup(projectRoot, { type: params.type, note: params.note });
986
+ const global = params.includeGlobal ? await createGlobalBackup({ type: params.type, note: params.note }) : null;
987
+ return lafsSuccess({ ...data, ...global ? { global } : {} }, "backup.mutate");
988
+ } catch (err) {
989
+ return lafsError(
990
+ "E_GENERAL",
991
+ err instanceof Error ? err.message : String(err),
992
+ "backup.mutate"
993
+ );
994
+ }
995
+ },
996
+ migrate: async (params) => {
997
+ const projectRoot = getProjectRoot();
998
+ try {
999
+ const data = await getMigrationStatus(projectRoot, {
1000
+ target: params.target,
1001
+ dryRun: params.dryRun
1002
+ });
1003
+ return lafsSuccess(data, "migrate");
1004
+ } catch (err) {
1005
+ return lafsError(
1006
+ "E_MIGRATE_FAILED",
1007
+ err instanceof Error ? err.message : String(err),
1008
+ "migrate"
1009
+ );
1010
+ }
1011
+ },
1012
+ cleanup: async (params) => {
1013
+ const projectRoot = getProjectRoot();
1014
+ if (!params.target) {
1015
+ return lafsError("E_INVALID_INPUT", "target is required", "cleanup");
1016
+ }
1017
+ try {
1018
+ const data = await cleanupSystem(projectRoot, {
1019
+ target: params.target,
1020
+ olderThan: params.olderThan,
1021
+ dryRun: params.dryRun
1022
+ });
1023
+ return lafsSuccess(data, "cleanup");
1024
+ } catch (err) {
1025
+ return lafsError(
1026
+ "E_CLEANUP_FAILED",
1027
+ err instanceof Error ? err.message : String(err),
1028
+ "cleanup"
1029
+ );
1030
+ }
1031
+ },
1032
+ "job.cancel": async (params) => {
1033
+ const { getJobManager } = await import("@cleocode/runtime/gateway");
1034
+ const mgr = getJobManager();
1035
+ if (!mgr) {
1036
+ return lafsError(
1037
+ "E_NOT_AVAILABLE",
1038
+ "Job manager not available. Background jobs require a running CLEO daemon or long-lived process.",
1039
+ "job.cancel"
1040
+ );
1041
+ }
1042
+ const cancellationRequested = mgr.cancelJob(params.jobId);
1043
+ const job = mgr.getJob(params.jobId);
1044
+ if (!job) {
1045
+ return lafsError("E_NOT_FOUND", `Job ${params.jobId} not found`, "job.cancel");
1046
+ }
1047
+ return lafsSuccess(
1048
+ {
1049
+ jobId: params.jobId,
1050
+ cancellationRequested,
1051
+ cancelled: job.status === "cancelled",
1052
+ status: job.status
1053
+ },
1054
+ "job.cancel"
1055
+ );
1056
+ },
1057
+ safestop: async (params) => {
1058
+ const projectRoot = getProjectRoot();
1059
+ try {
1060
+ const data = await safestop(projectRoot, {
1061
+ reason: params.reason,
1062
+ commit: params.commit,
1063
+ handoff: params.handoff,
1064
+ noSessionEnd: params.noSessionEnd,
1065
+ dryRun: params.dryRun
1066
+ });
1067
+ return lafsSuccess(data, "safestop");
1068
+ } catch (err) {
1069
+ return lafsError("E_GENERAL", err instanceof Error ? err.message : String(err), "safestop");
1070
+ }
1071
+ },
1072
+ "inject.generate": async (_params) => {
1073
+ const projectRoot = getProjectRoot();
1074
+ try {
1075
+ const accessor = await getTaskAccessor(projectRoot);
1076
+ const data = await generateInjection(projectRoot, accessor);
1077
+ return lafsSuccess(data, "inject.generate");
1078
+ } catch (err) {
1079
+ return lafsError(
1080
+ "E_GENERAL",
1081
+ err instanceof Error ? err.message : String(err),
1082
+ "inject.generate"
1083
+ );
1084
+ }
1085
+ },
1086
+ "adr.sync": async (params) => {
1087
+ const projectRoot = getProjectRoot();
1088
+ if (params.validate) {
1089
+ const result2 = await validateAllAdrs(projectRoot);
1090
+ return lafsSuccess(result2, "adr.sync");
1091
+ }
1092
+ const result = await syncAdrsToDb(projectRoot);
1093
+ return lafsSuccess(result, "adr.sync");
1094
+ },
1095
+ import: async (params) => {
1096
+ const projectRoot = getProjectRoot();
1097
+ const file = params.file;
1098
+ if (params.scope === "snapshot") {
1099
+ const snapshot = await readSnapshot(file);
1100
+ if (params.dryRun) {
1101
+ return lafsSuccess(
1102
+ {
1103
+ dryRun: true,
1104
+ source: snapshot._meta.source,
1105
+ taskCount: snapshot._meta.taskCount,
1106
+ createdAt: snapshot._meta.createdAt
1107
+ },
1108
+ "import"
1109
+ );
1110
+ }
1111
+ const result2 = await importSnapshot(snapshot, projectRoot);
1112
+ return lafsSuccess(
1113
+ {
1114
+ imported: true,
1115
+ added: result2.added,
1116
+ updated: result2.updated,
1117
+ skipped: result2.skipped,
1118
+ conflicts: result2.conflicts.length > 0 ? result2.conflicts : void 0
1119
+ },
1120
+ "import"
1121
+ );
1122
+ }
1123
+ if (params.scope === "tasks") {
1124
+ const result2 = await importTasksPackage(projectRoot, params);
1125
+ return lafsSuccess(result2, "import");
1126
+ }
1127
+ const result = await importTasks(projectRoot, params);
1128
+ return lafsSuccess(result, "import");
1129
+ },
1130
+ detect: async (_params) => {
1131
+ const projectRoot = getProjectRoot();
1132
+ const [{ ensureProjectContext }, { ensureContributorMcp: ensureContributorDev }] = await Promise.all([
1133
+ import("@cleocode/core/scaffold/ensure-skills"),
1134
+ import("@cleocode/core/scaffold/ensure-config")
1135
+ ]);
1136
+ const contextResult = await ensureProjectContext(projectRoot, { force: true });
1137
+ const devResult = await ensureContributorDev(projectRoot);
1138
+ return lafsSuccess({ context: contextResult, devChannel: devResult }, "detect");
1139
+ },
1140
+ "token.mutate": async (params) => {
1141
+ const projectRoot = getProjectRoot();
1142
+ const action = params.action ?? "record";
1143
+ if (action === "delete") {
1144
+ const tokenId = params.tokenId;
1145
+ if (!tokenId) {
1146
+ return lafsError("E_INVALID_INPUT", "tokenId is required", "token.mutate");
1147
+ }
1148
+ const result2 = await deleteTokenUsage(projectRoot, { id: tokenId });
1149
+ return lafsSuccess(result2, "token.mutate");
1150
+ }
1151
+ if (action === "clear") {
1152
+ const result2 = await clearTokenUsage(projectRoot, {
1153
+ provider: params.provider,
1154
+ transport: params.transport,
1155
+ gateway: params.gateway,
1156
+ domain: params.domain,
1157
+ operation: params.operationName,
1158
+ sessionId: params.sessionId,
1159
+ taskId: params.taskId,
1160
+ method: params.method,
1161
+ confidence: params.confidence,
1162
+ requestId: params.requestId,
1163
+ since: params.since,
1164
+ until: params.until
1165
+ });
1166
+ return lafsSuccess(result2, "token.mutate");
1167
+ }
1168
+ const result = await recordTokenExchange(projectRoot, {
1169
+ provider: params.provider,
1170
+ model: params.model,
1171
+ transport: params.transport,
1172
+ gateway: params.gateway,
1173
+ domain: params.domain,
1174
+ operation: params.operationName,
1175
+ sessionId: params.sessionId,
1176
+ taskId: params.taskId,
1177
+ requestId: params.requestId,
1178
+ requestPayload: params.requestPayload,
1179
+ responsePayload: params.responsePayload,
1180
+ metadata: params.metadata
1181
+ });
1182
+ return lafsSuccess(result, "token.mutate");
1183
+ },
1184
+ "context.inject": async (params) => {
1185
+ const projectRoot = getProjectRoot();
1186
+ const result = await sessionContextInject(
1187
+ params.protocolType,
1188
+ {
1189
+ taskId: params.taskId,
1190
+ variant: params.variant
1191
+ },
1192
+ projectRoot
1193
+ );
1194
+ if (!result.success) {
1195
+ return lafsError(
1196
+ String(result.error?.code ?? "E_INTERNAL"),
1197
+ result.error?.message ?? "Unknown error",
1198
+ "context.inject"
1199
+ );
1200
+ }
1201
+ return lafsSuccess(result.data, "context.inject");
1202
+ },
1203
+ "map.mutate": async (params) => {
1204
+ const projectRoot = getProjectRoot();
1205
+ try {
1206
+ const data = await mapCodebase(projectRoot, { focus: params.focus, storeToBrain: true });
1207
+ return lafsSuccess(data, "map.mutate");
1208
+ } catch (err) {
1209
+ return lafsError("E_GENERAL", err instanceof Error ? err.message : String(err), "map.mutate");
1210
+ }
1211
+ },
1212
+ "install.global": async (_params) => {
1213
+ const [{ ensureGlobalScaffold }, { ensureGlobalTemplates }] = await Promise.all([
1214
+ import("@cleocode/core/scaffold/global-scaffold"),
1215
+ import("@cleocode/core/scaffold/ensure-templates")
1216
+ ]);
1217
+ const scaffoldResult = await ensureGlobalScaffold();
1218
+ const templateResult = await ensureGlobalTemplates();
1219
+ return lafsSuccess({ scaffold: scaffoldResult, templates: templateResult }, "install.global");
1220
+ }
1221
+ });
1222
+ var QUERY_OPS = /* @__PURE__ */ new Set([
1223
+ "version",
1224
+ "health",
1225
+ "config.show",
1226
+ "config.presets",
1227
+ "config.get",
1228
+ "config.list",
1229
+ "config.validate",
1230
+ "stats",
1231
+ "context",
1232
+ "context.pull",
1233
+ "runtime",
1234
+ "paths",
1235
+ "job",
1236
+ "dash",
1237
+ "log",
1238
+ "sequence",
1239
+ "help",
1240
+ "token",
1241
+ "adr.find",
1242
+ "adr.show",
1243
+ "backup",
1244
+ "export",
1245
+ "map",
1246
+ "roadmap",
1247
+ "smoke",
1248
+ "smoke.provider",
1249
+ "hooks.matrix"
1250
+ ]);
1251
+ var MUTATE_OPS = /* @__PURE__ */ new Set([
1252
+ "init",
1253
+ "scaffold-hub",
1254
+ "health",
1255
+ "config.set",
1256
+ "config.set-preset",
1257
+ "config.unset",
1258
+ "backup",
1259
+ "migrate",
1260
+ "cleanup",
1261
+ "job.cancel",
1262
+ "safestop",
1263
+ "inject.generate",
1264
+ "adr.sync",
1265
+ "import",
1266
+ "detect",
1267
+ "token",
1268
+ "context.inject",
1269
+ "map",
1270
+ "install.global"
1271
+ ]);
1272
+ function queryKey(operation) {
1273
+ return operation;
1274
+ }
1275
+ function mutateKey(operation) {
1276
+ switch (operation) {
1277
+ case "health":
1278
+ return "health.mutate";
1279
+ case "backup":
1280
+ return "backup.mutate";
1281
+ case "map":
1282
+ return "map.mutate";
1283
+ case "token":
1284
+ return "token.mutate";
1285
+ default:
1286
+ return operation;
1287
+ }
1288
+ }
1289
+ var AdminHandler = class {
1290
+ // -----------------------------------------------------------------------
1291
+ // Query
1292
+ // -----------------------------------------------------------------------
1293
+ /**
1294
+ * Execute a read-only admin query operation.
1295
+ *
1296
+ * @param operation - The admin query op name (e.g. 'version', 'health').
1297
+ * @param params - Raw params from the dispatcher (narrowed internally).
1298
+ */
1299
+ async query(operation, params) {
1300
+ const startTime = Date.now();
1301
+ if (!QUERY_OPS.has(operation)) {
1302
+ return unsupportedOp("query", "admin", operation, startTime);
1303
+ }
1304
+ try {
1305
+ const envelope = await typedDispatch(_adminTypedHandler, queryKey(operation), params ?? {});
1306
+ return wrapResult(envelopeToEngineResult(envelope), "query", "admin", operation, startTime);
1307
+ } catch (error) {
1308
+ getLogger("domain:admin").error(
1309
+ { gateway: "query", domain: "admin", operation, err: error },
1310
+ error instanceof Error ? error.message : String(error)
1311
+ );
1312
+ return handleErrorResult("query", "admin", operation, error, startTime);
1313
+ }
1314
+ }
1315
+ // -----------------------------------------------------------------------
1316
+ // Mutate
1317
+ // -----------------------------------------------------------------------
1318
+ /**
1319
+ * Execute a state-modifying admin mutation operation.
1320
+ *
1321
+ * @param operation - The admin mutate op name (e.g. 'init', 'backup').
1322
+ * @param params - Raw params from the dispatcher (narrowed internally).
1323
+ */
1324
+ async mutate(operation, params) {
1325
+ const startTime = Date.now();
1326
+ if (!MUTATE_OPS.has(operation)) {
1327
+ return unsupportedOp("mutate", "admin", operation, startTime);
1328
+ }
1329
+ try {
1330
+ const envelope = await typedDispatch(_adminTypedHandler, mutateKey(operation), params ?? {});
1331
+ if (operation === "adr.sync") {
1332
+ const data = envelope.success ? envelope.data : void 0;
1333
+ if (data && "valid" in data && !data.valid) {
1334
+ const errors = Array.isArray(data.errors) ? data.errors : [];
1335
+ return {
1336
+ meta: dispatchMeta("mutate", "admin", operation, startTime),
1337
+ success: false,
1338
+ data,
1339
+ error: {
1340
+ code: "E_ADR_VALIDATION",
1341
+ message: `${errors.length} ADR validation error(s) found`
1342
+ }
1343
+ };
1344
+ }
1345
+ if (data && "errors" in data && Array.isArray(data.errors) && data.errors.length > 0) {
1346
+ return {
1347
+ meta: dispatchMeta("mutate", "admin", operation, startTime),
1348
+ success: false,
1349
+ data,
1350
+ error: {
1351
+ code: "E_ADR_SYNC",
1352
+ message: `${data.errors.length} ADR sync error(s) occurred`
1353
+ }
1354
+ };
1355
+ }
1356
+ }
1357
+ return wrapResult(envelopeToEngineResult(envelope), "mutate", "admin", operation, startTime);
1358
+ } catch (error) {
1359
+ getLogger("domain:admin").error(
1360
+ { gateway: "mutate", domain: "admin", operation, err: error },
1361
+ error instanceof Error ? error.message : String(error)
1362
+ );
1363
+ return handleErrorResult("mutate", "admin", operation, error, startTime);
1364
+ }
1365
+ }
1366
+ // -----------------------------------------------------------------------
1367
+ // Supported operations
1368
+ // -----------------------------------------------------------------------
1369
+ /** Declared operations for introspection and validation. */
1370
+ getSupportedOperations() {
1371
+ return {
1372
+ query: [
1373
+ "version",
1374
+ "health",
1375
+ "config.show",
1376
+ "config.presets",
1377
+ "config.get",
1378
+ "config.list",
1379
+ "config.validate",
1380
+ "stats",
1381
+ "context",
1382
+ "context.pull",
1383
+ "runtime",
1384
+ "paths",
1385
+ "job",
1386
+ "dash",
1387
+ "log",
1388
+ "sequence",
1389
+ "help",
1390
+ "token",
1391
+ "adr.show",
1392
+ "adr.find",
1393
+ "backup",
1394
+ "export",
1395
+ "map",
1396
+ "roadmap",
1397
+ "smoke",
1398
+ "smoke.provider",
1399
+ "hooks.matrix"
1400
+ ],
1401
+ mutate: [
1402
+ "init",
1403
+ "scaffold-hub",
1404
+ "config.set",
1405
+ "config.set-preset",
1406
+ "config.unset",
1407
+ "backup",
1408
+ "migrate",
1409
+ "cleanup",
1410
+ "job.cancel",
1411
+ "safestop",
1412
+ "inject.generate",
1413
+ "install.global",
1414
+ "token",
1415
+ "adr.sync",
1416
+ "health",
1417
+ "context.inject",
1418
+ "import",
1419
+ "detect",
1420
+ "map"
1421
+ ]
1422
+ };
1423
+ }
1424
+ };
1425
+ export {
1426
+ AdminHandler
1427
+ };
1428
+ //# sourceMappingURL=admin-L3F6CDYH.js.map