rovecode 0.3.3 → 0.4.0-beta.2

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 (491) hide show
  1. package/CHANGELOG.md +512 -0
  2. package/README.md +33 -48
  3. package/bin/rovecode.js +24 -0
  4. package/dist/cli/app-dybnr56b.js +2 -0
  5. package/dist/cli/ask-user-p8hq4xgj.js +2 -0
  6. package/dist/cli/auth-login-ewpgw5sm.js +2 -0
  7. package/dist/cli/auth-m8p9grty.js +2 -0
  8. package/dist/cli/bench-xv3ypwev.js +9 -0
  9. package/dist/cli/catalog-737wb2s0.js +2 -0
  10. package/dist/cli/cli-arhg40m0.js +2 -0
  11. package/dist/cli/client-cf2pxx8q.js +2 -0
  12. package/dist/cli/commands-3p7e4xxs.js +2 -0
  13. package/dist/cli/connect-3q93d7cb.js +2 -0
  14. package/dist/cli/context-cmd-eqxmxhzq.js +2 -0
  15. package/dist/cli/context-report-hbw9zfes.js +2 -0
  16. package/dist/cli/count-remote-mby98cd0.js +2 -0
  17. package/dist/cli/design-122y0axd.js +2 -0
  18. package/dist/cli/dispatch-b4egzvvh.js +2 -0
  19. package/dist/cli/doctor-x4jkv72e.js +3 -0
  20. package/dist/cli/executor-ftvg6tsy.js +2 -0
  21. package/dist/cli/export-pdgdhkch.js +2 -0
  22. package/dist/cli/files-cez9a96p.js +2 -0
  23. package/dist/cli/gauntlet-r3xxaszc.js +2 -0
  24. package/dist/cli/gauntlet-runner-r515m7kk.js +10 -0
  25. package/dist/cli/gauntlet-wave3-bnkjk2v2.js +5 -0
  26. package/dist/cli/gauntlet-wave4-acs9s60q.js +14 -0
  27. package/dist/cli/hashline-ewg5hbe3.js +2 -0
  28. package/dist/cli/http-n0kehsk8.js +5 -0
  29. package/dist/cli/index-z5qt1s76.js +2 -0
  30. package/dist/cli/install-80mp63kx.js +2 -0
  31. package/dist/cli/loop-12twjcat.js +2 -0
  32. package/dist/cli/main-01pv9206.js +4 -0
  33. package/dist/cli/main-0jys2ccn.js +3 -0
  34. package/dist/cli/main-1ztz6fkj.js +10 -0
  35. package/dist/cli/main-23q7cmww.js +9 -0
  36. package/dist/cli/main-2rzbexn2.js +3 -0
  37. package/dist/cli/main-2wyax8k9.js +9 -0
  38. package/dist/cli/main-2yeveeve.js +6 -0
  39. package/dist/cli/main-2z3dek0b.js +3 -0
  40. package/dist/cli/main-2zgsknth.js +3 -0
  41. package/dist/cli/main-45ejth3a.js +4 -0
  42. package/dist/cli/main-45rn3trk.js +22 -0
  43. package/dist/cli/main-4p4e2w7x.js +4 -0
  44. package/dist/cli/main-4y0tnfpa.js +16 -0
  45. package/dist/cli/main-5py0rkmc.js +4 -0
  46. package/dist/cli/main-6dtqmbt6.js +7 -0
  47. package/dist/cli/main-6h9x282m.js +4 -0
  48. package/dist/cli/main-6vjeds42.js +3 -0
  49. package/dist/cli/main-78gq4bt9.js +6 -0
  50. package/dist/cli/main-7jd5vh3x.js +4 -0
  51. package/dist/cli/main-7kt6r53y.js +4 -0
  52. package/dist/cli/main-8c1tbazx.js +58 -0
  53. package/dist/cli/main-9a9rnh47.js +19 -0
  54. package/dist/cli/main-9ht36z12.js +3 -0
  55. package/dist/cli/main-a2yfvcy9.js +7 -0
  56. package/dist/cli/main-a3f51n0x.js +5 -0
  57. package/dist/cli/main-b8zq261k.js +3 -0
  58. package/dist/cli/main-bxtvnf6d.js +13 -0
  59. package/dist/cli/main-edxc3yzt.js +4 -0
  60. package/dist/cli/main-evgz4mp5.js +21 -0
  61. package/dist/cli/main-f33fc5je.js +9 -0
  62. package/dist/cli/main-fvnpq46y.js +12 -0
  63. package/dist/cli/main-gbbty4d4.js +3 -0
  64. package/dist/cli/main-gth53dnt.js +25 -0
  65. package/dist/cli/main-hqbz10aw.js +9 -0
  66. package/dist/cli/main-hrrvcfan.js +38 -0
  67. package/dist/cli/main-hzwtsb2m.js +5 -0
  68. package/dist/cli/main-j7ttv0sd.js +34 -0
  69. package/dist/cli/main-jak598k9.js +5 -0
  70. package/dist/cli/main-kba6zeyd.js +6 -0
  71. package/dist/cli/main-kwwsz6rq.js +3 -0
  72. package/dist/cli/main-m8vm17zq.js +3 -0
  73. package/dist/cli/main-mg4f96e1.js +3 -0
  74. package/dist/cli/main-mg9b20ac.js +18 -0
  75. package/dist/cli/main-mgb9ccnx.js +3 -0
  76. package/dist/cli/main-mjt2p7aj.js +3 -0
  77. package/dist/cli/main-n6qrdbmy.js +3 -0
  78. package/dist/cli/main-na7wse0x.js +5 -0
  79. package/dist/cli/main-nqveez48.js +4 -0
  80. package/dist/cli/main-ntqef02r.js +10 -0
  81. package/dist/cli/main-nvc3yjay.js +136 -0
  82. package/dist/cli/main-p0cfn6nr.js +16 -0
  83. package/dist/cli/main-qj2djy17.js +19 -0
  84. package/dist/cli/main-qsevpgsv.js +3 -0
  85. package/dist/cli/main-qvarybsp.js +3 -0
  86. package/dist/cli/main-rebtt91r.js +5 -0
  87. package/dist/cli/main-rpg7h8mb.js +3 -0
  88. package/dist/cli/main-rsy72qmw.js +15 -0
  89. package/dist/cli/main-rvetps99.js +18 -0
  90. package/dist/cli/main-s4bb0jav.js +3 -0
  91. package/dist/cli/main-s9v8k74e.js +3 -0
  92. package/dist/cli/main-tjvwmscs.js +3 -0
  93. package/dist/cli/main-tkgarpjj.js +4 -0
  94. package/dist/cli/main-v8y60bb2.js +3 -0
  95. package/dist/cli/main-vhrrq337.js +3 -0
  96. package/dist/cli/main-vp2dfb7s.js +4 -0
  97. package/dist/cli/main-vqbr22sz.js +8 -0
  98. package/dist/cli/main-vxnwe5xx.js +18 -0
  99. package/dist/cli/main-wgph00xf.js +5 -0
  100. package/dist/cli/main-wk2csfnj.js +5 -0
  101. package/dist/cli/main-wm997zjx.js +3 -0
  102. package/dist/cli/main-wpkyraxh.js +3 -0
  103. package/dist/cli/main-wqt32p5x.js +4 -0
  104. package/dist/cli/main-x9ct6y1a.js +3 -0
  105. package/dist/cli/main-xfekqh9m.js +7 -0
  106. package/dist/cli/main-xt9zc3n6.js +7 -0
  107. package/dist/cli/main-xx2z3zh5.js +4 -0
  108. package/dist/cli/main-y5c82rxr.js +3 -0
  109. package/dist/cli/main-yrjt2sqt.js +14 -0
  110. package/dist/cli/main-ys6zj3yr.js +3 -0
  111. package/dist/cli/main-ywbxshqc.js +8 -0
  112. package/dist/cli/main-z13755t8.js +25 -0
  113. package/dist/cli/main-zc7pyrbj.js +4 -0
  114. package/dist/cli/main.js +279 -0
  115. package/dist/cli/market-cmd-bm5xvn9f.js +5 -0
  116. package/dist/cli/mcp-login-bthtfpt7.js +2 -0
  117. package/dist/cli/mcp-market-cmd-mbeshfyd.js +2 -0
  118. package/dist/cli/notify-54v5z9dz.js +2 -0
  119. package/dist/cli/oauth-g5gme95c.js +2 -0
  120. package/dist/cli/output-satndjap.js +16 -0
  121. package/dist/cli/profiles-sfhpbq3m.js +2 -0
  122. package/dist/cli/provider-config-hv3xtdt4.js +2 -0
  123. package/dist/cli/provider-kwzq6g84.js +2 -0
  124. package/dist/cli/registry-fh0hdnyn.js +2 -0
  125. package/dist/cli/registry-y1y8e94r.js +2 -0
  126. package/dist/cli/repl-t4z03mqq.js +11 -0
  127. package/dist/cli/resume-fqt4chg8.js +2 -0
  128. package/dist/cli/run-flags-rysbag9t.js +2 -0
  129. package/dist/cli/runtime-j19fjbsa.js +2 -0
  130. package/dist/cli/sandbox-config-g4qxd7y5.js +2 -0
  131. package/dist/cli/server-r0b6bksk.js +5 -0
  132. package/dist/cli/session-arg-txmn5g4x.js +2 -0
  133. package/dist/cli/session-ed250d9j.js +2 -0
  134. package/dist/cli/sessions-cmd-adw7svfn.js +7 -0
  135. package/dist/cli/settings-y9rzcqx8.js +2 -0
  136. package/dist/cli/setup-jmbr11j0.js +2 -0
  137. package/dist/cli/sextant-smoke-tcth0vea.js +5 -0
  138. package/dist/cli/skills-cmd-zbdy99v6.js +2 -0
  139. package/dist/cli/smoke-1bg937kx.js +8 -0
  140. package/dist/cli/start-chat-p01cdks3.js +12 -0
  141. package/dist/cli/stream-4wmyaypz.js +2 -0
  142. package/dist/cli/task-eg4s093s.js +2 -0
  143. package/dist/cli/tasks-12v9rr9k.js +2 -0
  144. package/dist/cli/thinking-a5ngvqyh.js +2 -0
  145. package/dist/cli/todo-1wxpcecx.js +2 -0
  146. package/dist/cli/tools-2ftsya7w.js +2 -0
  147. package/dist/cli/tools-x1tj4fxm.js +2 -0
  148. package/dist/cli/trust-cmd-hccxehzb.js +2 -0
  149. package/dist/cli/update-check-ygt3vd7m.js +2 -0
  150. package/dist/cli/update-cmd-v23qhr8c.js +2 -0
  151. package/dist/cli/voice-g1gtck92.js +2 -0
  152. package/dist/cli/webfetch-0nnrjgb5.js +2 -0
  153. package/dist/cli/websearch-f0vr2p7d.js +2 -0
  154. package/dist/cli/workspace-9rq1w4ta.js +2 -0
  155. package/dist/lib/index.js +62 -0
  156. package/dist/lib/models-index.json +1 -0
  157. package/dist/lib/plugins.js +6 -0
  158. package/dist/lib/providers.js +17 -0
  159. package/dist/lib/public-api.js +20 -0
  160. package/dist/rovecode.exe +4 -0
  161. package/package.json +83 -72
  162. package/bin/rovecode.ts +0 -21
  163. package/src/acp/server.ts +0 -374
  164. package/src/cli/auth-login.ts +0 -122
  165. package/src/cli/connect.ts +0 -244
  166. package/src/cli/context-cmd.ts +0 -199
  167. package/src/cli/dispatch.ts +0 -82
  168. package/src/cli/doctor.ts +0 -362
  169. package/src/cli/export.ts +0 -276
  170. package/src/cli/help.ts +0 -293
  171. package/src/cli/is-tui-invocation.ts +0 -8
  172. package/src/cli/main.ts +0 -583
  173. package/src/cli/market-cmd.ts +0 -658
  174. package/src/cli/mcp-login.ts +0 -141
  175. package/src/cli/mcp-market-cmd.ts +0 -302
  176. package/src/cli/output.ts +0 -382
  177. package/src/cli/repl.ts +0 -250
  178. package/src/cli/repomap-root.ts +0 -14
  179. package/src/cli/resume.ts +0 -57
  180. package/src/cli/run-flags.ts +0 -43
  181. package/src/cli/run-limits.ts +0 -78
  182. package/src/cli/runtime.ts +0 -931
  183. package/src/cli/session-arg.ts +0 -30
  184. package/src/cli/sessions-cmd.ts +0 -145
  185. package/src/cli/setup.ts +0 -153
  186. package/src/cli/skills-cmd.ts +0 -194
  187. package/src/cli/start-chat.ts +0 -65
  188. package/src/cli/trust-cmd.ts +0 -52
  189. package/src/coding/bash.ts +0 -148
  190. package/src/coding/checkpoints.ts +0 -327
  191. package/src/coding/diff.ts +0 -138
  192. package/src/coding/files.ts +0 -341
  193. package/src/coding/hashline.ts +0 -274
  194. package/src/coding/lsp-gate.ts +0 -254
  195. package/src/coding/lsp-servers.ts +0 -147
  196. package/src/coding/lsp.ts +0 -283
  197. package/src/coding/repomap-cache.ts +0 -99
  198. package/src/coding/repomap-files.ts +0 -192
  199. package/src/coding/repomap.ts +0 -481
  200. package/src/core/agents.ts +0 -255
  201. package/src/core/compaction.ts +0 -259
  202. package/src/core/config.ts +0 -289
  203. package/src/core/context-report.ts +0 -228
  204. package/src/core/context.ts +0 -60
  205. package/src/core/count-remote.ts +0 -107
  206. package/src/core/execpolicy-rules.ts +0 -196
  207. package/src/core/execpolicy.ts +0 -385
  208. package/src/core/executor.ts +0 -454
  209. package/src/core/guardrails.ts +0 -400
  210. package/src/core/hooks.ts +0 -411
  211. package/src/core/images.ts +0 -230
  212. package/src/core/intro.ts +0 -266
  213. package/src/core/loop.ts +0 -567
  214. package/src/core/modes.ts +0 -372
  215. package/src/core/orchestrator.ts +0 -245
  216. package/src/core/proc-group.ts +0 -48
  217. package/src/core/project-trust.ts +0 -98
  218. package/src/core/reflection.ts +0 -165
  219. package/src/core/sandbox-config.ts +0 -186
  220. package/src/core/session-id.ts +0 -24
  221. package/src/core/session-images.ts +0 -73
  222. package/src/core/session-ops.ts +0 -183
  223. package/src/core/session-text.ts +0 -29
  224. package/src/core/session.ts +0 -469
  225. package/src/core/settings.ts +0 -170
  226. package/src/core/tasks.ts +0 -646
  227. package/src/core/token-scale.ts +0 -108
  228. package/src/core/tools.ts +0 -309
  229. package/src/core/trust.ts +0 -104
  230. package/src/core/types.ts +0 -330
  231. package/src/core/update-check.ts +0 -171
  232. package/src/core/usage.ts +0 -204
  233. package/src/core/validate.ts +0 -121
  234. package/src/core/verify-gate.ts +0 -159
  235. package/src/core/verify.ts +0 -236
  236. package/src/core/voice.ts +0 -158
  237. package/src/core/win-job.ts +0 -183
  238. package/src/core/workspace.ts +0 -184
  239. package/src/design/audit.ts +0 -797
  240. package/src/design/direction.ts +0 -190
  241. package/src/design/rules.ts +0 -157
  242. package/src/eval/bench.ts +0 -150
  243. package/src/eval/gauntlet-runner.ts +0 -215
  244. package/src/eval/gauntlet-support.ts +0 -84
  245. package/src/eval/gauntlet-wave3.ts +0 -269
  246. package/src/eval/gauntlet-wave4.ts +0 -217
  247. package/src/eval/gauntlet.ts +0 -253
  248. package/src/index.ts +0 -17
  249. package/src/lanes/agy.ts +0 -95
  250. package/src/lanes/approval.ts +0 -24
  251. package/src/lanes/claude.ts +0 -129
  252. package/src/lanes/codex.ts +0 -127
  253. package/src/lanes/events.ts +0 -130
  254. package/src/lanes/job.ts +0 -142
  255. package/src/lanes/opencode.ts +0 -122
  256. package/src/lanes/process.ts +0 -184
  257. package/src/lanes/progress.ts +0 -183
  258. package/src/lanes/registry.ts +0 -178
  259. package/src/lanes/runner.ts +0 -124
  260. package/src/lanes/types.ts +0 -112
  261. package/src/market/catalogs/mcp-docs.json +0 -111
  262. package/src/market/catalogs/plugins.json +0 -111
  263. package/src/market/catalogs/skills.json +0 -478
  264. package/src/market/clone.ts +0 -72
  265. package/src/market/context-cost.ts +0 -121
  266. package/src/market/digest.ts +0 -106
  267. package/src/market/index.ts +0 -22
  268. package/src/market/install.ts +0 -578
  269. package/src/market/manifest.ts +0 -187
  270. package/src/market/prereq.ts +0 -145
  271. package/src/market/registry.ts +0 -363
  272. package/src/market/resolve.ts +0 -111
  273. package/src/market/types.ts +0 -236
  274. package/src/market/validate.ts +0 -227
  275. package/src/mcp/client.ts +0 -449
  276. package/src/mcp/config.ts +0 -252
  277. package/src/mcp/local-package.ts +0 -211
  278. package/src/mcp/market-catalog.ts +0 -84
  279. package/src/mcp/market-install.ts +0 -289
  280. package/src/mcp/market.ts +0 -362
  281. package/src/mcp/oauth.ts +0 -251
  282. package/src/mcp/prompts-resources.ts +0 -249
  283. package/src/mcp/shared.ts +0 -149
  284. package/src/mcp/status.ts +0 -67
  285. package/src/mcp/tools.ts +0 -275
  286. package/src/mcp/transport.ts +0 -122
  287. package/src/mcp/trust.ts +0 -25
  288. package/src/memory/blocks.ts +0 -278
  289. package/src/memory/recall.ts +0 -355
  290. package/src/memory/scope.ts +0 -182
  291. package/src/memory/store.ts +0 -105
  292. package/src/memory/tools.ts +0 -99
  293. package/src/plugins/cli.ts +0 -119
  294. package/src/plugins/discover.ts +0 -108
  295. package/src/plugins/index.ts +0 -50
  296. package/src/plugins/install.ts +0 -184
  297. package/src/plugins/load.ts +0 -124
  298. package/src/plugins/manifest.ts +0 -92
  299. package/src/plugins/state.ts +0 -83
  300. package/src/providers/auth.ts +0 -408
  301. package/src/providers/cache.ts +0 -223
  302. package/src/providers/catalog-local.ts +0 -160
  303. package/src/providers/catalog.ts +0 -421
  304. package/src/providers/middleware-context.ts +0 -86
  305. package/src/providers/middleware.ts +0 -373
  306. package/src/providers/model-list.ts +0 -23
  307. package/src/providers/oauth/common.ts +0 -105
  308. package/src/providers/oauth/device-code.ts +0 -107
  309. package/src/providers/oauth/github-copilot.ts +0 -146
  310. package/src/providers/oauth/loopback.ts +0 -158
  311. package/src/providers/oauth/openai.ts +0 -163
  312. package/src/providers/oauth/openrouter.ts +0 -89
  313. package/src/providers/oauth/pkce.ts +0 -45
  314. package/src/providers/oauth/registry.ts +0 -39
  315. package/src/providers/oauth/seam.ts +0 -89
  316. package/src/providers/profile-glm53.ts +0 -111
  317. package/src/providers/profile-sonnet5-persona.ts +0 -65
  318. package/src/providers/profile-sonnet5-voice.ts +0 -23
  319. package/src/providers/profiles.ts +0 -156
  320. package/src/providers/provider-config.ts +0 -311
  321. package/src/providers/registry.ts +0 -333
  322. package/src/providers/responses.ts +0 -209
  323. package/src/providers/retry.ts +0 -234
  324. package/src/providers/router.ts +0 -294
  325. package/src/providers/sse.ts +0 -26
  326. package/src/providers/stream-errors.ts +0 -117
  327. package/src/providers/stream.ts +0 -566
  328. package/src/providers/thinking.ts +0 -189
  329. package/src/providers/wire-messages.ts +0 -129
  330. package/src/providers/wire-responses.ts +0 -79
  331. package/src/providers/wire-select.ts +0 -53
  332. package/src/server/http.ts +0 -291
  333. package/src/server/openapi.ts +0 -246
  334. package/src/sextant/card-hits.ts +0 -102
  335. package/src/sextant/card-keys.ts +0 -55
  336. package/src/sextant/context-source.ts +0 -157
  337. package/src/sextant/crew-cards.ts +0 -350
  338. package/src/sextant/draw-agents.ts +0 -273
  339. package/src/sextant/draw-code.ts +0 -388
  340. package/src/sextant/draw-context.ts +0 -222
  341. package/src/sextant/draw-frame.ts +0 -164
  342. package/src/sextant/draw-market.ts +0 -573
  343. package/src/sextant/draw-messages.ts +0 -386
  344. package/src/sextant/draw-pet.ts +0 -230
  345. package/src/sextant/draw-plan.ts +0 -187
  346. package/src/sextant/draw-tabs.ts +0 -85
  347. package/src/sextant/draw-util.ts +0 -65
  348. package/src/sextant/draw-wizard.ts +0 -378
  349. package/src/sextant/engine.ts +0 -230
  350. package/src/sextant/frame-hits.ts +0 -25
  351. package/src/sextant/frame.ts +0 -101
  352. package/src/sextant/git-status.ts +0 -197
  353. package/src/sextant/grid.ts +0 -59
  354. package/src/sextant/input.ts +0 -119
  355. package/src/sextant/keys.ts +0 -521
  356. package/src/sextant/layout.ts +0 -86
  357. package/src/sextant/local-commands.ts +0 -169
  358. package/src/sextant/market-source.ts +0 -287
  359. package/src/sextant/mentions.ts +0 -200
  360. package/src/sextant/message-hits.ts +0 -26
  361. package/src/sextant/model.ts +0 -387
  362. package/src/sextant/overlays.ts +0 -456
  363. package/src/sextant/panel-hits.ts +0 -38
  364. package/src/sextant/pet.ts +0 -399
  365. package/src/sextant/screen.ts +0 -324
  366. package/src/sextant/scroll-hits.ts +0 -66
  367. package/src/sextant/scrollbar.ts +0 -82
  368. package/src/sextant/sextant-bridge.ts +0 -174
  369. package/src/sextant/sextant-cards.ts +0 -142
  370. package/src/sextant/sextant-diff-base.ts +0 -63
  371. package/src/sextant/sextant-files.ts +0 -154
  372. package/src/sextant/sextant-frame-loop.ts +0 -335
  373. package/src/sextant/sextant-renderer.ts +0 -574
  374. package/src/sextant/sextant-repo.ts +0 -140
  375. package/src/sextant/theme.ts +0 -66
  376. package/src/sextant/tool-rows.ts +0 -189
  377. package/src/sextant/types.ts +0 -493
  378. package/src/skills/index.ts +0 -387
  379. package/src/skills/pack.ts +0 -220
  380. package/src/skills/spec.ts +0 -162
  381. package/src/skills/tools.ts +0 -69
  382. package/src/skills/versioned.ts +0 -227
  383. package/src/telemetry/otel-export.ts +0 -122
  384. package/src/telemetry/otel-lanes.ts +0 -89
  385. package/src/telemetry/otel-logs.ts +0 -131
  386. package/src/telemetry/otel-metrics.ts +0 -136
  387. package/src/telemetry/otel.ts +0 -397
  388. package/src/telemetry/otlp.ts +0 -76
  389. package/src/tools/ask-user.ts +0 -156
  390. package/src/tools/bash-bg.ts +0 -94
  391. package/src/tools/bash-jobs.ts +0 -237
  392. package/src/tools/design.ts +0 -151
  393. package/src/tools/evalcell.ts +0 -338
  394. package/src/tools/html-text.ts +0 -139
  395. package/src/tools/provider.ts +0 -149
  396. package/src/tools/task.ts +0 -250
  397. package/src/tools/todo.ts +0 -320
  398. package/src/tools/webfetch.ts +0 -332
  399. package/src/tools/websearch.ts +0 -359
  400. package/src/tui/agents-cmd.ts +0 -41
  401. package/src/tui/app.ts +0 -749
  402. package/src/tui/attach.ts +0 -127
  403. package/src/tui/boot-notes.ts +0 -41
  404. package/src/tui/builtin-prompts.ts +0 -59
  405. package/src/tui/checkpoints-cmd.ts +0 -70
  406. package/src/tui/clipboard-image.ts +0 -81
  407. package/src/tui/clipboard.ts +0 -78
  408. package/src/tui/commands.ts +0 -283
  409. package/src/tui/config-view.ts +0 -53
  410. package/src/tui/context-cmds.ts +0 -282
  411. package/src/tui/cost.ts +0 -108
  412. package/src/tui/crash-guard.ts +0 -173
  413. package/src/tui/focus-terminal.ts +0 -34
  414. package/src/tui/git-cmds.ts +0 -273
  415. package/src/tui/git-plain.ts +0 -58
  416. package/src/tui/info-cmd.ts +0 -150
  417. package/src/tui/input-plain.ts +0 -76
  418. package/src/tui/mcp-cmd.ts +0 -128
  419. package/src/tui/memory-note.ts +0 -77
  420. package/src/tui/modes-cmd.ts +0 -45
  421. package/src/tui/notify-seq.ts +0 -100
  422. package/src/tui/notify.ts +0 -318
  423. package/src/tui/overlays.ts +0 -97
  424. package/src/tui/pi-renderer.ts +0 -428
  425. package/src/tui/providers-cmd.ts +0 -377
  426. package/src/tui/reasoning-view.ts +0 -56
  427. package/src/tui/renderer.ts +0 -128
  428. package/src/tui/replay-marker.ts +0 -29
  429. package/src/tui/session-cmd.ts +0 -148
  430. package/src/tui/session-manage.ts +0 -95
  431. package/src/tui/sextant-attach.ts +0 -102
  432. package/src/tui/sextant-io.ts +0 -202
  433. package/src/tui/sextant-smoke.ts +0 -110
  434. package/src/tui/shell-cmd.ts +0 -158
  435. package/src/tui/smoke.ts +0 -72
  436. package/src/tui/staged-terminal.ts +0 -50
  437. package/src/tui/startup.ts +0 -12
  438. package/src/tui/theme.ts +0 -59
  439. package/src/tui/todo-label.ts +0 -7
  440. package/src/tui/trust-card.ts +0 -107
  441. package/src/tui/tui-commands.ts +0 -87
  442. package/tsconfig.json +0 -30
  443. package/vendor/pi-tui/LICENSE +0 -21
  444. package/vendor/pi-tui/PATCHES.md +0 -12
  445. package/vendor/pi-tui/PROVENANCE.md +0 -12
  446. package/vendor/pi-tui/README.upstream.md +0 -854
  447. package/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  448. package/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  449. package/vendor/pi-tui/src/alt-screen-search.ts +0 -158
  450. package/vendor/pi-tui/src/autocomplete.ts +0 -827
  451. package/vendor/pi-tui/src/components/alt-screen-flash.ts +0 -52
  452. package/vendor/pi-tui/src/components/box.ts +0 -138
  453. package/vendor/pi-tui/src/components/cancellable-loader.ts +0 -41
  454. package/vendor/pi-tui/src/components/editor.ts +0 -2364
  455. package/vendor/pi-tui/src/components/h-stack.ts +0 -45
  456. package/vendor/pi-tui/src/components/image.ts +0 -128
  457. package/vendor/pi-tui/src/components/input.ts +0 -448
  458. package/vendor/pi-tui/src/components/loader.ts +0 -93
  459. package/vendor/pi-tui/src/components/markdown.ts +0 -1016
  460. package/vendor/pi-tui/src/components/scroll-view.ts +0 -217
  461. package/vendor/pi-tui/src/components/select-list.ts +0 -230
  462. package/vendor/pi-tui/src/components/settings-list.ts +0 -277
  463. package/vendor/pi-tui/src/components/spacer.ts +0 -29
  464. package/vendor/pi-tui/src/components/stack.ts +0 -155
  465. package/vendor/pi-tui/src/components/text.ts +0 -108
  466. package/vendor/pi-tui/src/components/truncated-text.ts +0 -66
  467. package/vendor/pi-tui/src/components/v-stack.ts +0 -34
  468. package/vendor/pi-tui/src/editor-component.ts +0 -75
  469. package/vendor/pi-tui/src/fuzzy.ts +0 -138
  470. package/vendor/pi-tui/src/index.ts +0 -149
  471. package/vendor/pi-tui/src/keybindings.ts +0 -321
  472. package/vendor/pi-tui/src/keys.ts +0 -1402
  473. package/vendor/pi-tui/src/kill-ring.ts +0 -47
  474. package/vendor/pi-tui/src/latex.ts +0 -1381
  475. package/vendor/pi-tui/src/layout-node.ts +0 -52
  476. package/vendor/pi-tui/src/layout.ts +0 -411
  477. package/vendor/pi-tui/src/native-modifiers.ts +0 -60
  478. package/vendor/pi-tui/src/native-module-path.ts +0 -32
  479. package/vendor/pi-tui/src/stdin-buffer.ts +0 -445
  480. package/vendor/pi-tui/src/terminal-colors.ts +0 -74
  481. package/vendor/pi-tui/src/terminal-image.ts +0 -701
  482. package/vendor/pi-tui/src/terminal.ts +0 -554
  483. package/vendor/pi-tui/src/tui-alt-screen.ts +0 -1379
  484. package/vendor/pi-tui/src/tui-main-screen.ts +0 -655
  485. package/vendor/pi-tui/src/tui.ts +0 -1264
  486. package/vendor/pi-tui/src/undo-stack.ts +0 -29
  487. package/vendor/pi-tui/src/utils.ts +0 -1327
  488. package/vendor/pi-tui/src/word-navigation.ts +0 -118
  489. package/vendor/pi-tui/test/test-themes.ts +0 -39
  490. package/vendor/pi-tui/test/virtual-terminal.ts +0 -219
  491. /package/{src/providers → dist/cli}/models-index.json +0 -0
