From ac7a885ae9d134571d332e11a12b184bde92507f Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Fri, 8 May 2026 10:18:22 +0000 Subject: [PATCH] chore: generate --- packages/opencode/src/cli/cmd/run/demo.ts | 9 +- .../src/cli/cmd/run/footer.command.tsx | 24 ++-- .../opencode/src/cli/cmd/run/footer.menu.tsx | 40 ++++-- .../src/cli/cmd/run/footer.subagent.tsx | 9 +- packages/opencode/src/cli/cmd/run/footer.ts | 6 +- packages/opencode/src/cli/cmd/run/otel.ts | 16 +-- .../opencode/src/cli/cmd/run/prompt.shared.ts | 14 +- .../src/cli/cmd/run/runtime.lifecycle.ts | 7 +- packages/opencode/src/cli/cmd/run/runtime.ts | 11 +- .../src/cli/cmd/run/scrollback.surface.ts | 53 ++++--- .../src/cli/cmd/run/scrollback.writer.tsx | 7 +- .../opencode/src/cli/cmd/run/session-data.ts | 5 +- packages/opencode/src/cli/cmd/run/splash.ts | 10 +- .../src/cli/cmd/run/stream.transport.ts | 11 +- .../src/cli/cmd/run/variant.shared.ts | 10 +- .../opencode/test/cli/run/entry.body.test.ts | 20 +-- .../test/cli/run/footer.view.test.tsx | 131 ++++++++++-------- .../test/cli/run/runtime.boot.test.ts | 7 +- .../test/cli/run/scrollback.surface.test.ts | 19 ++- .../test/cli/run/session-data.test.ts | 15 +- .../test/cli/run/stream.transport.test.ts | 113 +++++++-------- packages/opencode/test/cli/run/theme.test.ts | 23 ++- .../test/cli/run/variant.shared.test.ts | 5 +- 23 files changed, 283 insertions(+), 282 deletions(-) diff --git a/packages/opencode/src/cli/cmd/run/demo.ts b/packages/opencode/src/cli/cmd/run/demo.ts index 195ef6f496..d0d72ce002 100644 --- a/packages/opencode/src/cli/cmd/run/demo.ts +++ b/packages/opencode/src/cli/cmd/run/demo.ts @@ -18,14 +18,7 @@ import path from "path" import type { Event, ToolPart } from "@opencode-ai/sdk/v2" import { createSessionData, reduceSessionData, type SessionData } from "./session-data" import { writeSessionOutput } from "./stream" -import type { - FooterApi, - PermissionReply, - QuestionReject, - QuestionReply, - RunPrompt, - StreamCommit, -} from "./types" +import type { FooterApi, PermissionReply, QuestionReject, QuestionReply, RunPrompt, StreamCommit } from "./types" const KINDS = [ "markdown", diff --git a/packages/opencode/src/cli/cmd/run/footer.command.tsx b/packages/opencode/src/cli/cmd/run/footer.command.tsx index 9e964d02bc..4da370eabe 100644 --- a/packages/opencode/src/cli/cmd/run/footer.command.tsx +++ b/packages/opencode/src/cli/cmd/run/footer.command.tsx @@ -180,13 +180,7 @@ function PanelShell(props: { children: JSX.Element }) { return ( - + categoryRank(a.category) - categoryRank(b.category) || a.display.localeCompare(b.display)), + footer: `/${item.name}`, + keywords: + item.source === "mcp" + ? `/${item.name} ${item.name} mcp ${item.description ?? ""}` + : `/${item.name} ${item.name} ${item.description ?? ""}`, + }) satisfies CommandEntry, + ) + .sort((a, b) => categoryRank(a.category) - categoryRank(b.category) || a.display.localeCompare(b.display)), { action: "exit", category: "System", display: "Exit", footer: "/exit", keywords: "/exit exit" }, ] }) diff --git a/packages/opencode/src/cli/cmd/run/footer.menu.tsx b/packages/opencode/src/cli/cmd/run/footer.menu.tsx index 7a3332165b..c3770b27b0 100644 --- a/packages/opencode/src/cli/cmd/run/footer.menu.tsx +++ b/packages/opencode/src/cli/cmd/run/footer.menu.tsx @@ -161,10 +161,7 @@ export function RunFooterMenu(props: { return } - const dir = - props.selected() === previous + 1 ? 1 - : props.selected() === previous - 1 ? -1 - : undefined + const dir = props.selected() === previous + 1 ? 1 : props.selected() === previous - 1 ? -1 : undefined setGroupOffset((value) => dir ? moveOffset(value, { count: all.length, limit: limit(), selected, dir }) @@ -175,11 +172,14 @@ export function RunFooterMenu(props: { const rows = createMemo(() => { if (!props.grouped) { - return props.items().slice(props.offset(), props.offset() + limit()).map((item, index) => ({ - type: "item", - item, - index: index + props.offset(), - })) + return props + .items() + .slice(props.offset(), props.offset() + limit()) + .map((item, index) => ({ + type: "item", + item, + index: index + props.offset(), + })) } const all = groupedRows() @@ -187,7 +187,13 @@ export function RunFooterMenu(props: { return all.slice(start, start + limit()) }) const descriptionColumn = createMemo(() => { - const width = Math.max(0, ...props.items().filter((item) => item.description).map((item) => Bun.stringWidth(item.display))) + const width = Math.max( + 0, + ...props + .items() + .filter((item) => item.description) + .map((item) => Bun.stringWidth(item.display)), + ) return width === 0 ? 0 : width + 2 }) const descriptionPad = (item: RunFooterMenuItem) => { @@ -264,7 +270,12 @@ export function RunFooterMenu(props: { backgroundColor={active() ? props.theme().highlight : props.theme().surface} > - + {row.item.display} {row.item.description ? ( @@ -274,7 +285,12 @@ export function RunFooterMenu(props: { ) : undefined} {row.item.footer ? ( - + {row.item.footer} ) : undefined} diff --git a/packages/opencode/src/cli/cmd/run/footer.subagent.tsx b/packages/opencode/src/cli/cmd/run/footer.subagent.tsx index 02c9c0a6d7..0cd1367249 100644 --- a/packages/opencode/src/cli/cmd/run/footer.subagent.tsx +++ b/packages/opencode/src/cli/cmd/run/footer.subagent.tsx @@ -36,10 +36,7 @@ function statusIcon(status: FooterSubagentTab["status"]) { } function tabText(tab: FooterSubagentTab, slot: string, count: number, width: number) { - const perTab = Math.max( - 1, - Math.floor((width - 4 - Math.max(0, count - 1) * 3) / Math.max(1, count)), - ) + const perTab = Math.max(1, Math.floor((width - 4 - Math.max(0, count - 1) * 3) / Math.max(1, count))) if (count >= 8 || perTab < 12) { return `[${slot}]` } @@ -96,7 +93,9 @@ export function RunFooterSubagentTabs(props: { flexDirection="row" flexShrink={0} > - {items()} + + {items()} + ) } diff --git a/packages/opencode/src/cli/cmd/run/footer.ts b/packages/opencode/src/cli/cmd/run/footer.ts index b98323385b..8fe353a588 100644 --- a/packages/opencode/src/cli/cmd/run/footer.ts +++ b/packages/opencode/src/cli/cmd/run/footer.ts @@ -567,9 +567,9 @@ export class RunFooter implements FooterApi { ? 1 + tabs + MODEL_ROWS : this.promptRoute.type === "variant" ? 1 + tabs + VARIANT_ROWS - : this.promptRoute.type === "subagent" - ? this.base + tabs + SUBAGENT_INSPECTOR_ROWS - : Math.max(base + TEXTAREA_MIN_ROWS, Math.min(base + PROMPT_MAX_ROWS, base + this.rows)) + : this.promptRoute.type === "subagent" + ? this.base + tabs + SUBAGENT_INSPECTOR_ROWS + : Math.max(base + TEXTAREA_MIN_ROWS, Math.min(base + PROMPT_MAX_ROWS, base + this.rows)) if (height !== this.renderer.footerHeight) { this.renderer.footerHeight = height diff --git a/packages/opencode/src/cli/cmd/run/otel.ts b/packages/opencode/src/cli/cmd/run/otel.ts index 56d9afd2f9..cd42447ec8 100644 --- a/packages/opencode/src/cli/cmd/run/otel.ts +++ b/packages/opencode/src/cli/cmd/run/otel.ts @@ -103,15 +103,13 @@ export function withRunSpan( attributes: attributes(input), }) - return context.with( - trace.setSpan(context.active(), span), - () => - finish( - span, - new Promise((resolve) => { - resolve(fn(span)) - }), - ), + return context.with(trace.setSpan(context.active(), span), () => + finish( + span, + new Promise((resolve) => { + resolve(fn(span)) + }), + ), ) }, () => fn(noop), diff --git a/packages/opencode/src/cli/cmd/run/prompt.shared.ts b/packages/opencode/src/cli/cmd/run/prompt.shared.ts index 0d840e17c4..1b639e6e7e 100644 --- a/packages/opencode/src/cli/cmd/run/prompt.shared.ts +++ b/packages/opencode/src/cli/cmd/run/prompt.shared.ts @@ -23,13 +23,7 @@ export type PromptHistoryState = { draft: string } -export function promptInfo(event: { - name: string - ctrl?: boolean - meta?: boolean - shift?: boolean - super?: boolean -}) { +export function promptInfo(event: { name: string; ctrl?: boolean; meta?: boolean; shift?: boolean; super?: boolean }) { return { name: event.name === " " ? "space" : event.name, ctrl: !!event.ctrl, @@ -123,7 +117,11 @@ export function promptBindings(bindings: FooterKeybinds["commandList"], leader: }) } -function mapInputBindings(bindings: FooterKeybinds["inputSubmit"], leader: string, action: "submit" | "newline"): KeyBinding[] { +function mapInputBindings( + bindings: FooterKeybinds["inputSubmit"], + leader: string, + action: "submit" | "newline", +): KeyBinding[] { return promptBindings(bindings, leader).flatMap((key) => { if (key.leader) { return [] diff --git a/packages/opencode/src/cli/cmd/run/runtime.lifecycle.ts b/packages/opencode/src/cli/cmd/run/runtime.lifecycle.ts index c02f8fa5a5..eb342a7fda 100644 --- a/packages/opencode/src/cli/cmd/run/runtime.lifecycle.ts +++ b/packages/opencode/src/cli/cmd/run/runtime.lifecycle.ts @@ -248,7 +248,12 @@ export async function createRuntimeLifecycle(input: LifecycleInput): Promise { + const close = async (next: { + showExit: boolean + sessionTitle?: string + sessionID?: string + history?: RunPrompt[] + }) => { if (closed) { return } diff --git a/packages/opencode/src/cli/cmd/run/runtime.ts b/packages/opencode/src/cli/cmd/run/runtime.ts index 6e91195396..d811106bd8 100644 --- a/packages/opencode/src/cli/cmd/run/runtime.ts +++ b/packages/opencode/src/cli/cmd/run/runtime.ts @@ -39,10 +39,7 @@ type CreateSessionInput = { variant: string | undefined } -type CreateSession = ( - sdk: RunInput["sdk"], - input: CreateSessionInput, -) => Promise<{ id: string; title?: string }> +type CreateSession = (sdk: RunInput["sdk"], input: CreateSessionInput) => Promise<{ id: string; title?: string }> type RunRuntimeInput = { boot: () => Promise @@ -548,9 +545,9 @@ async function runInteractiveRuntime(input: RunRuntimeInput): Promise { state.sessionTitle = created.sessionTitle state.agent = created.agent ?? state.agent state.history = [] - includeFiles = true - state.demo = input.demo - ? createRunDemo({ + includeFiles = true + state.demo = input.demo + ? createRunDemo({ footer, sessionID: state.sessionID, thinking: input.thinking, diff --git a/packages/opencode/src/cli/cmd/run/scrollback.surface.ts b/packages/opencode/src/cli/cmd/run/scrollback.surface.ts index 7b01d140ad..41e4a913f2 100644 --- a/packages/opencode/src/cli/cmd/run/scrollback.surface.ts +++ b/packages/opencode/src/cli/cmd/run/scrollback.surface.ts @@ -118,37 +118,37 @@ export class RunScrollbackStream { const renderable = body.type === "text" ? new TextRenderable(surface.renderContext, { - id, - content: "", - width: "100%", - wrapMode: "word", - fg: style.fg, - attributes: style.attrs, - }) - : body.type === "code" - ? new CodeRenderable(surface.renderContext, { id, content: "", - filetype: body.filetype, - syntaxStyle: entrySyntax(commit, this.theme), width: "100%", wrapMode: "word", - drawUnstyledText: false, - streaming: true, - fg: entryColor(commit, this.theme), - treeSitterClient: this.treeSitterClient, + fg: style.fg, + attributes: style.attrs, }) + : body.type === "code" + ? new CodeRenderable(surface.renderContext, { + id, + content: "", + filetype: body.filetype, + syntaxStyle: entrySyntax(commit, this.theme), + width: "100%", + wrapMode: "word", + drawUnstyledText: false, + streaming: true, + fg: entryColor(commit, this.theme), + treeSitterClient: this.treeSitterClient, + }) : new MarkdownRenderable(surface.renderContext, { - id, - content: "", - syntaxStyle: entrySyntax(commit, this.theme), - width: "100%", - streaming: true, - internalBlockMode: "top-level", - tableOptions: { widthMode: "content" }, - fg: entryColor(commit, this.theme), - treeSitterClient: this.treeSitterClient, - }) + id, + content: "", + syntaxStyle: entrySyntax(commit, this.theme), + width: "100%", + streaming: true, + internalBlockMode: "top-level", + tableOptions: { widthMode: "content" }, + fg: entryColor(commit, this.theme), + treeSitterClient: this.treeSitterClient, + }) surface.root.add(renderable) @@ -326,8 +326,7 @@ export class RunScrollbackStream { if ( body.type !== "structured" && - (entryCanStream(commit, body) || - (commit.kind === "tool" && commit.phase === "final" && body.type === "markdown")) + (entryCanStream(commit, body) || (commit.kind === "tool" && commit.phase === "final" && body.type === "markdown")) ) { await this.writeStreaming(commit, body) if (entryDone(commit)) { diff --git a/packages/opencode/src/cli/cmd/run/scrollback.writer.tsx b/packages/opencode/src/cli/cmd/run/scrollback.writer.tsx index 66ae6a2560..94c136415d 100644 --- a/packages/opencode/src/cli/cmd/run/scrollback.writer.tsx +++ b/packages/opencode/src/cli/cmd/run/scrollback.writer.tsx @@ -55,7 +55,12 @@ export function entryLayout(commit: StreamCommit, body: RunEntryBody = entryBody return "block" } - if (commit.phase === "progress" && commit.toolState === "completed" && body.type === "text" && body.content.includes("\n")) { + if ( + commit.phase === "progress" && + commit.toolState === "completed" && + body.type === "text" && + body.content.includes("\n") + ) { return "block" } diff --git a/packages/opencode/src/cli/cmd/run/session-data.ts b/packages/opencode/src/cli/cmd/run/session-data.ts index af68b3750b..d3d61dd15e 100644 --- a/packages/opencode/src/cli/cmd/run/session-data.ts +++ b/packages/opencode/src/cli/cmd/run/session-data.ts @@ -205,10 +205,7 @@ function out(data: SessionData, commits: SessionCommit[], footer?: FooterOutput) } } -export function pickBlockerView(input: { - permission?: PermissionRequest - question?: QuestionRequest -}): FooterView { +export function pickBlockerView(input: { permission?: PermissionRequest; question?: QuestionRequest }): FooterView { if (input.permission) { return { type: "permission", request: input.permission } } diff --git a/packages/opencode/src/cli/cmd/run/splash.ts b/packages/opencode/src/cli/cmd/run/splash.ts index 37559e00c2..e0c8d93848 100644 --- a/packages/opencode/src/cli/cmd/run/splash.ts +++ b/packages/opencode/src/cli/cmd/run/splash.ts @@ -259,7 +259,15 @@ function build(input: SplashWriterInput, kind: "entry" | "exit", ctx: Scrollback } push(lines, body_left, top + 1, label, left, undefined, TextAttributes.DIM) - push(lines, body_left + label.length, top + 1, `opencode run -i -s ${meta.session_id}`, right, undefined, TextAttributes.BOLD) + push( + lines, + body_left + label.length, + top + 1, + `opencode run -i -s ${meta.session_id}`, + right, + undefined, + TextAttributes.BOLD, + ) height = top + mark.length } diff --git a/packages/opencode/src/cli/cmd/run/stream.transport.ts b/packages/opencode/src/cli/cmd/run/stream.transport.ts index 10e7c07527..d4b73ce6fa 100644 --- a/packages/opencode/src/cli/cmd/run/stream.transport.ts +++ b/packages/opencode/src/cli/cmd/run/stream.transport.ts @@ -189,9 +189,7 @@ function waitTurn(done: Wait["done"], signal: AbortSignal) { signal.addEventListener("abort", onAbort, { once: true }) return Effect.sync(() => signal.removeEventListener("abort", onAbort)) }).pipe(Effect.exit), - ]).pipe( - Effect.flatMap((exit) => (Exit.isFailure(exit) ? Effect.failCause(exit.cause) : Effect.succeed(exit.value))), - ) + ]).pipe(Effect.flatMap((exit) => (Exit.isFailure(exit) ? Effect.failCause(exit.cause) : Effect.succeed(exit.value)))) } export function formatUnknownError(error: unknown): string { @@ -380,7 +378,7 @@ function createLayer(input: StreamInput) { (events) => Effect.sync(() => { void events.stream.return(undefined).catch(() => {}) - }), + }), ), ) closeStream = () => { @@ -422,10 +420,7 @@ function createLayer(input: StreamInput) { return } - if ( - event.properties.sessionID !== input.sessionID && - !state.subagent.tabs.has(event.properties.sessionID) - ) { + if (event.properties.sessionID !== input.sessionID && !state.subagent.tabs.has(event.properties.sessionID)) { return } diff --git a/packages/opencode/src/cli/cmd/run/variant.shared.ts b/packages/opencode/src/cli/cmd/run/variant.shared.ts index 10ac5e6dae..9e95413e0b 100644 --- a/packages/opencode/src/cli/cmd/run/variant.shared.ts +++ b/packages/opencode/src/cli/cmd/run/variant.shared.ts @@ -178,10 +178,12 @@ function createLayer(fs = AppFileSystem.defaultLayer) { delete next[key] } - yield* file.writeJson(MODEL_FILE, { - ...current, - variant: next, - }).pipe(Effect.orElseSucceed(() => undefined)) + yield* file + .writeJson(MODEL_FILE, { + ...current, + variant: next, + }) + .pipe(Effect.orElseSucceed(() => undefined)) }) return Service.of({ diff --git a/packages/opencode/test/cli/run/entry.body.test.ts b/packages/opencode/test/cli/run/entry.body.test.ts index 58e6678293..b55549573c 100644 --- a/packages/opencode/test/cli/run/entry.body.test.ts +++ b/packages/opencode/test/cli/run/entry.body.test.ts @@ -191,8 +191,8 @@ describe("run entry body", () => { deletions: 0, }, ], - }, }, + }, ] satisfies Array<{ name: string; commit: StreamCommit; snapshot: ToolSnapshot }>) { test(item.name, () => { expect(structured(item.commit)).toEqual(item.snapshot) @@ -335,26 +335,16 @@ describe("run entry body", () => { tool: "bash", phase: "progress", toolState: "completed", - text: [ - "/tmp/demo", - "git status", - "On branch demo", - "nothing to commit, working tree clean", - "", - ].join("\n"), + text: ["/tmp/demo", "git status", "On branch demo", "nothing to commit, working tree clean", ""].join("\n"), state: { status: "completed", input: { command: "git status", workdir: "/tmp/demo", }, - output: [ - "/tmp/demo", - "git status", - "On branch demo", - "nothing to commit, working tree clean", - "", - ].join("\n"), + output: ["/tmp/demo", "git status", "On branch demo", "nothing to commit, working tree clean", ""].join( + "\n", + ), title: "git status", metadata: { exitCode: 0, diff --git a/packages/opencode/test/cli/run/footer.view.test.tsx b/packages/opencode/test/cli/run/footer.view.test.tsx index a54375b681..06f5d93cae 100644 --- a/packages/opencode/test/cli/run/footer.view.test.tsx +++ b/packages/opencode/test/cli/run/footer.view.test.tsx @@ -2,7 +2,12 @@ import { expect, test } from "bun:test" import { testRender } from "@opentui/solid" import { createSignal } from "solid-js" -import { RUN_COMMAND_PANEL_ROWS, RunCommandMenuBody, RunModelSelectBody, RunVariantSelectBody } from "@/cli/cmd/run/footer.command" +import { + RUN_COMMAND_PANEL_ROWS, + RunCommandMenuBody, + RunModelSelectBody, + RunVariantSelectBody, +} from "@/cli/cmd/run/footer.command" import { RunEntryContent } from "@/cli/cmd/run/scrollback.writer" import { RUN_THEME_FALLBACK } from "@/cli/cmd/run/theme" import type { FooterKeybinds, RunCommand, RunInput, RunProvider, StreamCommit } from "@/cli/cmd/run/types" @@ -117,14 +122,17 @@ test("run entry content updates when live commit text changes", async () => { tool: "bash", }) - const app = await testRender(() => ( - - - - ), { - width: 80, - height: 4, - }) + const app = await testRender( + () => ( + + + + ), + { + width: 80, + height: 4, + }, + ) try { await app.renderOnce() @@ -155,26 +163,29 @@ test("direct command panel renders grouped command palette", async () => { ]) const [variants] = createSignal(["high", "minimal"]) - const app = await testRender(() => ( - - RUN_THEME_FALLBACK.footer} - commands={commands} - variants={variants} - keybinds={keybinds} - onClose={() => {}} - onModel={() => {}} - onVariant={() => {}} - onVariantCycle={() => {}} - onCommand={() => {}} - onNew={() => {}} - onExit={() => {}} - /> - - ), { - width: 100, - height: RUN_COMMAND_PANEL_ROWS, - }) + const app = await testRender( + () => ( + + RUN_THEME_FALLBACK.footer} + commands={commands} + variants={variants} + keybinds={keybinds} + onClose={() => {}} + onModel={() => {}} + onVariant={() => {}} + onVariantCycle={() => {}} + onCommand={() => {}} + onNew={() => {}} + onExit={() => {}} + /> + + ), + { + width: 100, + height: RUN_COMMAND_PANEL_ROWS, + }, + ) try { await app.renderOnce() @@ -207,20 +218,23 @@ test("direct model panel renders current model selector", async () => { const [providers] = createSignal([provider()]) const [current] = createSignal({ providerID: "opencode", modelID: "gpt-5" }) - const app = await testRender(() => ( - - RUN_THEME_FALLBACK.footer} - providers={providers} - current={current} - onClose={() => {}} - onSelect={() => {}} - /> - - ), { - width: 100, - height: RUN_COMMAND_PANEL_ROWS, - }) + const app = await testRender( + () => ( + + RUN_THEME_FALLBACK.footer} + providers={providers} + current={current} + onClose={() => {}} + onSelect={() => {}} + /> + + ), + { + width: 100, + height: RUN_COMMAND_PANEL_ROWS, + }, + ) try { await app.renderOnce() @@ -243,20 +257,23 @@ test("direct variant panel renders current variant selector", async () => { const [variants] = createSignal(["high", "minimal"]) const [current] = createSignal("high") - const app = await testRender(() => ( - - RUN_THEME_FALLBACK.footer} - variants={variants} - current={current} - onClose={() => {}} - onSelect={() => {}} - /> - - ), { - width: 100, - height: RUN_COMMAND_PANEL_ROWS, - }) + const app = await testRender( + () => ( + + RUN_THEME_FALLBACK.footer} + variants={variants} + current={current} + onClose={() => {}} + onSelect={() => {}} + /> + + ), + { + width: 100, + height: RUN_COMMAND_PANEL_ROWS, + }, + ) try { await app.renderOnce() diff --git a/packages/opencode/test/cli/run/runtime.boot.test.ts b/packages/opencode/test/cli/run/runtime.boot.test.ts index 2a8f928f9e..c0d66bf75d 100644 --- a/packages/opencode/test/cli/run/runtime.boot.test.ts +++ b/packages/opencode/test/cli/run/runtime.boot.test.ts @@ -7,11 +7,7 @@ import { TuiConfig, type Resolved } from "@/cli/cmd/tui/config/tui" import { formatBindings } from "@/cli/cmd/run/keymap.shared" import { KeymapSectionNames, keymapBindingDefaults, type KeymapSection } from "@/cli/cmd/tui/config/tui-schema" import { ConfigKeybinds } from "@/config/keybinds" -import { - resolveDiffStyle, - resolveFooterKeybinds, - resolveModelInfo, -} from "@/cli/cmd/run/runtime.boot" +import { resolveDiffStyle, resolveFooterKeybinds, resolveModelInfo } from "@/cli/cmd/run/runtime.boot" type RunBinding = Binding @@ -299,5 +295,4 @@ describe("run runtime boot", () => { }, }) }) - }) diff --git a/packages/opencode/test/cli/run/scrollback.surface.test.ts b/packages/opencode/test/cli/run/scrollback.surface.test.ts index ac63b3f388..5b2966a5e1 100644 --- a/packages/opencode/test/cli/run/scrollback.surface.test.ts +++ b/packages/opencode/test/cli/run/scrollback.surface.test.ts @@ -58,10 +58,12 @@ function destroy(commits: ClaimedCommit[]) { } } -async function setup(input: { - width?: number - wrote?: boolean -} = {}) { +async function setup( + input: { + width?: number + wrote?: boolean + } = {}, +) { const out = await createTestRenderer({ width: input.width ?? 80, screenMode: "split-footer", @@ -150,7 +152,8 @@ function toolCommit(input: { } test("finalizes markdown tables for streamed and coalesced input", async () => { - const text = "| Column 1 | Column 2 | Column 3 |\n|---|---|---|\n| Row 1 | Value 1 | Value 2 |\n| Row 2 | Value 3 | Value 4 |" + const text = + "| Column 1 | Column 2 | Column 3 |\n|---|---|---|\n| Row 1 | Value 1 | Value 2 |\n| Row 2 | Value 3 | Value 4 |" for (const chunks of [[text], [...text]]) { const out = await setup() @@ -182,7 +185,9 @@ test("holds markdown code blocks until final commit and keeps newline ownership" try { await out.scrollback.append( - assistant('# Markdown Sample\n\n- Item 1\n- Item 2\n\n```js\nconst message = "Hello, markdown"\nconsole.log(message)\n```'), + assistant( + '# Markdown Sample\n\n- Item 1\n- Item 2\n\n```js\nconst message = "Hello, markdown"\nconsole.log(message)\n```', + ), ) const progress = claim(out.renderer) @@ -543,7 +548,7 @@ test("inserts a spacer before the next tool after completed multiline bash outpu take() const output = lines.join("\n") - expect(output).toContain("total 4\n\n✱ Glob \"**/*tool*\" in src/cli/cmd") + expect(output).toContain('total 4\n\n✱ Glob "**/*tool*" in src/cli/cmd') } finally { out.scrollback.destroy() } diff --git a/packages/opencode/test/cli/run/session-data.test.ts b/packages/opencode/test/cli/run/session-data.test.ts index fd80a2de71..439d988be9 100644 --- a/packages/opencode/test/cli/run/session-data.test.ts +++ b/packages/opencode/test/cli/run/session-data.test.ts @@ -48,12 +48,7 @@ function user(id: string) { } } -function text(input: { - id: string - messageID: string - text: string - time?: Record -}) { +function text(input: { id: string; messageID: string; text: string; time?: Record }) { return { type: "message.part.updated", properties: { @@ -98,13 +93,7 @@ function delta(messageID: string, partID: string, value: string) { } } -function tool(input: { - id: string - messageID: string - tool: string - state: Record - callID?: string -}) { +function tool(input: { id: string; messageID: string; tool: string; state: Record; callID?: string }) { return { type: "message.part.updated", properties: { diff --git a/packages/opencode/test/cli/run/stream.transport.test.ts b/packages/opencode/test/cli/run/stream.transport.test.ts index 10611c4822..dab5264bd6 100644 --- a/packages/opencode/test/cli/run/stream.transport.test.ts +++ b/packages/opencode/test/cli/run/stream.transport.test.ts @@ -144,11 +144,7 @@ function statusMap(busy: boolean): SessionStatusMap { return {} } -function assistantMessage(input: { - sessionID: string - id: string - parts: SessionMessage["parts"] -}): SessionMessage { +function assistantMessage(input: { sessionID: string; id: string; parts: SessionMessage["parts"] }): SessionMessage { return { info: { id: input.id, @@ -334,16 +330,18 @@ function footer(fn?: (commit: StreamCommit) => void) { return { api, commits, events } } -function sdk(input: { - stream?: EventStream - subscribe?: OpencodeClient["event"]["subscribe"] - promptAsync?: OpencodeClient["session"]["promptAsync"] - status?: OpencodeClient["session"]["status"] - messages?: OpencodeClient["session"]["messages"] - children?: OpencodeClient["session"]["children"] - permissions?: OpencodeClient["permission"]["list"] - questions?: OpencodeClient["question"]["list"] -} = {}) { +function sdk( + input: { + stream?: EventStream + subscribe?: OpencodeClient["event"]["subscribe"] + promptAsync?: OpencodeClient["session"]["promptAsync"] + status?: OpencodeClient["session"]["status"] + messages?: OpencodeClient["session"]["messages"] + children?: OpencodeClient["session"]["children"] + permissions?: OpencodeClient["permission"]["list"] + questions?: OpencodeClient["question"]["list"] + } = {}, +) { const client = new OpencodeClient() const subscribe: OpencodeClient["event"]["subscribe"] = input.subscribe ?? (() => sse(input.stream ?? emptyStream())) @@ -375,51 +373,52 @@ describe("run stream transport", () => { messages: async ({ sessionID }) => { if (sessionID === "session-1") { return ok([ - assistantMessage({ - sessionID: "session-1", - id: "msg-1", - parts: [ - runningTool({ - sessionID: "session-1", - messageID: "msg-1", - id: "task-1", - callID: "call-1", - tool: "task", - body: { - description: "Explore run folder", - subagent_type: "explore", - }, - metadata: { - sessionId: "child-1", - }, - }), - ], - }), - ]) - } - - return ok([ assistantMessage({ - sessionID: "child-1", - id: "msg-child-1", + sessionID: "session-1", + id: "msg-1", parts: [ runningTool({ - sessionID: "child-1", - messageID: "msg-child-1", - id: "edit-1", - callID: "call-edit-1", - tool: "edit", + sessionID: "session-1", + messageID: "msg-1", + id: "task-1", + callID: "call-1", + tool: "task", body: { - filePath: "src/run/subagent-data.ts", - diff: "@@ -1 +1 @@", + description: "Explore run folder", + subagent_type: "explore", + }, + metadata: { + sessionId: "child-1", }, }), ], }), ]) + } + + return ok([ + assistantMessage({ + sessionID: "child-1", + id: "msg-child-1", + parts: [ + runningTool({ + sessionID: "child-1", + messageID: "msg-child-1", + id: "edit-1", + callID: "call-edit-1", + tool: "edit", + body: { + filePath: "src/run/subagent-data.ts", + diff: "@@ -1 +1 @@", + }, + }), + ], + }), + ]) }, children: async () => ok([child("child-1")]), - permissions: async () => ok([ + permissions: async () => + ok([ { id: "perm-1", sessionID: "child-1", @@ -743,7 +742,8 @@ describe("run stream transport", () => { expect( ui.events.some( - (event) => event.type === "stream.view" && event.view.type === "question" && event.view.request.id === request.id, + (event) => + event.type === "stream.view" && event.view.type === "question" && event.view.request.id === request.id, ), ).toBe(false) @@ -982,11 +982,14 @@ describe("run stream transport", () => { const transport = await createSessionTransport({ sdk: sdk({ - subscribe: () => sse((async function* (): AsyncGenerator { - await ready.promise - yield busy() - throw new Error("boom") - })()), + subscribe: () => + sse( + (async function* (): AsyncGenerator { + await ready.promise + yield busy() + throw new Error("boom") + })(), + ), promptAsync: async () => { ready.resolve() return ok(undefined) diff --git a/packages/opencode/test/cli/run/theme.test.ts b/packages/opencode/test/cli/run/theme.test.ts index 42e3e02d7b..0d82ba7f19 100644 --- a/packages/opencode/test/cli/run/theme.test.ts +++ b/packages/opencode/test/cli/run/theme.test.ts @@ -2,16 +2,7 @@ import { expect, test } from "bun:test" import { RGBA, type CliRenderer, type TerminalColors } from "@opentui/core" import { RUN_THEME_FALLBACK, generateSystem, resolveRunTheme, resolveTheme } from "@/cli/cmd/run/theme" -const palette = [ - "#15161e", - "#f7768e", - "#9ece6a", - "#e0af68", - "#7aa2f7", - "#bb9af7", - "#7dcfff", - "#c0caf5", -] as const +const palette = ["#15161e", "#f7768e", "#9ece6a", "#e0af68", "#7aa2f7", "#bb9af7", "#7dcfff", "#c0caf5"] as const function terminalColors(input: Partial = {}): TerminalColors { return { @@ -28,11 +19,13 @@ function terminalColors(input: Partial = {}): TerminalColors { } } -function renderer(input: { - themeMode?: "dark" | "light" - colors?: TerminalColors - fail?: boolean -} = {}) { +function renderer( + input: { + themeMode?: "dark" | "light" + colors?: TerminalColors + fail?: boolean + } = {}, +) { return { themeMode: input.themeMode, getPalette: async () => { diff --git a/packages/opencode/test/cli/run/variant.shared.test.ts b/packages/opencode/test/cli/run/variant.shared.test.ts index e7e7a2a0b1..9fa41be320 100644 --- a/packages/opencode/test/cli/run/variant.shared.test.ts +++ b/packages/opencode/test/cli/run/variant.shared.test.ts @@ -79,7 +79,10 @@ const providers: RunProvider[] = [ }, ] -function userMessage(id: string, input: { providerID: string; modelID: string; variant?: string }): SessionMessages[number] { +function userMessage( + id: string, + input: { providerID: string; modelID: string; variant?: string }, +): SessionMessages[number] { return { info: { id,