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,15 +0,0 @@
1
- import z from "zod"
2
-
3
- export const ConsoleState = z.object({
4
- consoleManagedProviders: z.array(z.string()),
5
- activeOrgName: z.string().optional(),
6
- switchableOrgCount: z.number().int().nonnegative(),
7
- })
8
-
9
- export type ConsoleState = z.infer<typeof ConsoleState>
10
-
11
- export const emptyConsoleState: ConsoleState = {
12
- consoleManagedProviders: [],
13
- activeOrgName: undefined,
14
- switchableOrgCount: 0,
15
- }
@@ -1,99 +0,0 @@
1
- import { NamedError } from "@opencode-ai/util/error"
2
- import matter from "gray-matter"
3
- import { z } from "zod"
4
- import { Filesystem } from "../util/filesystem"
5
-
6
- export namespace ConfigMarkdown {
7
- export const FILE_REGEX = /(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g
8
- export const SHELL_REGEX = /!`([^`]+)`/g
9
-
10
- export function files(template: string) {
11
- return Array.from(template.matchAll(FILE_REGEX))
12
- }
13
-
14
- export function shell(template: string) {
15
- return Array.from(template.matchAll(SHELL_REGEX))
16
- }
17
-
18
- // other coding agents like claude code allow invalid yaml in their
19
- // frontmatter, we need to fallback to a more permissive parser for those cases
20
- export function fallbackSanitization(content: string): string {
21
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/)
22
- if (!match) return content
23
-
24
- const frontmatter = match[1]
25
- const lines = frontmatter.split(/\r?\n/)
26
- const result: string[] = []
27
-
28
- for (const line of lines) {
29
- // skip comments and empty lines
30
- if (line.trim().startsWith("#") || line.trim() === "") {
31
- result.push(line)
32
- continue
33
- }
34
-
35
- // skip lines that are continuations (indented)
36
- if (line.match(/^\s+/)) {
37
- result.push(line)
38
- continue
39
- }
40
-
41
- // match key: value pattern
42
- const kvMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*:\s*(.*)$/)
43
- if (!kvMatch) {
44
- result.push(line)
45
- continue
46
- }
47
-
48
- const key = kvMatch[1]
49
- const value = kvMatch[2].trim()
50
-
51
- // skip if value is empty, already quoted, or uses block scalar
52
- if (value === "" || value === ">" || value === "|" || value.startsWith('"') || value.startsWith("'")) {
53
- result.push(line)
54
- continue
55
- }
56
-
57
- // if value contains a colon, convert to block scalar
58
- if (value.includes(":")) {
59
- result.push(`${key}: |-`)
60
- result.push(` ${value}`)
61
- continue
62
- }
63
-
64
- result.push(line)
65
- }
66
-
67
- const processed = result.join("\n")
68
- return content.replace(frontmatter, () => processed)
69
- }
70
-
71
- export async function parse(filePath: string) {
72
- const template = await Filesystem.readText(filePath)
73
-
74
- try {
75
- const md = matter(template)
76
- return md
77
- } catch {
78
- try {
79
- return matter(fallbackSanitization(template))
80
- } catch (err) {
81
- throw new FrontmatterError(
82
- {
83
- path: filePath,
84
- message: `${filePath}: Failed to parse YAML frontmatter: ${err instanceof Error ? err.message : String(err)}`,
85
- },
86
- { cause: err },
87
- )
88
- }
89
- }
90
- }
91
-
92
- export const FrontmatterError = NamedError.create(
93
- "ConfigFrontmatterError",
94
- z.object({
95
- path: z.string(),
96
- message: z.string(),
97
- }),
98
- )
99
- }
@@ -1,167 +0,0 @@
1
- import path from "path"
2
- import os from "os"
3
- import z from "zod"
4
- import { type ParseError as JsoncParseError, parse as parseJsonc, printParseErrorCode } from "jsonc-parser"
5
- import { NamedError } from "@opencode-ai/util/error"
6
- import { Filesystem } from "@/util/filesystem"
7
- import { Flag } from "@/flag/flag"
8
- import { Global } from "@/global"
9
-
10
- export namespace ConfigPaths {
11
- export async function projectFiles(name: string, directory: string, worktree: string) {
12
- return Filesystem.findUp([`${name}.json`, `${name}.jsonc`], directory, worktree, { rootFirst: true })
13
- }
14
-
15
- export async function directories(directory: string, worktree: string) {
16
- return [
17
- Global.Path.config,
18
- ...(!Flag.OPENCODE_DISABLE_PROJECT_CONFIG
19
- ? await Array.fromAsync(
20
- Filesystem.up({
21
- targets: [".opencode"],
22
- start: directory,
23
- stop: worktree,
24
- }),
25
- )
26
- : []),
27
- ...(await Array.fromAsync(
28
- Filesystem.up({
29
- targets: [".opencode"],
30
- start: Global.Path.home,
31
- stop: Global.Path.home,
32
- }),
33
- )),
34
- ...(Flag.OPENCODE_CONFIG_DIR ? [Flag.OPENCODE_CONFIG_DIR] : []),
35
- ]
36
- }
37
-
38
- export function fileInDirectory(dir: string, name: string) {
39
- return [path.join(dir, `${name}.json`), path.join(dir, `${name}.jsonc`)]
40
- }
41
-
42
- export const JsonError = NamedError.create(
43
- "ConfigJsonError",
44
- z.object({
45
- path: z.string(),
46
- message: z.string().optional(),
47
- }),
48
- )
49
-
50
- export const InvalidError = NamedError.create(
51
- "ConfigInvalidError",
52
- z.object({
53
- path: z.string(),
54
- issues: z.custom<z.core.$ZodIssue[]>().optional(),
55
- message: z.string().optional(),
56
- }),
57
- )
58
-
59
- /** Read a config file, returning undefined for missing files and throwing JsonError for other failures. */
60
- export async function readFile(filepath: string) {
61
- return Filesystem.readText(filepath).catch((err: NodeJS.ErrnoException) => {
62
- if (err.code === "ENOENT") return
63
- throw new JsonError({ path: filepath }, { cause: err })
64
- })
65
- }
66
-
67
- type ParseSource = string | { source: string; dir: string }
68
-
69
- function source(input: ParseSource) {
70
- return typeof input === "string" ? input : input.source
71
- }
72
-
73
- function dir(input: ParseSource) {
74
- return typeof input === "string" ? path.dirname(input) : input.dir
75
- }
76
-
77
- /** Apply {env:VAR} and {file:path} substitutions to config text. */
78
- async function substitute(text: string, input: ParseSource, missing: "error" | "empty" = "error") {
79
- text = text.replace(/\{env:([^}]+)\}/g, (_, varName) => {
80
- return process.env[varName] || ""
81
- })
82
-
83
- const fileMatches = Array.from(text.matchAll(/\{file:[^}]+\}/g))
84
- if (!fileMatches.length) return text
85
-
86
- const configDir = dir(input)
87
- const configSource = source(input)
88
- let out = ""
89
- let cursor = 0
90
-
91
- for (const match of fileMatches) {
92
- const token = match[0]
93
- const index = match.index!
94
- out += text.slice(cursor, index)
95
-
96
- const lineStart = text.lastIndexOf("\n", index - 1) + 1
97
- const prefix = text.slice(lineStart, index).trimStart()
98
- if (prefix.startsWith("//")) {
99
- out += token
100
- cursor = index + token.length
101
- continue
102
- }
103
-
104
- let filePath = token.replace(/^\{file:/, "").replace(/\}$/, "")
105
- if (filePath.startsWith("~/")) {
106
- filePath = path.join(os.homedir(), filePath.slice(2))
107
- }
108
-
109
- const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve(configDir, filePath)
110
- const fileContent = (
111
- await Filesystem.readText(resolvedPath).catch((error: NodeJS.ErrnoException) => {
112
- if (missing === "empty") return ""
113
-
114
- const errMsg = `bad file reference: "${token}"`
115
- if (error.code === "ENOENT") {
116
- throw new InvalidError(
117
- {
118
- path: configSource,
119
- message: errMsg + ` ${resolvedPath} does not exist`,
120
- },
121
- { cause: error },
122
- )
123
- }
124
- throw new InvalidError({ path: configSource, message: errMsg }, { cause: error })
125
- })
126
- ).trim()
127
-
128
- out += JSON.stringify(fileContent).slice(1, -1)
129
- cursor = index + token.length
130
- }
131
-
132
- out += text.slice(cursor)
133
- return out
134
- }
135
-
136
- /** Substitute and parse JSONC text, throwing JsonError on syntax errors. */
137
- export async function parseText(text: string, input: ParseSource, missing: "error" | "empty" = "error") {
138
- const configSource = source(input)
139
- text = await substitute(text, input, missing)
140
-
141
- const errors: JsoncParseError[] = []
142
- const data = parseJsonc(text, errors, { allowTrailingComma: true })
143
- if (errors.length) {
144
- const lines = text.split("\n")
145
- const errorDetails = errors
146
- .map((e) => {
147
- const beforeOffset = text.substring(0, e.offset).split("\n")
148
- const line = beforeOffset.length
149
- const column = beforeOffset[beforeOffset.length - 1].length + 1
150
- const problemLine = lines[line - 1]
151
-
152
- const error = `${printParseErrorCode(e.error)} at line ${line}, column ${column}`
153
- if (!problemLine) return error
154
-
155
- return `${error}\n Line ${line}: ${problemLine}\n${"".padStart(column + 9)}^`
156
- })
157
- .join("\n")
158
-
159
- throw new JsonError({
160
- path: configSource,
161
- message: `\n--- JSONC Input ---\n${text}\n--- Errors ---\n${errorDetails}\n--- End ---`,
162
- })
163
- }
164
-
165
- return data
166
- }
167
- }
@@ -1,155 +0,0 @@
1
- import path from "path"
2
- import { type ParseError as JsoncParseError, applyEdits, modify, parse as parseJsonc } from "jsonc-parser"
3
- import { unique } from "remeda"
4
- import z from "zod"
5
- import { ConfigPaths } from "./paths"
6
- import { TuiInfo, TuiOptions } from "./tui-schema"
7
- import { Instance } from "@/project/instance"
8
- import { Flag } from "@/flag/flag"
9
- import { Log } from "@/util/log"
10
- import { Filesystem } from "@/util/filesystem"
11
- import { Global } from "@/global"
12
-
13
- const log = Log.create({ service: "tui.migrate" })
14
-
15
- const TUI_SCHEMA_URL = "https://opencode.ai/tui.json"
16
-
17
- const LegacyTheme = TuiInfo.shape.theme.optional()
18
- const LegacyRecord = z.record(z.string(), z.unknown()).optional()
19
-
20
- const TuiLegacy = z
21
- .object({
22
- scroll_speed: TuiOptions.shape.scroll_speed.catch(undefined),
23
- scroll_acceleration: TuiOptions.shape.scroll_acceleration.catch(undefined),
24
- diff_style: TuiOptions.shape.diff_style.catch(undefined),
25
- })
26
- .strip()
27
-
28
- interface MigrateInput {
29
- directories: string[]
30
- custom?: string
31
- managed: string
32
- }
33
-
34
- /**
35
- * Migrates tui-specific keys (theme, keybinds, tui) from opencode.json files
36
- * into dedicated tui.json files. Migration is performed per-directory and
37
- * skips only locations where a tui.json already exists.
38
- */
39
- export async function migrateTuiConfig(input: MigrateInput) {
40
- const opencode = await opencodeFiles(input)
41
- for (const file of opencode) {
42
- const source = await Filesystem.readText(file).catch((error) => {
43
- log.warn("failed to read config for tui migration", { path: file, error })
44
- return undefined
45
- })
46
- if (!source) continue
47
- const errors: JsoncParseError[] = []
48
- const data = parseJsonc(source, errors, { allowTrailingComma: true })
49
- if (errors.length || !data || typeof data !== "object" || Array.isArray(data)) continue
50
-
51
- const theme = LegacyTheme.safeParse("theme" in data ? data.theme : undefined)
52
- const keybinds = LegacyRecord.safeParse("keybinds" in data ? data.keybinds : undefined)
53
- const legacyTui = LegacyRecord.safeParse("tui" in data ? data.tui : undefined)
54
- const extracted = {
55
- theme: theme.success ? theme.data : undefined,
56
- keybinds: keybinds.success ? keybinds.data : undefined,
57
- tui: legacyTui.success ? legacyTui.data : undefined,
58
- }
59
- const tui = extracted.tui ? normalizeTui(extracted.tui) : undefined
60
- if (extracted.theme === undefined && extracted.keybinds === undefined && !tui) continue
61
-
62
- const target = path.join(path.dirname(file), "tui.json")
63
- const targetExists = await Filesystem.exists(target)
64
- if (targetExists) continue
65
-
66
- const payload: Record<string, unknown> = {
67
- $schema: TUI_SCHEMA_URL,
68
- }
69
- if (extracted.theme !== undefined) payload.theme = extracted.theme
70
- if (extracted.keybinds !== undefined) payload.keybinds = extracted.keybinds
71
- if (tui) Object.assign(payload, tui)
72
-
73
- const wrote = await Filesystem.write(target, JSON.stringify(payload, null, 2))
74
- .then(() => true)
75
- .catch((error) => {
76
- log.warn("failed to write tui migration target", { from: file, to: target, error })
77
- return false
78
- })
79
- if (!wrote) continue
80
-
81
- const stripped = await backupAndStripLegacy(file, source)
82
- if (!stripped) {
83
- log.warn("tui config migrated but source file was not stripped", { from: file, to: target })
84
- continue
85
- }
86
- log.info("migrated tui config", { from: file, to: target })
87
- }
88
- }
89
-
90
- function normalizeTui(data: Record<string, unknown>) {
91
- const parsed = TuiLegacy.parse(data)
92
- if (
93
- parsed.scroll_speed === undefined &&
94
- parsed.diff_style === undefined &&
95
- parsed.scroll_acceleration === undefined
96
- ) {
97
- return
98
- }
99
- return parsed
100
- }
101
-
102
- async function backupAndStripLegacy(file: string, source: string) {
103
- const backup = file + ".tui-migration.bak"
104
- const hasBackup = await Filesystem.exists(backup)
105
- const backed = hasBackup
106
- ? true
107
- : await Filesystem.write(backup, source)
108
- .then(() => true)
109
- .catch((error) => {
110
- log.warn("failed to backup source config during tui migration", { path: file, backup, error })
111
- return false
112
- })
113
- if (!backed) return false
114
-
115
- const text = ["theme", "keybinds", "tui"].reduce((acc, key) => {
116
- const edits = modify(acc, [key], undefined, {
117
- formattingOptions: {
118
- insertSpaces: true,
119
- tabSize: 2,
120
- },
121
- })
122
- if (!edits.length) return acc
123
- return applyEdits(acc, edits)
124
- }, source)
125
-
126
- return Filesystem.write(file, text)
127
- .then(() => {
128
- log.info("stripped tui keys from server config", { path: file, backup })
129
- return true
130
- })
131
- .catch((error) => {
132
- log.warn("failed to strip legacy tui keys from server config", { path: file, backup, error })
133
- return false
134
- })
135
- }
136
-
137
- async function opencodeFiles(input: { directories: string[]; managed: string }) {
138
- const project = Flag.OPENCODE_DISABLE_PROJECT_CONFIG
139
- ? []
140
- : await ConfigPaths.projectFiles("opencode", Instance.directory, Instance.worktree)
141
- const files = [...project, ...ConfigPaths.fileInDirectory(Global.Path.config, "opencode")]
142
- for (const dir of unique(input.directories)) {
143
- files.push(...ConfigPaths.fileInDirectory(dir, "opencode"))
144
- }
145
- if (Flag.OPENCODE_CONFIG) files.push(Flag.OPENCODE_CONFIG)
146
- files.push(...ConfigPaths.fileInDirectory(input.managed, "opencode"))
147
-
148
- const existing = await Promise.all(
149
- unique(files).map(async (file) => {
150
- const ok = await Filesystem.exists(file)
151
- return ok ? file : undefined
152
- }),
153
- )
154
- return existing.filter((file): file is string => !!file)
155
- }
@@ -1,37 +0,0 @@
1
- import z from "zod"
2
- import { Config } from "./config"
3
-
4
- const KeybindOverride = z
5
- .object(
6
- Object.fromEntries(Object.keys(Config.Keybinds.shape).map((key) => [key, z.string().optional()])) as Record<
7
- string,
8
- z.ZodOptional<z.ZodString>
9
- >,
10
- )
11
- .strict()
12
-
13
- export const TuiOptions = z.object({
14
- scroll_speed: z.number().min(0.001).optional().describe("TUI scroll speed"),
15
- scroll_acceleration: z
16
- .object({
17
- enabled: z.boolean().describe("Enable scroll acceleration"),
18
- })
19
- .optional()
20
- .describe("Scroll acceleration settings"),
21
- diff_style: z
22
- .enum(["auto", "stacked"])
23
- .optional()
24
- .describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),
25
- mouse: z.boolean().optional().describe("Enable or disable mouse capture (default: true)"),
26
- })
27
-
28
- export const TuiInfo = z
29
- .object({
30
- $schema: z.string().optional(),
31
- theme: z.string().optional(),
32
- keybinds: KeybindOverride.optional(),
33
- plugin: Config.PluginSpec.array().optional(),
34
- plugin_enabled: z.record(z.string(), z.boolean()).optional(),
35
- })
36
- .extend(TuiOptions.shape)
37
- .strict()
@@ -1,179 +0,0 @@
1
- import { existsSync } from "fs"
2
- import z from "zod"
3
- import { mergeDeep, unique } from "remeda"
4
- import { Config } from "./config"
5
- import { ConfigPaths } from "./paths"
6
- import { migrateTuiConfig } from "./tui-migrate"
7
- import { TuiInfo } from "./tui-schema"
8
- import { Instance } from "@/project/instance"
9
- import { Flag } from "@/flag/flag"
10
- import { Log } from "@/util/log"
11
- import { isRecord } from "@/util/record"
12
- import { Global } from "@/global"
13
-
14
- export namespace TuiConfig {
15
- const log = Log.create({ service: "tui.config" })
16
-
17
- export const Info = TuiInfo
18
-
19
- type Acc = {
20
- result: Info
21
- }
22
-
23
- export type Info = z.output<typeof Info> & {
24
- // Internal resolved plugin list used by runtime loading.
25
- plugin_origins?: Config.PluginOrigin[]
26
- }
27
-
28
- function pluginScope(file: string): Config.PluginScope {
29
- if (Instance.containsPath(file)) return "local"
30
- return "global"
31
- }
32
-
33
- function customPath() {
34
- return Flag.OPENCODE_TUI_CONFIG
35
- }
36
-
37
- function normalize(raw: Record<string, unknown>) {
38
- const data = { ...raw }
39
- if (!("tui" in data)) return data
40
- if (!isRecord(data.tui)) {
41
- delete data.tui
42
- return data
43
- }
44
-
45
- const tui = data.tui
46
- delete data.tui
47
- return {
48
- ...tui,
49
- ...data,
50
- }
51
- }
52
-
53
- function installDeps(dir: string): Promise<void> {
54
- return Config.installDependencies(dir)
55
- }
56
-
57
- async function mergeFile(acc: Acc, file: string) {
58
- const data = await loadFile(file)
59
- acc.result = mergeDeep(acc.result, data)
60
- if (!data.plugin?.length) return
61
-
62
- const scope = pluginScope(file)
63
- const plugins = Config.deduplicatePluginOrigins([
64
- ...(acc.result.plugin_origins ?? []),
65
- ...data.plugin.map((spec) => ({ spec, scope, source: file })),
66
- ])
67
- acc.result.plugin = plugins.map((item) => item.spec)
68
- acc.result.plugin_origins = plugins
69
- }
70
-
71
- const state = Instance.state(async () => {
72
- let projectFiles = Flag.OPENCODE_DISABLE_PROJECT_CONFIG
73
- ? []
74
- : await ConfigPaths.projectFiles("tui", Instance.directory, Instance.worktree)
75
- const directories = await ConfigPaths.directories(Instance.directory, Instance.worktree)
76
- const custom = customPath()
77
- const managed = Config.managedConfigDir()
78
- await migrateTuiConfig({ directories, custom, managed })
79
- // Re-compute after migration since migrateTuiConfig may have created new tui.json files
80
- projectFiles = Flag.OPENCODE_DISABLE_PROJECT_CONFIG
81
- ? []
82
- : await ConfigPaths.projectFiles("tui", Instance.directory, Instance.worktree)
83
-
84
- const acc: Acc = {
85
- result: {},
86
- }
87
-
88
- for (const file of ConfigPaths.fileInDirectory(Global.Path.config, "tui")) {
89
- await mergeFile(acc, file)
90
- }
91
-
92
- if (custom) {
93
- await mergeFile(acc, custom)
94
- log.debug("loaded custom tui config", { path: custom })
95
- }
96
-
97
- for (const file of projectFiles) {
98
- await mergeFile(acc, file)
99
- }
100
-
101
- for (const dir of unique(directories)) {
102
- if (!dir.endsWith(".opencode") && dir !== Flag.OPENCODE_CONFIG_DIR) continue
103
- for (const file of ConfigPaths.fileInDirectory(dir, "tui")) {
104
- await mergeFile(acc, file)
105
- }
106
- }
107
-
108
- if (existsSync(managed)) {
109
- for (const file of ConfigPaths.fileInDirectory(managed, "tui")) {
110
- await mergeFile(acc, file)
111
- }
112
- }
113
-
114
- const keybinds = { ...(acc.result.keybinds ?? {}) }
115
- if (process.platform === "win32") {
116
- // Native Windows terminals do not support POSIX suspend, so prefer prompt undo.
117
- keybinds.terminal_suspend = "none"
118
- keybinds.input_undo ??= unique(["ctrl+z", ...Config.Keybinds.shape.input_undo.parse(undefined).split(",")]).join(
119
- ",",
120
- )
121
- }
122
- acc.result.keybinds = Config.Keybinds.parse(keybinds)
123
-
124
- const deps: Promise<void>[] = []
125
- if (acc.result.plugin?.length) {
126
- for (const dir of unique(directories)) {
127
- if (!dir.endsWith(".opencode") && dir !== Flag.OPENCODE_CONFIG_DIR) continue
128
- deps.push(installDeps(dir))
129
- }
130
- }
131
-
132
- return {
133
- config: acc.result,
134
- deps,
135
- }
136
- })
137
-
138
- export async function get() {
139
- return state().then((x) => x.config)
140
- }
141
-
142
- export async function waitForDependencies() {
143
- const deps = await state().then((x) => x.deps)
144
- await Promise.all(deps)
145
- }
146
-
147
- async function loadFile(filepath: string): Promise<Info> {
148
- const text = await ConfigPaths.readFile(filepath)
149
- if (!text) return {}
150
- return load(text, filepath).catch((error) => {
151
- log.warn("failed to load tui config", { path: filepath, error })
152
- return {}
153
- })
154
- }
155
-
156
- async function load(text: string, configFilepath: string): Promise<Info> {
157
- const raw = await ConfigPaths.parseText(text, configFilepath, "empty")
158
- if (!isRecord(raw)) return {}
159
-
160
- // Flatten a nested "tui" key so users who wrote `{ "tui": { ... } }` inside tui.json
161
- // (mirroring the old opencode.json shape) still get their settings applied.
162
- const normalized = normalize(raw)
163
-
164
- const parsed = Info.safeParse(normalized)
165
- if (!parsed.success) {
166
- log.warn("invalid tui config", { path: configFilepath, issues: parsed.error.issues })
167
- return {}
168
- }
169
-
170
- const data = parsed.data
171
- if (data.plugin) {
172
- for (let i = 0; i < data.plugin.length; i++) {
173
- data.plugin[i] = await Config.resolvePluginSpec(data.plugin[i], configFilepath)
174
- }
175
- }
176
-
177
- return data
178
- }
179
- }
@@ -1,20 +0,0 @@
1
- import { lazy } from "@/util/lazy"
2
- import type { Adaptor } from "../types"
3
-
4
- const ADAPTORS: Record<string, () => Promise<Adaptor>> = {
5
- worktree: lazy(async () => (await import("./worktree")).WorktreeAdaptor),
6
- }
7
-
8
- export function getAdaptor(type: string): Promise<Adaptor> {
9
- return ADAPTORS[type]()
10
- }
11
-
12
- export function installAdaptor(type: string, adaptor: Adaptor) {
13
- // This is experimental: mostly used for testing right now, but we
14
- // will likely allow this in the future. Need to figure out the
15
- // TypeScript story
16
-
17
- // @ts-expect-error we force the builtin types right now, but we
18
- // will implement a way to extend the types for custom adaptors
19
- ADAPTORS[type] = () => adaptor
20
- }