rovecode 0.3.3 → 0.4.0-beta.3

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 (495) hide show
  1. package/CHANGELOG.md +527 -0
  2. package/README.md +46 -48
  3. package/bin/rovecode.js +24 -0
  4. package/dist/cli/app-j6gn14w3.js +2 -0
  5. package/dist/cli/ask-user-cwstt8fz.js +2 -0
  6. package/dist/cli/auth-login-9bbp9915.js +2 -0
  7. package/dist/cli/auth-m8p9grty.js +2 -0
  8. package/dist/cli/bench-16zqdms5.js +9 -0
  9. package/dist/cli/catalog-1xchffa4.js +2 -0
  10. package/dist/cli/cli-1n1zb64f.js +2 -0
  11. package/dist/cli/client-2t9gjkck.js +2 -0
  12. package/dist/cli/commands-exafvm2b.js +2 -0
  13. package/dist/cli/connect-6zde0kn3.js +2 -0
  14. package/dist/cli/context-cmd-5t43wgqt.js +2 -0
  15. package/dist/cli/context-report-kt01pw8y.js +2 -0
  16. package/dist/cli/count-remote-ap7x3vh6.js +2 -0
  17. package/dist/cli/design-ne5zszyh.js +2 -0
  18. package/dist/cli/dispatch-2r5myxye.js +2 -0
  19. package/dist/cli/doctor-ws4fh4tn.js +3 -0
  20. package/dist/cli/executor-bdrjn634.js +2 -0
  21. package/dist/cli/export-1mxb9g5p.js +2 -0
  22. package/dist/cli/files-g104xghh.js +2 -0
  23. package/dist/cli/gauntlet-07xrjpj7.js +2 -0
  24. package/dist/cli/gauntlet-runner-xvy64436.js +10 -0
  25. package/dist/cli/gauntlet-wave3-jm91yt5w.js +5 -0
  26. package/dist/cli/gauntlet-wave4-r13py7p1.js +14 -0
  27. package/dist/cli/hashline-znvrat11.js +2 -0
  28. package/dist/cli/http-xafw6fsh.js +143 -0
  29. package/dist/cli/index-1sgjm25y.js +2 -0
  30. package/dist/cli/init-g2m0tn4m.js +51 -0
  31. package/dist/cli/install-avaqjjqq.js +2 -0
  32. package/dist/cli/loop-mmpfft01.js +2 -0
  33. package/dist/cli/main-0904f6ps.js +5 -0
  34. package/dist/cli/main-0ab9fc26.js +9 -0
  35. package/dist/cli/main-0jys2ccn.js +3 -0
  36. package/dist/cli/main-0mtcdbs7.js +3 -0
  37. package/dist/cli/main-0z1w2zsg.js +3 -0
  38. package/dist/cli/main-1dchs7xv.js +18 -0
  39. package/dist/cli/main-1ereejm1.js +3 -0
  40. package/dist/cli/main-1k1kw6b5.js +3 -0
  41. package/dist/cli/main-27y4sm2k.js +38 -0
  42. package/dist/cli/main-2wwjex5j.js +58 -0
  43. package/dist/cli/main-2yeveeve.js +6 -0
  44. package/dist/cli/main-2yfck9b5.js +3 -0
  45. package/dist/cli/main-2zmzgkwh.js +3 -0
  46. package/dist/cli/main-351pz3z7.js +7 -0
  47. package/dist/cli/main-3gjqfh7a.js +6 -0
  48. package/dist/cli/main-3nf3kgve.js +3 -0
  49. package/dist/cli/main-3pjrb2hd.js +3 -0
  50. package/dist/cli/main-3rxcvgna.js +19 -0
  51. package/dist/cli/main-4b3jgy66.js +19 -0
  52. package/dist/cli/main-4wndhjdc.js +7 -0
  53. package/dist/cli/main-4xcmvxnk.js +3 -0
  54. package/dist/cli/main-5tbz0wbz.js +4 -0
  55. package/dist/cli/main-5ywnwthm.js +3 -0
  56. package/dist/cli/main-6b62vkz0.js +14 -0
  57. package/dist/cli/main-6dnk69vp.js +3 -0
  58. package/dist/cli/main-6genrmhs.js +136 -0
  59. package/dist/cli/main-73g7eff4.js +15 -0
  60. package/dist/cli/main-7c5thhjd.js +5 -0
  61. package/dist/cli/main-7rn6bqje.js +3 -0
  62. package/dist/cli/main-80haw7qk.js +4 -0
  63. package/dist/cli/main-875s60s2.js +4 -0
  64. package/dist/cli/main-8kjxbpw4.js +8 -0
  65. package/dist/cli/main-90ds1z4e.js +10 -0
  66. package/dist/cli/main-9etavkew.js +3 -0
  67. package/dist/cli/main-a9njrkk1.js +3 -0
  68. package/dist/cli/main-aecrjq2d.js +12 -0
  69. package/dist/cli/main-ck9asesq.js +9 -0
  70. package/dist/cli/main-cta9racd.js +4 -0
  71. package/dist/cli/main-ddv7j2ag.js +3 -0
  72. package/dist/cli/main-dfreez27.js +10 -0
  73. package/dist/cli/main-f7rw7des.js +3 -0
  74. package/dist/cli/main-ggcn7rd7.js +5 -0
  75. package/dist/cli/main-gzkmycnv.js +3 -0
  76. package/dist/cli/main-hq51jg8v.js +18 -0
  77. package/dist/cli/main-jft389w9.js +8 -0
  78. package/dist/cli/main-k1eqkg83.js +3 -0
  79. package/dist/cli/main-k2y8a2aw.js +9 -0
  80. package/dist/cli/main-kcpbykxz.js +4 -0
  81. package/dist/cli/main-kd488vje.js +22 -0
  82. package/dist/cli/main-kh32yvgk.js +5 -0
  83. package/dist/cli/main-kqxnqjnv.js +25 -0
  84. package/dist/cli/main-kyn0xnsg.js +3 -0
  85. package/dist/cli/main-m1kk6fp5.js +21 -0
  86. package/dist/cli/main-mv40pcr2.js +4 -0
  87. package/dist/cli/main-n0t3973w.js +3 -0
  88. package/dist/cli/main-nqveez48.js +4 -0
  89. package/dist/cli/main-pknhvrmj.js +3 -0
  90. package/dist/cli/main-pn1w7a7j.js +3 -0
  91. package/dist/cli/main-prxxs70n.js +4 -0
  92. package/dist/cli/main-q3vsesf9.js +3 -0
  93. package/dist/cli/main-qsevpgsv.js +3 -0
  94. package/dist/cli/main-rdgdw24b.js +25 -0
  95. package/dist/cli/main-rfth4tbm.js +16 -0
  96. package/dist/cli/main-rg0wn0xf.js +5 -0
  97. package/dist/cli/main-sdmxhtv8.js +4 -0
  98. package/dist/cli/main-skbp13js.js +18 -0
  99. package/dist/cli/main-t4xnd213.js +7 -0
  100. package/dist/cli/main-vqak588n.js +4 -0
  101. package/dist/cli/main-w2n1303f.js +9 -0
  102. package/dist/cli/main-wbrdspr2.js +5 -0
  103. package/dist/cli/main-wsrg79c1.js +7 -0
  104. package/dist/cli/main-x4r0fne4.js +5 -0
  105. package/dist/cli/main-xea2f3tn.js +6 -0
  106. package/dist/cli/main-xg704a3c.js +3 -0
  107. package/dist/cli/main-xvnrabfp.js +16 -0
  108. package/dist/cli/main-xy53xf0r.js +4 -0
  109. package/dist/cli/main-y1fqy60y.js +3 -0
  110. package/dist/cli/main-yn8cd281.js +34 -0
  111. package/dist/cli/main-yr0ksc0h.js +4 -0
  112. package/dist/cli/main-z2ex2vyf.js +4 -0
  113. package/dist/cli/main-z3aayzvq.js +3 -0
  114. package/dist/cli/main-zaqh35jg.js +3 -0
  115. package/dist/cli/main-zc2e8e46.js +4 -0
  116. package/dist/cli/main-zzrfw6cf.js +13 -0
  117. package/dist/cli/main.js +280 -0
  118. package/dist/cli/market-cmd-e14kmx9n.js +5 -0
  119. package/dist/cli/mcp-login-wq7ktdek.js +2 -0
  120. package/dist/cli/mcp-market-cmd-9mg3jecy.js +2 -0
  121. package/dist/cli/notify-b7qc0cjb.js +2 -0
  122. package/dist/cli/oauth-z8whcgfx.js +2 -0
  123. package/dist/cli/output-b3ewj3ps.js +16 -0
  124. package/dist/cli/profiles-6mr5he5e.js +2 -0
  125. package/dist/cli/provider-config-g7j42q8x.js +2 -0
  126. package/dist/cli/provider-jr1y8vvm.js +2 -0
  127. package/dist/cli/registry-s8yk86g0.js +2 -0
  128. package/dist/cli/registry-t6p8d4mn.js +2 -0
  129. package/dist/cli/repl-bajwe1mh.js +11 -0
  130. package/dist/cli/resume-rwn9nz7y.js +2 -0
  131. package/dist/cli/run-flags-nah7ndpt.js +2 -0
  132. package/dist/cli/runtime-n7gafzhb.js +2 -0
  133. package/dist/cli/sandbox-config-emdy18x4.js +2 -0
  134. package/dist/cli/server-b0nvs2bn.js +5 -0
  135. package/dist/cli/session-arg-y75wd4kj.js +2 -0
  136. package/dist/cli/session-j62evmjq.js +2 -0
  137. package/dist/cli/sessions-cmd-tsnwz0ns.js +7 -0
  138. package/dist/cli/settings-df10wfez.js +2 -0
  139. package/dist/cli/setup-jzvv72fg.js +2 -0
  140. package/dist/cli/sextant-smoke-37m81ke6.js +5 -0
  141. package/dist/cli/skills-cmd-gjxnxnhx.js +2 -0
  142. package/dist/cli/smoke-p7748apt.js +8 -0
  143. package/dist/cli/start-chat-s4st3mm0.js +12 -0
  144. package/dist/cli/stream-gmeyewds.js +2 -0
  145. package/dist/cli/task-gh0kkp3n.js +2 -0
  146. package/dist/cli/tasks-z1kfpe8e.js +2 -0
  147. package/dist/cli/thinking-0eqkrz6t.js +2 -0
  148. package/dist/cli/todo-5brcrt9m.js +2 -0
  149. package/dist/cli/tools-7pzm0vj9.js +2 -0
  150. package/dist/cli/tools-s635p6s8.js +2 -0
  151. package/dist/cli/trust-cmd-cjav8zgm.js +2 -0
  152. package/dist/cli/update-check-pt31bm2f.js +2 -0
  153. package/dist/cli/update-cmd-tk131s9t.js +2 -0
  154. package/dist/cli/voice-56nabd8d.js +2 -0
  155. package/dist/cli/webfetch-xd8q596m.js +2 -0
  156. package/dist/cli/websearch-5hkf98k1.js +2 -0
  157. package/dist/cli/workflow-cmd-cy3cvzjp.js +4 -0
  158. package/dist/cli/workspace-q10g5z3e.js +2 -0
  159. package/dist/lib/index.js +62 -0
  160. package/dist/lib/models-index.json +1 -0
  161. package/dist/lib/plugins.js +55 -0
  162. package/dist/lib/providers.js +17 -0
  163. package/dist/lib/public-api.js +20 -0
  164. package/dist/lib/sdk.js +360 -0
  165. package/package.json +84 -72
  166. package/bin/rovecode.ts +0 -21
  167. package/src/acp/server.ts +0 -374
  168. package/src/cli/auth-login.ts +0 -122
  169. package/src/cli/connect.ts +0 -244
  170. package/src/cli/context-cmd.ts +0 -199
  171. package/src/cli/dispatch.ts +0 -82
  172. package/src/cli/doctor.ts +0 -362
  173. package/src/cli/export.ts +0 -276
  174. package/src/cli/help.ts +0 -293
  175. package/src/cli/is-tui-invocation.ts +0 -8
  176. package/src/cli/main.ts +0 -583
  177. package/src/cli/market-cmd.ts +0 -658
  178. package/src/cli/mcp-login.ts +0 -141
  179. package/src/cli/mcp-market-cmd.ts +0 -302
  180. package/src/cli/output.ts +0 -382
  181. package/src/cli/repl.ts +0 -250
  182. package/src/cli/repomap-root.ts +0 -14
  183. package/src/cli/resume.ts +0 -57
  184. package/src/cli/run-flags.ts +0 -43
  185. package/src/cli/run-limits.ts +0 -78
  186. package/src/cli/runtime.ts +0 -931
  187. package/src/cli/session-arg.ts +0 -30
  188. package/src/cli/sessions-cmd.ts +0 -145
  189. package/src/cli/setup.ts +0 -153
  190. package/src/cli/skills-cmd.ts +0 -194
  191. package/src/cli/start-chat.ts +0 -65
  192. package/src/cli/trust-cmd.ts +0 -52
  193. package/src/coding/bash.ts +0 -148
  194. package/src/coding/checkpoints.ts +0 -327
  195. package/src/coding/diff.ts +0 -138
  196. package/src/coding/files.ts +0 -341
  197. package/src/coding/hashline.ts +0 -274
  198. package/src/coding/lsp-gate.ts +0 -254
  199. package/src/coding/lsp-servers.ts +0 -147
  200. package/src/coding/lsp.ts +0 -283
  201. package/src/coding/repomap-cache.ts +0 -99
  202. package/src/coding/repomap-files.ts +0 -192
  203. package/src/coding/repomap.ts +0 -481
  204. package/src/core/agents.ts +0 -255
  205. package/src/core/compaction.ts +0 -259
  206. package/src/core/config.ts +0 -289
  207. package/src/core/context-report.ts +0 -228
  208. package/src/core/context.ts +0 -60
  209. package/src/core/count-remote.ts +0 -107
  210. package/src/core/execpolicy-rules.ts +0 -196
  211. package/src/core/execpolicy.ts +0 -385
  212. package/src/core/executor.ts +0 -454
  213. package/src/core/guardrails.ts +0 -400
  214. package/src/core/hooks.ts +0 -411
  215. package/src/core/images.ts +0 -230
  216. package/src/core/intro.ts +0 -266
  217. package/src/core/loop.ts +0 -567
  218. package/src/core/modes.ts +0 -372
  219. package/src/core/orchestrator.ts +0 -245
  220. package/src/core/proc-group.ts +0 -48
  221. package/src/core/project-trust.ts +0 -98
  222. package/src/core/reflection.ts +0 -165
  223. package/src/core/sandbox-config.ts +0 -186
  224. package/src/core/session-id.ts +0 -24
  225. package/src/core/session-images.ts +0 -73
  226. package/src/core/session-ops.ts +0 -183
  227. package/src/core/session-text.ts +0 -29
  228. package/src/core/session.ts +0 -469
  229. package/src/core/settings.ts +0 -170
  230. package/src/core/tasks.ts +0 -646
  231. package/src/core/token-scale.ts +0 -108
  232. package/src/core/tools.ts +0 -309
  233. package/src/core/trust.ts +0 -104
  234. package/src/core/types.ts +0 -330
  235. package/src/core/update-check.ts +0 -171
  236. package/src/core/usage.ts +0 -204
  237. package/src/core/validate.ts +0 -121
  238. package/src/core/verify-gate.ts +0 -159
  239. package/src/core/verify.ts +0 -236
  240. package/src/core/voice.ts +0 -158
  241. package/src/core/win-job.ts +0 -183
  242. package/src/core/workspace.ts +0 -184
  243. package/src/design/audit.ts +0 -797
  244. package/src/design/direction.ts +0 -190
  245. package/src/design/rules.ts +0 -157
  246. package/src/eval/bench.ts +0 -150
  247. package/src/eval/gauntlet-runner.ts +0 -215
  248. package/src/eval/gauntlet-support.ts +0 -84
  249. package/src/eval/gauntlet-wave3.ts +0 -269
  250. package/src/eval/gauntlet-wave4.ts +0 -217
  251. package/src/eval/gauntlet.ts +0 -253
  252. package/src/index.ts +0 -17
  253. package/src/lanes/agy.ts +0 -95
  254. package/src/lanes/approval.ts +0 -24
  255. package/src/lanes/claude.ts +0 -129
  256. package/src/lanes/codex.ts +0 -127
  257. package/src/lanes/events.ts +0 -130
  258. package/src/lanes/job.ts +0 -142
  259. package/src/lanes/opencode.ts +0 -122
  260. package/src/lanes/process.ts +0 -184
  261. package/src/lanes/progress.ts +0 -183
  262. package/src/lanes/registry.ts +0 -178
  263. package/src/lanes/runner.ts +0 -124
  264. package/src/lanes/types.ts +0 -112
  265. package/src/market/catalogs/mcp-docs.json +0 -111
  266. package/src/market/catalogs/plugins.json +0 -111
  267. package/src/market/catalogs/skills.json +0 -478
  268. package/src/market/clone.ts +0 -72
  269. package/src/market/context-cost.ts +0 -121
  270. package/src/market/digest.ts +0 -106
  271. package/src/market/index.ts +0 -22
  272. package/src/market/install.ts +0 -578
  273. package/src/market/manifest.ts +0 -187
  274. package/src/market/prereq.ts +0 -145
  275. package/src/market/registry.ts +0 -363
  276. package/src/market/resolve.ts +0 -111
  277. package/src/market/types.ts +0 -236
  278. package/src/market/validate.ts +0 -227
  279. package/src/mcp/client.ts +0 -449
  280. package/src/mcp/config.ts +0 -252
  281. package/src/mcp/local-package.ts +0 -211
  282. package/src/mcp/market-catalog.ts +0 -84
  283. package/src/mcp/market-install.ts +0 -289
  284. package/src/mcp/market.ts +0 -362
  285. package/src/mcp/oauth.ts +0 -251
  286. package/src/mcp/prompts-resources.ts +0 -249
  287. package/src/mcp/shared.ts +0 -149
  288. package/src/mcp/status.ts +0 -67
  289. package/src/mcp/tools.ts +0 -275
  290. package/src/mcp/transport.ts +0 -122
  291. package/src/mcp/trust.ts +0 -25
  292. package/src/memory/blocks.ts +0 -278
  293. package/src/memory/recall.ts +0 -355
  294. package/src/memory/scope.ts +0 -182
  295. package/src/memory/store.ts +0 -105
  296. package/src/memory/tools.ts +0 -99
  297. package/src/plugins/cli.ts +0 -119
  298. package/src/plugins/discover.ts +0 -108
  299. package/src/plugins/index.ts +0 -50
  300. package/src/plugins/install.ts +0 -184
  301. package/src/plugins/load.ts +0 -124
  302. package/src/plugins/manifest.ts +0 -92
  303. package/src/plugins/state.ts +0 -83
  304. package/src/providers/auth.ts +0 -408
  305. package/src/providers/cache.ts +0 -223
  306. package/src/providers/catalog-local.ts +0 -160
  307. package/src/providers/catalog.ts +0 -421
  308. package/src/providers/middleware-context.ts +0 -86
  309. package/src/providers/middleware.ts +0 -373
  310. package/src/providers/model-list.ts +0 -23
  311. package/src/providers/oauth/common.ts +0 -105
  312. package/src/providers/oauth/device-code.ts +0 -107
  313. package/src/providers/oauth/github-copilot.ts +0 -146
  314. package/src/providers/oauth/loopback.ts +0 -158
  315. package/src/providers/oauth/openai.ts +0 -163
  316. package/src/providers/oauth/openrouter.ts +0 -89
  317. package/src/providers/oauth/pkce.ts +0 -45
  318. package/src/providers/oauth/registry.ts +0 -39
  319. package/src/providers/oauth/seam.ts +0 -89
  320. package/src/providers/profile-glm53.ts +0 -111
  321. package/src/providers/profile-sonnet5-persona.ts +0 -65
  322. package/src/providers/profile-sonnet5-voice.ts +0 -23
  323. package/src/providers/profiles.ts +0 -156
  324. package/src/providers/provider-config.ts +0 -311
  325. package/src/providers/registry.ts +0 -333
  326. package/src/providers/responses.ts +0 -209
  327. package/src/providers/retry.ts +0 -234
  328. package/src/providers/router.ts +0 -294
  329. package/src/providers/sse.ts +0 -26
  330. package/src/providers/stream-errors.ts +0 -117
  331. package/src/providers/stream.ts +0 -566
  332. package/src/providers/thinking.ts +0 -189
  333. package/src/providers/wire-messages.ts +0 -129
  334. package/src/providers/wire-responses.ts +0 -79
  335. package/src/providers/wire-select.ts +0 -53
  336. package/src/server/http.ts +0 -291
  337. package/src/server/openapi.ts +0 -246
  338. package/src/sextant/card-hits.ts +0 -102
  339. package/src/sextant/card-keys.ts +0 -55
  340. package/src/sextant/context-source.ts +0 -157
  341. package/src/sextant/crew-cards.ts +0 -350
  342. package/src/sextant/draw-agents.ts +0 -273
  343. package/src/sextant/draw-code.ts +0 -388
  344. package/src/sextant/draw-context.ts +0 -222
  345. package/src/sextant/draw-frame.ts +0 -164
  346. package/src/sextant/draw-market.ts +0 -573
  347. package/src/sextant/draw-messages.ts +0 -386
  348. package/src/sextant/draw-pet.ts +0 -230
  349. package/src/sextant/draw-plan.ts +0 -187
  350. package/src/sextant/draw-tabs.ts +0 -85
  351. package/src/sextant/draw-util.ts +0 -65
  352. package/src/sextant/draw-wizard.ts +0 -378
  353. package/src/sextant/engine.ts +0 -230
  354. package/src/sextant/frame-hits.ts +0 -25
  355. package/src/sextant/frame.ts +0 -101
  356. package/src/sextant/git-status.ts +0 -197
  357. package/src/sextant/grid.ts +0 -59
  358. package/src/sextant/input.ts +0 -119
  359. package/src/sextant/keys.ts +0 -521
  360. package/src/sextant/layout.ts +0 -86
  361. package/src/sextant/local-commands.ts +0 -169
  362. package/src/sextant/market-source.ts +0 -287
  363. package/src/sextant/mentions.ts +0 -200
  364. package/src/sextant/message-hits.ts +0 -26
  365. package/src/sextant/model.ts +0 -387
  366. package/src/sextant/overlays.ts +0 -456
  367. package/src/sextant/panel-hits.ts +0 -38
  368. package/src/sextant/pet.ts +0 -399
  369. package/src/sextant/screen.ts +0 -324
  370. package/src/sextant/scroll-hits.ts +0 -66
  371. package/src/sextant/scrollbar.ts +0 -82
  372. package/src/sextant/sextant-bridge.ts +0 -174
  373. package/src/sextant/sextant-cards.ts +0 -142
  374. package/src/sextant/sextant-diff-base.ts +0 -63
  375. package/src/sextant/sextant-files.ts +0 -154
  376. package/src/sextant/sextant-frame-loop.ts +0 -335
  377. package/src/sextant/sextant-renderer.ts +0 -574
  378. package/src/sextant/sextant-repo.ts +0 -140
  379. package/src/sextant/theme.ts +0 -66
  380. package/src/sextant/tool-rows.ts +0 -189
  381. package/src/sextant/types.ts +0 -493
  382. package/src/skills/index.ts +0 -387
  383. package/src/skills/pack.ts +0 -220
  384. package/src/skills/spec.ts +0 -162
  385. package/src/skills/tools.ts +0 -69
  386. package/src/skills/versioned.ts +0 -227
  387. package/src/telemetry/otel-export.ts +0 -122
  388. package/src/telemetry/otel-lanes.ts +0 -89
  389. package/src/telemetry/otel-logs.ts +0 -131
  390. package/src/telemetry/otel-metrics.ts +0 -136
  391. package/src/telemetry/otel.ts +0 -397
  392. package/src/telemetry/otlp.ts +0 -76
  393. package/src/tools/ask-user.ts +0 -156
  394. package/src/tools/bash-bg.ts +0 -94
  395. package/src/tools/bash-jobs.ts +0 -237
  396. package/src/tools/design.ts +0 -151
  397. package/src/tools/evalcell.ts +0 -338
  398. package/src/tools/html-text.ts +0 -139
  399. package/src/tools/provider.ts +0 -149
  400. package/src/tools/task.ts +0 -250
  401. package/src/tools/todo.ts +0 -320
  402. package/src/tools/webfetch.ts +0 -332
  403. package/src/tools/websearch.ts +0 -359
  404. package/src/tui/agents-cmd.ts +0 -41
  405. package/src/tui/app.ts +0 -749
  406. package/src/tui/attach.ts +0 -127
  407. package/src/tui/boot-notes.ts +0 -41
  408. package/src/tui/builtin-prompts.ts +0 -59
  409. package/src/tui/checkpoints-cmd.ts +0 -70
  410. package/src/tui/clipboard-image.ts +0 -81
  411. package/src/tui/clipboard.ts +0 -78
  412. package/src/tui/commands.ts +0 -283
  413. package/src/tui/config-view.ts +0 -53
  414. package/src/tui/context-cmds.ts +0 -282
  415. package/src/tui/cost.ts +0 -108
  416. package/src/tui/crash-guard.ts +0 -173
  417. package/src/tui/focus-terminal.ts +0 -34
  418. package/src/tui/git-cmds.ts +0 -273
  419. package/src/tui/git-plain.ts +0 -58
  420. package/src/tui/info-cmd.ts +0 -150
  421. package/src/tui/input-plain.ts +0 -76
  422. package/src/tui/mcp-cmd.ts +0 -128
  423. package/src/tui/memory-note.ts +0 -77
  424. package/src/tui/modes-cmd.ts +0 -45
  425. package/src/tui/notify-seq.ts +0 -100
  426. package/src/tui/notify.ts +0 -318
  427. package/src/tui/overlays.ts +0 -97
  428. package/src/tui/pi-renderer.ts +0 -428
  429. package/src/tui/providers-cmd.ts +0 -377
  430. package/src/tui/reasoning-view.ts +0 -56
  431. package/src/tui/renderer.ts +0 -128
  432. package/src/tui/replay-marker.ts +0 -29
  433. package/src/tui/session-cmd.ts +0 -148
  434. package/src/tui/session-manage.ts +0 -95
  435. package/src/tui/sextant-attach.ts +0 -102
  436. package/src/tui/sextant-io.ts +0 -202
  437. package/src/tui/sextant-smoke.ts +0 -110
  438. package/src/tui/shell-cmd.ts +0 -158
  439. package/src/tui/smoke.ts +0 -72
  440. package/src/tui/staged-terminal.ts +0 -50
  441. package/src/tui/startup.ts +0 -12
  442. package/src/tui/theme.ts +0 -59
  443. package/src/tui/todo-label.ts +0 -7
  444. package/src/tui/trust-card.ts +0 -107
  445. package/src/tui/tui-commands.ts +0 -87
  446. package/tsconfig.json +0 -30
  447. package/vendor/pi-tui/LICENSE +0 -21
  448. package/vendor/pi-tui/PATCHES.md +0 -12
  449. package/vendor/pi-tui/PROVENANCE.md +0 -12
  450. package/vendor/pi-tui/README.upstream.md +0 -854
  451. package/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  452. package/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  453. package/vendor/pi-tui/src/alt-screen-search.ts +0 -158
  454. package/vendor/pi-tui/src/autocomplete.ts +0 -827
  455. package/vendor/pi-tui/src/components/alt-screen-flash.ts +0 -52
  456. package/vendor/pi-tui/src/components/box.ts +0 -138
  457. package/vendor/pi-tui/src/components/cancellable-loader.ts +0 -41
  458. package/vendor/pi-tui/src/components/editor.ts +0 -2364
  459. package/vendor/pi-tui/src/components/h-stack.ts +0 -45
  460. package/vendor/pi-tui/src/components/image.ts +0 -128
  461. package/vendor/pi-tui/src/components/input.ts +0 -448
  462. package/vendor/pi-tui/src/components/loader.ts +0 -93
  463. package/vendor/pi-tui/src/components/markdown.ts +0 -1016
  464. package/vendor/pi-tui/src/components/scroll-view.ts +0 -217
  465. package/vendor/pi-tui/src/components/select-list.ts +0 -230
  466. package/vendor/pi-tui/src/components/settings-list.ts +0 -277
  467. package/vendor/pi-tui/src/components/spacer.ts +0 -29
  468. package/vendor/pi-tui/src/components/stack.ts +0 -155
  469. package/vendor/pi-tui/src/components/text.ts +0 -108
  470. package/vendor/pi-tui/src/components/truncated-text.ts +0 -66
  471. package/vendor/pi-tui/src/components/v-stack.ts +0 -34
  472. package/vendor/pi-tui/src/editor-component.ts +0 -75
  473. package/vendor/pi-tui/src/fuzzy.ts +0 -138
  474. package/vendor/pi-tui/src/index.ts +0 -149
  475. package/vendor/pi-tui/src/keybindings.ts +0 -321
  476. package/vendor/pi-tui/src/keys.ts +0 -1402
  477. package/vendor/pi-tui/src/kill-ring.ts +0 -47
  478. package/vendor/pi-tui/src/latex.ts +0 -1381
  479. package/vendor/pi-tui/src/layout-node.ts +0 -52
  480. package/vendor/pi-tui/src/layout.ts +0 -411
  481. package/vendor/pi-tui/src/native-modifiers.ts +0 -60
  482. package/vendor/pi-tui/src/native-module-path.ts +0 -32
  483. package/vendor/pi-tui/src/stdin-buffer.ts +0 -445
  484. package/vendor/pi-tui/src/terminal-colors.ts +0 -74
  485. package/vendor/pi-tui/src/terminal-image.ts +0 -701
  486. package/vendor/pi-tui/src/terminal.ts +0 -554
  487. package/vendor/pi-tui/src/tui-alt-screen.ts +0 -1379
  488. package/vendor/pi-tui/src/tui-main-screen.ts +0 -655
  489. package/vendor/pi-tui/src/tui.ts +0 -1264
  490. package/vendor/pi-tui/src/undo-stack.ts +0 -29
  491. package/vendor/pi-tui/src/utils.ts +0 -1327
  492. package/vendor/pi-tui/src/word-navigation.ts +0 -118
  493. package/vendor/pi-tui/test/test-themes.ts +0 -39
  494. package/vendor/pi-tui/test/virtual-terminal.ts +0 -219
  495. /package/{src/providers → dist/cli}/models-index.json +0 -0
