GeezerVison is showing github.com — feat(cli): add session delete command (#13571) · schjonhaug/opencode@b0afdf6
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/opencode/src/cli/cmd
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: .opencode/agent/translator.md +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -359,6 +359,7 @@ opencode serve --hostname 0.0.0.0 --port 4096 |
359 | 359 | opencode serve [--port <number>] [--hostname <string>] [--cors <origin>] |
360 | 360 | opencode session [command] |
361 | 361 | opencode session list |
| 362 | +opencode session delete <sessionID> |
362 | 363 | opencode stats |
363 | 364 | opencode uninstall |
364 | 365 | opencode upgrade |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/session.ts +25-1Lines changed: 25 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -38,10 +38,34 @@ function pagerCmd(): string[] { |
38 | 38 | export const SessionCommand = cmd({ |
39 | 39 | command: "session", |
40 | 40 | describe: "manage sessions", |
41 | | - builder: (yargs: Argv) => yargs.command(SessionListCommand).demandCommand(), |
| 41 | + builder: (yargs: Argv) => yargs.command(SessionListCommand).command(SessionDeleteCommand).demandCommand(), |
42 | 42 | async handler() {}, |
43 | 43 | }) |
44 | 44 |
|
| 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 | + |
45 | 69 | export const SessionListCommand = cmd({ |
46 | 70 | command: "list", |
47 | 71 | describe: "list sessions", |
|