soraacode 0.1.7 → 0.2.1

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 (352) hide show
  1. package/LICENSE +21 -0
  2. package/bin/soraacode.exe +10 -0
  3. package/package.json +17 -114
  4. package/{script/postinstall.mjs → postinstall.mjs} +5 -5
  5. package/AGENTS.md +0 -131
  6. package/Dockerfile +0 -18
  7. package/README.md +0 -15
  8. package/bin/opencode +0 -199
  9. package/bin/soraacode +0 -199
  10. package/bunfig.toml +0 -7
  11. package/git +0 -0
  12. package/migration/20260511173437_session-metadata/migration.sql +0 -1
  13. package/migration/20260511173437_session-metadata/snapshot.json +0 -1500
  14. package/parsers-config.ts +0 -1
  15. package/script/bench-search.ts +0 -94
  16. package/script/bench-test-suite.ts +0 -52
  17. package/script/build-headless.ts +0 -51
  18. package/script/build.ts +0 -245
  19. package/script/generate.ts +0 -14
  20. package/script/httpapi-exercise.ts +0 -1
  21. package/script/profile-test-files.ts +0 -42
  22. package/script/publish.ts +0 -213
  23. package/script/run-workspace-server +0 -106
  24. package/script/schema.ts +0 -77
  25. package/script/time.ts +0 -6
  26. package/script/trace-imports.ts +0 -153
  27. package/specs/effect/error-boundaries-plan.md +0 -235
  28. package/specs/effect/errors.md +0 -207
  29. package/specs/effect/facades.md +0 -218
  30. package/specs/effect/guide.md +0 -247
  31. package/specs/effect/instance-context.md +0 -13
  32. package/specs/effect/loose-ends.md +0 -30
  33. package/specs/effect/migration.md +0 -62
  34. package/specs/effect/routes.md +0 -61
  35. package/specs/effect/schema.md +0 -88
  36. package/specs/effect/server-package.md +0 -58
  37. package/specs/effect/todo.md +0 -241
  38. package/specs/effect/tools.md +0 -88
  39. package/specs/openapi-translation-cleanup.md +0 -204
  40. package/specs/tui-plugins.md +0 -544
  41. package/specs/v2/api.ts +0 -67
  42. package/specs/v2/message-shape.md +0 -136
  43. package/specs/v2/notifications.md +0 -13
  44. package/specs/v2/tui-command-shim.md +0 -67
  45. package/src/account/account.ts +0 -481
  46. package/src/account/repo.ts +0 -171
  47. package/src/account/schema.ts +0 -99
  48. package/src/account/url.ts +0 -8
  49. package/src/acp/agent.ts +0 -95
  50. package/src/acp/config-option.ts +0 -206
  51. package/src/acp/content.ts +0 -269
  52. package/src/acp/directory.ts +0 -212
  53. package/src/acp/error.ts +0 -97
  54. package/src/acp/event.ts +0 -421
  55. package/src/acp/permission.ts +0 -254
  56. package/src/acp/profile.ts +0 -42
  57. package/src/acp/service.ts +0 -1226
  58. package/src/acp/session.ts +0 -232
  59. package/src/acp/tool.ts +0 -364
  60. package/src/acp/usage.ts +0 -243
  61. package/src/agent/agent.ts +0 -450
  62. package/src/agent/generate.txt +0 -75
  63. package/src/agent/prompt/compaction.txt +0 -5
  64. package/src/agent/prompt/explore.txt +0 -18
  65. package/src/agent/prompt/summary.txt +0 -11
  66. package/src/agent/prompt/title.txt +0 -44
  67. package/src/agent/subagent-permissions.ts +0 -27
  68. package/src/audio.d.ts +0 -14
  69. package/src/auth/index.ts +0 -97
  70. package/src/background/job.ts +0 -37
  71. package/src/bus/global.ts +0 -22
  72. package/src/cli/bootstrap.ts +0 -11
  73. package/src/cli/cmd/cmd.ts +0 -7
  74. package/src/cli/cmd/serve.ts +0 -24
  75. package/src/cli/effect/prompt.ts +0 -37
  76. package/src/cli/effect-cmd.ts +0 -96
  77. package/src/cli/error.ts +0 -130
  78. package/src/cli/heap.ts +0 -45
  79. package/src/cli/logo.ts +0 -2
  80. package/src/cli/network.ts +0 -80
  81. package/src/cli/ui.ts +0 -132
  82. package/src/command/index.ts +0 -177
  83. package/src/command/template/initialize.txt +0 -66
  84. package/src/command/template/review.txt +0 -101
  85. package/src/config/agent.ts +0 -59
  86. package/src/config/command.ts +0 -39
  87. package/src/config/config.ts +0 -707
  88. package/src/config/entry-name.ts +0 -19
  89. package/src/config/managed.ts +0 -69
  90. package/src/config/markdown.ts +0 -36
  91. package/src/config/parse.ts +0 -61
  92. package/src/config/paths.ts +0 -45
  93. package/src/config/plugin.ts +0 -79
  94. package/src/config/v2-compat.ts +0 -449
  95. package/src/config/variable.ts +0 -91
  96. package/src/control-plane/adapters/index.ts +0 -41
  97. package/src/control-plane/adapters/worktree.ts +0 -96
  98. package/src/control-plane/dev/README.md +0 -19
  99. package/src/control-plane/dev/debug-workspace-plugin.ts +0 -73
  100. package/src/control-plane/types.ts +0 -59
  101. package/src/control-plane/util.ts +0 -39
  102. package/src/control-plane/workspace-adapter-runtime.ts +0 -51
  103. package/src/control-plane/workspace-context.ts +0 -26
  104. package/src/control-plane/workspace.ts +0 -966
  105. package/src/effect/app-node-builder-v1.ts +0 -12
  106. package/src/effect/app-runtime.ts +0 -135
  107. package/src/effect/bootstrap-runtime.ts +0 -19
  108. package/src/effect/bridge.ts +0 -84
  109. package/src/effect/config-service.ts +0 -67
  110. package/src/effect/instance-ref.ts +0 -11
  111. package/src/effect/instance-registry.ts +0 -12
  112. package/src/effect/instance-state.ts +0 -69
  113. package/src/effect/promise.ts +0 -17
  114. package/src/effect/run-service.ts +0 -47
  115. package/src/effect/runner.ts +0 -217
  116. package/src/effect/runtime-flags.ts +0 -78
  117. package/src/env/index.ts +0 -41
  118. package/src/event-manifest.ts +0 -3
  119. package/src/event-v2-bridge.ts +0 -71
  120. package/src/format/formatter.ts +0 -404
  121. package/src/format/index.ts +0 -203
  122. package/src/git/index.ts +0 -348
  123. package/src/id/id.ts +0 -80
  124. package/src/ide/index.ts +0 -54
  125. package/src/image/image.ts +0 -172
  126. package/src/index-headless.ts +0 -89
  127. package/src/index.ts +0 -93
  128. package/src/installation/index.ts +0 -336
  129. package/src/lsp/client.ts +0 -650
  130. package/src/lsp/diagnostic.ts +0 -29
  131. package/src/lsp/language.ts +0 -121
  132. package/src/lsp/launch.ts +0 -21
  133. package/src/lsp/lsp.ts +0 -507
  134. package/src/lsp/server.ts +0 -1983
  135. package/src/markdown.d.ts +0 -4
  136. package/src/mcp/auth.ts +0 -163
  137. package/src/mcp/browser.ts +0 -37
  138. package/src/mcp/catalog.ts +0 -170
  139. package/src/mcp/index.ts +0 -1004
  140. package/src/mcp/oauth-callback.ts +0 -194
  141. package/src/mcp/oauth-provider.ts +0 -259
  142. package/src/node.ts +0 -4
  143. package/src/patch/index.ts +0 -686
  144. package/src/permission/arity.ts +0 -163
  145. package/src/permission/evaluate.ts +0 -1
  146. package/src/permission/index.ts +0 -223
  147. package/src/plugin/github-copilot/copilot.ts +0 -415
  148. package/src/plugin/github-copilot/models.ts +0 -261
  149. package/src/plugin/index.ts +0 -298
  150. package/src/plugin/install.ts +0 -439
  151. package/src/plugin/loader.ts +0 -237
  152. package/src/plugin/meta.ts +0 -188
  153. package/src/plugin/openai/README.md +0 -31
  154. package/src/plugin/openai/codex.ts +0 -575
  155. package/src/plugin/openai/ws-pool.ts +0 -271
  156. package/src/plugin/openai/ws.ts +0 -383
  157. package/src/plugin/pty-environment.ts +0 -24
  158. package/src/plugin/shared.ts +0 -323
  159. package/src/project/bootstrap-service.ts +0 -9
  160. package/src/project/bootstrap.ts +0 -58
  161. package/src/project/instance-context.ts +0 -24
  162. package/src/project/instance-runtime.ts +0 -16
  163. package/src/project/instance-store.ts +0 -213
  164. package/src/project/project.ts +0 -483
  165. package/src/project/vcs.ts +0 -423
  166. package/src/provider/auth.ts +0 -229
  167. package/src/provider/error.ts +0 -195
  168. package/src/provider/model-status.ts +0 -8
  169. package/src/provider/provider.ts +0 -1955
  170. package/src/provider/transform.ts +0 -1923
  171. package/src/question/index.ts +0 -161
  172. package/src/question/schema.ts +0 -4
  173. package/src/server/auth.ts +0 -48
  174. package/src/server/event.ts +0 -10
  175. package/src/server/global-lifecycle.ts +0 -28
  176. package/src/server/mdns.ts +0 -47
  177. package/src/server/proxy-util.ts +0 -48
  178. package/src/server/routes/instance/httpapi/AGENTS.md +0 -39
  179. package/src/server/routes/instance/httpapi/api.ts +0 -97
  180. package/src/server/routes/instance/httpapi/errors.ts +0 -193
  181. package/src/server/routes/instance/httpapi/groups/config.ts +0 -65
  182. package/src/server/routes/instance/httpapi/groups/control-plane.ts +0 -35
  183. package/src/server/routes/instance/httpapi/groups/control.ts +0 -76
  184. package/src/server/routes/instance/httpapi/groups/event.ts +0 -29
  185. package/src/server/routes/instance/httpapi/groups/experimental.ts +0 -275
  186. package/src/server/routes/instance/httpapi/groups/file.ts +0 -185
  187. package/src/server/routes/instance/httpapi/groups/global.ts +0 -139
  188. package/src/server/routes/instance/httpapi/groups/instance.ts +0 -206
  189. package/src/server/routes/instance/httpapi/groups/mcp.ts +0 -156
  190. package/src/server/routes/instance/httpapi/groups/metadata.ts +0 -18
  191. package/src/server/routes/instance/httpapi/groups/permission.ts +0 -61
  192. package/src/server/routes/instance/httpapi/groups/project-copy.ts +0 -32
  193. package/src/server/routes/instance/httpapi/groups/project.ts +0 -93
  194. package/src/server/routes/instance/httpapi/groups/provider.ts +0 -101
  195. package/src/server/routes/instance/httpapi/groups/pty.ts +0 -172
  196. package/src/server/routes/instance/httpapi/groups/query.ts +0 -12
  197. package/src/server/routes/instance/httpapi/groups/question.ts +0 -74
  198. package/src/server/routes/instance/httpapi/groups/session.ts +0 -462
  199. package/src/server/routes/instance/httpapi/groups/sync.ts +0 -113
  200. package/src/server/routes/instance/httpapi/groups/tui.ts +0 -208
  201. package/src/server/routes/instance/httpapi/groups/workspace.ts +0 -141
  202. package/src/server/routes/instance/httpapi/handlers/config.ts +0 -34
  203. package/src/server/routes/instance/httpapi/handlers/control-plane.ts +0 -37
  204. package/src/server/routes/instance/httpapi/handlers/control.ts +0 -43
  205. package/src/server/routes/instance/httpapi/handlers/event.ts +0 -99
  206. package/src/server/routes/instance/httpapi/handlers/experimental.ts +0 -193
  207. package/src/server/routes/instance/httpapi/handlers/file.ts +0 -139
  208. package/src/server/routes/instance/httpapi/handlers/global.ts +0 -126
  209. package/src/server/routes/instance/httpapi/handlers/instance.ts +0 -110
  210. package/src/server/routes/instance/httpapi/handlers/mcp.ts +0 -111
  211. package/src/server/routes/instance/httpapi/handlers/permission.ts +0 -41
  212. package/src/server/routes/instance/httpapi/handlers/project-copy.ts +0 -83
  213. package/src/server/routes/instance/httpapi/handlers/project.ts +0 -63
  214. package/src/server/routes/instance/httpapi/handlers/provider.ts +0 -116
  215. package/src/server/routes/instance/httpapi/handlers/pty.ts +0 -273
  216. package/src/server/routes/instance/httpapi/handlers/question.ts +0 -54
  217. package/src/server/routes/instance/httpapi/handlers/session-errors.ts +0 -21
  218. package/src/server/routes/instance/httpapi/handlers/session.ts +0 -442
  219. package/src/server/routes/instance/httpapi/handlers/sync.ts +0 -89
  220. package/src/server/routes/instance/httpapi/handlers/tui.ts +0 -131
  221. package/src/server/routes/instance/httpapi/handlers/workspace.ts +0 -102
  222. package/src/server/routes/instance/httpapi/lifecycle.ts +0 -54
  223. package/src/server/routes/instance/httpapi/middleware/authorization.ts +0 -150
  224. package/src/server/routes/instance/httpapi/middleware/compression.ts +0 -64
  225. package/src/server/routes/instance/httpapi/middleware/cors-vary.ts +0 -29
  226. package/src/server/routes/instance/httpapi/middleware/error.ts +0 -44
  227. package/src/server/routes/instance/httpapi/middleware/fence.ts +0 -25
  228. package/src/server/routes/instance/httpapi/middleware/instance-context.ts +0 -43
  229. package/src/server/routes/instance/httpapi/middleware/proxy.ts +0 -131
  230. package/src/server/routes/instance/httpapi/middleware/schema-error.ts +0 -41
  231. package/src/server/routes/instance/httpapi/middleware/workspace-routing.ts +0 -250
  232. package/src/server/routes/instance/httpapi/public.ts +0 -537
  233. package/src/server/routes/instance/httpapi/server.ts +0 -325
  234. package/src/server/routes/instance/httpapi/websocket-tracker.ts +0 -60
  235. package/src/server/server.ts +0 -224
  236. package/src/server/shared/fence.ts +0 -60
  237. package/src/server/shared/pty-ticket.ts +0 -15
  238. package/src/server/shared/public-ui.ts +0 -12
  239. package/src/server/shared/tui-control.ts +0 -28
  240. package/src/server/shared/ui.ts +0 -108
  241. package/src/server/shared/workspace-routing.ts +0 -45
  242. package/src/server/tui-event.ts +0 -1
  243. package/src/session/compaction.ts +0 -608
  244. package/src/session/instruction.ts +0 -237
  245. package/src/session/llm/AGENTS.md +0 -90
  246. package/src/session/llm/ai-sdk.ts +0 -291
  247. package/src/session/llm/native-request.ts +0 -196
  248. package/src/session/llm/native-runtime.ts +0 -195
  249. package/src/session/llm/request.ts +0 -226
  250. package/src/session/llm.ts +0 -390
  251. package/src/session/message-error.ts +0 -14
  252. package/src/session/message-v2.ts +0 -742
  253. package/src/session/message.ts +0 -148
  254. package/src/session/overflow.ts +0 -34
  255. package/src/session/processor.ts +0 -732
  256. package/src/session/prompt/build-switch.txt +0 -5
  257. package/src/session/prompt/default.txt +0 -35
  258. package/src/session/prompt/plan-mode.txt +0 -70
  259. package/src/session/prompt/plan.txt +0 -26
  260. package/src/session/prompt.ts +0 -1631
  261. package/src/session/reminders.ts +0 -92
  262. package/src/session/retry.ts +0 -209
  263. package/src/session/revert.ts +0 -136
  264. package/src/session/run-state.ts +0 -151
  265. package/src/session/schema.ts +0 -26
  266. package/src/session/session.ts +0 -1016
  267. package/src/session/status.ts +0 -56
  268. package/src/session/summary.ts +0 -160
  269. package/src/session/system.ts +0 -123
  270. package/src/session/todo.ts +0 -74
  271. package/src/session/tools.ts +0 -590
  272. package/src/share/session.ts +0 -58
  273. package/src/share/share-next.ts +0 -371
  274. package/src/skill/discovery.ts +0 -140
  275. package/src/skill/index.ts +0 -354
  276. package/src/snapshot/index.ts +0 -807
  277. package/src/sql.d.ts +0 -4
  278. package/src/storage/schema.ts +0 -5
  279. package/src/storage/storage.ts +0 -327
  280. package/src/sync/README.md +0 -179
  281. package/src/sync/schema.ts +0 -11
  282. package/src/temporary.ts +0 -31
  283. package/src/tool/apply_patch.ts +0 -313
  284. package/src/tool/apply_patch.txt +0 -14
  285. package/src/tool/code-mode.ts +0 -310
  286. package/src/tool/edit.ts +0 -737
  287. package/src/tool/edit.txt +0 -13
  288. package/src/tool/external-directory.ts +0 -49
  289. package/src/tool/glob.ts +0 -76
  290. package/src/tool/glob.txt +0 -7
  291. package/src/tool/grep.ts +0 -115
  292. package/src/tool/grep.txt +0 -7
  293. package/src/tool/invalid.ts +0 -21
  294. package/src/tool/json-schema.ts +0 -164
  295. package/src/tool/lsp.ts +0 -113
  296. package/src/tool/lsp.txt +0 -1
  297. package/src/tool/mcp-websearch.ts +0 -96
  298. package/src/tool/plan-enter.txt +0 -1
  299. package/src/tool/plan-exit.txt +0 -1
  300. package/src/tool/plan.ts +0 -79
  301. package/src/tool/question.ts +0 -44
  302. package/src/tool/question.txt +0 -1
  303. package/src/tool/read.ts +0 -386
  304. package/src/tool/read.txt +0 -13
  305. package/src/tool/registry.ts +0 -455
  306. package/src/tool/schema.ts +0 -14
  307. package/src/tool/shell/id.ts +0 -19
  308. package/src/tool/shell/prompt.ts +0 -293
  309. package/src/tool/shell/shell.txt +0 -21
  310. package/src/tool/shell.ts +0 -645
  311. package/src/tool/skill.ts +0 -70
  312. package/src/tool/skill.txt +0 -1
  313. package/src/tool/task.ts +0 -371
  314. package/src/tool/task.txt +0 -11
  315. package/src/tool/todo.ts +0 -46
  316. package/src/tool/todowrite.txt +0 -11
  317. package/src/tool/tool.ts +0 -183
  318. package/src/tool/truncate.ts +0 -156
  319. package/src/tool/truncation-dir.ts +0 -4
  320. package/src/tool/webfetch.ts +0 -192
  321. package/src/tool/webfetch.txt +0 -9
  322. package/src/tool/websearch.ts +0 -143
  323. package/src/tool/websearch.txt +0 -9
  324. package/src/tool/write.ts +0 -104
  325. package/src/tool/write.txt +0 -11
  326. package/src/util/archive.ts +0 -17
  327. package/src/util/bom.ts +0 -27
  328. package/src/util/data-url.ts +0 -9
  329. package/src/util/defer.ts +0 -10
  330. package/src/util/effect-http-client.ts +0 -11
  331. package/src/util/error.ts +0 -16
  332. package/src/util/filesystem.ts +0 -251
  333. package/src/util/html.ts +0 -8
  334. package/src/util/iife.ts +0 -3
  335. package/src/util/lazy.ts +0 -20
  336. package/src/util/local-context.ts +0 -25
  337. package/src/util/locale.ts +0 -4
  338. package/src/util/media.ts +0 -26
  339. package/src/util/process.ts +0 -177
  340. package/src/util/proxy-env.ts +0 -72
  341. package/src/util/queue.ts +0 -32
  342. package/src/util/record.ts +0 -3
  343. package/src/util/repository.ts +0 -232
  344. package/src/util/rpc.ts +0 -66
  345. package/src/util/signal.ts +0 -12
  346. package/src/util/timeout.ts +0 -13
  347. package/src/util/token.ts +0 -1
  348. package/src/util/wildcard.ts +0 -59
  349. package/src/worktree/index.ts +0 -623
  350. package/sst-env.d.ts +0 -10
  351. package/tsconfig.headless.json +0 -13
  352. package/tsconfig.json +0 -16
package/script/publish.ts DELETED
@@ -1,213 +0,0 @@
1
- #!/usr/bin/env bun
2
- import { $ } from "bun"
3
- import pkg from "../package.json"
4
- import { Script } from "@soraacode/script"
5
- import { fileURLToPath } from "url"
6
-
7
- const dir = fileURLToPath(new URL("..", import.meta.url))
8
- process.chdir(dir)
9
-
10
- async function published(name: string, version: string) {
11
- return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0
12
- }
13
-
14
- async function publish(dir: string, name: string, version: string) {
15
- // GitHub artifact downloads can drop the executable bit, and Docker uses the
16
- // unpacked dist binaries directly rather than the published tarball.
17
- if (process.platform !== "win32") await $`chmod -R 755 .`.cwd(dir)
18
- if (await published(name, version)) {
19
- console.log(`already published ${name}@${version}`)
20
- return
21
- }
22
- await $`bun pm pack`.cwd(dir)
23
- await $`npm publish *.tgz --access public --tag ${Script.channel}`.cwd(dir)
24
- }
25
-
26
- const binaries: Record<string, string> = {}
27
- for (const filepath of new Bun.Glob("*/package.json").scanSync({ cwd: "./dist" })) {
28
- const pkg = await Bun.file(`./dist/${filepath}`).json()
29
- binaries[pkg.name] = pkg.version
30
- }
31
- console.log("binaries", binaries)
32
- const version = Object.values(binaries)[0]
33
-
34
- await $`mkdir -p ./dist/${pkg.name}`
35
- await $`mkdir -p ./dist/${pkg.name}/bin`
36
- await $`cp ./script/postinstall.mjs ./dist/${pkg.name}/postinstall.mjs`
37
- await Bun.file(`./dist/${pkg.name}/LICENSE`).write(await Bun.file("../../LICENSE").text())
38
- await Bun.file(`./dist/${pkg.name}/bin/${pkg.name}.exe`).write(
39
- [
40
- `echo "Error: ${pkg.name}-ai's postinstall script was not run." >&2`,
41
- 'echo "" >&2',
42
- 'echo "This occurs when using --ignore-scripts during installation, or when using a" >&2',
43
- 'echo "package manager like pnpm that does not run postinstall scripts by default." >&2',
44
- 'echo "" >&2',
45
- 'echo "To fix this, run the postinstall script manually:" >&2',
46
- `echo " cd node_modules/${pkg.name}-ai && node postinstall.mjs" >&2`,
47
- 'echo "" >&2',
48
- `echo "Or reinstall ${pkg.name}-ai without the --ignore-scripts flag." >&2`,
49
- "exit 1",
50
- "",
51
- ].join("\n"),
52
- )
53
-
54
- await Bun.file(`./dist/${pkg.name}/package.json`).write(
55
- JSON.stringify(
56
- {
57
- name: pkg.name + "-ai",
58
- bin: {
59
- [pkg.name]: `./bin/${pkg.name}.exe`,
60
- },
61
- scripts: {
62
- postinstall: "node ./postinstall.mjs",
63
- },
64
- version: version,
65
- license: pkg.license,
66
- os: ["darwin", "linux", "win32"],
67
- cpu: ["arm64", "x64"],
68
- optionalDependencies: binaries,
69
- },
70
- null,
71
- 2,
72
- ),
73
- )
74
-
75
- const tasks = Object.entries(binaries).map(async ([name]) => {
76
- await publish(`./dist/${name}`, name, binaries[name])
77
- })
78
- await Promise.all(tasks)
79
- await publish(`./dist/${pkg.name}`, `${pkg.name}-ai`, version)
80
-
81
- const image = "ghcr.io/anomalyco/opencode"
82
- const platforms = "linux/amd64,linux/arm64"
83
- const tags = [`${image}:${version}`, `${image}:${Script.channel}`]
84
- const tagFlags = tags.flatMap((t) => ["-t", t])
85
-
86
- // registries
87
- if (!Script.preview) {
88
- await $`docker buildx build --platform ${platforms} ${tagFlags} --push .`
89
- // Calculate SHA values
90
- const arm64Sha = await $`sha256sum ./dist/opencode-linux-arm64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim())
91
- const x64Sha = await $`sha256sum ./dist/opencode-linux-x64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim())
92
- const macX64Sha = await $`sha256sum ./dist/opencode-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
93
- const macArm64Sha = await $`sha256sum ./dist/opencode-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
94
-
95
- const [pkgver, _subver = ""] = Script.version.split(/(-.*)/, 2)
96
-
97
- // arch
98
- const binaryPkgbuild = [
99
- "# Maintainer: dax",
100
- "# Maintainer: adam",
101
- "",
102
- "pkgname='opencode-bin'",
103
- `pkgver=${pkgver}`,
104
- `_subver=${_subver}`,
105
- "options=('!debug' '!strip')",
106
- "pkgrel=1",
107
- "pkgdesc='The AI coding agent built for the terminal.'",
108
- "url='https://github.com/anomalyco/opencode'",
109
- "arch=('aarch64' 'x86_64')",
110
- "license=('MIT')",
111
- "provides=('opencode')",
112
- "conflicts=('opencode')",
113
- "depends=('ripgrep')",
114
- "",
115
- `source_aarch64=("\${pkgname}_\${pkgver}_aarch64.tar.gz::https://github.com/anomalyco/opencode/releases/download/v\${pkgver}\${_subver}/opencode-linux-arm64.tar.gz")`,
116
- `sha256sums_aarch64=('${arm64Sha}')`,
117
-
118
- `source_x86_64=("\${pkgname}_\${pkgver}_x86_64.tar.gz::https://github.com/anomalyco/opencode/releases/download/v\${pkgver}\${_subver}/opencode-linux-x64.tar.gz")`,
119
- `sha256sums_x86_64=('${x64Sha}')`,
120
- "",
121
- "package() {",
122
- ' install -Dm755 ./opencode "${pkgdir}/usr/bin/opencode"',
123
- "}",
124
- "",
125
- ].join("\n")
126
-
127
- for (const [pkg, pkgbuild] of [["opencode-bin", binaryPkgbuild]]) {
128
- for (let i = 0; i < 30; i++) {
129
- try {
130
- await $`rm -rf ./dist/aur-${pkg}`
131
- await $`git clone ssh://aur@aur.archlinux.org/${pkg}.git ./dist/aur-${pkg}`
132
- await $`cd ./dist/aur-${pkg} && git checkout master`
133
- await Bun.file(`./dist/aur-${pkg}/PKGBUILD`).write(pkgbuild)
134
- await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO`
135
- await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO`
136
- if ((await $`cd ./dist/aur-${pkg} && git diff --cached --quiet`.nothrow()).exitCode === 0) break
137
- await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${Script.version}"`
138
- await $`cd ./dist/aur-${pkg} && git push`
139
- break
140
- } catch {
141
- continue
142
- }
143
- }
144
- }
145
-
146
- // Homebrew formula
147
- const homebrewFormula = [
148
- "# typed: false",
149
- "# frozen_string_literal: true",
150
- "",
151
- "# This file was generated by GoReleaser. DO NOT EDIT.",
152
- "class Opencode < Formula",
153
- ` desc "The AI coding agent built for the terminal."`,
154
- ` homepage "https://github.com/anomalyco/opencode"`,
155
- ` version "${Script.version.split("-")[0]}"`,
156
- "",
157
- ` depends_on "ripgrep"`,
158
- "",
159
- " on_macos do",
160
- " if Hardware::CPU.intel?",
161
- ` url "https://github.com/anomalyco/opencode/releases/download/v${Script.version}/opencode-darwin-x64.zip"`,
162
- ` sha256 "${macX64Sha}"`,
163
- "",
164
- " def install",
165
- ' bin.install "opencode"',
166
- " end",
167
- " end",
168
- " if Hardware::CPU.arm?",
169
- ` url "https://github.com/anomalyco/opencode/releases/download/v${Script.version}/opencode-darwin-arm64.zip"`,
170
- ` sha256 "${macArm64Sha}"`,
171
- "",
172
- " def install",
173
- ' bin.install "opencode"',
174
- " end",
175
- " end",
176
- " end",
177
- "",
178
- " on_linux do",
179
- " if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?",
180
- ` url "https://github.com/anomalyco/opencode/releases/download/v${Script.version}/opencode-linux-x64.tar.gz"`,
181
- ` sha256 "${x64Sha}"`,
182
- " def install",
183
- ' bin.install "opencode"',
184
- " end",
185
- " end",
186
- " if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?",
187
- ` url "https://github.com/anomalyco/opencode/releases/download/v${Script.version}/opencode-linux-arm64.tar.gz"`,
188
- ` sha256 "${arm64Sha}"`,
189
- " def install",
190
- ' bin.install "opencode"',
191
- " end",
192
- " end",
193
- " end",
194
- "end",
195
- "",
196
- "",
197
- ].join("\n")
198
-
199
- const token = process.env.GITHUB_TOKEN
200
- if (!token) {
201
- console.error("GITHUB_TOKEN is required to update homebrew tap")
202
- process.exit(1)
203
- }
204
- const tap = `https://x-access-token:${token}@github.com/anomalyco/homebrew-tap.git`
205
- await $`rm -rf ./dist/homebrew-tap`
206
- await $`git clone ${tap} ./dist/homebrew-tap`
207
- await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
208
- await $`cd ./dist/homebrew-tap && git add opencode.rb`
209
- if ((await $`cd ./dist/homebrew-tap && git diff --cached --quiet`.nothrow()).exitCode !== 0) {
210
- await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"`
211
- await $`cd ./dist/homebrew-tap && git push`
212
- }
213
- }
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- // This script runs a separate OpenCode server to be used as a remote
4
- // workspace, simulating a remote environment but all local to make
5
- // debugger easier
6
- //
7
- // *Important*: make sure you add the debug workspace plugin first.
8
- // In `.opencode/opencode.jsonc` in the root of this project add:
9
- //
10
- // "plugin": ["../packages/opencode/src/control-plane/dev/debug-workspace-plugin.ts"]
11
- //
12
- // Afterwards, run `./packages/opencode/script/run-workspace-server`
13
-
14
- import { stat } from "node:fs/promises"
15
- import { setTimeout as sleep } from "node:timers/promises"
16
-
17
- const DEV_DATA_FILE = "/tmp/opencode-workspace-dev-data.json"
18
- const RESTART_POLL_INTERVAL = 250
19
-
20
- async function readData() {
21
- return await Bun.file(DEV_DATA_FILE).json()
22
- }
23
-
24
- async function readDataMtime() {
25
- return await stat(DEV_DATA_FILE)
26
- .then((info) => info.mtimeMs)
27
- .catch((error) => {
28
- if (typeof error === "object" && error && "code" in error && error.code === "ENOENT") {
29
- return undefined
30
- }
31
-
32
- throw error
33
- })
34
- }
35
-
36
- async function readSnapshot() {
37
- while (true) {
38
- try {
39
- const before = await readDataMtime()
40
- if (before === undefined) {
41
- await sleep(RESTART_POLL_INTERVAL)
42
- continue
43
- }
44
-
45
- const data = await readData()
46
- const after = await readDataMtime()
47
-
48
- if (before === after) {
49
- return { data, mtime: after }
50
- }
51
- } catch (error) {
52
- if (typeof error === "object" && error && "code" in error && error.code === "ENOENT") {
53
- await sleep(RESTART_POLL_INTERVAL)
54
- continue
55
- }
56
-
57
- throw error
58
- }
59
- }
60
- }
61
-
62
- function startDevServer(data: any) {
63
- const env = Object.fromEntries(Object.entries(data.env ?? {}).filter(([, value]) => value !== undefined))
64
-
65
- return Bun.spawn(["bun", "run", "dev", "serve", "--port", String(data.port), "--print-logs"], {
66
- env: {
67
- ...process.env,
68
- ...env,
69
- XDG_DATA_HOME: "/tmp/data",
70
- },
71
- stdin: "inherit",
72
- stdout: "inherit",
73
- stderr: "inherit",
74
- })
75
- }
76
-
77
- async function waitForRestartSignal(mtime: number, signal: AbortSignal) {
78
- while (!signal.aborted) {
79
- await sleep(RESTART_POLL_INTERVAL)
80
- if (signal.aborted) return false
81
- if ((await readDataMtime()) !== mtime) return true
82
- }
83
-
84
- return false
85
- }
86
-
87
- while (true) {
88
- const { data, mtime } = await readSnapshot()
89
- const proc = startDevServer(data)
90
- const restartAbort = new AbortController()
91
-
92
- const result = await Promise.race([
93
- proc.exited.then((code) => ({ type: "exit" as const, code })),
94
- waitForRestartSignal(mtime, restartAbort.signal).then((restart) => ({ type: "restart" as const, restart })),
95
- ])
96
-
97
- restartAbort.abort()
98
-
99
- if (result.type === "restart" && result.restart) {
100
- proc.kill()
101
- await proc.exited
102
- continue
103
- }
104
-
105
- process.exit(result.code)
106
- }
package/script/schema.ts DELETED
@@ -1,77 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import { Config } from "@/config/config"
4
- import { ConfigV1 } from "@soraacode/core/v1/config/config"
5
- import { TuiConfig } from "@soraacode/tui/config"
6
- import { Schema } from "effect"
7
-
8
- type JsonSchema = Record<string, unknown>
9
- const MODEL_REF = "https://models.dev/model-schema.json#/$defs/Model"
10
-
11
- function generateEffect(schema: Schema.Top) {
12
- const document = Schema.toJsonSchemaDocument(schema)
13
- const normalized = normalize({
14
- $schema: "https://json-schema.org/draft/2020-12/schema",
15
- ...document.schema,
16
- $defs: document.definitions,
17
- })
18
- if (!isRecord(normalized)) throw new Error("schema generator produced a non-object schema")
19
- const restored = restoreModelRefs(normalized)
20
- if (!isRecord(restored)) throw new Error("schema generator produced a non-object schema")
21
- restored.allowComments = true
22
- restored.allowTrailingCommas = true
23
- return restored
24
- }
25
-
26
- function normalize(value: unknown): unknown {
27
- if (Array.isArray(value)) return value.map(normalize)
28
- if (!isRecord(value)) return value
29
-
30
- const schema = Object.fromEntries(Object.entries(value).map(([key, item]) => [key, normalize(item)]))
31
-
32
- if (Array.isArray(schema.anyOf)) {
33
- const anyOf = schema.anyOf.filter((item) => !isRecord(item) || item.type !== "null")
34
- if (anyOf.length !== schema.anyOf.length) {
35
- const { anyOf: _, ...rest } = schema
36
- if (anyOf.length === 1 && isRecord(anyOf[0])) return normalize({ ...anyOf[0], ...rest })
37
- return { ...rest, anyOf }
38
- }
39
- }
40
-
41
- if (Array.isArray(schema.allOf) && schema.allOf.length === 1 && isRecord(schema.allOf[0])) {
42
- const { allOf: _, ...rest } = schema
43
- return normalize({ ...schema.allOf[0], ...rest })
44
- }
45
-
46
- if (schema.type === "integer" && schema.maximum === undefined) {
47
- return { ...schema, maximum: Number.MAX_SAFE_INTEGER }
48
- }
49
-
50
- return schema
51
- }
52
-
53
- function restoreModelRefs(value: unknown, key?: string): unknown {
54
- if (Array.isArray(value)) return value.map((item) => restoreModelRefs(item))
55
- if (!isRecord(value)) return value
56
-
57
- const schema = Object.fromEntries(Object.entries(value).map(([name, item]) => [name, restoreModelRefs(item, name)]))
58
- if ((key === "model" || key === "small_model") && schema.type === "string") {
59
- return { ...schema, $ref: MODEL_REF }
60
- }
61
- return schema
62
- }
63
-
64
- function isRecord(value: unknown): value is JsonSchema {
65
- return typeof value === "object" && value !== null && !Array.isArray(value)
66
- }
67
-
68
- const configFile = process.argv[2]
69
- const tuiFile = process.argv[3]
70
-
71
- console.log(configFile)
72
- await Bun.write(configFile, JSON.stringify(generateEffect(ConfigV1.Info), null, 2))
73
-
74
- if (tuiFile) {
75
- console.log(tuiFile)
76
- await Bun.write(tuiFile, JSON.stringify(generateEffect(TuiConfig.Info), null, 2))
77
- }
package/script/time.ts DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import path from "path"
4
- const toDynamicallyImport = path.join(process.cwd(), process.argv[2])
5
- await import(toDynamicallyImport)
6
- console.log(performance.now())
@@ -1,153 +0,0 @@
1
- #!/usr/bin/env bun
2
- import * as path from "path"
3
- import * as ts from "typescript"
4
-
5
- const BASE_DIR = "/home/thdxr/dev/projects/anomalyco/opencode/packages/opencode"
6
-
7
- // Get entry file from command line arg or use default
8
- const ENTRY_FILE = process.argv[2] || "src/plugin/tui/runtime.ts"
9
-
10
- const visited = new Set<string>()
11
-
12
- function resolveImport(importPath: string, fromFile: string): string | null {
13
- if (importPath.startsWith("@/")) {
14
- return path.join(BASE_DIR, "src", importPath.slice(2))
15
- }
16
-
17
- if (importPath.startsWith("./") || importPath.startsWith("../")) {
18
- const dir = path.dirname(fromFile)
19
- return path.resolve(dir, importPath)
20
- }
21
-
22
- return null
23
- }
24
-
25
- function isInternalImport(importPath: string): boolean {
26
- return importPath.startsWith("@/") || importPath.startsWith("./") || importPath.startsWith("../")
27
- }
28
-
29
- async function tryExtensions(filePath: string): Promise<string | null> {
30
- const extensions = [".ts", ".tsx", ".js", ".jsx"]
31
-
32
- try {
33
- const file = Bun.file(filePath)
34
- const stat = await file.stat()
35
-
36
- if (stat?.isDirectory()) {
37
- for (const ext of extensions) {
38
- const indexPath = path.join(filePath, "index" + ext)
39
- const indexFile = Bun.file(indexPath)
40
- if (await indexFile.exists()) return indexPath
41
- }
42
- return null
43
- }
44
-
45
- // It's a file
46
- return filePath
47
- } catch {
48
- // Path doesn't exist, try adding extensions
49
- for (const ext of extensions) {
50
- const withExt = filePath + ext
51
- const extFile = Bun.file(withExt)
52
- if (await extFile.exists()) return withExt
53
- }
54
- return null
55
- }
56
- }
57
-
58
- function extractImports(sourceFile: ts.SourceFile): string[] {
59
- const imports: string[] = []
60
-
61
- function visit(node: ts.Node) {
62
- // import x from "path" or import { x } from "path"
63
- if (ts.isImportDeclaration(node)) {
64
- // Skip type-only imports
65
- if (node.importClause?.isTypeOnly) return
66
-
67
- const moduleSpec = node.moduleSpecifier
68
- if (ts.isStringLiteral(moduleSpec)) {
69
- imports.push(moduleSpec.text)
70
- }
71
- }
72
-
73
- // export { x } from "path"
74
- if (ts.isExportDeclaration(node) && node.moduleSpecifier) {
75
- if (ts.isStringLiteral(node.moduleSpecifier)) {
76
- imports.push(node.moduleSpecifier.text)
77
- }
78
- }
79
-
80
- // Dynamic import: import("path")
81
- if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
82
- const arg = node.arguments[0]
83
- if (arg && ts.isStringLiteral(arg)) {
84
- imports.push(arg.text)
85
- }
86
- }
87
-
88
- ts.forEachChild(node, visit)
89
- }
90
-
91
- visit(sourceFile)
92
- return imports
93
- }
94
-
95
- async function traceFile(filePath: string, depth = 0): Promise<void> {
96
- const normalizedPath = path.relative(BASE_DIR, filePath)
97
-
98
- if (visited.has(filePath)) {
99
- return
100
- }
101
-
102
- // Only trace TypeScript/JavaScript files
103
- if (!filePath.match(/\.(ts|tsx|js|jsx)$/)) {
104
- return
105
- }
106
-
107
- visited.add(filePath)
108
- console.log("\t".repeat(depth) + normalizedPath)
109
-
110
- let content: string
111
- try {
112
- content = await Bun.file(filePath).text()
113
- } catch {
114
- return
115
- }
116
-
117
- const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true)
118
-
119
- const imports = extractImports(sourceFile)
120
- const internalImports = imports.filter(isInternalImport)
121
- const externalImports = imports.filter((imp) => !isInternalImport(imp))
122
-
123
- // Print external imports
124
- for (const imp of externalImports) {
125
- console.log("\t".repeat(depth + 1) + `[ext] ${imp}`)
126
- }
127
-
128
- for (const imp of internalImports) {
129
- const resolved = resolveImport(imp, filePath)
130
- if (!resolved) continue
131
-
132
- const actualPath = await tryExtensions(resolved)
133
- if (!actualPath) continue
134
-
135
- await traceFile(actualPath, depth + 1)
136
- }
137
- }
138
-
139
- async function main() {
140
- const entryPath = path.join(BASE_DIR, ENTRY_FILE)
141
-
142
- // Check if file exists
143
- const file = Bun.file(entryPath)
144
- if (!(await file.exists())) {
145
- console.error(`File not found: ${ENTRY_FILE}`)
146
- console.error(`Resolved to: ${entryPath}`)
147
- process.exit(1)
148
- }
149
-
150
- await traceFile(entryPath)
151
- }
152
-
153
- main().catch(console.error)