@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,2924 @@
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
+ dispatchFromCli,
18
+ dispatchRaw
19
+ } from "./chunk-L7ONYSV6.js";
20
+ import "./chunk-6N6WGLXE.js";
21
+ import "./chunk-4VASFLUW.js";
22
+ import {
23
+ asCleoErrorLike,
24
+ cleoErrorCodeName
25
+ } from "./chunk-VLEYOOPH.js";
26
+ import {
27
+ defineCommand,
28
+ showUsage
29
+ } from "./chunk-PKKZPOOP.js";
30
+ import "./chunk-QKMBWYAS.js";
31
+ import {
32
+ cliError,
33
+ cliOutput,
34
+ humanInfo,
35
+ humanWarn
36
+ } from "./chunk-4RGSNUUP.js";
37
+ import {
38
+ getFormatContext,
39
+ setFormatContext
40
+ } from "./chunk-6JSJNYH2.js";
41
+ import "./chunk-D7BAQNV2.js";
42
+ import "./chunk-TYC7G5LF.js";
43
+
44
+ // packages/cleo/src/cli/commands/nexus.ts
45
+ import { statSync } from "node:fs";
46
+ import { appendFile, mkdir } from "node:fs/promises";
47
+ import path from "node:path";
48
+ import {
49
+ ExitCode
50
+ } from "@cleocode/contracts";
51
+ import { getSymbolImpact } from "@cleocode/core/nexus";
52
+ import { runNexusAnalysis } from "@cleocode/core/nexus/analyze-orchestrator.js";
53
+ import {
54
+ parseAssessmentFilesRequest,
55
+ projectAssessmentFiles
56
+ } from "@cleocode/core/nexus/assessment-projection.js";
57
+ import { exportNexusGraph } from "@cleocode/core/nexus/export.js";
58
+ import {
59
+ assessNexusFreshnessForQuery,
60
+ assessNexusIndexFreshness,
61
+ discloseNexusFreshness,
62
+ judgeSymbolFiles,
63
+ querySymbolFiles,
64
+ withNexusFreshnessMeta
65
+ } from "@cleocode/core/nexus/freshness.js";
66
+ import { KnowledgeSymbolAmbiguityError } from "@cleocode/core/nexus/knowledge.js";
67
+ import { resolveNexusQueryProjectId } from "@cleocode/core/nexus/registry.js";
68
+ import { runNexusWiki } from "@cleocode/core/nexus/wiki-orchestrator.js";
69
+ import { getProjectRoot } from "@cleocode/core/project-scope";
70
+ import { getCleoStateDir } from "@cleocode/paths";
71
+
72
+ // packages/cleo/src/dispatch/nexus-decorator.ts
73
+ import {
74
+ buildNexusMetaExtensions,
75
+ formatSuggestedNext,
76
+ pickDecoratorMetaExtensions,
77
+ stampNexusMeta,
78
+ validateSuggestedNext
79
+ } from "@cleocode/runtime/gateway/dispatch";
80
+
81
+ // packages/cleo/src/cli/commands/nexus.ts
82
+ async function appendDeprecationTelemetry(op, replacement) {
83
+ try {
84
+ const dateStr = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
85
+ const dir = path.join(getCleoStateDir(), "nexus-deprecation");
86
+ await mkdir(dir, { recursive: true });
87
+ const record = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), op, replacement }) + "\n";
88
+ await appendFile(path.join(dir, `${dateStr}.jsonl`), record, "utf8");
89
+ } catch {
90
+ }
91
+ }
92
+ function applyJsonFlag(jsonFlag) {
93
+ if (jsonFlag) {
94
+ setFormatContext({ format: "json", source: "flag", quiet: false });
95
+ }
96
+ }
97
+ var initCommand = defineCommand({
98
+ meta: { name: "init", description: "Initialize NEXUS directory structure and registry" },
99
+ async run() {
100
+ await dispatchFromCli("mutate", "nexus", "init", {}, { command: "nexus" });
101
+ }
102
+ });
103
+ var registerCommand = defineCommand({
104
+ meta: { name: "register", description: "Register a project in the global registry" },
105
+ args: {
106
+ path: {
107
+ type: "positional",
108
+ description: "Path to the project directory",
109
+ required: true
110
+ },
111
+ name: {
112
+ type: "string",
113
+ description: "Custom project name (default: directory name)"
114
+ },
115
+ permissions: {
116
+ type: "string",
117
+ description: "Permissions: read|write|execute",
118
+ default: "read"
119
+ }
120
+ },
121
+ async run({ args }) {
122
+ await dispatchFromCli(
123
+ "mutate",
124
+ "nexus",
125
+ "register",
126
+ {
127
+ path: args.path,
128
+ name: args.name,
129
+ permission: args.permissions
130
+ },
131
+ { command: "nexus" }
132
+ );
133
+ }
134
+ });
135
+ var unregisterCommand = defineCommand({
136
+ meta: { name: "unregister", description: "Remove a project from the registry" },
137
+ args: {
138
+ nameOrHash: {
139
+ type: "positional",
140
+ description: "Project name or hash to unregister",
141
+ required: true
142
+ }
143
+ },
144
+ async run({ args }) {
145
+ await dispatchFromCli(
146
+ "mutate",
147
+ "nexus",
148
+ "unregister",
149
+ { name: args.nameOrHash },
150
+ { command: "nexus" }
151
+ );
152
+ }
153
+ });
154
+ var listCommand = defineCommand({
155
+ meta: { name: "list", description: "List all registered projects" },
156
+ async run() {
157
+ await dispatchFromCli("query", "nexus", "list", {}, { command: "nexus" });
158
+ }
159
+ });
160
+ var statusCommand = defineCommand({
161
+ meta: {
162
+ name: "status",
163
+ description: "Show code intelligence index freshness: file count, node/relation counts, last indexed time, stale files. Per-file rows are counted (assessment.filesByStatus) and paged (assessment.filesPage; --limit/--offset/--file-status, --files for all). Falls back to NEXUS registry status if code-intelligence index is unavailable."
164
+ },
165
+ args: {
166
+ path: {
167
+ type: "positional",
168
+ description: "Path to the project directory (default: cwd)",
169
+ required: false
170
+ },
171
+ "project-id": {
172
+ type: "string",
173
+ description: "Override the project ID (default: auto-detected from path)"
174
+ },
175
+ references: {
176
+ type: "boolean",
177
+ description: "Include every retained unresolved/unmodeled reference (large; the default reports referenceCount)"
178
+ },
179
+ // T12560: the per-file list is ~635 B per file (391 MB for one reporter),
180
+ // so the default reports counts plus a 20-row page and marks `files` withheld.
181
+ files: {
182
+ type: "boolean",
183
+ description: "Include every assessed file row under assessment.files (large; the default reports fileCount, filesByStatus and a 20-row filesPage)"
184
+ },
185
+ limit: {
186
+ type: "string",
187
+ description: "Rows in assessment.filesPage (default 20; 0 = every row)"
188
+ },
189
+ offset: {
190
+ type: "string",
191
+ description: "Rows to skip before assessment.filesPage (use filesPage.nextOffset)"
192
+ },
193
+ "file-status": {
194
+ type: "string",
195
+ description: "Page only files with this status: analyzed|excluded|unsupported|oversized|failed"
196
+ },
197
+ json: {
198
+ type: "boolean",
199
+ description: "Output as JSON (LAFS envelope format)"
200
+ },
201
+ // gh#1329, second half — DECLARE the global output flag so citty consumes
202
+ // it. Undeclared, `--output json` was consumed as the positional `path`,
203
+ // and `json` base64url'd into a well-formed project id: the flag silently
204
+ // changed WHICH PROJECT was queried, which is how the reporter reached the
205
+ // reporting bug. Same precedent as `docs.ts`, which declares it "for
206
+ // docs-command consistency".
207
+ //
208
+ // The repo-wide fix is the strict-flags chokepoint (gh#1276); declaring it
209
+ // here removes the hazard from the one command whose swallowed value selects
210
+ // a project rather than merely being ignored.
211
+ output: {
212
+ type: "string",
213
+ description: "Output mode: envelope|id|table|count|silent (global output flag; declared here so it is not consumed as the positional path)."
214
+ }
215
+ },
216
+ async run({ args }) {
217
+ applyJsonFlag(args.json);
218
+ const projectIdOverride = args["project-id"];
219
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
220
+ const startTime = Date.now();
221
+ if (args.path) {
222
+ let isDir = false;
223
+ try {
224
+ isDir = statSync(repoPath).isDirectory();
225
+ } catch {
226
+ isDir = false;
227
+ }
228
+ if (!isDir) {
229
+ cliError(
230
+ `nexus status was given '${args.path}', which is not a directory.
231
+ A project id can be derived from any string, so an unreadable path would otherwise produce a well-formed id and be reported alongside THIS project's counts. If you meant to pass a flag value, note that an undeclared flag on this subcommand is consumed as the positional path.`,
232
+ ExitCode.INVALID_INPUT,
233
+ {
234
+ name: "E_NEXUS_PATH_NOT_A_DIRECTORY",
235
+ fix: `cleo nexus status <existing project directory> (omit the path to use the current project)`
236
+ },
237
+ { operation: "nexus.status" }
238
+ );
239
+ process.exitCode = ExitCode.INVALID_INPUT;
240
+ return;
241
+ }
242
+ }
243
+ let projectId;
244
+ try {
245
+ projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
246
+ } catch (error) {
247
+ const typed = asCleoErrorLike(error);
248
+ const code = typed?.code ?? ExitCode.INVALID_INPUT;
249
+ const name = code === ExitCode.INVALID_INPUT && !typed?.codeName ? "E_NEXUS_CROSS_PROJECT_STATUS" : typed ? cleoErrorCodeName(typed) : "E_NEXUS_IDENTITY";
250
+ cliError(
251
+ error instanceof Error ? error.message : String(error),
252
+ code,
253
+ {
254
+ name,
255
+ fix: typed ? typed.fix : "Run nexus status from the intended project using its portable project id."
256
+ },
257
+ { operation: "nexus.status" }
258
+ );
259
+ process.exitCode = code;
260
+ return;
261
+ }
262
+ let filesRequest;
263
+ try {
264
+ filesRequest = parseAssessmentFilesRequest({
265
+ files: args.files,
266
+ limit: args.limit,
267
+ offset: args.offset,
268
+ fileStatus: args["file-status"]
269
+ });
270
+ } catch (err) {
271
+ cliError(
272
+ err instanceof Error ? err.message : String(err),
273
+ ExitCode.INVALID_INPUT,
274
+ {
275
+ name: "E_VALIDATION",
276
+ fix: "cleo nexus status --limit 20 --offset 0 --file-status failed"
277
+ },
278
+ { operation: "nexus.status" }
279
+ );
280
+ process.exitCode = ExitCode.INVALID_INPUT;
281
+ return;
282
+ }
283
+ const currentRoot = getProjectRoot();
284
+ if (args.path && path.resolve(repoPath) !== path.resolve(currentRoot)) {
285
+ cliError(
286
+ `nexus status cannot report on '${repoPath}' from this project.
287
+ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store per project, and the counts always describe the store that is open. Reporting them under '${repoPath}' would attribute this project's index to another.`,
288
+ ExitCode.INVALID_INPUT,
289
+ {
290
+ name: "E_NEXUS_CROSS_PROJECT_STATUS",
291
+ fix: `cd ${repoPath} && cleo nexus status`
292
+ },
293
+ { operation: "nexus.status" }
294
+ );
295
+ process.exitCode = ExitCode.INVALID_INPUT;
296
+ return;
297
+ }
298
+ try {
299
+ const [
300
+ { getNexusDb, nexusSchema },
301
+ { getIndexStats },
302
+ { readKnowledgeIndexAssessment, readKnowledgeIndexReferences }
303
+ ] = await Promise.all([
304
+ import("@cleocode/core/store/nexus-sqlite"),
305
+ import("@cleocode/nexus/pipeline"),
306
+ import("@cleocode/core/nexus/knowledge")
307
+ ]);
308
+ const db = await getNexusDb();
309
+ const tables = {
310
+ nexusNodes: nexusSchema.nexusNodes,
311
+ nexusRelations: nexusSchema.nexusRelations
312
+ };
313
+ const freshness = await assessNexusIndexFreshness(currentRoot);
314
+ const stats = await getIndexStats(projectId, repoPath, db, tables, {
315
+ staleScan: freshness.status === "unknown"
316
+ });
317
+ const summary = await readKnowledgeIndexAssessment(currentRoot);
318
+ const detailed = summary && args.references ? { ...summary, references: await readKnowledgeIndexReferences(currentRoot) } : summary;
319
+ const assessment = detailed && projectAssessmentFiles(detailed, filesRequest);
320
+ const durationMs = Date.now() - startTime;
321
+ cliOutput(
322
+ {
323
+ projectId,
324
+ repoPath,
325
+ ...stats,
326
+ ...freshness.status === "unknown" ? {} : { staleFileCount: freshness.staleFileCount },
327
+ freshness,
328
+ assessment
329
+ },
330
+ {
331
+ command: "nexus-status",
332
+ operation: "nexus.status",
333
+ extensions: {
334
+ duration_ms: durationMs,
335
+ ...buildNexusMetaExtensions("status", { projectId, path: repoPath })
336
+ }
337
+ }
338
+ );
339
+ } catch (err) {
340
+ const msg = err instanceof Error ? err.message : String(err);
341
+ const ctx = getFormatContext();
342
+ if (ctx.format === "json") {
343
+ cliError(msg, 1, { name: "E_STATUS_FAILED" }, { operation: "nexus.status" });
344
+ } else {
345
+ humanWarn(`[nexus] Error: ${msg}`);
346
+ await dispatchFromCli("query", "nexus", "status", {}, { command: "nexus" });
347
+ }
348
+ process.exitCode = 1;
349
+ }
350
+ }
351
+ });
352
+ var showCommand = defineCommand({
353
+ meta: { name: "show", description: "Show details for a registered project by name" },
354
+ args: {
355
+ name: {
356
+ type: "positional",
357
+ description: "Project name",
358
+ required: true
359
+ }
360
+ },
361
+ async run({ args }) {
362
+ await dispatchFromCli("query", "nexus", "show", { name: args.name }, { command: "nexus" });
363
+ }
364
+ });
365
+ var resolveCommand = defineCommand({
366
+ meta: {
367
+ name: "resolve",
368
+ description: "Resolve a task reference across projects (project:T### or T###)"
369
+ },
370
+ args: {
371
+ taskRef: {
372
+ type: "positional",
373
+ description: "Task reference to resolve",
374
+ required: true
375
+ }
376
+ },
377
+ async run({ args }) {
378
+ await dispatchFromCli(
379
+ "query",
380
+ "nexus",
381
+ "resolve",
382
+ { query: args.taskRef },
383
+ { command: "nexus" }
384
+ );
385
+ }
386
+ });
387
+ var discoverCommand = defineCommand({
388
+ meta: { name: "discover", description: "Find related tasks across projects" },
389
+ args: {
390
+ taskQuery: {
391
+ type: "positional",
392
+ description: "Task query string",
393
+ required: true
394
+ },
395
+ method: {
396
+ type: "string",
397
+ description: "Discovery method: labels|description|files|auto",
398
+ default: "auto"
399
+ },
400
+ limit: {
401
+ type: "string",
402
+ description: "Max results",
403
+ default: "10"
404
+ }
405
+ },
406
+ async run({ args }) {
407
+ await dispatchFromCli(
408
+ "query",
409
+ "nexus",
410
+ "discover",
411
+ {
412
+ query: args.taskQuery,
413
+ method: args.method,
414
+ limit: parseInt(args.limit, 10)
415
+ },
416
+ { command: "nexus" }
417
+ );
418
+ }
419
+ });
420
+ var augmentCommand = defineCommand({
421
+ meta: {
422
+ name: "augment",
423
+ description: "Augment symbol pattern with code context (for PreToolUse hooks)"
424
+ },
425
+ args: {
426
+ pattern: {
427
+ type: "positional",
428
+ description: "Symbol name or file pattern to search",
429
+ required: true
430
+ },
431
+ limit: {
432
+ type: "string",
433
+ description: "Max results to return (default: 5)",
434
+ default: "5"
435
+ }
436
+ },
437
+ async run({ args }) {
438
+ const pattern = args.pattern;
439
+ const limit = parseInt(args.limit, 10) || 5;
440
+ await dispatchFromCli(
441
+ "query",
442
+ "nexus",
443
+ "augment",
444
+ {
445
+ pattern,
446
+ limit
447
+ },
448
+ { command: "nexus" }
449
+ );
450
+ }
451
+ });
452
+ var setupCommand = defineCommand({
453
+ meta: {
454
+ name: "setup",
455
+ description: "Install Nexus PreToolUse hook augmenter"
456
+ },
457
+ args: {},
458
+ async run() {
459
+ try {
460
+ const { homedir } = await import("node:os");
461
+ const { installNexusAugmentHook } = await import("@cleocode/core/nexus/hooks-augment");
462
+ const homeDir = homedir();
463
+ installNexusAugmentHook(homeDir);
464
+ cliOutput({ homeDir }, { command: "nexus-setup", operation: "nexus.setup" });
465
+ } catch (err) {
466
+ const msg = err instanceof Error ? err.message : String(err);
467
+ cliError(msg, 1, { name: "E_SETUP_FAILED" }, { operation: "nexus.setup" });
468
+ process.exitCode = 1;
469
+ }
470
+ }
471
+ });
472
+ var searchCommand = defineCommand({
473
+ meta: { name: "search", description: "Search tasks across projects by pattern" },
474
+ args: {
475
+ pattern: {
476
+ type: "positional",
477
+ description: "Search pattern",
478
+ required: true
479
+ },
480
+ project: {
481
+ type: "string",
482
+ description: "Limit search to specific project"
483
+ },
484
+ limit: {
485
+ type: "string",
486
+ description: "Max results",
487
+ default: "20"
488
+ }
489
+ },
490
+ async run({ args }) {
491
+ await dispatchFromCli(
492
+ "query",
493
+ "nexus",
494
+ "search",
495
+ {
496
+ pattern: args.pattern,
497
+ project: args.project,
498
+ limit: parseInt(args.limit, 10)
499
+ },
500
+ { command: "nexus" }
501
+ );
502
+ }
503
+ });
504
+ var depsCommand = defineCommand({
505
+ meta: { name: "deps", description: "Show cross-project dependencies" },
506
+ args: {
507
+ taskQuery: {
508
+ type: "positional",
509
+ description: "Task query string",
510
+ required: true
511
+ },
512
+ reverse: {
513
+ type: "boolean",
514
+ description: "Show reverse dependencies (what depends on this)"
515
+ }
516
+ },
517
+ async run({ args }) {
518
+ await dispatchFromCli(
519
+ "query",
520
+ "nexus",
521
+ "deps",
522
+ {
523
+ query: args.taskQuery,
524
+ direction: args.reverse ? "reverse" : "forward"
525
+ },
526
+ { command: "nexus" }
527
+ );
528
+ }
529
+ });
530
+ var criticalPathCommand = defineCommand({
531
+ meta: {
532
+ name: "critical-path",
533
+ description: "Show global critical path across all registered projects"
534
+ },
535
+ async run() {
536
+ await dispatchFromCli("query", "nexus", "path.show", {}, { command: "nexus" });
537
+ }
538
+ });
539
+ var blockingCommand = defineCommand({
540
+ meta: { name: "blocking", description: "Show blocking impact analysis for a task" },
541
+ args: {
542
+ taskQuery: {
543
+ type: "positional",
544
+ description: "Task query string",
545
+ required: true
546
+ }
547
+ },
548
+ async run({ args }) {
549
+ await dispatchFromCli(
550
+ "query",
551
+ "nexus",
552
+ "blockers.show",
553
+ { query: args.taskQuery },
554
+ { command: "nexus" }
555
+ );
556
+ }
557
+ });
558
+ var orphansCommand = defineCommand({
559
+ meta: { name: "orphans", description: "Detect broken cross-project dependency references" },
560
+ async run() {
561
+ await dispatchFromCli("query", "nexus", "orphans.list", {}, { command: "nexus" });
562
+ }
563
+ });
564
+ var syncCommand = defineCommand({
565
+ meta: { name: "sync", description: "Sync project metadata (task count, labels)" },
566
+ args: {
567
+ project: {
568
+ type: "positional",
569
+ description: "Project name to sync (default: all)",
570
+ required: false
571
+ }
572
+ },
573
+ async run({ args }) {
574
+ if (args.project) {
575
+ await dispatchFromCli(
576
+ "mutate",
577
+ "nexus",
578
+ "sync",
579
+ { name: args.project },
580
+ { command: "nexus" }
581
+ );
582
+ } else {
583
+ await dispatchFromCli("mutate", "nexus", "sync", {}, { command: "nexus" });
584
+ }
585
+ }
586
+ });
587
+ var reconcileCommand = defineCommand({
588
+ meta: {
589
+ name: "reconcile",
590
+ description: "Reconcile current project with NEXUS registry (auto-register if new, update path if moved)"
591
+ },
592
+ args: {
593
+ path: {
594
+ type: "string",
595
+ description: "Project path (default: current directory)"
596
+ },
597
+ "force-rebind": {
598
+ type: "boolean",
599
+ description: "Point the registry row at this checkout even though its previous location still exists (T12470). Without it, that checkout is recorded as a candidate.",
600
+ default: false
601
+ }
602
+ },
603
+ async run({ args }) {
604
+ await dispatchFromCli(
605
+ "mutate",
606
+ "nexus",
607
+ "reconcile",
608
+ {
609
+ projectRoot: args.path,
610
+ ...args["force-rebind"] ? { forceRebind: true } : {}
611
+ },
612
+ { command: "nexus" }
613
+ );
614
+ }
615
+ });
616
+ var graphCommand = defineCommand({
617
+ meta: { name: "graph", description: "Show full dependency graph across all registered projects" },
618
+ async run() {
619
+ await dispatchFromCli("query", "nexus", "graph", {}, { command: "nexus" });
620
+ }
621
+ });
622
+ var shareStatusCommand = defineCommand({
623
+ meta: {
624
+ name: "share-status",
625
+ description: "Show multi-contributor sharing status for the current project"
626
+ },
627
+ async run() {
628
+ await dispatchFromCli("query", "nexus", "share.status", {}, { command: "nexus" });
629
+ }
630
+ });
631
+ var transferPreviewCommand = defineCommand({
632
+ meta: {
633
+ name: "transfer-preview",
634
+ description: "Preview a task transfer between projects (dry-run, no changes made)"
635
+ },
636
+ args: {
637
+ taskIds: {
638
+ type: "positional",
639
+ description: "Task IDs to preview transfer for",
640
+ required: true
641
+ },
642
+ from: {
643
+ type: "string",
644
+ description: "Source project name",
645
+ required: true
646
+ },
647
+ to: {
648
+ type: "string",
649
+ description: "Target project name",
650
+ required: true
651
+ },
652
+ mode: {
653
+ type: "string",
654
+ description: "Transfer mode: copy|move",
655
+ default: "copy"
656
+ },
657
+ scope: {
658
+ type: "string",
659
+ description: "Transfer scope: single|subtree",
660
+ default: "subtree"
661
+ }
662
+ },
663
+ async run({ args }) {
664
+ await dispatchFromCli(
665
+ "query",
666
+ "nexus",
667
+ "transfer.preview",
668
+ {
669
+ taskIds: args.taskIds.split(",").map((s) => s.trim()),
670
+ sourceProject: args.from,
671
+ targetProject: args.to,
672
+ mode: args.mode,
673
+ scope: args.scope
674
+ },
675
+ { command: "nexus" }
676
+ );
677
+ }
678
+ });
679
+ var transferCommand = defineCommand({
680
+ meta: { name: "transfer", description: "Transfer tasks from one project to another" },
681
+ args: {
682
+ taskIds: {
683
+ type: "positional",
684
+ description: "Task IDs to transfer",
685
+ required: true
686
+ },
687
+ from: {
688
+ type: "string",
689
+ description: "Source project name",
690
+ required: true
691
+ },
692
+ to: {
693
+ type: "string",
694
+ description: "Target project name",
695
+ required: true
696
+ },
697
+ mode: {
698
+ type: "string",
699
+ description: "Transfer mode: copy|move",
700
+ default: "copy"
701
+ },
702
+ scope: {
703
+ type: "string",
704
+ description: "Transfer scope: single|subtree",
705
+ default: "subtree"
706
+ },
707
+ "on-conflict": {
708
+ type: "string",
709
+ description: "Conflict strategy: rename|skip|duplicate|fail",
710
+ default: "rename"
711
+ },
712
+ "transfer-brain": {
713
+ type: "boolean",
714
+ description: "Also transfer associated brain memory entries"
715
+ }
716
+ },
717
+ async run({ args }) {
718
+ await dispatchFromCli(
719
+ "mutate",
720
+ "nexus",
721
+ "transfer",
722
+ {
723
+ taskIds: args.taskIds.split(",").map((s) => s.trim()),
724
+ sourceProject: args.from,
725
+ targetProject: args.to,
726
+ mode: args.mode,
727
+ scope: args.scope,
728
+ onConflict: args["on-conflict"],
729
+ transferBrain: args["transfer-brain"]
730
+ },
731
+ { command: "nexus" }
732
+ );
733
+ }
734
+ });
735
+ var permissionSetCommand = defineCommand({
736
+ meta: {
737
+ name: "set",
738
+ description: "Set permission level for a registered project (read|write|execute)"
739
+ },
740
+ args: {
741
+ name: {
742
+ type: "positional",
743
+ description: "Project name",
744
+ required: true
745
+ },
746
+ level: {
747
+ type: "positional",
748
+ description: "Permission level: read|write|execute",
749
+ required: true
750
+ }
751
+ },
752
+ async run({ args }) {
753
+ await dispatchFromCli(
754
+ "mutate",
755
+ "nexus",
756
+ "permission.set",
757
+ { name: args.name, level: args.level },
758
+ { command: "nexus" }
759
+ );
760
+ }
761
+ });
762
+ var permissionCommand = defineCommand({
763
+ meta: { name: "permission", description: "Manage permissions for registered projects" },
764
+ subCommands: {
765
+ set: permissionSetCommand
766
+ }
767
+ });
768
+ var shareExportCommand = defineCommand({
769
+ meta: { name: "export", description: "Export a snapshot of current project state for sharing" },
770
+ args: {
771
+ output: {
772
+ type: "string",
773
+ description: "Output file path (default: auto-generated in current directory)"
774
+ }
775
+ },
776
+ async run({ args }) {
777
+ await dispatchFromCli(
778
+ "mutate",
779
+ "nexus",
780
+ "share.snapshot.export",
781
+ { outputPath: args.output },
782
+ { command: "nexus" }
783
+ );
784
+ }
785
+ });
786
+ var shareImportCommand = defineCommand({
787
+ meta: { name: "import", description: "Import a shared project snapshot" },
788
+ args: {
789
+ file: {
790
+ type: "positional",
791
+ description: "Path to snapshot file",
792
+ required: true
793
+ }
794
+ },
795
+ async run({ args }) {
796
+ await dispatchFromCli(
797
+ "mutate",
798
+ "nexus",
799
+ "share.snapshot.import",
800
+ { inputPath: args.file },
801
+ { command: "nexus" }
802
+ );
803
+ }
804
+ });
805
+ var shareCommand = defineCommand({
806
+ meta: { name: "share", description: "Multi-contributor sharing operations" },
807
+ subCommands: {
808
+ export: shareExportCommand,
809
+ import: shareImportCommand
810
+ }
811
+ });
812
+ var clustersCommand = defineCommand({
813
+ meta: {
814
+ name: "clusters",
815
+ description: "List all detected communities (Louvain clusters) from the last analysis"
816
+ },
817
+ args: {
818
+ path: {
819
+ type: "positional",
820
+ description: "Path to project directory (default: cwd)",
821
+ required: false
822
+ },
823
+ json: {
824
+ type: "boolean",
825
+ description: "Output result as JSON (LAFS envelope format)"
826
+ },
827
+ "project-id": {
828
+ type: "string",
829
+ description: "Override the project ID (default: auto-detected from path)"
830
+ }
831
+ },
832
+ async run({ args }) {
833
+ applyJsonFlag(args.json);
834
+ const startTime = Date.now();
835
+ const projectIdOverride = args["project-id"];
836
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
837
+ const projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
838
+ const response = await dispatchRaw("query", "nexus", "clusters", { projectId, repoPath });
839
+ const durationMs = Date.now() - startTime;
840
+ if (!response.success) {
841
+ const msg = response.error?.message ?? "Unknown error";
842
+ cliError(
843
+ msg,
844
+ 1,
845
+ { name: response.error?.code ?? "E_CLUSTERS_FAILED", details: response.error?.details },
846
+ { operation: "nexus.clusters", duration_ms: durationMs }
847
+ );
848
+ process.exitCode = 1;
849
+ return;
850
+ }
851
+ cliOutput(response.data, {
852
+ command: "nexus-clusters",
853
+ operation: "nexus.clusters",
854
+ extensions: { duration_ms: durationMs },
855
+ responseMeta: response.meta
856
+ });
857
+ }
858
+ });
859
+ var flowsCommand = defineCommand({
860
+ meta: {
861
+ name: "flows",
862
+ description: "List all detected execution flows (processes) from the last analysis"
863
+ },
864
+ args: {
865
+ path: {
866
+ type: "positional",
867
+ description: "Path to project directory (default: cwd)",
868
+ required: false
869
+ },
870
+ json: { type: "boolean", description: "Output result as JSON (LAFS envelope format)" },
871
+ "project-id": {
872
+ type: "string",
873
+ description: "Override the project ID (default: auto-detected from path)"
874
+ }
875
+ },
876
+ async run({ args }) {
877
+ applyJsonFlag(args.json);
878
+ const startTime = Date.now();
879
+ const projectIdOverride = args["project-id"];
880
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
881
+ const projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
882
+ const response = await dispatchRaw("query", "nexus", "flows", { projectId, repoPath });
883
+ const durationMs = Date.now() - startTime;
884
+ if (!response.success) {
885
+ const msg = response.error?.message ?? "Unknown error";
886
+ cliError(
887
+ msg,
888
+ 1,
889
+ { name: response.error?.code ?? "E_FLOWS_FAILED", details: response.error?.details },
890
+ { operation: "nexus.flows", duration_ms: durationMs }
891
+ );
892
+ process.exitCode = 1;
893
+ return;
894
+ }
895
+ cliOutput(response.data, {
896
+ command: "nexus-flows",
897
+ operation: "nexus.flows",
898
+ extensions: { duration_ms: durationMs },
899
+ responseMeta: response.meta
900
+ });
901
+ }
902
+ });
903
+ var contextCommand = defineCommand({
904
+ meta: {
905
+ name: "context",
906
+ description: "Show callers, callees, community membership, and process participation for a code symbol"
907
+ },
908
+ args: {
909
+ symbol: { type: "positional", description: "Symbol name to look up", required: true },
910
+ json: { type: "boolean", description: "Output result as JSON (LAFS envelope format)" },
911
+ "project-id": {
912
+ type: "string",
913
+ description: "Override the project ID (default: auto-detected from cwd)"
914
+ },
915
+ limit: { type: "string", description: "Max callers/callees to show per side", default: "20" },
916
+ content: { type: "boolean", description: "Append source code content for the symbol" }
917
+ },
918
+ async run({ args }) {
919
+ applyJsonFlag(args.json);
920
+ void appendDeprecationTelemetry("nexus.context", "cleo graph context");
921
+ const startTime = Date.now();
922
+ const projectIdOverride = args["project-id"];
923
+ const repoPath = getProjectRoot();
924
+ const projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
925
+ const limit = parseInt(args.limit, 10);
926
+ const symbolName = args.symbol;
927
+ const showContent = !!args.content;
928
+ const response = await dispatchRaw("query", "nexus", "context", {
929
+ symbol: symbolName,
930
+ projectId,
931
+ limit,
932
+ content: showContent,
933
+ _legacyAliasFor: "cleo graph context"
934
+ });
935
+ const durationMs = Date.now() - startTime;
936
+ if (!response.success) {
937
+ const msg = response.error?.message ?? "Unknown error";
938
+ cliError(
939
+ msg,
940
+ 1,
941
+ { name: response.error?.code ?? "E_CONTEXT_FAILED", details: response.error?.details },
942
+ { operation: "nexus.context", duration_ms: durationMs }
943
+ );
944
+ process.exitCode = 1;
945
+ return;
946
+ }
947
+ const result = response.data;
948
+ if (result.matchCount === 0) {
949
+ cliError(
950
+ `No symbol found matching '${symbolName}' in project ${projectId}`,
951
+ 4,
952
+ { name: "E_NOT_FOUND" },
953
+ { operation: "nexus.context", duration_ms: durationMs }
954
+ );
955
+ process.exitCode = 4;
956
+ return;
957
+ }
958
+ cliOutput({ ...result, _symbolName: symbolName }, {
959
+ command: "nexus-context",
960
+ operation: "nexus.context",
961
+ extensions: { duration_ms: durationMs },
962
+ responseMeta: response.meta
963
+ });
964
+ }
965
+ });
966
+ var impactCommand = defineCommand({
967
+ meta: {
968
+ name: "impact",
969
+ description: "Show blast radius for a code symbol \u2014 direct callers (d=1), indirect callers (d=2), transitive (d=3)"
970
+ },
971
+ args: {
972
+ symbol: { type: "positional", description: "Symbol name to analyze", required: true },
973
+ json: { type: "boolean", description: "Output result as JSON (LAFS envelope format)" },
974
+ "project-id": {
975
+ type: "string",
976
+ description: "Override the project ID (default: auto-detected from cwd)"
977
+ },
978
+ depth: { type: "string", description: "Maximum traversal depth (default: 3)", default: "3" },
979
+ why: { type: "boolean", description: "Append reasons[] path-strings for each affected symbol" }
980
+ },
981
+ async run({ args }) {
982
+ applyJsonFlag(args.json);
983
+ const startTime = Date.now();
984
+ const whyFlag = !!args.why;
985
+ const projectIdOverride = args["project-id"];
986
+ const repoPath = getProjectRoot();
987
+ const projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
988
+ const maxDepth = Math.min(parseInt(args.depth, 10), 5);
989
+ const symbolName = args.symbol;
990
+ try {
991
+ const assessment = await assessNexusFreshnessForQuery(repoPath);
992
+ const result = await getSymbolImpact(symbolName, projectId, repoPath, {
993
+ maxDepth,
994
+ why: whyFlag
995
+ });
996
+ const freshness = judgeSymbolFiles(assessment, querySymbolFiles(result));
997
+ discloseNexusFreshness("nexus impact", freshness);
998
+ const durationMs = Date.now() - startTime;
999
+ cliOutput({ ...result, _symbolName: symbolName, _why: whyFlag }, {
1000
+ command: "nexus-impact",
1001
+ operation: "nexus.impact",
1002
+ extensions: withNexusFreshnessMeta(
1003
+ {
1004
+ duration_ms: durationMs,
1005
+ ...buildNexusMetaExtensions("impact", { symbol: symbolName, projectId })
1006
+ },
1007
+ freshness
1008
+ )
1009
+ });
1010
+ } catch (err) {
1011
+ const code = err instanceof Error && "code" in err ? err.code : void 0;
1012
+ const msg = err instanceof Error ? err.message : String(err);
1013
+ const durationMs = Date.now() - startTime;
1014
+ if (err instanceof KnowledgeSymbolAmbiguityError) {
1015
+ cliError(
1016
+ err.message,
1017
+ 6,
1018
+ {
1019
+ name: err.code,
1020
+ details: { candidates: err.candidates },
1021
+ fix: "Use one of the exact candidate identifiers."
1022
+ },
1023
+ { operation: "nexus.impact", duration_ms: durationMs }
1024
+ );
1025
+ process.exitCode = 6;
1026
+ return;
1027
+ }
1028
+ if (code === "E_NOT_FOUND") {
1029
+ cliError(
1030
+ msg,
1031
+ 4,
1032
+ { name: "E_NOT_FOUND" },
1033
+ { operation: "nexus.impact", duration_ms: durationMs }
1034
+ );
1035
+ process.exitCode = 4;
1036
+ return;
1037
+ }
1038
+ cliError(
1039
+ msg,
1040
+ 1,
1041
+ { name: "E_IMPACT_FAILED" },
1042
+ { operation: "nexus.impact", duration_ms: durationMs }
1043
+ );
1044
+ process.exitCode = 1;
1045
+ }
1046
+ }
1047
+ });
1048
+ var analyzeCommand = defineCommand({
1049
+ meta: {
1050
+ name: "analyze",
1051
+ description: "Run code intelligence pipeline on a repository directory"
1052
+ },
1053
+ args: {
1054
+ path: {
1055
+ type: "positional",
1056
+ description: "Path to repository directory (default: cwd)",
1057
+ required: false
1058
+ },
1059
+ json: {
1060
+ type: "boolean",
1061
+ description: "Output result as JSON (LAFS envelope format)"
1062
+ },
1063
+ "project-id": {
1064
+ type: "string",
1065
+ description: "Override the project ID (default: auto-detected)"
1066
+ },
1067
+ "include-repositories": {
1068
+ type: "string",
1069
+ description: "Comma-separated relative nested repository/worktree paths explicitly included in this project index"
1070
+ },
1071
+ full: {
1072
+ type: "boolean",
1073
+ description: "Parse every file instead of reusing unchanged files (default: incremental, falling back to full with a stated reason). Also re-binds a moved project's graph (same project id, old recorded root) to the live root"
1074
+ },
1075
+ incremental: {
1076
+ type: "boolean",
1077
+ description: "Deprecated no-op: incremental analysis is now the default (use --full to rebuild)"
1078
+ },
1079
+ "drop-missing-repositories": {
1080
+ type: "boolean",
1081
+ description: "Drop included repositories that are missing on disk instead of refusing (the default keeps the previous graph). Dropped paths are reported with a one-command restore"
1082
+ }
1083
+ },
1084
+ async run({ args }) {
1085
+ applyJsonFlag(args.json);
1086
+ const startTime = Date.now();
1087
+ const projectIdOverride = args["project-id"];
1088
+ const full = !!args.full;
1089
+ const ctx = getFormatContext();
1090
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
1091
+ if (args.incremental)
1092
+ humanWarn(
1093
+ "[nexus] --incremental is deprecated and has no effect: incremental is the default."
1094
+ );
1095
+ humanInfo(`[nexus] Analyzing: ${repoPath}${full ? " (full rebuild)" : ""}`);
1096
+ humanInfo("[nexus] Staging replacement graph; current index remains available...");
1097
+ try {
1098
+ const result = await runNexusAnalysis({
1099
+ repoPath,
1100
+ projectIdOverride,
1101
+ full,
1102
+ dropMissingRepositories: args["drop-missing-repositories"] === true,
1103
+ includedRepositories: args["include-repositories"]?.split(",").map((entry) => entry.trim()).filter(Boolean),
1104
+ onProgress: ctx.format === "json" ? void 0 : (current, total, filePath) => {
1105
+ if (current % 50 === 0 || current === total) {
1106
+ const pct = total > 0 ? Math.round(current / total * 100) : 100;
1107
+ humanInfo(`[nexus] Progress: ${current}/${total} files (${pct}%) \u2014 ${filePath}`);
1108
+ }
1109
+ }
1110
+ });
1111
+ humanInfo(`[nexus] nexus-bridge.md refreshed at ${repoPath}/.cleo/nexus-bridge.md`);
1112
+ humanInfo("[nexus] Project registered/updated in multi-project registry.");
1113
+ if (result.droppedRepositories)
1114
+ humanWarn(
1115
+ `[nexus] DROPPED missing included repositories: ${result.droppedRepositories.paths.join(", ")}. Restore them once they exist again: ${result.droppedRepositories.restoreCommand}`
1116
+ );
1117
+ if (result.rebind)
1118
+ humanInfo(
1119
+ `[nexus] Re-bound graph for ${result.rebind.projectId}: ${result.rebind.oldRoot} -> ${result.rebind.newRoot}`
1120
+ );
1121
+ humanInfo(
1122
+ `[nexus] Mode: ${result.summary.mode} \u2014 ${result.summary.reason} (parsed ${result.summary.parsedFiles}, reused ${result.summary.reusedFiles})`
1123
+ );
1124
+ cliOutput(
1125
+ {
1126
+ projectId: result.projectId,
1127
+ repoPath,
1128
+ incremental: result.incremental,
1129
+ mode: result.summary.mode,
1130
+ reason: result.summary.reason,
1131
+ summary: result.summary,
1132
+ nodeCount: result.nodeCount,
1133
+ relationCount: result.relationCount,
1134
+ fileCount: result.fileCount,
1135
+ durationMs: result.durationMs,
1136
+ assessment: result.assessment,
1137
+ // T12659: receipt of a moved project's graph re-bound to the live root.
1138
+ ...result.rebind ? { rebind: result.rebind } : {},
1139
+ ...result.droppedRepositories ? { droppedRepositories: result.droppedRepositories } : {}
1140
+ },
1141
+ {
1142
+ command: "nexus-analyze",
1143
+ operation: "nexus.analyze",
1144
+ extensions: { duration_ms: result.durationMs }
1145
+ }
1146
+ );
1147
+ } catch (err) {
1148
+ const msg = err instanceof Error ? err.message : String(err);
1149
+ cliError(
1150
+ msg,
1151
+ 1,
1152
+ { name: "E_PIPELINE_FAILED" },
1153
+ { operation: "nexus.analyze", duration_ms: Date.now() - startTime }
1154
+ );
1155
+ process.exitCode = 1;
1156
+ }
1157
+ }
1158
+ });
1159
+ var projectsListCommand = defineCommand({
1160
+ meta: {
1161
+ name: "list",
1162
+ description: "List all projects registered in the global nexus registry"
1163
+ },
1164
+ args: {
1165
+ json: {
1166
+ type: "boolean",
1167
+ description: "Output as JSON (LAFS envelope format)"
1168
+ }
1169
+ },
1170
+ async run({ args }) {
1171
+ applyJsonFlag(args.json);
1172
+ const startTime = Date.now();
1173
+ const response = await dispatchRaw("query", "nexus", "projects.list", {});
1174
+ const durationMs = Date.now() - startTime;
1175
+ if (!response.success) {
1176
+ const msg = response.error?.message ?? "Unknown error";
1177
+ cliError(
1178
+ msg,
1179
+ 1,
1180
+ {
1181
+ name: response.error?.code ?? "E_PROJECTS_LIST_FAILED",
1182
+ details: response.error?.details
1183
+ },
1184
+ { operation: "nexus.projects.list", duration_ms: durationMs }
1185
+ );
1186
+ process.exitCode = 1;
1187
+ return;
1188
+ }
1189
+ cliOutput(response.data, {
1190
+ command: "nexus-projects-list",
1191
+ operation: "nexus.projects.list",
1192
+ extensions: { duration_ms: durationMs },
1193
+ responseMeta: response.meta
1194
+ });
1195
+ }
1196
+ });
1197
+ var projectsRegisterCommand = defineCommand({
1198
+ meta: {
1199
+ name: "register",
1200
+ description: "Register a project in the global nexus registry (default: current directory)"
1201
+ },
1202
+ args: {
1203
+ path: {
1204
+ type: "positional",
1205
+ description: "Path to the project directory (default: cwd)",
1206
+ required: false
1207
+ },
1208
+ name: {
1209
+ type: "string",
1210
+ description: "Custom project name (default: directory name)"
1211
+ },
1212
+ json: {
1213
+ type: "boolean",
1214
+ description: "Output as JSON (LAFS envelope format)"
1215
+ }
1216
+ },
1217
+ async run({ args }) {
1218
+ applyJsonFlag(args.json);
1219
+ const startTime = Date.now();
1220
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
1221
+ const name = args.name;
1222
+ const response = await dispatchRaw("mutate", "nexus", "projects.register", {
1223
+ path: repoPath,
1224
+ name
1225
+ });
1226
+ const durationMs = Date.now() - startTime;
1227
+ if (!response.success) {
1228
+ const msg = response.error?.message ?? "Unknown error";
1229
+ cliError(
1230
+ msg,
1231
+ 1,
1232
+ { name: response.error?.code ?? "E_REGISTER_FAILED", details: response.error?.details },
1233
+ { operation: "nexus.projects.register", duration_ms: durationMs }
1234
+ );
1235
+ process.exitCode = 1;
1236
+ return;
1237
+ }
1238
+ cliOutput(response.data, {
1239
+ command: "nexus-projects-register",
1240
+ operation: "nexus.projects.register",
1241
+ extensions: { duration_ms: durationMs },
1242
+ responseMeta: response.meta
1243
+ });
1244
+ }
1245
+ });
1246
+ var projectsRemoveCommand = defineCommand({
1247
+ meta: {
1248
+ name: "remove",
1249
+ description: "Remove a project from the global nexus registry"
1250
+ },
1251
+ args: {
1252
+ nameOrHash: {
1253
+ type: "positional",
1254
+ description: "Project name or hash to remove",
1255
+ required: true
1256
+ },
1257
+ json: {
1258
+ type: "boolean",
1259
+ description: "Output as JSON (LAFS envelope format)"
1260
+ }
1261
+ },
1262
+ async run({ args }) {
1263
+ applyJsonFlag(args.json);
1264
+ const startTime = Date.now();
1265
+ const response = await dispatchRaw("mutate", "nexus", "projects.remove", {
1266
+ nameOrHash: args.nameOrHash
1267
+ });
1268
+ const durationMs = Date.now() - startTime;
1269
+ if (!response.success) {
1270
+ const msg = response.error?.message ?? "Unknown error";
1271
+ cliError(
1272
+ msg,
1273
+ 1,
1274
+ { name: response.error?.code ?? "E_REMOVE_FAILED", details: response.error?.details },
1275
+ { operation: "nexus.projects.remove", duration_ms: durationMs }
1276
+ );
1277
+ process.exitCode = 1;
1278
+ return;
1279
+ }
1280
+ cliOutput(
1281
+ { ...response.data ?? {}, nameOrHash: args.nameOrHash },
1282
+ {
1283
+ command: "nexus-projects-remove",
1284
+ operation: "nexus.projects.remove",
1285
+ extensions: { duration_ms: durationMs },
1286
+ responseMeta: response.meta
1287
+ }
1288
+ );
1289
+ }
1290
+ });
1291
+ var projectsScanCommand = defineCommand({
1292
+ meta: {
1293
+ name: "scan",
1294
+ description: "Walk filesystem roots to discover .cleo/ directories not registered in the global nexus registry"
1295
+ },
1296
+ args: {
1297
+ roots: {
1298
+ type: "string",
1299
+ description: "Comma-separated search roots (default: parent directories of registered projects; ~/code,~/projects when none)"
1300
+ },
1301
+ "max-depth": {
1302
+ type: "string",
1303
+ description: "Maximum directory traversal depth (default: 4)",
1304
+ default: "4"
1305
+ },
1306
+ "auto-register": {
1307
+ type: "boolean",
1308
+ description: "Register all discovered unregistered projects automatically"
1309
+ },
1310
+ "include-existing": {
1311
+ type: "boolean",
1312
+ description: "Also report projects that are already registered"
1313
+ },
1314
+ json: { type: "boolean", description: "Output as JSON (LAFS envelope format)" }
1315
+ },
1316
+ async run({ args }) {
1317
+ applyJsonFlag(args.json);
1318
+ const startTime = Date.now();
1319
+ const autoRegister = !!args["auto-register"];
1320
+ const includeExisting = !!args["include-existing"];
1321
+ const maxDepth = Math.max(1, Math.min(parseInt(args["max-depth"], 10), 20));
1322
+ humanInfo(`[nexus] Scanning up to depth ${maxDepth} for .cleo/ project roots...`);
1323
+ const response = await dispatchRaw("mutate", "nexus", "projects.scan", {
1324
+ roots: args.roots,
1325
+ maxDepth,
1326
+ autoRegister,
1327
+ includeExisting
1328
+ });
1329
+ const durationMs = Date.now() - startTime;
1330
+ if (!response.success) {
1331
+ const msg = response.error?.message ?? "Unknown error";
1332
+ cliError(
1333
+ msg,
1334
+ 1,
1335
+ {
1336
+ name: response.error?.code ?? "E_PROJECTS_SCAN_FAILED",
1337
+ details: response.error?.details
1338
+ },
1339
+ { operation: "nexus.projects.scan", duration_ms: durationMs }
1340
+ );
1341
+ process.exitCode = 1;
1342
+ return;
1343
+ }
1344
+ cliOutput(
1345
+ {
1346
+ ...response.data ?? {},
1347
+ _maxDepth: maxDepth,
1348
+ _autoRegister: autoRegister,
1349
+ _includeExisting: includeExisting
1350
+ },
1351
+ {
1352
+ command: "nexus-projects-scan",
1353
+ operation: "nexus.projects.scan",
1354
+ extensions: { duration_ms: durationMs },
1355
+ responseMeta: response.meta
1356
+ }
1357
+ );
1358
+ }
1359
+ });
1360
+ var projectsCleanCommand = defineCommand({
1361
+ meta: {
1362
+ name: "clean",
1363
+ description: "Bulk purge project_registry rows matching path criteria (requires at least one filter flag)"
1364
+ },
1365
+ args: {
1366
+ "dry-run": {
1367
+ type: "boolean",
1368
+ description: "List matching projects without deleting anything"
1369
+ },
1370
+ pattern: {
1371
+ type: "string",
1372
+ description: "JS regex matched against project_path"
1373
+ },
1374
+ "include-temp": {
1375
+ type: "boolean",
1376
+ description: "Preset: match paths containing a .temp/ segment or under the OS temp directory"
1377
+ },
1378
+ "include-tests": {
1379
+ type: "boolean",
1380
+ description: "Preset: match paths containing tmp/test(s)/__tests__/fixture(s)/scratch/sandbox segments"
1381
+ },
1382
+ unhealthy: {
1383
+ type: "boolean",
1384
+ description: 'Also match rows where health_status is "unhealthy"'
1385
+ },
1386
+ "never-indexed": {
1387
+ type: "boolean",
1388
+ description: "Also match rows where last_indexed IS NULL"
1389
+ },
1390
+ orphans: {
1391
+ type: "boolean",
1392
+ description: "Also match rows whose project_path no longer exists on disk (T9117)"
1393
+ },
1394
+ "rm-fs": {
1395
+ type: "boolean",
1396
+ description: "After DB delete, rm -rf each matched on-disk directory (T9117). Implies --yes when combined with --orphans for fully unattended runs is still gated by confirmation."
1397
+ },
1398
+ vacuum: {
1399
+ type: "boolean",
1400
+ description: "After delete, VACUUM the global registry store (<cleoHome>/cleo.db) to reclaim space"
1401
+ },
1402
+ yes: {
1403
+ type: "boolean",
1404
+ description: "Skip confirmation prompt (still shows preview)"
1405
+ },
1406
+ json: {
1407
+ type: "boolean",
1408
+ description: "Output as JSON (LAFS envelope format)"
1409
+ }
1410
+ },
1411
+ async run({ args }) {
1412
+ applyJsonFlag(args.json);
1413
+ const startTime = Date.now();
1414
+ const dryRun = !!args["dry-run"];
1415
+ const skipPrompt = !!args.yes;
1416
+ const ctx = getFormatContext();
1417
+ const cleanOpts = {
1418
+ pattern: args.pattern,
1419
+ includeTemp: !!args["include-temp"],
1420
+ includeTests: !!args["include-tests"],
1421
+ matchUnhealthy: !!args.unhealthy,
1422
+ matchNeverIndexed: !!args["never-indexed"],
1423
+ matchOrphaned: !!args.orphans,
1424
+ removeFs: !!args["rm-fs"],
1425
+ vacuum: !!args.vacuum
1426
+ };
1427
+ try {
1428
+ const previewResp = await dispatchRaw("mutate", "nexus", "projects.clean", {
1429
+ ...cleanOpts,
1430
+ dryRun: true
1431
+ });
1432
+ if (!previewResp.success) {
1433
+ const code = previewResp.error?.code ?? "E_CLEAN_FAILED";
1434
+ const msg = previewResp.error?.message ?? "Unknown error";
1435
+ const exitCode = code === "E_NO_CRITERIA" || code === "E_INVALID_PATTERN" ? 6 : 1;
1436
+ cliError(
1437
+ msg,
1438
+ exitCode,
1439
+ { name: code },
1440
+ { operation: "nexus.projects.clean", duration_ms: Date.now() - startTime }
1441
+ );
1442
+ process.exitCode = exitCode;
1443
+ return;
1444
+ }
1445
+ const preview = previewResp.data;
1446
+ const {
1447
+ matched: matchCount,
1448
+ totalCount,
1449
+ sample: samplePaths,
1450
+ classification,
1451
+ matchedByReason
1452
+ } = preview;
1453
+ if (ctx.format !== "json") {
1454
+ cliOutput(
1455
+ {
1456
+ matched: matchCount,
1457
+ totalCount,
1458
+ sample: samplePaths,
1459
+ classification,
1460
+ ...preview.relocated ? { relocated: preview.relocated } : {},
1461
+ ...preview.unreadable ? { unreadable: preview.unreadable } : {},
1462
+ ...preview.idMismatch ? { idMismatch: preview.idMismatch } : {}
1463
+ },
1464
+ {
1465
+ command: "nexus-projects-clean-preview",
1466
+ operation: "nexus.projects.clean",
1467
+ responseMeta: previewResp.meta
1468
+ }
1469
+ );
1470
+ }
1471
+ if (matchCount === 0 || dryRun) {
1472
+ const durationMs2 = Date.now() - startTime;
1473
+ cliOutput(
1474
+ {
1475
+ dryRun: true,
1476
+ matched: matchCount,
1477
+ purged: 0,
1478
+ remaining: totalCount,
1479
+ sample: samplePaths,
1480
+ classification,
1481
+ matchedByReason,
1482
+ ...preview.relocated ? { relocated: preview.relocated } : {},
1483
+ ...preview.unreadable ? { unreadable: preview.unreadable } : {},
1484
+ ...preview.idMismatch ? { idMismatch: preview.idMismatch } : {}
1485
+ },
1486
+ {
1487
+ command: "nexus-projects-clean",
1488
+ operation: "nexus.projects.clean",
1489
+ extensions: { duration_ms: durationMs2 },
1490
+ responseMeta: previewResp.meta
1491
+ }
1492
+ );
1493
+ return;
1494
+ }
1495
+ if (!skipPrompt) {
1496
+ const { createInterface } = await import("node:readline");
1497
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
1498
+ const confirmed = await new Promise((resolve) => {
1499
+ rl.question(
1500
+ `
1501
+ [nexus] Delete ${matchCount} project(s) from the registry? [y/N] `,
1502
+ (answer) => {
1503
+ rl.close();
1504
+ resolve(answer.trim().toLowerCase() === "y");
1505
+ }
1506
+ );
1507
+ });
1508
+ if (!confirmed) {
1509
+ cliOutput(
1510
+ { aborted: true, message: "No projects deleted." },
1511
+ { command: "nexus-projects-clean", operation: "nexus.projects.clean" }
1512
+ );
1513
+ return;
1514
+ }
1515
+ }
1516
+ const deleteResp = await dispatchRaw("mutate", "nexus", "projects.clean", {
1517
+ ...cleanOpts,
1518
+ dryRun: false
1519
+ });
1520
+ const durationMs = Date.now() - startTime;
1521
+ if (!deleteResp.success) {
1522
+ const code = deleteResp.error?.code ?? "E_CLEAN_FAILED";
1523
+ const msg = deleteResp.error?.message ?? "Unknown error";
1524
+ const exitCode = code === "E_NO_CRITERIA" || code === "E_INVALID_PATTERN" ? 6 : 1;
1525
+ cliError(
1526
+ msg,
1527
+ exitCode,
1528
+ { name: code },
1529
+ { operation: "nexus.projects.clean", duration_ms: durationMs }
1530
+ );
1531
+ process.exitCode = exitCode;
1532
+ return;
1533
+ }
1534
+ const result = deleteResp.data;
1535
+ cliOutput(
1536
+ {
1537
+ dryRun: false,
1538
+ matched: result.matched,
1539
+ purged: result.purged,
1540
+ remaining: result.remaining,
1541
+ sample: result.sample,
1542
+ fsRemoved: result.fsRemoved,
1543
+ fsFailed: result.fsFailed,
1544
+ vacuumBytesFreed: result.vacuumBytesFreed,
1545
+ classification: result.classification,
1546
+ matchedByReason: result.matchedByReason,
1547
+ receipt: result.receipt,
1548
+ ...result.relocated ? { relocated: result.relocated } : {},
1549
+ ...result.unreadable ? { unreadable: result.unreadable } : {},
1550
+ ...result.idMismatch ? { idMismatch: result.idMismatch } : {}
1551
+ },
1552
+ {
1553
+ command: "nexus-projects-clean",
1554
+ operation: "nexus.projects.clean",
1555
+ extensions: { duration_ms: durationMs },
1556
+ responseMeta: deleteResp.meta
1557
+ }
1558
+ );
1559
+ } catch (err) {
1560
+ const durationMs = Date.now() - startTime;
1561
+ const msg = err instanceof Error ? err.message : String(err);
1562
+ cliError(
1563
+ msg,
1564
+ 1,
1565
+ { name: "E_CLEAN_FAILED" },
1566
+ { operation: "nexus.projects.clean", duration_ms: durationMs }
1567
+ );
1568
+ process.exitCode = 1;
1569
+ }
1570
+ }
1571
+ });
1572
+ function intFlag(value, min) {
1573
+ if (value === void 0 || value === "") return void 0;
1574
+ const n = Number(value);
1575
+ return Number.isInteger(n) && n >= min ? n : null;
1576
+ }
1577
+ var projectsStatusCommand = defineCommand({
1578
+ meta: {
1579
+ name: "status",
1580
+ description: "Fleet view: every project, its location on each device, and its last recorded git state (branch, head, dirty, ahead/behind as of the last fetch) with staleness; paged, counts first. Reads recorded probes; --refresh re-probes this device (bounded), --fetch also fetches"
1581
+ },
1582
+ args: {
1583
+ refresh: {
1584
+ type: "boolean",
1585
+ description: "Re-probe this device first (bounded concurrency, per-repo timeout; no network)"
1586
+ },
1587
+ fetch: {
1588
+ type: "boolean",
1589
+ description: "Re-probe this device with git fetch per location first (network; implies --refresh)"
1590
+ },
1591
+ device: {
1592
+ type: "string",
1593
+ description: "Only locations on this device (device id, hostname, or current)"
1594
+ },
1595
+ missing: { type: "boolean", description: "Only projects with a missing location" },
1596
+ dirty: { type: "boolean", description: "Only projects with uncommitted or untracked changes" },
1597
+ behind: {
1598
+ type: "boolean",
1599
+ description: "Only projects behind their upstream (as of last fetch)"
1600
+ },
1601
+ ahead: {
1602
+ type: "boolean",
1603
+ description: "Only projects ahead of their upstream (as of last fetch)"
1604
+ },
1605
+ stale: {
1606
+ type: "boolean",
1607
+ description: "Only projects never probed, or probed/fetched longer ago than --stale-after-ms"
1608
+ },
1609
+ errored: { type: "boolean", description: "Only projects whose last probe recorded an error" },
1610
+ limit: { type: "string", description: "Projects per page (default 50, max 500; 0 = all)" },
1611
+ offset: { type: "string", description: "Projects skipped before the page (default 0)" },
1612
+ concurrency: {
1613
+ type: "string",
1614
+ description: "With --refresh: locations probed at once (default 8, max 64)"
1615
+ },
1616
+ "timeout-ms": {
1617
+ type: "string",
1618
+ description: "With --refresh: per-location git budget in ms (default 10000; 30000 with --fetch)"
1619
+ },
1620
+ "stale-after-ms": {
1621
+ type: "string",
1622
+ description: "Staleness window for probes, fetches and heartbeats (default 86400000)"
1623
+ },
1624
+ json: { type: "boolean", description: "Output as JSON (LAFS envelope format)" }
1625
+ },
1626
+ async run({ args }) {
1627
+ applyJsonFlag(args.json);
1628
+ const startTime = Date.now();
1629
+ const concurrency = intFlag(args.concurrency, 1);
1630
+ const timeoutMs = intFlag(args["timeout-ms"], 1);
1631
+ const staleAfterMs = intFlag(args["stale-after-ms"], 1);
1632
+ const limit = intFlag(args.limit, 0);
1633
+ const offset = intFlag(args.offset, 0);
1634
+ if ([concurrency, timeoutMs, staleAfterMs, limit, offset].includes(null)) {
1635
+ cliError(
1636
+ "--concurrency, --timeout-ms and --stale-after-ms take positive integers; --limit and --offset take integers >= 0",
1637
+ 6,
1638
+ { name: "E_VALIDATION" },
1639
+ { operation: "nexus.projects.fleet", duration_ms: 0 }
1640
+ );
1641
+ process.exitCode = 6;
1642
+ return;
1643
+ }
1644
+ const fetch = args.fetch === true;
1645
+ let refresh;
1646
+ if (fetch || args.refresh === true) {
1647
+ const probe = await dispatchRaw("mutate", "nexus", "projects.status", {
1648
+ fetch,
1649
+ concurrency: concurrency ?? void 0,
1650
+ timeoutMs: timeoutMs ?? void 0,
1651
+ staleAfterMs: staleAfterMs ?? void 0
1652
+ });
1653
+ if (!probe.success) {
1654
+ const probeExit = probe.error?.exitCode ?? 1;
1655
+ cliError(
1656
+ probe.error?.message ?? "Unknown error",
1657
+ probeExit,
1658
+ { name: probe.error?.code ?? "E_PROJECTS_STATUS_FAILED", details: probe.error?.details },
1659
+ { operation: "nexus.projects.status", duration_ms: Date.now() - startTime }
1660
+ );
1661
+ process.exitCode = probeExit;
1662
+ return;
1663
+ }
1664
+ const probed = probe.data;
1665
+ refresh = {
1666
+ deviceId: probed.deviceId,
1667
+ count: probed.count,
1668
+ fetched: probed.fetched,
1669
+ durationMs: probed.durationMs,
1670
+ summary: probed.summary
1671
+ };
1672
+ }
1673
+ const response = await dispatchRaw("query", "nexus", "projects.fleet", {
1674
+ device: typeof args.device === "string" ? args.device : void 0,
1675
+ missing: args.missing === true,
1676
+ dirty: args.dirty === true,
1677
+ behind: args.behind === true,
1678
+ ahead: args.ahead === true,
1679
+ stale: args.stale === true,
1680
+ errored: args.errored === true,
1681
+ staleAfterMs: staleAfterMs ?? void 0,
1682
+ limit: limit ?? void 0,
1683
+ offset: offset ?? void 0
1684
+ });
1685
+ const durationMs = Date.now() - startTime;
1686
+ if (!response.success) {
1687
+ const code = response.error?.code ?? "E_PROJECTS_FLEET_FAILED";
1688
+ const exitCode = response.error?.exitCode ?? 1;
1689
+ cliError(
1690
+ response.error?.message ?? "Unknown error",
1691
+ exitCode,
1692
+ { name: code, details: response.error?.details },
1693
+ { operation: "nexus.projects.fleet", duration_ms: durationMs }
1694
+ );
1695
+ process.exitCode = exitCode;
1696
+ return;
1697
+ }
1698
+ cliOutput(
1699
+ { ...response.data, ...refresh ? { refresh } : {} },
1700
+ {
1701
+ command: "nexus-projects-fleet",
1702
+ operation: "nexus.projects.fleet",
1703
+ extensions: { duration_ms: durationMs },
1704
+ responseMeta: response.meta
1705
+ }
1706
+ );
1707
+ }
1708
+ });
1709
+ var projectsCommand = defineCommand({
1710
+ meta: { name: "projects", description: "Multi-project registry management" },
1711
+ subCommands: {
1712
+ list: projectsListCommand,
1713
+ register: projectsRegisterCommand,
1714
+ remove: projectsRemoveCommand,
1715
+ scan: projectsScanCommand,
1716
+ clean: projectsCleanCommand,
1717
+ status: projectsStatusCommand
1718
+ }
1719
+ });
1720
+ var refreshBridgeCommand = defineCommand({
1721
+ meta: {
1722
+ name: "refresh-bridge",
1723
+ description: "Regenerate .cleo/nexus-bridge.md from the existing nexus.db index (does not re-index)"
1724
+ },
1725
+ args: {
1726
+ path: {
1727
+ type: "positional",
1728
+ description: "Path to project directory (default: cwd)",
1729
+ required: false
1730
+ },
1731
+ json: {
1732
+ type: "boolean",
1733
+ description: "Output result as JSON (LAFS envelope format)"
1734
+ },
1735
+ "project-id": {
1736
+ type: "string",
1737
+ description: "Override the project ID (default: auto-detected from path)"
1738
+ }
1739
+ },
1740
+ async run({ args }) {
1741
+ applyJsonFlag(args.json);
1742
+ const startTime = Date.now();
1743
+ const projectIdOverride = args["project-id"];
1744
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
1745
+ const projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
1746
+ const response = await dispatchRaw("mutate", "nexus", "refresh-bridge", {
1747
+ repoPath,
1748
+ projectId
1749
+ });
1750
+ const durationMs = Date.now() - startTime;
1751
+ if (!response.success) {
1752
+ const msg = response.error?.message ?? "Unknown error";
1753
+ cliError(
1754
+ msg,
1755
+ 1,
1756
+ { name: response.error?.code ?? "E_BRIDGE_FAILED", details: response.error?.details },
1757
+ { operation: "nexus.refresh-bridge", duration_ms: durationMs }
1758
+ );
1759
+ process.exitCode = 1;
1760
+ return;
1761
+ }
1762
+ cliOutput(response.data, {
1763
+ command: "nexus-refresh-bridge",
1764
+ operation: "nexus.refresh-bridge",
1765
+ extensions: { duration_ms: durationMs },
1766
+ responseMeta: response.meta
1767
+ });
1768
+ }
1769
+ });
1770
+ var exportCommand = defineCommand({
1771
+ meta: { name: "export", description: "Export nexus graph to GEXF (Gephi) or JSON format" },
1772
+ args: {
1773
+ format: {
1774
+ type: "string",
1775
+ description: "Output format: gexf, json",
1776
+ default: "gexf"
1777
+ },
1778
+ output: {
1779
+ type: "string",
1780
+ description: "Output file path (stdout if omitted)"
1781
+ },
1782
+ project: {
1783
+ type: "string",
1784
+ description: "Filter by project ID (exports all projects if omitted)"
1785
+ }
1786
+ },
1787
+ async run({ args }) {
1788
+ const startTime = Date.now();
1789
+ const format = args.format ?? "gexf";
1790
+ const outputFile = args.output;
1791
+ const projectFilter = args.project;
1792
+ try {
1793
+ const result = await exportNexusGraph({
1794
+ format,
1795
+ projectFilter
1796
+ });
1797
+ if (outputFile) {
1798
+ const { writeFileSync } = await import("node:fs");
1799
+ writeFileSync(outputFile, result.content, "utf-8");
1800
+ const durationMs = Date.now() - startTime;
1801
+ cliOutput(
1802
+ { outputFile, nodeCount: result.nodeCount, edgeCount: result.edgeCount },
1803
+ {
1804
+ command: "nexus-export",
1805
+ operation: "nexus.export",
1806
+ extensions: { duration_ms: durationMs }
1807
+ }
1808
+ );
1809
+ humanInfo(`[nexus] Export completed in ${durationMs}ms`);
1810
+ } else {
1811
+ process.stdout.write(result.content);
1812
+ if (!result.content.endsWith("\n")) process.stdout.write("\n");
1813
+ }
1814
+ } catch (err) {
1815
+ const msg = err instanceof Error ? err.message : String(err);
1816
+ if (msg.includes("Unknown format")) {
1817
+ cliError(msg, 1, { name: "E_INVALID_INPUT" }, { operation: "nexus.export" });
1818
+ } else {
1819
+ cliError(msg, 1, { name: "E_EXPORT_FAILED" }, { operation: "nexus.export" });
1820
+ }
1821
+ process.exitCode = 1;
1822
+ }
1823
+ }
1824
+ });
1825
+ var diffCommand = defineCommand({
1826
+ meta: {
1827
+ name: "diff",
1828
+ description: "Compare NEXUS index state between two git commits \u2014 shows new/removed relations and broken call chains"
1829
+ },
1830
+ args: {
1831
+ before: {
1832
+ type: "string",
1833
+ description: 'Git SHA or ref for the "before" snapshot (default: HEAD~1)'
1834
+ },
1835
+ after: {
1836
+ type: "string",
1837
+ description: 'Git SHA or ref for the "after" snapshot (default: HEAD)',
1838
+ default: "HEAD"
1839
+ },
1840
+ path: { type: "string", description: "Repository directory to analyze (default: cwd)" },
1841
+ json: { type: "boolean", description: "Output result as JSON (LAFS envelope format)" },
1842
+ "project-id": {
1843
+ type: "string",
1844
+ description: "Override the project ID (default: auto-detected from path)"
1845
+ }
1846
+ },
1847
+ async run({ args }) {
1848
+ applyJsonFlag(args.json);
1849
+ const startTime = Date.now();
1850
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
1851
+ const projectIdOverride = args["project-id"];
1852
+ const beforeRef = args.before ?? "HEAD~1";
1853
+ const afterRef = args.after ?? "HEAD";
1854
+ humanInfo(`[nexus] Diffing relations: ${beforeRef}..${afterRef} in ${repoPath}`);
1855
+ const response = await dispatchRaw("query", "nexus", "diff", {
1856
+ repoPath,
1857
+ beforeRef,
1858
+ afterRef,
1859
+ projectId: projectIdOverride
1860
+ });
1861
+ const durationMs = Date.now() - startTime;
1862
+ if (!response.success) {
1863
+ const msg = response.error?.message ?? "Unknown error";
1864
+ cliError(
1865
+ msg,
1866
+ 1,
1867
+ { name: response.error?.code ?? "E_DIFF_FAILED", details: response.error?.details },
1868
+ { operation: "nexus.diff", duration_ms: durationMs }
1869
+ );
1870
+ process.exitCode = 1;
1871
+ return;
1872
+ }
1873
+ cliOutput(response.data, {
1874
+ command: "nexus-diff",
1875
+ operation: "nexus.diff",
1876
+ extensions: { duration_ms: durationMs },
1877
+ responseMeta: response.meta
1878
+ });
1879
+ }
1880
+ });
1881
+ var queryCommand = defineCommand({
1882
+ meta: {
1883
+ name: "query",
1884
+ description: "Execute recursive CTE queries against nexus.db"
1885
+ },
1886
+ args: {
1887
+ cte: {
1888
+ type: "positional",
1889
+ description: "CTE SQL or template alias (callers-of, callees-of, co-changed, co-cited, path-between, community-members)",
1890
+ required: true
1891
+ },
1892
+ params: {
1893
+ type: "string",
1894
+ description: 'Comma-separated parameters (e.g., "sym-id-1,sym-id-2")'
1895
+ }
1896
+ },
1897
+ async run({ args }) {
1898
+ const cteOrAlias = args.cte;
1899
+ const paramsStr = args.params || "";
1900
+ const params = paramsStr.split(",").map((p) => p.trim()).filter(Boolean);
1901
+ const startTime = Date.now();
1902
+ const response = await dispatchRaw("query", "nexus", "query-cte", {
1903
+ cte: cteOrAlias,
1904
+ params
1905
+ });
1906
+ const durationMs = Date.now() - startTime;
1907
+ if (!response.success) {
1908
+ const code = response.error?.code;
1909
+ const msg = response.error?.message ?? "Unknown error";
1910
+ const exitCode = code === "E_INVALID_INPUT" ? 6 : 77;
1911
+ cliError(
1912
+ msg,
1913
+ exitCode,
1914
+ { name: code ?? "E_QUERY_FAILED" },
1915
+ { operation: "nexus.query-cte", duration_ms: durationMs }
1916
+ );
1917
+ process.exitCode = exitCode;
1918
+ return;
1919
+ }
1920
+ const result = response.data;
1921
+ if (!result.success) {
1922
+ cliError(
1923
+ result.error ?? "Unknown",
1924
+ 77,
1925
+ { name: "E_QUERY_FAILED" },
1926
+ { operation: "nexus.query-cte", duration_ms: durationMs }
1927
+ );
1928
+ process.exitCode = 77;
1929
+ return;
1930
+ }
1931
+ const { formatCteResultAsMarkdown } = await import("@cleocode/core/nexus/query-dsl.js");
1932
+ const markdown = formatCteResultAsMarkdown(result);
1933
+ cliOutput(
1934
+ { ...result, _markdown: markdown },
1935
+ {
1936
+ command: "nexus-query",
1937
+ operation: "nexus.query-cte",
1938
+ extensions: { duration_ms: durationMs },
1939
+ responseMeta: response.meta
1940
+ }
1941
+ );
1942
+ }
1943
+ });
1944
+ var routeMapCommand = defineCommand({
1945
+ meta: {
1946
+ name: "route-map",
1947
+ description: "Display all routes with their handlers and dependencies"
1948
+ },
1949
+ args: {
1950
+ path: {
1951
+ type: "positional",
1952
+ description: "Path to project directory (default: cwd)",
1953
+ required: false
1954
+ },
1955
+ json: {
1956
+ type: "boolean",
1957
+ description: "Output result as JSON (LAFS envelope format)"
1958
+ },
1959
+ "project-id": {
1960
+ type: "string",
1961
+ description: "Override the project ID (default: auto-detected from path)"
1962
+ }
1963
+ },
1964
+ async run({ args }) {
1965
+ applyJsonFlag(args.json);
1966
+ const startTime = Date.now();
1967
+ const projectIdOverride = args["project-id"];
1968
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
1969
+ const projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
1970
+ const response = await dispatchRaw("query", "nexus", "route-map", { projectId });
1971
+ const durationMs = Date.now() - startTime;
1972
+ if (!response.success) {
1973
+ const msg = response.error?.message ?? "Unknown error";
1974
+ cliError(
1975
+ msg,
1976
+ 1,
1977
+ { name: response.error?.code ?? "E_ROUTE_MAP_FAILED", details: response.error?.details },
1978
+ { operation: "nexus.route-map", duration_ms: durationMs }
1979
+ );
1980
+ process.exitCode = 1;
1981
+ return;
1982
+ }
1983
+ cliOutput(
1984
+ { ...response.data ?? {}, _projectId: projectId },
1985
+ {
1986
+ command: "nexus-route-map",
1987
+ operation: "nexus.route-map",
1988
+ extensions: { duration_ms: durationMs },
1989
+ responseMeta: response.meta
1990
+ }
1991
+ );
1992
+ }
1993
+ });
1994
+ var shapeCheckCommand = defineCommand({
1995
+ meta: {
1996
+ name: "shape-check",
1997
+ description: "Check response shape compatibility for a route handler"
1998
+ },
1999
+ args: {
2000
+ routeSymbol: {
2001
+ type: "positional",
2002
+ description: "Route symbol ID (format: <filePath>::<routeName>)",
2003
+ required: true
2004
+ },
2005
+ path: {
2006
+ type: "positional",
2007
+ description: "Path to project directory (default: cwd)",
2008
+ required: false
2009
+ },
2010
+ json: {
2011
+ type: "boolean",
2012
+ description: "Output result as JSON (LAFS envelope format)"
2013
+ },
2014
+ "project-id": {
2015
+ type: "string",
2016
+ description: "Override the project ID (default: auto-detected from path)"
2017
+ }
2018
+ },
2019
+ async run({ args }) {
2020
+ applyJsonFlag(args.json);
2021
+ const startTime = Date.now();
2022
+ const routeSymbol = args.routeSymbol;
2023
+ const projectIdOverride = args["project-id"];
2024
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
2025
+ const projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
2026
+ const response = await dispatchRaw("query", "nexus", "shape-check", { routeSymbol, projectId });
2027
+ const durationMs = Date.now() - startTime;
2028
+ if (!response.success) {
2029
+ const msg = response.error?.message ?? "Unknown error";
2030
+ cliError(
2031
+ msg,
2032
+ 1,
2033
+ { name: response.error?.code ?? "E_SHAPE_CHECK_FAILED", details: response.error?.details },
2034
+ { operation: "nexus.shape-check", duration_ms: durationMs }
2035
+ );
2036
+ process.exitCode = 1;
2037
+ return;
2038
+ }
2039
+ cliOutput(
2040
+ { ...response.data ?? {}, _routeSymbol: routeSymbol },
2041
+ {
2042
+ command: "nexus-shape-check",
2043
+ operation: "nexus.shape-check",
2044
+ extensions: { duration_ms: durationMs },
2045
+ responseMeta: response.meta
2046
+ }
2047
+ );
2048
+ }
2049
+ });
2050
+ var fullContextCommand = defineCommand({
2051
+ meta: {
2052
+ name: "full-context",
2053
+ description: "Show full Living Brain context for a symbol: NEXUS callers/callees, BRAIN memories, TASKS, sentient proposals, conduit threads"
2054
+ },
2055
+ args: {
2056
+ symbol: {
2057
+ type: "positional",
2058
+ description: "Symbol name or nexus node ID",
2059
+ required: true
2060
+ },
2061
+ json: {
2062
+ type: "boolean",
2063
+ description: "Output result as JSON (LAFS envelope format)"
2064
+ }
2065
+ },
2066
+ async run({ args }) {
2067
+ applyJsonFlag(args.json);
2068
+ const startTime = Date.now();
2069
+ const symbolId = args.symbol;
2070
+ const response = await dispatchRaw("query", "nexus", "full-context", { symbol: symbolId });
2071
+ if (!response.success) {
2072
+ cliError(
2073
+ response.error?.message ?? "Unknown error",
2074
+ 1,
2075
+ { name: response.error?.code ?? "E_FULL_CONTEXT_FAILED", details: response.error?.details },
2076
+ { operation: "nexus.full-context" }
2077
+ );
2078
+ process.exitCode = 1;
2079
+ return;
2080
+ }
2081
+ const durationMs = Date.now() - startTime;
2082
+ cliOutput(
2083
+ { ...response.data ?? {}, _durationMs: durationMs },
2084
+ {
2085
+ command: "nexus-full-context",
2086
+ operation: "nexus.full-context",
2087
+ extensions: { duration_ms: durationMs },
2088
+ responseMeta: response.meta
2089
+ }
2090
+ );
2091
+ }
2092
+ });
2093
+ var taskFootprintCommand = defineCommand({
2094
+ meta: {
2095
+ name: "task-footprint",
2096
+ description: "Show full code impact of a task: files, symbols, blast radius, brain observations, decisions, risk tier"
2097
+ },
2098
+ args: {
2099
+ taskId: {
2100
+ type: "positional",
2101
+ description: "Task ID (e.g., T001)",
2102
+ required: true
2103
+ },
2104
+ json: {
2105
+ type: "boolean",
2106
+ description: "Output result as JSON (LAFS envelope format)"
2107
+ }
2108
+ },
2109
+ async run({ args }) {
2110
+ applyJsonFlag(args.json);
2111
+ const startTime = Date.now();
2112
+ const taskId = args.taskId;
2113
+ const response = await dispatchRaw("query", "nexus", "task-footprint", { taskId });
2114
+ if (!response.success) {
2115
+ cliError(
2116
+ response.error?.message ?? "Unknown error",
2117
+ 1,
2118
+ {
2119
+ name: response.error?.code ?? "E_TASK_FOOTPRINT_FAILED",
2120
+ details: response.error?.details
2121
+ },
2122
+ { operation: "nexus.task-footprint" }
2123
+ );
2124
+ process.exitCode = 1;
2125
+ return;
2126
+ }
2127
+ const durationMs = Date.now() - startTime;
2128
+ cliOutput(
2129
+ { ...response.data ?? {}, _durationMs: durationMs },
2130
+ {
2131
+ command: "nexus-task-footprint",
2132
+ operation: "nexus.task-footprint",
2133
+ extensions: { duration_ms: durationMs },
2134
+ responseMeta: response.meta
2135
+ }
2136
+ );
2137
+ }
2138
+ });
2139
+ var brainAnchorsCommand = defineCommand({
2140
+ meta: {
2141
+ name: "brain-anchors",
2142
+ description: "Show code anchors for a brain memory entry: linked nexus nodes, tasks that touched them, plasticity signal"
2143
+ },
2144
+ args: {
2145
+ entryId: {
2146
+ type: "positional",
2147
+ description: "Brain entry node ID (e.g., observation:abc123)",
2148
+ required: true
2149
+ },
2150
+ json: {
2151
+ type: "boolean",
2152
+ description: "Output result as JSON (LAFS envelope format)"
2153
+ }
2154
+ },
2155
+ async run({ args }) {
2156
+ applyJsonFlag(args.json);
2157
+ const startTime = Date.now();
2158
+ const entryId = args.entryId;
2159
+ const response = await dispatchRaw("query", "nexus", "brain-anchors", { entryId });
2160
+ if (!response.success) {
2161
+ cliError(
2162
+ response.error?.message ?? "Unknown error",
2163
+ 1,
2164
+ {
2165
+ name: response.error?.code ?? "E_BRAIN_ANCHORS_FAILED",
2166
+ details: response.error?.details
2167
+ },
2168
+ { operation: "nexus.brain-anchors" }
2169
+ );
2170
+ process.exitCode = 1;
2171
+ return;
2172
+ }
2173
+ const durationMs = Date.now() - startTime;
2174
+ cliOutput(
2175
+ { ...response.data ?? {}, _durationMs: durationMs },
2176
+ {
2177
+ command: "nexus-brain-anchors",
2178
+ operation: "nexus.brain-anchors",
2179
+ extensions: { duration_ms: durationMs },
2180
+ responseMeta: response.meta
2181
+ }
2182
+ );
2183
+ }
2184
+ });
2185
+ var whyCommand = defineCommand({
2186
+ meta: {
2187
+ name: "why",
2188
+ description: "Trace why a code symbol is structured this way: walks BRAIN decisions, observations, and tasks via code_reference+documents+applies_to edges"
2189
+ },
2190
+ args: {
2191
+ symbol: {
2192
+ type: "positional",
2193
+ description: "Symbol name or nexus node ID to trace",
2194
+ required: true
2195
+ },
2196
+ json: {
2197
+ type: "boolean",
2198
+ description: "Output result as JSON (LAFS envelope format)"
2199
+ }
2200
+ },
2201
+ async run({ args }) {
2202
+ applyJsonFlag(args.json);
2203
+ const startTime = Date.now();
2204
+ const symbolId = args.symbol;
2205
+ const response = await dispatchRaw("query", "nexus", "why", { symbol: symbolId });
2206
+ if (!response.success) {
2207
+ cliError(
2208
+ response.error?.message ?? "Unknown error",
2209
+ 1,
2210
+ { name: response.error?.code ?? "E_WHY_FAILED", details: response.error?.details },
2211
+ { operation: "nexus.why" }
2212
+ );
2213
+ process.exitCode = 1;
2214
+ return;
2215
+ }
2216
+ const durationMs = Date.now() - startTime;
2217
+ cliOutput(
2218
+ { ...response.data ?? {}, _durationMs: durationMs },
2219
+ {
2220
+ command: "nexus-why",
2221
+ operation: "nexus.why",
2222
+ extensions: { duration_ms: durationMs },
2223
+ responseMeta: response.meta
2224
+ }
2225
+ );
2226
+ }
2227
+ });
2228
+ var impactFullCommand = defineCommand({
2229
+ meta: {
2230
+ name: "impact-full",
2231
+ description: "Full merged impact report for a code symbol: structural blast radius + open tasks + brain risk notes"
2232
+ },
2233
+ args: {
2234
+ symbol: {
2235
+ type: "positional",
2236
+ description: "Symbol name or nexus node ID to analyze",
2237
+ required: true
2238
+ },
2239
+ json: {
2240
+ type: "boolean",
2241
+ description: "Output result as JSON (LAFS envelope format)"
2242
+ }
2243
+ },
2244
+ async run({ args }) {
2245
+ applyJsonFlag(args.json);
2246
+ const startTime = Date.now();
2247
+ const symbolId = args.symbol;
2248
+ const response = await dispatchRaw("query", "nexus", "impact-full", { symbol: symbolId });
2249
+ if (!response.success) {
2250
+ cliError(
2251
+ response.error?.message ?? "Unknown error",
2252
+ 1,
2253
+ { name: response.error?.code ?? "E_IMPACT_FULL_FAILED", details: response.error?.details },
2254
+ { operation: "nexus.impact-full" }
2255
+ );
2256
+ process.exitCode = 1;
2257
+ return;
2258
+ }
2259
+ const durationMs = Date.now() - startTime;
2260
+ cliOutput(
2261
+ { ...response.data ?? {}, _durationMs: durationMs },
2262
+ {
2263
+ command: "nexus-impact-full",
2264
+ operation: "nexus.impact-full",
2265
+ extensions: { duration_ms: durationMs },
2266
+ responseMeta: response.meta
2267
+ }
2268
+ );
2269
+ }
2270
+ });
2271
+ var conduitScanCommand = defineCommand({
2272
+ meta: {
2273
+ name: "conduit-scan",
2274
+ description: "Scan conduit messages for symbol mentions and link them to nexus nodes (conduit_mentions_symbol edges)"
2275
+ },
2276
+ args: {
2277
+ json: {
2278
+ type: "boolean",
2279
+ description: "Output result as JSON (LAFS envelope format)"
2280
+ }
2281
+ },
2282
+ async run({ args }) {
2283
+ applyJsonFlag(args.json);
2284
+ const startTime = Date.now();
2285
+ const response = await dispatchRaw("mutate", "nexus", "conduit-scan", {});
2286
+ const durationMs = Date.now() - startTime;
2287
+ if (!response.success) {
2288
+ const msg = response.error?.message ?? "Unknown error";
2289
+ cliError(
2290
+ msg,
2291
+ 1,
2292
+ { name: response.error?.code ?? "E_CONDUIT_SCAN_FAILED", details: response.error?.details },
2293
+ { operation: "nexus.conduit-scan", duration_ms: durationMs }
2294
+ );
2295
+ process.exitCode = 1;
2296
+ return;
2297
+ }
2298
+ cliOutput(
2299
+ { ...response.data ?? {}, _durationMs: durationMs },
2300
+ {
2301
+ command: "nexus-conduit-scan",
2302
+ operation: "nexus.conduit-scan",
2303
+ extensions: { duration_ms: durationMs },
2304
+ responseMeta: response.meta
2305
+ }
2306
+ );
2307
+ }
2308
+ });
2309
+ var taskSymbolsCommand = defineCommand({
2310
+ meta: {
2311
+ name: "task-symbols",
2312
+ description: "Show code symbols touched by a task (task_touches_symbol forward-lookup)"
2313
+ },
2314
+ args: {
2315
+ taskId: {
2316
+ type: "positional",
2317
+ description: "Task ID (e.g., T001)",
2318
+ required: true
2319
+ },
2320
+ json: {
2321
+ type: "boolean",
2322
+ description: "Output result as JSON (LAFS envelope format)"
2323
+ }
2324
+ },
2325
+ async run({ args }) {
2326
+ applyJsonFlag(args.json);
2327
+ const startTime = Date.now();
2328
+ const taskId = args.taskId;
2329
+ const response = await dispatchRaw("query", "nexus", "task-symbols", { taskId });
2330
+ const durationMs = Date.now() - startTime;
2331
+ if (!response.success) {
2332
+ const msg = response.error?.message ?? "Unknown error";
2333
+ cliError(
2334
+ msg,
2335
+ 1,
2336
+ { name: response.error?.code ?? "E_TASK_SYMBOLS_FAILED", details: response.error?.details },
2337
+ { operation: "nexus.task-symbols", duration_ms: durationMs }
2338
+ );
2339
+ process.exitCode = 1;
2340
+ return;
2341
+ }
2342
+ const data = response.data;
2343
+ cliOutput(
2344
+ { ...data, taskId, count: data.symbols.length, _durationMs: durationMs },
2345
+ {
2346
+ command: "nexus-task-symbols",
2347
+ operation: "nexus.task-symbols",
2348
+ extensions: { duration_ms: durationMs },
2349
+ responseMeta: response.meta
2350
+ }
2351
+ );
2352
+ }
2353
+ });
2354
+ var searchCodeCommand = defineCommand({
2355
+ meta: {
2356
+ name: "search-code",
2357
+ description: "BM25 search of code symbols in nexus.db (augment BM25 index)"
2358
+ },
2359
+ args: {
2360
+ query: {
2361
+ type: "positional",
2362
+ description: "Search query (symbol name, file pattern, or keyword)",
2363
+ required: true
2364
+ },
2365
+ limit: {
2366
+ type: "string",
2367
+ description: "Max results (default: 10)",
2368
+ default: "10"
2369
+ },
2370
+ json: {
2371
+ type: "boolean",
2372
+ description: "Output result as JSON (LAFS envelope format)"
2373
+ }
2374
+ },
2375
+ async run({ args }) {
2376
+ applyJsonFlag(args.json);
2377
+ const startTime = Date.now();
2378
+ const query = args.query;
2379
+ const limit = parseInt(args.limit, 10) || 10;
2380
+ await dispatchFromCli(
2381
+ "query",
2382
+ "nexus",
2383
+ "augment",
2384
+ { pattern: query, limit },
2385
+ { command: "nexus" }
2386
+ );
2387
+ const durationMs = Date.now() - startTime;
2388
+ const ctx = getFormatContext();
2389
+ if (ctx.format !== "json") {
2390
+ cliOutput(
2391
+ { _durationMs: durationMs },
2392
+ { command: "nexus-search-code", operation: "nexus.search-code" }
2393
+ );
2394
+ }
2395
+ }
2396
+ });
2397
+ var contractsSyncCommand = defineCommand({
2398
+ meta: {
2399
+ name: "sync",
2400
+ description: "Extract contracts (HTTP/gRPC/topic) from the current project and store them"
2401
+ },
2402
+ args: {
2403
+ path: {
2404
+ type: "positional",
2405
+ description: "Path to project directory (default: cwd)",
2406
+ required: false
2407
+ },
2408
+ json: {
2409
+ type: "boolean",
2410
+ description: "Output result as JSON (LAFS envelope format)"
2411
+ },
2412
+ "project-id": {
2413
+ type: "string",
2414
+ description: "Override the project ID (default: auto-detected)"
2415
+ }
2416
+ },
2417
+ async run({ args }) {
2418
+ applyJsonFlag(args.json);
2419
+ const startTime = Date.now();
2420
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
2421
+ const projectIdOverride = args["project-id"];
2422
+ const projectId = await resolveNexusQueryProjectId(repoPath, projectIdOverride);
2423
+ const response = await dispatchRaw("mutate", "nexus", "contracts-sync", {
2424
+ projectId,
2425
+ repoPath
2426
+ });
2427
+ const durationMs = Date.now() - startTime;
2428
+ if (!response.success) {
2429
+ const msg = response.error?.message ?? "Unknown error";
2430
+ cliError(
2431
+ msg,
2432
+ 1,
2433
+ {
2434
+ name: response.error?.code ?? "E_CONTRACTS_SYNC_FAILED",
2435
+ details: response.error?.details
2436
+ },
2437
+ { operation: "nexus.contracts.sync", duration_ms: durationMs }
2438
+ );
2439
+ process.exitCode = 1;
2440
+ return;
2441
+ }
2442
+ cliOutput(
2443
+ { ...response.data ?? {}, _durationMs: durationMs },
2444
+ {
2445
+ command: "nexus-contracts-sync",
2446
+ operation: "nexus.contracts.sync",
2447
+ extensions: { duration_ms: durationMs },
2448
+ responseMeta: response.meta
2449
+ }
2450
+ );
2451
+ }
2452
+ });
2453
+ var contractsShowCommand = defineCommand({
2454
+ meta: {
2455
+ name: "show",
2456
+ description: "Show contract compatibility matrix between two registered projects"
2457
+ },
2458
+ args: {
2459
+ "project-a": {
2460
+ type: "string",
2461
+ description: "First project name or ID",
2462
+ required: true
2463
+ },
2464
+ "project-b": {
2465
+ type: "string",
2466
+ description: "Second project name or ID",
2467
+ required: true
2468
+ },
2469
+ json: {
2470
+ type: "boolean",
2471
+ description: "Output result as JSON (LAFS envelope format)"
2472
+ }
2473
+ },
2474
+ async run({ args }) {
2475
+ applyJsonFlag(args.json);
2476
+ const startTime = Date.now();
2477
+ const projectA = args["project-a"];
2478
+ const projectB = args["project-b"];
2479
+ const response = await dispatchRaw("query", "nexus", "contracts-show", { projectA, projectB });
2480
+ const durationMs = Date.now() - startTime;
2481
+ if (!response.success) {
2482
+ const msg = response.error?.message ?? "Unknown error";
2483
+ cliError(
2484
+ msg,
2485
+ 1,
2486
+ {
2487
+ name: response.error?.code ?? "E_CONTRACTS_SHOW_FAILED",
2488
+ details: response.error?.details
2489
+ },
2490
+ { operation: "nexus.contracts.show", duration_ms: durationMs }
2491
+ );
2492
+ process.exitCode = 1;
2493
+ return;
2494
+ }
2495
+ cliOutput(
2496
+ {
2497
+ ...response.data ?? {},
2498
+ _projectA: projectA,
2499
+ _projectB: projectB,
2500
+ _durationMs: durationMs
2501
+ },
2502
+ {
2503
+ command: "nexus-contracts-show",
2504
+ operation: "nexus.contracts.show",
2505
+ extensions: { duration_ms: durationMs },
2506
+ responseMeta: response.meta
2507
+ }
2508
+ );
2509
+ }
2510
+ });
2511
+ var contractsLinkTasksCommand = defineCommand({
2512
+ meta: {
2513
+ name: "link-tasks",
2514
+ description: "Link extracted contracts to tasks that touch their source symbols"
2515
+ },
2516
+ args: {
2517
+ path: {
2518
+ type: "positional",
2519
+ description: "Path to project directory (default: cwd)",
2520
+ required: false
2521
+ },
2522
+ json: {
2523
+ type: "boolean",
2524
+ description: "Output result as JSON (LAFS envelope format)"
2525
+ }
2526
+ },
2527
+ async run({ args }) {
2528
+ applyJsonFlag(args.json);
2529
+ const startTime = Date.now();
2530
+ const repoPath = args.path ? path.resolve(args.path) : getProjectRoot();
2531
+ const projectId = await resolveNexusQueryProjectId(repoPath);
2532
+ const response = await dispatchRaw("mutate", "nexus", "contracts-link-tasks", {
2533
+ projectId,
2534
+ repoPath
2535
+ });
2536
+ const durationMs = Date.now() - startTime;
2537
+ if (!response.success) {
2538
+ const msg = response.error?.message ?? "Unknown error";
2539
+ cliError(
2540
+ msg,
2541
+ 1,
2542
+ {
2543
+ name: response.error?.code ?? "E_CONTRACTS_LINK_FAILED",
2544
+ details: response.error?.details
2545
+ },
2546
+ { operation: "nexus.contracts.link-tasks", duration_ms: durationMs }
2547
+ );
2548
+ process.exitCode = 1;
2549
+ return;
2550
+ }
2551
+ cliOutput(
2552
+ { ...response.data ?? {}, _durationMs: durationMs },
2553
+ {
2554
+ command: "nexus-contracts-link-tasks",
2555
+ operation: "nexus.contracts.link-tasks",
2556
+ extensions: { duration_ms: durationMs },
2557
+ responseMeta: response.meta
2558
+ }
2559
+ );
2560
+ }
2561
+ });
2562
+ var contractsCommand = defineCommand({
2563
+ meta: { name: "contracts", description: "Contract extraction and compatibility operations" },
2564
+ subCommands: {
2565
+ sync: contractsSyncCommand,
2566
+ show: contractsShowCommand,
2567
+ "link-tasks": contractsLinkTasksCommand
2568
+ }
2569
+ });
2570
+ var groupCommand = defineCommand({
2571
+ meta: {
2572
+ name: "group",
2573
+ description: "Contract extraction and compatibility operations (alias for contracts)"
2574
+ },
2575
+ subCommands: {
2576
+ sync: contractsSyncCommand,
2577
+ show: contractsShowCommand,
2578
+ "link-tasks": contractsLinkTasksCommand
2579
+ }
2580
+ });
2581
+ var wikiCommand = defineCommand({
2582
+ meta: {
2583
+ name: "wiki",
2584
+ description: "Generate community-grouped wiki index from nexus code graph"
2585
+ },
2586
+ args: {
2587
+ output: {
2588
+ type: "string",
2589
+ description: "Output directory for wiki files (default: .cleo/wiki)",
2590
+ alias: "o"
2591
+ },
2592
+ community: {
2593
+ type: "string",
2594
+ description: 'Filter generation to a single community ID (e.g. "community:3")',
2595
+ alias: "c"
2596
+ },
2597
+ incremental: {
2598
+ type: "boolean",
2599
+ description: "Only regenerate communities whose symbols changed since last wiki run (uses .cleo/wiki-state.json)"
2600
+ },
2601
+ json: {
2602
+ type: "boolean",
2603
+ description: "Output result as JSON (LAFS envelope format)"
2604
+ }
2605
+ },
2606
+ async run({ args }) {
2607
+ applyJsonFlag(args.json);
2608
+ const startTime = Date.now();
2609
+ const outputDir = args.output ?? void 0;
2610
+ const communityFilter = args.community ?? void 0;
2611
+ const isIncremental = !!args.incremental;
2612
+ try {
2613
+ const result = await runNexusWiki({
2614
+ projectRoot: getProjectRoot(),
2615
+ outputDir,
2616
+ communityFilter,
2617
+ incremental: isIncremental
2618
+ });
2619
+ if (!result.success) {
2620
+ cliError(
2621
+ `wiki generation failed: ${result.error ?? "unknown"}`,
2622
+ 1,
2623
+ { name: "E_WIKI_GENERATION_FAILED" },
2624
+ { operation: "nexus.wiki" }
2625
+ );
2626
+ process.exitCode = 1;
2627
+ return;
2628
+ }
2629
+ cliOutput(
2630
+ { ...result, _outputDir: result.outputDir, _durationMs: result.durationMs },
2631
+ {
2632
+ command: "nexus-wiki",
2633
+ operation: "nexus.wiki",
2634
+ extensions: { duration_ms: result.durationMs }
2635
+ }
2636
+ );
2637
+ } catch (err) {
2638
+ const msg = err instanceof Error ? err.message : String(err);
2639
+ cliError(
2640
+ msg,
2641
+ 1,
2642
+ { name: "E_WIKI_GENERATION_FAILED" },
2643
+ { operation: "nexus.wiki", duration_ms: Date.now() - startTime }
2644
+ );
2645
+ process.exitCode = 1;
2646
+ }
2647
+ }
2648
+ });
2649
+ var hotPathsCommand = defineCommand({
2650
+ meta: {
2651
+ name: "hot-paths",
2652
+ description: "List highest-weight relation edges by Hebbian plasticity weight"
2653
+ },
2654
+ args: {
2655
+ limit: {
2656
+ type: "string",
2657
+ description: "Maximum number of edges to return (default: 20)",
2658
+ default: "20"
2659
+ },
2660
+ json: {
2661
+ type: "boolean",
2662
+ description: "Output raw JSON",
2663
+ default: false
2664
+ }
2665
+ },
2666
+ async run({ args }) {
2667
+ applyJsonFlag(args.json);
2668
+ const limit = Number.parseInt(args.limit, 10) || 20;
2669
+ const startTime = Date.now();
2670
+ const response = await dispatchRaw("query", "nexus", "hot-paths", { limit });
2671
+ const durationMs = Date.now() - startTime;
2672
+ if (!response.success) {
2673
+ cliError(
2674
+ response.error?.message ?? "Unknown error",
2675
+ 1,
2676
+ { name: response.error?.code ?? "E_HOT_PATHS_FAILED", details: response.error?.details },
2677
+ { operation: "nexus.hot-paths", duration_ms: durationMs }
2678
+ );
2679
+ process.exitCode = 1;
2680
+ return;
2681
+ }
2682
+ cliOutput(response.data, {
2683
+ command: "nexus-hot-paths",
2684
+ operation: "nexus.hot-paths",
2685
+ extensions: { duration_ms: durationMs },
2686
+ responseMeta: response.meta
2687
+ });
2688
+ }
2689
+ });
2690
+ var hotNodesCommand = defineCommand({
2691
+ meta: {
2692
+ name: "hot-nodes",
2693
+ description: "List symbols with highest aggregate Hebbian weight"
2694
+ },
2695
+ args: {
2696
+ limit: {
2697
+ type: "string",
2698
+ description: "Maximum number of nodes to return (default: 20)",
2699
+ default: "20"
2700
+ },
2701
+ json: {
2702
+ type: "boolean",
2703
+ description: "Output raw JSON",
2704
+ default: false
2705
+ }
2706
+ },
2707
+ async run({ args }) {
2708
+ applyJsonFlag(args.json);
2709
+ const limit = Number.parseInt(args.limit, 10) || 20;
2710
+ const startTime = Date.now();
2711
+ const response = await dispatchRaw("query", "nexus", "hot-nodes", { limit });
2712
+ const durationMs = Date.now() - startTime;
2713
+ if (!response.success) {
2714
+ cliError(
2715
+ response.error?.message ?? "Unknown error",
2716
+ 1,
2717
+ { name: response.error?.code ?? "E_HOT_NODES_FAILED", details: response.error?.details },
2718
+ { operation: "nexus.hot-nodes", duration_ms: durationMs }
2719
+ );
2720
+ process.exitCode = 1;
2721
+ return;
2722
+ }
2723
+ cliOutput(response.data, {
2724
+ command: "nexus-hot-nodes",
2725
+ operation: "nexus.hot-nodes",
2726
+ extensions: { duration_ms: durationMs },
2727
+ responseMeta: response.meta
2728
+ });
2729
+ }
2730
+ });
2731
+ var coldSymbolsCommand = defineCommand({
2732
+ meta: {
2733
+ name: "cold-symbols",
2734
+ description: "List cold symbols (stale access + low weight) for pruning candidates"
2735
+ },
2736
+ args: {
2737
+ days: {
2738
+ type: "string",
2739
+ description: "Age threshold in days (default: 30)",
2740
+ default: "30"
2741
+ },
2742
+ json: {
2743
+ type: "boolean",
2744
+ description: "Output raw JSON",
2745
+ default: false
2746
+ }
2747
+ },
2748
+ async run({ args }) {
2749
+ applyJsonFlag(args.json);
2750
+ const thresholdDays = Number.parseInt(args.days, 10) || 30;
2751
+ const startTime = Date.now();
2752
+ const response = await dispatchRaw("query", "nexus", "cold-symbols", { days: thresholdDays });
2753
+ const durationMs = Date.now() - startTime;
2754
+ if (!response.success) {
2755
+ cliError(
2756
+ response.error?.message ?? "Unknown error",
2757
+ 1,
2758
+ { name: response.error?.code ?? "E_COLD_SYMBOLS_FAILED", details: response.error?.details },
2759
+ { operation: "nexus.cold-symbols", duration_ms: durationMs }
2760
+ );
2761
+ process.exitCode = 1;
2762
+ return;
2763
+ }
2764
+ cliOutput(response.data, {
2765
+ command: "nexus-cold-symbols",
2766
+ operation: "nexus.cold-symbols",
2767
+ extensions: { duration_ms: durationMs },
2768
+ responseMeta: response.meta
2769
+ });
2770
+ }
2771
+ });
2772
+ var sigilSyncCommand = defineCommand({
2773
+ meta: {
2774
+ name: "sync",
2775
+ description: "Populate the nexus.db sigils table with one row per canonical CANT agent (cleo-subagent + 5 seed roles + 2 meta agents). Idempotent."
2776
+ },
2777
+ args: {
2778
+ json: {
2779
+ type: "boolean",
2780
+ description: "Output as JSON (LAFS envelope format)"
2781
+ }
2782
+ },
2783
+ async run() {
2784
+ await dispatchFromCli("mutate", "nexus", "sigil.sync", {}, { command: "nexus" });
2785
+ }
2786
+ });
2787
+ var sigilListCommand = defineCommand({
2788
+ meta: {
2789
+ name: "list",
2790
+ description: "List every sigil currently stored in nexus.db, optionally filtered by role."
2791
+ },
2792
+ args: {
2793
+ role: {
2794
+ type: "string",
2795
+ description: 'Filter by role (e.g. "orchestrator", "lead", "worker", "specialist", "subagent")'
2796
+ }
2797
+ },
2798
+ async run({ args }) {
2799
+ await dispatchFromCli(
2800
+ "query",
2801
+ "nexus",
2802
+ "sigil.list",
2803
+ { role: args.role },
2804
+ { command: "nexus" }
2805
+ );
2806
+ }
2807
+ });
2808
+ var sigilCommand = defineCommand({
2809
+ meta: {
2810
+ name: "sigil",
2811
+ description: "Sigil (peer-card) operations \u2014 sync from canonical CANT agents, list current rows"
2812
+ },
2813
+ subCommands: {
2814
+ sync: sigilSyncCommand,
2815
+ list: sigilListCommand
2816
+ }
2817
+ });
2818
+ var topEntriesCommand = defineCommand({
2819
+ meta: {
2820
+ name: "top-entries",
2821
+ description: "List top-weighted symbols from nexus_relations by weight DESC"
2822
+ },
2823
+ args: {
2824
+ limit: {
2825
+ type: "string",
2826
+ description: "Maximum number of entries to return (default: 20)",
2827
+ default: "20"
2828
+ },
2829
+ kind: {
2830
+ type: "string",
2831
+ description: "Filter by nexus_nodes.kind (e.g. function, method, class, interface, type_alias)"
2832
+ },
2833
+ json: {
2834
+ type: "boolean",
2835
+ description: "Output result as JSON (LAFS envelope format)"
2836
+ }
2837
+ },
2838
+ async run({ args }) {
2839
+ const limit = Number.parseInt(args.limit, 10) || 20;
2840
+ const kind = args.kind ?? void 0;
2841
+ const jsonOutput = !!args.json;
2842
+ const params = { limit };
2843
+ if (kind !== void 0 && kind.length > 0) params.kind = kind;
2844
+ await dispatchFromCli("query", "nexus", "top-entries", params, {
2845
+ command: "nexus",
2846
+ operation: "nexus.top-entries",
2847
+ ...jsonOutput ? { json: true } : {}
2848
+ });
2849
+ }
2850
+ });
2851
+ var nexusCommand = defineCommand({
2852
+ meta: { name: "nexus", description: "Cross-project NEXUS operations" },
2853
+ subCommands: {
2854
+ init: initCommand,
2855
+ register: registerCommand,
2856
+ unregister: unregisterCommand,
2857
+ list: listCommand,
2858
+ status: statusCommand,
2859
+ show: showCommand,
2860
+ resolve: resolveCommand,
2861
+ discover: discoverCommand,
2862
+ search: searchCommand,
2863
+ augment: augmentCommand,
2864
+ setup: setupCommand,
2865
+ deps: depsCommand,
2866
+ "critical-path": criticalPathCommand,
2867
+ blocking: blockingCommand,
2868
+ orphans: orphansCommand,
2869
+ sync: syncCommand,
2870
+ reconcile: reconcileCommand,
2871
+ graph: graphCommand,
2872
+ "share-status": shareStatusCommand,
2873
+ "transfer-preview": transferPreviewCommand,
2874
+ transfer: transferCommand,
2875
+ permission: permissionCommand,
2876
+ share: shareCommand,
2877
+ clusters: clustersCommand,
2878
+ flows: flowsCommand,
2879
+ context: contextCommand,
2880
+ impact: impactCommand,
2881
+ analyze: analyzeCommand,
2882
+ query: queryCommand,
2883
+ projects: projectsCommand,
2884
+ "refresh-bridge": refreshBridgeCommand,
2885
+ export: exportCommand,
2886
+ diff: diffCommand,
2887
+ "route-map": routeMapCommand,
2888
+ "shape-check": shapeCheckCommand,
2889
+ "full-context": fullContextCommand,
2890
+ "task-footprint": taskFootprintCommand,
2891
+ "brain-anchors": brainAnchorsCommand,
2892
+ why: whyCommand,
2893
+ "impact-full": impactFullCommand,
2894
+ // T1071 — conduit scan
2895
+ "conduit-scan": conduitScanCommand,
2896
+ // T1067 — task symbols
2897
+ "task-symbols": taskSymbolsCommand,
2898
+ // T1058 — code symbol search
2899
+ "search-code": searchCodeCommand,
2900
+ // T1065 — contract registry
2901
+ contracts: contractsCommand,
2902
+ // T1114 — group alias for contracts
2903
+ group: groupCommand,
2904
+ // T1060 — wiki index
2905
+ wiki: wikiCommand,
2906
+ // T1108 — plasticity queries
2907
+ "hot-paths": hotPathsCommand,
2908
+ "hot-nodes": hotNodesCommand,
2909
+ "cold-symbols": coldSymbolsCommand,
2910
+ // T1013 / T1006 — top-weighted symbols by nexus_relations.weight
2911
+ "top-entries": topEntriesCommand,
2912
+ // T1386 — sigil sync + list (canonical CANT agent peer cards)
2913
+ sigil: sigilCommand
2914
+ },
2915
+ async run({ cmd, rawArgs }) {
2916
+ const firstArg = rawArgs?.find((a) => !a.startsWith("-"));
2917
+ if (firstArg && cmd.subCommands && firstArg in cmd.subCommands) return;
2918
+ await showUsage(cmd);
2919
+ }
2920
+ });
2921
+ export {
2922
+ nexusCommand
2923
+ };
2924
+ //# sourceMappingURL=nexus-XSFXN5E6.js.map