mirror of
https://github.com/sst/opencode.git
synced 2025-08-29 01:14:06 +00:00
sync
This commit is contained in:
parent
b7b490f67c
commit
888105e60f
5 changed files with 43 additions and 19 deletions
|
@ -1,12 +1,24 @@
|
||||||
#!/usr/bin/env bun
|
#!/usr/bin/env bun
|
||||||
|
|
||||||
import { $ } from "bun"
|
import { $ } from "bun"
|
||||||
|
import { Glob } from "bun"
|
||||||
|
|
||||||
import pkg from "../package.json"
|
import pkg from "../package.json"
|
||||||
|
|
||||||
const dry = process.argv.includes("--dry")
|
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<string, string> = {
|
const GOARCH: Record<string, string> = {
|
||||||
arm64: "arm64",
|
arm64: "arm64",
|
||||||
|
@ -24,6 +36,7 @@ const targets = [
|
||||||
await $`rm -rf dist`
|
await $`rm -rf dist`
|
||||||
|
|
||||||
const optionalDependencies: Record<string, string> = {}
|
const optionalDependencies: Record<string, string> = {}
|
||||||
|
const npmTag = snapshot ? "snapshot" : "latest"
|
||||||
for (const [os, arch] of targets) {
|
for (const [os, arch] of targets) {
|
||||||
console.log(`building ${os}-${arch}`)
|
console.log(`building ${os}-${arch}`)
|
||||||
const name = `${pkg.name}-${os}-${arch}`
|
const name = `${pkg.name}-${os}-${arch}`
|
||||||
|
@ -45,7 +58,8 @@ for (const [os, arch] of targets) {
|
||||||
2,
|
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
|
optionalDependencies[name] = version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,4 +84,14 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if (!dry)
|
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`
|
|
@ -7,17 +7,12 @@ export namespace BunProc {
|
||||||
cmd: string[],
|
cmd: string[],
|
||||||
options?: Bun.SpawnOptions.OptionsObject<any, any, any>,
|
options?: Bun.SpawnOptions.OptionsObject<any, any, any>,
|
||||||
) {
|
) {
|
||||||
const root =
|
|
||||||
process.argv0 !== "bun" && false
|
|
||||||
? path.resolve(process.cwd(), process.argv0)
|
|
||||||
: "bun"
|
|
||||||
log.info("running", {
|
log.info("running", {
|
||||||
cmd: [root, ...cmd],
|
cmd: [which(), ...cmd],
|
||||||
options,
|
options,
|
||||||
})
|
})
|
||||||
const result = Bun.spawn([root, ...cmd], {
|
const result = Bun.spawn([which(), ...cmd], {
|
||||||
...options,
|
...options,
|
||||||
argv0: "bun",
|
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
...options?.env,
|
...options?.env,
|
||||||
|
@ -31,4 +26,10 @@ export namespace BunProc {
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function which() {
|
||||||
|
return process.argv0 !== "bun"
|
||||||
|
? path.resolve(process.cwd(), process.argv0)
|
||||||
|
: "bun"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import type { App } from "../app/app"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { Global } from "../global"
|
import { Global } from "../global"
|
||||||
import { Log } from "../util/log"
|
import { Log } from "../util/log"
|
||||||
|
import { BunProc } from "../bun"
|
||||||
|
|
||||||
export namespace LSPServer {
|
export namespace LSPServer {
|
||||||
const log = Log.create({ service: "lsp.server" })
|
const log = Log.create({ service: "lsp.server" })
|
||||||
|
@ -37,15 +38,10 @@ export namespace LSPServer {
|
||||||
app.path.cwd,
|
app.path.cwd,
|
||||||
).catch(() => {})
|
).catch(() => {})
|
||||||
if (!tsserver) return
|
if (!tsserver) return
|
||||||
const root =
|
|
||||||
process.argv0 !== "bun" && false
|
|
||||||
? path.resolve(process.cwd(), process.argv0)
|
|
||||||
: "bun"
|
|
||||||
const proc = spawn(
|
const proc = spawn(
|
||||||
root,
|
BunProc.which(),
|
||||||
["x", "typescript-language-server", "--stdio"],
|
["x", "typescript-language-server", "--stdio"],
|
||||||
{
|
{
|
||||||
argv0: "bun",
|
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
BUN_BE_BUN: "1",
|
BUN_BE_BUN: "1",
|
||||||
|
|
|
@ -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[]) {
|
export function sort(models: Model[]) {
|
||||||
return sortBy(
|
return sortBy(
|
||||||
models,
|
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.includes("latest") ? 0 : 1), "asc"],
|
||||||
[(model) => model.id, "desc"],
|
[(model) => model.id, "desc"],
|
||||||
)
|
)
|
||||||
|
|
|
@ -283,7 +283,7 @@ export namespace Session {
|
||||||
}
|
}
|
||||||
msgs.push(system)
|
msgs.push(system)
|
||||||
generateText({
|
generateText({
|
||||||
maxOutputTokens: 80,
|
maxOutputTokens: 20,
|
||||||
messages: convertToModelMessages([
|
messages: convertToModelMessages([
|
||||||
{
|
{
|
||||||
role: "system",
|
role: "system",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue