onlycode 1.18.0 → 1.19.0

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 (417) hide show
  1. package/package.json +11 -146
  2. package/src/account/account.ts +0 -463
  3. package/src/account/repo.ts +0 -173
  4. package/src/account/schema.ts +0 -99
  5. package/src/account/url.ts +0 -8
  6. package/src/acp/agent.ts +0 -95
  7. package/src/acp/config-option.ts +0 -203
  8. package/src/acp/content.ts +0 -250
  9. package/src/acp/directory.ts +0 -210
  10. package/src/acp/error.ts +0 -90
  11. package/src/acp/event.ts +0 -342
  12. package/src/acp/permission.ts +0 -124
  13. package/src/acp/profile.ts +0 -42
  14. package/src/acp/service.ts +0 -1048
  15. package/src/acp/session.ts +0 -231
  16. package/src/acp/tool.ts +0 -367
  17. package/src/acp/usage.ts +0 -232
  18. package/src/agent/agent.ts +0 -459
  19. package/src/agent/generate.txt +0 -75
  20. package/src/agent/prompt/compaction.txt +0 -9
  21. package/src/agent/prompt/explore.txt +0 -18
  22. package/src/agent/prompt/summary.txt +0 -11
  23. package/src/agent/prompt/title.txt +0 -44
  24. package/src/agent/subagent-permissions.ts +0 -27
  25. package/src/audio.d.ts +0 -14
  26. package/src/auth/index.ts +0 -99
  27. package/src/background/job.ts +0 -39
  28. package/src/bus/global.ts +0 -22
  29. package/src/cli/bootstrap.ts +0 -11
  30. package/src/cli/cmd/account.ts +0 -264
  31. package/src/cli/cmd/acp.ts +0 -73
  32. package/src/cli/cmd/agent.ts +0 -259
  33. package/src/cli/cmd/attach.ts +0 -97
  34. package/src/cli/cmd/cmd.ts +0 -7
  35. package/src/cli/cmd/db.ts +0 -62
  36. package/src/cli/cmd/debug/agent.handler.ts +0 -193
  37. package/src/cli/cmd/debug/agent.ts +0 -27
  38. package/src/cli/cmd/debug/config.ts +0 -14
  39. package/src/cli/cmd/debug/file.ts +0 -73
  40. package/src/cli/cmd/debug/index.ts +0 -87
  41. package/src/cli/cmd/debug/lsp.ts +0 -50
  42. package/src/cli/cmd/debug/ripgrep.ts +0 -79
  43. package/src/cli/cmd/debug/scrap.ts +0 -15
  44. package/src/cli/cmd/debug/skill.ts +0 -15
  45. package/src/cli/cmd/debug/snapshot.ts +0 -50
  46. package/src/cli/cmd/debug/startup.ts +0 -11
  47. package/src/cli/cmd/debug/v2.ts +0 -44
  48. package/src/cli/cmd/export.ts +0 -292
  49. package/src/cli/cmd/generate.ts +0 -54
  50. package/src/cli/cmd/github.handler.ts +0 -1593
  51. package/src/cli/cmd/github.shared.ts +0 -30
  52. package/src/cli/cmd/github.ts +0 -42
  53. package/src/cli/cmd/import.ts +0 -224
  54. package/src/cli/cmd/mcp.ts +0 -849
  55. package/src/cli/cmd/models.ts +0 -66
  56. package/src/cli/cmd/plug.ts +0 -230
  57. package/src/cli/cmd/pr.ts +0 -115
  58. package/src/cli/cmd/prompt-display.ts +0 -1
  59. package/src/cli/cmd/providers.ts +0 -534
  60. package/src/cli/cmd/run/demo.ts +0 -1274
  61. package/src/cli/cmd/run/entry.body.ts +0 -205
  62. package/src/cli/cmd/run/footer.command.tsx +0 -1064
  63. package/src/cli/cmd/run/footer.menu.tsx +0 -351
  64. package/src/cli/cmd/run/footer.permission.tsx +0 -472
  65. package/src/cli/cmd/run/footer.prompt.tsx +0 -1306
  66. package/src/cli/cmd/run/footer.question.tsx +0 -573
  67. package/src/cli/cmd/run/footer.subagent.tsx +0 -173
  68. package/src/cli/cmd/run/footer.ts +0 -1129
  69. package/src/cli/cmd/run/footer.view.tsx +0 -943
  70. package/src/cli/cmd/run/footer.width.ts +0 -27
  71. package/src/cli/cmd/run/permission.shared.ts +0 -256
  72. package/src/cli/cmd/run/prompt.editor.ts +0 -157
  73. package/src/cli/cmd/run/prompt.shared.ts +0 -153
  74. package/src/cli/cmd/run/question.shared.ts +0 -340
  75. package/src/cli/cmd/run/runtime.boot.ts +0 -202
  76. package/src/cli/cmd/run/runtime.lifecycle.ts +0 -406
  77. package/src/cli/cmd/run/runtime.queue.ts +0 -349
  78. package/src/cli/cmd/run/runtime.shared.ts +0 -17
  79. package/src/cli/cmd/run/runtime.stdin.ts +0 -37
  80. package/src/cli/cmd/run/runtime.ts +0 -814
  81. package/src/cli/cmd/run/scrollback.shared.ts +0 -92
  82. package/src/cli/cmd/run/scrollback.surface.ts +0 -431
  83. package/src/cli/cmd/run/scrollback.writer.tsx +0 -352
  84. package/src/cli/cmd/run/session-data.ts +0 -1113
  85. package/src/cli/cmd/run/session-replay.ts +0 -374
  86. package/src/cli/cmd/run/session.shared.ts +0 -196
  87. package/src/cli/cmd/run/splash.ts +0 -275
  88. package/src/cli/cmd/run/stream.transport.ts +0 -1462
  89. package/src/cli/cmd/run/stream.ts +0 -175
  90. package/src/cli/cmd/run/subagent-data.ts +0 -876
  91. package/src/cli/cmd/run/theme.ts +0 -690
  92. package/src/cli/cmd/run/tool.ts +0 -1489
  93. package/src/cli/cmd/run/trace.ts +0 -94
  94. package/src/cli/cmd/run/turn-summary.ts +0 -47
  95. package/src/cli/cmd/run/types.ts +0 -350
  96. package/src/cli/cmd/run/variant.shared.ts +0 -215
  97. package/src/cli/cmd/run.ts +0 -894
  98. package/src/cli/cmd/serve.ts +0 -24
  99. package/src/cli/cmd/session.ts +0 -147
  100. package/src/cli/cmd/stats.ts +0 -393
  101. package/src/cli/cmd/tui.ts +0 -224
  102. package/src/cli/cmd/uninstall.ts +0 -353
  103. package/src/cli/cmd/upgrade.ts +0 -74
  104. package/src/cli/cmd/web.ts +0 -84
  105. package/src/cli/effect/prompt.ts +0 -37
  106. package/src/cli/effect-cmd.ts +0 -96
  107. package/src/cli/error.ts +0 -130
  108. package/src/cli/heap.ts +0 -45
  109. package/src/cli/logo-pixel.ts +0 -35
  110. package/src/cli/logo.ts +0 -1
  111. package/src/cli/network.ts +0 -64
  112. package/src/cli/tui/layer.ts +0 -7
  113. package/src/cli/tui/validate-session.ts +0 -29
  114. package/src/cli/tui/worker.ts +0 -71
  115. package/src/cli/ui.ts +0 -148
  116. package/src/cli/upgrade.ts +0 -53
  117. package/src/command/index.ts +0 -184
  118. package/src/command/template/initialize.txt +0 -66
  119. package/src/command/template/review.txt +0 -101
  120. package/src/config/agent.ts +0 -59
  121. package/src/config/command.ts +0 -39
  122. package/src/config/config.ts +0 -686
  123. package/src/config/entry-name.ts +0 -19
  124. package/src/config/managed.ts +0 -69
  125. package/src/config/markdown.ts +0 -36
  126. package/src/config/parse.ts +0 -79
  127. package/src/config/paths.ts +0 -45
  128. package/src/config/plugin.ts +0 -79
  129. package/src/config/tui-cwd.ts +0 -5
  130. package/src/config/tui-host-attention.ts +0 -21
  131. package/src/config/tui-migrate.ts +0 -132
  132. package/src/config/tui.ts +0 -274
  133. package/src/config/variable.ts +0 -91
  134. package/src/control-plane/adapters/index.ts +0 -41
  135. package/src/control-plane/adapters/worktree.ts +0 -96
  136. package/src/control-plane/dev/README.md +0 -19
  137. package/src/control-plane/dev/debug-workspace-plugin.ts +0 -73
  138. package/src/control-plane/types.ts +0 -59
  139. package/src/control-plane/util.ts +0 -39
  140. package/src/control-plane/workspace-adapter-runtime.ts +0 -51
  141. package/src/control-plane/workspace-context.ts +0 -26
  142. package/src/control-plane/workspace.ts +0 -989
  143. package/src/effect/app-runtime.ts +0 -132
  144. package/src/effect/bootstrap-runtime.ts +0 -23
  145. package/src/effect/bridge.ts +0 -84
  146. package/src/effect/config-service.ts +0 -67
  147. package/src/effect/instance-ref.ts +0 -11
  148. package/src/effect/instance-registry.ts +0 -12
  149. package/src/effect/instance-state.ts +0 -69
  150. package/src/effect/promise.ts +0 -17
  151. package/src/effect/run-service.ts +0 -47
  152. package/src/effect/runner.ts +0 -217
  153. package/src/effect/runtime-flags.ts +0 -79
  154. package/src/env/index.ts +0 -43
  155. package/src/event-v2-bridge.ts +0 -79
  156. package/src/format/formatter.ts +0 -404
  157. package/src/format/index.ts +0 -205
  158. package/src/git/index.ts +0 -350
  159. package/src/id/id.ts +0 -80
  160. package/src/ide/index.ts +0 -61
  161. package/src/image/image.ts +0 -174
  162. package/src/index.ts +0 -142
  163. package/src/installation/index.ts +0 -350
  164. package/src/lsp/client.ts +0 -650
  165. package/src/lsp/diagnostic.ts +0 -29
  166. package/src/lsp/language.ts +0 -121
  167. package/src/lsp/launch.ts +0 -21
  168. package/src/lsp/lsp.ts +0 -511
  169. package/src/lsp/server.ts +0 -1983
  170. package/src/markdown.d.ts +0 -4
  171. package/src/mcp/auth.ts +0 -174
  172. package/src/mcp/catalog.ts +0 -153
  173. package/src/mcp/index.ts +0 -953
  174. package/src/mcp/oauth-callback.ts +0 -233
  175. package/src/mcp/oauth-provider.ts +0 -206
  176. package/src/node.ts +0 -4
  177. package/src/patch/index.ts +0 -686
  178. package/src/permission/arity.ts +0 -163
  179. package/src/permission/evaluate.ts +0 -1
  180. package/src/permission/index.ts +0 -230
  181. package/src/plugin/azure.ts +0 -26
  182. package/src/plugin/cloudflare.ts +0 -76
  183. package/src/plugin/digitalocean.ts +0 -383
  184. package/src/plugin/github-copilot/copilot.ts +0 -414
  185. package/src/plugin/github-copilot/models.ts +0 -246
  186. package/src/plugin/index.ts +0 -316
  187. package/src/plugin/install.ts +0 -439
  188. package/src/plugin/loader.ts +0 -237
  189. package/src/plugin/meta.ts +0 -188
  190. package/src/plugin/openai/README.md +0 -31
  191. package/src/plugin/openai/codex.ts +0 -641
  192. package/src/plugin/openai/ws-pool.ts +0 -270
  193. package/src/plugin/openai/ws.ts +0 -381
  194. package/src/plugin/pty-environment.ts +0 -24
  195. package/src/plugin/shared.ts +0 -323
  196. package/src/plugin/snowflake-cortex.ts +0 -529
  197. package/src/plugin/tui/internal.ts +0 -10
  198. package/src/plugin/tui/runtime.ts +0 -1130
  199. package/src/plugin/xai.ts +0 -716
  200. package/src/project/bootstrap-service.ts +0 -9
  201. package/src/project/bootstrap.ts +0 -76
  202. package/src/project/instance-context.ts +0 -24
  203. package/src/project/instance-layer.ts +0 -11
  204. package/src/project/instance-runtime.ts +0 -16
  205. package/src/project/instance-store.ts +0 -209
  206. package/src/project/project.ts +0 -519
  207. package/src/project/vcs.ts +0 -431
  208. package/src/provider/auth.ts +0 -233
  209. package/src/provider/error.ts +0 -188
  210. package/src/provider/model-status.ts +0 -8
  211. package/src/provider/provider.ts +0 -1975
  212. package/src/provider/transform.ts +0 -1543
  213. package/src/question/index.ts +0 -229
  214. package/src/question/schema.ts +0 -10
  215. package/src/server/auth.ts +0 -48
  216. package/src/server/event.ts +0 -13
  217. package/src/server/global-lifecycle.ts +0 -28
  218. package/src/server/init-projectors.ts +0 -3
  219. package/src/server/mdns.ts +0 -47
  220. package/src/server/projectors.ts +0 -1
  221. package/src/server/proxy-util.ts +0 -48
  222. package/src/server/routes/instance/httpapi/AGENTS.md +0 -39
  223. package/src/server/routes/instance/httpapi/api.ts +0 -78
  224. package/src/server/routes/instance/httpapi/errors.ts +0 -193
  225. package/src/server/routes/instance/httpapi/groups/config.ts +0 -65
  226. package/src/server/routes/instance/httpapi/groups/control-plane.ts +0 -35
  227. package/src/server/routes/instance/httpapi/groups/control.ts +0 -76
  228. package/src/server/routes/instance/httpapi/groups/event.ts +0 -29
  229. package/src/server/routes/instance/httpapi/groups/experimental.ts +0 -275
  230. package/src/server/routes/instance/httpapi/groups/file.ts +0 -185
  231. package/src/server/routes/instance/httpapi/groups/global.ts +0 -138
  232. package/src/server/routes/instance/httpapi/groups/instance.ts +0 -206
  233. package/src/server/routes/instance/httpapi/groups/mcp.ts +0 -156
  234. package/src/server/routes/instance/httpapi/groups/metadata.ts +0 -18
  235. package/src/server/routes/instance/httpapi/groups/permission.ts +0 -61
  236. package/src/server/routes/instance/httpapi/groups/project-copy.ts +0 -32
  237. package/src/server/routes/instance/httpapi/groups/project.ts +0 -93
  238. package/src/server/routes/instance/httpapi/groups/provider.ts +0 -101
  239. package/src/server/routes/instance/httpapi/groups/pty.ts +0 -172
  240. package/src/server/routes/instance/httpapi/groups/query.ts +0 -12
  241. package/src/server/routes/instance/httpapi/groups/question.ts +0 -74
  242. package/src/server/routes/instance/httpapi/groups/session.ts +0 -462
  243. package/src/server/routes/instance/httpapi/groups/sync.ts +0 -113
  244. package/src/server/routes/instance/httpapi/groups/tui.ts +0 -208
  245. package/src/server/routes/instance/httpapi/groups/workspace.ts +0 -141
  246. package/src/server/routes/instance/httpapi/handlers/config.ts +0 -34
  247. package/src/server/routes/instance/httpapi/handlers/control-plane.ts +0 -37
  248. package/src/server/routes/instance/httpapi/handlers/control.ts +0 -43
  249. package/src/server/routes/instance/httpapi/handlers/event.ts +0 -99
  250. package/src/server/routes/instance/httpapi/handlers/experimental.ts +0 -192
  251. package/src/server/routes/instance/httpapi/handlers/file.ts +0 -139
  252. package/src/server/routes/instance/httpapi/handlers/global.ts +0 -156
  253. package/src/server/routes/instance/httpapi/handlers/instance.ts +0 -110
  254. package/src/server/routes/instance/httpapi/handlers/mcp.ts +0 -111
  255. package/src/server/routes/instance/httpapi/handlers/permission.ts +0 -41
  256. package/src/server/routes/instance/httpapi/handlers/project-copy.ts +0 -83
  257. package/src/server/routes/instance/httpapi/handlers/project.ts +0 -63
  258. package/src/server/routes/instance/httpapi/handlers/provider.ts +0 -113
  259. package/src/server/routes/instance/httpapi/handlers/pty.ts +0 -273
  260. package/src/server/routes/instance/httpapi/handlers/question.ts +0 -54
  261. package/src/server/routes/instance/httpapi/handlers/session-errors.ts +0 -21
  262. package/src/server/routes/instance/httpapi/handlers/session.ts +0 -440
  263. package/src/server/routes/instance/httpapi/handlers/sync.ts +0 -89
  264. package/src/server/routes/instance/httpapi/handlers/tui.ts +0 -131
  265. package/src/server/routes/instance/httpapi/handlers/workspace.ts +0 -102
  266. package/src/server/routes/instance/httpapi/lifecycle.ts +0 -54
  267. package/src/server/routes/instance/httpapi/middleware/authorization.ts +0 -150
  268. package/src/server/routes/instance/httpapi/middleware/compression.ts +0 -64
  269. package/src/server/routes/instance/httpapi/middleware/cors-vary.ts +0 -29
  270. package/src/server/routes/instance/httpapi/middleware/error.ts +0 -43
  271. package/src/server/routes/instance/httpapi/middleware/fence.ts +0 -25
  272. package/src/server/routes/instance/httpapi/middleware/instance-context.ts +0 -43
  273. package/src/server/routes/instance/httpapi/middleware/proxy.ts +0 -108
  274. package/src/server/routes/instance/httpapi/middleware/schema-error.ts +0 -41
  275. package/src/server/routes/instance/httpapi/middleware/workspace-routing.ts +0 -250
  276. package/src/server/routes/instance/httpapi/public.ts +0 -535
  277. package/src/server/routes/instance/httpapi/server.ts +0 -298
  278. package/src/server/routes/instance/httpapi/websocket-tracker.ts +0 -57
  279. package/src/server/server.ts +0 -225
  280. package/src/server/shared/fence.ts +0 -60
  281. package/src/server/shared/pty-ticket.ts +0 -15
  282. package/src/server/shared/public-ui.ts +0 -12
  283. package/src/server/shared/tui-control.ts +0 -28
  284. package/src/server/shared/ui.ts +0 -108
  285. package/src/server/shared/workspace-routing.ts +0 -38
  286. package/src/server/tui-event.ts +0 -53
  287. package/src/session/compaction.ts +0 -620
  288. package/src/session/instruction.ts +0 -241
  289. package/src/session/llm/AGENTS.md +0 -90
  290. package/src/session/llm/ai-sdk.ts +0 -288
  291. package/src/session/llm/native-request.ts +0 -196
  292. package/src/session/llm/native-runtime.ts +0 -195
  293. package/src/session/llm/request.ts +0 -216
  294. package/src/session/llm.ts +0 -415
  295. package/src/session/message-error.ts +0 -14
  296. package/src/session/message-v2.ts +0 -747
  297. package/src/session/message.ts +0 -148
  298. package/src/session/overflow.ts +0 -34
  299. package/src/session/processor.ts +0 -1084
  300. package/src/session/prompt/anthropic.txt +0 -109
  301. package/src/session/prompt/beast.txt +0 -151
  302. package/src/session/prompt/build-switch.txt +0 -9
  303. package/src/session/prompt/codex.txt +0 -83
  304. package/src/session/prompt/copilot-gpt-5.txt +0 -147
  305. package/src/session/prompt/default.txt +0 -99
  306. package/src/session/prompt/gemini.txt +0 -159
  307. package/src/session/prompt/gpt.txt +0 -111
  308. package/src/session/prompt/kimi.txt +0 -99
  309. package/src/session/prompt/plan-mode.txt +0 -74
  310. package/src/session/prompt/plan-reminder-anthropic.txt +0 -71
  311. package/src/session/prompt/plan.txt +0 -30
  312. package/src/session/prompt/trinity.txt +0 -101
  313. package/src/session/prompt.ts +0 -1707
  314. package/src/session/reminders.ts +0 -92
  315. package/src/session/retry.ts +0 -201
  316. package/src/session/revert.ts +0 -160
  317. package/src/session/run-state.ts +0 -156
  318. package/src/session/schema.ts +0 -26
  319. package/src/session/session.ts +0 -1119
  320. package/src/session/status.ts +0 -97
  321. package/src/session/summary.ts +0 -165
  322. package/src/session/system.ts +0 -117
  323. package/src/session/todo.ts +0 -90
  324. package/src/session/tools.ts +0 -207
  325. package/src/share/session.ts +0 -61
  326. package/src/share/share-next.ts +0 -385
  327. package/src/skill/discovery.ts +0 -109
  328. package/src/skill/index.ts +0 -366
  329. package/src/snapshot/index.ts +0 -808
  330. package/src/sql.d.ts +0 -4
  331. package/src/storage/schema.ts +0 -5
  332. package/src/storage/storage.ts +0 -329
  333. package/src/sync/README.md +0 -179
  334. package/src/sync/schema.ts +0 -11
  335. package/src/temporary.ts +0 -31
  336. package/src/tool/apply_patch.ts +0 -315
  337. package/src/tool/apply_patch.txt +0 -33
  338. package/src/tool/apply_patch.zh.txt +0 -33
  339. package/src/tool/description.ts +0 -100
  340. package/src/tool/edit.ts +0 -739
  341. package/src/tool/edit.txt +0 -10
  342. package/src/tool/edit.zh.txt +0 -10
  343. package/src/tool/external-directory.ts +0 -49
  344. package/src/tool/glob.ts +0 -78
  345. package/src/tool/glob.txt +0 -6
  346. package/src/tool/glob.zh.txt +0 -6
  347. package/src/tool/grep.ts +0 -114
  348. package/src/tool/grep.txt +0 -8
  349. package/src/tool/grep.zh.txt +0 -8
  350. package/src/tool/invalid.ts +0 -21
  351. package/src/tool/json-schema.ts +0 -164
  352. package/src/tool/lsp.ts +0 -115
  353. package/src/tool/lsp.txt +0 -24
  354. package/src/tool/lsp.zh.txt +0 -24
  355. package/src/tool/mcp-websearch.ts +0 -96
  356. package/src/tool/plan-enter.txt +0 -14
  357. package/src/tool/plan-enter.zh.txt +0 -14
  358. package/src/tool/plan-exit.txt +0 -13
  359. package/src/tool/plan-exit.zh.txt +0 -13
  360. package/src/tool/plan.ts +0 -81
  361. package/src/tool/question.ts +0 -46
  362. package/src/tool/question.txt +0 -10
  363. package/src/tool/question.zh.txt +0 -10
  364. package/src/tool/read.ts +0 -388
  365. package/src/tool/read.txt +0 -14
  366. package/src/tool/read.zh.txt +0 -14
  367. package/src/tool/registry.ts +0 -440
  368. package/src/tool/schema.ts +0 -14
  369. package/src/tool/shell/id.ts +0 -19
  370. package/src/tool/shell/prompt.ts +0 -307
  371. package/src/tool/shell/shell.txt +0 -21
  372. package/src/tool/shell.ts +0 -657
  373. package/src/tool/skill.ts +0 -73
  374. package/src/tool/skill.txt +0 -5
  375. package/src/tool/skill.zh.txt +0 -5
  376. package/src/tool/task.ts +0 -348
  377. package/src/tool/task.txt +0 -19
  378. package/src/tool/task.zh.txt +0 -19
  379. package/src/tool/todo.ts +0 -59
  380. package/src/tool/todowrite.txt +0 -44
  381. package/src/tool/todowrite.zh.txt +0 -44
  382. package/src/tool/tool.ts +0 -183
  383. package/src/tool/truncate.ts +0 -158
  384. package/src/tool/truncation-dir.ts +0 -4
  385. package/src/tool/webfetch.ts +0 -194
  386. package/src/tool/webfetch.txt +0 -13
  387. package/src/tool/webfetch.zh.txt +0 -13
  388. package/src/tool/websearch.ts +0 -145
  389. package/src/tool/websearch.txt +0 -14
  390. package/src/tool/websearch.zh.txt +0 -14
  391. package/src/tool/write.ts +0 -106
  392. package/src/tool/write.txt +0 -8
  393. package/src/tool/write.zh.txt +0 -8
  394. package/src/util/archive.ts +0 -17
  395. package/src/util/bom.ts +0 -27
  396. package/src/util/data-url.ts +0 -9
  397. package/src/util/defer.ts +0 -10
  398. package/src/util/effect-http-client.ts +0 -11
  399. package/src/util/error.ts +0 -1
  400. package/src/util/filesystem.ts +0 -251
  401. package/src/util/html.ts +0 -8
  402. package/src/util/iife.ts +0 -3
  403. package/src/util/lazy.ts +0 -20
  404. package/src/util/local-context.ts +0 -25
  405. package/src/util/locale.ts +0 -2
  406. package/src/util/media.ts +0 -26
  407. package/src/util/process.ts +0 -177
  408. package/src/util/proxy-env.ts +0 -72
  409. package/src/util/queue.ts +0 -32
  410. package/src/util/record.ts +0 -1
  411. package/src/util/repository.ts +0 -232
  412. package/src/util/rpc.ts +0 -66
  413. package/src/util/signal.ts +0 -12
  414. package/src/util/timeout.ts +0 -13
  415. package/src/util/token.ts +0 -1
  416. package/src/util/wildcard.ts +0 -59
  417. package/src/worktree/index.ts +0 -654
