@stonerzju/opencode 1.2.17 → 1.2.18

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 (261) hide show
  1. package/bin/opencode +29 -157
  2. package/package.json +29 -29
  3. package/src/acp/agent.ts +4 -4
  4. package/src/acp/session.ts +1 -1
  5. package/src/agent/agent.ts +3 -3
  6. package/src/bun/index.ts +2 -2
  7. package/src/cli/cmd/acp.ts +3 -3
  8. package/src/cli/cmd/debug/file.ts +1 -1
  9. package/src/cli/cmd/github.ts +2 -2
  10. package/src/cli/cmd/pr.ts +1 -1
  11. package/src/cli/cmd/tui/app.tsx +24 -24
  12. package/src/cli/cmd/tui/attach.ts +3 -3
  13. package/src/cli/cmd/tui/component/dialog-agent.tsx +3 -3
  14. package/src/cli/cmd/tui/component/dialog-command.tsx +3 -3
  15. package/src/cli/cmd/tui/component/dialog-mcp.tsx +5 -5
  16. package/src/cli/cmd/tui/component/dialog-model.tsx +4 -4
  17. package/src/cli/cmd/tui/component/dialog-provider.tsx +4 -4
  18. package/src/cli/cmd/tui/component/dialog-session-list.tsx +5 -5
  19. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +3 -3
  20. package/src/cli/cmd/tui/component/dialog-skill.tsx +3 -3
  21. package/src/cli/cmd/tui/component/dialog-stash.tsx +3 -3
  22. package/src/cli/cmd/tui/component/dialog-status.tsx +2 -2
  23. package/src/cli/cmd/tui/component/dialog-tag.tsx +3 -3
  24. package/src/cli/cmd/tui/component/logo.tsx +2 -2
  25. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +6 -6
  26. package/src/cli/cmd/tui/component/prompt/frecency.tsx +2 -2
  27. package/src/cli/cmd/tui/component/prompt/history.tsx +2 -2
  28. package/src/cli/cmd/tui/component/prompt/index.tsx +14 -14
  29. package/src/cli/cmd/tui/component/prompt/stash.tsx +2 -2
  30. package/src/cli/cmd/tui/component/textarea-keybindings.ts +1 -1
  31. package/src/cli/cmd/tui/component/tips.tsx +1 -1
  32. package/src/cli/cmd/tui/context/directory.ts +1 -1
  33. package/src/cli/cmd/tui/context/exit.tsx +1 -1
  34. package/src/cli/cmd/tui/context/keybind.tsx +2 -2
  35. package/src/cli/cmd/tui/context/kv.tsx +2 -2
  36. package/src/cli/cmd/tui/context/local.tsx +6 -6
  37. package/src/cli/cmd/tui/context/sync.tsx +4 -4
  38. package/src/cli/cmd/tui/context/theme/opencode.json +245 -0
  39. package/src/cli/cmd/tui/context/theme.tsx +2 -2
  40. package/src/cli/cmd/tui/context/tui-config.tsx +1 -1
  41. package/src/cli/cmd/tui/event.ts +2 -2
  42. package/src/cli/cmd/tui/routes/home.tsx +6 -6
  43. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +6 -6
  44. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +6 -6
  45. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +2 -2
  46. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +3 -3
  47. package/src/cli/cmd/tui/routes/session/header.tsx +5 -5
  48. package/src/cli/cmd/tui/routes/session/index.tsx +32 -32
  49. package/src/cli/cmd/tui/routes/session/permission.tsx +4 -4
  50. package/src/cli/cmd/tui/routes/session/sidebar.tsx +4 -4
  51. package/src/cli/cmd/tui/thread.ts +9 -9
  52. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +1 -1
  53. package/src/cli/cmd/tui/ui/dialog-help.tsx +2 -2
  54. package/src/cli/cmd/tui/ui/dialog-select.tsx +5 -5
  55. package/src/cli/cmd/tui/ui/dialog.tsx +3 -3
  56. package/src/cli/cmd/tui/ui/toast.tsx +1 -1
  57. package/src/cli/cmd/tui/util/editor.ts +3 -3
  58. package/src/cli/cmd/tui/util/transcript.ts +1 -1
  59. package/src/cli/cmd/tui/worker.ts +10 -10
  60. package/src/cli/error.ts +1 -1
  61. package/src/cli/ui.ts +1 -1
  62. package/src/cli/upgrade.ts +4 -4
  63. package/src/command/index.ts +1 -1
  64. package/src/config/config.ts +10 -10
  65. package/src/config/markdown.ts +1 -1
  66. package/src/config/migrate-tui-config.ts +5 -5
  67. package/src/config/paths.ts +4 -4
  68. package/src/config/tui.ts +4 -4
  69. package/src/control/control.sql.ts +1 -1
  70. package/src/control/index.ts +1 -1
  71. package/src/control-plane/adaptors/worktree.ts +1 -1
  72. package/src/control-plane/session-proxy-middleware.ts +1 -1
  73. package/src/control-plane/workspace.sql.ts +1 -1
  74. package/src/control-plane/workspace.ts +7 -7
  75. package/src/file/index.ts +1 -1
  76. package/src/file/ripgrep.ts +2 -2
  77. package/src/file/watcher.ts +5 -5
  78. package/src/format/formatter.ts +1 -1
  79. package/src/ide/index.ts +3 -3
  80. package/src/index.ts +1 -1
  81. package/src/installation/index.ts +3 -3
  82. package/src/lsp/client.ts +3 -3
  83. package/src/lsp/index.ts +3 -3
  84. package/src/mcp/index.ts +4 -4
  85. package/src/permission/index.ts +2 -2
  86. package/src/permission/next.ts +10 -10
  87. package/src/plugin/codex.ts +1 -1
  88. package/src/plugin/copilot.ts +2 -2
  89. package/src/plugin/index.ts +1 -1
  90. package/src/project/bootstrap.ts +2 -2
  91. package/src/project/instance.ts +4 -4
  92. package/src/project/project.sql.ts +1 -1
  93. package/src/project/project.ts +5 -5
  94. package/src/project/state.ts +1 -1
  95. package/src/project/vcs.ts +4 -4
  96. package/src/provider/auth.ts +4 -4
  97. package/src/provider/error.ts +1 -1
  98. package/src/provider/models-snapshot.ts +2 -0
  99. package/src/provider/models.ts +1 -1
  100. package/src/provider/provider.ts +2 -2
  101. package/src/provider/transform.ts +2 -2
  102. package/src/pty/index.ts +5 -5
  103. package/src/question/index.ts +5 -5
  104. package/src/server/event.ts +1 -1
  105. package/src/server/mdns.ts +1 -1
  106. package/src/server/routes/global.ts +3 -3
  107. package/src/server/routes/permission.ts +1 -1
  108. package/src/server/routes/pty.ts +1 -1
  109. package/src/server/routes/session.ts +4 -4
  110. package/src/server/routes/tui.ts +1 -1
  111. package/src/server/server.ts +3 -3
  112. package/src/session/compaction.ts +7 -7
  113. package/src/session/index.ts +10 -10
  114. package/src/session/instruction.ts +1 -1
  115. package/src/session/llm.ts +11 -11
  116. package/src/session/message-v2.ts +10 -10
  117. package/src/session/message.ts +1 -1
  118. package/src/session/processor.ts +10 -10
  119. package/src/session/prompt.ts +8 -8
  120. package/src/session/retry.ts +2 -2
  121. package/src/session/revert.ts +1 -1
  122. package/src/session/session.sql.ts +3 -3
  123. package/src/session/status.ts +3 -3
  124. package/src/session/summary.ts +5 -5
  125. package/src/session/system.ts +1 -1
  126. package/src/session/todo.ts +2 -2
  127. package/src/share/share-next.ts +7 -7
  128. package/src/share/share.sql.ts +1 -1
  129. package/src/shell/shell.ts +3 -3
  130. package/src/skill/skill.ts +6 -6
  131. package/src/storage/db.ts +1 -1
  132. package/src/storage/storage.ts +1 -1
  133. package/src/tool/bash.ts +6 -6
  134. package/src/tool/edit.ts +1 -1
  135. package/src/tool/registry.ts +2 -2
  136. package/src/tool/skill.ts +1 -1
  137. package/src/tool/task.ts +3 -3
  138. package/src/util/array.ts +10 -0
  139. package/src/util/binary.ts +41 -0
  140. package/src/util/encode.ts +51 -0
  141. package/src/util/error.ts +54 -0
  142. package/src/util/identifier.ts +48 -0
  143. package/src/util/lazy.ts +4 -16
  144. package/src/util/path.ts +37 -0
  145. package/src/util/retry.ts +41 -0
  146. package/src/util/slug.ts +74 -0
  147. package/src/worktree/index.ts +3 -3
  148. package/AGENTS.md +0 -10
  149. package/BUN_SHELL_MIGRATION_PLAN.md +0 -136
  150. package/Dockerfile +0 -18
  151. package/README.md +0 -15
  152. package/bunfig.toml +0 -7
  153. package/drizzle.config.ts +0 -10
  154. package/script/build.ts +0 -224
  155. package/script/check-migrations.ts +0 -16
  156. package/script/postinstall.mjs +0 -131
  157. package/script/publish.ts +0 -181
  158. package/script/schema.ts +0 -63
  159. package/script/seed-e2e.ts +0 -50
  160. package/sst-env.d.ts +0 -10
  161. package/test/AGENTS.md +0 -81
  162. package/test/acp/agent-interface.test.ts +0 -51
  163. package/test/acp/event-subscription.test.ts +0 -683
  164. package/test/agent/agent.test.ts +0 -689
  165. package/test/bun.test.ts +0 -53
  166. package/test/cli/github-action.test.ts +0 -197
  167. package/test/cli/github-remote.test.ts +0 -80
  168. package/test/cli/import.test.ts +0 -38
  169. package/test/cli/plugin-auth-picker.test.ts +0 -120
  170. package/test/cli/tui/transcript.test.ts +0 -322
  171. package/test/config/agent-color.test.ts +0 -71
  172. package/test/config/config.test.ts +0 -1886
  173. package/test/config/fixtures/empty-frontmatter.md +0 -4
  174. package/test/config/fixtures/frontmatter.md +0 -28
  175. package/test/config/fixtures/markdown-header.md +0 -11
  176. package/test/config/fixtures/no-frontmatter.md +0 -1
  177. package/test/config/fixtures/weird-model-id.md +0 -13
  178. package/test/config/markdown.test.ts +0 -228
  179. package/test/config/tui.test.ts +0 -510
  180. package/test/control-plane/session-proxy-middleware.test.ts +0 -147
  181. package/test/control-plane/sse.test.ts +0 -56
  182. package/test/control-plane/workspace-server-sse.test.ts +0 -65
  183. package/test/control-plane/workspace-sync.test.ts +0 -97
  184. package/test/file/ignore.test.ts +0 -10
  185. package/test/file/index.test.ts +0 -394
  186. package/test/file/path-traversal.test.ts +0 -198
  187. package/test/file/ripgrep.test.ts +0 -39
  188. package/test/file/time.test.ts +0 -361
  189. package/test/fixture/db.ts +0 -11
  190. package/test/fixture/fixture.ts +0 -45
  191. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  192. package/test/fixture/skills/agents-sdk/SKILL.md +0 -152
  193. package/test/fixture/skills/agents-sdk/references/callable.md +0 -92
  194. package/test/fixture/skills/cloudflare/SKILL.md +0 -211
  195. package/test/fixture/skills/index.json +0 -6
  196. package/test/ide/ide.test.ts +0 -82
  197. package/test/keybind.test.ts +0 -421
  198. package/test/lsp/client.test.ts +0 -95
  199. package/test/mcp/headers.test.ts +0 -153
  200. package/test/mcp/oauth-browser.test.ts +0 -249
  201. package/test/memory/abort-leak.test.ts +0 -136
  202. package/test/patch/patch.test.ts +0 -348
  203. package/test/permission/arity.test.ts +0 -33
  204. package/test/permission/next.test.ts +0 -689
  205. package/test/permission-task.test.ts +0 -319
  206. package/test/plugin/auth-override.test.ts +0 -44
  207. package/test/plugin/codex.test.ts +0 -123
  208. package/test/preload.ts +0 -80
  209. package/test/project/project.test.ts +0 -348
  210. package/test/project/worktree-remove.test.ts +0 -65
  211. package/test/provider/amazon-bedrock.test.ts +0 -446
  212. package/test/provider/copilot/convert-to-copilot-messages.test.ts +0 -523
  213. package/test/provider/copilot/copilot-chat-model.test.ts +0 -592
  214. package/test/provider/gitlab-duo.test.ts +0 -262
  215. package/test/provider/provider.test.ts +0 -2220
  216. package/test/provider/transform.test.ts +0 -2353
  217. package/test/pty/pty-output-isolation.test.ts +0 -140
  218. package/test/question/question.test.ts +0 -300
  219. package/test/scheduler.test.ts +0 -73
  220. package/test/server/global-session-list.test.ts +0 -89
  221. package/test/server/session-list.test.ts +0 -90
  222. package/test/server/session-select.test.ts +0 -78
  223. package/test/session/compaction.test.ts +0 -423
  224. package/test/session/instruction.test.ts +0 -170
  225. package/test/session/llm.test.ts +0 -667
  226. package/test/session/message-v2.test.ts +0 -924
  227. package/test/session/prompt.test.ts +0 -211
  228. package/test/session/retry.test.ts +0 -188
  229. package/test/session/revert-compact.test.ts +0 -285
  230. package/test/session/session.test.ts +0 -71
  231. package/test/session/structured-output-integration.test.ts +0 -233
  232. package/test/session/structured-output.test.ts +0 -385
  233. package/test/skill/discovery.test.ts +0 -110
  234. package/test/skill/skill.test.ts +0 -388
  235. package/test/snapshot/snapshot.test.ts +0 -1180
  236. package/test/storage/json-migration.test.ts +0 -846
  237. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  238. package/test/tool/apply_patch.test.ts +0 -566
  239. package/test/tool/bash.test.ts +0 -402
  240. package/test/tool/edit.test.ts +0 -496
  241. package/test/tool/external-directory.test.ts +0 -127
  242. package/test/tool/fixtures/large-image.png +0 -0
  243. package/test/tool/fixtures/models-api.json +0 -38413
  244. package/test/tool/grep.test.ts +0 -110
  245. package/test/tool/question.test.ts +0 -107
  246. package/test/tool/read.test.ts +0 -504
  247. package/test/tool/registry.test.ts +0 -122
  248. package/test/tool/skill.test.ts +0 -112
  249. package/test/tool/truncation.test.ts +0 -160
  250. package/test/tool/webfetch.test.ts +0 -100
  251. package/test/tool/write.test.ts +0 -348
  252. package/test/util/filesystem.test.ts +0 -443
  253. package/test/util/format.test.ts +0 -59
  254. package/test/util/glob.test.ts +0 -164
  255. package/test/util/iife.test.ts +0 -36
  256. package/test/util/lazy.test.ts +0 -50
  257. package/test/util/lock.test.ts +0 -72
  258. package/test/util/process.test.ts +0 -59
  259. package/test/util/timeout.test.ts +0 -21
  260. package/test/util/wildcard.test.ts +0 -90
  261. package/tsconfig.json +0 -16
