opencode-sesh 0.14.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,51 +0,0 @@
1
- // Custom tool: list opencode sessions for the agent.
2
- // Install: copy to ~/.config/opencode/tools/sesh-list.ts (global) or
3
- // .opencode/tools/sesh-list.ts (project). Requires the @opencode-ai/plugin
4
- // package next to it — see https://opencode.ai/docs/custom-tools/
5
- //
6
- // Lets the agent browse previous work across ALL project directories and
7
- // offer to resume one, without depending on the external fzf picker.
8
- import { tool } from "@opencode-ai/plugin"
9
-
10
- export default tool({
11
- description: "List opencode sessions across all project directories, newest first",
12
- args: {
13
- limit: tool.schema
14
- .number()
15
- .int()
16
- .min(0)
17
- .max(1000)
18
- .describe("Maximum sessions to return (0–1000; 0 returns none)")
19
- .default(50),
20
- directory: tool.schema
21
- .string()
22
- .describe("Only sessions from this directory (default: all directories)")
23
- .optional(),
24
- },
25
- async execute(args) {
26
- // Validate here as well as in the schema for direct/programmatic callers.
27
- if (!Number.isInteger(args.limit) || args.limit < 0 || args.limit > 1000) {
28
- throw new Error("limit must be an integer between 0 and 1000")
29
- }
30
- const bun = (globalThis as any).Bun
31
- if (!bun || typeof bun.$ !== "function") {
32
- throw new Error("This tool requires the Bun runtime (globalThis.Bun.$)")
33
- }
34
-
35
- // `session list` is project-scoped and hides only children of forks. The
36
- // global store has no project instance, so query the SQLite session table
37
- // directly (OpenCode 1.18.30). Match `Session.listGlobal`/the picker: roots
38
- // only, non-archived. Bun quotes the SQL as one shell argument; SQL string
39
- // literals need their own escaping as well.
40
- const where = args.directory === undefined
41
- ? ""
42
- : ` AND directory = '${args.directory.replaceAll("'", "''")}'`
43
- const query = `SELECT id, title, directory, time_updated AS updated, time_created AS created
44
- FROM session WHERE parent_id IS NULL AND time_archived IS NULL${where}
45
- ORDER BY time_updated DESC, id DESC LIMIT ${args.limit}`
46
- const text = await bun.$`opencode db ${query} --format json`.text()
47
- const sessions = JSON.parse(text.trim() || "[]")
48
- if (!Array.isArray(sessions)) throw new Error("Unexpected opencode db result: expected an array")
49
- return JSON.stringify(sessions)
50
- },
51
- })