GeezerVison is showing github.com — v2 message format and upgrade to ai sdk v5 (#743) · kennyg/opencode@f884766
This repository was archived by the owner on Jul 27, 2025. It is now read-only.
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/stats.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 28 | 28 | | 29 | 29 | git config --local user.name "GitHub Action" | 30 | 30 | git add STATS.md | 31 | | - git diff --staged --quiet || git commit -m "Update download stats $(date -I)" | | 31 | + git diff --staged --quiet || git commit -m "ignore: update download stats $(date -I)" | 32 | 32 | git push |
Collapse file Copy file name to clipboardExpand all lines: bun.lock +28-30Lines changed: 28 additions & 30 deletions Collapse file Copy file name to clipboardExpand all lines: package.json +4-6Lines changed: 4 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 | "catalog": { | 18 | 18 | "typescript": "5.8.2", | 19 | 19 | "@types/node": "22.13.9", | 20 | | - "zod": "3.24.2", | 21 | | - "ai": "4.3.16" | | 20 | + "zod": "3.25.49", | | 21 | + "ai": "5.0.0-beta.7" | 22 | 22 | } | 23 | 23 | }, | 24 | 24 | "devDependencies": { | | 31 | 31 | }, | 32 | 32 | "license": "MIT", | 33 | 33 | "prettier": { | 34 | | - "semi": false | 35 | | - }, | 36 | | - "overrides": { | 37 | | - "zod": "3.24.2" | | 34 | + "semi": false, | | 35 | + "printWidth": 120 | 38 | 36 | }, | 39 | 37 | "trustedDependencies": [ | 40 | 38 | "esbuild", | |
Collapse file Copy file name to clipboardExpand all lines: packages/function/src/api.ts +3-8Lines changed: 3 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -38,10 +38,7 @@ export class SyncServer extends DurableObject<Env> { | 38 | 38 |
| 39 | 39 | async publish(key: string, content: any) { | 40 | 40 | const sessionID = await this.getSessionID() | 41 | | - if ( | 42 | | - !key.startsWith(`session/info/${sessionID}`) && | 43 | | - !key.startsWith(`session/message/${sessionID}/`) | 44 | | - ) | | 41 | + if (!key.startsWith(`session/info/${sessionID}`) && !key.startsWith(`session/message/${sessionID}/`)) | 45 | 42 | return new Response("Error: Invalid key", { status: 400 }) | 46 | 43 |
| 47 | 44 | // store message | @@ -184,17 +181,15 @@ export default { | 184 | 181 | } | 185 | 182 | const id = url.searchParams.get("id") | 186 | 183 | console.log("share_poll", id) | 187 | | - if (!id) | 188 | | - return new Response("Error: Share ID is required", { status: 400 }) | | 184 | + if (!id) return new Response("Error: Share ID is required", { status: 400 }) | 189 | 185 | const stub = env.SYNC_SERVER.get(env.SYNC_SERVER.idFromName(id)) | 190 | 186 | return stub.fetch(request) | 191 | 187 | } | 192 | 188 |
| 193 | 189 | if (request.method === "GET" && method === "share_data") { | 194 | 190 | const id = url.searchParams.get("id") | 195 | 191 | console.log("share_data", id) | 196 | | - if (!id) | 197 | | - return new Response("Error: Share ID is required", { status: 400 }) | | 192 | + if (!id) return new Response("Error: Share ID is required", { status: 400 }) | 198 | 193 | const stub = env.SYNC_SERVER.get(env.SYNC_SERVER.idFromName(id)) | 199 | 194 | const data = await stub.getData() | 200 | 195 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/script/publish.ts +10-31Lines changed: 10 additions & 31 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -57,8 +57,7 @@ for (const [os, arch] of targets) { | 57 | 57 | 2, | 58 | 58 | ), | 59 | 59 | ) | 60 | | - if (!dry) | 61 | | - await $`cd dist/${name} && bun publish --access public --tag ${npmTag}` | | 60 | + if (!dry) await $`cd dist/${name} && bun publish --access public --tag ${npmTag}` | 62 | 61 | optionalDependencies[name] = version | 63 | 62 | } | 64 | 63 |
| @@ -82,24 +81,19 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write( | 82 | 81 | 2, | 83 | 82 | ), | 84 | 83 | ) | 85 | | -if (!dry) | 86 | | - await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${npmTag}` | | 84 | +if (!dry) await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${npmTag}` | 87 | 85 |
| 88 | 86 | if (!snapshot) { | 89 | 87 | // Github Release | 90 | 88 | for (const key of Object.keys(optionalDependencies)) { | 91 | 89 | await $`cd dist/${key}/bin && zip -r ../../${key}.zip *` | 92 | 90 | } | 93 | 91 |
| 94 | | - const previous = await fetch( | 95 | | - "https://api.github.com/repos/sst/opencode/releases/latest", | 96 | | - ) | | 92 | + const previous = await fetch("https://api.github.com/repos/sst/opencode/releases/latest") | 97 | 93 | .then((res) => res.json()) | 98 | 94 | .then((data) => data.tag_name) | 99 | 95 |
| 100 | | - const commits = await fetch( | 101 | | - `https://api.github.com/repos/sst/opencode/compare/${previous}...HEAD`, | 102 | | - ) | | 96 | + const commits = await fetch(`https://api.github.com/repos/sst/opencode/compare/${previous}...HEAD`) | 103 | 97 | .then((res) => res.json()) | 104 | 98 | .then((data) => data.commits || []) | 105 | 99 |
| @@ -117,26 +111,13 @@ if (!snapshot) { | 117 | 111 | }) | 118 | 112 | .join("\n") | 119 | 113 |
| 120 | | - if (!dry) | 121 | | - await $`gh release create v${version} --title "v${version}" --notes ${notes} ./dist/*.zip` | | 114 | + if (!dry) await $`gh release create v${version} --title "v${version}" --notes ${notes} ./dist/*.zip` | 122 | 115 |
| 123 | 116 | // Calculate SHA values | 124 | | - const arm64Sha = | 125 | | - await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1` | 126 | | - .text() | 127 | | - .then((x) => x.trim()) | 128 | | - const x64Sha = | 129 | | - await $`sha256sum ./dist/opencode-linux-x64.zip | cut -d' ' -f1` | 130 | | - .text() | 131 | | - .then((x) => x.trim()) | 132 | | - const macX64Sha = | 133 | | - await $`sha256sum ./dist/opencode-darwin-x64.zip | cut -d' ' -f1` | 134 | | - .text() | 135 | | - .then((x) => x.trim()) | 136 | | - const macArm64Sha = | 137 | | - await $`sha256sum ./dist/opencode-darwin-arm64.zip | cut -d' ' -f1` | 138 | | - .text() | 139 | | - .then((x) => x.trim()) | | 117 | + const arm64Sha = await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) | | 118 | + const x64Sha = await $`sha256sum ./dist/opencode-linux-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) | | 119 | + const macX64Sha = await $`sha256sum ./dist/opencode-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) | | 120 | + const macArm64Sha = await $`sha256sum ./dist/opencode-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) | 140 | 121 |
| 141 | 122 | // AUR package | 142 | 123 | const pkgbuild = [ | @@ -170,9 +151,7 @@ if (!snapshot) { | 170 | 151 | for (const pkg of ["opencode", "opencode-bin"]) { | 171 | 152 | await $`rm -rf ./dist/aur-${pkg}` | 172 | 153 | | 173 | | - await Bun.file(`./dist/aur-${pkg}/PKGBUILD`).write( | 174 | | - pkgbuild.replace("${pkg}", pkg), | 175 | | - ) | | 154 | + await Bun.file(`./dist/aur-${pkg}/PKGBUILD`).write(pkgbuild.replace("${pkg}", pkg)) | 176 | 155 | await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO` | 177 | 156 | await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO` | 178 | 157 | await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${version}"` | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/app/app.ts +3-12Lines changed: 3 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,23 +45,14 @@ export namespace App { | 45 | 45 | } | 46 | 46 |
| 47 | 47 | export const provideExisting = ctx.provide | 48 | | - export async function provide<T>( | 49 | | - input: Input, | 50 | | - cb: (app: App.Info) => Promise<T>, | 51 | | - ) { | | 48 | + export async function provide<T>(input: Input, cb: (app: App.Info) => Promise<T>) { | 52 | 49 | log.info("creating", { | 53 | 50 | cwd: input.cwd, | 54 | 51 | }) | 55 | | - const git = await Filesystem.findUp(".git", input.cwd).then(([x]) => | 56 | | - x ? path.dirname(x) : undefined, | 57 | | - ) | | 52 | + const git = await Filesystem.findUp(".git", input.cwd).then(([x]) => (x ? path.dirname(x) : undefined)) | 58 | 53 | log.info("git", { git }) | 59 | 54 |
| 60 | | - const data = path.join( | 61 | | - Global.Path.data, | 62 | | - "project", | 63 | | - git ? directory(git) : "global", | 64 | | - ) | | 55 | + const data = path.join(Global.Path.data, "project", git ? directory(git) : "global") | 65 | 56 | const stateFile = Bun.file(path.join(data, APP_JSON)) | 66 | 57 | const state = (await stateFile.json().catch(() => ({}))) as { | 67 | 58 | initialized: number | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/auth/anthropic.ts +12-21Lines changed: 12 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,14 +10,8 @@ export namespace AuthAnthropic { | 10 | 10 | url.searchParams.set("code", "true") | 11 | 11 | url.searchParams.set("client_id", CLIENT_ID) | 12 | 12 | url.searchParams.set("response_type", "code") | 13 | | - url.searchParams.set( | 14 | | - "redirect_uri", | 15 | | - "https://console.anthropic.com/oauth/code/callback", | 16 | | - ) | 17 | | - url.searchParams.set( | 18 | | - "scope", | 19 | | - "org:create_api_key user:profile user:inference", | 20 | | - ) | | 13 | + url.searchParams.set("redirect_uri", "https://console.anthropic.com/oauth/code/callback") | | 14 | + url.searchParams.set("scope", "org:create_api_key user:profile user:inference") | 21 | 15 | url.searchParams.set("code_challenge", pkce.challenge) | 22 | 16 | url.searchParams.set("code_challenge_method", "S256") | 23 | 17 | url.searchParams.set("state", pkce.verifier) | @@ -57,20 +51,17 @@ export namespace AuthAnthropic { | 57 | 51 | const info = await Auth.get("anthropic") | 58 | 52 | if (!info || info.type !== "oauth") return | 59 | 53 | if (info.access && info.expires > Date.now()) return info.access | 60 | | - const response = await fetch( | 61 | | - "https://console.anthropic.com/v1/oauth/token", | 62 | | - { | 63 | | - method: "POST", | 64 | | - headers: { | 65 | | - "Content-Type": "application/json", | 66 | | - }, | 67 | | - body: JSON.stringify({ | 68 | | - grant_type: "refresh_token", | 69 | | - refresh_token: info.refresh, | 70 | | - client_id: CLIENT_ID, | 71 | | - }), | | 54 | + const response = await fetch("https://console.anthropic.com/v1/oauth/token", { | | 55 | + method: "POST", | | 56 | + headers: { | | 57 | + "Content-Type": "application/json", | 72 | 58 | }, | 73 | | - ) | | 59 | + body: JSON.stringify({ | | 60 | + grant_type: "refresh_token", | | 61 | + refresh_token: info.refresh, | | 62 | + client_id: CLIENT_ID, | | 63 | + }), | | 64 | + }) | 74 | 65 | if (!response.ok) return | 75 | 66 | const json = await response.json() | 76 | 67 | await Auth.set("anthropic", { | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/auth/copilot.ts +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,9 +4,7 @@ import path from "path" | 4 | 4 |
| 5 | 5 | export const AuthCopilot = lazy(async () => { | 6 | 6 | const file = Bun.file(path.join(Global.Path.state, "plugin", "copilot.ts")) | 7 | | - const response = fetch( | 8 | | - "https://raw.githubusercontent.com/sst/opencode-github-copilot/refs/heads/main/auth.ts", | 9 | | - ) | | 7 | + const response = fetch("https://raw.githubusercontent.com/sst/opencode-github-copilot/refs/heads/main/auth.ts") | 10 | 8 | .then((x) => Bun.write(file, x)) | 11 | 9 | .catch(() => {}) | 12 | 10 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/auth/github-copilot.ts +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -122,10 +122,7 @@ export namespace AuthGithubCopilot { | 122 | 122 | return tokenData.token | 123 | 123 | } | 124 | 124 |
| 125 | | - export const DeviceCodeError = NamedError.create( | 126 | | - "DeviceCodeError", | 127 | | - z.object({}), | 128 | | - ) | | 125 | + export const DeviceCodeError = NamedError.create("DeviceCodeError", z.object({})) | 129 | 126 |
| 130 | 127 | export const TokenExchangeError = NamedError.create( | 131 | 128 | "TokenExchangeError", | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/bun/index.ts +13-8Lines changed: 13 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,10 +8,7 @@ import { readableStreamToText } from "bun" | 8 | 8 | export namespace BunProc { | 9 | 9 | const log = Log.create({ service: "bun" }) | 10 | 10 |
| 11 | | - export async function run( | 12 | | - cmd: string[], | 13 | | - options?: Bun.SpawnOptions.OptionsObject<any, any, any>, | 14 | | - ) { | | 11 | + export async function run(cmd: string[], options?: Bun.SpawnOptions.OptionsObject<any, any, any>) { | 15 | 12 | log.info("running", { | 16 | 13 | cmd: [which(), ...cmd], | 17 | 14 | ...options, | @@ -26,9 +23,17 @@ export namespace BunProc { | 26 | 23 | BUN_BE_BUN: "1", | 27 | 24 | }, | 28 | 25 | }) | 29 | | - const code = await result.exited; | 30 | | - const stdout = result.stdout ? typeof result.stdout === "number" ? result.stdout : await readableStreamToText(result.stdout) : undefined | 31 | | - const stderr = result.stderr ? typeof result.stderr === "number" ? result.stderr : await readableStreamToText(result.stderr) : undefined | | 26 | + const code = await result.exited | | 27 | + const stdout = result.stdout | | 28 | + ? typeof result.stdout === "number" | | 29 | + ? result.stdout | | 30 | + : await readableStreamToText(result.stdout) | | 31 | + : undefined | | 32 | + const stderr = result.stderr | | 33 | + ? typeof result.stderr === "number" | | 34 | + ? result.stderr | | 35 | + : await readableStreamToText(result.stderr) | | 36 | + : undefined | 32 | 37 | log.info("done", { | 33 | 38 | code, | 34 | 39 | stdout, | @@ -61,7 +66,7 @@ export namespace BunProc { | 61 | 66 | if (parsed.dependencies[pkg] === version) return mod | 62 | 67 | parsed.dependencies[pkg] = version | 63 | 68 | await Bun.write(pkgjson, JSON.stringify(parsed, null, 2)) | 64 | | - await BunProc.run(["install", "--registry=https://registry.npmjs.org"], { | | 69 | + await BunProc.run(["install", "--cwd", Global.Path.cache, "--registry=https://registry.npmjs.org"], { | 65 | 70 | cwd: Global.Path.cache, | 66 | 71 | }).catch((e) => { | 67 | 72 | throw new InstallFailedError( | |
|