feat: add -c and -s args to tui command following run command pattern (#1835)

This commit is contained in:
Aiden Cline
2025-08-11 18:32:09 -05:00
committed by GitHub
parent 0ce7d92a8b
commit b2a4f57d64
3 changed files with 66 additions and 15 deletions

View File

@@ -14,6 +14,7 @@ import { FileWatcher } from "../../file/watch"
import { Ide } from "../../ide"
import { Agent } from "../../agent/agent"
import { Flag } from "../../flag/flag"
import { Session } from "../../session"
declare global {
const OPENCODE_TUI_PATH: string
@@ -39,6 +40,16 @@ export const TuiCommand = cmd({
alias: ["m"],
describe: "model to use in the format of provider/model",
})
.option("continue", {
alias: ["c"],
describe: "continue the last session",
type: "boolean",
})
.option("session", {
alias: ["s"],
describe: "session id to continue",
type: "string",
})
.option("prompt", {
alias: ["p"],
type: "string",
@@ -69,6 +80,19 @@ export const TuiCommand = cmd({
return
}
const result = await bootstrap({ cwd }, async (app) => {
const sessionID = await (async () => {
if (args.continue) {
const list = Session.list()
const first = await list.next()
await list.return()
if (first.done) return
return first.value.id
}
if (args.session) {
return args.session
}
return undefined
})()
FileWatcher.init()
const providers = await Provider.list()
if (Object.keys(providers).length === 0) {
@@ -106,6 +130,7 @@ export const TuiCommand = cmd({
...(args.model ? ["--model", args.model] : []),
...(args.prompt ? ["--prompt", args.prompt] : []),
...(args.mode ? ["--mode", args.mode] : []),
...(sessionID ? ["--session", sessionID] : []),
],
cwd,
stdout: "inherit",