Skip to content

Commit ac7a885

Browse files
chore: generate
1 parent 7f2b5ee commit ac7a885

23 files changed

Lines changed: 283 additions & 282 deletions

packages/opencode/src/cli/cmd/run/demo.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ import path from "path"
1818
import type { Event, ToolPart } from "@opencode-ai/sdk/v2"
1919
import { createSessionData, reduceSessionData, type SessionData } from "./session-data"
2020
import { writeSessionOutput } from "./stream"
21-
import type {
22-
FooterApi,
23-
PermissionReply,
24-
QuestionReject,
25-
QuestionReply,
26-
RunPrompt,
27-
StreamCommit,
28-
} from "./types"
21+
import type { FooterApi, PermissionReply, QuestionReject, QuestionReply, RunPrompt, StreamCommit } from "./types"
2922

3023
const KINDS = [
3124
"markdown",

packages/opencode/src/cli/cmd/run/footer.command.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,7 @@ function PanelShell(props: {
180180
children: JSX.Element
181181
}) {
182182
return (
183-
<box
184-
id={props.id}
185-
width="100%"
186-
flexDirection="column"
187-
backgroundColor="transparent"
188-
flexShrink={0}
189-
>
183+
<box id={props.id} width="100%" flexDirection="column" backgroundColor="transparent" flexShrink={0}>
190184
<box
191185
width="100%"
192186
flexDirection="column"
@@ -333,14 +327,14 @@ export function RunCommandMenuBody(props: {
333327
category: item.source === "mcp" ? "MCP Commands" : "Project Commands",
334328
name: item.name,
335329
display: item.name,
336-
footer: `/${item.name}`,
337-
keywords:
338-
item.source === "mcp"
339-
? `/${item.name} ${item.name} mcp ${item.description ?? ""}`
340-
: `/${item.name} ${item.name} ${item.description ?? ""}`,
341-
}) satisfies CommandEntry,
342-
)
343-
.sort((a, b) => categoryRank(a.category) - categoryRank(b.category) || a.display.localeCompare(b.display)),
330+
footer: `/${item.name}`,
331+
keywords:
332+
item.source === "mcp"
333+
? `/${item.name} ${item.name} mcp ${item.description ?? ""}`
334+
: `/${item.name} ${item.name} ${item.description ?? ""}`,
335+
}) satisfies CommandEntry,
336+
)
337+
.sort((a, b) => categoryRank(a.category) - categoryRank(b.category) || a.display.localeCompare(b.display)),
344338
{ action: "exit", category: "System", display: "Exit", footer: "/exit", keywords: "/exit exit" },
345339
]
346340
})

