mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
Add packages/cli-rs, an OpenCode client written in Rust on OpenTUI's Rust crates. It is a client only.
18 lines
688 B
TypeScript
18 lines
688 B
TypeScript
// Exercises descendant cleanup, including a process that leaves the host's process group.
|
|
|
|
import { writeFileSync } from "node:fs"
|
|
|
|
export default {
|
|
id: "example.spawner",
|
|
async setup(api: any) {
|
|
const carrier = api[Symbol.for("opencode.carrier")]
|
|
const child = Bun.spawn(["sleep", "60"])
|
|
const shell = Bun.spawn(["sh", "-c", "setsid sleep 61 >/dev/null 2>&1 </dev/null & echo $!"], { stdout: "pipe" })
|
|
const escaped = (await new Response(shell.stdout).text()).trim()
|
|
await shell.exited
|
|
writeFileSync(api.options.pids, `${child.pid} ${escaped}`)
|
|
carrier.command({ name: "spawner.spin", title: "spawner.spin" }, () => {
|
|
while (true) {}
|
|
})
|
|
},
|
|
}
|