@@ -1,578 +0,0 @@
1
- /** One install entry, three kinds, one order of events — plan, show, ask, write.
2
- *
3
- * The MCP market established the order and it is the whole point of this module: the human sees the exact
4
- * command, folder or file list BEFORE anything lands, and the write happens only after a yes. A skill, a
5
- * plugin and an MCP server say different things in that preview ("copies one file, runs nothing" vs
6
- * "copies a folder whose code rovecode will run"), so the sentences differ per kind — but a caller only
7
- * ever calls `planInstall` then `runInstall`, and neither can be skipped by a new kind arriving later.
8
- *
9
- * Delegation, not reimplementation: MCP goes through mcp/market-install.ts (planner, `${NAME}` filling,
10
- * trust-recording write), plugins through plugins/install.ts (shallow clone, manifest validation, project
11
- * trust). Only skills are written here, because "copy files into a folder" had no installer yet.
12
- *
13
- * Project scope is the trusted scope: a project MCP file or plugin folder installed through this path is
14
- * recorded as trusted, because the human just approved the exact content. Skills are files, never code —
15
- * they carry no trust gate, and the preview says so. */
16
-
17
- import { cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
18
- import { tmpdir } from "node:os";
19
- import { dirname, join, sep, resolve as resolvePath } from "node:path";
20
- import { describePlan, fillPlan, namesWritten, planInstall as planMcp, removeServer, unfilledPending, writeServer, type InstallPlan as McpPlan } from "../mcp/market-install.ts";
21
- import { mcpConfigFiles, parseConfigFile } from "../mcp/config.ts";
22
- import { mcpTrustStatus } from "../mcp/trust.ts";
23
- import { addPlugin, cloneKey, removePlugin, scopeRoot, type CopyTree, type Spawn } from "../plugins/install.ts";
24
- import { discoverPlugins } from "../plugins/discover.ts";
25
- import { checkPrereq, prereqLine, prereqOf, type PrereqEnv } from "./prereq.ts";
26
- import { installLocalPackage, localLaunch } from "../mcp/local-package.ts";
27
- import { buildRecord, forgetInstall, recordInstall } from "./manifest.ts";
28
- import { cloneAtRef, type ResolvedBy } from "./clone.ts";
29
- import { contextCostLines, contextCostOf } from "./context-cost.ts";
30
- import { digestOf } from "./digest.ts";
31
- import type { InstalledState, InstallOutcome, InstallPlanView, MarketItem, MarketRow, MarketScope } from "./types.ts";
32
-
33
- export interface PlanOptions {
34
- scope: MarketScope;
35
- cwd: string;
36
- home: string;
37
- /** which of an MCP entry's install forms (default the first) */
38
- pick?: number;
39
- /** override the installed name */
40
- as?: string;
41
- /** PATH lookup for the prerequisite line — tests inject; production reads the real environment */
42
- prereqEnv?: PrereqEnv;
43
- /** pin a git source to a branch, tag or commit (`--ref`). clone.ts tells the three apart by asking git
44
- * rather than by looking at the string, and records which one answered. */
45
- ref?: string;
46
- /** the model the plan is being drawn for, so the token estimate can be scaled to its tokenizer. Left
47
- * undefined when nothing is configured — an unscaled number that says so beats one scaled to a model
48
- * the person is not running. */
49
- model?: { provider: string; model: string };
50
- /** MCP only: install the npx package ONCE and launch it with node (mcp/local-package.ts). True after the
51
- * human said yes to the offer (or passed --local); false or undefined writes today's npx line. Never
52
- * decided here — the surfaces ask, this only carries the answer. */
53
- local?: boolean;
54
- }
55
-
56
- export interface RunDeps {
57
- /** how `git clone` runs — tests inject one that never touches the network */
58
- spawn?: Spawn;
59
- /** replace something already installed under that name */
60
- force?: boolean;
61
- /** no network, for real: an install whose source has to be fetched is refused rather than quietly
62
- * cloning. `--offline` used to stop only the registry lookup, so `install --offline` still went to the
63
- * network and succeeded — a flag that says "skips the network entirely" has to mean it. */
64
- offline?: boolean;
65
- /** Clones made during THIS command, shared with plugins/install.ts (same map, same `cloneKey`). Three
66
- * plugins out of one monorepo become one clone. The CACHE owns every directory in it, so whoever
67
- * created the map must call `disposeCloneCache` in a finally — otherwise the clones outlive the
68
- * command in the temp directory. */
69
- cloneCache?: Map<string, string>;
70
- /** the copy step. Real installs leave it alone; a test injects one that fails part way through, which is
71
- * the only way to observe that the staging directory actually protects the previous install. */
72
- copy?: CopyTree;
73
- }
74
-
75
- /** The names an item may be installed under. `--as` is human input reaching a path join, so it is checked
76
- * like one: `--as "../../../head-pwned"` wrote a skill outside ROVECODE_HOME entirely, `--as ""` targeted
77
- * the skills root itself, and `--as "C:/x"` produced a raw ENOENT. Only a plain slug is a name. */
78
- const INSTALL_NAME = /^[a-z0-9][a-z0-9._-]{0,63}$/i;
79
- export function validInstallName(name: string): boolean {
80
- return INSTALL_NAME.test(name) && name !== "." && name !== "..";
81
- }
82
-
83
- /** The prerequisite row, or nothing. Deliberately `requires`, not `needs`: `needs` was already spoken for
84
- * by "this install needs an argument from YOU", and one word doing two jobs in the same paragraph is how a
85
- * plan stops being read. `requires` is about the machine, `fill in` is about the human.
86
- *
87
- * Placed right under `runs`/`connects`/`source`, because both answer the same question — what is going to
88
- * be executed or fetched — while `writes` and `fill in` are about what happens to the disk. It never
89
- * blocks: some people install the tool next, and a warning is not a gate. */
90
- function requiresLine(item: MarketItem, opts: PlanOptions): string[] {
91
- // install-once runs npm now and node at every start — those are the programs to look for, not npx
92
- if (opts.local === true && item.install.kind === "mcp") {
93
- const both = ["npm", "node"].map((p) => prereqLine(checkPrereq(p, opts.prereqEnv))).filter((l): l is string => l !== undefined);
94
- return both.length === 0 ? [] : [` requires ${both.join(" · ")}`];
95
- }
96
- const line = prereqLine(prereqOf(item, opts.prereqEnv));
97
- return line === undefined ? [] : [` requires ${line}`];
98
- }
99
-
100
- /** describePlan's own pending rows say the same thing the market's `fill in` says, one line later and
101
- * without the file path. Drop them here rather than change describePlan, which `rovecode mcp add` still
102
- * uses and where there is no `fill in` to duplicate. */
103
- const PENDING_ROW = /^ {2}needs {6}/;
104
-
105
- /** How many skills this machine already has, for the "past 50 the index leaves the prompt" warning.
106
- *
107
- * Counted from the two folders the market installs into. That UNDERCOUNTS: a plugin can contribute skills
108
- * too, and those are not visible without loading the plugin. Undercounting is the safe direction — it can
109
- * only make the warning silent, never make it wrong — and a warning that fires with a made-up number is
110
- * worth less than no warning at all. */
111
- function installedSkillCount(cwd: string, home: string): number {
112
- let n = 0;
113
- for (const root of [join(home, "skills"), join(cwd, ".rovecode", "skills")]) {
114
- if (!existsSync(root)) continue;
115
- try {
116
- for (const name of readdirSync(root)) if (existsSync(join(root, name, "SKILL.md"))) n += 1;
117
- } catch { /* unreadable folder: count what we could */ }
118
- }
119
- return n;
120
- }
121
-
122
- /** What this adds to every prompt, and what it adds only when the model opens it. Two numbers rather than
123
- * one because a skill's index line and its body differ by roughly thirty times — a single "per turn"
124
- * figure would overstate an unopened skill by that much. */
125
- function contextLines(item: MarketItem, opts: PlanOptions): string[] {
126
- const installed = installedSkillCount(opts.cwd, opts.home);
127
- const cost = contextCostOf(item, { installedSkills: installed, ...(opts.model ? { model: opts.model } : {}) });
128
- const lines = contextCostLines(cost);
129
- return lines.length === 0 ? [] : lines.map((l, i) => (i === 0 ? ` context ${l}` : ` ${l}`));
130
- }
131
-
132
- /** put the requires row directly after the line that says what will run or be fetched */
133
- function withRequires(lines: string[], item: MarketItem, opts: PlanOptions): string[] {
134
- const requires = [...requiresLine(item, opts), ...contextLines(item, opts)];
135
- if (requires.length === 0) return lines;
136
- // `runs`/`connects` first when there is one — that is the line the requirement belongs to. `source` is
137
- // only the fallback, for a skill or plugin whose plan has no launch line at all.
138
- const at = lines.findIndex((l) => /^ {2}(runs|connects) {3,}/.test(l));
139
- const anchor = at >= 0 ? at : lines.findIndex((l) => /^ {2}source {3,}/.test(l));
140
- return anchor < 0 ? [...lines, ...requires] : [...lines.slice(0, anchor + 1), ...requires, ...lines.slice(anchor + 1)];
141
- }
142
-
143
- /** where a skill of this id lives under a scope */
144
- export function skillDir(id: string, opts: { scope: MarketScope; cwd: string; home: string }): string {
145
- const root = opts.scope === "project" ? join(opts.cwd, ".rovecode", "skills") : join(opts.home, "skills");
146
- const dir = join(root, id);
147
- // belt and braces: even a name that slipped past the check cannot land outside the skills root
148
- if (!resolvePath(dir).startsWith(resolvePath(root) + sep)) throw new Error(`"${id}" is not a usable skill name`);
149
- return dir;
150
- }
151
-
152
- // ---------------------------------------------------------------- planning (writes nothing)
153
-
154
- /** The publisher's own status, said before anything else in the preview.
155
- *
156
- * First line, not a row among the rows: `requires` and `context` describe what an install COSTS, and
157
- * someone reading those has already decided they want the thing. "The publisher stopped maintaining
158
- * this" is a reason not to want it, so it goes above the decision rather than inside it.
159
- *
160
- * It never blocks. An archived skill is still a working skill, plenty of people install one on purpose,
161
- * and a market that refuses is a market that gets worked around. The wording is deliberately the flag's
162
- * own: GitHub says `archived`, so we say "archived on GitHub" — "abandoned" is a judgement about someone
163
- * else's work that nobody upstream made and we are in no position to make for them. */
164
- function statusLines(item: MarketItem): string[] {
165
- const status = item.status;
166
- if (status === undefined || status === "") return [];
167
- const said =
168
- status === "archived" ? "archived on GitHub — the publisher has stopped maintaining it"
169
- : status === "deprecated" ? "marked deprecated by its publisher"
170
- : `marked "${status}" by its publisher`;
171
- return [` ! ${said}. It still installs; nothing here is blocked.`];
172
- }
173
-
174
- /** the whole preview for one item: the publisher's status first, then what the install does */
175
- function previewFor(lines: string[], item: MarketItem, opts: PlanOptions): string[] {
176
- return [...statusLines(item), ...withRequires(lines, item, opts)];
177
- }
178
-
179
- export function planInstall(item: MarketItem, opts: PlanOptions): InstallPlanView | { error: string } {
180
- const { install } = item;
181
- // checked BEFORE any path is built from it, for every kind
182
- // `--ref` is only wired through the skill cloner. Accepting it for a plugin and ignoring it would be
183
- // the exact failure this feature exists to prevent: the human believes they pinned, and something else
184
- // is installed. Refuse until plugins/install.ts takes a ref.
185
- if (opts.ref !== undefined && item.install.kind === "plugin") {
186
- return { error: `--ref is not wired for plugins yet — it would be accepted and ignored, which is worse than not having it` };
187
- }
188
- if (opts.ref !== undefined && item.install.kind === "mcp") {
189
- return { error: `--ref applies to something that is cloned; an MCP entry is a config line, and its package version belongs in the entry itself` };
190
- }
191
- if (opts.as !== undefined && !validInstallName(opts.as)) {
192
- return { error: `"${opts.as}" is not a usable name — letters, digits, dot, dash and underscore only, and it must not be a path` };
193
- }
194
- if (install.kind === "mcp") {
195
- const inner = planMcp(install.entry, {
196
- scope: opts.scope, cwd: opts.cwd, home: opts.home,
197
- ...(opts.pick !== undefined ? { pick: opts.pick } : {}), ...(opts.as !== undefined ? { name: opts.as } : {}),
198
- ...(opts.local !== undefined ? { local: opts.local } : {}),
199
- });
200
- if ("error" in inner) return inner;
201
- const view: InstallPlanView = {
202
- item, target: inner.file, scope: opts.scope,
203
- preview: [
204
- ...previewFor(describePlan(inner, opts.scope === "project" ? "env" : "prompt").filter((l) => !PENDING_ROW.test(l)), item, opts),
205
- ...(item.planNote ?? []),
206
- ],
207
- asks: inner.asks.map((a) => ({ ...a })), pending: [...inner.pending],
208
- };
209
- const existing = existingMcpNames(opts.cwd, opts.home, opts.scope);
210
- if (existing.includes(inner.name)) view.replaces = `${inner.name} in ${inner.file}`;
211
- return view;
212
- }
213
-
214
- const id = opts.as ?? item.id;
215
- if (install.kind === "plugin") {
216
- // `--as` cannot be honoured here and must not be accepted silently: addPlugin writes under the name in
217
- // the plugin's own manifest, so a rename would put the folder somewhere the preview did not say.
218
- if (opts.as !== undefined) return { error: `--as does not apply to a plugin: it installs under the name in its own manifest` };
219
- const dir = join(scopeRoot(opts.scope, opts.cwd, opts.home), item.id);
220
- const preview = [
221
- `${item.title}${item.version ? ` ${item.version}` : ""}`,
222
- ` kind plugin — a folder of CODE that rovecode loads and RUNS in this process`,
223
- ` source ${install.git ? `git clone --depth 1 ${install.source}` : `copy of the folder ${install.source}`}${install.subfolder ? ` (subfolder ${install.subfolder})` : ""}`,
224
- ` publisher ${item.publisher}`,
225
- ...(item.license ? [` licence ${item.license}`] : []),
226
- ...(item.repository ? [` repo ${item.repository}`] : []),
227
- ` writes ${dir}${install.git ? " (the folder is named by the plugin's manifest; this is the expected name)" : ""}`,
228
- opts.scope === "project"
229
- ? ` trust installed into this repo — approving here records this exact content as trusted on this machine`
230
- : ` trust user scope (~/.rovecode/plugins): loaded in every project you open`,
231
- ` a plugin can add tools, hooks, commands, skills and MCP servers. Install one only from a publisher you trust.`,
232
- ...(item.planNote ?? []),
233
- ];
234
- return { item, target: dir, scope: opts.scope, preview: previewFor(preview, item, opts), asks: item.env.map((e) => ({ ...e })), pending: [],
235
- ...(existsSync(dir) ? { replaces: dir } : {}) };
236
- }
237
-
238
- const dir = skillDir(id, opts);
239
- const fileList = install.files ?? [];
240
- // a skill IS a folder with a SKILL.md — without one nothing would ever find it again: installedState
241
- // looks for exactly that file, so it would install and then read as "not installed" forever
242
- if (install.source === undefined && !fileList.some((f) => f.path.replace(/\\/g, "/").toLowerCase() === "skill.md")) {
243
- return { error: `${item.id} carries no SKILL.md — a skill is a folder with a SKILL.md, and rovecode would never see this one` };
244
- }
245
- const preview = [
246
- `${item.title}${item.version ? ` ${item.version}` : ""}`,
247
- ` kind skill — instructions the model reads. Files only: nothing here is executed on install.`,
248
- install.source
249
- ? ` source git clone --depth 1 ${install.source.git}${install.source.subfolder ? ` (subfolder ${install.source.subfolder})` : ""}`
250
- : ` source ${fileList.length} file${fileList.length === 1 ? "" : "s"} from rovecode's catalog`,
251
- ` publisher ${item.publisher}`,
252
- ...(item.license ? [` licence ${item.license}`] : []),
253
- ...(item.repository ? [` repo ${item.repository}`] : []),
254
- ` writes ${dir}`,
255
- ...fileList.slice(0, 8).map((f) => ` ${f.path}`),
256
- ...(fileList.length > 8 ? [` … and ${fileList.length - 8} more`] : []),
257
- ...(item.planNote ?? []),
258
- ];
259
- return { item, target: dir, scope: opts.scope, preview: previewFor(preview, item, opts), asks: item.env.map((e) => ({ ...e })), pending: [],
260
- ...(existsSync(dir) ? { replaces: dir } : {}) };
261
- }
262
-
263
- // ---------------------------------------------------------------- writing (only after a yes)
264
-
265
- export async function runInstall(plan: InstallPlanView, answers: Record<string, string>, opts: PlanOptions, deps: RunDeps = {}): Promise<InstallOutcome> {
266
- const { item } = plan;
267
- const { install } = item;
268
- try {
269
- if (install.kind === "mcp") {
270
- const inner = planMcp(install.entry, {
271
- scope: opts.scope, cwd: opts.cwd, home: opts.home,
272
- ...(opts.pick !== undefined ? { pick: opts.pick } : {}), ...(opts.as !== undefined ? { name: opts.as } : {}),
273
- ...(opts.local !== undefined ? { local: opts.local } : {}),
274
- });
275
- if ("error" in inner) return { ok: false, error: inner.error };
276
- // install-once (mcp/local-package.ts): npm runs FIRST, and only its success reaches mcp.json. A failed
277
- // npm leaves the file as it was — no half-entry pointing at a bin that never arrived — and says why.
278
- let launch: { command: string; args: string[] } | undefined;
279
- let pkg: NonNullable<Extract<InstallOutcome, { ok: true }>["package"]> | undefined;
280
- if (inner.local) {
281
- if (deps.offline === true) return { ok: false, error: `--offline: installing ${inner.local.pkg.spec} once means npm fetching it now; drop --local to write the npx line, which fetches at launch instead` };
282
- const r = await installLocalPackage(inner.local.pkg, inner.local.prefix, deps.spawn ? { spawn: deps.spawn } : {});
283
- if (!r.ok) return { ok: false, error: r.error };
284
- launch = localLaunch(r.pkg, inner.local.pkg.rest);
285
- pkg = { name: r.pkg.name, version: r.pkg.version, prefix: inner.local.prefix, bin: r.pkg.bin,
286
- ...(r.pkg.integrity !== undefined ? { integrity: r.pkg.integrity } : {}),
287
- ...(r.pkg.missing.length > 0 ? { missing: r.pkg.missing } : {}) };
288
- }
289
- const raw = fillPlan(inner, answers, launch);
290
- const written = writeServer(inner.file, inner.name, raw, {
291
- ...(deps.force === true ? { replace: true } : {}),
292
- ...(opts.scope === "project" ? { trustHome: opts.home } : {}),
293
- });
294
- recordInstall(buildRecord(item, { scope: opts.scope, target: inner.file, ...(pkg ? { package: { ...pkg, missing: pkg.missing ?? [] } } : {}) }),
295
- { cwd: opts.cwd, home: opts.home, stillInstalled: recordStillInstalled(opts.cwd, opts.home) });
296
- // The same closing line `rovecode mcp add` prints (cli/mcp-market-cmd.ts), for the same two reasons: an
297
- // entry still carrying a placeholder is skipped by the loader, so "restart rovecode" would send the
298
- // person to a restart that changes nothing; and the placeholder is the one thing they must go and
299
- // edit, so it is named here, not left for them to discover in a skipped-server warning later.
300
- const fillIn = unfilledPending(inner, raw);
301
- return {
302
- ok: true, item, target: inner.file, scope: opts.scope, envNames: namesWritten(inner, raw),
303
- ...(written.trusted !== undefined ? { trusted: written.trusted } : {}),
304
- ...(pkg ? { package: pkg } : {}),
305
- ...(fillIn.length ? { fillIn } : {}),
306
- next: fillIn.length
307
- ? `fill in before use: ${fillIn.join(", ")} — edit the args in ${inner.file}; until then this server is skipped`
308
- : "restart rovecode to connect — MCP servers are read once per process (a session that installs from /market connects it on the spot)",
309
- };
310
- }
311
-
312
- if (deps.offline === true && needsNetwork(install)) {
313
- return { ok: false, error: `--offline: ${item.id} would have to be fetched (${sourceOf(install)}) and nothing local can stand in for it` };
314
- }
315
- if (install.kind === "plugin") {
316
- // a monorepo plugin lives in plugins/<name>; plugins/install.ts validates the subfolder again
317
- const r = await addPlugin(install.source, {
318
- cwd: opts.cwd, home: opts.home, scope: opts.scope,
319
- ...(deps.force === true ? { force: true } : {}), ...(deps.spawn ? { spawn: deps.spawn } : {}),
320
- ...(install.subfolder !== undefined ? { subfolder: install.subfolder } : {}),
321
- ...(deps.cloneCache !== undefined ? { cloneCache: deps.cloneCache } : {}),
322
- });
323
- if (!r.ok) return { ok: false, error: r.error };
324
- recordInstall(buildRecord(item, { scope: opts.scope, target: r.dir,
325
- ...(() => { const d = digestOf(r.dir); return d ? { digest: d } : {}; })(),
326
- ...(install.git ? { git: { source: install.source } } : {}) }),
327
- { cwd: opts.cwd, home: opts.home, stillInstalled: recordStillInstalled(opts.cwd, opts.home) });
328
- return {
329
- ok: true, item, target: r.dir, scope: opts.scope, envNames: item.env.filter((e) => e.required).map((e) => e.name),
330
- ...(opts.scope === "project" ? { trusted: true } : {}),
331
- next: "restart rovecode — plugins are loaded once at startup",
332
- };
333
- }
334
-
335
- const dir = plan.target;
336
- if (existsSync(dir) && deps.force !== true) return { ok: false, error: `${dir} already exists (use --force to replace)` };
337
- let clonedSha: string | undefined;
338
- let clonedBy: ResolvedBy | undefined;
339
- if (install.source) {
340
- const r = await cloneSkill(install.source, dir, deps, opts.ref);
341
- if (!r.ok) return { ok: false, error: r.error };
342
- clonedSha = r.sha;
343
- clonedBy = r.resolvedBy;
344
- } else {
345
- // Build the whole thing beside the target and swap at the end. Writing in place meant deleting the
346
- // installed copy FIRST and then failing half way through the loop — the caller saw a clean
347
- // {ok:false} while the previous version was already gone and a partial one sat in its place.
348
- mkdirSync(dirname(dir), { recursive: true }); // the scope's skills/ folder may not exist yet
349
- const staging = mkdtempSync(join(dirname(dir), `.rovecode-skill-${item.id}-`));
350
- try {
351
- for (const f of install.files ?? []) {
352
- const dest = join(staging, f.path);
353
- // checked BEFORE anything is removed, not after — the catalog reader is the first lock, this the second
354
- if (!resolvePath(dest).startsWith(resolvePath(staging) + sep) ) return { ok: false, error: `${f.path} escapes the skill's folder` };
355
- mkdirSync(dirname(dest), { recursive: true });
356
- writeFileSync(dest, f.text);
357
- }
358
- if (existsSync(dir)) rmSync(dir, { recursive: true, force: true });
359
- renameSync(staging, dir);
360
- } finally {
361
- rmSync(staging, { recursive: true, force: true }); // no-op once it has been renamed into place
362
- }
363
- }
364
- recordInstall(buildRecord(item, { scope: opts.scope, target: dir,
365
- ...(() => { const d = digestOf(dir); return d ? { digest: d } : {}; })(),
366
- ...(install.source ? { git: { source: install.source.git,
367
- ...(clonedSha !== undefined ? { sha: clonedSha } : {}),
368
- ...(opts.ref !== undefined ? { ref: opts.ref } : {}),
369
- ...(clonedBy !== undefined ? { resolvedBy: clonedBy } : {}) } } : {}) }),
370
- { cwd: opts.cwd, home: opts.home, stillInstalled: recordStillInstalled(opts.cwd, opts.home) });
371
- return {
372
- ok: true, item, target: dir, scope: opts.scope, envNames: [],
373
- next: "restart rovecode — skills are indexed at startup",
374
- };
375
- } catch (e) {
376
- return { ok: false, error: e instanceof Error ? e.message : String(e) };
377
- }
378
- }
379
-
380
- /** Is what this record describes still on disk? Used to prune orphans on every write — a record whose
381
- * thing was deleted by hand is ignored anyway, and dropping it keeps the file from growing forever.
382
- * Asked through `installedState`, so it answers the same question `list` does rather than a second
383
- * approximation of it (an MCP record's target is the shared mcp.json, which exists whether or not the
384
- * entry inside it does — `existsSync` would be wrong here). */
385
- function recordStillInstalled(cwd: string, home: string) {
386
- return (r: { kind: MarketItem["kind"]; id: string; scope: MarketScope }): boolean =>
387
- installedState({ kind: r.kind, id: r.id } as MarketItem, cwd, home, r.scope) !== undefined;
388
- }
389
-
390
- /** The commit a clone is sitting on, read from the git directory rather than from stdout — `Spawn` gives
391
- * us an exit code and stderr, not stdout, and adding a channel to that seam for one string is not worth
392
- * it. Undefined when it cannot be read; provenance is best-effort. */
393
- function readSha(clone: string): string | undefined {
394
- try {
395
- const head = readFileSync(join(clone, ".git", "HEAD"), "utf8").trim();
396
- const ref = /^ref:\s*(.+)$/.exec(head)?.[1];
397
- if (ref === undefined) return /^[0-9a-f]{40}$/i.test(head) ? head : undefined;
398
- const direct = join(clone, ".git", ...ref.split("/"));
399
- if (existsSync(direct)) { const v = readFileSync(direct, "utf8").trim(); return /^[0-9a-f]{40}$/i.test(v) ? v : undefined; }
400
- const packed = join(clone, ".git", "packed-refs");
401
- if (!existsSync(packed)) return undefined;
402
- for (const line of readFileSync(packed, "utf8").split("\n")) {
403
- const m = /^([0-9a-f]{40})\s+(.+)$/i.exec(line.trim());
404
- if (m && m[2] === ref) return m[1]!;
405
- }
406
- return undefined;
407
- } catch { return undefined; }
408
- }
409
-
410
- /** does installing this reach the network? A catalog's literal files and a local folder do not. */
411
- export function needsNetwork(install: MarketItem["install"]): boolean {
412
- if (install.kind === "plugin") return install.git;
413
- if (install.kind === "skill") return install.source !== undefined;
414
- return false; // an MCP install writes a config entry; the server is fetched when it launches, not now
415
- }
416
- function sourceOf(install: MarketItem["install"]): string {
417
- if (install.kind === "plugin") return install.source;
418
- if (install.kind === "skill") return install.source?.git ?? "its catalog files";
419
- return "an mcp.json entry";
420
- }
421
-
422
- /** true for a symbolic link (never throws: an unreadable entry is not copied either) */
423
- function isLink(p: string): boolean {
424
- try { return lstatSync(p).isSymbolicLink(); } catch { return true; }
425
- }
426
-
427
- async function cloneSkill(source: { git: string; subfolder?: string }, dir: string, deps: RunDeps, ref?: string): Promise<{ ok: true; sha?: string; resolvedBy?: ResolvedBy } | { ok: false; error: string }> {
428
- let resolvedBy: ResolvedBy | undefined;
429
- const spawn: Spawn = deps.spawn ?? (async (cmd, cwd) => {
430
- const p = Bun.spawn(cmd, { cwd, stdout: "ignore", stderr: "pipe", stdin: "ignore" });
431
- return { code: await p.exited, stderr: await new Response(p.stderr).text() };
432
- });
433
- const copy: CopyTree = deps.copy ?? ((from, to, filter) => cpSync(from, to, { recursive: true, filter }));
434
-
435
- // The same key and the same map as plugins/install.ts: a skill and a plugin out of one repository, or
436
- // three skills out of one, are cloned once. Clone straight INTO the temp directory (`… <url> .`) so the
437
- // cached value is the clone itself — a cache disposer should never have to take dirname() of what it was
438
- // given and remove a directory nobody handed it.
439
- const key = cloneKey(source.git, ref);
440
- let owned: string | null = null;
441
-
442
- // the clone itself is INSIDE the try: `spawn` does not only return a non-zero code, it can throw
443
- // outright — no git on PATH is an ENOENT, not an exit status — and a temp directory created one line
444
- // earlier would otherwise be left behind on the one failure a user is most likely to hit.
445
- try {
446
- const cached = deps.cloneCache?.get(key);
447
- let clone: string;
448
- if (cached !== undefined) {
449
- clone = cached;
450
- } else {
451
- owned = mkdtempSync(join(tmpdir(), "rovecode-skill-"));
452
- const r = await cloneAtRef(spawn, source.git, owned, ref);
453
- if (!r.ok) return { ok: false, error: r.error }; // the finally clears `owned`
454
- resolvedBy = r.resolvedBy;
455
- clone = owned;
456
- }
457
-
458
- const from = source.subfolder ? join(clone, source.subfolder) : clone;
459
- if (!resolvePath(from).startsWith(resolvePath(clone))) return { ok: false, error: `subfolder escapes the clone` };
460
- if (!existsSync(join(from, "SKILL.md"))) return { ok: false, error: `no SKILL.md in ${source.subfolder ?? "the repository root"} — a skill is a folder with a SKILL.md` };
461
- // built beside the target and swapped in, never written over the top: `rmSync` then `cpSync` means a
462
- // failure half way through (full disk, a locked file on Windows, the process killed during
463
- // `update --all`) has already destroyed the working copy and leaves a partial tree in its place.
464
- // The catalog-files path below learned this the hard way; this is the same fix for the clone path.
465
- mkdirSync(dirname(dir), { recursive: true });
466
- const staging = mkdtempSync(join(dirname(dir), `.rovecode-clone-`));
467
- try {
468
- copy(from, staging, (p) => !/(?:^|[\\/])\.git(?:[\\/]|$)/.test(p) && !isLink(p));
469
- if (existsSync(dir)) rmSync(dir, { recursive: true, force: true });
470
- renameSync(staging, dir);
471
- } finally {
472
- rmSync(staging, { recursive: true, force: true }); // a no-op once it has been renamed into place
473
- }
474
- // the commit this actually resolved to, for the record. Best effort: a clone whose HEAD cannot be
475
- // read still installed fine, and a made-up sha would be worse than none.
476
- const head = await spawn(["git", "rev-parse", "HEAD"], clone).catch(() => ({ code: 1, stderr: "" }));
477
- const sha = head.code === 0 ? readSha(clone) : undefined;
478
- if (owned !== null && deps.cloneCache !== undefined) { deps.cloneCache.set(key, owned); owned = null; } // ownership moves to the cache
479
- return { ok: true, ...(sha !== undefined ? { sha } : {}), ...(resolvedBy !== undefined ? { resolvedBy } : {}) };
480
- } finally {
481
- if (owned !== null) rmSync(owned, { recursive: true, force: true });
482
- }
483
- }
484
-
485
- // ---------------------------------------------------------------- what is installed here
486
-
487
- function existingMcpNames(cwd: string, home: string, scope: MarketScope): string[] {
488
- const files = mcpConfigFiles(cwd, home);
489
- const file = scope === "project" ? files.project : files.user;
490
- if (file === undefined || !existsSync(file)) return [];
491
- const anySet = new Proxy({}, { get: () => "set" }) as Record<string, string>;
492
- return parseConfigFile(file, [], anySet).map((s) => s.name);
493
- }
494
-
495
- /** Local truth for one item: is it on disk, where, and does the version differ from the catalog's. */
496
- export function installedState(item: MarketItem, cwd: string, home: string, only?: MarketScope): InstalledState | undefined {
497
- const scopes: readonly MarketScope[] = only ? [only] : ["project", "user"];
498
- if (item.kind === "mcp") {
499
- const files = mcpConfigFiles(cwd, home);
500
- const byScope: Record<MarketScope, string | undefined> = { project: files.project, user: files.user };
501
- for (const scope of scopes) {
502
- const file = byScope[scope];
503
- if (file === undefined || !existsSync(file)) continue;
504
- const anySet = new Proxy({}, { get: () => "set" }) as Record<string, string>;
505
- const hit = parseConfigFile(file, [], anySet).find((s) => s.name === item.id);
506
- if (hit) {
507
- const state: InstalledState = { path: file, scope };
508
- if (scope === "project") state.trusted = mcpTrustStatus(home, file) === "trusted";
509
- return state;
510
- }
511
- }
512
- return undefined;
513
- }
514
- if (item.kind === "plugin") {
515
- const found = discoverPlugins(cwd, { home }).plugins.find((p) => p.name === item.id && (only === undefined || p.scope === only));
516
- if (!found) return undefined;
517
- const state: InstalledState = { path: found.dir, scope: found.scope };
518
- const version = found.manifest?.version;
519
- if (version !== undefined) {
520
- state.version = version;
521
- if (item.version !== undefined && item.version !== version) state.updateAvailable = true;
522
- }
523
- if (found.scope === "project") state.trusted = found.status !== "untrusted";
524
- return state;
525
- }
526
- for (const scope of scopes) {
527
- const dir = skillDir(item.id, { scope, cwd, home });
528
- if (!existsSync(join(dir, "SKILL.md"))) continue;
529
- const state: InstalledState = { path: dir, scope };
530
- const version = skillVersion(join(dir, "SKILL.md"));
531
- if (version !== undefined) {
532
- state.version = version;
533
- if (item.version !== undefined && item.version !== version) state.updateAvailable = true;
534
- }
535
- return state;
536
- }
537
- return undefined;
538
- }
539
-
540
- function skillVersion(file: string): string | undefined {
541
- try {
542
- const head = readFileSync(file, "utf8").slice(0, 2000);
543
- return /^version:\s*(.+)$/m.exec(head)?.[1]?.trim().slice(0, 64);
544
- } catch { return undefined; }
545
- }
546
-
547
- /** Attach local state to every item — what a UI renders. */
548
- export function withInstalled(items: readonly MarketItem[], cwd: string, home: string): MarketRow[] {
549
- return items.map((item) => {
550
- const installed = installedState(item, cwd, home);
551
- return installed ? { ...item, installed } : { ...item };
552
- });
553
- }
554
-
555
- /** `market remove <kind:id>` — undo an install, whichever kind it is. */
556
- export function removeItem(item: MarketItem, cwd: string, home: string, scope?: MarketScope): { ok: true; path: string } | { ok: false; error: string } {
557
- const state = installedState(item, cwd, home, scope);
558
- if (state === undefined) return { ok: false, error: `${item.kind} "${item.id}" is not installed here${scope ? ` in ${scope} scope` : ""}` };
559
- if (item.kind === "mcp") {
560
- // `trustHome` is not optional bookkeeping: removeServer re-records the file's trust after the edit, and
561
- // without it every OTHER server in a project file silently drops to "not approved" for having changed.
562
- const ok = removeServer(state.path, item.id, { trustHome: home });
563
- if (ok) forgetInstall(item.kind, item.id, state.scope, { cwd, home });
564
- return ok ? { ok: true, path: state.path } : { ok: false, error: `no server "${item.id}" in ${state.path}` };
565
- }
566
- if (item.kind === "plugin") {
567
- // through the plugin remover, which also drops the folder's trust entry — a plain rmSync leaves a
568
- // recorded digest pointing at a directory that no longer exists, and the next install is compared to it
569
- const r = removePlugin(item.id, { cwd, home, scope: state.scope });
570
- if (r.ok) forgetInstall(item.kind, item.id, state.scope, { cwd, home });
571
- return r.ok ? { ok: true, path: r.dir } : { ok: false, error: r.error };
572
- }
573
- rmSync(state.path, { recursive: true, force: true });
574
- forgetInstall(item.kind, item.id, state.scope, { cwd, home });
575
- return { ok: true, path: state.path };
576
- }
577
-
578
- export type { McpPlan };