Compare commits

...

10 Commits

Author SHA1 Message Date
opencode
48e12ade76 release: v0.4.13 2025-08-11 05:51:06 +00:00
Dax Raad
6145dfcca0 fix run command to be less messy 2025-08-11 01:45:05 -04:00
opencode
4580c88c0b release: v0.4.12 2025-08-11 05:28:22 +00:00
Dax Raad
061ba65d20 show combined output of bash tool progressively 2025-08-11 01:23:00 -04:00
Dax Raad
457386ad08 fix plan mode bash tool making changes 2025-08-11 01:15:12 -04:00
opencode
fce04dc48b release: v0.4.11 2025-08-11 02:30:21 +00:00
Dax Raad
81534ab387 ci: tweaks 2025-08-10 22:23:59 -04:00
Aiden Cline
409a6f93b2 fix: enforce field requirement for cli cmds (#1796) 2025-08-10 22:17:12 -04:00
opencode
55c294c013 release: v0.4.6 2025-08-11 01:59:27 +00:00
Dax Raad
70db372466 add OPENCODE_DISABLE_AUTOUPDATE flag 2025-08-10 21:52:52 -04:00
25 changed files with 157 additions and 119 deletions

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode/cloud-core",
"version": "0.4.3",
"version": "0.4.13",
"private": true,
"type": "module",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@opencode/cloud-function",
"version": "0.4.3",
"version": "0.4.13",
"$schema": "https://json.schemastore.org/package.json",
"private": true,
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@opencode/cloud-web",
"version": "0.4.3",
"version": "0.4.13",
"private": true,
"description": "",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@opencode/function",
"version": "0.4.3",
"version": "0.4.13",
"$schema": "https://json.schemastore.org/package.json",
"private": true,
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/package.json",
"version": "0.4.3",
"version": "0.4.13",
"name": "opencode",
"type": "module",
"private": true,

View File

@@ -40,7 +40,10 @@ for (const [os, arch] of targets) {
)
await $`bun build --define OPENCODE_TUI_PATH="'../../../dist/${name}/bin/tui'" --define OPENCODE_VERSION="'${version}'" --compile --target=bun-${os}-${arch} --outfile=dist/${name}/bin/opencode ./src/index.ts`
// Run the binary only if it matches current OS/arch
if ((process.platform === (os === "windows" ? "win32" : os)) && (process.arch === arch || (process.arch === "x64" && arch === "x64-baseline"))) {
if (
process.platform === (os === "windows" ? "win32" : os) &&
(process.arch === arch || (process.arch === "x64" && arch === "x64-baseline"))
) {
console.log(`smoke test: running dist/${name}/bin/opencode --version`)
await $`./dist/${name}/bin/opencode --version`
}
@@ -84,44 +87,10 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write(
if (!dry) await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${npmTag}`
if (!snapshot) {
// Github Release
for (const key of Object.keys(optionalDependencies)) {
await $`cd dist/${key}/bin && zip -r ../../${key}.zip *`
}
const previous = await fetch("https://api.github.com/repos/sst/opencode/releases/latest")
.then((res) => {
if (!res.ok) throw new Error(res.statusText)
return res.json()
})
.then((data) => data.tag_name)
console.log("finding commits between", previous, "and", "HEAD")
const commits = await fetch(`https://api.github.com/repos/sst/opencode/compare/${previous}...HEAD`)
.then((res) => res.json())
.then((data) => data.commits || [])
const raw = commits.map((commit: any) => `- ${commit.commit.message.split("\n").join(" ")}`)
console.log(raw)
const notes =
raw
.filter((x: string) => {
const lower = x.toLowerCase()
return (
!lower.includes("release:") &&
!lower.includes("ignore:") &&
!lower.includes("chore:") &&
!lower.includes("ci:") &&
!lower.includes("wip:") &&
!lower.includes("docs:") &&
!lower.includes("doc:")
)
})
.join("\n") || "No notable changes"
if (!dry) await $`gh release create v${version} --title "v${version}" --notes ${notes} ./dist/*.zip`
// Calculate SHA values
const arm64Sha = await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
const x64Sha = await $`sha256sum ./dist/opencode-linux-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim())

View File

@@ -39,7 +39,7 @@ const AgentCreateCommand = cmd({
const query = await prompts.text({
message: "Description",
placeholder: "What should this agent do?",
validate: (x) => x && (x.length > 0 ? undefined : "Required"),
validate: (x) => (x && x.length > 0 ? undefined : "Required"),
})
if (prompts.isCancel(query)) throw new UI.CancelledError()

View File

@@ -139,7 +139,7 @@ export const AuthLoginCommand = cmd({
if (provider === "other") {
provider = await prompts.text({
message: "Enter provider id",
validate: (x) => x && (x.match(/^[0-9a-z-]+$/) ? undefined : "a-z, 0-9 and hyphens only"),
validate: (x) => (x && x.match(/^[0-9a-z-]+$/) ? undefined : "a-z, 0-9 and hyphens only"),
})
if (prompts.isCancel(provider)) throw new UI.CancelledError()
provider = provider.replace(/^@ai-sdk\//, "")
@@ -193,7 +193,7 @@ export const AuthLoginCommand = cmd({
const code = await prompts.text({
message: "Paste the authorization code here: ",
validate: (x) => x && (x.length > 0 ? undefined : "Required"),
validate: (x) => (x && x.length > 0 ? undefined : "Required"),
})
if (prompts.isCancel(code)) throw new UI.CancelledError()
@@ -229,7 +229,7 @@ export const AuthLoginCommand = cmd({
const code = await prompts.text({
message: "Paste the authorization code here: ",
validate: (x) => x && (x.length > 0 ? undefined : "Required"),
validate: (x) => (x && x.length > 0 ? undefined : "Required"),
})
if (prompts.isCancel(code)) throw new UI.CancelledError()
@@ -302,7 +302,7 @@ export const AuthLoginCommand = cmd({
const key = await prompts.password({
message: "Enter your API key",
validate: (x) => x && (x.length > 0 ? undefined : "Required"),
validate: (x) => (x && x.length > 0 ? undefined : "Required"),
})
if (prompts.isCancel(key)) throw new UI.CancelledError()
await Auth.set(provider, {

View File

@@ -19,7 +19,7 @@ export const McpAddCommand = cmd({
const name = await prompts.text({
message: "Enter MCP server name",
validate: (x) => x && (x.length > 0 ? undefined : "Required"),
validate: (x) => (x && x.length > 0 ? undefined : "Required"),
})
if (prompts.isCancel(name)) throw new UI.CancelledError()
@@ -44,7 +44,7 @@ export const McpAddCommand = cmd({
const command = await prompts.text({
message: "Enter command to run",
placeholder: "e.g., opencode x @modelcontextprotocol/server-filesystem",
validate: (x) => x && (x.length > 0 ? undefined : "Required"),
validate: (x) => (x && x.length > 0 ? undefined : "Required"),
})
if (prompts.isCancel(command)) throw new UI.CancelledError()

View File

@@ -84,10 +84,6 @@ export const RunCommand = cmd({
return
}
UI.empty()
UI.println(UI.logo())
UI.empty()
const cfg = await Config.get()
if (cfg.share === "auto" || Flag.OPENCODE_AUTO_SHARE || args.share) {
try {
@@ -101,7 +97,6 @@ export const RunCommand = cmd({
}
}
}
UI.empty()
const agent = await (async () => {
if (args.agent) return Agent.get(args.agent)
@@ -116,9 +111,6 @@ export const RunCommand = cmd({
return Provider.defaultModel()
})()
UI.println(UI.Style.TEXT_NORMAL_BOLD + "@ ", UI.Style.TEXT_NORMAL + `${providerID}/${modelID}`)
UI.empty()
function printEvent(color: string, type: string, title: string) {
UI.println(
color + `|`,
@@ -137,7 +129,8 @@ export const RunCommand = cmd({
if (part.type === "tool" && part.state.status === "completed") {
const [tool, color] = TOOL[part.tool] ?? [part.tool, UI.Style.TEXT_INFO_BOLD]
const title =
part.state.title || Object.keys(part.state.input).length > 0 ? JSON.stringify(part.state.input) : "Unknown"
part.state.title ||
(Object.keys(part.state.input).length > 0 ? JSON.stringify(part.state.input) : "Unknown")
printEvent(color, tool, title)
}

View File

@@ -13,6 +13,7 @@ import { Log } from "../../util/log"
import { FileWatcher } from "../../file/watch"
import { Ide } from "../../ide"
import { Agent } from "../../agent/agent"
import { Flag } from "../../flag/flag"
declare global {
const OPENCODE_TUI_PATH: string
@@ -126,7 +127,7 @@ export const TuiCommand = cmd({
if (Installation.isDev()) return
if (Installation.isSnapshot()) return
const config = await Config.global()
if (config.autoupdate === false) return
if (config.autoupdate === false || Flag.OPENCODE_DISABLE_AUTOUPDATE) return
const latest = await Installation.latest().catch(() => {})
if (!latest) return
if (Installation.VERSION === latest) return

View File

@@ -2,6 +2,7 @@ export namespace Flag {
export const OPENCODE_AUTO_SHARE = truthy("OPENCODE_AUTO_SHARE")
export const OPENCODE_DISABLE_WATCHER = truthy("OPENCODE_DISABLE_WATCHER")
export const OPENCODE_CONFIG = process.env["OPENCODE_CONFIG"]
export const OPENCODE_DISABLE_AUTOUPDATE = truthy("OPENCODE_DISABLE_AUTOUPDATE")
function truthy(key: string) {
const value = process.env[key]?.toLowerCase()

View File

@@ -15,6 +15,7 @@ import {
} from "ai"
import PROMPT_INITIALIZE from "../session/prompt/initialize.txt"
import PROMPT_PLAN from "../session/prompt/plan.txt"
import { App } from "../app/app"
import { Bus } from "../bus"
@@ -607,17 +608,6 @@ export namespace Session {
]
}),
).then((x) => x.flat())
/*
if (inputAgent === "plan")
userParts.push({
id: Identifier.ascending("part"),
messageID: userMsg.id,
sessionID: input.sessionID,
type: "text",
text: PROMPT_PLAN,
synthetic: true,
})
*/
await Plugin.trigger(
"chat.message",
{},
@@ -720,6 +710,16 @@ export namespace Session {
}
const agent = await Agent.get(inputAgent)
if (agent.name === "plan") {
msgs.at(-1)?.parts.push({
id: Identifier.ascending("part"),
messageID: userMsg.id,
sessionID: input.sessionID,
type: "text",
text: PROMPT_PLAN,
synthetic: true,
})
}
let system = SystemPrompt.header(input.providerID)
system.push(
...(() => {

View File

@@ -1,3 +1,8 @@
<system-reminder>
Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received (for example, to make edits).
Plan mode is active. The user indicated that they do not want you to execute yet
-- you MUST NOT make any edits, run any non-readonly tools (including changing
configs or making commits), or otherwise make any changes to the system. This
supersedes any other instructions you have received (for example, to make
edits). Bash tool must only run readonly commands
</system-reminder>

View File

@@ -20,6 +20,7 @@ export namespace SystemPrompt {
if (providerID.includes("anthropic")) return [PROMPT_ANTHROPIC_SPOOF.trim()]
return []
}
export function provider(modelID: string) {
if (modelID.includes("gpt-5")) return [PROMPT_CODEX]
if (modelID.includes("gpt-") || modelID.includes("o1") || modelID.includes("o3")) return [PROMPT_BEAST]

View File

@@ -1,6 +1,6 @@
import { z } from "zod"
import { exec } from "child_process"
import { text } from "stream/consumers"
import { Tool } from "./tool"
import DESCRIPTION from "./bash.txt"
import { App } from "../app/app"
@@ -130,8 +130,35 @@ export const BashTool = Tool.define("bash", {
timeout,
})
const stdoutPromise = text(process.stdout!)
const stderrPromise = text(process.stderr!)
let output = ""
// Initialize metadata with empty output
ctx.metadata({
metadata: {
output: "",
description: params.description,
},
})
process.stdout?.on("data", (chunk) => {
output += chunk.toString()
ctx.metadata({
metadata: {
output: output,
description: params.description,
},
})
})
process.stderr?.on("data", (chunk) => {
output += chunk.toString()
ctx.metadata({
metadata: {
output: output,
description: params.description,
},
})
})
await new Promise<void>((resolve) => {
process.on("close", () => {
@@ -139,18 +166,22 @@ export const BashTool = Tool.define("bash", {
})
})
const stdout = await stdoutPromise
const stderr = await stderrPromise
ctx.metadata({
metadata: {
output: output,
exit: process.exitCode,
description: params.description,
},
})
return {
title: params.command,
metadata: {
stderr,
stdout,
output,
exit: process.exitCode,
description: params.description,
},
output: [`<stdout>`, stdout ?? "", `</stdout>`, `<stderr>`, stderr ?? "", `</stderr>`].join("\n"),
output,
}
},
})

View File

@@ -27,7 +27,7 @@ describe("tool.bash", () => {
ctx,
)
expect(result.metadata.exit).toBe(0)
expect(result.metadata.stdout).toContain("test")
expect(result.metadata.output).toContain("test")
})
})

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/plugin",
"version": "0.4.3",
"version": "0.4.13",
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit"

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/sdk",
"version": "0.4.3",
"version": "0.4.13",
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit"

View File

@@ -22,15 +22,18 @@ export type Event =
| ({
type: "storage.write"
} & EventStorageWrite)
| ({
type: "file.edited"
} & EventFileEdited)
| ({
type: "server.connected"
} & EventServerConnected)
| ({
type: "permission.updated"
} & EventPermissionUpdated)
| ({
type: "permission.replied"
} & EventPermissionReplied)
| ({
type: "file.edited"
} & EventFileEdited)
| ({
type: "session.updated"
} & EventSessionUpdated)
@@ -43,9 +46,6 @@ export type Event =
| ({
type: "session.error"
} & EventSessionError)
| ({
type: "server.connected"
} & EventServerConnected)
| ({
type: "file.watcher.updated"
} & EventFileWatcherUpdated)
@@ -425,6 +425,20 @@ export type EventStorageWrite = {
}
}
export type EventFileEdited = {
type: string
properties: {
file: string
}
}
export type EventServerConnected = {
type: string
properties: {
[key: string]: unknown
}
}
export type EventPermissionUpdated = {
type: string
properties: Permission
@@ -455,13 +469,6 @@ export type EventPermissionReplied = {
}
}
export type EventFileEdited = {
type: string
properties: {
file: string
}
}
export type EventSessionUpdated = {
type: string
properties: {
@@ -523,13 +530,6 @@ export type EventSessionError = {
}
}
export type EventServerConnected = {
type: string
properties: {
[key: string]: unknown
}
}
export type EventFileWatcherUpdated = {
type: string
properties: {
@@ -907,13 +907,17 @@ export type AgentConfig = {
* Description of when to use the agent
*/
description?: string
/**
* Additional model options passed through to provider
*/
options?: {
[key: string]: unknown
}
mode?: string
[key: string]:
| unknown
| string
| number
| {
[key: string]: boolean
}
| boolean
| string
| undefined
}
export type Provider = {
@@ -1053,9 +1057,6 @@ export type Agent = {
mode: string
topP?: number
temperature?: number
options: {
[key: string]: unknown
}
model?: {
modelID: string
providerID: string
@@ -1064,6 +1065,9 @@ export type Agent = {
tools: {
[key: string]: boolean
}
options: {
[key: string]: unknown
}
}
export type EventSubscribeData = {

View File

@@ -569,13 +569,9 @@ func renderToolDetails(
case "bash":
command := toolInputMap["command"].(string)
body = fmt.Sprintf("```console\n$ %s\n", command)
stdout := metadata["stdout"]
if stdout != nil {
body += ansi.Strip(fmt.Sprintf("%s", stdout))
}
stderr := metadata["stderr"]
if stderr != nil {
body += ansi.Strip(fmt.Sprintf("%s", stderr))
output := metadata["output"]
if output != nil {
body += ansi.Strip(fmt.Sprintf("%s", output))
}
body += "```"
body = util.ToMarkdown(body, width, backgroundColor)

View File

@@ -1,7 +1,7 @@
{
"name": "@opencode/web",
"type": "module",
"version": "0.4.3",
"version": "0.4.13",
"scripts": {
"dev": "astro dev",
"dev:remote": "sst shell --stage=dev --target=Web astro dev",

View File

@@ -605,7 +605,7 @@ export function BashTool(props: ToolProps) {
return (
<ContentBash
command={props.state.input.command}
output={props.state.metadata?.stdout || ""}
output={props.state.metadata.output ?? props.state.metadata?.stdout}
description={props.state.metadata.description}
/>
)

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bun
import { $ } from "bun"
import path from "path"
console.log("=== publishing ===\n")
@@ -38,10 +39,46 @@ await import(`../packages/sdk/js/script/publish.ts`)
console.log("\n=== plugin ===\n")
await import(`../packages/plugin/script/publish.ts`)
const dir = new URL("..", import.meta.url).pathname
process.chdir(dir)
if (!snapshot) {
await $`git commit -am "release: v${version}"`
await $`git tag v${version}`
await $`git push origin HEAD --tags --no-verify`
const previous = await fetch("https://api.github.com/repos/sst/opencode/releases/latest")
.then((res) => {
if (!res.ok) throw new Error(res.statusText)
return res.json()
})
.then((data) => data.tag_name)
console.log("finding commits between", previous, "and", "HEAD")
const commits = await fetch(`https://api.github.com/repos/sst/opencode/compare/${previous}...HEAD`)
.then((res) => res.json())
.then((data) => data.commits || [])
const raw = commits.map((commit: any) => `- ${commit.commit.message.split("\n").join(" ")}`)
console.log(raw)
const notes =
raw
.filter((x: string) => {
const lower = x.toLowerCase()
return (
!lower.includes("release:") &&
!lower.includes("ignore:") &&
!lower.includes("chore:") &&
!lower.includes("ci:") &&
!lower.includes("wip:") &&
!lower.includes("docs:") &&
!lower.includes("doc:")
)
})
.join("\n") || "No notable changes"
await $`gh release create v${version} --title "v${version}" --notes ${notes} ./packages/opencode/dist/*.zip`
}
if (snapshot) {
await $`git checkout -b snapshot-${version}`

View File

@@ -2,7 +2,7 @@
"name": "opencode",
"displayName": "opencode",
"description": "opencode for VS Code",
"version": "0.4.3",
"version": "0.4.13",
"publisher": "sst-dev",
"repository": {
"type": "git",