Skip to content

Commit b0afdf6

Browse files
authored
feat(cli): add session delete command (anomalyco#13571)
1 parent d8c25bf commit b0afdf6

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

.opencode/agent/translator.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ opencode serve --hostname 0.0.0.0 --port 4096
359359
opencode serve [--port <number>] [--hostname <string>] [--cors <origin>]
360360
opencode session [command]
361361
opencode session list
362+
opencode session delete <sessionID>
362363
opencode stats
363364
opencode uninstall
364365
opencode upgrade

packages/opencode/src/cli/cmd/session.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,34 @@ function pagerCmd(): string[] {
3838
export const SessionCommand = cmd({
3939
command: "session",
4040
describe: "manage sessions",
41-
builder: (yargs: Argv) => yargs.command(SessionListCommand).demandCommand(),
41+
builder: (yargs: Argv) => yargs.command(SessionListCommand).command(SessionDeleteCommand).demandCommand(),
4242
async handler() {},
4343
})
4444

45+
export const SessionDeleteCommand = cmd({
46+
command: "delete <sessionID>",
47+
describe: "delete a session",
48+
builder: (yargs: Argv) => {
49+
return yargs.positional("sessionID", {
50+
describe: "session ID to delete",
51+
type: "string",
52+
demandOption: true,
53+
})
54+
},
55+
handler: async (args) => {
56+
await bootstrap(process.cwd(), async () => {
57+
try {
58+
await Session.get(args.sessionID)
59+
} catch {
60+
UI.error(`Session not found: ${args.sessionID}`)
61+
process.exit(1)
62+
}
63+
await Session.remove(args.sessionID)
64+
UI.println(UI.Style.TEXT_SUCCESS_BOLD + `Session ${args.sessionID} deleted` + UI.Style.TEXT_NORMAL)
65+
})
66+
},
67+
})
68+
4569
export const SessionListCommand = cmd({
4670
command: "list",
4771
describe: "list sessions",

0 commit comments

Comments
 (0)