package/src/tools/task.ts DELETED
@@ -1,250 +0,0 @@
1
- /** `task` + `task_status` tools (port #26): the model's door to background subagents over
2
- * core/tasks.ts TaskManager. Children run through orchestrator.ts runChild (the ONE
3
- * agentLoop); these tools never run a loop themselves.
4
- *
5
- * Source shape: opencode packages/opencode/src/tool/task.ts (MIT, snapshot
6
- * research/source_snapshots/opencode-2026 @ ebece6e) — parameters description/prompt/
7
- * subagent_type + background flag (:43-62), "started" text that tells the model NOT to
8
- * poll and to keep working or end its turn (:31-35), depth walk refusal (:104-117),
9
- * result rendered as a tagged block with the child's final text (:64-79, :341-345).
10
- * Departures: TWO tools split by policy class instead of background:true on a foreground
11
- * tool — `task` (kind spawn: start|cancel — creating a child, or destroying its work) and
12
- * `task_status` (kind read: status|result|list — registry reads; `result` is an explicit
13
- * bounded wait). Refusals come from the orchestrator's preflight (depth cap / spawn
14
- * policy) as tool output, never exceptions.
15
- *
16
- * Policy: `task` kind "spawn" → action "spawn" (core/tools.ts actionFor): the default gated
17
- * rules PROMPT for it (cli/runtime.ts buildCfg) — once per start, since "once" is never
18
- * cached — yolo allows, plan mode denies (core/modes.ts); children derive prompt→deny
19
- * (orchestrator deriveChildRules), so nested starts exist only under an allow rule.
20
- * `task_status` kind "read" → action "file.read", which the gated rules ALLOW: collecting a
21
- * result never prompts, headless surfaces (run/serve/acp) and children read it, plan mode
22
- * keeps it. Its schema declares no path/command/url, so the policy resource is the tool
23
- * NAME and a smuggled `path` cannot re-aim a `deny file.read task_status` rule (tools.ts
24
- * describeResource honors declared keys only). Fix-wave MED-2: one action-agnostic
25
- * spawn-kind tool prompted for status/result/list too (≥2 prompts per task) and failed
26
- * them closed on headless surfaces. */
27
-
28
- import type { Tool, ToolContext, ToolOutput } from "../core/types.ts";
29
- import { formatTaskList, isTerminal, type TaskId, type TaskInfo, type TaskManager } from "../core/tasks.ts";
30
- import type { SteeringQueue } from "../core/loop.ts";
31
- import { ADAPTER_IDS } from "../lanes/types.ts";
32
- import { LANES_ALLOW_ENV } from "../lanes/registry.ts";
33
-
34
- export const DEFAULT_WAIT_MS = 60_000;
35
- export const MAX_WAIT_MS = 600_000;
36
-
37
- export interface TaskToolOptions {
38
- /** depth of the loop this tool serves (root = 0); children start at depth + 1 */
39
- parentDepth?: number;
40
- /** completion notes for tasks started here (default: the manager's attached queue) */
41
- notify?: SteeringQueue;
42
- /** the task id of the child this tool serves (nested); enables slot lending */
43
- caller?: TaskId;
44
- /** owner signal for tasks started here (nested: the serving task's own run signal, so
45
- * cancelling a task cancels its children). Root tools leave it unset — the manager's
46
- * bindRun() signal owns root tasks; ToolContext.signal is NOT usable (loop.ts:91). */
47
- owner?: AbortSignal;
48
- /** agent name used when `agent` is omitted */
49
- defaultAgent?: string;
50
- /** the custom subagent definitions loaded at boot (core/agents.ts agentRows) — enumerated in the schema so the model
51
- * knows which `agent` names exist; absent/empty = only the default */
52
- agents?: readonly { name: string; description: string }[];
53
- /** nested tools: the tool names of the registry THIS tool serves, read lazily at each start (the registry is filled
54
- * after the tool is built) → StartOptions.parentTools, so a child started from a restricted agent is clamped to that
55
- * agent's set (the allow-list is transitive). Root tools leave it unset. */
56
- parentTools?: () => ReadonlySet<string>;
57
- /** nested tools: the working tree of the child THIS tool serves (ChildContext.dir — its worktree when
58
- * it is isolated) → StartOptions.parentDir. An external lane started from here builds its worktree
59
- * from that directory and merges its patch back into it, so a nested lane's work travels up through
60
- * its parent's patch instead of landing in the user's live tree behind the parent's back. Root tools
61
- * leave it unset: there the manager's rootDir IS the working tree. */
62
- parentDir?: string;
63
- }
64
-
65
- export interface TaskStatusToolOptions {
66
- /** the task id of the child this tool serves (nested): a `result` wait lends its slot to
67
- * the waited-on queued task (TaskManager.result slot lending) */
68
- caller?: TaskId;
69
- }
70
-
71
- const NOT_POLLING =
72
- "You will be notified in this conversation when it finishes — do NOT poll or sleep: " +
73
- "continue other non-overlapping work or end your turn. Use `task_status result` to wait for it when you need its output.";
74
- /** one-shot policy (cli/main.ts cmdRun exit): tasks never outlive the process that started them */
75
- const ONE_SHOT =
76
- "In a one-shot run (`rovecode run`) background tasks do not outlive the run: collect what you need with " +
77
- "`task_status result` before ending your turn.";
78
-
79
- interface Args {
80
- action?: unknown; goal?: unknown; agent?: unknown; isolated?: unknown; label?: unknown; id?: unknown; timeout_ms?: unknown;
81
- }
82
-
83
- const err = (output: string): ToolOutput => ({ ok: false, output: `Error: ${output}` });
84
- const need = (tool: string, what: string): ToolOutput => err(`${tool} ${what} requires a string \`id\` (see \`task_status list\`)`);
85
-
86
- function describe(t: TaskInfo, now: number): string {
87
- const secs = t.startedAt !== undefined ? Math.max(0, Math.round(((t.finishedAt ?? now) - t.startedAt) / 1000)) : 0;
88
- const usage = t.usage ? `, tokens ${t.usage.input}in/${t.usage.output}out` : "";
89
- return `task ${t.id} (${t.label}) ${t.status} — agent ${t.agent}, ${t.isolated ? "isolated, " : ""}${secs}s${usage}`;
90
- }
91
-
92
- function renderResult(t: TaskInfo, now: number): ToolOutput {
93
- const head = describe(t, now);
94
- if (t.status === "done") {
95
- const patch = t.patchLines !== undefined ? `\n[isolated: ${t.patchLines === 0 ? "no file changes" : `patch of ${t.patchLines} lines merged back`}]` : "";
96
- // #47: a lane's permissions were the CLI's own flags — the ones the approval card stated. Repeating
97
- // them on the result is not decoration: it is the only place the model can see what the lane was
98
- // actually allowed to do, which is rarely what our own children are allowed to do.
99
- const lane = t.kind === "external"
100
- ? `\n[external ${t.agent} lane — permissions: ${t.permissions ?? "(unknown)"}${t.laneExit !== undefined ? `; exit ${t.laneExit}` : ""}${t.laneModel ? `; model ${t.laneModel}` : ""}]`
101
- : "";
102
- return { ok: true, output: `${head}${lane}${patch}\n${t.summary ?? "(no output)"}`, data: t };
103
- }
104
- if (t.status === "failed") return { ok: false, output: `${head}\n${t.error ?? "unknown error"}`, data: t };
105
- if (t.status === "cancelled") return { ok: false, output: head, data: t };
106
- return { ok: true, output: `${head}. ${NOT_POLLING}`, data: t };
107
- }
108
-
109
- /** `timeout_ms`: numbers and numeric strings ("5000" — models quote integers) clamp to
110
- * [0, MAX_WAIT_MS]; absent → the default; anything else is a clear error, never a silent
111
- * default (fix-wave L6: a quoted "5000" used to become the 60s default). */
112
- function parseTimeout(v: unknown): number | { error: string } {
113
- if (v === undefined || v === null) return DEFAULT_WAIT_MS;
114
- const n = typeof v === "number" ? v : typeof v === "string" && v.trim() !== "" ? Number(v) : NaN;
115
- if (!Number.isFinite(n)) return { error: `task_status result: \`timeout_ms\` must be a number of milliseconds (got ${JSON.stringify(v) ?? String(v)})` };
116
- return Math.min(MAX_WAIT_MS, Math.max(0, Math.floor(n)));
117
- }
118
-
119
- /** kind spawn: `start` (a new child) and `cancel` (destroys the child's work) — the two
120
- * actions a gated policy should ask about. Reads live on `task_status`. */
121
- export function createTaskTool(tasks: TaskManager, opts: TaskToolOptions = {}): Tool {
122
- const defaultAgent = opts.defaultAgent ?? "main";
123
- // custom definitions, enumerated (bounded per row) so the model can pick one by name
124
- const custom = (opts.agents ?? []).filter((a) => a.name !== defaultAgent);
125
- const clipRow = (s: string): string => (s.length > 120 ? s.slice(0, 119) + "…" : s);
126
- const customNote = custom.length > 0
127
- ? `Custom agent definitions (.rovecode/agents/<name>.md — own system prompt, model, mode and tool allow-list): ${custom.map((a) => `${a.name} — ${clipRow(a.description)}`).join("; ")}. `
128
- : "";
129
- return {
130
- schema: {
131
- name: "task",
132
- description:
133
- "Run subagents as background tasks. `start` launches a child agent session on `goal` and returns " +
134
- "at once with a task id; the child works while you continue, and a note lands in this conversation " +
135
- "when it finishes (do not poll). Read its state or output with the `task_status` tool (status/result/list " +
136
- "— never prompts); `cancel` aborts a task. Children see only `goal` (write it self-contained). " +
137
- `At most ${tasks.maxConcurrent} run concurrently; extra starts queue FIFO. ` +
138
- "`isolated` runs the child in a git worktree copy and merges its file changes back as a patch on success. " +
139
- `\`agent\` may also name an EXTERNAL agentic-CLI lane — ${ADAPTER_IDS.join(" | ")} — which runs \`goal\` in that CLI ` +
140
- "instead of in one of our agents. A lane always works in its own worktree, its diff merges back like any " +
141
- `isolated child, and it runs with the flags stated on the approval card. Lanes are OFF unless ${LANES_ALLOW_ENV} lists the id. ` +
142
- "Policy: under gated rules each `start` needs approval and the child runs read-only (prompt-gated actions " +
143
- "are denied for children) unless allow rules cover them; under yolo it inherits allow-all. " + customNote + ONE_SHOT,
144
- args: {
145
- type: "object",
146
- properties: {
147
- action: { type: "string", enum: ["start", "cancel"] },
148
- goal: { type: "string", description: "start: the child's task, self-contained (it has no access to this conversation)" },
149
- agent: { type: "string", description: `start: agent definition to run (default "${defaultAgent}"${custom.length > 0 ? `; custom: ${custom.map((a) => a.name).join(", ")}` : ""}), or an external CLI lane: ${ADAPTER_IDS.join(" | ")} (needs ${LANES_ALLOW_ENV})` },
150
- isolated: { type: "boolean", description: "start: run in an isolated worktree copy; file changes merge back as a patch when the task finishes ok" },
151
- label: { type: "string", description: "start: short label (3-5 words) shown in task lists and completion notes" },
152
- id: { type: "string", description: "cancel: task id (e.g. t1)" },
153
- },
154
- required: ["action"],
155
- },
156
- },
157
- kind: "spawn",
158
- sequential: true,
159
- async execute(args: unknown): Promise<ToolOutput> {
160
- const a = (args ?? {}) as Args;
161
- const id = typeof a.id === "string" ? a.id.trim() : "";
162
- switch (a.action) {
163
- case "start": {
164
- if (typeof a.goal !== "string" || a.goal.trim() === "") return err("task start requires a non-empty string `goal`");
165
- const agent = typeof a.agent === "string" && a.agent.trim() !== "" ? a.agent.trim() : defaultAgent;
166
- const r = tasks.start(
167
- { agent, goal: a.goal, isolated: a.isolated === true, background: true },
168
- { label: typeof a.label === "string" ? a.label : undefined, parentDepth: opts.parentDepth ?? 0, notify: opts.notify, caller: opts.caller, owner: opts.owner, ...(opts.parentTools ? { parentTools: opts.parentTools() } : {}), ...(opts.parentDir !== undefined ? { parentDir: opts.parentDir } : {}) },
169
- );
170
- if (!r.ok) return err(`task refused: ${r.reason}`);
171
- const t = tasks.status(r.id)!;
172
- const state = t.status === "running" ? "running" : `queued (${tasks.counts().running} running, bound ${tasks.maxConcurrent})`;
173
- // the approver/model must know what the child CAN do (deriveChildRules: prompt → deny); an
174
- // external lane's permissions are the CLI's OWN flags (#47) — the ones the approval card
175
- // stated — and they are not ours to describe in our own words
176
- const policy = t.kind === "external"
177
- ? `External ${t.agent} lane — permissions: ${t.permissions ?? "(unknown)"}; its worktree patch merges back when it finishes ok.`
178
- : r.childPolicy === "gated"
179
- ? "Policy: gated — the child runs read-only (prompt-gated actions are DENIED for children) unless allow rules cover them."
180
- : "Policy: the child inherits your allow rules.";
181
- return { ok: true, output: `task ${t.id} (${t.label}) started: ${state}. ${policy} ${NOT_POLLING}`, data: t };
182
- }
183
- case "cancel": {
184
- if (id === "") return need("task", "cancel");
185
- const before = tasks.status(id);
186
- if (!before) return err(`unknown task '${id}'`);
187
- if (isTerminal(before.status)) return { ok: true, output: `task ${id} already ${before.status}`, data: before };
188
- const t = tasks.cancel(id)!;
189
- return { ok: true, output: `task ${t.id} (${t.label}) cancelled`, data: t };
190
- }
191
- default:
192
- return err(`task requires action start|cancel (got ${JSON.stringify(a.action ?? null)}); status|result|list live on task_status`);
193
- }
194
- },
195
- };
196
- }
197
-
198
- /** kind read: `status` | `result` (bounded wait, aborts with the run) | `list`. Auto-allowed by
199
- * the gated rules (file.read) and plan mode; no path/command/url in the schema, so the policy
200
- * resource is always the tool name. */
201
- export function createTaskStatusTool(tasks: TaskManager, opts: TaskStatusToolOptions = {}): Tool {
202
- return {
203
- schema: {
204
- name: "task_status",
205
- description:
206
- "Read background tasks started with `task` (never prompts, never mutates). `status` shows one task's " +
207
- "state; `result` waits (bounded by `timeout_ms`, default 60s) for a task to finish and returns the " +
208
- "child's final output — call it when you need the output, otherwise wait for the completion note; " +
209
- "`list` shows every task. " + ONE_SHOT,
210
- args: {
211
- type: "object",
212
- properties: {
213
- action: { type: "string", enum: ["status", "result", "list"] },
214
- id: { type: "string", description: "status/result: task id (e.g. t1)" },
215
- timeout_ms: { type: "integer", description: `result: max wait in ms (default ${DEFAULT_WAIT_MS}, max ${MAX_WAIT_MS}); 0 = report the current state at once` },
216
- },
217
- required: ["action"],
218
- },
219
- },
220
- kind: "read",
221
- sequential: true,
222
- async execute(args: unknown, ctx: ToolContext): Promise<ToolOutput> {
223
- const a = (args ?? {}) as Args;
224
- const now = Date.now();
225
- const id = typeof a.id === "string" ? a.id.trim() : "";
226
- switch (a.action) {
227
- case "status": {
228
- if (id === "") return need("task_status", "status");
229
- const t = tasks.status(id);
230
- return t ? { ok: true, output: describe(t, now), data: t } : err(`unknown task '${id}'`);
231
- }
232
- case "result": {
233
- if (id === "") return need("task_status", "result");
234
- if (!tasks.status(id)) return err(`unknown task '${id}'`);
235
- const timeoutMs = parseTimeout(a.timeout_ms);
236
- if (typeof timeoutMs !== "number") return err(timeoutMs.error);
237
- const t = await tasks.result(id, { timeoutMs, signal: ctx.signal, caller: opts.caller });
238
- if (!t) return err(`unknown task '${id}'`);
239
- if (!isTerminal(t.status) && ctx.signal.aborted) return err(`wait for task ${id} aborted`);
240
- if (!isTerminal(t.status)) return { ok: true, output: `${describe(t, Date.now())} — still running after ${Math.round(timeoutMs / 1000)}s. ${NOT_POLLING}`, data: t };
241
- return renderResult(t, Date.now());
242
- }
243
- case "list":
244
- return { ok: true, output: formatTaskList(tasks.list(), now), data: tasks.counts() };
245
- default:
246
- return err(`task_status requires action status|result|list (got ${JSON.stringify(a.action ?? null)}); start|cancel live on task`);
247
- }
248
- },
249
- };
250
- }
package/src/tools/todo.ts DELETED
@@ -1,320 +0,0 @@
1
- /** Session todo / plan tool (PORT #32): `todo_write` + `todo_read` over one
2
- * JSON file per session, plus pure render helpers for the TUI surface.
3
- *
4
- * Ported from opencode (MIT, snapshot ebece6e):
5
- * - tool contract — ONE `todos` array argument that REPLACES the whole list
6
- * (packages/opencode/src/tool/todo.ts:6-8, :31-34; packages/core/src/tool/
7
- * todowrite.ts:14-16, :49); the store's update is delete-all + insert in
8
- * list order (packages/opencode/src/session/todo.ts:29-51), reads come back
9
- * in that order (:53-66);
10
- * - item shape content / status / priority with the status and priority sets
11
- * (packages/schema/src/session-todo.ts:7-15);
12
- * - the when-to-use / when-not / rules guidance folded into the tool
13
- * description (packages/opencode/src/tool/todowrite.txt:3-16, :24-30, :44).
14
- * Validation follows gemini-cli (Apache-2.0, snapshot 0bd1d43)
15
- * packages/core/src/tools/write-todos.ts:100-129 validateToolParamValues —
16
- * array check, per-item object / non-empty description / status-enum checks,
17
- * and the at-most-ONE-in_progress rule (:120-126); "Cleared todo list" is
18
- * gemini's wording (:52, :68). Both upstreams reject an invalid list whole.
19
- *
20
- * Deviations: items carry a caller-chosen `id` (whole-list replace needs a
21
- * stable handle the model can quote back; opencode is position-keyed, gemini
22
- * has none); three statuses only (no cancelled/blocked — drop the item
23
- * instead); bounds (≤50 items, id ≤64 chars, content ≤500 chars) so tool output
24
- * stays bounded; storage is `<sessionDir>/todos.json` written tmp+rename
25
- * (session.ts persistLeaf pattern; opencode uses SQLite, gemini is in-memory).
26
- * No in-memory cache: every read hits disk, so a second tool instance, a
27
- * resumed session and the TUI `/todos` surface all see the same truth. A
28
- * corrupt file is reported as empty + note — loading never throws.
29
- *
30
- * Policy: todo_write is kind "memory" — a disk write of agent-private,
31
- * session-scoped metadata, the same class as memory_edit (BlockStore under
32
- * <session>/memory). core/tools.ts actionFor() maps it to memory.write, which
33
- * the runtime's default gated rules ALLOW (runtime.ts buildCfg), so the list
34
- * never prompts; kind "read" would also auto-run but would let read-only rule
35
- * sets write to disk unseen — the mirror of recall.ts's argument against
36
- * mislabeling kinds. The schemas declare no `path`/`command`, so the policy
37
- * resource is the tool name: `memory.write todo_write` targets it precisely —
38
- * which is how plan mode (modes.ts planModeRules) denies memory.write wholesale
39
- * and then re-allows exactly todo_write: the list is the plan's own artifact
40
- * (agent-private session metadata, not workspace state), while memory_edit,
41
- * file.write and shell.exec stay denied there; todo_read (kind "read" →
42
- * file.read) is always available. Not in checkpoints.ts MUTATING_KINDS, so
43
- * todo writes never trigger snapshots. */
44
-
45
- import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
46
- import { basename, join } from "node:path";
47
- import type { Tool, ToolContext, ToolOutput } from "../core/types.ts";
48
-
49
- // ---------- schema ----------
50
-
51
- export type TodoStatus = "pending" | "in_progress" | "completed";
52
- export type TodoPriority = "high" | "medium" | "low";
53
- export interface TodoItem { id: string; content: string; status: TodoStatus; priority?: TodoPriority }
54
-
55
- export const TODO_STATUSES: readonly TodoStatus[] = ["pending", "in_progress", "completed"];
56
- export const TODO_PRIORITIES: readonly TodoPriority[] = ["high", "medium", "low"];
57
- export const MAX_TODOS = 50;
58
- export const MAX_ID_CHARS = 64;
59
- export const MAX_CONTENT_CHARS = 500;
60
- export const TODOS_FILE = "todos.json";
61
- const FILE_VERSION = 1;
62
- const RENDER_CONTENT_CHARS = 200; // per-line render clip (content is ≤500 on disk; the TUI note stays scannable)
63
-
64
- function isStatus(v: unknown): v is TodoStatus { return (TODO_STATUSES as readonly unknown[]).includes(v); }
65
- function isPriority(v: unknown): v is TodoPriority { return (TODO_PRIORITIES as readonly unknown[]).includes(v); }
66
-
67
- /** Bounded echo of a rejected value — a 200k-char status must not reflect into the error. */
68
- function show(v: unknown): string {
69
- let s: string;
70
- try { s = JSON.stringify(v) ?? String(v); } catch { s = String(v); }
71
- return s.length > 40 ? s.slice(0, 40).replace(/[\uD800-\uDBFF]$/, "") + "…" : s;
72
- }
73
-
74
- export type TodoValidation = { ok: true; items: TodoItem[] } | { ok: false; error: string };
75
-
76
- /** Whole-list validation (gemini-cli write-todos.ts:100-129 shape, plus ids and
77
- * bounds). Returns NORMALIZED items — ids/content trimmed, unknown keys
78
- * dropped, `priority` omitted when absent — or the first precise error. */
79
- export function validateTodos(raw: unknown): TodoValidation {
80
- const err = (error: string): TodoValidation => ({ ok: false, error });
81
- if (!Array.isArray(raw)) return err("`todos` must be an array of {id, content, status, priority?}");
82
- if (raw.length > MAX_TODOS) return err(`too many todos: ${raw.length} (max ${MAX_TODOS})`);
83
- const items: TodoItem[] = [];
84
- const seen = new Set<string>();
85
- const inProgress: string[] = [];
86
- for (let i = 0; i < raw.length; i++) {
87
- const t: unknown = raw[i];
88
- const at = `todos[${i}]`;
89
- if (!t || typeof t !== "object" || Array.isArray(t)) return err(`${at} must be an object {id, content, status, priority?}`);
90
- const o = t as Record<string, unknown>;
91
- if (typeof o.id !== "string" || o.id.trim().length === 0) return err(`${at}.id must be a non-empty string`);
92
- const id = o.id.trim();
93
- if (id.length > MAX_ID_CHARS) return err(`${at}.id exceeds ${MAX_ID_CHARS} chars`);
94
- if (seen.has(id)) return err(`duplicate id "${id}" at ${at} — ids must be unique`);
95
- seen.add(id);
96
- if (typeof o.content !== "string" || o.content.trim().length === 0) return err(`${at} ("${id}"): content must be a non-empty string`);
97
- const content = o.content.trim();
98
- if (content.length > MAX_CONTENT_CHARS) return err(`${at} ("${id}"): content exceeds ${MAX_CONTENT_CHARS} chars`);
99
- if (!isStatus(o.status)) return err(`${at} ("${id}"): status must be one of ${TODO_STATUSES.join(", ")} (got ${show(o.status)})`);
100
- const item: TodoItem = { id, content, status: o.status };
101
- if (o.priority !== undefined && o.priority !== null) {
102
- if (!isPriority(o.priority)) return err(`${at} ("${id}"): priority must be one of ${TODO_PRIORITIES.join(", ")} (got ${show(o.priority)})`);
103
- item.priority = o.priority;
104
- }
105
- if (item.status === "in_progress") inProgress.push(id);
106
- items.push(item);
107
- }
108
- // gemini-cli write-todos.ts:120-126: only one task can be in_progress at a time
109
- if (inProgress.length > 1) return err(`only one todo may be in_progress at a time (found ${inProgress.length}: ${inProgress.join(", ")})`);
110
- return { ok: true, items };
111
- }
112
-
113
- // ---------- persistence (<sessionDir>/todos.json) ----------
114
-
115
- export interface LoadedTodos { items: TodoItem[]; note?: string }
116
-
117
- /** Read the session's list. Missing file = empty (the normal initial state, no
118
- * note). Unreadable / malformed / schema-invalid content = empty + a note
119
- * saying so — never throws; the next todo_write replaces the file. */
120
- export function loadTodos(sessionDir: string): LoadedTodos {
121
- const file = join(sessionDir, TODOS_FILE);
122
- const tail = "treating the list as empty; the next todo_write replaces it";
123
- let text: string;
124
- try {
125
- text = readFileSync(file, "utf8");
126
- } catch (e) {
127
- if ((e as { code?: unknown } | null)?.code === "ENOENT") return { items: [] };
128
- return { items: [], note: `${TODOS_FILE} could not be read (${e instanceof Error ? e.message : String(e)}) — ${tail}` };
129
- }
130
- let raw: unknown;
131
- try { raw = JSON.parse(text); } catch { return { items: [], note: `${TODOS_FILE} is not valid JSON — ${tail}` }; }
132
- const o = raw && typeof raw === "object" && !Array.isArray(raw) ? (raw as Record<string, unknown>) : null;
133
- if (!o || o.version !== FILE_VERSION || !Array.isArray(o.items)) {
134
- return { items: [], note: `${TODOS_FILE} has an unexpected shape (expected {version: ${FILE_VERSION}, items: [...]}) — ${tail}` };
135
- }
136
- const v = validateTodos(o.items);
137
- if (!v.ok) return { items: [], note: `${TODOS_FILE} failed validation (${v.error}) — ${tail}` };
138
- return { items: v.items };
139
- }
140
-
141
- /** Atomic replace: write `todos.json.tmp`, then rename over the target (session.ts
142
- * persistLeaf). Creates the session dir if needed. IO errors propagate — the
143
- * tool turns them into ok:false. */
144
- export function saveTodos(sessionDir: string, items: readonly TodoItem[]): void {
145
- mkdirSync(sessionDir, { recursive: true });
146
- const file = join(sessionDir, TODOS_FILE);
147
- const tmp = file + ".tmp";
148
- writeFileSync(tmp, JSON.stringify({ version: FILE_VERSION, items }, null, 2) + "\n");
149
- renameSync(tmp, file);
150
- }
151
-
152
- /** A session id must be a plain directory name: `<root>/<id>/todos.json` may never
153
- * resolve outside the sessions root (listSessions identity = directory name). */
154
- function sessionDirFor(root: string, sessionId: string): string | null {
155
- // both slashes are refused on every host: a backslash is a legal file-name byte on POSIX, but an id
156
- // that would be a path on Windows is not a plain directory name anywhere
157
- if (!sessionId || sessionId === "." || sessionId === ".." || /[\\/]/.test(sessionId) || basename(sessionId) !== sessionId) return null;
158
- return join(root, sessionId);
159
- }
160
-
161
- // ---------- rendering (pure; shared by tool output and the TUI) ----------
162
-
163
- export interface TodoCounts { total: number; pending: number; inProgress: number; completed: number }
164
-
165
- export function todoCounts(items: readonly TodoItem[]): TodoCounts {
166
- const c: TodoCounts = { total: items.length, pending: 0, inProgress: 0, completed: 0 };
167
- for (const t of items) {
168
- if (t.status === "completed") c.completed++;
169
- else if (t.status === "in_progress") c.inProgress++;
170
- else c.pending++;
171
- }
172
- return c;
173
- }
174
-
175
- const GLYPH: Record<TodoStatus, string> = { pending: "[ ]", in_progress: "[>]", completed: "[x]" };
176
-
177
- /** Single-line content: whitespace collapsed, clipped with an ellipsis (surrogate-safe). */
178
- function oneLine(text: string): string {
179
- const flat = text.replace(/\s+/g, " ").trim();
180
- return flat.length > RENDER_CONTENT_CHARS
181
- ? flat.slice(0, RENDER_CONTENT_CHARS).replace(/[\uD800-\uDBFF]$/, "") + "…"
182
- : flat;
183
- }
184
-
185
- /** Checkbox rendering: a summary line, then one `[glyph] id: content (priority)`
186
- * row per item in list order. Bounded: ≤MAX_TODOS rows, content clipped, and the
187
- * id flattened too (a trimmed id may still carry an inner newline — one row per item). */
188
- export function renderTodos(items: readonly TodoItem[]): string {
189
- if (items.length === 0) return "todos: (empty)";
190
- const c = todoCounts(items);
191
- const lines = [`todos: ${c.total} total · ${c.completed} completed · ${c.inProgress} in progress · ${c.pending} pending`];
192
- for (const t of items.slice(0, MAX_TODOS)) {
193
- lines.push(`${GLYPH[t.status]} ${oneLine(t.id)}: ${oneLine(t.content)}${t.priority ? ` (${t.priority})` : ""}`);
194
- }
195
- if (items.length > MAX_TODOS) lines.push(`(+${items.length - MAX_TODOS} more not shown)`);
196
- return lines.join("\n");
197
- }
198
-
199
- /** The re-send the loop makes while a plan is open (loop.ts LoopDeps.planReminder).
200
- *
201
- * A list written twenty turns ago is buried under tool results: the model stops marking items done,
202
- * starts a second item without finishing the first, or forgets the tail of the plan entirely. This is
203
- * the same shape as the tool's own output, plus the one instruction that matters right now — so the
204
- * plan is always the most recent thing in the request, not the oldest.
205
- *
206
- * null when there is nothing to chase (no list, or everything completed): a finished plan must not
207
- * keep nagging, and an empty one has nothing to say. */
208
- export function planReminder(items: readonly TodoItem[]): string | null {
209
- const c = todoCounts(items);
210
- if (c.total === 0 || c.completed === c.total) return null;
211
- return [
212
- "<plan-reminder>",
213
- "Your own todo list for this task, still open — not a message from the user.",
214
- renderTodos(items),
215
- c.inProgress === 0
216
- ? "Nothing is in progress. Mark the next item in_progress with todo_write before you start it."
217
- : "Mark the in_progress item completed with todo_write the moment it is done, then start the next one.",
218
- "Rewrite the list if the plan changed. Never mention this reminder in your reply.",
219
- "</plan-reminder>",
220
- ].join("\n");
221
- }
222
-
223
- /** Status-bar label, e.g. "todos 1/3" (completed/total); "" when the list is empty. */
224
- export function todoStatusLabel(items: readonly TodoItem[]): string {
225
- if (items.length === 0) return "";
226
- const c = todoCounts(items);
227
- return `todos ${c.completed}/${c.total}`;
228
- }
229
-
230
- // ---------- tools ----------
231
-
232
- const WRITE_DESCRIPTION =
233
- "Create or update this session's structured todo list (your plan). REPLACES the whole list: send every item " +
234
- `you want kept — items {id, content, status, priority?}; at most ${MAX_TODOS} items, ids unique and non-empty ` +
235
- `(≤${MAX_ID_CHARS} chars), content non-empty (≤${MAX_CONTENT_CHARS} chars). Statuses: pending | in_progress ` +
236
- "(exactly ONE at a time) | completed. Priority: high | medium | low (optional). An invalid list is rejected whole " +
237
- "and nothing changes; an empty list clears the todos. Use proactively when: the task needs 3+ distinct steps; the " +
238
- "work is non-trivial and benefits from planning; the user gives multiple tasks or asks for a todo list; new " +
239
- "instructions arrive (capture them as todos); you start a step (mark it in_progress first) or finish one (mark it " +
240
- "completed only once the work, including verification, is actually done — never on intent; add follow-ups " +
241
- "discovered on the way). Skip it for a single straightforward task, a purely informational request, or when " +
242
- "tracking adds no value. Update in real time — don't batch completions. When in doubt, use it.";
243
-
244
- const READ_DESCRIPTION =
245
- "Read this session's todo list as last written by todo_write: ids, content, status, priority. Use it to get the " +
246
- "current ids before updating the list, or to check what remains. Empty until todo_write creates a list.";
247
-
248
- const itemSchema = {
249
- type: "object",
250
- properties: {
251
- id: { type: "string", description: `stable short id, unique within the list (e.g. "t1"); ≤${MAX_ID_CHARS} chars` },
252
- content: { type: "string", description: `brief, specific, actionable description of the task; ≤${MAX_CONTENT_CHARS} chars` },
253
- status: { type: "string", enum: [...TODO_STATUSES], description: "pending | in_progress (exactly one at a time) | completed" },
254
- priority: { type: "string", enum: [...TODO_PRIORITIES], description: "optional priority" },
255
- },
256
- required: ["id", "content", "status"],
257
- };
258
-
259
- /** `todo_write` bound to a sessions root; the list lives at <root>/<ctx.sessionId>/todos.json. */
260
- export function todoWriteTool(sessionsRoot: string): Tool {
261
- return {
262
- schema: {
263
- name: "todo_write",
264
- description: WRITE_DESCRIPTION,
265
- args: {
266
- type: "object",
267
- properties: {
268
- todos: { type: "array", description: "the complete, updated todo list (replaces the current one)", maxItems: MAX_TODOS, items: itemSchema },
269
- },
270
- required: ["todos"],
271
- },
272
- },
273
- kind: "memory",
274
- sequential: true,
275
- execute(args: unknown, ctx: ToolContext): Promise<ToolOutput> {
276
- const dir = sessionDirFor(sessionsRoot, ctx.sessionId);
277
- if (!dir) return Promise.resolve({ ok: false, output: `todo_write failed: invalid session id ${show(ctx.sessionId)}` });
278
- // keep ONLY the schema arg (recall.ts idiom): smuggled keys never influence behavior
279
- const raw = (args && typeof args === "object" ? args : {}) as Record<string, unknown>;
280
- const v = validateTodos(raw.todos);
281
- if (!v.ok) return Promise.resolve({ ok: false, output: `todo_write failed: ${v.error}; the list was not changed` });
282
- try {
283
- saveTodos(dir, v.items);
284
- } catch (e) {
285
- return Promise.resolve({ ok: false, output: `todo_write failed: could not write ${TODOS_FILE}: ${e instanceof Error ? e.message : String(e)}` });
286
- }
287
- // gemini write-todos.ts:52/:68 wording for the clear case; otherwise the checkbox view
288
- const output = v.items.length === 0 ? "Cleared todo list." : renderTodos(v.items);
289
- return Promise.resolve({ ok: true, output, data: { items: v.items } });
290
- },
291
- };
292
- }
293
-
294
- /** `todo_read` bound to the same root. Pure read (kind "read"): never creates the file. */
295
- export function todoReadTool(sessionsRoot: string): Tool {
296
- return {
297
- schema: {
298
- name: "todo_read",
299
- description: READ_DESCRIPTION,
300
- args: { type: "object", properties: {} },
301
- },
302
- kind: "read",
303
- sequential: false,
304
- execute(_args: unknown, ctx: ToolContext): Promise<ToolOutput> {
305
- const dir = sessionDirFor(sessionsRoot, ctx.sessionId);
306
- if (!dir) return Promise.resolve({ ok: false, output: `todo_read failed: invalid session id ${show(ctx.sessionId)}` });
307
- const { items, note } = loadTodos(dir);
308
- if (items.length === 0) {
309
- const head = note ? `${note}\n` : "";
310
- return Promise.resolve({ ok: true, output: `${head}No todos for this session yet — use todo_write to create a list.`, data: { items, ...(note ? { note } : {}) } });
311
- }
312
- return Promise.resolve({ ok: true, output: renderTodos(items), data: { items } });
313
- },
314
- };
315
- }
316
-
317
- /** Both tools over one sessions root — the runtime registration unit. */
318
- export function todoTools(sessionsRoot: string): Tool[] {
319
- return [todoWriteTool(sessionsRoot), todoReadTool(sessionsRoot)];
320
- }