Skip to content

Instantly share code, notes, and snippets.

@jlongster
Last active August 27, 2026 12:39
Show Gist options
  • Select an option

  • Save jlongster/8931cd754d740f36ee4108a9609313e4 to your computer and use it in GitHub Desktop.

Select an option

Save jlongster/8931cd754d740f36ee4108a9609313e4 to your computer and use it in GitHub Desktop.
OpenCode TUI shell completion jump demo
import { defineScript, Effect, Llm } from "opencode-drive"
export default defineScript({
config: {
permission: {
shell: "allow",
external_directory: "allow",
},
},
tuiConfig: {
theme: "opencode",
},
project: {
git: true,
files: {
"README.md": "# Shell jump demo\n",
},
},
run: ({ ui, llm }) =>
Effect.gen(function* () {
yield* ui.resize({ cols: 100, rows: 28 })
yield* llm.queue(
Llm.text("I will start the build in the background."),
Llm.toolCall({
index: 0,
id: "call_shell_jump_demo",
name: "shell",
input: {
command: "printf 'background shell started\\n'; sleep 2; printf 'background shell complete\\n'",
background: true,
},
}),
Llm.finish("tool-calls"),
)
yield* llm.queue(
Llm.text(
Array.from({ length: 30 }, (_, index) =>
`Build preparation ${index + 1}: validating deterministic demo fixture.`,
).join("\n\n"),
{ delay: 8, chunkSize: 24 },
),
)
yield* llm.queue(Llm.text("The background build notification was received."))
yield* ui.submit("Start the demo build in the background and continue preparing it.")
yield* ui.waitFor("Shell finished", { timeout: 20_000 })
yield* Effect.sleep(1_000)
yield* ui.screenshot("shell-finished")
const completion = yield* ui.getElement("shell-completion:call_shell_jump_demo")
yield* ui.click(completion)
yield* ui.waitFor("background shell started", { timeout: 10_000 })
yield* Effect.sleep(1_500)
yield* ui.screenshot("shell-start")
}),
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment