Compare commits

...

20 Commits

Author SHA1 Message Date
opencode 28ece1e94d release: v1.0.168
Update Nix Hashes / update (push) Waiting to run
2025-12-18 21:55:29 +00:00
Github Action 86fdb27ecc Update Nix flake.lock and hashes 2025-12-18 21:48:53 +00:00
GitHub Action 0eccba49a7 chore: generate 2025-12-18 21:47:59 +00:00
Adam e2dd770470 fix: id 2025-12-18 15:47:21 -06:00
Adam 430b891c5a fix(desktop): expanded states 2025-12-18 15:47:20 -06:00
Adam 8cd4f21019 chore: cleanup 2025-12-18 15:47:20 -06:00
Adam 83fe0b9a7b fix(desktop): smaller max-width when review open 2025-12-18 15:47:20 -06:00
Aiden Cline 74a883e8b3 ci: fix generate 2025-12-18 15:23:23 -06:00
Aiden Cline b29d9d8b5b ci: fix file perm 2025-12-18 14:39:44 -06:00
Aiden Cline 772eaa4993 ci: handle case where generate.yml fails better 2025-12-18 14:33:40 -06:00
Aiden Cline 04eaee6bd6 tweak: more retry cases 2025-12-18 13:59:37 -06:00
Aiden Cline 19a7bf9d64 chore: rm dead code 2025-12-18 13:59:37 -06:00
GitHub Action 39b2b8b0f4 chore: format code 2025-12-18 19:38:25 +00:00
OpeOginni 0ebc541055 feat: add experimental support for Ty language server (#5575) 2025-12-18 13:37:48 -06:00
Adam c1f2aa6661 fix(desktop): markdown styles 2025-12-18 13:03:14 -06:00
Adam c79379e679 fix(desktop): don't show image button in shell mode 2025-12-18 13:03:14 -06:00
Frank 34eafff20e zen: cleanup headers 2025-12-18 13:47:31 -05:00
Aiden Cline 1a332eeb72 rm interleaved thinking filter for certain kimi k2 thinking model providers that were bugged 2025-12-18 12:26:27 -06:00
Adam c79219ff27 fix(desktop): submit prompt 2025-12-18 12:03:21 -06:00
GitHub Action 1a9f2c21a9 chore: format code 2025-12-18 17:31:49 +00:00
37 changed files with 581 additions and 326 deletions
+26 -9
View File
@@ -14,6 +14,7 @@ jobs:
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -25,14 +26,30 @@ jobs:
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Generate SDK
run: |
bun ./packages/sdk/js/script/build.ts
(cd packages/opencode && bun dev generate > ../sdk/openapi.json)
bun x prettier --write packages/sdk/openapi.json
- name: Generate
run: ./script/generate.ts
- name: Format
run: ./script/format.ts
- name: Commit and push
id: push
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit"
exit 0
fi
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -A
git commit -m "chore: generate"
git push origin HEAD:${{ github.event.pull_request.head.ref || github.ref_name }} --no-verify
- name: Comment on failure
if: failure()
run: |
MESSAGE=$'Failed to push generated code. Please run locally and push:\n```\n./script/generate.ts\ngit add -A && git commit -m "chore: generate" && git push\n```'
if [ -n "${{ github.event.pull_request.number }}" ]; then
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE"
else
gh api repos/${{ github.repository }}/commits/${{ github.sha }}/comments -f body="$MESSAGE"
fi
env:
CI: true
PUSH_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+16 -15
View File
@@ -21,7 +21,7 @@
},
"packages/console/app": {
"name": "@opencode-ai/console-app",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@cloudflare/vite-plugin": "1.15.2",
"@ibm/plex": "6.4.1",
@@ -49,7 +49,7 @@
},
"packages/console/core": {
"name": "@opencode-ai/console-core",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@aws-sdk/client-sts": "3.782.0",
"@jsx-email/render": "1.1.1",
@@ -76,7 +76,7 @@
},
"packages/console/function": {
"name": "@opencode-ai/console-function",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@ai-sdk/anthropic": "2.0.0",
"@ai-sdk/openai": "2.0.2",
@@ -100,7 +100,7 @@
},
"packages/console/mail": {
"name": "@opencode-ai/console-mail",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@jsx-email/all": "2.2.3",
"@jsx-email/cli": "1.4.3",
@@ -124,7 +124,7 @@
},
"packages/desktop": {
"name": "@opencode-ai/desktop",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@kobalte/core": "catalog:",
"@opencode-ai/sdk": "workspace:*",
@@ -154,6 +154,7 @@
"solid-list": "catalog:",
"tailwindcss": "catalog:",
"virtua": "catalog:",
"zod": "catalog:",
},
"devDependencies": {
"@happy-dom/global-registrator": "20.0.11",
@@ -171,7 +172,7 @@
},
"packages/enterprise": {
"name": "@opencode-ai/enterprise",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@opencode-ai/ui": "workspace:*",
"@opencode-ai/util": "workspace:*",
@@ -200,7 +201,7 @@
},
"packages/function": {
"name": "@opencode-ai/function",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@octokit/auth-app": "8.0.1",
"@octokit/rest": "catalog:",
@@ -216,7 +217,7 @@
},
"packages/opencode": {
"name": "opencode",
"version": "1.0.167",
"version": "1.0.168",
"bin": {
"opencode": "./bin/opencode",
},
@@ -308,7 +309,7 @@
},
"packages/plugin": {
"name": "@opencode-ai/plugin",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@opencode-ai/sdk": "workspace:*",
"zod": "catalog:",
@@ -328,7 +329,7 @@
},
"packages/sdk/js": {
"name": "@opencode-ai/sdk",
"version": "1.0.167",
"version": "1.0.168",
"devDependencies": {
"@hey-api/openapi-ts": "0.88.1",
"@tsconfig/node22": "catalog:",
@@ -339,7 +340,7 @@
},
"packages/slack": {
"name": "@opencode-ai/slack",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@opencode-ai/sdk": "workspace:*",
"@slack/bolt": "^3.17.1",
@@ -352,7 +353,7 @@
},
"packages/tauri": {
"name": "@opencode-ai/tauri",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@opencode-ai/desktop": "workspace:*",
"@solid-primitives/storage": "catalog:",
@@ -378,7 +379,7 @@
},
"packages/ui": {
"name": "@opencode-ai/ui",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@kobalte/core": "catalog:",
"@opencode-ai/sdk": "workspace:*",
@@ -413,7 +414,7 @@
},
"packages/util": {
"name": "@opencode-ai/util",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"zod": "catalog:",
},
@@ -424,7 +425,7 @@
},
"packages/web": {
"name": "@opencode-ai/web",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@astrojs/cloudflare": "12.6.3",
"@astrojs/markdown-remark": "6.3.1",
Generated
+3 -3
View File
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1765934234,
"narHash": "sha256-pJjWUzNnjbIAMIc5gRFUuKCDQ9S1cuh3b2hKgA7Mc4A=",
"lastModified": 1766025857,
"narHash": "sha256-Lav5jJazCW4mdg1iHcROpuXqmM94BWJvabLFWaJVJp0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "af84f9d270d404c17699522fab95bbf928a2d92f",
"rev": "def3da69945bbe338c373fddad5a1bb49cf199ce",
"type": "github"
},
"original": {
+1 -1
View File
@@ -1,3 +1,3 @@
{
"nodeModules": "sha256-g6XHWk9IoDoeXbvENs+U2fqk185xKMLb0BRopCbXaIk="
"nodeModules": "sha256-U56rAkhKAhZKDEec05Mxj359wjpT03od26tosCjrj9A="
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/console-app",
"version": "1.0.167",
"version": "1.0.168",
"type": "module",
"scripts": {
"typecheck": "tsgo --noEmit",
@@ -112,6 +112,8 @@ export async function handler(
headers.delete("content-length")
headers.delete("x-opencode-request")
headers.delete("x-opencode-session")
headers.delete("x-opencode-project")
headers.delete("x-opencode-client")
return headers
})(),
body: reqBody,
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/console-core",
"version": "1.0.167",
"version": "1.0.168",
"private": true,
"type": "module",
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/console-function",
"version": "1.0.167",
"version": "1.0.168",
"$schema": "https://json.schemastore.org/package.json",
"private": true,
"type": "module",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/console-mail",
"version": "1.0.167",
"version": "1.0.168",
"dependencies": {
"@jsx-email/all": "2.2.3",
"@jsx-email/cli": "1.4.3",
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/desktop",
"version": "1.0.167",
"version": "1.0.168",
"description": "",
"type": "module",
"exports": {
@@ -56,6 +56,7 @@
"solid-js": "catalog:",
"solid-list": "catalog:",
"tailwindcss": "catalog:",
"virtua": "catalog:"
"virtua": "catalog:",
"zod": "catalog:"
}
}
@@ -21,7 +21,7 @@ import { DialogSelectModelUnpaid } from "@/components/dialog-select-model-unpaid
import { useProviders } from "@/hooks/use-providers"
import { useCommand, formatKeybind } from "@/context/command"
import { persisted } from "@/utils/persist"
import { Identifier } from "@opencode-ai/util/identifier"
import { Identifier } from "@/utils/id"
const ACCEPTED_IMAGE_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"]
const ACCEPTED_FILE_TYPES = [...ACCEPTED_IMAGE_TYPES, "application/pdf"]
@@ -1004,15 +1004,17 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
e.currentTarget.value = ""
}}
/>
<Tooltip placement="top" value="Attach image">
<IconButton
type="button"
icon="photo"
variant="ghost"
class="h-10 w-8"
onClick={() => fileInputRef.click()}
/>
</Tooltip>
<Show when={store.mode === "normal"}>
<Tooltip placement="top" value="Attach image">
<IconButton
type="button"
icon="photo"
variant="ghost"
class="h-10 w-8"
onClick={() => fileInputRef.click()}
/>
</Tooltip>
</Show>
<Tooltip
placement="top"
inactive={!prompt.dirty() && !working()}
+40 -4
View File
@@ -1,4 +1,17 @@
import { For, onCleanup, onMount, Show, Match, Switch, createResource, createMemo, createEffect, on } from "solid-js"
import {
For,
onCleanup,
onMount,
Show,
Match,
Switch,
createResource,
createMemo,
createEffect,
on,
createRenderEffect,
batch,
} from "solid-js"
import { Dynamic } from "solid-js/web"
import { useLocal, type LocalFile } from "@/context/local"
import { createStore } from "solid-js/store"
@@ -130,7 +143,8 @@ export default function Page() {
clickTimer: undefined as number | undefined,
activeDraggable: undefined as string | undefined,
activeTerminalDraggable: undefined as string | undefined,
stepsExpanded: false,
userInteracted: false,
stepsExpanded: true,
})
let inputRef!: HTMLDivElement
@@ -159,7 +173,28 @@ export default function Page() {
),
)
createEffect(() => {
params.id
const status = sync.data.session_status[params.id ?? ""] ?? { type: "idle" }
batch(() => {
setStore("userInteracted", false)
setStore("stepsExpanded", status.type !== "idle")
})
})
const status = createMemo(() => sync.data.session_status[params.id ?? ""] ?? { type: "idle" })
const working = createMemo(() => status().type !== "idle" && activeMessage()?.id === lastUserMessage()?.id)
createRenderEffect((prev) => {
const isWorking = working()
if (!prev && isWorking) {
setStore("stepsExpanded", true)
}
if (prev && !isWorking && !store.userInteracted) {
setStore("stepsExpanded", false)
}
return isWorking
}, working())
command.register(() => [
{
@@ -602,7 +637,7 @@ export default function Page() {
<div
classList={{
"relative shrink-0 py-3 flex flex-col gap-6 flex-1 min-h-0 w-full": true,
"max-w-200 mx-auto": !wide(),
"max-w-146 mx-auto": !wide(),
}}
>
<Switch>
@@ -619,7 +654,8 @@ export default function Page() {
sessionID={params.id!}
messageID={activeMessage()!.id}
stepsExpanded={store.stepsExpanded}
onStepsExpandedChange={(expanded) => setStore("stepsExpanded", expanded)}
onStepsExpandedToggle={() => setStore("stepsExpanded", (x) => !x)}
onUserInteracted={() => setStore("userInteracted", true)}
classes={{
root: "pb-20 flex-1 min-w-0",
content: "pb-20",
+99
View File
@@ -0,0 +1,99 @@
import z from "zod"
const prefixes = {
session: "ses",
message: "msg",
permission: "per",
user: "usr",
part: "prt",
pty: "pty",
} as const
const LENGTH = 26
let lastTimestamp = 0
let counter = 0
type Prefix = keyof typeof prefixes
export namespace Identifier {
export function schema(prefix: Prefix) {
return z.string().startsWith(prefixes[prefix])
}
export function ascending(prefix: Prefix, given?: string) {
return generateID(prefix, false, given)
}
export function descending(prefix: Prefix, given?: string) {
return generateID(prefix, true, given)
}
}
function generateID(prefix: Prefix, descending: boolean, given?: string): string {
if (!given) {
return create(prefix, descending)
}
if (!given.startsWith(prefixes[prefix])) {
throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`)
}
return given
}
function create(prefix: Prefix, descending: boolean, timestamp?: number): string {
const currentTimestamp = timestamp ?? Date.now()
if (currentTimestamp !== lastTimestamp) {
lastTimestamp = currentTimestamp
counter = 0
}
counter += 1
let now = BigInt(currentTimestamp) * BigInt(0x1000) + BigInt(counter)
if (descending) {
now = ~now
}
const timeBytes = new Uint8Array(6)
for (let i = 0; i < 6; i += 1) {
timeBytes[i] = Number((now >> BigInt(40 - 8 * i)) & BigInt(0xff))
}
return prefixes[prefix] + "_" + bytesToHex(timeBytes) + randomBase62(LENGTH - 12)
}
function bytesToHex(bytes: Uint8Array): string {
let hex = ""
for (let i = 0; i < bytes.length; i += 1) {
hex += bytes[i].toString(16).padStart(2, "0")
}
return hex
}
function randomBase62(length: number): string {
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
const bytes = getRandomBytes(length)
let result = ""
for (let i = 0; i < length; i += 1) {
result += chars[bytes[i] % 62]
}
return result
}
function getRandomBytes(length: number): Uint8Array {
const bytes = new Uint8Array(length)
const cryptoObj = typeof globalThis !== "undefined" ? globalThis.crypto : undefined
if (cryptoObj && typeof cryptoObj.getRandomValues === "function") {
cryptoObj.getRandomValues(bytes)
return bytes
}
for (let i = 0; i < length; i += 1) {
bytes[i] = Math.floor(Math.random() * 256)
}
return bytes
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/enterprise",
"version": "1.0.167",
"version": "1.0.168",
"private": true,
"type": "module",
"scripts": {
+6 -6
View File
@@ -1,7 +1,7 @@
id = "opencode"
name = "OpenCode"
description = "The open source coding agent."
version = "1.0.167"
version = "1.0.168"
schema_version = 1
authors = ["Anomaly"]
repository = "https://github.com/sst/opencode"
@@ -11,26 +11,26 @@ name = "OpenCode"
icon = "./icons/opencode.svg"
[agent_servers.opencode.targets.darwin-aarch64]
archive = "https://github.com/sst/opencode/releases/download/v1.0.167/opencode-darwin-arm64.zip"
archive = "https://github.com/sst/opencode/releases/download/v1.0.168/opencode-darwin-arm64.zip"
cmd = "./opencode"
args = ["acp"]
[agent_servers.opencode.targets.darwin-x86_64]
archive = "https://github.com/sst/opencode/releases/download/v1.0.167/opencode-darwin-x64.zip"
archive = "https://github.com/sst/opencode/releases/download/v1.0.168/opencode-darwin-x64.zip"
cmd = "./opencode"
args = ["acp"]
[agent_servers.opencode.targets.linux-aarch64]
archive = "https://github.com/sst/opencode/releases/download/v1.0.167/opencode-linux-arm64.tar.gz"
archive = "https://github.com/sst/opencode/releases/download/v1.0.168/opencode-linux-arm64.tar.gz"
cmd = "./opencode"
args = ["acp"]
[agent_servers.opencode.targets.linux-x86_64]
archive = "https://github.com/sst/opencode/releases/download/v1.0.167/opencode-linux-x64.tar.gz"
archive = "https://github.com/sst/opencode/releases/download/v1.0.168/opencode-linux-x64.tar.gz"
cmd = "./opencode"
args = ["acp"]
[agent_servers.opencode.targets.windows-x86_64]
archive = "https://github.com/sst/opencode/releases/download/v1.0.167/opencode-windows-x64.zip"
archive = "https://github.com/sst/opencode/releases/download/v1.0.168/opencode-windows-x64.zip"
cmd = "./opencode.exe"
args = ["acp"]
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/function",
"version": "1.0.167",
"version": "1.0.168",
"$schema": "https://json.schemastore.org/package.json",
"private": true,
"type": "module",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/package.json",
"version": "1.0.167",
"version": "1.0.168",
"name": "opencode",
"type": "module",
"private": true,
-18
View File
@@ -111,22 +111,4 @@ export namespace BunProc {
await Bun.write(pkgjson.name!, JSON.stringify(parsed, null, 2))
return mod
}
export async function resolve(pkg: string) {
const local = workspace(pkg)
if (local) return local
const dir = path.join(Global.Path.cache, "node_modules", pkg)
const pkgjson = Bun.file(path.join(dir, "package.json"))
const exists = await pkgjson.exists()
if (exists) return dir
}
function workspace(pkg: string) {
try {
const target = req.resolve(`${pkg}/package.json`)
return path.dirname(target)
} catch {
return
}
}
}
+1
View File
@@ -29,6 +29,7 @@ export namespace Flag {
export const OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS = number("OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS")
export const OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX = number("OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX")
export const OPENCODE_EXPERIMENTAL_OXFMT = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_OXFMT")
export const OPENCODE_EXPERIMENTAL_LSP_TY = truthy("OPENCODE_EXPERIMENTAL_LSP_TY")
function truthy(key: string) {
const value = process.env[key]?.toLowerCase()
+64 -10
View File
@@ -1,19 +1,73 @@
import { Identifier as SharedIdentifier } from "@opencode-ai/util/identifier"
import z from "zod"
import { randomBytes } from "crypto"
export namespace Identifier {
export type Prefix = SharedIdentifier.Prefix
const prefixes = {
session: "ses",
message: "msg",
permission: "per",
user: "usr",
part: "prt",
pty: "pty",
} as const
export const schema = (prefix: Prefix) => SharedIdentifier.schema(prefix)
export function ascending(prefix: Prefix, given?: string) {
return SharedIdentifier.ascending(prefix, given)
export function schema(prefix: keyof typeof prefixes) {
return z.string().startsWith(prefixes[prefix])
}
export function descending(prefix: Prefix, given?: string) {
return SharedIdentifier.descending(prefix, given)
const LENGTH = 26
// State for monotonic ID generation
let lastTimestamp = 0
let counter = 0
export function ascending(prefix: keyof typeof prefixes, given?: string) {
return generateID(prefix, false, given)
}
export function create(prefix: Prefix, descending: boolean, timestamp?: number) {
return SharedIdentifier.createPrefixed(prefix, descending, timestamp)
export function descending(prefix: keyof typeof prefixes, given?: string) {
return generateID(prefix, true, given)
}
function generateID(prefix: keyof typeof prefixes, descending: boolean, given?: string): string {
if (!given) {
return create(prefix, descending)
}
if (!given.startsWith(prefixes[prefix])) {
throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`)
}
return given
}
function randomBase62(length: number): string {
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
let result = ""
const bytes = randomBytes(length)
for (let i = 0; i < length; i++) {
result += chars[bytes[i] % 62]
}
return result
}
export function create(prefix: keyof typeof prefixes, descending: boolean, timestamp?: number): string {
const currentTimestamp = timestamp ?? Date.now()
if (currentTimestamp !== lastTimestamp) {
lastTimestamp = currentTimestamp
counter = 0
}
counter++
let now = BigInt(currentTimestamp) * BigInt(0x1000) + BigInt(counter)
now = descending ? ~now : now
const timeBytes = Buffer.alloc(6)
for (let i = 0; i < 6; i++) {
timeBytes[i] = Number((now >> BigInt(40 - 8 * i)) & BigInt(0xff))
}
return prefixes[prefix] + "_" + timeBytes.toString("hex") + randomBase62(LENGTH - 12)
}
}
+20
View File
@@ -9,6 +9,7 @@ import z from "zod"
import { Config } from "../config/config"
import { spawn } from "child_process"
import { Instance } from "../project/instance"
import { Flag } from "@/flag/flag"
export namespace LSP {
const log = Log.create({ service: "lsp" })
@@ -60,6 +61,21 @@ export namespace LSP {
})
export type DocumentSymbol = z.infer<typeof DocumentSymbol>
const filterExperimentalServers = (servers: Record<string, LSPServer.Info>) => {
if (Flag.OPENCODE_EXPERIMENTAL_LSP_TY) {
// If experimental flag is enabled, disable pyright
if (servers["pyright"]) {
log.info("LSP server pyright is disabled because OPENCODE_EXPERIMENTAL_LSP_TY is enabled")
delete servers["pyright"]
}
} else {
// If experimental flag is disabled, disable ty
if (servers["ty"]) {
delete servers["ty"]
}
}
}
const state = Instance.state(
async () => {
const clients: LSPClient.Info[] = []
@@ -79,6 +95,9 @@ export namespace LSP {
for (const server of Object.values(LSPServer)) {
servers[server.id] = server
}
filterExperimentalServers(servers)
for (const [name, item] of Object.entries(cfg.lsp ?? {})) {
const existing = servers[name]
if (item.disabled) {
@@ -204,6 +223,7 @@ export namespace LSP {
for (const server of Object.values(s.servers)) {
if (server.extensions.length && !server.extensions.includes(extension)) continue
const root = await server.root(file)
if (!root) continue
if (s.broken.has(root + server.id)) continue
+64
View File
@@ -361,6 +361,70 @@ export namespace LSPServer {
},
}
export const Ty: Info = {
id: "ty",
extensions: [".py", ".pyi"],
root: NearestRoot([
"pyproject.toml",
"ty.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"Pipfile",
"pyrightconfig.json",
]),
async spawn(root) {
if (!Flag.OPENCODE_EXPERIMENTAL_LSP_TY) {
return undefined
}
let binary = Bun.which("ty")
const initialization: Record<string, string> = {}
const potentialVenvPaths = [process.env["VIRTUAL_ENV"], path.join(root, ".venv"), path.join(root, "venv")].filter(
(p): p is string => p !== undefined,
)
for (const venvPath of potentialVenvPaths) {
const isWindows = process.platform === "win32"
const potentialPythonPath = isWindows
? path.join(venvPath, "Scripts", "python.exe")
: path.join(venvPath, "bin", "python")
if (await Bun.file(potentialPythonPath).exists()) {
initialization["pythonPath"] = potentialPythonPath
break
}
}
if (!binary) {
for (const venvPath of potentialVenvPaths) {
const isWindows = process.platform === "win32"
const potentialTyPath = isWindows
? path.join(venvPath, "Scripts", "ty.exe")
: path.join(venvPath, "bin", "ty")
if (await Bun.file(potentialTyPath).exists()) {
binary = potentialTyPath
break
}
}
}
if (!binary) {
log.error("ty not found, please install ty first")
return
}
const proc = spawn(binary, ["server"], {
cwd: root,
})
return {
process: proc,
initialization,
}
},
}
export const Pyright: Info = {
id: "pyright",
extensions: [".py", ".pyi"],
+1 -6
View File
@@ -74,17 +74,12 @@ export namespace ProviderTransform {
return result
}
// TODO: rm later
const bugged =
(model.id === "kimi-k2-thinking" && model.providerID === "opencode") ||
(model.id === "moonshotai/Kimi-K2-Thinking" && model.providerID === "baseten")
if (
model.providerID === "deepseek" ||
model.api.id.toLowerCase().includes("deepseek") ||
(model.capabilities.interleaved &&
typeof model.capabilities.interleaved === "object" &&
model.capabilities.interleaved.field === "reasoning_content" &&
!bugged)
model.capabilities.interleaved.field === "reasoning_content")
) {
return msgs.map((msg) => {
if (msg.role === "assistant" && Array.isArray(msg.content)) {
+3 -2
View File
@@ -65,7 +65,7 @@ export namespace SessionRetry {
if (json.type === "error" && json.error?.type === "too_many_requests") {
return "Too Many Requests"
}
if (json.code === "Some resource has been exhausted") {
if (json.code.includes("exhausted") || json.code.includes("unavailable")) {
return "Provider is overloaded"
}
if (json.type === "error" && json.error?.code?.includes("rate_limit")) {
@@ -73,7 +73,8 @@ export namespace SessionRetry {
}
if (
json.error?.message?.includes("no_kv_space") ||
(json.type === "error" && json.error?.type === "server_error")
(json.type === "error" && json.error?.type === "server_error") ||
!!json.error
) {
return "Provider Server Error"
}
+2 -2
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/plugin",
"version": "1.0.167",
"version": "1.0.168",
"type": "module",
"scripts": {
"typecheck": "tsgo --noEmit",
@@ -24,4 +24,4 @@
"typescript": "catalog:",
"@typescript/native-preview": "catalog:"
}
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/sdk",
"version": "1.0.167",
"version": "1.0.168",
"type": "module",
"scripts": {
"typecheck": "tsgo --noEmit",
@@ -29,4 +29,4 @@
"publishConfig": {
"directory": "dist"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/slack",
"version": "1.0.167",
"version": "1.0.168",
"type": "module",
"scripts": {
"dev": "bun run src/index.ts",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@opencode-ai/tauri",
"private": true,
"version": "1.0.167",
"version": "1.0.168",
"type": "module",
"scripts": {
"typecheck": "tsgo -b",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/ui",
"version": "1.0.167",
"version": "1.0.168",
"type": "module",
"exports": {
"./*": "./src/components/*.tsx",
+105 -62
View File
@@ -1,84 +1,103 @@
[data-component="markdown"] {
/* Reset & Base Typography */
min-width: 0;
max-width: 100%;
overflow: hidden;
overflow-wrap: break-word;
color: var(--text-base);
text-wrap: pretty;
strong {
font-weight: var(--font-weight-medium);
}
/* text-12-regular */
font-family: var(--font-family-sans);
font-size: var(--font-size-base);
font-style: normal;
font-weight: var(--font-weight-regular);
font-size: var(--font-size-base); /* 14px */
line-height: var(--line-height-large);
letter-spacing: var(--letter-spacing-normal);
h1 {
margin-top: 40px;
font-weight: var(--font-weight-medium);
/* Spacing for flow */
> *:first-child {
margin-top: 0;
}
> *:last-child {
margin-bottom: 0;
}
/* Headings: Same size, distinguished by color and spacing */
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: var(--font-size-base);
color: var(--text-strong);
strong {
font-weight: var(--font-weight-medium);
}
}
h2 {
margin-top: 32px;
font-weight: var(--font-weight-medium);
color: var(--text-strong);
strong {
font-weight: var(--font-weight-medium);
}
margin-top: 2rem;
margin-bottom: 0.75rem;
line-height: var(--line-height-large);
}
h3 {
margin-top: 24px;
/* Emphasis & Strong: Neutral strong color */
strong,
b {
color: var(--text-strong);
font-weight: var(--font-weight-medium);
color: var(--text-strong);
strong {
font-weight: var(--font-weight-medium);
}
}
h1 {
font-size: 15px;
}
/* Paragraphs */
p {
margin-top: 16px;
margin-bottom: 8px;
margin-bottom: 1rem;
}
/* Links */
a {
color: var(--text-interactive-base);
text-decoration: none;
font-weight: inherit;
}
a:hover {
text-decoration: underline;
text-underline-offset: 2px;
}
/* Lists */
ul,
ol {
margin-top: 16px;
li {
margin-bottom: 12px;
line-height: var(--line-height-large);
}
li:last-child {
margin-bottom: 0;
}
margin-top: 0.5rem;
margin-bottom: 1rem;
padding-left: 0;
list-style-position: inside;
}
li {
margin-bottom: 0.25rem;
}
li::marker {
color: var(--text-weak);
}
/* Nested lists spacing */
li > ul,
li > ol {
margin-top: 0.25rem;
margin-bottom: 0.25rem;
padding-left: 1rem; /* Minimal indent for nesting only */
}
/* Blockquotes */
blockquote {
border-left: 2px solid var(--border-weak-base);
margin: 1.5rem 0;
padding-left: 0.5rem;
color: var(--text-weak);
font-style: normal;
}
/* Horizontal Rule - Invisible spacing only */
hr {
margin-top: 8px;
margin-bottom: 16px;
border-color: var(--border-weaker-base);
border: none;
height: 0;
margin: 2.5rem 0;
}
.shiki {
font-size: 13px;
background: var(--surface-raised-base) !important; /* temporary fix to test style */
padding: 8px 12px;
border-radius: 4px;
border: 0.5px solid var(--border-weak-base);
@@ -99,19 +118,43 @@
font-family: var(--font-family-mono);
font-feature-settings: var(--font-family-mono--font-feature-settings);
font-size: 13px;
/* background-color: var(--surface-base-strong); */
/* padding: 0.15em 0.35em; */
/* border-radius: var(--radius-sm); */
padding: 2px 2px;
margin: 0 1.5px;
border-radius: 2px;
background: var(--surface-base);
box-shadow: 0 0 0 0.5px var(--border-weak-base);
}
/* &::before, */
/* &::after { */
/* content: "\`"; */
/* } */
/* Tables */
table {
width: 100%;
border-collapse: collapse;
margin: 1.5rem 0;
font-size: var(--font-size-base);
}
th,
td {
/* Minimal borders for structure, matching TUI "lines" roughly but keeping it web-clean */
border-bottom: 1px solid var(--border-weaker-base);
padding: 0.75rem 0.5rem;
text-align: left;
vertical-align: top;
}
th {
color: var(--text-strong);
font-weight: var(--font-weight-medium);
border-bottom: 1px solid var(--border-weak-base);
}
/* Images */
img {
max-width: 100%;
height: auto;
border-radius: 4px;
margin: 1.5rem 0;
display: block;
}
}
+67 -79
View File
@@ -3,7 +3,7 @@ import { useData } from "../context"
import { useDiffComponent } from "../context/diff"
import { getDirectory, getFilename } from "@opencode-ai/util/path"
import { checksum } from "@opencode-ai/util/encode"
import { createEffect, createMemo, For, Match, onCleanup, ParentProps, Show, Switch } from "solid-js"
import { batch, createEffect, createMemo, For, Match, onCleanup, ParentProps, Show, Switch } from "solid-js"
import { createResizeObserver } from "@solid-primitives/resize-observer"
import { DiffChanges } from "./diff-changes"
import { Typewriter } from "./typewriter"
@@ -25,7 +25,8 @@ export function SessionTurn(
sessionID: string
messageID: string
stepsExpanded?: boolean
onStepsExpandedChange?: (expanded: boolean) => void
onStepsExpandedToggle?: () => void
onUserInteracted?: () => void
classes?: {
root?: string
content?: string
@@ -70,6 +71,7 @@ export function SessionTurn(
)
const summary = createMemo(() => message().summary?.body)
const response = createMemo(() => lastTextPart()?.text)
const hasSteps = createMemo(() => assistantParts()?.some((p) => p?.type === "tool"))
const currentTask = createMemo(
() =>
@@ -136,11 +138,11 @@ export function SessionTurn(
})
const hasDiffs = createMemo(() => message().summary?.diffs?.length)
const isShellMode = createMemo(() => {
if (parts().some((p) => p.type !== "text" || !p.synthetic)) return false
if (parts().some((p) => p?.type !== "text" || !p?.synthetic)) return false
if (assistantParts().length !== 1) return false
const assistantPart = assistantParts()[0]
if (assistantPart.type !== "tool") return false
if (assistantPart.tool !== "bash") return false
if (assistantPart?.type !== "tool") return false
if (assistantPart?.tool !== "bash") return false
return true
})
@@ -160,17 +162,16 @@ export function SessionTurn(
}
let scrollRef: HTMLDivElement | undefined
let lastScrollTop = 0
const [store, setStore] = createStore({
contentRef: undefined as HTMLDivElement | undefined,
stickyTitleRef: undefined as HTMLDivElement | undefined,
stickyTriggerRef: undefined as HTMLDivElement | undefined,
lastScrollTop: 0,
autoScrolled: false,
userScrolled: false,
stickyHeaderHeight: 0,
retrySeconds: 0,
status: rawStatus(),
stepsExpanded: props.stepsExpanded ?? working(),
duration: duration(),
})
@@ -191,18 +192,26 @@ export function SessionTurn(
function handleScroll() {
if (!scrollRef || store.autoScrolled) return
const { scrollTop } = scrollRef
// only mark as user scrolled if they actively scrolled upward
// content growth increases scrollHeight but never decreases scrollTop
const scrolledUp = scrollTop < lastScrollTop - 10
const scrollTop = scrollRef.scrollTop
const reset = scrollTop <= 0 && store.lastScrollTop > 100 && working() && !store.userScrolled
if (reset) {
setStore("lastScrollTop", scrollTop)
requestAnimationFrame(scrollToBottom)
return
}
const scrolledUp = scrollTop < store.lastScrollTop - 10
if (scrolledUp && working()) {
setStore("userScrolled", true)
props.onUserInteracted?.()
}
lastScrollTop = scrollTop
setStore("lastScrollTop", scrollTop)
}
function handleInteraction() {
if (working()) setStore("userScrolled", true)
if (working()) {
setStore("userScrolled", true)
props.onUserInteracted?.()
}
}
function scrollToBottom() {
@@ -211,8 +220,10 @@ export function SessionTurn(
requestAnimationFrame(() => {
scrollRef?.scrollTo({ top: scrollRef.scrollHeight, behavior: "smooth" })
requestAnimationFrame(() => {
lastScrollTop = scrollRef?.scrollTop ?? 0
setStore("autoScrolled", false)
batch(() => {
setStore("lastScrollTop", scrollRef?.scrollTop ?? 0)
setStore("autoScrolled", false)
})
})
})
}
@@ -239,12 +250,6 @@ export function SessionTurn(
},
)
createEffect(() => {
if (props.stepsExpanded !== undefined) {
setStore("stepsExpanded", props.stepsExpanded)
}
})
createEffect(() => {
const timer = setInterval(() => {
setStore("duration", duration())
@@ -259,7 +264,6 @@ export function SessionTurn(
if (newStatus === store.status || !newStatus) return
const timeSinceLastChange = Date.now() - lastStatusChange
if (timeSinceLastChange >= 2500) {
setStore("status", newStatus)
lastStatusChange = Date.now()
@@ -277,19 +281,6 @@ export function SessionTurn(
}
})
createEffect((prev) => {
const isWorking = working()
if (!prev && isWorking) {
setStore("stepsExpanded", true)
props.onStepsExpandedChange?.(true)
}
if (prev && !isWorking && !store.userScrolled) {
setStore("stepsExpanded", false)
props.onStepsExpandedChange?.(false)
}
return isWorking
}, working())
return (
<div data-component="session-turn" class={props.classes?.root}>
<div ref={scrollRef} onScroll={handleScroll} data-slot="session-turn-content" class={props.classes?.content}>
@@ -315,7 +306,7 @@ export function SessionTurn(
<Typewriter as="h1" text={message().summary?.title} data-slot="session-turn-typewriter" />
</Match>
<Match when={true}>
<h1>{message().summary?.title ?? "New message"}</h1>
<h1>{message().summary?.title}</h1>
</Match>
</Switch>
</div>
@@ -326,49 +317,46 @@ export function SessionTurn(
<Message message={message()} parts={parts()} />
</div>
{/* Trigger (sticky) */}
<div ref={(el) => setStore("stickyTriggerRef", el)} data-slot="session-turn-response-trigger">
<Button
data-expandable={assistantMessages().length > 0}
data-slot="session-turn-collapsible-trigger-content"
variant="ghost"
size="small"
onClick={() => {
if (assistantMessages().length === 0) return
const next = !store.stepsExpanded
setStore("stepsExpanded", next)
props.onStepsExpandedChange?.(next)
}}
>
<Show when={working()}>
<Spinner />
</Show>
<Switch>
<Match when={retry()}>
<span data-slot="session-turn-retry-message">
{(() => {
const r = retry()
if (!r) return ""
return r.message.length > 60 ? r.message.slice(0, 60) + "..." : r.message
})()}
</span>
<span data-slot="session-turn-retry-seconds">
· retrying {store.retrySeconds > 0 ? `in ${store.retrySeconds}s ` : ""}
</span>
<span data-slot="session-turn-retry-attempt">(#{retry()?.attempt})</span>
</Match>
<Match when={working()}>{store.status ?? "Considering next steps"}</Match>
<Match when={store.stepsExpanded}>Hide steps</Match>
<Match when={!store.stepsExpanded}>Show steps</Match>
</Switch>
<span>·</span>
<span>{store.duration}</span>
<Show when={assistantMessages().length > 0}>
<Icon name="chevron-grabber-vertical" size="small" />
</Show>
</Button>
</div>
<Show when={working() || hasSteps()}>
<div ref={(el) => setStore("stickyTriggerRef", el)} data-slot="session-turn-response-trigger">
<Button
data-expandable={assistantMessages().length > 0}
data-slot="session-turn-collapsible-trigger-content"
variant="ghost"
size="small"
onClick={props.onStepsExpandedToggle ?? (() => {})}
>
<Show when={working()}>
<Spinner />
</Show>
<Switch>
<Match when={retry()}>
<span data-slot="session-turn-retry-message">
{(() => {
const r = retry()
if (!r) return ""
return r.message.length > 60 ? r.message.slice(0, 60) + "..." : r.message
})()}
</span>
<span data-slot="session-turn-retry-seconds">
· retrying {store.retrySeconds > 0 ? `in ${store.retrySeconds}s ` : ""}
</span>
<span data-slot="session-turn-retry-attempt">(#{retry()?.attempt})</span>
</Match>
<Match when={working()}>{store.status ?? "Considering next steps"}</Match>
<Match when={props.stepsExpanded}>Hide steps</Match>
<Match when={!props.stepsExpanded}>Show steps</Match>
</Switch>
<span>·</span>
<span>{store.duration}</span>
<Show when={assistantMessages().length > 0}>
<Icon name="chevron-grabber-vertical" size="small" />
</Show>
</Button>
</div>
</Show>
{/* Response */}
<Show when={store.stepsExpanded && assistantMessages().length > 0}>
<Show when={props.stepsExpanded && assistantMessages().length > 0}>
<div data-slot="session-turn-collapsible-content-inner">
<For each={assistantMessages()}>
{(assistantMessage) => {
@@ -467,7 +455,7 @@ export function SessionTurn(
</Accordion>
</div>
</Show>
<Show when={error() && !store.stepsExpanded}>
<Show when={error() && !props.stepsExpanded}>
<Card variant="error" class="error-card">
{error()?.data?.message as string}
</Card>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@opencode-ai/util",
"version": "1.0.167",
"version": "1.0.168",
"private": true,
"type": "module",
"exports": {
+22 -73
View File
@@ -1,99 +1,48 @@
import z from "zod"
import { randomBytes } from "crypto"
export namespace Identifier {
const prefixes = {
session: "ses",
message: "msg",
permission: "per",
user: "usr",
part: "prt",
pty: "pty",
} as const
export type Prefix = keyof typeof prefixes
type CryptoLike = {
getRandomValues<T extends ArrayBufferView>(array: T): T
}
const TOTAL_LENGTH = 26
const RANDOM_LENGTH = TOTAL_LENGTH - 12
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
const LENGTH = 26
// State for monotonic ID generation
let lastTimestamp = 0
let counter = 0
const fillRandomBytes = (buffer: Uint8Array) => {
const cryptoLike = (globalThis as { crypto?: CryptoLike }).crypto
if (cryptoLike?.getRandomValues) {
cryptoLike.getRandomValues(buffer)
return buffer
}
for (let i = 0; i < buffer.length; i++) {
buffer[i] = Math.floor(Math.random() * 256)
}
return buffer
export function ascending() {
return create(false)
}
const randomBase62 = (length: number) => {
const bytes = fillRandomBytes(new Uint8Array(length))
export function descending() {
return create(true)
}
function randomBase62(length: number): string {
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
let result = ""
const bytes = randomBytes(length)
for (let i = 0; i < length; i++) {
result += BASE62[bytes[i] % BASE62.length]
result += chars[bytes[i] % 62]
}
return result
}
const createSuffix = (descending: boolean, timestamp?: number) => {
export function create(descending: boolean, timestamp?: number): string {
const currentTimestamp = timestamp ?? Date.now()
if (currentTimestamp !== lastTimestamp) {
lastTimestamp = currentTimestamp
counter = 0
}
counter += 1
counter++
let value = BigInt(currentTimestamp) * 0x1000n + BigInt(counter)
if (descending) value = ~value
let now = BigInt(currentTimestamp) * BigInt(0x1000) + BigInt(counter)
const timeBytes = new Uint8Array(6)
now = descending ? ~now : now
const timeBytes = Buffer.alloc(6)
for (let i = 0; i < 6; i++) {
timeBytes[i] = Number((value >> BigInt(40 - 8 * i)) & 0xffn)
timeBytes[i] = Number((now >> BigInt(40 - 8 * i)) & BigInt(0xff))
}
const hex = Array.from(timeBytes)
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("")
return hex + randomBase62(RANDOM_LENGTH)
}
const generateID = (prefix: Prefix, descending: boolean, given?: string, timestamp?: number) => {
if (given) {
const expected = `${prefixes[prefix]}_`
if (!given.startsWith(expected)) throw new Error(`ID ${given} does not start with ${expected}`)
return given
}
return `${prefixes[prefix]}_${createSuffix(descending, timestamp)}`
}
export const schema = (prefix: Prefix) => z.string().startsWith(`${prefixes[prefix]}_`)
export function ascending(): string
export function ascending(prefix: Prefix, given?: string): string
export function ascending(prefix?: Prefix, given?: string) {
if (prefix) return generateID(prefix, false, given)
return create(false)
}
export function descending(): string
export function descending(prefix: Prefix, given?: string): string
export function descending(prefix?: Prefix, given?: string) {
if (prefix) return generateID(prefix, true, given)
return create(true)
}
export function create(descending: boolean, timestamp?: number) {
return createSuffix(descending, timestamp)
}
export function createPrefixed(prefix: Prefix, descending: boolean, timestamp?: number) {
return generateID(prefix, descending, undefined, timestamp)
return timeBytes.toString("hex") + randomBase62(LENGTH - 12)
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@opencode-ai/web",
"type": "module",
"version": "1.0.167",
"version": "1.0.168",
"scripts": {
"dev": "astro dev",
"dev:remote": "VITE_API_URL=https://api.opencode.ai astro dev",
-9
View File
@@ -3,12 +3,3 @@
import { $ } from "bun"
await $`bun run prettier --ignore-unknown --write .`
if (process.env["CI"] && (await $`git status --porcelain`.text())) {
await $`git config --local user.email "action@github.com"`
await $`git config --local user.name "GitHub Action"`
await $`git add -A`
await $`git commit -m "chore: format code"`
const branch = process.env["PUSH_BRANCH"]
await $`git push origin HEAD:${branch} --no-verify`
}
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env bun
import { $ } from "bun"
await $`bun ./packages/sdk/js/script/build.ts`
await $`bun dev generate > ../sdk/openapi.json`.cwd("packages/opencode")
await $`./script/format.ts`
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "opencode",
"displayName": "opencode",
"description": "opencode for VS Code",
"version": "1.0.167",
"version": "1.0.168",
"publisher": "sst-dev",
"repository": {
"type": "git",