alchemylab-opencode 1.0.6 → 1.0.8

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 (413) hide show
  1. package/dist/arktype-aI7TBD0R-HX4BR3RX.js +21 -0
  2. package/dist/arktype-aI7TBD0R-HX4BR3RX.js.map +7 -0
  3. package/dist/{chunk-UWZSRZHA.js → chunk-23UYOGZG.js} +817 -315
  4. package/dist/chunk-23UYOGZG.js.map +7 -0
  5. package/dist/chunk-3AF5MXLF.js +49 -0
  6. package/dist/chunk-3AF5MXLF.js.map +7 -0
  7. package/dist/chunk-FMP3YLWX.js +30 -0
  8. package/dist/chunk-FMP3YLWX.js.map +7 -0
  9. package/dist/{chunk-ANDTK76Q.js → chunk-GSE2T5UY.js} +3 -3
  10. package/dist/{chunk-CYXMV3J3.js → chunk-LU5XVQUD.js} +4 -4
  11. package/dist/chunk-O5VWOPCL.js +106 -0
  12. package/dist/chunk-O5VWOPCL.js.map +7 -0
  13. package/dist/chunk-PWFRMDDF.js +12 -0
  14. package/dist/{chunk-DSPC5QIG.js → chunk-SM6WZDN6.js} +9 -9
  15. package/dist/{chunk-MCWTARFP.js → chunk-TASPMBUL.js} +4 -4
  16. package/dist/chunk-VL3RSEZ2.js +160 -0
  17. package/dist/chunk-VL3RSEZ2.js.map +7 -0
  18. package/dist/default-u_dwuiYb-WOFHQQ3K.js +22 -0
  19. package/dist/effect-QlVUlMFu-UERLUUQW.js +29 -0
  20. package/dist/effect-QlVUlMFu-UERLUUQW.js.map +7 -0
  21. package/dist/{mcp-VAU4RMWH.js → mcp-XFGN3FWW.js} +2 -2
  22. package/dist/{registry-PYMN6L3G.js → registry-W4MBVBYD.js} +3 -3
  23. package/dist/{run-YFVCQJQM.js → run-73HUV4H3.js} +9 -6
  24. package/dist/{run-YFVCQJQM.js.map → run-73HUV4H3.js.map} +1 -1
  25. package/dist/run.js +1 -1
  26. package/dist/serve.js +1 -1
  27. package/dist/{server-K3UGWASP.js → server-2CPOG3LS.js} +9 -6
  28. package/dist/{session-HJFWTM7C.js → session-M6HOZ56B.js} +3 -3
  29. package/dist/session-M6HOZ56B.js.map +7 -0
  30. package/dist/{share-next-55VCIMUH.js → share-next-QRBVSD37.js} +4 -4
  31. package/dist/share-next-QRBVSD37.js.map +7 -0
  32. package/dist/sury-CWZTCd75-XC3NCMTP.js +29 -0
  33. package/dist/sury-CWZTCd75-XC3NCMTP.js.map +7 -0
  34. package/dist/typebox-Dei93FPO-QOBKW4L7.js +21 -0
  35. package/dist/typebox-Dei93FPO-QOBKW4L7.js.map +7 -0
  36. package/dist/valibot--1zFm7rT-LHHLSLYY.js +29 -0
  37. package/dist/valibot--1zFm7rT-LHHLSLYY.js.map +7 -0
  38. package/dist/valibot-D_HTw1Gn-UR62BIDY.js +60 -0
  39. package/dist/valibot-D_HTw1Gn-UR62BIDY.js.map +7 -0
  40. package/dist/{worktree-6GGDLADY.js → worktree-3GUHT2P7.js} +5 -5
  41. package/dist/zod-Bwrt9trS-J2GOMA2R.js +43 -0
  42. package/dist/zod-Bwrt9trS-J2GOMA2R.js.map +7 -0
  43. package/dist/zod-DSgpEGAE-VTXQW6SB.js +56 -0
  44. package/dist/zod-DSgpEGAE-VTXQW6SB.js.map +7 -0
  45. package/package.json +2 -15
  46. package/build.mjs +0 -182
  47. package/dist/chunk-UWZSRZHA.js.map +0 -7
  48. package/packages/opencode/package.json +0 -138
  49. package/packages/opencode/src/account/account.sql.ts +0 -39
  50. package/packages/opencode/src/account/index.ts +0 -463
  51. package/packages/opencode/src/account/repo.ts +0 -163
  52. package/packages/opencode/src/account/schema.ts +0 -91
  53. package/packages/opencode/src/acp/README.md +0 -174
  54. package/packages/opencode/src/acp/agent.ts +0 -1847
  55. package/packages/opencode/src/acp/session.ts +0 -116
  56. package/packages/opencode/src/acp/types.ts +0 -24
  57. package/packages/opencode/src/agent/agent.ts +0 -420
  58. package/packages/opencode/src/agent/generate.txt +0 -75
  59. package/packages/opencode/src/agent/prompt/compaction.txt +0 -15
  60. package/packages/opencode/src/agent/prompt/explore.txt +0 -18
  61. package/packages/opencode/src/agent/prompt/summary.txt +0 -11
  62. package/packages/opencode/src/agent/prompt/title.txt +0 -44
  63. package/packages/opencode/src/auth/index.ts +0 -110
  64. package/packages/opencode/src/bus/bus-event.ts +0 -40
  65. package/packages/opencode/src/bus/global.ts +0 -10
  66. package/packages/opencode/src/bus/index.ts +0 -185
  67. package/packages/opencode/src/cli/bootstrap.ts +0 -17
  68. package/packages/opencode/src/cli/cmd/cmd.ts +0 -7
  69. package/packages/opencode/src/cli/cmd/run.ts +0 -689
  70. package/packages/opencode/src/cli/cmd/serve.ts +0 -24
  71. package/packages/opencode/src/cli/cmd/tui/event.ts +0 -49
  72. package/packages/opencode/src/cli/effect/prompt.ts +0 -25
  73. package/packages/opencode/src/cli/error.ts +0 -46
  74. package/packages/opencode/src/cli/heap.ts +0 -59
  75. package/packages/opencode/src/cli/logo.ts +0 -6
  76. package/packages/opencode/src/cli/network.ts +0 -60
  77. package/packages/opencode/src/cli/ui.ts +0 -133
  78. package/packages/opencode/src/cli/upgrade.ts +0 -31
  79. package/packages/opencode/src/command/index.ts +0 -195
  80. package/packages/opencode/src/command/template/initialize.txt +0 -66
  81. package/packages/opencode/src/command/template/review.txt +0 -101
  82. package/packages/opencode/src/config/config.ts +0 -1599
  83. package/packages/opencode/src/config/console-state.ts +0 -15
  84. package/packages/opencode/src/config/markdown.ts +0 -99
  85. package/packages/opencode/src/config/paths.ts +0 -167
  86. package/packages/opencode/src/config/tui-migrate.ts +0 -155
  87. package/packages/opencode/src/config/tui-schema.ts +0 -37
  88. package/packages/opencode/src/config/tui.ts +0 -179
  89. package/packages/opencode/src/control-plane/adaptors/index.ts +0 -20
  90. package/packages/opencode/src/control-plane/adaptors/worktree.ts +0 -42
  91. package/packages/opencode/src/control-plane/schema.ts +0 -17
  92. package/packages/opencode/src/control-plane/sse.ts +0 -66
  93. package/packages/opencode/src/control-plane/types.ts +0 -32
  94. package/packages/opencode/src/control-plane/workspace.sql.ts +0 -17
  95. package/packages/opencode/src/control-plane/workspace.ts +0 -168
  96. package/packages/opencode/src/effect/cross-spawn-spawner.ts +0 -502
  97. package/packages/opencode/src/effect/instance-ref.ts +0 -6
  98. package/packages/opencode/src/effect/instance-registry.ts +0 -12
  99. package/packages/opencode/src/effect/instance-state.ts +0 -82
  100. package/packages/opencode/src/effect/run-service.ts +0 -33
  101. package/packages/opencode/src/effect/runner.ts +0 -216
  102. package/packages/opencode/src/env/index.ts +0 -28
  103. package/packages/opencode/src/file/ignore.ts +0 -82
  104. package/packages/opencode/src/file/index.ts +0 -686
  105. package/packages/opencode/src/file/protected.ts +0 -59
  106. package/packages/opencode/src/file/ripgrep.ts +0 -376
  107. package/packages/opencode/src/file/time.ts +0 -133
  108. package/packages/opencode/src/file/watcher.ts +0 -173
  109. package/packages/opencode/src/filesystem/index.ts +0 -236
  110. package/packages/opencode/src/flag/flag.ts +0 -156
  111. package/packages/opencode/src/format/formatter.ts +0 -413
  112. package/packages/opencode/src/format/index.ts +0 -203
  113. package/packages/opencode/src/git/index.ts +0 -303
  114. package/packages/opencode/src/global/index.ts +0 -56
  115. package/packages/opencode/src/id/id.ts +0 -85
  116. package/packages/opencode/src/ide/index.ts +0 -74
  117. package/packages/opencode/src/installation/index.ts +0 -355
  118. package/packages/opencode/src/installation/meta.ts +0 -7
  119. package/packages/opencode/src/lsp/client.ts +0 -252
  120. package/packages/opencode/src/lsp/index.ts +0 -558
  121. package/packages/opencode/src/lsp/language.ts +0 -120
  122. package/packages/opencode/src/lsp/launch.ts +0 -21
  123. package/packages/opencode/src/lsp/server.ts +0 -1968
  124. package/packages/opencode/src/mcp/auth.ts +0 -173
  125. package/packages/opencode/src/mcp/index.ts +0 -931
  126. package/packages/opencode/src/mcp/oauth-callback.ts +0 -216
  127. package/packages/opencode/src/mcp/oauth-provider.ts +0 -185
  128. package/packages/opencode/src/node-loader.mjs +0 -104
  129. package/packages/opencode/src/node-preload.mjs +0 -39
  130. package/packages/opencode/src/node.ts +0 -1
  131. package/packages/opencode/src/npm/index.ts +0 -188
  132. package/packages/opencode/src/patch/index.ts +0 -680
  133. package/packages/opencode/src/permission/arity.ts +0 -163
  134. package/packages/opencode/src/permission/evaluate.ts +0 -15
  135. package/packages/opencode/src/permission/index.ts +0 -325
  136. package/packages/opencode/src/permission/schema.ts +0 -17
  137. package/packages/opencode/src/plugin/cloudflare.ts +0 -67
  138. package/packages/opencode/src/plugin/codex.ts +0 -608
  139. package/packages/opencode/src/plugin/github-copilot/copilot.ts +0 -361
  140. package/packages/opencode/src/plugin/github-copilot/models.ts +0 -144
  141. package/packages/opencode/src/plugin/index.ts +0 -299
  142. package/packages/opencode/src/plugin/install.ts +0 -439
  143. package/packages/opencode/src/plugin/loader.ts +0 -174
  144. package/packages/opencode/src/plugin/meta.ts +0 -188
  145. package/packages/opencode/src/plugin/shared.ts +0 -323
  146. package/packages/opencode/src/project/bootstrap.ts +0 -31
  147. package/packages/opencode/src/project/instance.ts +0 -175
  148. package/packages/opencode/src/project/project.sql.ts +0 -16
  149. package/packages/opencode/src/project/project.ts +0 -519
  150. package/packages/opencode/src/project/schema.ts +0 -16
  151. package/packages/opencode/src/project/state.ts +0 -70
  152. package/packages/opencode/src/project/vcs.ts +0 -240
  153. package/packages/opencode/src/provider/auth.ts +0 -253
  154. package/packages/opencode/src/provider/error.ts +0 -197
  155. package/packages/opencode/src/provider/models.ts +0 -162
  156. package/packages/opencode/src/provider/provider.ts +0 -1709
  157. package/packages/opencode/src/provider/schema.ts +0 -38
  158. package/packages/opencode/src/provider/sdk/copilot/README.md +0 -5
  159. package/packages/opencode/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +0 -170
  160. package/packages/opencode/src/provider/sdk/copilot/chat/get-response-metadata.ts +0 -15
  161. package/packages/opencode/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +0 -19
  162. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +0 -64
  163. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +0 -815
  164. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +0 -28
  165. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +0 -44
  166. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +0 -83
  167. package/packages/opencode/src/provider/sdk/copilot/copilot-provider.ts +0 -100
  168. package/packages/opencode/src/provider/sdk/copilot/index.ts +0 -2
  169. package/packages/opencode/src/provider/sdk/copilot/openai-compatible-error.ts +0 -27
  170. package/packages/opencode/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +0 -335
  171. package/packages/opencode/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +0 -22
  172. package/packages/opencode/src/provider/sdk/copilot/responses/openai-config.ts +0 -18
  173. package/packages/opencode/src/provider/sdk/copilot/responses/openai-error.ts +0 -22
  174. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +0 -214
  175. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +0 -1769
  176. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +0 -173
  177. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-settings.ts +0 -1
  178. package/packages/opencode/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +0 -87
  179. package/packages/opencode/src/provider/sdk/copilot/responses/tool/file-search.ts +0 -127
  180. package/packages/opencode/src/provider/sdk/copilot/responses/tool/image-generation.ts +0 -114
  181. package/packages/opencode/src/provider/sdk/copilot/responses/tool/local-shell.ts +0 -64
  182. package/packages/opencode/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +0 -103
  183. package/packages/opencode/src/provider/sdk/copilot/responses/tool/web-search.ts +0 -102
  184. package/packages/opencode/src/provider/transform.ts +0 -1050
  185. package/packages/opencode/src/pty/index.ts +0 -397
  186. package/packages/opencode/src/pty/pty.node.ts +0 -27
  187. package/packages/opencode/src/pty/pty.ts +0 -25
  188. package/packages/opencode/src/pty/schema.ts +0 -17
  189. package/packages/opencode/src/question/index.ts +0 -224
  190. package/packages/opencode/src/question/schema.ts +0 -17
  191. package/packages/opencode/src/run.ts +0 -28
  192. package/packages/opencode/src/serve.ts +0 -45
  193. package/packages/opencode/src/server/error.ts +0 -36
  194. package/packages/opencode/src/server/event.ts +0 -7
  195. package/packages/opencode/src/server/instance.ts +0 -324
  196. package/packages/opencode/src/server/mdns.ts +0 -60
  197. package/packages/opencode/src/server/middleware.ts +0 -33
  198. package/packages/opencode/src/server/projectors.ts +0 -28
  199. package/packages/opencode/src/server/proxy.ts +0 -131
  200. package/packages/opencode/src/server/router.ts +0 -105
  201. package/packages/opencode/src/server/routes/config.ts +0 -92
  202. package/packages/opencode/src/server/routes/event.ts +0 -83
  203. package/packages/opencode/src/server/routes/experimental.ts +0 -374
  204. package/packages/opencode/src/server/routes/file.ts +0 -197
  205. package/packages/opencode/src/server/routes/global.ts +0 -312
  206. package/packages/opencode/src/server/routes/mcp.ts +0 -225
  207. package/packages/opencode/src/server/routes/permission.ts +0 -69
  208. package/packages/opencode/src/server/routes/project.ts +0 -118
  209. package/packages/opencode/src/server/routes/provider.ts +0 -171
  210. package/packages/opencode/src/server/routes/pty.ts +0 -210
  211. package/packages/opencode/src/server/routes/question.ts +0 -99
  212. package/packages/opencode/src/server/routes/session.ts +0 -1030
  213. package/packages/opencode/src/server/routes/tui.ts +0 -379
  214. package/packages/opencode/src/server/routes/workspace.ts +0 -94
  215. package/packages/opencode/src/server/server.ts +0 -353
  216. package/packages/opencode/src/session/compaction.ts +0 -428
  217. package/packages/opencode/src/session/index.ts +0 -887
  218. package/packages/opencode/src/session/instruction.ts +0 -258
  219. package/packages/opencode/src/session/llm.ts +0 -354
  220. package/packages/opencode/src/session/message-v2.ts +0 -1031
  221. package/packages/opencode/src/session/message.ts +0 -191
  222. package/packages/opencode/src/session/overflow.ts +0 -22
  223. package/packages/opencode/src/session/processor.ts +0 -523
  224. package/packages/opencode/src/session/projectors.ts +0 -135
  225. package/packages/opencode/src/session/prompt/anthropic.txt +0 -105
  226. package/packages/opencode/src/session/prompt/beast.txt +0 -147
  227. package/packages/opencode/src/session/prompt/build-switch.txt +0 -5
  228. package/packages/opencode/src/session/prompt/codex.txt +0 -79
  229. package/packages/opencode/src/session/prompt/copilot-gpt-5.txt +0 -143
  230. package/packages/opencode/src/session/prompt/default.txt +0 -105
  231. package/packages/opencode/src/session/prompt/gemini.txt +0 -155
  232. package/packages/opencode/src/session/prompt/gpt.txt +0 -107
  233. package/packages/opencode/src/session/prompt/kimi.txt +0 -95
  234. package/packages/opencode/src/session/prompt/max-steps.txt +0 -16
  235. package/packages/opencode/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  236. package/packages/opencode/src/session/prompt/plan.txt +0 -26
  237. package/packages/opencode/src/session/prompt/trinity.txt +0 -97
  238. package/packages/opencode/src/session/prompt.ts +0 -1911
  239. package/packages/opencode/src/session/retry.ts +0 -106
  240. package/packages/opencode/src/session/revert.ts +0 -176
  241. package/packages/opencode/src/session/schema.ts +0 -38
  242. package/packages/opencode/src/session/session.sql.ts +0 -103
  243. package/packages/opencode/src/session/status.ts +0 -102
  244. package/packages/opencode/src/session/summary.ts +0 -177
  245. package/packages/opencode/src/session/system.ts +0 -76
  246. package/packages/opencode/src/session/todo.ts +0 -95
  247. package/packages/opencode/src/share/share-next.ts +0 -369
  248. package/packages/opencode/src/share/share.sql.ts +0 -13
  249. package/packages/opencode/src/shell/shell.ts +0 -110
  250. package/packages/opencode/src/skill/discovery.ts +0 -116
  251. package/packages/opencode/src/skill/index.ts +0 -277
  252. package/packages/opencode/src/snapshot/index.ts +0 -726
  253. package/packages/opencode/src/sql.d.ts +0 -4
  254. package/packages/opencode/src/storage/db.node.ts +0 -8
  255. package/packages/opencode/src/storage/db.ts +0 -177
  256. package/packages/opencode/src/storage/json-migration.ts +0 -425
  257. package/packages/opencode/src/storage/schema.sql.ts +0 -10
  258. package/packages/opencode/src/storage/schema.ts +0 -5
  259. package/packages/opencode/src/storage/storage.ts +0 -353
  260. package/packages/opencode/src/sync/README.md +0 -179
  261. package/packages/opencode/src/sync/event.sql.ts +0 -16
  262. package/packages/opencode/src/sync/index.ts +0 -263
  263. package/packages/opencode/src/sync/schema.ts +0 -14
  264. package/packages/opencode/src/tool/apply_patch.ts +0 -281
  265. package/packages/opencode/src/tool/apply_patch.txt +0 -33
  266. package/packages/opencode/src/tool/bash.ts +0 -496
  267. package/packages/opencode/src/tool/bash.txt +0 -117
  268. package/packages/opencode/src/tool/batch.ts +0 -183
  269. package/packages/opencode/src/tool/batch.txt +0 -24
  270. package/packages/opencode/src/tool/codesearch.ts +0 -132
  271. package/packages/opencode/src/tool/codesearch.txt +0 -12
  272. package/packages/opencode/src/tool/edit.ts +0 -667
  273. package/packages/opencode/src/tool/edit.txt +0 -10
  274. package/packages/opencode/src/tool/external-directory.ts +0 -46
  275. package/packages/opencode/src/tool/glob.ts +0 -78
  276. package/packages/opencode/src/tool/glob.txt +0 -6
  277. package/packages/opencode/src/tool/grep.ts +0 -156
  278. package/packages/opencode/src/tool/grep.txt +0 -8
  279. package/packages/opencode/src/tool/invalid.ts +0 -17
  280. package/packages/opencode/src/tool/ls.ts +0 -121
  281. package/packages/opencode/src/tool/ls.txt +0 -1
  282. package/packages/opencode/src/tool/lsp.ts +0 -97
  283. package/packages/opencode/src/tool/lsp.txt +0 -19
  284. package/packages/opencode/src/tool/multiedit.ts +0 -46
  285. package/packages/opencode/src/tool/multiedit.txt +0 -41
  286. package/packages/opencode/src/tool/plan-enter.txt +0 -14
  287. package/packages/opencode/src/tool/plan-exit.txt +0 -13
  288. package/packages/opencode/src/tool/plan.ts +0 -131
  289. package/packages/opencode/src/tool/question.ts +0 -46
  290. package/packages/opencode/src/tool/question.txt +0 -10
  291. package/packages/opencode/src/tool/read.ts +0 -332
  292. package/packages/opencode/src/tool/read.txt +0 -14
  293. package/packages/opencode/src/tool/registry.ts +0 -265
  294. package/packages/opencode/src/tool/schema.ts +0 -17
  295. package/packages/opencode/src/tool/skill.ts +0 -105
  296. package/packages/opencode/src/tool/task.ts +0 -166
  297. package/packages/opencode/src/tool/task.txt +0 -60
  298. package/packages/opencode/src/tool/todo.ts +0 -48
  299. package/packages/opencode/src/tool/todowrite.txt +0 -167
  300. package/packages/opencode/src/tool/tool.ts +0 -112
  301. package/packages/opencode/src/tool/truncate.ts +0 -144
  302. package/packages/opencode/src/tool/truncation-dir.ts +0 -4
  303. package/packages/opencode/src/tool/webfetch.ts +0 -206
  304. package/packages/opencode/src/tool/webfetch.txt +0 -13
  305. package/packages/opencode/src/tool/websearch.ts +0 -150
  306. package/packages/opencode/src/tool/websearch.txt +0 -14
  307. package/packages/opencode/src/tool/write.ts +0 -84
  308. package/packages/opencode/src/tool/write.txt +0 -8
  309. package/packages/opencode/src/util/abort.ts +0 -35
  310. package/packages/opencode/src/util/archive.ts +0 -17
  311. package/packages/opencode/src/util/color.ts +0 -19
  312. package/packages/opencode/src/util/context.ts +0 -25
  313. package/packages/opencode/src/util/data-url.ts +0 -9
  314. package/packages/opencode/src/util/defer.ts +0 -12
  315. package/packages/opencode/src/util/effect-http-client.ts +0 -11
  316. package/packages/opencode/src/util/effect-zod.ts +0 -98
  317. package/packages/opencode/src/util/error.ts +0 -77
  318. package/packages/opencode/src/util/filesystem.ts +0 -245
  319. package/packages/opencode/src/util/flock.ts +0 -333
  320. package/packages/opencode/src/util/fn.ts +0 -21
  321. package/packages/opencode/src/util/format.ts +0 -20
  322. package/packages/opencode/src/util/glob.ts +0 -34
  323. package/packages/opencode/src/util/hash.ts +0 -7
  324. package/packages/opencode/src/util/iife.ts +0 -3
  325. package/packages/opencode/src/util/keybind.ts +0 -103
  326. package/packages/opencode/src/util/lazy.ts +0 -23
  327. package/packages/opencode/src/util/locale.ts +0 -81
  328. package/packages/opencode/src/util/lock.ts +0 -98
  329. package/packages/opencode/src/util/log.ts +0 -182
  330. package/packages/opencode/src/util/network.ts +0 -9
  331. package/packages/opencode/src/util/process.ts +0 -176
  332. package/packages/opencode/src/util/queue.ts +0 -32
  333. package/packages/opencode/src/util/record.ts +0 -3
  334. package/packages/opencode/src/util/rpc.ts +0 -66
  335. package/packages/opencode/src/util/schema.ts +0 -53
  336. package/packages/opencode/src/util/scrap.ts +0 -10
  337. package/packages/opencode/src/util/signal.ts +0 -12
  338. package/packages/opencode/src/util/timeout.ts +0 -14
  339. package/packages/opencode/src/util/token.ts +0 -7
  340. package/packages/opencode/src/util/update-schema.ts +0 -13
  341. package/packages/opencode/src/util/which.ts +0 -14
  342. package/packages/opencode/src/util/wildcard.ts +0 -59
  343. package/packages/opencode/src/worktree/index.ts +0 -612
  344. package/packages/plugin/package.json +0 -38
  345. package/packages/plugin/src/example.ts +0 -18
  346. package/packages/plugin/src/index.ts +0 -282
  347. package/packages/plugin/src/shell.ts +0 -136
  348. package/packages/plugin/src/tool.ts +0 -38
  349. package/packages/plugin/src/tui.ts +0 -508
  350. package/packages/script/package.json +0 -16
  351. package/packages/script/src/index.ts +0 -77
  352. package/packages/sdk/package.json +0 -33
  353. package/packages/sdk/src/client.ts +0 -55
  354. package/packages/sdk/src/gen/client/client.gen.ts +0 -212
  355. package/packages/sdk/src/gen/client/index.ts +0 -25
  356. package/packages/sdk/src/gen/client/types.gen.ts +0 -222
  357. package/packages/sdk/src/gen/client/utils.gen.ts +0 -287
  358. package/packages/sdk/src/gen/client.gen.ts +0 -22
  359. package/packages/sdk/src/gen/core/auth.gen.ts +0 -41
  360. package/packages/sdk/src/gen/core/bodySerializer.gen.ts +0 -74
  361. package/packages/sdk/src/gen/core/params.gen.ts +0 -144
  362. package/packages/sdk/src/gen/core/pathSerializer.gen.ts +0 -167
  363. package/packages/sdk/src/gen/core/queryKeySerializer.gen.ts +0 -111
  364. package/packages/sdk/src/gen/core/serverSentEvents.gen.ts +0 -210
  365. package/packages/sdk/src/gen/core/types.gen.ts +0 -91
  366. package/packages/sdk/src/gen/core/utils.gen.ts +0 -109
  367. package/packages/sdk/src/gen/sdk.gen.ts +0 -1197
  368. package/packages/sdk/src/gen/types.gen.ts +0 -3904
  369. package/packages/sdk/src/index.ts +0 -21
  370. package/packages/sdk/src/process.ts +0 -31
  371. package/packages/sdk/src/server.ts +0 -134
  372. package/packages/sdk/src/v2/client.ts +0 -81
  373. package/packages/sdk/src/v2/gen/client/client.gen.ts +0 -285
  374. package/packages/sdk/src/v2/gen/client/index.ts +0 -25
  375. package/packages/sdk/src/v2/gen/client/types.gen.ts +0 -202
  376. package/packages/sdk/src/v2/gen/client/utils.gen.ts +0 -289
  377. package/packages/sdk/src/v2/gen/client.gen.ts +0 -18
  378. package/packages/sdk/src/v2/gen/core/auth.gen.ts +0 -41
  379. package/packages/sdk/src/v2/gen/core/bodySerializer.gen.ts +0 -82
  380. package/packages/sdk/src/v2/gen/core/params.gen.ts +0 -169
  381. package/packages/sdk/src/v2/gen/core/pathSerializer.gen.ts +0 -167
  382. package/packages/sdk/src/v2/gen/core/queryKeySerializer.gen.ts +0 -111
  383. package/packages/sdk/src/v2/gen/core/serverSentEvents.gen.ts +0 -239
  384. package/packages/sdk/src/v2/gen/core/types.gen.ts +0 -86
  385. package/packages/sdk/src/v2/gen/core/utils.gen.ts +0 -137
  386. package/packages/sdk/src/v2/gen/sdk.gen.ts +0 -4223
  387. package/packages/sdk/src/v2/gen/types.gen.ts +0 -5265
  388. package/packages/sdk/src/v2/index.ts +0 -21
  389. package/packages/sdk/src/v2/server.ts +0 -134
  390. package/packages/util/package.json +0 -20
  391. package/packages/util/src/array.ts +0 -10
  392. package/packages/util/src/binary.ts +0 -41
  393. package/packages/util/src/encode.ts +0 -51
  394. package/packages/util/src/error.ts +0 -54
  395. package/packages/util/src/fn.ts +0 -11
  396. package/packages/util/src/identifier.ts +0 -48
  397. package/packages/util/src/iife.ts +0 -3
  398. package/packages/util/src/lazy.ts +0 -11
  399. package/packages/util/src/module.ts +0 -10
  400. package/packages/util/src/path.ts +0 -37
  401. package/packages/util/src/retry.ts +0 -41
  402. package/packages/util/src/slug.ts +0 -74
  403. package/postinstall.cjs +0 -55
  404. /package/dist/{chunk-ANDTK76Q.js.map → chunk-GSE2T5UY.js.map} +0 -0
  405. /package/dist/{chunk-CYXMV3J3.js.map → chunk-LU5XVQUD.js.map} +0 -0
  406. /package/dist/{mcp-VAU4RMWH.js.map → chunk-PWFRMDDF.js.map} +0 -0
  407. /package/dist/{chunk-DSPC5QIG.js.map → chunk-SM6WZDN6.js.map} +0 -0
  408. /package/dist/{chunk-MCWTARFP.js.map → chunk-TASPMBUL.js.map} +0 -0
  409. /package/dist/{registry-PYMN6L3G.js.map → default-u_dwuiYb-WOFHQQ3K.js.map} +0 -0
  410. /package/dist/{server-K3UGWASP.js.map → mcp-XFGN3FWW.js.map} +0 -0
  411. /package/dist/{session-HJFWTM7C.js.map → registry-W4MBVBYD.js.map} +0 -0
  412. /package/dist/{share-next-55VCIMUH.js.map → server-2CPOG3LS.js.map} +0 -0
  413. /package/dist/{worktree-6GGDLADY.js.map → worktree-3GUHT2P7.js.map} +0 -0
@@ -1,502 +0,0 @@
1
- import type * as Arr from "effect/Array"
2
- import { NodeFileSystem, NodeSink, NodeStream } from "@effect/platform-node"
3
- import * as NodePath from "@effect/platform-node/NodePath"
4
- import * as Deferred from "effect/Deferred"
5
- import * as Effect from "effect/Effect"
6
- import * as Exit from "effect/Exit"
7
- import * as FileSystem from "effect/FileSystem"
8
- import * as Layer from "effect/Layer"
9
- import * as Path from "effect/Path"
10
- import * as PlatformError from "effect/PlatformError"
11
- import * as Predicate from "effect/Predicate"
12
- import type * as Scope from "effect/Scope"
13
- import * as Sink from "effect/Sink"
14
- import * as Stream from "effect/Stream"
15
- import * as ChildProcess from "effect/unstable/process/ChildProcess"
16
- import type { ChildProcessHandle } from "effect/unstable/process/ChildProcessSpawner"
17
- import {
18
- ChildProcessSpawner,
19
- ExitCode,
20
- make as makeSpawner,
21
- makeHandle,
22
- ProcessId,
23
- } from "effect/unstable/process/ChildProcessSpawner"
24
- import * as NodeChildProcess from "node:child_process"
25
- import { PassThrough } from "node:stream"
26
- import launch from "cross-spawn"
27
-
28
- const toError = (err: unknown): Error => (err instanceof globalThis.Error ? err : new globalThis.Error(String(err)))
29
-
30
- const toTag = (err: NodeJS.ErrnoException): PlatformError.SystemErrorTag => {
31
- switch (err.code) {
32
- case "ENOENT":
33
- return "NotFound"
34
- case "EACCES":
35
- return "PermissionDenied"
36
- case "EEXIST":
37
- return "AlreadyExists"
38
- case "EISDIR":
39
- return "BadResource"
40
- case "ENOTDIR":
41
- return "BadResource"
42
- case "EBUSY":
43
- return "Busy"
44
- case "ELOOP":
45
- return "BadResource"
46
- default:
47
- return "Unknown"
48
- }
49
- }
50
-
51
- const flatten = (command: ChildProcess.Command) => {
52
- const commands: Array<ChildProcess.StandardCommand> = []
53
- const opts: Array<ChildProcess.PipeOptions> = []
54
-
55
- const walk = (cmd: ChildProcess.Command): void => {
56
- switch (cmd._tag) {
57
- case "StandardCommand":
58
- commands.push(cmd)
59
- return
60
- case "PipedCommand":
61
- walk(cmd.left)
62
- opts.push(cmd.options)
63
- walk(cmd.right)
64
- return
65
- }
66
- }
67
-
68
- walk(command)
69
- if (commands.length === 0) throw new Error("flatten produced empty commands array")
70
- const [head, ...tail] = commands
71
- return {
72
- commands: [head, ...tail] as Arr.NonEmptyReadonlyArray<ChildProcess.StandardCommand>,
73
- opts,
74
- }
75
- }
76
-
77
- const toPlatformError = (
78
- method: string,
79
- err: NodeJS.ErrnoException,
80
- command: ChildProcess.Command,
81
- ): PlatformError.PlatformError => {
82
- const cmd = flatten(command)
83
- .commands.map((x) => `${x.command} ${x.args.join(" ")}`)
84
- .join(" | ")
85
- return PlatformError.systemError({
86
- _tag: toTag(err),
87
- module: "ChildProcess",
88
- method,
89
- pathOrDescriptor: cmd,
90
- syscall: err.syscall,
91
- cause: err,
92
- })
93
- }
94
-
95
- type ExitSignal = Deferred.Deferred<readonly [code: number | null, signal: NodeJS.Signals | null]>
96
-
97
- export const make = Effect.gen(function* () {
98
- const fs = yield* FileSystem.FileSystem
99
- const path = yield* Path.Path
100
-
101
- const cwd = Effect.fnUntraced(function* (opts: ChildProcess.CommandOptions) {
102
- if (Predicate.isUndefined(opts.cwd)) return undefined
103
- yield* fs.access(opts.cwd)
104
- return path.resolve(opts.cwd)
105
- })
106
-
107
- const env = (opts: ChildProcess.CommandOptions) =>
108
- opts.extendEnv ? { ...globalThis.process.env, ...opts.env } : opts.env
109
-
110
- const input = (x: ChildProcess.CommandInput | undefined): NodeChildProcess.IOType | undefined =>
111
- Stream.isStream(x) ? "pipe" : x
112
-
113
- const output = (x: ChildProcess.CommandOutput | undefined): NodeChildProcess.IOType | undefined =>
114
- Sink.isSink(x) ? "pipe" : x
115
-
116
- const stdin = (opts: ChildProcess.CommandOptions): ChildProcess.StdinConfig => {
117
- const cfg: ChildProcess.StdinConfig = { stream: "pipe", encoding: "utf-8", endOnDone: true }
118
- if (Predicate.isUndefined(opts.stdin)) return cfg
119
- if (typeof opts.stdin === "string") return { ...cfg, stream: opts.stdin }
120
- if (Stream.isStream(opts.stdin)) return { ...cfg, stream: opts.stdin }
121
- return {
122
- stream: opts.stdin.stream,
123
- encoding: opts.stdin.encoding ?? cfg.encoding,
124
- endOnDone: opts.stdin.endOnDone ?? cfg.endOnDone,
125
- }
126
- }
127
-
128
- const stdio = (opts: ChildProcess.CommandOptions, key: "stdout" | "stderr"): ChildProcess.StdoutConfig => {
129
- const cfg = opts[key]
130
- if (Predicate.isUndefined(cfg)) return { stream: "pipe" }
131
- if (typeof cfg === "string") return { stream: cfg }
132
- if (Sink.isSink(cfg)) return { stream: cfg }
133
- return { stream: cfg.stream }
134
- }
135
-
136
- const fds = (opts: ChildProcess.CommandOptions) => {
137
- if (Predicate.isUndefined(opts.additionalFds)) return []
138
- return Object.entries(opts.additionalFds)
139
- .flatMap(([name, config]) => {
140
- const fd = ChildProcess.parseFdName(name)
141
- return Predicate.isUndefined(fd) ? [] : [{ fd, config }]
142
- })
143
- .toSorted((a, b) => a.fd - b.fd)
144
- }
145
-
146
- const stdios = (
147
- sin: ChildProcess.StdinConfig,
148
- sout: ChildProcess.StdoutConfig,
149
- serr: ChildProcess.StderrConfig,
150
- extra: ReadonlyArray<{ fd: number; config: ChildProcess.AdditionalFdConfig }>,
151
- ): NodeChildProcess.StdioOptions => {
152
- const pipe = (x: NodeChildProcess.IOType | undefined) =>
153
- process.platform === "win32" && x === "pipe" ? "overlapped" : x
154
- const arr: Array<NodeChildProcess.IOType | undefined> = [
155
- pipe(input(sin.stream)),
156
- pipe(output(sout.stream)),
157
- pipe(output(serr.stream)),
158
- ]
159
- if (extra.length === 0) return arr as NodeChildProcess.StdioOptions
160
- const max = extra.reduce((acc, x) => Math.max(acc, x.fd), 2)
161
- for (let i = 3; i <= max; i++) arr[i] = "ignore"
162
- for (const x of extra) arr[x.fd] = pipe("pipe")
163
- return arr as NodeChildProcess.StdioOptions
164
- }
165
-
166
- const setupFds = Effect.fnUntraced(function* (
167
- command: ChildProcess.StandardCommand,
168
- proc: NodeChildProcess.ChildProcess,
169
- extra: ReadonlyArray<{ fd: number; config: ChildProcess.AdditionalFdConfig }>,
170
- ) {
171
- if (extra.length === 0) {
172
- return {
173
- getInputFd: () => Sink.drain,
174
- getOutputFd: () => Stream.empty,
175
- }
176
- }
177
-
178
- const ins = new Map<number, Sink.Sink<void, Uint8Array, never, PlatformError.PlatformError>>()
179
- const outs = new Map<number, Stream.Stream<Uint8Array, PlatformError.PlatformError>>()
180
-
181
- for (const x of extra) {
182
- const node = proc.stdio[x.fd]
183
- switch (x.config.type) {
184
- case "input": {
185
- let sink: Sink.Sink<void, Uint8Array, never, PlatformError.PlatformError> = Sink.drain
186
- if (node && "write" in node) {
187
- sink = NodeSink.fromWritable({
188
- evaluate: () => node,
189
- onError: (err) => toPlatformError(`fromWritable(fd${x.fd})`, toError(err), command),
190
- endOnDone: true,
191
- })
192
- }
193
- if (x.config.stream) yield* Effect.forkScoped(Stream.run(x.config.stream, sink))
194
- ins.set(x.fd, sink)
195
- break
196
- }
197
- case "output": {
198
- let stream: Stream.Stream<Uint8Array, PlatformError.PlatformError> = Stream.empty
199
- if (node && "read" in node) {
200
- const tap = new PassThrough()
201
- node.on("error", (err) => tap.destroy(toError(err)))
202
- node.pipe(tap)
203
- stream = NodeStream.fromReadable({
204
- evaluate: () => tap,
205
- onError: (err) => toPlatformError(`fromReadable(fd${x.fd})`, toError(err), command),
206
- })
207
- }
208
- if (x.config.sink) stream = Stream.transduce(stream, x.config.sink)
209
- outs.set(x.fd, stream)
210
- break
211
- }
212
- }
213
- }
214
-
215
- return {
216
- getInputFd: (fd: number) => ins.get(fd) ?? Sink.drain,
217
- getOutputFd: (fd: number) => outs.get(fd) ?? Stream.empty,
218
- }
219
- })
220
-
221
- const setupStdin = (
222
- command: ChildProcess.StandardCommand,
223
- proc: NodeChildProcess.ChildProcess,
224
- cfg: ChildProcess.StdinConfig,
225
- ) =>
226
- Effect.suspend(() => {
227
- let sink: Sink.Sink<void, unknown, never, PlatformError.PlatformError> = Sink.drain
228
- if (Predicate.isNotNull(proc.stdin)) {
229
- sink = NodeSink.fromWritable({
230
- evaluate: () => proc.stdin!,
231
- onError: (err) => toPlatformError("fromWritable(stdin)", toError(err), command),
232
- endOnDone: cfg.endOnDone,
233
- encoding: cfg.encoding,
234
- })
235
- }
236
- if (Stream.isStream(cfg.stream)) return Effect.as(Effect.forkScoped(Stream.run(cfg.stream, sink)), sink)
237
- return Effect.succeed(sink)
238
- })
239
-
240
- const setupOutput = (
241
- command: ChildProcess.StandardCommand,
242
- proc: NodeChildProcess.ChildProcess,
243
- out: ChildProcess.StdoutConfig,
244
- err: ChildProcess.StderrConfig,
245
- ) => {
246
- let stdout = proc.stdout
247
- ? NodeStream.fromReadable({
248
- evaluate: () => proc.stdout!,
249
- onError: (cause) => toPlatformError("fromReadable(stdout)", toError(cause), command),
250
- })
251
- : Stream.empty
252
- let stderr = proc.stderr
253
- ? NodeStream.fromReadable({
254
- evaluate: () => proc.stderr!,
255
- onError: (cause) => toPlatformError("fromReadable(stderr)", toError(cause), command),
256
- })
257
- : Stream.empty
258
-
259
- if (Sink.isSink(out.stream)) stdout = Stream.transduce(stdout, out.stream)
260
- if (Sink.isSink(err.stream)) stderr = Stream.transduce(stderr, err.stream)
261
-
262
- return { stdout, stderr, all: Stream.merge(stdout, stderr) }
263
- }
264
-
265
- const spawn = (command: ChildProcess.StandardCommand, opts: NodeChildProcess.SpawnOptions) =>
266
- Effect.callback<readonly [NodeChildProcess.ChildProcess, ExitSignal], PlatformError.PlatformError>((resume) => {
267
- const signal = Deferred.makeUnsafe<readonly [code: number | null, signal: NodeJS.Signals | null]>()
268
- const proc = launch(command.command, command.args, opts)
269
- let end = false
270
- let exit: readonly [code: number | null, signal: NodeJS.Signals | null] | undefined
271
- proc.on("error", (err) => {
272
- resume(Effect.fail(toPlatformError("spawn", err, command)))
273
- })
274
- proc.on("exit", (...args) => {
275
- exit = args
276
- })
277
- proc.on("close", (...args) => {
278
- if (end) return
279
- end = true
280
- Deferred.doneUnsafe(signal, Exit.succeed(exit ?? args))
281
- })
282
- proc.on("spawn", () => {
283
- resume(Effect.succeed([proc, signal]))
284
- })
285
- return Effect.sync(() => {
286
- proc.kill("SIGTERM")
287
- })
288
- })
289
-
290
- const killGroup = (
291
- command: ChildProcess.StandardCommand,
292
- proc: NodeChildProcess.ChildProcess,
293
- signal: NodeJS.Signals,
294
- ) => {
295
- if (globalThis.process.platform === "win32") {
296
- return Effect.callback<void, PlatformError.PlatformError>((resume) => {
297
- NodeChildProcess.exec(`taskkill /pid ${proc.pid} /T /F`, { windowsHide: true }, (err) => {
298
- if (err) return resume(Effect.fail(toPlatformError("kill", toError(err), command)))
299
- resume(Effect.void)
300
- })
301
- })
302
- }
303
-
304
- return Effect.try({
305
- try: () => {
306
- globalThis.process.kill(-proc.pid!, signal)
307
- },
308
- catch: (err) => toPlatformError("kill", toError(err), command),
309
- })
310
- }
311
-
312
- const killOne = (
313
- command: ChildProcess.StandardCommand,
314
- proc: NodeChildProcess.ChildProcess,
315
- signal: NodeJS.Signals,
316
- ) =>
317
- Effect.suspend(() => {
318
- if (proc.kill(signal)) return Effect.void
319
- return Effect.fail(toPlatformError("kill", new Error("Failed to kill child process"), command))
320
- })
321
-
322
- const timeout =
323
- (
324
- proc: NodeChildProcess.ChildProcess,
325
- command: ChildProcess.StandardCommand,
326
- opts: ChildProcess.KillOptions | undefined,
327
- ) =>
328
- <A, E, R>(
329
- f: (
330
- command: ChildProcess.StandardCommand,
331
- proc: NodeChildProcess.ChildProcess,
332
- signal: NodeJS.Signals,
333
- ) => Effect.Effect<A, E, R>,
334
- ) => {
335
- const signal = opts?.killSignal ?? "SIGTERM"
336
- if (Predicate.isUndefined(opts?.forceKillAfter)) return f(command, proc, signal)
337
- return Effect.timeoutOrElse(f(command, proc, signal), {
338
- duration: opts.forceKillAfter,
339
- orElse: () => f(command, proc, "SIGKILL"),
340
- })
341
- }
342
-
343
- const source = (handle: ChildProcessHandle, from: ChildProcess.PipeFromOption | undefined) => {
344
- const opt = from ?? "stdout"
345
- switch (opt) {
346
- case "stdout":
347
- return handle.stdout
348
- case "stderr":
349
- return handle.stderr
350
- case "all":
351
- return handle.all
352
- default: {
353
- const fd = ChildProcess.parseFdName(opt)
354
- return Predicate.isNotUndefined(fd) ? handle.getOutputFd(fd) : handle.stdout
355
- }
356
- }
357
- }
358
-
359
- const spawnCommand: (
360
- command: ChildProcess.Command,
361
- ) => Effect.Effect<ChildProcessHandle, PlatformError.PlatformError, Scope.Scope> = Effect.fnUntraced(
362
- function* (command) {
363
- switch (command._tag) {
364
- case "StandardCommand": {
365
- const sin = stdin(command.options)
366
- const sout = stdio(command.options, "stdout")
367
- const serr = stdio(command.options, "stderr")
368
- const extra = fds(command.options)
369
- const dir = yield* cwd(command.options)
370
-
371
- const [proc, signal] = yield* Effect.acquireRelease(
372
- spawn(command, {
373
- cwd: dir,
374
- env: env(command.options),
375
- stdio: stdios(sin, sout, serr, extra),
376
- detached: command.options.detached ?? process.platform !== "win32",
377
- shell: command.options.shell,
378
- windowsHide: process.platform === "win32",
379
- }),
380
- Effect.fnUntraced(function* ([proc, signal]) {
381
- const done = yield* Deferred.isDone(signal)
382
- const kill = timeout(proc, command, command.options)
383
- if (done) {
384
- const [code] = yield* Deferred.await(signal)
385
- if (process.platform === "win32") return yield* Effect.void
386
- if (code !== 0 && Predicate.isNotNull(code)) return yield* Effect.ignore(kill(killGroup))
387
- return yield* Effect.void
388
- }
389
- const send = (s: NodeJS.Signals) =>
390
- Effect.catch(killGroup(command, proc, s), () => killOne(command, proc, s))
391
- const sig = command.options.killSignal ?? "SIGTERM"
392
- const attempt = send(sig).pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid)
393
- const escalated = command.options.forceKillAfter
394
- ? Effect.timeoutOrElse(attempt, {
395
- duration: command.options.forceKillAfter,
396
- orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
397
- })
398
- : attempt
399
- return yield* Effect.ignore(escalated)
400
- }),
401
- )
402
-
403
- const fd = yield* setupFds(command, proc, extra)
404
- const out = setupOutput(command, proc, sout, serr)
405
- return makeHandle({
406
- pid: ProcessId(proc.pid!),
407
- stdin: yield* setupStdin(command, proc, sin),
408
- stdout: out.stdout,
409
- stderr: out.stderr,
410
- all: out.all,
411
- getInputFd: fd.getInputFd,
412
- getOutputFd: fd.getOutputFd,
413
- isRunning: Effect.map(Deferred.isDone(signal), (done) => !done),
414
- exitCode: Effect.flatMap(Deferred.await(signal), ([code, signal]) => {
415
- if (Predicate.isNotNull(code)) return Effect.succeed(ExitCode(code))
416
- return Effect.fail(
417
- toPlatformError(
418
- "exitCode",
419
- new Error(`Process interrupted due to receipt of signal: '${signal}'`),
420
- command,
421
- ),
422
- )
423
- }),
424
- kill: (opts?: ChildProcess.KillOptions) => {
425
- const sig = opts?.killSignal ?? "SIGTERM"
426
- const send = (s: NodeJS.Signals) =>
427
- Effect.catch(killGroup(command, proc, s), () => killOne(command, proc, s))
428
- const attempt = send(sig).pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid)
429
- if (!opts?.forceKillAfter) return attempt
430
- return Effect.timeoutOrElse(attempt, {
431
- duration: opts.forceKillAfter,
432
- orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
433
- })
434
- },
435
- })
436
- }
437
- case "PipedCommand": {
438
- const flat = flatten(command)
439
- const [head, ...tail] = flat.commands
440
- let handle = spawnCommand(head)
441
- for (let i = 0; i < tail.length; i++) {
442
- const next = tail[i]
443
- const opts = flat.opts[i] ?? {}
444
- const sin = stdin(next.options)
445
- const stream = Stream.unwrap(Effect.map(handle, (x) => source(x, opts.from)))
446
- const to = opts.to ?? "stdin"
447
- if (to === "stdin") {
448
- handle = spawnCommand(
449
- ChildProcess.make(next.command, next.args, {
450
- ...next.options,
451
- stdin: { ...sin, stream },
452
- }),
453
- )
454
- continue
455
- }
456
- const fd = ChildProcess.parseFdName(to)
457
- if (Predicate.isUndefined(fd)) {
458
- handle = spawnCommand(
459
- ChildProcess.make(next.command, next.args, {
460
- ...next.options,
461
- stdin: { ...sin, stream },
462
- }),
463
- )
464
- continue
465
- }
466
- handle = spawnCommand(
467
- ChildProcess.make(next.command, next.args, {
468
- ...next.options,
469
- additionalFds: {
470
- ...next.options.additionalFds,
471
- [ChildProcess.fdName(fd) as `fd${number}`]: { type: "input", stream },
472
- },
473
- }),
474
- )
475
- }
476
- return yield* handle
477
- }
478
- }
479
- },
480
- )
481
-
482
- return makeSpawner(spawnCommand)
483
- })
484
-
485
- export const layer: Layer.Layer<ChildProcessSpawner, never, FileSystem.FileSystem | Path.Path> = Layer.effect(
486
- ChildProcessSpawner,
487
- make,
488
- )
489
-
490
- export const defaultLayer = layer.pipe(Layer.provide(NodeFileSystem.layer), Layer.provide(NodePath.layer))
491
-
492
- import { lazy } from "@/util/lazy"
493
-
494
- const rt = lazy(async () => {
495
- // Dynamic import to avoid circular dep: cross-spawn-spawner → run-service → Instance → project → cross-spawn-spawner
496
- const { makeRuntime } = await import("@/effect/run-service")
497
- return makeRuntime(ChildProcessSpawner, defaultLayer)
498
- })
499
-
500
- type RT = Awaited<ReturnType<typeof rt>>
501
- export const runPromiseExit: RT["runPromiseExit"] = async (...args) => (await rt()).runPromiseExit(...(args as [any]))
502
- export const runPromise: RT["runPromise"] = async (...args) => (await rt()).runPromise(...(args as [any]))
@@ -1,6 +0,0 @@
1
- import { ServiceMap } from "effect"
2
- import type { InstanceContext } from "@/project/instance"
3
-
4
- export const InstanceRef = ServiceMap.Reference<InstanceContext | undefined>("~opencode/InstanceRef", {
5
- defaultValue: () => undefined,
6
- })
@@ -1,12 +0,0 @@
1
- const disposers = new Set<(directory: string) => Promise<void>>()
2
-
3
- export function registerDisposer(disposer: (directory: string) => Promise<void>) {
4
- disposers.add(disposer)
5
- return () => {
6
- disposers.delete(disposer)
7
- }
8
- }
9
-
10
- export async function disposeInstance(directory: string) {
11
- await Promise.allSettled([...disposers].map((disposer) => disposer(directory)))
12
- }
@@ -1,82 +0,0 @@
1
- import { Effect, Fiber, ScopedCache, Scope, ServiceMap } from "effect"
2
- import { Instance, type InstanceContext } from "@/project/instance"
3
- import { Context } from "@/util/context"
4
- import { InstanceRef } from "./instance-ref"
5
- import { registerDisposer } from "./instance-registry"
6
-
7
- const TypeId = "~opencode/InstanceState"
8
-
9
- export interface InstanceState<A, E = never, R = never> {
10
- readonly [TypeId]: typeof TypeId
11
- readonly cache: ScopedCache.ScopedCache<string, A, E, R>
12
- }
13
-
14
- export namespace InstanceState {
15
- export const bind = <F extends (...args: any[]) => any>(fn: F): F => {
16
- try {
17
- return Instance.bind(fn)
18
- } catch (err) {
19
- if (!(err instanceof Context.NotFound)) throw err
20
- }
21
- const fiber = Fiber.getCurrent()
22
- const ctx = fiber ? ServiceMap.getReferenceUnsafe(fiber.services, InstanceRef) : undefined
23
- if (!ctx) return fn
24
- return ((...args: any[]) => Instance.restore(ctx, () => fn(...args))) as F
25
- }
26
-
27
- export const context = Effect.gen(function* () {
28
- return (yield* InstanceRef) ?? Instance.current
29
- })
30
-
31
- export const directory = Effect.map(context, (ctx) => ctx.directory)
32
-
33
- export const make = <A, E = never, R = never>(
34
- init: (ctx: InstanceContext) => Effect.Effect<A, E, R | Scope.Scope>,
35
- ): Effect.Effect<InstanceState<A, E, Exclude<R, Scope.Scope>>, never, R | Scope.Scope> =>
36
- Effect.gen(function* () {
37
- const cache = yield* ScopedCache.make<string, A, E, R>({
38
- capacity: Number.POSITIVE_INFINITY,
39
- lookup: () =>
40
- Effect.gen(function* () {
41
- return yield* init(yield* context)
42
- }),
43
- })
44
-
45
- const off = registerDisposer((directory) => Effect.runPromise(ScopedCache.invalidate(cache, directory)))
46
- yield* Effect.addFinalizer(() => Effect.sync(off))
47
-
48
- return {
49
- [TypeId]: TypeId,
50
- cache,
51
- }
52
- })
53
-
54
- export const get = <A, E, R>(self: InstanceState<A, E, R>) =>
55
- Effect.gen(function* () {
56
- return yield* ScopedCache.get(self.cache, yield* directory)
57
- })
58
-
59
- export const use = <A, E, R, B>(self: InstanceState<A, E, R>, select: (value: A) => B) =>
60
- Effect.map(get(self), select)
61
-
62
- export const useEffect = <A, E, R, B, E2, R2>(
63
- self: InstanceState<A, E, R>,
64
- select: (value: A) => Effect.Effect<B, E2, R2>,
65
- ) => Effect.flatMap(get(self), select)
66
-
67
- export const has = <A, E, R>(self: InstanceState<A, E, R>) =>
68
- Effect.gen(function* () {
69
- return yield* ScopedCache.has(self.cache, yield* directory)
70
- })
71
-
72
- export const invalidate = <A, E, R>(self: InstanceState<A, E, R>) =>
73
- Effect.gen(function* () {
74
- return yield* ScopedCache.invalidate(self.cache, yield* directory)
75
- })
76
-
77
- /**
78
- * Effect finalizers run on the fiber scheduler after the original async
79
- * boundary, so ALS reads like Instance.directory can be gone by then.
80
- */
81
- export const withALS = <T>(fn: () => T) => Effect.map(context, (ctx) => Instance.restore(ctx, fn))
82
- }
@@ -1,33 +0,0 @@
1
- import { Effect, Layer, ManagedRuntime } from "effect"
2
- import * as ServiceMap from "effect/ServiceMap"
3
- import { Instance } from "@/project/instance"
4
- import { Context } from "@/util/context"
5
- import { InstanceRef } from "./instance-ref"
6
-
7
- export const memoMap = Layer.makeMemoMapUnsafe()
8
-
9
- function attach<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> {
10
- try {
11
- const ctx = Instance.current
12
- return Effect.provideService(effect, InstanceRef, ctx)
13
- } catch (err) {
14
- if (!(err instanceof Context.NotFound)) throw err
15
- }
16
- return effect
17
- }
18
-
19
- export function makeRuntime<I, S, E>(service: ServiceMap.Service<I, S>, layer: Layer.Layer<I, E>) {
20
- let rt: ManagedRuntime.ManagedRuntime<I, E> | undefined
21
- const getRuntime = () => (rt ??= ManagedRuntime.make(layer, { memoMap }))
22
-
23
- return {
24
- runSync: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runSync(attach(service.use(fn))),
25
- runPromiseExit: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) =>
26
- getRuntime().runPromiseExit(attach(service.use(fn)), options),
27
- runPromise: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) =>
28
- getRuntime().runPromise(attach(service.use(fn)), options),
29
- runFork: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runFork(attach(service.use(fn))),
30
- runCallback: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) =>
31
- getRuntime().runCallback(attach(service.use(fn))),
32
- }
33
- }