package/src/tool/shell.ts DELETED
@@ -1,657 +0,0 @@
1
- import { Effect, Stream } from "effect"
2
- import os from "os"
3
- import { createWriteStream } from "node:fs"
4
- import * as Tool from "./tool"
5
- import path from "path"
6
- import { containsPath, type InstanceContext } from "../project/instance-context"
7
- import { InstanceState } from "@/effect/instance-state"
8
- import { lazy } from "@/util/lazy"
9
- import { Language, type Node } from "web-tree-sitter"
10
-
11
- import { FSUtil } from "@opencode-ai/core/fs-util"
12
- import { fileURLToPath } from "url"
13
- import { Config } from "@/config/config"
14
- import { RuntimeFlags } from "@/effect/runtime-flags"
15
- import { Shell } from "@opencode-ai/core/shell"
16
- import { ShellID } from "./shell/id"
17
-
18
- import * as Truncate from "./truncate"
19
- import { Plugin } from "@/plugin"
20
- import { ChildProcess } from "effect/unstable/process"
21
- import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner"
22
- import { ShellPrompt, type Parameters } from "./shell/prompt"
23
- import { BashArity } from "@/permission/arity"
24
-
25
- export { Parameters } from "./shell/prompt"
26
-
27
- const MAX_METADATA_LENGTH = 30_000
28
- const CWD = new Set(["cd", "chdir", "popd", "pushd", "push-location", "set-location"])
29
- const FILES = new Set([
30
- ...CWD,
31
- "rm",
32
- "cp",
33
- "mv",
34
- "mkdir",
35
- "touch",
36
- "chmod",
37
- "chown",
38
- "cat",
39
- // Leave PowerShell aliases out for now. Common ones like cat/cp/mv/rm/mkdir
40
- // already hit the entries above, and alias normalization should happen in one
41
- // place later so we do not risk double-prompting.
42
- "get-content",
43
- "set-content",
44
- "add-content",
45
- "copy-item",
46
- "move-item",
47
- "remove-item",
48
- "new-item",
49
- "rename-item",
50
- ])
51
- const CMD_FILES = new Set([
52
- "copy",
53
- "del",
54
- "dir",
55
- "erase",
56
- "md",
57
- "mkdir",
58
- "move",
59
- "rd",
60
- "ren",
61
- "rename",
62
- "rmdir",
63
- "type",
64
- ])
65
- const FLAGS = new Set(["-destination", "-literalpath", "-path"])
66
- const SWITCHES = new Set(["-confirm", "-debug", "-force", "-nonewline", "-recurse", "-verbose", "-whatif"])
67
-
68
- type Part = {
69
- type: string
70
- text: string
71
- }
72
-
73
- type Scan = {
74
- dirs: Set<string>
75
- patterns: Set<string>
76
- always: Set<string>
77
- }
78
-
79
- type Chunk = {
80
- text: string
81
- size: number
82
- }
83
-
84
- const resolveWasm = (asset: string) => {
85
- if (asset.startsWith("file://")) return fileURLToPath(asset)
86
- if (asset.startsWith("/") || /^[a-z]:/i.test(asset)) return asset
87
- const url = new URL(asset, import.meta.url)
88
- return fileURLToPath(url)
89
- }
90
-
91
- function parts(node: Node) {
92
- const out: Part[] = []
93
- for (let i = 0; i < node.childCount; i++) {
94
- const child = node.child(i)
95
- if (!child) continue
96
- if (child.type === "command_elements") {
97
- for (let j = 0; j < child.childCount; j++) {
98
- const item = child.child(j)
99
- if (!item || item.type === "command_argument_sep" || item.type === "redirection") continue
100
- out.push({ type: item.type, text: item.text })
101
- }
102
- continue
103
- }
104
- if (
105
- child.type !== "command_name" &&
106
- child.type !== "command_name_expr" &&
107
- child.type !== "word" &&
108
- child.type !== "string" &&
109
- child.type !== "raw_string" &&
110
- child.type !== "concatenation"
111
- ) {
112
- continue
113
- }
114
- out.push({ type: child.type, text: child.text })
115
- }
116
- return out
117
- }
118
-
119
- function source(node: Node) {
120
- return (node.parent?.type === "redirected_statement" ? node.parent.text : node.text).trim()
121
- }
122
-
123
- function commands(node: Node) {
124
- return node.descendantsOfType("command").filter((child): child is Node => Boolean(child))
125
- }
126
-
127
- function unquote(text: string) {
128
- if (text.length < 2) return text
129
- const first = text[0]
130
- const last = text[text.length - 1]
131
- if ((first === '"' || first === "'") && first === last) return text.slice(1, -1)
132
- return text
133
- }
134
-
135
- function home(text: string) {
136
- if (text === "~") return os.homedir()
137
- if (text.startsWith("~/") || text.startsWith("~\\")) return path.join(os.homedir(), text.slice(2))
138
- return text
139
- }
140
-
141
- function envValue(key: string) {
142
- if (process.platform !== "win32") return process.env[key]
143
- const name = Object.keys(process.env).find((item) => item.toLowerCase() === key.toLowerCase())
144
- return name ? process.env[name] : undefined
145
- }
146
-
147
- function auto(key: string, cwd: string, shell: string) {
148
- const name = key.toUpperCase()
149
- if (name === "HOME") return os.homedir()
150
- if (name === "PWD") return cwd
151
- if (name === "PSHOME") return path.dirname(shell)
152
- }
153
-
154
- function expand(text: string, cwd: string, shell: string) {
155
- const out = unquote(text)
156
- .replace(/\$\{env:([^}]+)\}/gi, (_, key: string) => envValue(key) || "")
157
- .replace(/\$env:([A-Za-z_][A-Za-z0-9_]*)/gi, (_, key: string) => envValue(key) || "")
158
- .replace(/\$(HOME|PWD|PSHOME)(?=$|[\\/])/gi, (_, key: string) => auto(key, cwd, shell) || "")
159
- return home(out)
160
- }
161
-
162
- function provider(text: string) {
163
- const match = text.match(/^([A-Za-z]+)::(.*)$/)
164
- if (match) {
165
- if (match[1].toLowerCase() !== "filesystem") return
166
- return match[2]
167
- }
168
- const prefix = text.match(/^([A-Za-z]+):(.*)$/)
169
- if (!prefix) return text
170
- if (prefix[1].length === 1) return text
171
- return
172
- }
173
-
174
- function dynamic(text: string, ps: boolean) {
175
- if (text.startsWith("(") || text.startsWith("@(")) return true
176
- if (text.includes("$(") || text.includes("${") || text.includes("`")) return true
177
- if (ps) return /\$(?!env:)/i.test(text)
178
- return text.includes("$")
179
- }
180
-
181
- function prefix(text: string) {
182
- const match = /[?*[]/.exec(text)
183
- if (!match) return text
184
- if (match.index === 0) return
185
- return text.slice(0, match.index)
186
- }
187
-
188
- function pathArgs(list: Part[], ps: boolean, cmd = false) {
189
- if (!ps) {
190
- return list
191
- .slice(1)
192
- .filter(
193
- (item) =>
194
- !item.text.startsWith("-") &&
195
- !(cmd && item.text.startsWith("/")) &&
196
- !(list[0]?.text === "chmod" && item.text.startsWith("+")),
197
- )
198
- .map((item) => item.text)
199
- }
200
-
201
- const out: string[] = []
202
- let want = false
203
- for (const item of list.slice(1)) {
204
- if (want) {
205
- out.push(item.text)
206
- want = false
207
- continue
208
- }
209
- if (item.type === "command_parameter") {
210
- const flag = item.text.toLowerCase()
211
- if (SWITCHES.has(flag)) continue
212
- want = FLAGS.has(flag)
213
- continue
214
- }
215
- out.push(item.text)
216
- }
217
- return out
218
- }
219
-
220
- function preview(text: string) {
221
- if (text.length <= MAX_METADATA_LENGTH) return text
222
- return "...\n\n" + text.slice(-MAX_METADATA_LENGTH)
223
- }
224
-
225
- function tail(text: string, maxLines: number, maxBytes: number) {
226
- const lines = text.split("\n")
227
- if (lines.length <= maxLines && Buffer.byteLength(text, "utf-8") <= maxBytes) {
228
- return {
229
- text,
230
- cut: false,
231
- }
232
- }
233
-
234
- const out: string[] = []
235
- let bytes = 0
236
- for (let i = lines.length - 1; i >= 0 && out.length < maxLines; i--) {
237
- const size = Buffer.byteLength(lines[i], "utf-8") + (out.length > 0 ? 1 : 0)
238
- if (bytes + size > maxBytes) {
239
- if (out.length === 0) {
240
- const buf = Buffer.from(lines[i], "utf-8")
241
- let start = buf.length - maxBytes
242
- if (start < 0) start = 0
243
- while (start < buf.length && (buf[start] & 0xc0) === 0x80) start++
244
- out.unshift(buf.subarray(start).toString("utf-8"))
245
- }
246
- break
247
- }
248
- out.unshift(lines[i])
249
- bytes += size
250
- }
251
- return {
252
- text: out.join("\n"),
253
- cut: true,
254
- }
255
- }
256
-
257
- const parse = Effect.fn("ShellTool.parse")(function* (command: string, ps: boolean) {
258
- const tree = yield* Effect.promise(() => parser().then((p) => (ps ? p.ps : p.bash).parse(command)))
259
- if (!tree) throw new Error("Failed to parse command")
260
- return tree
261
- })
262
-
263
- const ask = Effect.fn("ShellTool.ask")(function* (
264
- ctx: Tool.Context,
265
- scan: Scan,
266
- input: { command: string; description: string },
267
- ) {
268
- if (scan.dirs.size > 0) {
269
- const directories = Array.from(scan.dirs)
270
- const globs = directories.map((dir) => {
271
- if (process.platform === "win32") return FSUtil.normalizePathPattern(path.join(dir, "*"))
272
- return path.join(dir, "*")
273
- })
274
- yield* ctx.ask({
275
- permission: "external_directory",
276
- patterns: globs,
277
- always: globs,
278
- metadata: {
279
- command: input.command,
280
- description: input.description,
281
- directories,
282
- patterns: globs,
283
- },
284
- })
285
- }
286
-
287
- if (scan.patterns.size === 0) return
288
- yield* ctx.ask({
289
- permission: ShellID.ToolID,
290
- patterns: Array.from(scan.patterns),
291
- always: Array.from(scan.always),
292
- metadata: {
293
- command: input.command,
294
- description: input.description,
295
- },
296
- })
297
- })
298
-
299
- function cmd(shell: string, command: string, cwd: string, env: NodeJS.ProcessEnv) {
300
- if (process.platform === "win32" && Shell.ps(shell)) {
301
- return ChildProcess.make(shell, ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", command], {
302
- cwd,
303
- env,
304
- stdin: "ignore",
305
- detached: false,
306
- })
307
- }
308
-
309
- return ChildProcess.make(command, [], {
310
- shell,
311
- cwd,
312
- env,
313
- stdin: "ignore",
314
- detached: process.platform !== "win32",
315
- })
316
- }
317
- const parser = lazy(async () => {
318
- const { Parser } = await import("web-tree-sitter")
319
- const { default: treeWasm } = await import("web-tree-sitter/tree-sitter.wasm" as string, {
320
- with: { type: "wasm" },
321
- })
322
- const treePath = resolveWasm(treeWasm)
323
- await Parser.init({
324
- locateFile() {
325
- return treePath
326
- },
327
- })
328
- const { default: bashWasm } = await import("tree-sitter-bash/tree-sitter-bash.wasm" as string, {
329
- with: { type: "wasm" },
330
- })
331
- const { default: psWasm } = await import("tree-sitter-powershell/tree-sitter-powershell.wasm" as string, {
332
- with: { type: "wasm" },
333
- })
334
- const bashPath = resolveWasm(bashWasm)
335
- const psPath = resolveWasm(psWasm)
336
- const [bashLanguage, psLanguage] = await Promise.all([Language.load(bashPath), Language.load(psPath)])
337
- const bash = new Parser()
338
- bash.setLanguage(bashLanguage)
339
- const ps = new Parser()
340
- ps.setLanguage(psLanguage)
341
- return { bash, ps }
342
- })
343
-
344
- export const ShellTool = Tool.define(
345
- ShellID.ToolID,
346
- Effect.gen(function* () {
347
- const config = yield* Config.Service
348
- const spawner = yield* ChildProcessSpawner
349
- const fs = yield* FSUtil.Service
350
- const trunc = yield* Truncate.Service
351
- const plugin = yield* Plugin.Service
352
- const flags = yield* RuntimeFlags.Service
353
- const defaultTimeoutMs = flags.bashDefaultTimeoutMs ?? 2 * 60 * 1000
354
-
355
- const cygpath = Effect.fn("ShellTool.cygpath")(function* (shell: string, text: string) {
356
- const lines = yield* spawner
357
- .lines(ChildProcess.make(shell, ["-lc", 'cygpath -w -- "$1"', "_", text]))
358
- .pipe(Effect.catch(() => Effect.succeed([] as string[])))
359
- const file = lines[0]?.trim()
360
- if (!file) return
361
- return FSUtil.normalizePath(file)
362
- })
363
-
364
- const resolvePath = Effect.fn("ShellTool.resolvePath")(function* (text: string, root: string, shell: string) {
365
- if (process.platform === "win32") {
366
- if (Shell.posix(shell) && text.startsWith("/") && FSUtil.windowsPath(text) === text) {
367
- const file = yield* cygpath(shell, text)
368
- if (file) return file
369
- }
370
- return FSUtil.normalizePath(path.resolve(root, FSUtil.windowsPath(text)))
371
- }
372
- return path.resolve(root, text)
373
- })
374
-
375
- const argPath = Effect.fn("ShellTool.argPath")(function* (arg: string, cwd: string, ps: boolean, shell: string) {
376
- const text = ps ? expand(arg, cwd, shell) : home(unquote(arg))
377
- const file = text && prefix(text)
378
- if (!file || dynamic(file, ps)) return
379
- const next = ps ? provider(file) : file
380
- if (!next) return
381
- return yield* resolvePath(next, cwd, shell)
382
- })
383
-
384
- const collect = Effect.fn("ShellTool.collect")(function* (
385
- root: Node,
386
- cwd: string,
387
- ps: boolean,
388
- shell: string,
389
- instance: InstanceContext,
390
- ) {
391
- const scan: Scan = {
392
- dirs: new Set<string>(),
393
- patterns: new Set<string>(),
394
- always: new Set<string>(),
395
- }
396
- const shellKind = ShellID.toKind(Shell.name(shell))
397
-
398
- for (const node of commands(root)) {
399
- const command = parts(node)
400
- const tokens = command.map((item) => item.text)
401
- const cmd = ps || shellKind === "cmd" ? tokens[0]?.toLowerCase() : tokens[0]
402
-
403
- if (cmd && (FILES.has(cmd) || (shellKind === "cmd" && CMD_FILES.has(cmd)))) {
404
- for (const arg of pathArgs(command, ps, shellKind === "cmd")) {
405
- const resolved = yield* argPath(arg, cwd, ps, shell)
406
- yield* Effect.logInfo("resolved path", { arg, resolved })
407
- if (!resolved || containsPath(resolved, instance)) continue
408
- const dir = (yield* fs.isDir(resolved)) ? resolved : path.dirname(resolved)
409
- scan.dirs.add(dir)
410
- }
411
- }
412
-
413
- if (tokens.length && (!cmd || !CWD.has(cmd))) {
414
- scan.patterns.add(source(node))
415
- scan.always.add(BashArity.prefix(tokens).join(" ") + " *")
416
- }
417
- }
418
-
419
- return scan
420
- })
421
-
422
- const shellEnv = Effect.fn("ShellTool.shellEnv")(function* (ctx: Tool.Context, cwd: string) {
423
- const extra = yield* plugin.trigger(
424
- "shell.env",
425
- { cwd, sessionID: ctx.sessionID, callID: ctx.callID },
426
- { env: {} },
427
- )
428
- return {
429
- ...process.env,
430
- ...extra.env,
431
- }
432
- })
433
-
434
- const run = Effect.fn("ShellTool.run")(function* (
435
- input: {
436
- shell: string
437
- command: string
438
- cwd: string
439
- env: NodeJS.ProcessEnv
440
- timeout: number
441
- description: string
442
- },
443
- ctx: Tool.Context,
444
- ) {
445
- const limits = yield* trunc.limits()
446
- const keep = limits.maxBytes * 2
447
- let full = ""
448
- let last = ""
449
- const list: Chunk[] = []
450
- let used = 0
451
- let file = ""
452
- let sink: ReturnType<typeof createWriteStream> | undefined
453
- let cut = false
454
- let expired = false
455
- let aborted = false
456
-
457
- const closeSink = Effect.fnUntraced(function* () {
458
- const stream = sink
459
- if (!stream) return
460
- sink = undefined
461
- if (stream.destroyed || stream.closed) return
462
- yield* Effect.promise(
463
- () =>
464
- new Promise<void>((resolve) => {
465
- let settled = false
466
- const done = () => {
467
- if (settled) return
468
- settled = true
469
- stream.off("close", done)
470
- stream.off("error", done)
471
- stream.off("finish", done)
472
- resolve()
473
- }
474
- stream.once("close", done)
475
- stream.once("error", done)
476
- stream.once("finish", done)
477
- stream.end(done)
478
- }),
479
- ).pipe(Effect.catch(() => Effect.void))
480
- })
481
-
482
- yield* ctx.metadata({
483
- metadata: {
484
- output: "",
485
- description: input.description,
486
- },
487
- })
488
-
489
- const code: number | null = yield* Effect.scoped(
490
- Effect.gen(function* () {
491
- yield* Effect.addFinalizer(closeSink)
492
- const handle = yield* spawner.spawn(cmd(input.shell, input.command, input.cwd, input.env))
493
-
494
- yield* Effect.forkScoped(
495
- Stream.runForEach(Stream.decodeText(handle.all), (chunk) => {
496
- const size = Buffer.byteLength(chunk, "utf-8")
497
- list.push({ text: chunk, size })
498
- used += size
499
- while (used > keep && list.length > 1) {
500
- const item = list.shift()
501
- if (!item) break
502
- used -= item.size
503
- cut = true
504
- }
505
-
506
- last = preview(last + chunk)
507
-
508
- if (file) {
509
- sink?.write(chunk)
510
- } else {
511
- full += chunk
512
- if (Buffer.byteLength(full, "utf-8") > limits.maxBytes) {
513
- return trunc.write(full).pipe(
514
- Effect.andThen((next) =>
515
- Effect.sync(() => {
516
- file = next
517
- cut = true
518
- sink = createWriteStream(next, { flags: "a" })
519
- full = ""
520
- }),
521
- ),
522
- Effect.andThen(
523
- ctx.metadata({
524
- metadata: {
525
- output: last,
526
- description: input.description,
527
- },
528
- }),
529
- ),
530
- )
531
- }
532
- }
533
-
534
- return ctx.metadata({
535
- metadata: {
536
- output: last,
537
- description: input.description,
538
- },
539
- })
540
- }),
541
- )
542
-
543
- const abort = Effect.callback<void>((resume) => {
544
- if (ctx.abort.aborted) return resume(Effect.void)
545
- const handler = () => resume(Effect.void)
546
- ctx.abort.addEventListener("abort", handler, { once: true })
547
- return Effect.sync(() => ctx.abort.removeEventListener("abort", handler))
548
- })
549
-
550
- const timeout = Effect.sleep(`${input.timeout + 100} millis`)
551
-
552
- const exit = yield* Effect.raceAll([
553
- handle.exitCode.pipe(Effect.map((code) => ({ kind: "exit" as const, code }))),
554
- abort.pipe(Effect.map(() => ({ kind: "abort" as const, code: null }))),
555
- timeout.pipe(Effect.map(() => ({ kind: "timeout" as const, code: null }))),
556
- ])
557
-
558
- if (exit.kind === "abort") {
559
- aborted = true
560
- yield* handle.kill({ forceKillAfter: "3 seconds" }).pipe(Effect.orDie)
561
- }
562
- if (exit.kind === "timeout") {
563
- expired = true
564
- yield* handle.kill({ forceKillAfter: "3 seconds" }).pipe(Effect.orDie)
565
- }
566
-
567
- return exit.kind === "exit" ? exit.code : null
568
- }),
569
- ).pipe(Effect.orDie)
570
-
571
- const meta: string[] = []
572
- if (expired) {
573
- meta.push(
574
- `shell tool terminated command after exceeding timeout ${input.timeout} ms. If this command is expected to take longer and is not waiting for interactive input, retry with a larger timeout value in milliseconds.`,
575
- )
576
- }
577
- if (aborted) meta.push("User aborted the command")
578
- const raw = list.map((item) => item.text).join("")
579
- const end = tail(raw, limits.maxLines, limits.maxBytes)
580
- if (end.cut) cut = true
581
- if (!file && end.cut) {
582
- file = yield* trunc.write(raw)
583
- }
584
-
585
- let output = end.text
586
- if (!output) output = "(no output)"
587
-
588
- if (cut && file) {
589
- output = `...output truncated...\n\nFull output saved to: ${file}\n\n` + output
590
- }
591
-
592
- if (meta.length > 0) {
593
- output += "\n\n<shell_metadata>\n" + meta.join("\n") + "\n</shell_metadata>"
594
- }
595
- return {
596
- title: input.description,
597
- metadata: {
598
- output: last || preview(output),
599
- exit: code,
600
- description: input.description,
601
- truncated: cut,
602
- ...(cut && file ? { outputPath: file } : {}),
603
- },
604
- output,
605
- }
606
- })
607
-
608
- return () =>
609
- Effect.gen(function* () {
610
- const cfg = yield* config.get()
611
- const shell = Shell.acceptable(cfg.shell)
612
- const name = Shell.name(shell)
613
- const limits = yield* trunc.limits()
614
- const prompt = ShellPrompt.render(name, process.platform, limits, defaultTimeoutMs)
615
- yield* Effect.logInfo("shell tool using shell", { shell })
616
-
617
- return {
618
- description: prompt.description,
619
- parameters: prompt.parameters,
620
- execute: (params: Parameters, ctx: Tool.Context) =>
621
- Effect.gen(function* () {
622
- const instanceCtx = yield* InstanceState.context
623
- const cwd = params.workdir
624
- ? yield* resolvePath(params.workdir, instanceCtx.directory, shell)
625
- : instanceCtx.directory
626
- if (params.timeout !== undefined && params.timeout < 0) {
627
- throw new Error(`Invalid timeout value: ${params.timeout}. Timeout must be a positive number.`)
628
- }
629
- const timeout = params.timeout ?? defaultTimeoutMs
630
- const ps = Shell.ps(shell)
631
- yield* Effect.scoped(
632
- Effect.gen(function* () {
633
- const tree = yield* Effect.acquireRelease(parse(params.command, ps), (tree) =>
634
- Effect.sync(() => tree.delete()),
635
- )
636
- const scan = yield* collect(tree.rootNode, cwd, ps, shell, instanceCtx)
637
- if (!containsPath(cwd, instanceCtx)) scan.dirs.add(cwd)
638
- yield* ask(ctx, scan, params)
639
- }),
640
- )
641
-
642
- return yield* run(
643
- {
644
- shell,
645
- command: params.command,
646
- cwd,
647
- env: yield* shellEnv(ctx, cwd),
648
- timeout,
649
- description: params.description,
650
- },
651
- ctx,
652
- )
653
- }),
654
- }
655
- })
656
- }),
657
- )