@iowarp/clio-coder 0.3.4 → 0.3.7

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 (376) hide show
  1. package/CHANGELOG.md +65 -2
  2. package/CONTRIBUTING.md +6 -6
  3. package/README.md +16 -5
  4. package/dist/{acp-S5R4RR5B.js → acp-SK4MD6MM.js} +11 -11
  5. package/dist/{agents-P6DMMVZY.js → agents-2FN2K6ME.js} +33 -26
  6. package/dist/assets/codewiki.json +1 -1
  7. package/dist/{auth-2XCZLPKS.js → auth-QIYZWM5I.js} +15 -15
  8. package/dist/{chunk-EKMEHE4H.js → chunk-33YXPOE3.js} +2 -3
  9. package/dist/{chunk-VAWWTKDP.js → chunk-3HAPLH5M.js} +11 -11
  10. package/dist/{chunk-YCWGATWI.js → chunk-465YSENW.js} +3 -3
  11. package/dist/{chunk-4OC57DA6.js → chunk-4DGYLA73.js} +53 -2
  12. package/dist/{chunk-UZHIZC5S.js → chunk-4DWFMQDR.js} +61 -76
  13. package/dist/{chunk-ZWMF7253.js → chunk-5C3AQNDW.js} +328 -9
  14. package/dist/{chunk-22NAGB7X.js → chunk-5C77SEEY.js} +5 -94
  15. package/dist/{chunk-WPQLXFOZ.js → chunk-5FR74PWO.js} +3 -2
  16. package/dist/{chunk-35MKKU5R.js → chunk-5UJ6ECTS.js} +18 -10
  17. package/dist/{chunk-BRXQQJFP.js → chunk-6M7VS3J3.js} +571 -50
  18. package/dist/{chunk-QQK64KLB.js → chunk-6TUKSZVF.js} +141 -23
  19. package/dist/{chunk-N4CZJQRK.js → chunk-AB4XIIVB.js} +8 -6
  20. package/dist/{chunk-KRPY7NTG.js → chunk-BMWK7ZIZ.js} +14 -20
  21. package/dist/{chunk-4BPJXDWC.js → chunk-C4JBQ5SR.js} +30 -14
  22. package/dist/{chunk-ZYKPLLNQ.js → chunk-CEYBNUGC.js} +821 -83
  23. package/dist/{chunk-VEZEGCGW.js → chunk-D4MDIG46.js} +20 -18
  24. package/dist/chunk-DJNLUABN.js +843 -0
  25. package/dist/{chunk-BP4OYD6A.js → chunk-DMD2AGVS.js} +21 -2
  26. package/dist/{chunk-KOHPCX4K.js → chunk-DOOEX22V.js} +2 -2
  27. package/dist/chunk-DQA7QLMD.js +123 -0
  28. package/dist/chunk-DR52UMZW.js +21 -0
  29. package/dist/{chunk-3HZ5RWN2.js → chunk-EBEFWSGL.js} +9 -7
  30. package/dist/{chunk-EDRHSCIE.js → chunk-EELBMBT6.js} +128 -13
  31. package/dist/{chunk-HV5X7OR2.js → chunk-EOOQZZDE.js} +16 -14
  32. package/dist/{chunk-WR67VIZY.js → chunk-FOT2FX5J.js} +63 -5
  33. package/dist/{chunk-BPGS2WCQ.js → chunk-GEYXPTRF.js} +2 -1
  34. package/dist/{chunk-FYYLNIL5.js → chunk-GH5622CP.js} +2 -2
  35. package/dist/{chunk-BEY543CS.js → chunk-GOXNB3AO.js} +5 -2
  36. package/dist/chunk-GWS3VEIW.js +195 -0
  37. package/dist/{chunk-G4BMMOKF.js → chunk-HVDIIIQW.js} +2 -2
  38. package/dist/chunk-HWUFFB6L.js +83 -0
  39. package/dist/{chunk-X6COSD2O.js → chunk-J7PIKKWC.js} +8 -436
  40. package/dist/{chunk-NILBFAPG.js → chunk-JNXPYBB4.js} +2 -2
  41. package/dist/{chunk-4VP4KH3K.js → chunk-JRIO5UD2.js} +4 -4
  42. package/dist/{chunk-K6WL7QZT.js → chunk-JTSEDYVQ.js} +7 -7
  43. package/dist/{chunk-QKMUKYO7.js → chunk-KCMKRQX4.js} +236 -84
  44. package/dist/chunk-KZ2H5X4G.js +1026 -0
  45. package/dist/{chunk-A2GZF7DC.js → chunk-LADCF22A.js} +13 -13
  46. package/dist/chunk-LCGCVYZ4.js +57 -0
  47. package/dist/chunk-M4AKACEO.js +382 -0
  48. package/dist/{chunk-POHLU5DW.js → chunk-M6L6IDJG.js} +3 -3
  49. package/dist/{chunk-4JUF2NNX.js → chunk-MXI6J5JF.js} +7 -7
  50. package/dist/{chunk-X4RCMKVQ.js → chunk-NDINPTJ4.js} +2 -2
  51. package/dist/{chunk-TTNYS3EA.js → chunk-OB5HIGJY.js} +1 -1
  52. package/dist/{chunk-7RXG6QRZ.js → chunk-OBMAI2DP.js} +61 -840
  53. package/dist/{chunk-5M54SPOL.js → chunk-ODFEOB4F.js} +161 -5
  54. package/dist/chunk-PD3MESLB.js +242 -0
  55. package/dist/{chunk-ED4KHGC3.js → chunk-PPAMZ32Z.js} +9 -2
  56. package/dist/{chunk-VMNQ6OZA.js → chunk-QCTRSGHQ.js} +963 -786
  57. package/dist/chunk-RVG5JXAL.js +41 -0
  58. package/dist/{chunk-RD5U66HV.js → chunk-SROCI7ZU.js} +7 -7
  59. package/dist/{chunk-MFFY33HR.js → chunk-THKY7CD7.js} +466 -205
  60. package/dist/{chunk-34475P3I.js → chunk-TSHXZTOQ.js} +5 -4
  61. package/dist/{chunk-PCZJO5TI.js → chunk-UFQ3F4FW.js} +13 -178
  62. package/dist/{chunk-AD2SYQYC.js → chunk-UHXRNZ2J.js} +121 -3
  63. package/dist/chunk-UND3GU2L.js +103 -0
  64. package/dist/{chunk-QQL5RT5M.js → chunk-UUANF5CR.js} +2323 -2114
  65. package/dist/{chunk-VJWL6YS5.js → chunk-UUVG37B4.js} +2 -2
  66. package/dist/chunk-UVDSQ6LW.js +472 -0
  67. package/dist/{chunk-QWU7ZBO7.js → chunk-VQNODYQ4.js} +215 -56
  68. package/dist/chunk-VREKEFLL.js +37 -0
  69. package/dist/{chunk-2TZWSW76.js → chunk-WHGPSPT5.js} +2 -2
  70. package/dist/{chunk-TW3WDMVS.js → chunk-WHJYKASB.js} +2 -2
  71. package/dist/{chunk-MEQ45TQ4.js → chunk-WJHBC77E.js} +21 -7
  72. package/dist/{chunk-HXG4IURW.js → chunk-X2KV5FXT.js} +2 -2
  73. package/dist/{chunk-YHZX5GEU.js → chunk-XAKHZX5N.js} +2 -2
  74. package/dist/{chunk-2LZI5CAG.js → chunk-XEGB6BCN.js} +228 -36
  75. package/dist/{chunk-E25LMLRW.js → chunk-YD734TPH.js} +2 -2
  76. package/dist/{verifiers-4UUM6TEE.js → chunk-YTYFXUI3.js} +121 -372
  77. package/dist/{chunk-3JLKSKD7.js → chunk-ZGH7FGS5.js} +17 -7
  78. package/dist/{chunk-VSNATDE6.js → chunk-ZZMN5OM4.js} +2 -2
  79. package/dist/cli/index.js +34 -32
  80. package/dist/{clio-J5JIOIDS.js → clio-WBVQEBKO.js} +7 -7
  81. package/dist/{code-nav-AXCXSBHX.js → code-nav-FGGFIE7L.js} +7 -7
  82. package/dist/codewiki/build-worker.js +4 -4
  83. package/dist/{components-KELWS457.js → components-F7OEATSO.js} +5 -5
  84. package/dist/{config-OEBMIN2U.js → config-TRBL3RCF.js} +48 -41
  85. package/dist/{configure-PUQOSIXQ.js → configure-OLCVPHNM.js} +17 -17
  86. package/dist/{context-URSXPBCK.js → context-MJIJ6GOX.js} +12 -12
  87. package/dist/{context-EKDCKUUZ.js → context-WFPKQSM6.js} +26 -9
  88. package/dist/{context-MGSE4Z2T.js → context-XEWE3MOJ.js} +44 -37
  89. package/dist/{context-clear-KDAJRNUK.js → context-clear-KNOS2JPB.js} +44 -37
  90. package/dist/{context-index-BZ4UYMTC.js → context-index-SSR5ECNE.js} +3 -3
  91. package/dist/{context-working-set-SBKMPPI2.js → context-working-set-EUXAZI6N.js} +14 -13
  92. package/dist/{dispatch-runner-MSWN72NK.js → dispatch-runner-B7MTOVKL.js} +321 -60
  93. package/dist/{docs-2C2LTVT2.js → docs-FLJTIDSE.js} +5 -5
  94. package/dist/{doctor-7BSE27PJ.js → doctor-RN4YKO2X.js} +15 -15
  95. package/dist/{eval-IZGDOO4H.js → eval-RUBJVSNQ.js} +52 -236
  96. package/dist/{evidence-SR7WXB5B.js → evidence-JZNBUOQZ.js} +39 -33
  97. package/dist/{evolve-K7VE2CBX.js → evolve-FJVC4KKI.js} +39 -33
  98. package/dist/{extensions-QVDOHDGJ.js → extensions-IQL36S7K.js} +5 -5
  99. package/dist/{fleet-7XMJNQNF.js → fleet-BDKYJFCP.js} +243 -370
  100. package/dist/fleet-commands-ZFIWZSB3.js +70 -0
  101. package/dist/fleet-graph-Y6HPXIVF.js +125 -0
  102. package/dist/fleet-new-RDVJLHHH.js +48 -0
  103. package/dist/{fleet-preflight-AQNAH644.js → fleet-preflight-BHSNPBMH.js} +2 -2
  104. package/dist/fleet-validate-BIYREGIK.js +79 -0
  105. package/dist/{init-JGNPAYXT.js → init-LQUB5COQ.js} +57 -48
  106. package/dist/library-NJAHIGG4.js +217 -0
  107. package/dist/memory-OG6HOYKM.js +472 -0
  108. package/dist/{models-ZMMLFJNN.js → models-5ZG5XY7J.js} +23 -22
  109. package/dist/{monitor-2F3T5KHP.js → monitor-TJ7AMTGB.js} +69 -35
  110. package/dist/{orchestrator-ORHT43JB.js → orchestrator-WZYB54DM.js} +4868 -1189
  111. package/dist/{paths-UXLN5YYZ.js → paths-XUC7GS6E.js} +5 -5
  112. package/dist/{reset-NXGTYNUO.js → reset-PXQT45IY.js} +8 -8
  113. package/dist/{run-RF4WJGMT.js → run-FQ74YF62.js} +82 -62
  114. package/dist/{share-UT3W6E4M.js → share-FW7SVCL3.js} +34 -10
  115. package/dist/{skills-PSACKC5Q.js → skills-7E7IRB3R.js} +25 -9
  116. package/dist/{skills-eval-WJSI55RZ.js → skills-eval-LI75W6OK.js} +43 -35
  117. package/dist/{targets-PIIRAOYS.js → targets-4CIFKCTW.js} +27 -24
  118. package/dist/{terminal-lease-ULWXWNVY.js → terminal-lease-WUZY7ZV5.js} +5 -4
  119. package/dist/{uninstall-FZCQCDKC.js → uninstall-7FV7IP4E.js} +5 -5
  120. package/dist/{upgrade-346TZ6AV.js → upgrade-K2HVIVMQ.js} +21 -20
  121. package/dist/{usage-6KKXR32N.js → usage-GTZELZQX.js} +159 -59
  122. package/dist/verifiers-RLAHT27O.js +336 -0
  123. package/dist/{verify-X5HDROLA.js → verify-BX3BRKH5.js} +7 -6
  124. package/dist/{wiki-generate-7STOCIFZ.js → wiki-generate-ASIFASCN.js} +58 -48
  125. package/dist/worker/entry.js +98 -84
  126. package/dist/{workspace-G4ZWUIPR.js → workspace-ZJ6BFM3Q.js} +4 -4
  127. package/docs/README.md +4 -3
  128. package/docs/acp.md +1 -1
  129. package/docs/alcf-provider.md +1 -1
  130. package/docs/architecture.md +2 -2
  131. package/docs/artifact-placement.md +1 -2
  132. package/docs/artifact-versions.md +10 -6
  133. package/docs/built-in-agents.md +26 -2
  134. package/docs/capacity-and-scheduling.md +1 -1
  135. package/docs/commands-and-modes.md +90 -8
  136. package/docs/configuration-and-targets.md +90 -2
  137. package/docs/context-engine.md +4 -2
  138. package/docs/context-working-set.md +4 -4
  139. package/docs/development-pipeline.md +1 -1
  140. package/docs/dispatch-architecture-rationale.md +1 -1
  141. package/docs/documentation-coverage.md +4 -4
  142. package/docs/documentation-guide.md +4 -4
  143. package/docs/eval-runner.md +1 -1
  144. package/docs/evals-internal.md +4 -45
  145. package/docs/evidence-and-memory.md +70 -10
  146. package/docs/evolution.md +1 -1
  147. package/docs/exit-codes-and-output.md +4 -1
  148. package/docs/extensions-and-sharing.md +6 -2
  149. package/docs/fleet-demo-runbook.md +2 -2
  150. package/docs/fleet-dispatch.md +224 -11
  151. package/docs/git-commit-provenance.md +2 -2
  152. package/docs/glossary.md +1 -1
  153. package/docs/installation-and-lifecycle.md +2 -2
  154. package/docs/middleware-and-components.md +20 -2
  155. package/docs/model-catalog.md +1 -1
  156. package/docs/observability.md +55 -8
  157. package/docs/proactive-memory.md +26 -16
  158. package/docs/prompt-envelope-and-tools.md +4 -2
  159. package/docs/provider-adapter-cookbook.md +1 -1
  160. package/docs/release-cut-checklist.md +83 -65
  161. package/docs/resource-library.md +59 -0
  162. package/docs/safety-model.md +29 -7
  163. package/docs/scientific-validation.md +3 -3
  164. package/docs/session-lifecycle.md +37 -1
  165. package/docs/skills-marketplace.md +16 -3
  166. package/docs/tool-usage.md +14 -7
  167. package/docs/trace-store.md +1 -1
  168. package/docs/troubleshooting.md +1 -1
  169. package/docs/tui-design.md +38 -4
  170. package/docs/worker-dispatch-mechanics.md +3 -3
  171. package/package.json +7 -4
  172. package/src/cli/agents.ts +2 -3
  173. package/src/cli/argv.ts +14 -1
  174. package/src/cli/fleet-commands.ts +37 -0
  175. package/src/cli/fleet-graph.ts +102 -0
  176. package/src/cli/fleet-new.ts +36 -0
  177. package/src/cli/fleet-preflight.ts +121 -0
  178. package/src/cli/fleet-validate.ts +30 -0
  179. package/src/cli/fleet.ts +188 -335
  180. package/src/cli/index.ts +4 -2
  181. package/src/cli/library.ts +190 -0
  182. package/src/cli/memory.ts +272 -10
  183. package/src/cli/modes/json-stream.ts +2 -2
  184. package/src/cli/modes/print.ts +12 -1
  185. package/src/cli/run.ts +22 -2
  186. package/src/cli/share.ts +13 -1
  187. package/src/cli/targets.ts +12 -3
  188. package/src/cli/usage.ts +160 -20
  189. package/src/core/bus-events.ts +7 -0
  190. package/src/core/commit-attribution.ts +4 -4
  191. package/src/core/config.ts +130 -0
  192. package/src/core/defaults.ts +81 -0
  193. package/src/core/response-model-id.ts +134 -0
  194. package/src/core/toml.ts +62 -0
  195. package/src/core/workspace-files.ts +0 -1
  196. package/src/domains/agents/builtins/architect.md +2 -1
  197. package/src/domains/agents/builtins/oracle.md +33 -0
  198. package/src/domains/agents/catalog.ts +18 -5
  199. package/src/domains/agents/fleet-contract.ts +278 -16
  200. package/src/domains/agents/index.ts +14 -0
  201. package/src/domains/agents/recipe.ts +54 -14
  202. package/src/domains/agents/result-contract.ts +242 -5
  203. package/src/domains/config/classify.ts +4 -0
  204. package/src/domains/context/bootstrap.ts +36 -27
  205. package/src/domains/context/project-metadata.ts +19 -63
  206. package/src/domains/context/prompt-context.ts +8 -0
  207. package/src/domains/context/working-set/policies/index.ts +3 -4
  208. package/src/domains/dispatch/active-route-planner.ts +14 -0
  209. package/src/domains/dispatch/backoff.ts +2 -1
  210. package/src/domains/dispatch/budget-envelope.ts +396 -0
  211. package/src/domains/dispatch/capability-match.ts +1 -0
  212. package/src/domains/dispatch/checkout-writer-lease.ts +175 -0
  213. package/src/domains/dispatch/contract.ts +36 -0
  214. package/src/domains/dispatch/delegation-plan.ts +167 -0
  215. package/src/domains/dispatch/execution-plan.ts +76 -5
  216. package/src/domains/dispatch/execution-role.ts +3 -1
  217. package/src/domains/dispatch/execution-scheduler.ts +183 -67
  218. package/src/domains/dispatch/extension.ts +339 -36
  219. package/src/domains/dispatch/fleet-gate.ts +14 -0
  220. package/src/domains/dispatch/fleet-plan.ts +63 -3
  221. package/src/domains/dispatch/fleet-run.ts +737 -0
  222. package/src/domains/dispatch/gate-role-prompts.ts +9 -0
  223. package/src/domains/dispatch/host-verification.ts +178 -0
  224. package/src/domains/dispatch/index.ts +38 -0
  225. package/src/domains/dispatch/intent.ts +159 -0
  226. package/src/domains/dispatch/orphan-recovery.ts +1 -0
  227. package/src/domains/dispatch/receipt-integrity.ts +12 -4
  228. package/src/domains/dispatch/state.ts +37 -3
  229. package/src/domains/dispatch/types.ts +61 -9
  230. package/src/domains/dispatch/validation.ts +80 -6
  231. package/src/domains/dispatch/worker-spawn.ts +14 -3
  232. package/src/domains/eval/metrics/evidence.ts +0 -116
  233. package/src/domains/eval/metrics/invariants.ts +1 -1
  234. package/src/domains/eval/runners/clio-run.ts +1 -10
  235. package/src/domains/eval/runners/external-command.ts +2 -29
  236. package/src/domains/eval/schema/suite.ts +0 -7
  237. package/src/domains/eval/suites/run.ts +1 -7
  238. package/src/domains/evidence/trust-status.ts +10 -1
  239. package/src/domains/memory/index.ts +22 -0
  240. package/src/domains/memory/operations.ts +58 -1
  241. package/src/domains/memory/promotion.ts +281 -0
  242. package/src/domains/memory/prompt-section.ts +25 -5
  243. package/src/domains/memory/proposal.ts +51 -7
  244. package/src/domains/memory/task-bank.ts +3 -2
  245. package/src/domains/memory/task-memory-handoff.ts +181 -24
  246. package/src/domains/memory/task-memory-policy.ts +3 -1
  247. package/src/domains/memory/types.ts +37 -0
  248. package/src/domains/memory/validate.ts +178 -0
  249. package/src/domains/middleware/index.ts +15 -0
  250. package/src/domains/middleware/memory-intervention.ts +35 -25
  251. package/src/domains/middleware/runtime.ts +6 -0
  252. package/src/domains/middleware/skills-reminder.ts +19 -4
  253. package/src/domains/middleware/stalled-turn.ts +43 -1
  254. package/src/domains/middleware/types.ts +10 -0
  255. package/src/domains/middleware/watchdog.ts +281 -0
  256. package/src/domains/observability/contract.ts +9 -2
  257. package/src/domains/observability/cost.ts +31 -4
  258. package/src/domains/observability/extension.ts +2 -2
  259. package/src/domains/observability/index.ts +10 -0
  260. package/src/domains/observability/out-of-turn-usage.ts +223 -0
  261. package/src/domains/providers/index.ts +3 -0
  262. package/src/domains/providers/model-discovery.ts +9 -0
  263. package/src/domains/providers/runtime-resolution.ts +38 -1
  264. package/src/domains/providers/runtimes/common/probe-helpers.ts +97 -16
  265. package/src/domains/providers/types/context-window-slots.ts +18 -0
  266. package/src/domains/providers/types/runtime-descriptor.ts +3 -1
  267. package/src/domains/resources/index.ts +20 -0
  268. package/src/domains/resources/library.ts +326 -0
  269. package/src/domains/resources/skills/marketplace.ts +37 -12
  270. package/src/domains/safety/call-target.ts +211 -14
  271. package/src/domains/safety/decision-presentation.ts +268 -0
  272. package/src/domains/safety/redaction.ts +73 -0
  273. package/src/domains/session/context-ledger.ts +10 -1
  274. package/src/domains/session/decision-board.ts +4 -0
  275. package/src/domains/session/entries.ts +3 -0
  276. package/src/domains/session/handoff.ts +629 -0
  277. package/src/domains/session/history.ts +68 -19
  278. package/src/domains/session/usage.ts +24 -7
  279. package/src/domains/share/archive.ts +67 -2
  280. package/src/engine/acp/event-mapper.ts +7 -0
  281. package/src/engine/acp/server.ts +29 -2
  282. package/src/engine/apis/lmstudio.ts +25 -4
  283. package/src/engine/apis/openai-completions.ts +147 -22
  284. package/src/engine/claude/sdk-runtime.ts +8 -2
  285. package/src/engine/claude/tool-safety.ts +13 -0
  286. package/src/engine/loop-guard.ts +27 -3
  287. package/src/engine/worker-events.ts +4 -3
  288. package/src/engine/worker-runtime.ts +59 -54
  289. package/src/entry/orchestrator.ts +55 -1
  290. package/src/interactive/bus-notices.ts +26 -0
  291. package/src/interactive/chat-loop-messages.ts +22 -0
  292. package/src/interactive/chat-loop.ts +248 -1
  293. package/src/interactive/chat-renderer.ts +41 -3
  294. package/src/interactive/clio-editor.ts +44 -7
  295. package/src/interactive/context-overlay.ts +43 -5
  296. package/src/interactive/cost-overlay.ts +70 -11
  297. package/src/interactive/council-dispatch.ts +30 -0
  298. package/src/interactive/council-grid.ts +213 -0
  299. package/src/interactive/council.ts +99 -0
  300. package/src/interactive/dispatch-board.ts +471 -50
  301. package/src/interactive/fleet-run-preview.ts +307 -0
  302. package/src/interactive/footer/notifications.ts +219 -0
  303. package/src/interactive/footer/widgets.ts +13 -0
  304. package/src/interactive/handoff-round.ts +56 -0
  305. package/src/interactive/interactive-application.ts +49 -2
  306. package/src/interactive/interactive-event-projection.ts +9 -1
  307. package/src/interactive/interactive-input-runtime.ts +11 -1
  308. package/src/interactive/interactive-presentation.ts +11 -1
  309. package/src/interactive/interactive-slash-runtime.ts +52 -2
  310. package/src/interactive/interactive-subscriptions.ts +14 -2
  311. package/src/interactive/memory-overlay.ts +89 -4
  312. package/src/interactive/oracle.ts +179 -0
  313. package/src/interactive/overlay-ask-user-lifecycle.ts +7 -1
  314. package/src/interactive/overlay-frame.ts +5 -2
  315. package/src/interactive/overlay-general-openers.ts +230 -2
  316. package/src/interactive/overlay-key-routing.ts +58 -2
  317. package/src/interactive/overlay-lifecycle.ts +52 -5
  318. package/src/interactive/overlay-permission-lifecycle.ts +33 -8
  319. package/src/interactive/overlay-resource-openers.ts +11 -3
  320. package/src/interactive/overlay-session-lifecycle.ts +234 -2
  321. package/src/interactive/overlay-transitions.ts +11 -0
  322. package/src/interactive/overlays/ask-user.ts +74 -30
  323. package/src/interactive/overlays/decisions.ts +3 -1
  324. package/src/interactive/overlays/fleet-run-approval.ts +208 -0
  325. package/src/interactive/overlays/handoff-review.ts +185 -0
  326. package/src/interactive/overlays/library-install-confirm.ts +151 -0
  327. package/src/interactive/overlays/list-overlay.ts +168 -2
  328. package/src/interactive/overlays/settings.ts +101 -4
  329. package/src/interactive/overlays/side-question.ts +139 -0
  330. package/src/interactive/overlays/skills-hub.ts +401 -15
  331. package/src/interactive/permission-hint.ts +35 -0
  332. package/src/interactive/permission-overlay.ts +95 -45
  333. package/src/interactive/renderers/tool-execution.ts +19 -49
  334. package/src/interactive/session-last-turn.ts +8 -1
  335. package/src/interactive/session-usage-reseed.ts +36 -10
  336. package/src/interactive/side-question.ts +171 -0
  337. package/src/interactive/slash-commands.ts +434 -7
  338. package/src/interactive/slash-spec.ts +19 -6
  339. package/src/interactive/status/summary.ts +5 -0
  340. package/src/interactive/status/types.ts +5 -0
  341. package/src/interactive/terminal-lease.ts +1 -0
  342. package/src/interactive/theme/tokens.ts +30 -0
  343. package/src/interactive/turn-context.ts +96 -23
  344. package/src/interactive/turn-middleware.ts +16 -1
  345. package/src/interactive/turn-runtime.ts +37 -8
  346. package/src/interactive/turn-state.ts +3 -0
  347. package/src/interactive/watchdog-run.ts +75 -0
  348. package/src/interactive/worker-progress.ts +440 -0
  349. package/src/interactive/worker-share.ts +56 -1
  350. package/src/interactive/worker-stream.ts +58 -110
  351. package/src/tools/agent-tools.ts +28 -3
  352. package/src/tools/ask-user.ts +21 -1
  353. package/src/tools/bootstrap.ts +3 -0
  354. package/src/tools/compete-worktrees.ts +13 -79
  355. package/src/tools/context/index.ts +2 -2
  356. package/src/tools/dispatch-admission.ts +242 -8
  357. package/src/tools/dispatch-arguments.ts +65 -1
  358. package/src/tools/dispatch-event-text.ts +19 -0
  359. package/src/tools/dispatch-plan.ts +136 -6
  360. package/src/tools/dispatch-runner.ts +319 -13
  361. package/src/tools/dispatch-types.ts +20 -1
  362. package/src/tools/dispatch.ts +96 -3
  363. package/src/tools/monitor.ts +31 -0
  364. package/src/tools/profiles.ts +18 -4
  365. package/src/tools/registry.ts +15 -5
  366. package/src/tools/result-disposition.ts +156 -0
  367. package/src/tools/result-shaping.ts +59 -1
  368. package/src/tools/task-worktree.ts +238 -0
  369. package/src/tools/verify/authoring.ts +116 -55
  370. package/src/tools/verify/scripts.ts +62 -0
  371. package/src/tools/worker-evidence.ts +21 -1
  372. package/src/worker/spec-contract.ts +44 -3
  373. package/dist/chunk-EFADSJET.js +0 -18
  374. package/dist/chunk-HC4CLZ2Y.js +0 -68
  375. package/dist/memory-4ALKDJ4Q.js +0 -246
  376. package/src/domains/eval/metrics/chaos-stream.ts +0 -93
