alchemylab-opencode 1.0.7 → 1.0.9

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 (391) hide show
  1. package/dist/{chunk-B3FN2B2N.js → chunk-3PZZ2D23.js} +7 -3
  2. package/dist/chunk-3PZZ2D23.js.map +7 -0
  3. package/dist/{chunk-LU5XVQUD.js → chunk-EGZMJTLE.js} +7 -7
  4. package/dist/{chunk-LU5XVQUD.js.map → chunk-EGZMJTLE.js.map} +2 -2
  5. package/dist/{chunk-23UYOGZG.js → chunk-ORHZOVWK.js} +6 -6
  6. package/dist/{chunk-TASPMBUL.js → chunk-SV5NEV33.js} +5 -5
  7. package/dist/{chunk-SM6WZDN6.js → chunk-UKQIL5XA.js} +18 -12
  8. package/dist/chunk-UKQIL5XA.js.map +7 -0
  9. package/dist/{chunk-GSE2T5UY.js → chunk-ZFHDPNFZ.js} +4 -4
  10. package/dist/{mcp-XFGN3FWW.js → mcp-66BBNSWA.js} +3 -3
  11. package/dist/{registry-W4MBVBYD.js → registry-YVL3V6Z6.js} +4 -4
  12. package/dist/{run-73HUV4H3.js → run-65PIGE2A.js} +7 -7
  13. package/dist/{run-service-LHEVFBIU.js → run-service-AYATGPA6.js} +2 -2
  14. package/dist/run.js +1 -1
  15. package/dist/serve.js +1 -1
  16. package/dist/{server-2CPOG3LS.js → server-KCG3B4WQ.js} +7 -7
  17. package/dist/{session-M6HOZ56B.js → session-BR5MTI3X.js} +4 -4
  18. package/dist/{share-next-QRBVSD37.js → share-next-EPYQDJ32.js} +5 -5
  19. package/dist/{worktree-3GUHT2P7.js → worktree-PIVTZBUE.js} +6 -6
  20. package/package.json +2 -15
  21. package/packages/opencode/migration/20260409000000_add_session_metadata/migration.sql +1 -0
  22. package/build.mjs +0 -192
  23. package/dist/chunk-B3FN2B2N.js.map +0 -7
  24. package/dist/chunk-SM6WZDN6.js.map +0 -7
  25. package/packages/opencode/package.json +0 -138
  26. package/packages/opencode/src/account/account.sql.ts +0 -39
  27. package/packages/opencode/src/account/index.ts +0 -463
  28. package/packages/opencode/src/account/repo.ts +0 -163
  29. package/packages/opencode/src/account/schema.ts +0 -91
  30. package/packages/opencode/src/acp/README.md +0 -174
  31. package/packages/opencode/src/acp/agent.ts +0 -1847
  32. package/packages/opencode/src/acp/session.ts +0 -116
  33. package/packages/opencode/src/acp/types.ts +0 -24
  34. package/packages/opencode/src/agent/agent.ts +0 -420
  35. package/packages/opencode/src/agent/generate.txt +0 -75
  36. package/packages/opencode/src/agent/prompt/compaction.txt +0 -15
  37. package/packages/opencode/src/agent/prompt/explore.txt +0 -18
  38. package/packages/opencode/src/agent/prompt/summary.txt +0 -11
  39. package/packages/opencode/src/agent/prompt/title.txt +0 -44
  40. package/packages/opencode/src/auth/index.ts +0 -110
  41. package/packages/opencode/src/bus/bus-event.ts +0 -40
  42. package/packages/opencode/src/bus/global.ts +0 -10
  43. package/packages/opencode/src/bus/index.ts +0 -185
  44. package/packages/opencode/src/cli/bootstrap.ts +0 -17
  45. package/packages/opencode/src/cli/cmd/cmd.ts +0 -7
  46. package/packages/opencode/src/cli/cmd/run.ts +0 -689
  47. package/packages/opencode/src/cli/cmd/serve.ts +0 -24
  48. package/packages/opencode/src/cli/cmd/tui/event.ts +0 -49
  49. package/packages/opencode/src/cli/effect/prompt.ts +0 -25
  50. package/packages/opencode/src/cli/error.ts +0 -46
  51. package/packages/opencode/src/cli/heap.ts +0 -59
  52. package/packages/opencode/src/cli/logo.ts +0 -6
  53. package/packages/opencode/src/cli/network.ts +0 -60
  54. package/packages/opencode/src/cli/ui.ts +0 -133
  55. package/packages/opencode/src/cli/upgrade.ts +0 -31
  56. package/packages/opencode/src/command/index.ts +0 -195
  57. package/packages/opencode/src/command/template/initialize.txt +0 -66
  58. package/packages/opencode/src/command/template/review.txt +0 -101
  59. package/packages/opencode/src/config/config.ts +0 -1599
  60. package/packages/opencode/src/config/console-state.ts +0 -15
  61. package/packages/opencode/src/config/markdown.ts +0 -99
  62. package/packages/opencode/src/config/paths.ts +0 -167
  63. package/packages/opencode/src/config/tui-migrate.ts +0 -155
  64. package/packages/opencode/src/config/tui-schema.ts +0 -37
  65. package/packages/opencode/src/config/tui.ts +0 -179
  66. package/packages/opencode/src/control-plane/adaptors/index.ts +0 -20
  67. package/packages/opencode/src/control-plane/adaptors/worktree.ts +0 -42
  68. package/packages/opencode/src/control-plane/schema.ts +0 -17
  69. package/packages/opencode/src/control-plane/sse.ts +0 -66
  70. package/packages/opencode/src/control-plane/types.ts +0 -32
  71. package/packages/opencode/src/control-plane/workspace.sql.ts +0 -17
  72. package/packages/opencode/src/control-plane/workspace.ts +0 -168
  73. package/packages/opencode/src/effect/cross-spawn-spawner.ts +0 -502
  74. package/packages/opencode/src/effect/instance-ref.ts +0 -6
  75. package/packages/opencode/src/effect/instance-registry.ts +0 -12
  76. package/packages/opencode/src/effect/instance-state.ts +0 -82
  77. package/packages/opencode/src/effect/run-service.ts +0 -33
  78. package/packages/opencode/src/effect/runner.ts +0 -216
  79. package/packages/opencode/src/env/index.ts +0 -28
  80. package/packages/opencode/src/file/ignore.ts +0 -82
  81. package/packages/opencode/src/file/index.ts +0 -686
  82. package/packages/opencode/src/file/protected.ts +0 -59
  83. package/packages/opencode/src/file/ripgrep.ts +0 -376
  84. package/packages/opencode/src/file/time.ts +0 -133
  85. package/packages/opencode/src/file/watcher.ts +0 -173
  86. package/packages/opencode/src/filesystem/index.ts +0 -236
  87. package/packages/opencode/src/flag/flag.ts +0 -156
  88. package/packages/opencode/src/format/formatter.ts +0 -413
  89. package/packages/opencode/src/format/index.ts +0 -203
  90. package/packages/opencode/src/git/index.ts +0 -303
  91. package/packages/opencode/src/global/index.ts +0 -56
  92. package/packages/opencode/src/id/id.ts +0 -85
  93. package/packages/opencode/src/ide/index.ts +0 -74
  94. package/packages/opencode/src/installation/index.ts +0 -355
  95. package/packages/opencode/src/installation/meta.ts +0 -7
  96. package/packages/opencode/src/lsp/client.ts +0 -252
  97. package/packages/opencode/src/lsp/index.ts +0 -558
  98. package/packages/opencode/src/lsp/language.ts +0 -120
  99. package/packages/opencode/src/lsp/launch.ts +0 -21
  100. package/packages/opencode/src/lsp/server.ts +0 -1968
  101. package/packages/opencode/src/mcp/auth.ts +0 -173
  102. package/packages/opencode/src/mcp/index.ts +0 -931
  103. package/packages/opencode/src/mcp/oauth-callback.ts +0 -216
  104. package/packages/opencode/src/mcp/oauth-provider.ts +0 -185
  105. package/packages/opencode/src/node-loader.mjs +0 -104
  106. package/packages/opencode/src/node-preload.mjs +0 -39
  107. package/packages/opencode/src/node.ts +0 -1
  108. package/packages/opencode/src/npm/index.ts +0 -188
  109. package/packages/opencode/src/patch/index.ts +0 -680
  110. package/packages/opencode/src/permission/arity.ts +0 -163
  111. package/packages/opencode/src/permission/evaluate.ts +0 -15
  112. package/packages/opencode/src/permission/index.ts +0 -325
  113. package/packages/opencode/src/permission/schema.ts +0 -17
  114. package/packages/opencode/src/plugin/cloudflare.ts +0 -67
  115. package/packages/opencode/src/plugin/codex.ts +0 -608
  116. package/packages/opencode/src/plugin/github-copilot/copilot.ts +0 -361
  117. package/packages/opencode/src/plugin/github-copilot/models.ts +0 -144
  118. package/packages/opencode/src/plugin/index.ts +0 -299
  119. package/packages/opencode/src/plugin/install.ts +0 -439
  120. package/packages/opencode/src/plugin/loader.ts +0 -174
  121. package/packages/opencode/src/plugin/meta.ts +0 -188
  122. package/packages/opencode/src/plugin/shared.ts +0 -323
  123. package/packages/opencode/src/project/bootstrap.ts +0 -31
  124. package/packages/opencode/src/project/instance.ts +0 -175
  125. package/packages/opencode/src/project/project.sql.ts +0 -16
  126. package/packages/opencode/src/project/project.ts +0 -519
  127. package/packages/opencode/src/project/schema.ts +0 -16
  128. package/packages/opencode/src/project/state.ts +0 -70
  129. package/packages/opencode/src/project/vcs.ts +0 -240
  130. package/packages/opencode/src/provider/auth.ts +0 -253
  131. package/packages/opencode/src/provider/error.ts +0 -197
  132. package/packages/opencode/src/provider/models.ts +0 -162
  133. package/packages/opencode/src/provider/provider.ts +0 -1709
  134. package/packages/opencode/src/provider/schema.ts +0 -38
  135. package/packages/opencode/src/provider/sdk/copilot/README.md +0 -5
  136. package/packages/opencode/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +0 -170
  137. package/packages/opencode/src/provider/sdk/copilot/chat/get-response-metadata.ts +0 -15
  138. package/packages/opencode/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +0 -19
  139. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +0 -64
  140. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +0 -815
  141. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +0 -28
  142. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +0 -44
  143. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +0 -83
  144. package/packages/opencode/src/provider/sdk/copilot/copilot-provider.ts +0 -100
  145. package/packages/opencode/src/provider/sdk/copilot/index.ts +0 -2
  146. package/packages/opencode/src/provider/sdk/copilot/openai-compatible-error.ts +0 -27
  147. package/packages/opencode/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +0 -335
  148. package/packages/opencode/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +0 -22
  149. package/packages/opencode/src/provider/sdk/copilot/responses/openai-config.ts +0 -18
  150. package/packages/opencode/src/provider/sdk/copilot/responses/openai-error.ts +0 -22
  151. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +0 -214
  152. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +0 -1769
  153. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +0 -173
  154. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-settings.ts +0 -1
  155. package/packages/opencode/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +0 -87
  156. package/packages/opencode/src/provider/sdk/copilot/responses/tool/file-search.ts +0 -127
  157. package/packages/opencode/src/provider/sdk/copilot/responses/tool/image-generation.ts +0 -114
  158. package/packages/opencode/src/provider/sdk/copilot/responses/tool/local-shell.ts +0 -64
  159. package/packages/opencode/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +0 -103
  160. package/packages/opencode/src/provider/sdk/copilot/responses/tool/web-search.ts +0 -102
  161. package/packages/opencode/src/provider/transform.ts +0 -1050
  162. package/packages/opencode/src/pty/index.ts +0 -397
  163. package/packages/opencode/src/pty/pty.node.ts +0 -27
  164. package/packages/opencode/src/pty/pty.ts +0 -25
  165. package/packages/opencode/src/pty/schema.ts +0 -17
  166. package/packages/opencode/src/question/index.ts +0 -224
  167. package/packages/opencode/src/question/schema.ts +0 -17
  168. package/packages/opencode/src/run.ts +0 -28
  169. package/packages/opencode/src/serve.ts +0 -45
  170. package/packages/opencode/src/server/error.ts +0 -36
  171. package/packages/opencode/src/server/event.ts +0 -7
  172. package/packages/opencode/src/server/instance.ts +0 -324
  173. package/packages/opencode/src/server/mdns.ts +0 -60
  174. package/packages/opencode/src/server/middleware.ts +0 -33
  175. package/packages/opencode/src/server/projectors.ts +0 -28
  176. package/packages/opencode/src/server/proxy.ts +0 -131
  177. package/packages/opencode/src/server/router.ts +0 -105
  178. package/packages/opencode/src/server/routes/config.ts +0 -92
  179. package/packages/opencode/src/server/routes/event.ts +0 -83
  180. package/packages/opencode/src/server/routes/experimental.ts +0 -374
  181. package/packages/opencode/src/server/routes/file.ts +0 -197
  182. package/packages/opencode/src/server/routes/global.ts +0 -312
  183. package/packages/opencode/src/server/routes/mcp.ts +0 -225
  184. package/packages/opencode/src/server/routes/permission.ts +0 -69
  185. package/packages/opencode/src/server/routes/project.ts +0 -118
  186. package/packages/opencode/src/server/routes/provider.ts +0 -171
  187. package/packages/opencode/src/server/routes/pty.ts +0 -210
  188. package/packages/opencode/src/server/routes/question.ts +0 -99
  189. package/packages/opencode/src/server/routes/session.ts +0 -1030
  190. package/packages/opencode/src/server/routes/tui.ts +0 -379
  191. package/packages/opencode/src/server/routes/workspace.ts +0 -94
  192. package/packages/opencode/src/server/server.ts +0 -353
  193. package/packages/opencode/src/session/compaction.ts +0 -428
  194. package/packages/opencode/src/session/index.ts +0 -887
  195. package/packages/opencode/src/session/instruction.ts +0 -258
  196. package/packages/opencode/src/session/llm.ts +0 -354
  197. package/packages/opencode/src/session/message-v2.ts +0 -1031
  198. package/packages/opencode/src/session/message.ts +0 -191
  199. package/packages/opencode/src/session/overflow.ts +0 -22
  200. package/packages/opencode/src/session/processor.ts +0 -523
  201. package/packages/opencode/src/session/projectors.ts +0 -135
  202. package/packages/opencode/src/session/prompt/anthropic.txt +0 -105
  203. package/packages/opencode/src/session/prompt/beast.txt +0 -147
  204. package/packages/opencode/src/session/prompt/build-switch.txt +0 -5
  205. package/packages/opencode/src/session/prompt/codex.txt +0 -79
  206. package/packages/opencode/src/session/prompt/copilot-gpt-5.txt +0 -143
  207. package/packages/opencode/src/session/prompt/default.txt +0 -105
  208. package/packages/opencode/src/session/prompt/gemini.txt +0 -155
  209. package/packages/opencode/src/session/prompt/gpt.txt +0 -107
  210. package/packages/opencode/src/session/prompt/kimi.txt +0 -95
  211. package/packages/opencode/src/session/prompt/max-steps.txt +0 -16
  212. package/packages/opencode/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  213. package/packages/opencode/src/session/prompt/plan.txt +0 -26
  214. package/packages/opencode/src/session/prompt/trinity.txt +0 -97
  215. package/packages/opencode/src/session/prompt.ts +0 -1911
  216. package/packages/opencode/src/session/retry.ts +0 -106
  217. package/packages/opencode/src/session/revert.ts +0 -176
  218. package/packages/opencode/src/session/schema.ts +0 -38
  219. package/packages/opencode/src/session/session.sql.ts +0 -103
  220. package/packages/opencode/src/session/status.ts +0 -102
  221. package/packages/opencode/src/session/summary.ts +0 -177
  222. package/packages/opencode/src/session/system.ts +0 -76
  223. package/packages/opencode/src/session/todo.ts +0 -95
  224. package/packages/opencode/src/share/share-next.ts +0 -369
  225. package/packages/opencode/src/share/share.sql.ts +0 -13
  226. package/packages/opencode/src/shell/shell.ts +0 -110
  227. package/packages/opencode/src/skill/discovery.ts +0 -116
  228. package/packages/opencode/src/skill/index.ts +0 -277
  229. package/packages/opencode/src/snapshot/index.ts +0 -726
  230. package/packages/opencode/src/sql.d.ts +0 -4
  231. package/packages/opencode/src/storage/db.node.ts +0 -8
  232. package/packages/opencode/src/storage/db.ts +0 -177
  233. package/packages/opencode/src/storage/json-migration.ts +0 -425
  234. package/packages/opencode/src/storage/schema.sql.ts +0 -10
  235. package/packages/opencode/src/storage/schema.ts +0 -5
  236. package/packages/opencode/src/storage/storage.ts +0 -353
  237. package/packages/opencode/src/sync/README.md +0 -179
  238. package/packages/opencode/src/sync/event.sql.ts +0 -16
  239. package/packages/opencode/src/sync/index.ts +0 -263
  240. package/packages/opencode/src/sync/schema.ts +0 -14
  241. package/packages/opencode/src/tool/apply_patch.ts +0 -281
  242. package/packages/opencode/src/tool/apply_patch.txt +0 -33
  243. package/packages/opencode/src/tool/bash.ts +0 -496
  244. package/packages/opencode/src/tool/bash.txt +0 -117
  245. package/packages/opencode/src/tool/batch.ts +0 -183
  246. package/packages/opencode/src/tool/batch.txt +0 -24
  247. package/packages/opencode/src/tool/codesearch.ts +0 -132
  248. package/packages/opencode/src/tool/codesearch.txt +0 -12
  249. package/packages/opencode/src/tool/edit.ts +0 -667
  250. package/packages/opencode/src/tool/edit.txt +0 -10
  251. package/packages/opencode/src/tool/external-directory.ts +0 -46
  252. package/packages/opencode/src/tool/glob.ts +0 -78
  253. package/packages/opencode/src/tool/glob.txt +0 -6
  254. package/packages/opencode/src/tool/grep.ts +0 -156
  255. package/packages/opencode/src/tool/grep.txt +0 -8
  256. package/packages/opencode/src/tool/invalid.ts +0 -17
  257. package/packages/opencode/src/tool/ls.ts +0 -121
  258. package/packages/opencode/src/tool/ls.txt +0 -1
  259. package/packages/opencode/src/tool/lsp.ts +0 -97
  260. package/packages/opencode/src/tool/lsp.txt +0 -19
  261. package/packages/opencode/src/tool/multiedit.ts +0 -46
  262. package/packages/opencode/src/tool/multiedit.txt +0 -41
  263. package/packages/opencode/src/tool/plan-enter.txt +0 -14
  264. package/packages/opencode/src/tool/plan-exit.txt +0 -13
  265. package/packages/opencode/src/tool/plan.ts +0 -131
  266. package/packages/opencode/src/tool/question.ts +0 -46
  267. package/packages/opencode/src/tool/question.txt +0 -10
  268. package/packages/opencode/src/tool/read.ts +0 -332
  269. package/packages/opencode/src/tool/read.txt +0 -14
  270. package/packages/opencode/src/tool/registry.ts +0 -265
  271. package/packages/opencode/src/tool/schema.ts +0 -17
  272. package/packages/opencode/src/tool/skill.ts +0 -105
  273. package/packages/opencode/src/tool/task.ts +0 -166
  274. package/packages/opencode/src/tool/task.txt +0 -60
  275. package/packages/opencode/src/tool/todo.ts +0 -48
  276. package/packages/opencode/src/tool/todowrite.txt +0 -167
  277. package/packages/opencode/src/tool/tool.ts +0 -112
  278. package/packages/opencode/src/tool/truncate.ts +0 -144
  279. package/packages/opencode/src/tool/truncation-dir.ts +0 -4
  280. package/packages/opencode/src/tool/webfetch.ts +0 -206
  281. package/packages/opencode/src/tool/webfetch.txt +0 -13
  282. package/packages/opencode/src/tool/websearch.ts +0 -150
  283. package/packages/opencode/src/tool/websearch.txt +0 -14
  284. package/packages/opencode/src/tool/write.ts +0 -84
  285. package/packages/opencode/src/tool/write.txt +0 -8
  286. package/packages/opencode/src/util/abort.ts +0 -35
  287. package/packages/opencode/src/util/archive.ts +0 -17
  288. package/packages/opencode/src/util/color.ts +0 -19
  289. package/packages/opencode/src/util/context.ts +0 -25
  290. package/packages/opencode/src/util/data-url.ts +0 -9
  291. package/packages/opencode/src/util/defer.ts +0 -12
  292. package/packages/opencode/src/util/effect-http-client.ts +0 -11
  293. package/packages/opencode/src/util/effect-zod.ts +0 -98
  294. package/packages/opencode/src/util/error.ts +0 -77
  295. package/packages/opencode/src/util/filesystem.ts +0 -245
  296. package/packages/opencode/src/util/flock.ts +0 -333
  297. package/packages/opencode/src/util/fn.ts +0 -21
  298. package/packages/opencode/src/util/format.ts +0 -20
  299. package/packages/opencode/src/util/glob.ts +0 -34
  300. package/packages/opencode/src/util/hash.ts +0 -7
  301. package/packages/opencode/src/util/iife.ts +0 -3
  302. package/packages/opencode/src/util/keybind.ts +0 -103
  303. package/packages/opencode/src/util/lazy.ts +0 -23
  304. package/packages/opencode/src/util/locale.ts +0 -81
  305. package/packages/opencode/src/util/lock.ts +0 -98
  306. package/packages/opencode/src/util/log.ts +0 -182
  307. package/packages/opencode/src/util/network.ts +0 -9
  308. package/packages/opencode/src/util/process.ts +0 -176
  309. package/packages/opencode/src/util/queue.ts +0 -32
  310. package/packages/opencode/src/util/record.ts +0 -3
  311. package/packages/opencode/src/util/rpc.ts +0 -66
  312. package/packages/opencode/src/util/schema.ts +0 -53
  313. package/packages/opencode/src/util/scrap.ts +0 -10
  314. package/packages/opencode/src/util/signal.ts +0 -12
  315. package/packages/opencode/src/util/timeout.ts +0 -14
  316. package/packages/opencode/src/util/token.ts +0 -7
  317. package/packages/opencode/src/util/update-schema.ts +0 -13
  318. package/packages/opencode/src/util/which.ts +0 -14
  319. package/packages/opencode/src/util/wildcard.ts +0 -59
  320. package/packages/opencode/src/worktree/index.ts +0 -612
  321. package/packages/plugin/package.json +0 -38
  322. package/packages/plugin/src/example.ts +0 -18
  323. package/packages/plugin/src/index.ts +0 -282
  324. package/packages/plugin/src/shell.ts +0 -136
  325. package/packages/plugin/src/tool.ts +0 -38
  326. package/packages/plugin/src/tui.ts +0 -508
  327. package/packages/script/package.json +0 -16
  328. package/packages/script/src/index.ts +0 -77
  329. package/packages/sdk/package.json +0 -33
  330. package/packages/sdk/src/client.ts +0 -55
  331. package/packages/sdk/src/gen/client/client.gen.ts +0 -212
  332. package/packages/sdk/src/gen/client/index.ts +0 -25
  333. package/packages/sdk/src/gen/client/types.gen.ts +0 -222
  334. package/packages/sdk/src/gen/client/utils.gen.ts +0 -287
  335. package/packages/sdk/src/gen/client.gen.ts +0 -22
  336. package/packages/sdk/src/gen/core/auth.gen.ts +0 -41
  337. package/packages/sdk/src/gen/core/bodySerializer.gen.ts +0 -74
  338. package/packages/sdk/src/gen/core/params.gen.ts +0 -144
  339. package/packages/sdk/src/gen/core/pathSerializer.gen.ts +0 -167
  340. package/packages/sdk/src/gen/core/queryKeySerializer.gen.ts +0 -111
  341. package/packages/sdk/src/gen/core/serverSentEvents.gen.ts +0 -210
  342. package/packages/sdk/src/gen/core/types.gen.ts +0 -91
  343. package/packages/sdk/src/gen/core/utils.gen.ts +0 -109
  344. package/packages/sdk/src/gen/sdk.gen.ts +0 -1197
  345. package/packages/sdk/src/gen/types.gen.ts +0 -3904
  346. package/packages/sdk/src/index.ts +0 -21
  347. package/packages/sdk/src/process.ts +0 -31
  348. package/packages/sdk/src/server.ts +0 -134
  349. package/packages/sdk/src/v2/client.ts +0 -81
  350. package/packages/sdk/src/v2/gen/client/client.gen.ts +0 -285
  351. package/packages/sdk/src/v2/gen/client/index.ts +0 -25
  352. package/packages/sdk/src/v2/gen/client/types.gen.ts +0 -202
  353. package/packages/sdk/src/v2/gen/client/utils.gen.ts +0 -289
  354. package/packages/sdk/src/v2/gen/client.gen.ts +0 -18
  355. package/packages/sdk/src/v2/gen/core/auth.gen.ts +0 -41
  356. package/packages/sdk/src/v2/gen/core/bodySerializer.gen.ts +0 -82
  357. package/packages/sdk/src/v2/gen/core/params.gen.ts +0 -169
  358. package/packages/sdk/src/v2/gen/core/pathSerializer.gen.ts +0 -167
  359. package/packages/sdk/src/v2/gen/core/queryKeySerializer.gen.ts +0 -111
  360. package/packages/sdk/src/v2/gen/core/serverSentEvents.gen.ts +0 -239
  361. package/packages/sdk/src/v2/gen/core/types.gen.ts +0 -86
  362. package/packages/sdk/src/v2/gen/core/utils.gen.ts +0 -137
  363. package/packages/sdk/src/v2/gen/sdk.gen.ts +0 -4223
  364. package/packages/sdk/src/v2/gen/types.gen.ts +0 -5265
  365. package/packages/sdk/src/v2/index.ts +0 -21
  366. package/packages/sdk/src/v2/server.ts +0 -134
  367. package/packages/util/package.json +0 -20
  368. package/packages/util/src/array.ts +0 -10
  369. package/packages/util/src/binary.ts +0 -41
  370. package/packages/util/src/encode.ts +0 -51
  371. package/packages/util/src/error.ts +0 -54
  372. package/packages/util/src/fn.ts +0 -11
  373. package/packages/util/src/identifier.ts +0 -48
  374. package/packages/util/src/iife.ts +0 -3
  375. package/packages/util/src/lazy.ts +0 -11
  376. package/packages/util/src/module.ts +0 -10
  377. package/packages/util/src/path.ts +0 -37
  378. package/packages/util/src/retry.ts +0 -41
  379. package/packages/util/src/slug.ts +0 -74
  380. package/postinstall.cjs +0 -55
  381. /package/dist/{chunk-23UYOGZG.js.map → chunk-ORHZOVWK.js.map} +0 -0
  382. /package/dist/{chunk-TASPMBUL.js.map → chunk-SV5NEV33.js.map} +0 -0
  383. /package/dist/{chunk-GSE2T5UY.js.map → chunk-ZFHDPNFZ.js.map} +0 -0
  384. /package/dist/{mcp-XFGN3FWW.js.map → mcp-66BBNSWA.js.map} +0 -0
  385. /package/dist/{registry-W4MBVBYD.js.map → registry-YVL3V6Z6.js.map} +0 -0
  386. /package/dist/{run-73HUV4H3.js.map → run-65PIGE2A.js.map} +0 -0
  387. /package/dist/{run-service-LHEVFBIU.js.map → run-service-AYATGPA6.js.map} +0 -0
  388. /package/dist/{server-2CPOG3LS.js.map → server-KCG3B4WQ.js.map} +0 -0
  389. /package/dist/{session-M6HOZ56B.js.map → session-BR5MTI3X.js.map} +0 -0
  390. /package/dist/{share-next-QRBVSD37.js.map → share-next-EPYQDJ32.js.map} +0 -0
  391. /package/dist/{worktree-3GUHT2P7.js.map → worktree-PIVTZBUE.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
- }