summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bun.lock10
-rw-r--r--packages/plugin/src/index.ts4
-rw-r--r--packages/plugin/src/shell.ts136
-rwxr-xr-xscript/publish.ts1
4 files changed, 144 insertions, 7 deletions
diff --git a/bun.lock b/bun.lock
index 85515308e..db59359b6 100644
--- a/bun.lock
+++ b/bun.lock
@@ -10,7 +10,7 @@
},
"packages/function": {
"name": "@opencode/function",
- "version": "0.3.128",
+ "version": "0.3.129",
"dependencies": {
"@ai-sdk/anthropic": "2.0.0",
"@ai-sdk/openai": "2.0.2",
@@ -30,7 +30,7 @@
},
"packages/opencode": {
"name": "opencode",
- "version": "0.3.128",
+ "version": "0.3.129",
"bin": {
"opencode": "./bin/opencode",
},
@@ -83,7 +83,7 @@
},
"packages/plugin": {
"name": "@opencode-ai/plugin",
- "version": "0.3.128",
+ "version": "0.3.129",
"dependencies": {
"@opencode-ai/sdk": "workspace:*",
},
@@ -95,7 +95,7 @@
},
"packages/sdk/js": {
"name": "@opencode-ai/sdk",
- "version": "0.3.128",
+ "version": "0.3.129",
"devDependencies": {
"@hey-api/openapi-ts": "0.80.1",
"@tsconfig/node22": "catalog:",
@@ -104,7 +104,7 @@
},
"packages/web": {
"name": "@opencode/web",
- "version": "0.3.128",
+ "version": "0.3.129",
"dependencies": {
"@astrojs/cloudflare": "^12.5.4",
"@astrojs/markdown-remark": "6.3.1",
diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts
index be9822ee2..d0d484a00 100644
--- a/packages/plugin/src/index.ts
+++ b/packages/plugin/src/index.ts
@@ -1,10 +1,10 @@
import type { Event, createOpencodeClient, App, Model, Provider, Permission, UserMessage, Part } from "@opencode-ai/sdk"
-import { $ } from "bun"
+import type { BunShell } from "./shell"
export type PluginInput = {
client: ReturnType<typeof createOpencodeClient>
app: App
- $: $
+ $: BunShell
}
export type Plugin = (input: PluginInput) => Promise<Hooks>
diff --git a/packages/plugin/src/shell.ts b/packages/plugin/src/shell.ts
new file mode 100644
index 000000000..56733fdb3
--- /dev/null
+++ b/packages/plugin/src/shell.ts
@@ -0,0 +1,136 @@
+export type ShellFunction = (input: Uint8Array) => Uint8Array
+
+export type ShellExpression =
+ | { toString(): string }
+ | Array<ShellExpression>
+ | string
+ | { raw: string }
+ | ReadableStream
+
+export interface BunShell {
+ (strings: TemplateStringsArray, ...expressions: ShellExpression[]): BunShellPromise
+
+ /**
+ * Perform bash-like brace expansion on the given pattern.
+ * @param pattern - Brace pattern to expand
+ */
+ braces(pattern: string): string[]
+
+ /**
+ * Escape strings for input into shell commands.
+ */
+ escape(input: string): string
+
+ /**
+ * Change the default environment variables for shells created by this instance.
+ */
+ env(newEnv?: Record<string, string | undefined>): BunShell
+
+ /**
+ * Default working directory to use for shells created by this instance.
+ */
+ cwd(newCwd?: string): BunShell
+
+ /**
+ * Configure the shell to not throw an exception on non-zero exit codes.
+ */
+ nothrow(): BunShell
+
+ /**
+ * Configure whether or not the shell should throw an exception on non-zero exit codes.
+ */
+ throws(shouldThrow: boolean): BunShell
+}
+
+export interface BunShellPromise extends Promise<BunShellOutput> {
+ readonly stdin: WritableStream
+
+ /**
+ * Change the current working directory of the shell.
+ */
+ cwd(newCwd: string): this
+
+ /**
+ * Set environment variables for the shell.
+ */
+ env(newEnv: Record<string, string> | undefined): this
+
+ /**
+ * By default, the shell will write to the current process's stdout and stderr, as well as buffering that output.
+ * This configures the shell to only buffer the output.
+ */
+ quiet(): this
+
+ /**
+ * Read from stdout as a string, line by line
+ * Automatically calls quiet() to disable echoing to stdout.
+ */
+ lines(): AsyncIterable<string>
+
+ /**
+ * Read from stdout as a string.
+ * Automatically calls quiet() to disable echoing to stdout.
+ */
+ text(encoding?: BufferEncoding): Promise<string>
+
+ /**
+ * Read from stdout as a JSON object
+ * Automatically calls quiet()
+ */
+ json(): Promise<any>
+
+ /**
+ * Read from stdout as an ArrayBuffer
+ * Automatically calls quiet()
+ */
+ arrayBuffer(): Promise<ArrayBuffer>
+
+ /**
+ * Read from stdout as a Blob
+ * Automatically calls quiet()
+ */
+ blob(): Promise<Blob>
+
+ /**
+ * Configure the shell to not throw an exception on non-zero exit codes.
+ */
+ nothrow(): this
+
+ /**
+ * Configure whether or not the shell should throw an exception on non-zero exit codes.
+ */
+ throws(shouldThrow: boolean): this
+}
+
+export interface BunShellOutput {
+ readonly stdout: Buffer
+ readonly stderr: Buffer
+ readonly exitCode: number
+
+ /**
+ * Read from stdout as a string
+ */
+ text(encoding?: BufferEncoding): string
+
+ /**
+ * Read from stdout as a JSON object
+ */
+ json(): any
+
+ /**
+ * Read from stdout as an ArrayBuffer
+ */
+ arrayBuffer(): ArrayBuffer
+
+ /**
+ * Read from stdout as an Uint8Array
+ */
+ bytes(): Uint8Array
+
+ /**
+ * Read from stdout as a Blob
+ */
+ blob(): Blob
+}
+
+export type BunShellError = Error & BunShellOutput
diff --git a/script/publish.ts b/script/publish.ts
index 066f90e4d..7a48749d1 100755
--- a/script/publish.ts
+++ b/script/publish.ts
@@ -27,6 +27,7 @@ for (const file of pkgjsons) {
console.log("updated:", file)
await Bun.file(file).write(pkg)
}
+await $`bun install`
console.log("\n=== opencode ===\n")
await import(`../packages/opencode/script/publish.ts`)