@cleocode/cleo 2026.10.3 → 2026.10.4

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