diff --git a/packages/opencode/script/release.ts b/packages/opencode/script/publish.ts similarity index 66% rename from packages/opencode/script/release.ts rename to packages/opencode/script/publish.ts index e75ca9736..0f8069fb2 100755 --- a/packages/opencode/script/release.ts +++ b/packages/opencode/script/publish.ts @@ -1,12 +1,24 @@ #!/usr/bin/env bun import { $ } from "bun" +import { Glob } from "bun" import pkg from "../package.json" const dry = process.argv.includes("--dry") +const snapshot = process.argv.includes("--snapshot") -const version = `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` +const version = snapshot + ? `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` + : await $`git describe --tags --exact-match HEAD` + .text() + .then((x) => x.substring(1).trim()) + .catch(() => { + console.error("tag not found") + process.exit(1) + }) + +console.log(`publishing ${version}`) const GOARCH: Record = { arm64: "arm64", @@ -24,6 +36,7 @@ const targets = [ await $`rm -rf dist` const optionalDependencies: Record = {} +const npmTag = snapshot ? "snapshot" : "latest" for (const [os, arch] of targets) { console.log(`building ${os}-${arch}`) const name = `${pkg.name}-${os}-${arch}` @@ -45,7 +58,8 @@ for (const [os, arch] of targets) { 2, ), ) - if (!dry) await $`cd dist/${name} && npm publish --access public --tag latest` + if (!dry) + await $`cd dist/${name} && npm publish --access public --tag ${npmTag}` optionalDependencies[name] = version } @@ -70,4 +84,14 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write( ), ) if (!dry) - await $`cd ./dist/${pkg.name} && npm publish --access public --tag latest` + await $`cd ./dist/${pkg.name} && npm publish --access public --tag ${npmTag}` + +for (const key of Object.keys(optionalDependencies)) { + await $`cd dist/${key}/bin && zip -r ../../${key}.zip *` +} + +// Upload to GitHub releases +const files = Object.keys(optionalDependencies) + .map((key) => `dist/${key}.zip`) + .join(" ") +await $`gh release create v${version} ${files} --title "Release v${version}" --generate-notes` diff --git a/packages/opencode/src/bun/index.ts b/packages/opencode/src/bun/index.ts index d74d184d1..2819607de 100644 --- a/packages/opencode/src/bun/index.ts +++ b/packages/opencode/src/bun/index.ts @@ -7,17 +7,12 @@ export namespace BunProc { cmd: string[], options?: Bun.SpawnOptions.OptionsObject, ) { - const root = - process.argv0 !== "bun" && false - ? path.resolve(process.cwd(), process.argv0) - : "bun" log.info("running", { - cmd: [root, ...cmd], + cmd: [which(), ...cmd], options, }) - const result = Bun.spawn([root, ...cmd], { + const result = Bun.spawn([which(), ...cmd], { ...options, - argv0: "bun", env: { ...process.env, ...options?.env, @@ -31,4 +26,10 @@ export namespace BunProc { } return result } + + export function which() { + return process.argv0 !== "bun" + ? path.resolve(process.cwd(), process.argv0) + : "bun" + } } diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts index 8b53d76b2..ae922a1d7 100644 --- a/packages/opencode/src/lsp/server.ts +++ b/packages/opencode/src/lsp/server.ts @@ -3,6 +3,7 @@ import type { App } from "../app/app" import path from "path" import { Global } from "../global" import { Log } from "../util/log" +import { BunProc } from "../bun" export namespace LSPServer { const log = Log.create({ service: "lsp.server" }) @@ -37,15 +38,10 @@ export namespace LSPServer { app.path.cwd, ).catch(() => {}) if (!tsserver) return - const root = - process.argv0 !== "bun" && false - ? path.resolve(process.cwd(), process.argv0) - : "bun" const proc = spawn( - root, + BunProc.which(), ["x", "typescript-language-server", "--stdio"], { - argv0: "bun", env: { ...process.env, BUN_BE_BUN: "1", diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index 2c4e4daff..6889feb9f 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -259,11 +259,14 @@ export namespace Provider { } } - const priority = ["claude-sonnet-4", "gemini-2.5-pro-preview", "codex-mini"] + const priority = ["gemini-2.5-pro-preview", "codex-mini", "claude-sonnet-4"] export function sort(models: Model[]) { return sortBy( models, - [(model) => priority.indexOf(model.id), "desc"], + [ + (model) => priority.findIndex((filter) => model.id.includes(filter)), + "desc", + ], [(model) => (model.id.includes("latest") ? 0 : 1), "asc"], [(model) => model.id, "desc"], ) diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index 59d0ca361..601757e72 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -283,7 +283,7 @@ export namespace Session { } msgs.push(system) generateText({ - maxOutputTokens: 80, + maxOutputTokens: 20, messages: convertToModelMessages([ { role: "system",