summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax <[email protected]>2026-03-19 21:17:06 -0400
committerGitHub <[email protected]>2026-03-19 21:17:06 -0400
commit52a7a04ad807acc577672f379e8e0cb327602e9d (patch)
tree3e888a08a4dffddcef6ded481bd1ee6aae4beb55
parent37b8662a9dec85a9c66e9679a34cbd09761a8b35 (diff)
downloadopencode-52a7a04ad807acc577672f379e8e0cb327602e9d.tar.gz
opencode-52a7a04ad807acc577672f379e8e0cb327602e9d.zip
refactor: replace Bun shell execution with portable Process utilities (#18318)
-rw-r--r--packages/opencode/src/mcp/index.ts11
-rw-r--r--packages/opencode/src/session/prompt.ts16
2 files changed, 11 insertions, 16 deletions
diff --git a/packages/opencode/src/mcp/index.ts b/packages/opencode/src/mcp/index.ts
index e48a42a8b..bf5a0d3ce 100644
--- a/packages/opencode/src/mcp/index.ts
+++ b/packages/opencode/src/mcp/index.ts
@@ -11,6 +11,7 @@ import {
} from "@modelcontextprotocol/sdk/types.js"
import { Config } from "../config/config"
import { Log } from "../util/log"
+import { Process } from "../util/process"
import { NamedError } from "@opencode-ai/util/error"
import z from "zod/v4"
import { Instance } from "../project/instance"
@@ -166,14 +167,10 @@ export namespace MCP {
const queue = [pid]
while (queue.length > 0) {
const current = queue.shift()!
- const proc = Bun.spawn(["pgrep", "-P", String(current)], { stdout: "pipe", stderr: "pipe" })
- const [code, out] = await Promise.all([proc.exited, new Response(proc.stdout).text()]).catch(
- () => [-1, ""] as const,
- )
- if (code !== 0) continue
- for (const tok of out.trim().split(/\s+/)) {
+ const lines = await Process.lines(["pgrep", "-P", String(current)], { nothrow: true })
+ for (const tok of lines) {
const cpid = parseInt(tok, 10)
- if (!isNaN(cpid) && pids.indexOf(cpid) === -1) {
+ if (!isNaN(cpid) && !pids.includes(cpid)) {
pids.push(cpid)
queue.push(cpid)
}
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index 36162656a..1cc144c8d 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -32,7 +32,6 @@ import { Flag } from "../flag/flag"
import { ulid } from "ulid"
import { spawn } from "child_process"
import { Command } from "../command"
-import { $ } from "bun"
import { pathToFileURL, fileURLToPath } from "url"
import { ConfigMarkdown } from "../config/markdown"
import { SessionSummary } from "./summary"
@@ -48,6 +47,7 @@ import { iife } from "@/util/iife"
import { Shell } from "@/shell/shell"
import { Truncate } from "@/tool/truncate"
import { decodeDataUrl } from "@/util/data-url"
+import { Process } from "@/util/process"
// @ts-ignore
globalThis.AI_SDK_LOG_WARNINGS = false
@@ -1812,15 +1812,13 @@ NOTE: At any point in time through this workflow you should feel free to ask the
template = template + "\n\n" + input.arguments
}
- const shell = ConfigMarkdown.shell(template)
- if (shell.length > 0) {
+ const shellMatches = ConfigMarkdown.shell(template)
+ if (shellMatches.length > 0) {
+ const sh = Shell.preferred()
const results = await Promise.all(
- shell.map(async ([, cmd]) => {
- try {
- return await $`${{ raw: cmd }}`.quiet().nothrow().text()
- } catch (error) {
- return `Error executing command: ${error instanceof Error ? error.message : String(error)}`
- }
+ shellMatches.map(async ([, cmd]) => {
+ const out = await Process.text([cmd], { shell: sh, nothrow: true })
+ return out.text
}),
)
let index = 0