@@ -0,0 +1,217 @@
1
+ import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
+ import {
3
+ classifyLibraryRequirements,
4
+ confirmLibraryRemote,
5
+ discoverLibrary,
6
+ installLibraryPlan,
7
+ libraryEntryRef,
8
+ libraryInstallPath,
9
+ planLibraryInstall,
10
+ syncLibrary
11
+ } from "./chunk-THKY7CD7.js";
12
+ import "./chunk-UVDSQ6LW.js";
13
+ import "./chunk-DR52UMZW.js";
14
+ import "./chunk-C4JBQ5SR.js";
15
+ import "./chunk-2SFS6XQE.js";
16
+ import "./chunk-ZWLZP4ZT.js";
17
+ import "./chunk-KCMKRQX4.js";
18
+ import "./chunk-DJNLUABN.js";
19
+ import "./chunk-AOCYTWAV.js";
20
+ import "./chunk-MV3K5QF2.js";
21
+ import "./chunk-UL3WSD3F.js";
22
+ import "./chunk-ECH6PKUQ.js";
23
+ import "./chunk-5B2AEOW5.js";
24
+ import "./chunk-CGKSTWHD.js";
25
+ import "./chunk-465YSENW.js";
26
+ import {
27
+ printError,
28
+ printOk
29
+ } from "./chunk-PPAMZ32Z.js";
30
+ import "./chunk-5TSRNF4G.js";
31
+ import "./chunk-JRIO5UD2.js";
32
+ import "./chunk-IHXBNWMM.js";
33
+ import "./chunk-UHXRNZ2J.js";
34
+ import "./chunk-4DGYLA73.js";
35
+ import "./chunk-LL4KHSZI.js";
36
+ import "./chunk-SST6Z5JA.js";
37
+ import "./chunk-D4MDIG46.js";
38
+ import "./chunk-FQ4SKYE4.js";
39
+ import "./chunk-4ZG3XFUR.js";
40
+ import "./chunk-IKCO5N3L.js";
41
+ import "./chunk-3I7MS7N2.js";
42
+ import "./chunk-APJ265NV.js";
43
+ import "./chunk-YXLYO42X.js";
44
+ import "./chunk-BNAZZHFG.js";
45
+ import "./chunk-6EJMN2Y3.js";
46
+ import "./chunk-WEPFGWHJ.js";
47
+ import "./chunk-IWHMRKLL.js";
48
+ import {
49
+ init_esm_shims
50
+ } from "./chunk-3R73A4XB.js";
51
+
52
+ // src/cli/library.ts
53
+ init_esm_shims();
54
+ var KINDS = /* @__PURE__ */ new Set(["skill", "agent", "prompt", "fleet"]);
55
+ var HELP = `clio-coder library <command>
56
+
57
+ Commands:
58
+ clio-coder library list [--kind <kind>] [--json]
59
+ clio-coder library search <query> [--kind <kind>] [--json]
60
+ clio-coder library add <ref> [--from <catalog|path>] [--with-requirements] [--yes] [--json]
61
+ clio-coder library use <kind> <name>
62
+ clio-coder library sync
63
+ clio-coder library push
64
+ clio-coder library remote confirm <url>
65
+ `;
66
+ function parse(argv) {
67
+ const out = { positional: [], json: false, yes: false, withRequirements: false, help: false };
68
+ for (let i = 0; i < argv.length; i += 1) {
69
+ const arg = argv[i];
70
+ if (!arg) continue;
71
+ if (!out.command && !arg.startsWith("-")) {
72
+ out.command = arg;
73
+ continue;
74
+ }
75
+ if (arg === "--json") out.json = true;
76
+ else if (arg === "--yes") out.yes = true;
77
+ else if (arg === "--with-requirements") out.withRequirements = true;
78
+ else if (arg === "--help" || arg === "-h") out.help = true;
79
+ else if (arg === "--kind") {
80
+ const value = argv[++i];
81
+ if (!value || !KINDS.has(value))
82
+ throw new Error("--kind requires skill, agent, prompt, or fleet");
83
+ out.kind = value;
84
+ } else if (arg === "--from") {
85
+ const value = argv[++i];
86
+ if (!value) throw new Error("--from requires a value");
87
+ out.from = value;
88
+ } else if (arg.startsWith("-")) throw new Error(`unknown flag: ${arg}`);
89
+ else out.positional.push(arg);
90
+ }
91
+ return out;
92
+ }
93
+ function selectEntry(entries, ref) {
94
+ const matches = ref.includes(":") ? entries.filter((entry) => libraryEntryRef(entry) === ref) : entries.filter((entry) => entry.name === ref);
95
+ if (matches.length === 0) throw new Error(`library entry not found: ${ref}`);
96
+ if (matches.length > 1)
97
+ throw new Error(`library entry is ambiguous; use a typed reference: ${matches.map(libraryEntryRef).join(", ")}`);
98
+ return matches[0];
99
+ }
100
+ function filtered(entries, kind) {
101
+ return entries.filter((entry) => kind === void 0 || entry.kind === kind);
102
+ }
103
+ async function runLibraryCommand(argv) {
104
+ let parsed;
105
+ try {
106
+ parsed = parse(argv);
107
+ } catch (error) {
108
+ printError(error instanceof Error ? error.message : String(error));
109
+ return 2;
110
+ }
111
+ if (!parsed.command || parsed.help) {
112
+ process.stdout.write(HELP);
113
+ return parsed.help ? 0 : 2;
114
+ }
115
+ try {
116
+ if (parsed.command === "list" || parsed.command === "search") {
117
+ const discovery = discoverLibrary();
118
+ const query = parsed.command === "search" ? parsed.positional.join(" ").trim().toLowerCase() : "";
119
+ if (parsed.command === "search" && !query) throw new Error("library search requires a query");
120
+ const entries = filtered(discovery.entries, parsed.kind).filter(
121
+ (entry) => !query || entry.name.toLowerCase().includes(query) || entry.description.toLowerCase().includes(query)
122
+ );
123
+ if (parsed.json)
124
+ process.stdout.write(`${JSON.stringify({ entries, diagnostics: discovery.diagnostics }, null, 2)}
125
+ `);
126
+ else
127
+ for (const entry of entries) process.stdout.write(`${libraryEntryRef(entry).padEnd(28)} ${entry.description}
128
+ `);
129
+ return 0;
130
+ }
131
+ if (parsed.command === "add") {
132
+ const ref = parsed.positional[0];
133
+ if (!ref || parsed.positional.length !== 1) throw new Error("library add requires one reference");
134
+ const catalog = parsed.from && parsed.from !== "catalog" ? parsed.from : void 0;
135
+ const discovery = discoverLibrary(catalog ? { catalog } : {});
136
+ let entry;
137
+ try {
138
+ entry = selectEntry(discovery.entries, ref);
139
+ } catch (error) {
140
+ const refusal = ref.includes(":") ? discovery.refusals[ref] : Object.entries(discovery.refusals).find(([key]) => key.endsWith(`:${ref}`))?.[1];
141
+ if (refusal) throw new Error(refusal);
142
+ throw error;
143
+ }
144
+ const requirements = classifyLibraryRequirements(entry, discovery.entries);
145
+ if (requirements.unsatisfied.length > 0 && !parsed.withRequirements) {
146
+ const refs = requirements.unsatisfied.map(libraryEntryRef);
147
+ if (parsed.json)
148
+ process.stdout.write(
149
+ `${JSON.stringify({ ok: false, entry: libraryEntryRef(entry), satisfiedRequirements: requirements.satisfied.map(libraryEntryRef), unresolvedRequirements: refs }, null, 2)}
150
+ `
151
+ );
152
+ else
153
+ process.stderr.write(
154
+ `satisfied requirements: ${requirements.satisfied.length > 0 ? requirements.satisfied.map(libraryEntryRef).join(", ") : "none"}
155
+ unresolved requirements: ${refs.join(", ")}
156
+ pass --with-requirements to install them in dependency order
157
+ `
158
+ );
159
+ return 1;
160
+ }
161
+ const plans = [...parsed.withRequirements ? requirements.unsatisfied : [], entry].map(planLibraryInstall);
162
+ if (parsed.json)
163
+ process.stdout.write(
164
+ `${JSON.stringify({ ok: true, confirmed: parsed.yes, satisfiedRequirements: requirements.satisfied.map(libraryEntryRef), writes: plans.map((plan) => ({ ref: libraryEntryRef(plan.entry), path: plan.path, sha256: plan.sha256 })) }, null, 2)}
165
+ `
166
+ );
167
+ else {
168
+ process.stdout.write("library add plan:\n");
169
+ process.stdout.write(
170
+ ` satisfied requirements: ${requirements.satisfied.length > 0 ? requirements.satisfied.map(libraryEntryRef).join(", ") : "none"}
171
+ `
172
+ );
173
+ for (const plan of plans)
174
+ process.stdout.write(` ${libraryEntryRef(plan.entry)} -> ${plan.path} sha256 ${plan.sha256}
175
+ `);
176
+ }
177
+ if (!parsed.yes) return 0;
178
+ for (const plan of plans) installLibraryPlan(plan);
179
+ if (!parsed.json) printOk(`installed ${plans.length} library entry or entries`);
180
+ return 0;
181
+ }
182
+ if (parsed.command === "use") {
183
+ const kind = parsed.positional[0];
184
+ const name = parsed.positional[1];
185
+ if (!kind || !KINDS.has(kind) || !name || parsed.positional.length !== 2)
186
+ throw new Error("library use requires a kind and name");
187
+ const output = kind === "fleet" ? `clio-coder fleet run ${name}` : kind === "agent" ? `/run ${name}` : kind === "skill" ? `${libraryInstallPath({ kind, name })}
188
+ load it from /skill in the TUI, or ask the model to call context(scope="skills")` : name;
189
+ process.stdout.write(`${output}
190
+ `);
191
+ return 0;
192
+ }
193
+ if (parsed.command === "remote") {
194
+ if (parsed.positional[0] !== "confirm" || !parsed.positional[1] || parsed.positional.length !== 2)
195
+ throw new Error("library remote confirm requires a URL");
196
+ confirmLibraryRemote(parsed.positional[1]);
197
+ printOk("confirmed library remote");
198
+ return 0;
199
+ }
200
+ if (parsed.command === "sync" || parsed.command === "push") {
201
+ await syncLibrary(parsed.command);
202
+ printOk(`library ${parsed.command} complete`);
203
+ return 0;
204
+ }
205
+ throw new Error(`unknown library command: ${parsed.command}`);
206
+ } catch (error) {
207
+ const message = error instanceof Error ? error.message : String(error);
208
+ printError(message);
209
+ if (parsed.json) process.stdout.write(`${JSON.stringify({ ok: false, error: message }, null, 2)}
210
+ `);
211
+ return 1;
212
+ }
213
+ }
214
+ export {
215
+ runLibraryCommand
216
+ };
217
+ //# sourceMappingURL=library-NJAHIGG4.js.map
@@ -0,0 +1,472 @@
1
+ import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
+ import {
3
+ approveMemoryRecord,
4
+ canonicalMemoryRepositoryIdentity,
5
+ loadMemoryRecords,
6
+ memoryAgentIdentity,
7
+ memoryRuntimeIdentity,
8
+ memoryStatus,
9
+ parseTaskMemoryHandoffSnapshot,
10
+ proposeMemoryFromEvidence,
11
+ proposeMemoryPromotion,
12
+ pruneStaleMemory,
13
+ rejectMemoryRecord
14
+ } from "./chunk-6M7VS3J3.js";
15
+ import "./chunk-UUANF5CR.js";
16
+ import "./chunk-6TUKSZVF.js";
17
+ import "./chunk-KZ2H5X4G.js";
18
+ import "./chunk-M4AKACEO.js";
19
+ import "./chunk-RVG5JXAL.js";
20
+ import "./chunk-ZGH7FGS5.js";
21
+ import "./chunk-TSHXZTOQ.js";
22
+ import "./chunk-TXOTCRLG.js";
23
+ import "./chunk-HVDIIIQW.js";
24
+ import "./chunk-W6GROXXM.js";
25
+ import "./chunk-KCMKRQX4.js";
26
+ import "./chunk-WHGPSPT5.js";
27
+ import "./chunk-CEYBNUGC.js";
28
+ import "./chunk-5FR74PWO.js";
29
+ import "./chunk-OBMAI2DP.js";
30
+ import "./chunk-5C77SEEY.js";
31
+ import "./chunk-UND3GU2L.js";
32
+ import "./chunk-CMZWFGD2.js";
33
+ import "./chunk-I4HZDVNP.js";
34
+ import "./chunk-GH5622CP.js";
35
+ import "./chunk-OQE5J4C6.js";
36
+ import "./chunk-GOXNB3AO.js";
37
+ import "./chunk-HWUFFB6L.js";
38
+ import "./chunk-DJNLUABN.js";
39
+ import "./chunk-AOCYTWAV.js";
40
+ import "./chunk-MV3K5QF2.js";
41
+ import "./chunk-UL3WSD3F.js";
42
+ import "./chunk-ODFEOB4F.js";
43
+ import "./chunk-OZNBF4L3.js";
44
+ import "./chunk-4BJ5BYCE.js";
45
+ import "./chunk-ECH6PKUQ.js";
46
+ import "./chunk-6XLNIQDB.js";
47
+ import "./chunk-5B2AEOW5.js";
48
+ import "./chunk-CGKSTWHD.js";
49
+ import "./chunk-XAKHZX5N.js";
50
+ import "./chunk-33YXPOE3.js";
51
+ import "./chunk-465YSENW.js";
52
+ import {
53
+ printError,
54
+ printOk
55
+ } from "./chunk-PPAMZ32Z.js";
56
+ import "./chunk-5TSRNF4G.js";
57
+ import "./chunk-VQNODYQ4.js";
58
+ import "./chunk-CFGTUFWB.js";
59
+ import "./chunk-JRIO5UD2.js";
60
+ import "./chunk-IHXBNWMM.js";
61
+ import "./chunk-GEYXPTRF.js";
62
+ import "./chunk-UHXRNZ2J.js";
63
+ import "./chunk-4DGYLA73.js";
64
+ import "./chunk-LL4KHSZI.js";
65
+ import "./chunk-SST6Z5JA.js";
66
+ import "./chunk-FO5ZOVUY.js";
67
+ import "./chunk-R346GLFC.js";
68
+ import "./chunk-D4MDIG46.js";
69
+ import "./chunk-FQ4SKYE4.js";
70
+ import "./chunk-4ZG3XFUR.js";
71
+ import "./chunk-IKCO5N3L.js";
72
+ import "./chunk-3I7MS7N2.js";
73
+ import "./chunk-FCSXB6T2.js";
74
+ import "./chunk-APJ265NV.js";
75
+ import "./chunk-YXLYO42X.js";
76
+ import {
77
+ clioDataDir
78
+ } from "./chunk-BNAZZHFG.js";
79
+ import "./chunk-6EJMN2Y3.js";
80
+ import "./chunk-WEPFGWHJ.js";
81
+ import "./chunk-ZGVHUX3M.js";
82
+ import "./chunk-OB5HIGJY.js";
83
+ import "./chunk-7CR24IG7.js";
84
+ import "./chunk-IWHMRKLL.js";
85
+ import {
86
+ init_esm_shims
87
+ } from "./chunk-3R73A4XB.js";
88
+
89
+ // src/cli/memory.ts
90
+ init_esm_shims();
91
+ import { readFile, stat } from "node:fs/promises";
92
+ var HELP = `clio-coder memory list
93
+ clio-coder memory propose --from-evidence <evidenceId> [scope options]
94
+ clio-coder memory promote --from-handoff <path> [--entry <id>...] --scope <scope> [scope options]
95
+ clio-coder memory approve <memoryId>
96
+ clio-coder memory reject <memoryId>
97
+ clio-coder memory prune --stale
98
+
99
+ Manage scoped, approved, evidence-linked local memory records.
100
+
101
+ Scope options:
102
+ --scope repo --repository <canonical-absolute-path>
103
+ --scope global --acknowledge-global
104
+ --scope runtime --runtime <source-runtime-id>
105
+ --scope agent --agent <source-agent-id>
106
+
107
+ Omit scope options from propose to preserve evidence-inferred scope. Promotion
108
+ always requires an explicit scope and creates unapproved records for review.
109
+ `;
110
+ function parseMemoryArgs(args) {
111
+ const parsed = { entryIds: [], acknowledgeGlobal: false, stale: false, help: false };
112
+ for (let index = 0; index < args.length; index += 1) {
113
+ const arg = args[index];
114
+ if (arg === void 0) continue;
115
+ if (arg === "--help" || arg === "-h") {
116
+ parsed.help = true;
117
+ continue;
118
+ }
119
+ if (parsed.command === void 0) {
120
+ if (arg === "list" || arg === "propose" || arg === "promote" || arg === "approve" || arg === "reject" || arg === "prune") {
121
+ parsed.command = arg;
122
+ continue;
123
+ }
124
+ throw new Error(`unknown memory command: ${arg}`);
125
+ }
126
+ if (parsed.command === "propose" || parsed.command === "promote") {
127
+ if (arg === "--from-evidence") {
128
+ if (parsed.command !== "propose") throw new Error("--from-evidence is valid only for memory propose");
129
+ const value = args[index + 1];
130
+ if (value === void 0 || value.startsWith("-")) throw new Error("--from-evidence requires an evidence id");
131
+ parsed.evidenceId = value;
132
+ index += 1;
133
+ continue;
134
+ }
135
+ if (arg === "--from-handoff") {
136
+ if (parsed.command !== "promote") throw new Error("--from-handoff is valid only for memory promote");
137
+ const value = requireOptionValue(args, index, "--from-handoff", "a path");
138
+ parsed.handoffPath = value;
139
+ index += 1;
140
+ continue;
141
+ }
142
+ if (arg === "--entry") {
143
+ if (parsed.command !== "promote") throw new Error("--entry is valid only for memory promote");
144
+ parsed.entryIds.push(requireOptionValue(args, index, "--entry", "an entry id"));
145
+ index += 1;
146
+ continue;
147
+ }
148
+ if (arg === "--scope") {
149
+ const value = requireOptionValue(args, index, "--scope", "repo, global, runtime, or agent");
150
+ if (value !== "repo" && value !== "global" && value !== "runtime" && value !== "agent") {
151
+ throw new Error("--scope requires repo, global, runtime, or agent");
152
+ }
153
+ parsed.scope = value;
154
+ index += 1;
155
+ continue;
156
+ }
157
+ if (arg === "--repository") {
158
+ parsed.repositoryPath = requireOptionValue(args, index, "--repository", "a canonical absolute path");
159
+ index += 1;
160
+ continue;
161
+ }
162
+ if (arg === "--acknowledge-global") {
163
+ parsed.acknowledgeGlobal = true;
164
+ continue;
165
+ }
166
+ if (arg === "--runtime") {
167
+ parsed.runtimeId = requireOptionValue(args, index, "--runtime", "a runtime id");
168
+ index += 1;
169
+ continue;
170
+ }
171
+ if (arg === "--agent") {
172
+ parsed.agentId = requireOptionValue(args, index, "--agent", "an agent id");
173
+ index += 1;
174
+ continue;
175
+ }
176
+ throw new Error(`unknown memory ${parsed.command} argument: ${arg}`);
177
+ }
178
+ if (parsed.command === "approve" || parsed.command === "reject") {
179
+ if (parsed.memoryId === void 0 && !arg.startsWith("-")) {
180
+ parsed.memoryId = arg;
181
+ continue;
182
+ }
183
+ throw new Error(`unexpected memory ${parsed.command} argument: ${arg}`);
184
+ }
185
+ if (parsed.command === "prune") {
186
+ if (arg === "--stale") {
187
+ parsed.stale = true;
188
+ continue;
189
+ }
190
+ throw new Error(`unknown memory prune argument: ${arg}`);
191
+ }
192
+ throw new Error(`unexpected memory argument: ${arg}`);
193
+ }
194
+ if (parsed.help) return parsed;
195
+ if (parsed.command === void 0) throw new Error("memory requires list, propose, promote, approve, reject, or prune");
196
+ if (parsed.command === "propose" && parsed.evidenceId === void 0) {
197
+ throw new Error("propose requires --from-evidence <evidenceId>");
198
+ }
199
+ if (parsed.command === "promote" && parsed.handoffPath === void 0) {
200
+ throw new Error("promote requires --from-handoff <path>");
201
+ }
202
+ if ((parsed.command === "approve" || parsed.command === "reject") && parsed.memoryId === void 0) {
203
+ throw new Error(`${parsed.command} requires a memory id`);
204
+ }
205
+ if (parsed.command === "prune" && !parsed.stale) throw new Error("prune requires --stale");
206
+ if (parsed.command === "promote" && parsed.scope === void 0) {
207
+ throw new Error("promote requires --scope <repo|global|runtime|agent>");
208
+ }
209
+ validateScopeArguments(parsed);
210
+ if (parsed.command === "list" && (parsed.evidenceId !== void 0 || parsed.handoffPath !== void 0 || parsed.entryIds.length > 0 || parsed.memoryId !== void 0 || parsed.stale || parsed.scope !== void 0)) {
211
+ throw new Error("list does not accept extra arguments");
212
+ }
213
+ return parsed;
214
+ }
215
+ function requireOptionValue(args, index, option, expected) {
216
+ const value = args[index + 1];
217
+ if (value === void 0 || value.startsWith("-")) throw new Error(`${option} requires ${expected}`);
218
+ return value;
219
+ }
220
+ function validateScopeArguments(parsed) {
221
+ const hasIdentityOption = parsed.repositoryPath !== void 0 || parsed.acknowledgeGlobal || parsed.runtimeId !== void 0 || parsed.agentId !== void 0;
222
+ if (parsed.scope === void 0) {
223
+ if (hasIdentityOption) throw new Error("scope identity options require --scope");
224
+ return;
225
+ }
226
+ if (parsed.scope === "repo") {
227
+ if (parsed.repositoryPath === void 0)
228
+ throw new Error("repo scope requires --repository <canonical-absolute-path>");
229
+ if (parsed.acknowledgeGlobal || parsed.runtimeId !== void 0 || parsed.agentId !== void 0) {
230
+ throw new Error("repo scope accepts only --repository");
231
+ }
232
+ return;
233
+ }
234
+ if (parsed.scope === "global") {
235
+ if (!parsed.acknowledgeGlobal) throw new Error("global scope requires --acknowledge-global");
236
+ if (parsed.repositoryPath !== void 0 || parsed.runtimeId !== void 0 || parsed.agentId !== void 0) {
237
+ throw new Error("global scope accepts only --acknowledge-global");
238
+ }
239
+ return;
240
+ }
241
+ if (parsed.scope === "runtime") {
242
+ if (parsed.runtimeId === void 0) throw new Error("runtime scope requires --runtime <source-runtime-id>");
243
+ if (parsed.repositoryPath !== void 0 || parsed.acknowledgeGlobal || parsed.agentId !== void 0) {
244
+ throw new Error("runtime scope accepts only --runtime");
245
+ }
246
+ return;
247
+ }
248
+ if (parsed.agentId === void 0) throw new Error("agent scope requires --agent <source-agent-id>");
249
+ if (parsed.repositoryPath !== void 0 || parsed.acknowledgeGlobal || parsed.runtimeId !== void 0) {
250
+ throw new Error("agent scope accepts only --agent");
251
+ }
252
+ }
253
+ async function runMemoryCommand(args) {
254
+ let parsed;
255
+ try {
256
+ parsed = parseMemoryArgs(args);
257
+ } catch (error) {
258
+ printError(error instanceof Error ? error.message : String(error));
259
+ process.stderr.write(HELP);
260
+ return 2;
261
+ }
262
+ if (parsed.help) {
263
+ process.stdout.write(HELP);
264
+ return 0;
265
+ }
266
+ const dataDir = clioDataDir();
267
+ try {
268
+ if (parsed.command === "list") {
269
+ renderMemoryList(await loadMemoryRecords(dataDir));
270
+ return 0;
271
+ }
272
+ if (parsed.command === "propose") {
273
+ const evidenceId = parsed.evidenceId;
274
+ if (evidenceId === void 0) {
275
+ printError("propose requires --from-evidence <evidenceId>");
276
+ return 2;
277
+ }
278
+ const result = await proposeMemoryFromEvidence(dataDir, evidenceId, scopeSelection(parsed));
279
+ renderProposal(result.record, result.created);
280
+ return 0;
281
+ }
282
+ if (parsed.command === "promote") {
283
+ const handoffPath = parsed.handoffPath;
284
+ const selection = scopeSelection(parsed);
285
+ if (handoffPath === void 0 || selection === void 0) {
286
+ printError("promote requires a handoff and explicit scope");
287
+ return 2;
288
+ }
289
+ const snapshot = await readReviewedHandoff(handoffPath);
290
+ const entries = selectHandoffEntries(snapshot, parsed.entryIds);
291
+ for (const entry of entries) {
292
+ const result = await proposeMemoryPromotion(
293
+ dataDir,
294
+ {
295
+ kind: "handoff-snapshot",
296
+ sessionId: snapshot.source.sessionId,
297
+ evidenceRefs: snapshot.source.evidenceRefs,
298
+ runtimeIds: snapshot.source.runtimeIds,
299
+ agentIds: snapshot.source.agentIds,
300
+ entry: handoffTaskEntry(entry),
301
+ redaction: {
302
+ replacementCount: snapshot.redaction.replacementCount,
303
+ sourceFields: snapshot.redaction.sourceFields
304
+ }
305
+ },
306
+ selection
307
+ );
308
+ renderProposal(result.record, result.created);
309
+ }
310
+ return 0;
311
+ }
312
+ if (parsed.command === "approve") {
313
+ const memoryId = parsed.memoryId;
314
+ if (memoryId === void 0) {
315
+ printError("approve requires a memory id");
316
+ return 2;
317
+ }
318
+ const record = await approveMemoryRecord(dataDir, memoryId);
319
+ printOk(`approved ${record.id}`);
320
+ return 0;
321
+ }
322
+ if (parsed.command === "reject") {
323
+ const memoryId = parsed.memoryId;
324
+ if (memoryId === void 0) {
325
+ printError("reject requires a memory id");
326
+ return 2;
327
+ }
328
+ const record = await rejectMemoryRecord(dataDir, memoryId);
329
+ printOk(`rejected ${record.id}`);
330
+ return 0;
331
+ }
332
+ if (parsed.command === "prune") {
333
+ const pruned = await pruneStaleMemory(dataDir);
334
+ printOk(`pruned ${pruned.length} stale memory record${pruned.length === 1 ? "" : "s"}`);
335
+ return 0;
336
+ }
337
+ printError("memory requires list, propose, promote, approve, reject, or prune");
338
+ return 2;
339
+ } catch (error) {
340
+ printError(error instanceof Error ? error.message : String(error));
341
+ return 1;
342
+ }
343
+ }
344
+ function scopeSelection(parsed) {
345
+ if (parsed.scope === void 0) return void 0;
346
+ if (parsed.scope === "repo") {
347
+ const repositoryPath = parsed.repositoryPath;
348
+ if (repositoryPath === void 0) throw new Error("repo scope requires --repository");
349
+ const repository = canonicalMemoryRepositoryIdentity(repositoryPath);
350
+ if (repository === null || repository.key !== repositoryPath) {
351
+ throw new Error("--repository must be an existing canonical absolute repository path");
352
+ }
353
+ return { scope: "repo", repository };
354
+ }
355
+ if (parsed.scope === "global") {
356
+ if (!parsed.acknowledgeGlobal) throw new Error("global scope requires --acknowledge-global");
357
+ return { scope: "global", acknowledgeGlobal: true };
358
+ }
359
+ if (parsed.scope === "runtime") {
360
+ if (parsed.runtimeId === void 0) throw new Error("runtime scope requires --runtime");
361
+ return { scope: "runtime", runtime: memoryRuntimeIdentity(parsed.runtimeId) };
362
+ }
363
+ if (parsed.agentId === void 0) throw new Error("agent scope requires --agent");
364
+ return { scope: "agent", agent: memoryAgentIdentity(parsed.agentId) };
365
+ }
366
+ async function readReviewedHandoff(path) {
367
+ const info = await stat(path);
368
+ if (!info.isFile()) throw new Error(`task-memory handoff is not a file: ${path}`);
369
+ if (info.size > 1e6) throw new Error(`task-memory handoff exceeds 1000000 bytes: ${path}`);
370
+ const snapshot = parseTaskMemoryHandoffSnapshot(await readFile(path, "utf8"));
371
+ if (snapshot === null) throw new Error(`task-memory handoff is invalid: ${path}`);
372
+ if (snapshot.version !== 2) {
373
+ throw new Error("task-memory handoff lacks source session and evidence provenance; create a new redacted handoff");
374
+ }
375
+ return snapshot;
376
+ }
377
+ function selectHandoffEntries(snapshot, entryIds) {
378
+ const entries = [
379
+ ...snapshot.knowledge.map((entry) => ({ kind: "knowledge", entry })),
380
+ ...snapshot.procedural.map((entry) => ({ kind: "procedural", entry }))
381
+ ];
382
+ if (entries.length === 0) throw new Error("task-memory handoff contains no promotable entries");
383
+ if (entryIds.length === 0) return entries;
384
+ const requested = new Set(entryIds);
385
+ const selected = entries.filter(({ entry }) => requested.has(entry.id));
386
+ const missing = [...requested].filter((id) => !selected.some(({ entry }) => entry.id === id));
387
+ if (missing.length > 0) throw new Error(`task-memory handoff entry not found: ${missing.join(", ")}`);
388
+ return selected;
389
+ }
390
+ function handoffTaskEntry(selected) {
391
+ const createdAt = selected.entry.createdAt;
392
+ const lastTouchedAt = selected.entry.lastTouchedAt;
393
+ if (createdAt === void 0 || lastTouchedAt === void 0) {
394
+ throw new Error(`task-memory handoff entry lacks timestamps: ${selected.entry.id}`);
395
+ }
396
+ return {
397
+ id: selected.entry.id,
398
+ kind: selected.kind,
399
+ content: selected.entry.content,
400
+ createdAt,
401
+ lastTouchedAt,
402
+ injectionCount: selected.entry.injectionCount
403
+ };
404
+ }
405
+ function renderProposal(record, created) {
406
+ process.stdout.write(`memory: ${record.id}
407
+ `);
408
+ process.stdout.write(`status: ${created ? "proposed" : memoryStatus(record)}
409
+ `);
410
+ process.stdout.write(`scope: ${record.scope}
411
+ `);
412
+ if (record.repository !== void 0) process.stdout.write(`repository: ${record.repository.key}
413
+ `);
414
+ if (record.runtime !== void 0) process.stdout.write(`runtime: ${record.runtime.key}
415
+ `);
416
+ if (record.agent !== void 0) process.stdout.write(`agent: ${record.agent.key}
417
+ `);
418
+ process.stdout.write(`key: ${record.key}
419
+ `);
420
+ process.stdout.write(`evidence: ${record.evidenceRefs.join(", ")}
421
+ `);
422
+ process.stdout.write(`confidence: ${record.confidence.toFixed(2)}
423
+ `);
424
+ process.stdout.write(`lesson: ${record.lesson}
425
+ `);
426
+ if (record.provenance !== void 0) {
427
+ process.stdout.write(`source: ${record.provenance.sourceKind}
428
+ `);
429
+ if (record.provenance.sourceSessionId !== void 0) {
430
+ process.stdout.write(`source-session: ${record.provenance.sourceSessionId}
431
+ `);
432
+ }
433
+ if (record.provenance.sourceEntryId !== void 0) {
434
+ process.stdout.write(`source-entry: ${record.provenance.sourceEntryId}
435
+ `);
436
+ }
437
+ if (record.provenance.redaction !== void 0) {
438
+ process.stdout.write(
439
+ `redaction: ${record.provenance.redaction.replacementCount} replacement${record.provenance.redaction.replacementCount === 1 ? "" : "s"}; fields=${record.provenance.redaction.sourceFields.join(",") || "none"}
440
+ `
441
+ );
442
+ }
443
+ }
444
+ process.stdout.write(`review: clio-coder memory approve ${record.id}
445
+ `);
446
+ }
447
+ function renderMemoryList(records) {
448
+ process.stdout.write(`${records.length} memory record${records.length === 1 ? "" : "s"}
449
+ `);
450
+ if (records.length === 0) return;
451
+ process.stdout.write("\n");
452
+ for (const record of records) {
453
+ process.stdout.write(
454
+ [
455
+ record.id.padEnd(21),
456
+ memoryStatus(record).padEnd(10),
457
+ record.scope.padEnd(13),
458
+ `confidence=${record.confidence.toFixed(2)}`.padEnd(16),
459
+ `evidence=${record.evidenceRefs.join(",")}`
460
+ ].join("")
461
+ );
462
+ process.stdout.write("\n");
463
+ process.stdout.write(` key: ${record.key}
464
+ `);
465
+ process.stdout.write(` lesson: ${record.lesson}
466
+ `);
467
+ }
468
+ }
469
+ export {
470
+ runMemoryCommand
471
+ };
472
+ //# sourceMappingURL=memory-OG6HOYKM.js.map