Skip to content

Commit 13006d6

Browse files
chore: generate
1 parent 539b118 commit 13006d6

2 files changed

Lines changed: 97 additions & 90 deletions

File tree

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,7 @@ export function createPromptState(input: PromptInput): PromptState {
283283
const [shell, setShell] = createSignal(false)
284284
const placeholder = createMemo(() => {
285285
if (shell()) {
286-
return new StyledText([
287-
bg(input.theme().surface)(fg(input.theme().muted)('Run a command... "git status"')),
288-
])
286+
return new StyledText([bg(input.theme().surface)(fg(input.theme().muted)('Run a command... "git status"'))])
289287
}
290288

291289
if (!input.state().first) {
@@ -1087,7 +1085,8 @@ export function createPromptState(input: PromptInput): PromptState {
10871085
return
10881086
}
10891087

1090-
const parsed = next.mode === "shell" || isNewCommand(next.text) ? undefined : parseSlashCommand(next.text, input.commands())
1088+
const parsed =
1089+
next.mode === "shell" || isNewCommand(next.text) ? undefined : parseSlashCommand(next.text, input.commands())
10911090
if (parsed?.type === "pending") {
10921091
input.onStatus("loading commands")
10931092
return

packages/opencode/src/cli/cmd/run/stream.transport.ts

Lines changed: 94 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -515,14 +515,19 @@ function createLayer(input: StreamInput) {
515515
state.footerView = current
516516
}
517517

518-
const resolveShellAgent = Effect.fn("RunStreamTransport.resolveShellAgent")(function* (agent: string | undefined) {
518+
const resolveShellAgent = Effect.fn("RunStreamTransport.resolveShellAgent")(function* (
519+
agent: string | undefined,
520+
) {
519521
if (agent) {
520522
return agent
521523
}
522524

523525
const list = yield* Effect.promise(() =>
524526
input.sdk.app.agents(input.directory ? { directory: input.directory } : undefined, { throwOnError: true }),
525-
).pipe(Effect.map((item) => item.data ?? []), Effect.orElseSucceed(() => []))
527+
).pipe(
528+
Effect.map((item) => item.data ?? []),
529+
Effect.orElseSucceed(() => []),
530+
)
526531
const next = list.find((item) => item.mode !== "subagent" && item.hidden !== true)?.name
527532
if (next) {
528533
return next
@@ -1023,105 +1028,108 @@ function createLayer(input: StreamInput) {
10231028
],
10241029
}
10251030
const command = next.prompt.command
1026-
const send = next.prompt.mode === "shell"
1027-
? Effect.sync(() => {
1028-
input.trace?.write("send.shell", {
1029-
sessionID: input.sessionID,
1030-
command: next.prompt.text,
1031-
})
1032-
}).pipe(
1033-
Effect.andThen(
1034-
resolveShellAgent(next.agent).pipe(
1035-
Effect.flatMap((agent) =>
1031+
const send =
1032+
next.prompt.mode === "shell"
1033+
? Effect.sync(() => {
1034+
input.trace?.write("send.shell", {
1035+
sessionID: input.sessionID,
1036+
command: next.prompt.text,
1037+
})
1038+
}).pipe(
1039+
Effect.andThen(
1040+
resolveShellAgent(next.agent)
1041+
.pipe(
1042+
Effect.flatMap((agent) =>
1043+
Effect.promise(() =>
1044+
input.sdk.session.shell(
1045+
{
1046+
sessionID: input.sessionID,
1047+
agent,
1048+
model: next.model,
1049+
command: next.prompt.text,
1050+
},
1051+
{ signal: turn.signal, throwOnError: true },
1052+
),
1053+
),
1054+
),
1055+
)
1056+
.pipe(
1057+
Effect.tap(() =>
1058+
Effect.sync(() => {
1059+
input.trace?.write("send.shell.ok", {
1060+
sessionID: input.sessionID,
1061+
})
1062+
item.armed = true
1063+
item.live = true
1064+
}),
1065+
),
1066+
Effect.flatMap(() => Deferred.succeed(item.done, undefined).pipe(Effect.ignore)),
1067+
Effect.catch((error) => Deferred.fail(item.done, error).pipe(Effect.ignore)),
1068+
Effect.forkIn(scope, { startImmediately: true }),
1069+
Effect.asVoid,
1070+
),
1071+
),
1072+
)
1073+
: command
1074+
? Effect.sync(() => {
1075+
input.trace?.write("send.command", { sessionID: input.sessionID, command: command.name })
1076+
}).pipe(
1077+
Effect.andThen(
10361078
Effect.promise(() =>
1037-
input.sdk.session.shell(
1079+
input.sdk.session.command(
10381080
{
10391081
sessionID: input.sessionID,
1040-
agent,
1041-
model: next.model,
1042-
command: next.prompt.text,
1082+
agent: next.agent,
1083+
model: next.model ? `${next.model.providerID}/${next.model.modelID}` : undefined,
1084+
variant: next.variant,
1085+
command: command.name,
1086+
arguments: command.arguments,
1087+
parts: [
1088+
...(next.includeFiles ? next.files : []),
1089+
...next.prompt.parts.filter(
1090+
(item): item is Extract<RunPromptPart, { type: "file" }> => item.type === "file",
1091+
),
1092+
],
10431093
},
1044-
{ signal: turn.signal, throwOnError: true },
1094+
{ signal: turn.signal },
10451095
),
1096+
).pipe(
1097+
Effect.tap(() =>
1098+
Effect.sync(() => {
1099+
input.trace?.write("send.command.ok", {
1100+
sessionID: input.sessionID,
1101+
command: command.name,
1102+
})
1103+
item.armed = true
1104+
item.live = true
1105+
}),
1106+
),
1107+
Effect.flatMap(() => Deferred.succeed(item.done, undefined).pipe(Effect.ignore)),
1108+
Effect.catch((error) => Deferred.fail(item.done, error).pipe(Effect.ignore)),
1109+
Effect.forkIn(scope, { startImmediately: true }),
1110+
Effect.asVoid,
10461111
),
10471112
),
1048-
).pipe(
1049-
Effect.tap(() =>
1050-
Effect.sync(() => {
1051-
input.trace?.write("send.shell.ok", {
1052-
sessionID: input.sessionID,
1053-
})
1054-
item.armed = true
1055-
item.live = true
1056-
}),
1057-
),
1058-
Effect.flatMap(() => Deferred.succeed(item.done, undefined).pipe(Effect.ignore)),
1059-
Effect.catch((error) => Deferred.fail(item.done, error).pipe(Effect.ignore)),
1060-
Effect.forkIn(scope, { startImmediately: true }),
1061-
Effect.asVoid,
1062-
),
1063-
),
1064-
)
1065-
: command
1066-
? Effect.sync(() => {
1067-
input.trace?.write("send.command", { sessionID: input.sessionID, command: command.name })
1068-
}).pipe(
1069-
Effect.andThen(
1070-
Effect.promise(() =>
1071-
input.sdk.session.command(
1072-
{
1073-
sessionID: input.sessionID,
1074-
agent: next.agent,
1075-
model: next.model ? `${next.model.providerID}/${next.model.modelID}` : undefined,
1076-
variant: next.variant,
1077-
command: command.name,
1078-
arguments: command.arguments,
1079-
parts: [
1080-
...(next.includeFiles ? next.files : []),
1081-
...next.prompt.parts.filter(
1082-
(item): item is Extract<RunPromptPart, { type: "file" }> => item.type === "file",
1083-
),
1084-
],
1085-
},
1086-
{ signal: turn.signal },
1113+
)
1114+
: Effect.sync(() => {
1115+
input.trace?.write("send.prompt", req)
1116+
}).pipe(
1117+
Effect.andThen(
1118+
Effect.promise(() =>
1119+
input.sdk.session.promptAsync(req, {
1120+
signal: turn.signal,
1121+
}),
1122+
),
10871123
),
1088-
).pipe(
10891124
Effect.tap(() =>
10901125
Effect.sync(() => {
1091-
input.trace?.write("send.command.ok", {
1126+
input.trace?.write("send.prompt.ok", {
10921127
sessionID: input.sessionID,
1093-
command: command.name,
10941128
})
10951129
item.armed = true
1096-
item.live = true
10971130
}),
10981131
),
1099-
Effect.flatMap(() => Deferred.succeed(item.done, undefined).pipe(Effect.ignore)),
1100-
Effect.catch((error) => Deferred.fail(item.done, error).pipe(Effect.ignore)),
1101-
Effect.forkIn(scope, { startImmediately: true }),
1102-
Effect.asVoid,
1103-
),
1104-
),
1105-
)
1106-
: Effect.sync(() => {
1107-
input.trace?.write("send.prompt", req)
1108-
}).pipe(
1109-
Effect.andThen(
1110-
Effect.promise(() =>
1111-
input.sdk.session.promptAsync(req, {
1112-
signal: turn.signal,
1113-
}),
1114-
),
1115-
),
1116-
Effect.tap(() =>
1117-
Effect.sync(() => {
1118-
input.trace?.write("send.prompt.ok", {
1119-
sessionID: input.sessionID,
1120-
})
1121-
item.armed = true
1122-
}),
1123-
),
1124-
)
1132+
)
11251133

11261134
yield* send.pipe(
11271135
Effect.flatMap(() => {

0 commit comments

Comments
 (0)