packages/opencode/src/cli/cmd/run/footer.menu.tsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,7 @@ export function RunFooterMenu(props: {
161161
return
162162
}
163163

164-
const dir =
165-
props.selected() === previous + 1 ? 1
166-
: props.selected() === previous - 1 ? -1
167-
: undefined
164+
const dir = props.selected() === previous + 1 ? 1 : props.selected() === previous - 1 ? -1 : undefined
168165
setGroupOffset((value) =>
169166
dir
170167
? moveOffset(value, { count: all.length, limit: limit(), selected, dir })
@@ -175,19 +172,28 @@ export function RunFooterMenu(props: {
175172

176173
const rows = createMemo<RunFooterMenuRow[]>(() => {
177174
if (!props.grouped) {
178-
return props.items().slice(props.offset(), props.offset() + limit()).map((item, index) => ({
179-
type: "item",
180-
item,
181-
index: index + props.offset(),
182-
}))
175+
return props
176+
.items()
177+
.slice(props.offset(), props.offset() + limit())
178+
.map((item, index) => ({
179+
type: "item",
180+
item,
181+
index: index + props.offset(),
182+
}))
183183
}
184184

185185
const all = groupedRows()
186186
const start = Math.max(0, Math.min(groupOffset(), all.length - limit()))
187187
return all.slice(start, start + limit())
188188
})
189189
const descriptionColumn = createMemo(() => {
190-
const width = Math.max(0, ...props.items().filter((item) => item.description).map((item) => Bun.stringWidth(item.display)))
190+
const width = Math.max(
191+
0,
192+
...props
193+
.items()
194+
.filter((item) => item.description)
195+
.map((item) => Bun.stringWidth(item.display)),
196+
)
191197
return width === 0 ? 0 : width + 2
192198
})
193199
const descriptionPad = (item: RunFooterMenuItem) => {
@@ -264,7 +270,12 @@ export function RunFooterMenu(props: {
264270
backgroundColor={active() ? props.theme().highlight : props.theme().surface}
265271
>
266272
<box width="100%" flexDirection="row" justifyContent="space-between" gap={1}>
267-
<text fg={active() ? props.theme().surface : props.theme().text} wrapMode="none" truncate flexGrow={1}>
273+
<text
274+
fg={active() ? props.theme().surface : props.theme().text}
275+
wrapMode="none"
276+
truncate
277+
flexGrow={1}
278+
>
268279
{row.item.display}
269280
{row.item.description ? (
270281
<span style={{ fg: active() ? props.theme().surface : props.theme().muted }}>
@@ -274,7 +285,12 @@ export function RunFooterMenu(props: {
274285
) : undefined}
275286
</text>
276287
{row.item.footer ? (
277-
<text fg={active() ? props.theme().surface : props.theme().muted} wrapMode="none" truncate flexShrink={0}>
288+
<text
289+
fg={active() ? props.theme().surface : props.theme().muted}
290+
wrapMode="none"
291+
truncate
292+
flexShrink={0}
293+
>
278294
{row.item.footer}
279295
</text>
280296
) : undefined}

packages/opencode/src/cli/cmd/run/footer.subagent.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ function statusIcon(status: FooterSubagentTab["status"]) {
3636
}
3737

3838
function tabText(tab: FooterSubagentTab, slot: string, count: number, width: number) {
39-
const perTab = Math.max(
40-
1,
41-
Math.floor((width - 4 - Math.max(0, count - 1) * 3) / Math.max(1, count)),
42-
)
39+
const perTab = Math.max(1, Math.floor((width - 4 - Math.max(0, count - 1) * 3) / Math.max(1, count)))
4340
if (count >= 8 || perTab < 12) {
4441
return `[${slot}]`
4542
}
@@ -96,7 +93,9 @@ export function RunFooterSubagentTabs(props: {
9693
flexDirection="row"
9794
flexShrink={0}
9895
>
99-
<box flexDirection="row" gap={3} flexShrink={1} flexGrow={1}>{items()}</box>
96+
<box flexDirection="row" gap={3} flexShrink={1} flexGrow={1}>
97+
{items()}
98+
</box>
10099
</box>
101100
)
102101
}

packages/opencode/src/cli/cmd/run/footer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,9 @@ export class RunFooter implements FooterApi {
567567
? 1 + tabs + MODEL_ROWS
568568
: this.promptRoute.type === "variant"
569569
? 1 + tabs + VARIANT_ROWS
570-
: this.promptRoute.type === "subagent"
571-
? this.base + tabs + SUBAGENT_INSPECTOR_ROWS
572-
: Math.max(base + TEXTAREA_MIN_ROWS, Math.min(base + PROMPT_MAX_ROWS, base + this.rows))
570+
: this.promptRoute.type === "subagent"
571+
? this.base + tabs + SUBAGENT_INSPECTOR_ROWS
572+
: Math.max(base + TEXTAREA_MIN_ROWS, Math.min(base + PROMPT_MAX_ROWS, base + this.rows))
573573

574574
if (height !== this.renderer.footerHeight) {
575575
this.renderer.footerHeight = height

packages/opencode/src/cli/cmd/run/otel.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,13 @@ export function withRunSpan<A>(
103103
attributes: attributes(input),
104104
})
105105

106-
return context.with(
107-
trace.setSpan(context.active(), span),
108-
() =>
109-
finish(
110-
span,
111-
new Promise<A>((resolve) => {
112-
resolve(fn(span))
113-
}),
114-
),
106+
return context.with(trace.setSpan(context.active(), span), () =>
107+
finish(
108+
span,
109+
new Promise<A>((resolve) => {
110+
resolve(fn(span))
111+
}),
112+
),
115113
)
116114
},
117115
() => fn(noop),

packages/opencode/src/cli/cmd/run/prompt.shared.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ export type PromptHistoryState = {
2323
draft: string
2424
}
2525

26-
export function promptInfo(event: {
27-
name: string
28-
ctrl?: boolean
29-
meta?: boolean
30-
shift?: boolean
31-
super?: boolean
32-
}) {
26+
export function promptInfo(event: { name: string; ctrl?: boolean; meta?: boolean; shift?: boolean; super?: boolean }) {
3327
return {
3428
name: event.name === " " ? "space" : event.name,
3529
ctrl: !!event.ctrl,
@@ -123,7 +117,11 @@ export function promptBindings(bindings: FooterKeybinds["commandList"], leader:
123117
})
124118
}
125119

126-
function mapInputBindings(bindings: FooterKeybinds["inputSubmit"], leader: string, action: "submit" | "newline"): KeyBinding[] {
120+
function mapInputBindings(
121+
bindings: FooterKeybinds["inputSubmit"],
122+
leader: string,
123+
action: "submit" | "newline",
124+
): KeyBinding[] {
127125
return promptBindings(bindings, leader).flatMap((key) => {
128126
if (key.leader) {
129127
return []

packages/opencode/src/cli/cmd/run/runtime.lifecycle.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,12 @@ export async function createRuntimeLifecycle(input: LifecycleInput): Promise<Lif
248248
process.on("SIGINT", sigint)
249249

250250
let closed = false
251-
const close = async (next: { showExit: boolean; sessionTitle?: string; sessionID?: string; history?: RunPrompt[] }) => {
251+
const close = async (next: {
252+
showExit: boolean
253+
sessionTitle?: string
254+
sessionID?: string
255+
history?: RunPrompt[]
256+
}) => {
252257
if (closed) {
253258
return
254259
}

packages/opencode/src/cli/cmd/run/runtime.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ type CreateSessionInput = {
3939
variant: string | undefined
4040
}
4141

42-
type CreateSession = (
43-
sdk: RunInput["sdk"],
44-
input: CreateSessionInput,
45-
) => Promise<{ id: string; title?: string }>
42+
type CreateSession = (sdk: RunInput["sdk"], input: CreateSessionInput) => Promise<{ id: string; title?: string }>
4643

4744
type RunRuntimeInput = {
4845
boot: () => Promise<BootContext>
@@ -548,9 +545,9 @@ async function runInteractiveRuntime(input: RunRuntimeInput): Promise<void> {
548545
state.sessionTitle = created.sessionTitle
549546
state.agent = created.agent ?? state.agent
550547
state.history = []
551-
includeFiles = true
552-
state.demo = input.demo
553-
? createRunDemo({
548+
includeFiles = true
549+
state.demo = input.demo
550+
? createRunDemo({
554551
footer,
555552
sessionID: state.sessionID,
556553
thinking: input.thinking,

packages/opencode/src/cli/cmd/run/scrollback.surface.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -118,37 +118,37 @@ export class RunScrollbackStream {
118118
const renderable =
119119
body.type === "text"
120120
? new TextRenderable(surface.renderContext, {
121-
id,
122-
content: "",
123-
width: "100%",
124-
wrapMode: "word",
125-
fg: style.fg,
126-
attributes: style.attrs,
127-
})
128-
: body.type === "code"
129-
? new CodeRenderable(surface.renderContext, {
130121
id,
131122
content: "",
132-
filetype: body.filetype,
133-
syntaxStyle: entrySyntax(commit, this.theme),
134123
width: "100%",
135124
wrapMode: "word",
136-
drawUnstyledText: false,
137-
streaming: true,
138-
fg: entryColor(commit, this.theme),
139-
treeSitterClient: this.treeSitterClient,
125+
fg: style.fg,
126+
attributes: style.attrs,
140127
})
128+
: body.type === "code"
129+
? new CodeRenderable(surface.renderContext, {
130+
id,
131+
content: "",
132+
filetype: body.filetype,
133+
syntaxStyle: entrySyntax(commit, this.theme),
134+
width: "100%",
135+
wrapMode: "word",
136+
drawUnstyledText: false,
137+
streaming: true,
138+
fg: entryColor(commit, this.theme),
139+
treeSitterClient: this.treeSitterClient,
140+
})
141141
: new MarkdownRenderable(surface.renderContext, {
142-
id,
143-
content: "",
144-
syntaxStyle: entrySyntax(commit, this.theme),
145-
width: "100%",
146-
streaming: true,
147-
internalBlockMode: "top-level",
148-
tableOptions: { widthMode: "content" },
149-
fg: entryColor(commit, this.theme),
150-
treeSitterClient: this.treeSitterClient,
151-
})
142+
id,
143+
content: "",
144+
syntaxStyle: entrySyntax(commit, this.theme),
145+
width: "100%",
146+
streaming: true,
147+
internalBlockMode: "top-level",
148+
tableOptions: { widthMode: "content" },
149+
fg: entryColor(commit, this.theme),
150+
treeSitterClient: this.treeSitterClient,
151+
})
152152

153153
surface.root.add(renderable)
154154

@@ -326,8 +326,7 @@ export class RunScrollbackStream {
326326

327327
if (
328328
body.type !== "structured" &&
329-
(entryCanStream(commit, body) ||
330-
(commit.kind === "tool" && commit.phase === "final" && body.type === "markdown"))
329+
(entryCanStream(commit, body) || (commit.kind === "tool" && commit.phase === "final" && body.type === "markdown"))
331330
) {
332331
await this.writeStreaming(commit, body)
333332
if (entryDone(commit)) {

0 commit comments

Comments
 (0)