package/test/bun.test.ts DELETED
@@ -1,53 +0,0 @@
1
- import { describe, expect, test } from "bun:test"
2
- import fs from "fs/promises"
3
- import path from "path"
4
-
5
- describe("BunProc registry configuration", () => {
6
- test("should not contain hardcoded registry parameters", async () => {
7
- // Read the bun/index.ts file
8
- const bunIndexPath = path.join(__dirname, "../src/bun/index.ts")
9
- const content = await fs.readFile(bunIndexPath, "utf-8")
10
-
11
- // Verify that no hardcoded registry is present
12
- expect(content).not.toContain("--registry=")
13
- expect(content).not.toContain("hasNpmRcConfig")
14
- expect(content).not.toContain("NpmRc")
15
- })
16
-
17
- test("should use Bun's default registry resolution", async () => {
18
- // Read the bun/index.ts file
19
- const bunIndexPath = path.join(__dirname, "../src/bun/index.ts")
20
- const content = await fs.readFile(bunIndexPath, "utf-8")
21
-
22
- // Verify that it uses Bun's default resolution
23
- expect(content).toContain("Bun's default registry resolution")
24
- expect(content).toContain("Bun will use them automatically")
25
- expect(content).toContain("No need to pass --registry flag")
26
- })
27
-
28
- test("should have correct command structure without registry", async () => {
29
- // Read the bun/index.ts file
30
- const bunIndexPath = path.join(__dirname, "../src/bun/index.ts")
31
- const content = await fs.readFile(bunIndexPath, "utf-8")
32
-
33
- // Extract the install function
34
- const installFunctionMatch = content.match(/export async function install[\s\S]*?^ }/m)
35
- expect(installFunctionMatch).toBeTruthy()
36
-
37
- if (installFunctionMatch) {
38
- const installFunction = installFunctionMatch[0]
39
-
40
- // Verify expected arguments are present
41
- expect(installFunction).toContain('"add"')
42
- expect(installFunction).toContain('"--force"')
43
- expect(installFunction).toContain('"--exact"')
44
- expect(installFunction).toContain('"--cwd"')
45
- expect(installFunction).toContain("Global.Path.cache")
46
- expect(installFunction).toContain('pkg + "@" + version')
47
-
48
- // Verify no registry argument is added
49
- expect(installFunction).not.toContain('"--registry"')
50
- expect(installFunction).not.toContain('args.push("--registry')
51
- }
52
- })
53
- })
@@ -1,197 +0,0 @@
1
- import { test, expect, describe } from "bun:test"
2
- import { extractResponseText, formatPromptTooLargeError } from "../../src/cli/cmd/github"
3
- import type { MessageV2 } from "../../src/session/message-v2"
4
-
5
- // Helper to create minimal valid parts
6
- function createTextPart(text: string): MessageV2.Part {
7
- return {
8
- id: "1",
9
- sessionID: "s",
10
- messageID: "m",
11
- type: "text" as const,
12
- text,
13
- }
14
- }
15
-
16
- function createReasoningPart(text: string): MessageV2.Part {
17
- return {
18
- id: "1",
19
- sessionID: "s",
20
- messageID: "m",
21
- type: "reasoning" as const,
22
- text,
23
- time: { start: 0 },
24
- }
25
- }
26
-
27
- function createToolPart(tool: string, title: string, status: "completed" | "running" = "completed"): MessageV2.Part {
28
- if (status === "completed") {
29
- return {
30
- id: "1",
31
- sessionID: "s",
32
- messageID: "m",
33
- type: "tool" as const,
34
- callID: "c1",
35
- tool,
36
- state: {
37
- status: "completed",
38
- input: {},
39
- output: "",
40
- title,
41
- metadata: {},
42
- time: { start: 0, end: 1 },
43
- },
44
- }
45
- }
46
- return {
47
- id: "1",
48
- sessionID: "s",
49
- messageID: "m",
50
- type: "tool" as const,
51
- callID: "c1",
52
- tool,
53
- state: {
54
- status: "running",
55
- input: {},
56
- time: { start: 0 },
57
- },
58
- }
59
- }
60
-
61
- function createStepStartPart(): MessageV2.Part {
62
- return {
63
- id: "1",
64
- sessionID: "s",
65
- messageID: "m",
66
- type: "step-start" as const,
67
- }
68
- }
69
-
70
- function createStepFinishPart(): MessageV2.Part {
71
- return {
72
- id: "1",
73
- sessionID: "s",
74
- messageID: "m",
75
- type: "step-finish" as const,
76
- reason: "done",
77
- cost: 0,
78
- tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
79
- }
80
- }
81
-
82
- describe("extractResponseText", () => {
83
- test("returns text from text part", () => {
84
- const parts = [createTextPart("Hello world")]
85
- expect(extractResponseText(parts)).toBe("Hello world")
86
- })
87
-
88
- test("returns last text part when multiple exist", () => {
89
- const parts = [createTextPart("First"), createTextPart("Last")]
90
- expect(extractResponseText(parts)).toBe("Last")
91
- })
92
-
93
- test("returns text even when tool parts follow", () => {
94
- const parts = [createTextPart("I'll help with that."), createToolPart("todowrite", "3 todos")]
95
- expect(extractResponseText(parts)).toBe("I'll help with that.")
96
- })
97
-
98
- test("returns null for reasoning-only response (signals summary needed)", () => {
99
- const parts = [createReasoningPart("Let me think about this...")]
100
- expect(extractResponseText(parts)).toBeNull()
101
- })
102
-
103
- test("returns null for tool-only response (signals summary needed)", () => {
104
- // This is the exact scenario from the bug report - todowrite with no text
105
- const parts = [createToolPart("todowrite", "8 todos")]
106
- expect(extractResponseText(parts)).toBeNull()
107
- })
108
-
109
- test("returns null for multiple completed tools", () => {
110
- const parts = [
111
- createToolPart("read", "src/file.ts"),
112
- createToolPart("edit", "src/file.ts"),
113
- createToolPart("bash", "bun test"),
114
- ]
115
- expect(extractResponseText(parts)).toBeNull()
116
- })
117
-
118
- test("returns null for running tool parts (signals summary needed)", () => {
119
- const parts = [createToolPart("bash", "", "running")]
120
- expect(extractResponseText(parts)).toBeNull()
121
- })
122
-
123
- test("throws on empty array", () => {
124
- expect(() => extractResponseText([])).toThrow("no parts returned")
125
- })
126
-
127
- test("returns null for step-start only", () => {
128
- const parts = [createStepStartPart()]
129
- expect(extractResponseText(parts)).toBeNull()
130
- })
131
-
132
- test("returns null for step-finish only", () => {
133
- const parts = [createStepFinishPart()]
134
- expect(extractResponseText(parts)).toBeNull()
135
- })
136
-
137
- test("returns null for step-start and step-finish", () => {
138
- const parts = [createStepStartPart(), createStepFinishPart()]
139
- expect(extractResponseText(parts)).toBeNull()
140
- })
141
-
142
- test("returns text from multi-step response", () => {
143
- const parts = [
144
- createStepStartPart(),
145
- createToolPart("read", "src/file.ts"),
146
- createTextPart("Done"),
147
- createStepFinishPart(),
148
- ]
149
- expect(extractResponseText(parts)).toBe("Done")
150
- })
151
-
152
- test("prefers text over reasoning when both present", () => {
153
- const parts = [createReasoningPart("Internal thinking..."), createTextPart("Final answer")]
154
- expect(extractResponseText(parts)).toBe("Final answer")
155
- })
156
-
157
- test("prefers text over tools when both present", () => {
158
- const parts = [createToolPart("read", "src/file.ts"), createTextPart("Here's what I found")]
159
- expect(extractResponseText(parts)).toBe("Here's what I found")
160
- })
161
- })
162
-
163
- describe("formatPromptTooLargeError", () => {
164
- test("formats error without files", () => {
165
- const result = formatPromptTooLargeError([])
166
- expect(result).toBe("PROMPT_TOO_LARGE: The prompt exceeds the model's context limit.")
167
- })
168
-
169
- test("formats error with files (base64 content)", () => {
170
- // Base64 is ~33% larger than original, so we multiply by 0.75 to get original size
171
- // 400 KB base64 = 300 KB original, 200 KB base64 = 150 KB original
172
- const files = [
173
- { filename: "screenshot.png", content: "a".repeat(400 * 1024) },
174
- { filename: "diagram.png", content: "b".repeat(200 * 1024) },
175
- ]
176
- const result = formatPromptTooLargeError(files)
177
-
178
- expect(result).toStartWith("PROMPT_TOO_LARGE: The prompt exceeds the model's context limit.")
179
- expect(result).toInclude("Files in prompt:")
180
- expect(result).toInclude("screenshot.png (300 KB)")
181
- expect(result).toInclude("diagram.png (150 KB)")
182
- })
183
-
184
- test("lists all files when multiple present", () => {
185
- // Base64 sizes: 4KB -> 3KB, 8KB -> 6KB, 12KB -> 9KB
186
- const files = [
187
- { filename: "img1.png", content: "x".repeat(4 * 1024) },
188
- { filename: "img2.jpg", content: "y".repeat(8 * 1024) },
189
- { filename: "img3.gif", content: "z".repeat(12 * 1024) },
190
- ]
191
- const result = formatPromptTooLargeError(files)
192
-
193
- expect(result).toInclude("img1.png (3 KB)")
194
- expect(result).toInclude("img2.jpg (6 KB)")
195
- expect(result).toInclude("img3.gif (9 KB)")
196
- })
197
- })
@@ -1,80 +0,0 @@
1
- import { test, expect } from "bun:test"
2
- import { parseGitHubRemote } from "../../src/cli/cmd/github"
3
-
4
- test("parses https URL with .git suffix", () => {
5
- expect(parseGitHubRemote("https://github.com/sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
6
- })
7
-
8
- test("parses https URL without .git suffix", () => {
9
- expect(parseGitHubRemote("https://github.com/sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
10
- })
11
-
12
- test("parses git@ URL with .git suffix", () => {
13
- expect(parseGitHubRemote("git@github.com:sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
14
- })
15
-
16
- test("parses git@ URL without .git suffix", () => {
17
- expect(parseGitHubRemote("git@github.com:sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
18
- })
19
-
20
- test("parses ssh:// URL with .git suffix", () => {
21
- expect(parseGitHubRemote("ssh://git@github.com/sst/opencode.git")).toEqual({ owner: "sst", repo: "opencode" })
22
- })
23
-
24
- test("parses ssh:// URL without .git suffix", () => {
25
- expect(parseGitHubRemote("ssh://git@github.com/sst/opencode")).toEqual({ owner: "sst", repo: "opencode" })
26
- })
27
-
28
- test("parses http URL", () => {
29
- expect(parseGitHubRemote("http://github.com/owner/repo")).toEqual({ owner: "owner", repo: "repo" })
30
- })
31
-
32
- test("parses URL with hyphenated owner and repo names", () => {
33
- expect(parseGitHubRemote("https://github.com/my-org/my-repo.git")).toEqual({ owner: "my-org", repo: "my-repo" })
34
- })
35
-
36
- test("parses URL with underscores in names", () => {
37
- expect(parseGitHubRemote("git@github.com:my_org/my_repo.git")).toEqual({ owner: "my_org", repo: "my_repo" })
38
- })
39
-
40
- test("parses URL with numbers in names", () => {
41
- expect(parseGitHubRemote("https://github.com/org123/repo456")).toEqual({ owner: "org123", repo: "repo456" })
42
- })
43
-
44
- test("parses repos with dots in the name", () => {
45
- expect(parseGitHubRemote("https://github.com/socketio/socket.io.git")).toEqual({
46
- owner: "socketio",
47
- repo: "socket.io",
48
- })
49
- expect(parseGitHubRemote("https://github.com/vuejs/vue.js")).toEqual({
50
- owner: "vuejs",
51
- repo: "vue.js",
52
- })
53
- expect(parseGitHubRemote("git@github.com:mrdoob/three.js.git")).toEqual({
54
- owner: "mrdoob",
55
- repo: "three.js",
56
- })
57
- expect(parseGitHubRemote("https://github.com/jashkenas/backbone.git")).toEqual({
58
- owner: "jashkenas",
59
- repo: "backbone",
60
- })
61
- })
62
-
63
- test("returns null for non-github URLs", () => {
64
- expect(parseGitHubRemote("https://gitlab.com/owner/repo.git")).toBeNull()
65
- expect(parseGitHubRemote("git@gitlab.com:owner/repo.git")).toBeNull()
66
- expect(parseGitHubRemote("https://bitbucket.org/owner/repo")).toBeNull()
67
- })
68
-
69
- test("returns null for invalid URLs", () => {
70
- expect(parseGitHubRemote("not-a-url")).toBeNull()
71
- expect(parseGitHubRemote("")).toBeNull()
72
- expect(parseGitHubRemote("github.com")).toBeNull()
73
- expect(parseGitHubRemote("https://github.com/")).toBeNull()
74
- expect(parseGitHubRemote("https://github.com/owner")).toBeNull()
75
- })
76
-
77
- test("returns null for URLs with extra path segments", () => {
78
- expect(parseGitHubRemote("https://github.com/owner/repo/tree/main")).toBeNull()
79
- expect(parseGitHubRemote("https://github.com/owner/repo/blob/main/file.ts")).toBeNull()
80
- })
@@ -1,38 +0,0 @@
1
- import { test, expect } from "bun:test"
2
- import { parseShareUrl, transformShareData, type ShareData } from "../../src/cli/cmd/import"
3
-
4
- // parseShareUrl tests
5
- test("parses valid share URLs", () => {
6
- expect(parseShareUrl("https://opncd.ai/share/Jsj3hNIW")).toBe("Jsj3hNIW")
7
- expect(parseShareUrl("https://custom.example.com/share/abc123")).toBe("abc123")
8
- expect(parseShareUrl("http://localhost:3000/share/test_id-123")).toBe("test_id-123")
9
- })
10
-
11
- test("rejects invalid URLs", () => {
12
- expect(parseShareUrl("https://opncd.ai/s/Jsj3hNIW")).toBeNull() // legacy format
13
- expect(parseShareUrl("https://opncd.ai/share/")).toBeNull()
14
- expect(parseShareUrl("https://opncd.ai/share/id/extra")).toBeNull()
15
- expect(parseShareUrl("not-a-url")).toBeNull()
16
- })
17
-
18
- // transformShareData tests
19
- test("transforms share data to storage format", () => {
20
- const data: ShareData[] = [
21
- { type: "session", data: { id: "sess-1", title: "Test" } as any },
22
- { type: "message", data: { id: "msg-1", sessionID: "sess-1" } as any },
23
- { type: "part", data: { id: "part-1", messageID: "msg-1" } as any },
24
- { type: "part", data: { id: "part-2", messageID: "msg-1" } as any },
25
- ]
26
-
27
- const result = transformShareData(data)!
28
-
29
- expect(result.info.id).toBe("sess-1")
30
- expect(result.messages).toHaveLength(1)
31
- expect(result.messages[0].parts).toHaveLength(2)
32
- })
33
-
34
- test("returns null for invalid share data", () => {
35
- expect(transformShareData([])).toBeNull()
36
- expect(transformShareData([{ type: "message", data: {} as any }])).toBeNull()
37
- expect(transformShareData([{ type: "session", data: { id: "s" } as any }])).toBeNull() // no messages
38
- })
@@ -1,120 +0,0 @@
1
- import { test, expect, describe } from "bun:test"
2
- import { resolvePluginProviders } from "../../src/cli/cmd/auth"
3
- import type { Hooks } from "@opencode-ai/plugin"
4
-
5
- function hookWithAuth(provider: string): Hooks {
6
- return {
7
- auth: {
8
- provider,
9
- methods: [],
10
- },
11
- }
12
- }
13
-
14
- function hookWithoutAuth(): Hooks {
15
- return {}
16
- }
17
-
18
- describe("resolvePluginProviders", () => {
19
- test("returns plugin providers not in models.dev", () => {
20
- const result = resolvePluginProviders({
21
- hooks: [hookWithAuth("portkey")],
22
- existingProviders: {},
23
- disabled: new Set(),
24
- providerNames: {},
25
- })
26
- expect(result).toEqual([{ id: "portkey", name: "portkey" }])
27
- })
28
-
29
- test("skips providers already in models.dev", () => {
30
- const result = resolvePluginProviders({
31
- hooks: [hookWithAuth("anthropic")],
32
- existingProviders: { anthropic: {} },
33
- disabled: new Set(),
34
- providerNames: {},
35
- })
36
- expect(result).toEqual([])
37
- })
38
-
39
- test("deduplicates across plugins", () => {
40
- const result = resolvePluginProviders({
41
- hooks: [hookWithAuth("portkey"), hookWithAuth("portkey")],
42
- existingProviders: {},
43
- disabled: new Set(),
44
- providerNames: {},
45
- })
46
- expect(result).toEqual([{ id: "portkey", name: "portkey" }])
47
- })
48
-
49
- test("respects disabled_providers", () => {
50
- const result = resolvePluginProviders({
51
- hooks: [hookWithAuth("portkey")],
52
- existingProviders: {},
53
- disabled: new Set(["portkey"]),
54
- providerNames: {},
55
- })
56
- expect(result).toEqual([])
57
- })
58
-
59
- test("respects enabled_providers when provider is absent", () => {
60
- const result = resolvePluginProviders({
61
- hooks: [hookWithAuth("portkey")],
62
- existingProviders: {},
63
- disabled: new Set(),
64
- enabled: new Set(["anthropic"]),
65
- providerNames: {},
66
- })
67
- expect(result).toEqual([])
68
- })
69
-
70
- test("includes provider when in enabled set", () => {
71
- const result = resolvePluginProviders({
72
- hooks: [hookWithAuth("portkey")],
73
- existingProviders: {},
74
- disabled: new Set(),
75
- enabled: new Set(["portkey"]),
76
- providerNames: {},
77
- })
78
- expect(result).toEqual([{ id: "portkey", name: "portkey" }])
79
- })
80
-
81
- test("resolves name from providerNames", () => {
82
- const result = resolvePluginProviders({
83
- hooks: [hookWithAuth("portkey")],
84
- existingProviders: {},
85
- disabled: new Set(),
86
- providerNames: { portkey: "Portkey AI" },
87
- })
88
- expect(result).toEqual([{ id: "portkey", name: "Portkey AI" }])
89
- })
90
-
91
- test("falls back to id when no name configured", () => {
92
- const result = resolvePluginProviders({
93
- hooks: [hookWithAuth("portkey")],
94
- existingProviders: {},
95
- disabled: new Set(),
96
- providerNames: {},
97
- })
98
- expect(result).toEqual([{ id: "portkey", name: "portkey" }])
99
- })
100
-
101
- test("skips hooks without auth", () => {
102
- const result = resolvePluginProviders({
103
- hooks: [hookWithoutAuth(), hookWithAuth("portkey"), hookWithoutAuth()],
104
- existingProviders: {},
105
- disabled: new Set(),
106
- providerNames: {},
107
- })
108
- expect(result).toEqual([{ id: "portkey", name: "portkey" }])
109
- })
110
-
111
- test("returns empty for no hooks", () => {
112
- const result = resolvePluginProviders({
113
- hooks: [],
114
- existingProviders: {},
115
- disabled: new Set(),
116
- providerNames: {},
117
- })
118
- expect(result).toEqual([])
119
- })
120
- })