opencode-sessions-explorer 0.1.1 → 0.1.2
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.
- package/CHANGELOG.md +8 -0
- package/README.md +30 -4
- package/docs/README.md +45 -0
- package/docs/getting-started.md +96 -0
- package/docs/guides/cost-and-usage-analysis.md +75 -0
- package/docs/guides/export-and-maintenance.md +85 -0
- package/docs/guides/manage-archived-sessions.md +70 -0
- package/docs/guides/recall-and-navigation.md +90 -0
- package/docs/guides/search-and-grep.md +87 -0
- package/docs/install.md +140 -0
- package/docs/maintainers/development.md +140 -0
- package/docs/maintainers/docs-writing.md +86 -0
- package/docs/maintainers/release.md +72 -0
- package/docs/maintainers/triage.md +55 -0
- package/docs/reference/architecture.md +112 -0
- package/docs/reference/configuration.md +115 -0
- package/docs/reference/response-format.md +120 -0
- package/docs/reference/search-surfaces.md +106 -0
- package/docs/reference/tools.md +151 -0
- package/docs/support/troubleshooting.md +230 -0
- package/package.json +2 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Configuration Reference
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
This page documents how to configure `opencode-sessions-explorer`: the OpenCode
|
|
6
|
+
`permission` rule the plugin needs, the environment variables that override every
|
|
7
|
+
filesystem path, and the opt-in switch for running the test suite against real
|
|
8
|
+
session data.
|
|
9
|
+
|
|
10
|
+
The plugin has no settings object of its own — it is configured entirely through
|
|
11
|
+
OpenCode permissions and environment variables. All defaults work out of the box on
|
|
12
|
+
macOS and Linux; Windows paths resolve via `%LOCALAPPDATA%`.
|
|
13
|
+
|
|
14
|
+
## Required Permission
|
|
15
|
+
|
|
16
|
+
The OpenCode session database lives outside your project workspace, so OpenCode
|
|
17
|
+
must be granted access to its data directory. Add an `external_directory` allow rule
|
|
18
|
+
to your OpenCode config and restart:
|
|
19
|
+
|
|
20
|
+
```jsonc
|
|
21
|
+
// ~/.config/opencode/opencode.json
|
|
22
|
+
{
|
|
23
|
+
"$schema": "https://opencode.ai/config.json",
|
|
24
|
+
"plugin": ["opencode-sessions-explorer"],
|
|
25
|
+
"permission": {
|
|
26
|
+
"external_directory": {
|
|
27
|
+
"~/.local/share/opencode/**": "allow"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Without this rule the read-only database handle cannot open the file and tools fail
|
|
34
|
+
with `DB_NOT_FOUND` or a permission error. The change takes effect only after a full
|
|
35
|
+
OpenCode restart. See [Permission Denied / external_directory](../support/troubleshooting.md#permission-denied--external_directory)
|
|
36
|
+
if a tool still cannot reach the database after adding the rule.
|
|
37
|
+
|
|
38
|
+
The snippet above covers the common macOS/Linux default path. If `$XDG_DATA_HOME`,
|
|
39
|
+
Windows `%LOCALAPPDATA%`, or `OPENCODE_SESSIONS_EXPLORER_DB` points to another
|
|
40
|
+
database location, allow the actual directory that contains `opencode.db` and
|
|
41
|
+
restart OpenCode. Some existing global configs may set `external_directory: "allow"`;
|
|
42
|
+
that grants broad access and is useful for local power users, but the scoped path
|
|
43
|
+
rule is preferred for normal installs.
|
|
44
|
+
|
|
45
|
+
## Runtime Compatibility
|
|
46
|
+
|
|
47
|
+
The plugin targets the OpenCode plugin host contract provided by
|
|
48
|
+
`@opencode-ai/plugin >= 1.15.0`. It runs on Bun and uses `bun:sqlite`, which should
|
|
49
|
+
include SQLite `json1`; the bundled health probes (`check-deps` CLI and `db-stats`
|
|
50
|
+
tool) verify `json1`, schema drift, and database runtime settings for the active
|
|
51
|
+
OpenCode database.
|
|
52
|
+
|
|
53
|
+
## Environment Overrides
|
|
54
|
+
|
|
55
|
+
Every path the plugin uses is overridable through an environment variable. These are
|
|
56
|
+
the simplest way to point the plugin (or its tests) at non-default locations.
|
|
57
|
+
|
|
58
|
+
| Variable | Default | Purpose |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| `OPENCODE_SESSIONS_EXPLORER_DB` | `$XDG_DATA_HOME/opencode/opencode.db` (macOS/Linux) or `%LOCALAPPDATA%\opencode\opencode.db` (Windows); falls back to `~/.local/share/opencode/opencode.db` | Absolute path to the OpenCode SQLite database the plugin reads. Set this when the database is not in the default OpenCode data directory. |
|
|
61
|
+
| `OPENCODE_SESSIONS_EXPLORER_EXPORT_ROOT` | `~/.local/share/opencode-sessions-explorer` | Directory where searchable session content is materialized (the `by-session` and `by-channel` export trees that `ck` indexes). |
|
|
62
|
+
| `OPENCODE_SESSIONS_EXPLORER_TOOL_OUTPUT_DIR` | `$XDG_DATA_HOME/opencode/tool-output` (macOS/Linux) or `%LOCALAPPDATA%\opencode\tool-output` (Windows); falls back to `~/.local/share/opencode/tool-output` | Whitelist root for `get-part` dereference. Only files resolving inside this root may be read when `dereference_output_path:true`; any other path is rejected with `PATH_TRAVERSAL`. |
|
|
63
|
+
| `OPENCODE_SESSIONS_EXPLORER_CK_BIN` | `ck` discovered on `PATH` | Absolute path to the `ck` binary. Set this when `ck` is installed outside `PATH`; only `search-text` and `grep-session` use it. |
|
|
64
|
+
|
|
65
|
+
### `get-part` Dereference Guard
|
|
66
|
+
|
|
67
|
+
The `OPENCODE_SESSIONS_EXPLORER_TOOL_OUTPUT_DIR` whitelist is enforced before any
|
|
68
|
+
externalized tool output is read. Symlinks are resolved before the path is compared
|
|
69
|
+
to the root, so a symlink inside the whitelist that points outside it is also
|
|
70
|
+
rejected. This is why `get-part` returns `PATH_TRAVERSAL` for any path outside the
|
|
71
|
+
tool-output directory — see the troubleshooting page for the recovery steps.
|
|
72
|
+
|
|
73
|
+
## Testing Override (Dev Only)
|
|
74
|
+
|
|
75
|
+
`bun test` is hermetic by default and runs against a synthetic fixture database. To
|
|
76
|
+
exercise the suite against real session data instead, opt in with:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
OPENCODE_SESSIONS_EXPLORER_LIVE=1 bun test
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Live runs read real `ses_`/`msg_`/`prt_` ids and minimum counts from your own
|
|
83
|
+
history, so failures there reflect local data rather than a regression. This switch
|
|
84
|
+
is for contributors only and has no effect on the plugin at runtime; see the
|
|
85
|
+
[Development Guide](../maintainers/development.md) for the full contributor loop.
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
Point the plugin at a database in a custom location:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
export OPENCODE_SESSIONS_EXPLORER_DB="/data/opencode/opencode.db"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Materialize the search export to a dedicated disk:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
export OPENCODE_SESSIONS_EXPLORER_EXPORT_ROOT="/fast-ssd/opencode-search"
|
|
99
|
+
bunx opencode-sessions-explorer-bulk-export
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Use a `ck` binary that is not on `PATH`:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
export OPENCODE_SESSIONS_EXPLORER_CK_BIN="$HOME/.cargo/bin/ck"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Related Docs
|
|
109
|
+
|
|
110
|
+
- Tool catalog: [tools.md](tools.md)
|
|
111
|
+
- Search surfaces and channels: [search-surfaces.md](search-surfaces.md)
|
|
112
|
+
- Four-layer architecture: [architecture.md](architecture.md)
|
|
113
|
+
- Data exposure and redaction policy: [../../.github/SECURITY.md](../../.github/SECURITY.md)
|
|
114
|
+
- Install walkthrough: [../install.md](../install.md)
|
|
115
|
+
- Troubleshooting: [../support/troubleshooting.md](../support/troubleshooting.md)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Response Format Reference
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
This page documents the compact, lossless format that list-shaped tool results use.
|
|
6
|
+
Several tools return arrays of uniform records (sessions, events, tool calls, cost
|
|
7
|
+
groups, search hits). Serializing those as plain arrays-of-objects repeats every
|
|
8
|
+
JSON key on every row and re-serializes the same nested values (model, directory,
|
|
9
|
+
agent) again and again. To cut payload size without losing information, list results
|
|
10
|
+
are encoded as a columnar table with string interning.
|
|
11
|
+
|
|
12
|
+
Scalar, single-object responses (for example `get-session` or `db-stats`) are
|
|
13
|
+
returned as ordinary JSON objects and are **not** encoded this way.
|
|
14
|
+
|
|
15
|
+
## The Table Shape
|
|
16
|
+
|
|
17
|
+
An encoded list result is an object with three keys:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"cols": ["id", "title", "agent", "model"],
|
|
22
|
+
"dict": {
|
|
23
|
+
"agent": ["build", "executor-gpt"],
|
|
24
|
+
"model": [{ "id": "claude-opus", "provider": "anthropic" }]
|
|
25
|
+
},
|
|
26
|
+
"rows": [
|
|
27
|
+
["ses_a1", "Fix retry bug", 0, 0],
|
|
28
|
+
["ses_b2", "Cost audit", 1, 0]
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- `cols` — the column order; each row is an array of cells in this order.
|
|
34
|
+
- `dict` — interning tables for selected columns. A column listed here stores its
|
|
35
|
+
distinct values once; rows reference them by integer index. Columns absent from
|
|
36
|
+
`dict` store their literal value inline.
|
|
37
|
+
- `rows` — one array per record.
|
|
38
|
+
|
|
39
|
+
## Decode Rule
|
|
40
|
+
|
|
41
|
+
There is a single decode rule:
|
|
42
|
+
|
|
43
|
+
> A cell in a column whose name is a key in `dict` is an integer index into
|
|
44
|
+
> `dict[col]`. Otherwise the cell is its literal value.
|
|
45
|
+
|
|
46
|
+
Decoding the example above yields:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
[
|
|
50
|
+
{ "id": "ses_a1", "title": "Fix retry bug", "agent": "build", "model": { "id": "claude-opus", "provider": "anthropic" } },
|
|
51
|
+
{ "id": "ses_b2", "title": "Cost audit", "agent": "executor-gpt", "model": { "id": "claude-opus", "provider": "anthropic" } }
|
|
52
|
+
]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Note that both rows reuse the same `model` object (index `0`) instead of repeating
|
|
56
|
+
it — that is where the savings come from on large result sets.
|
|
57
|
+
|
|
58
|
+
## Reference Decoder
|
|
59
|
+
|
|
60
|
+
The plugin ships the inverse function, `decodeTable()`, in
|
|
61
|
+
[`src/lib/table.ts`](../../src/lib/table.ts). It is used by the test suite and is
|
|
62
|
+
safe for consumers to copy. Two behaviors make migration painless:
|
|
63
|
+
|
|
64
|
+
- A plain array passed to `decodeTable()` is returned unchanged, so callers can
|
|
65
|
+
treat encoded and unencoded results uniformly.
|
|
66
|
+
- An out-of-range or non-integer cell in a `dict` column is passed through as its
|
|
67
|
+
literal value rather than throwing.
|
|
68
|
+
|
|
69
|
+
A minimal equivalent decoder:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
function decodeTable(t) {
|
|
73
|
+
if (t == null) return []
|
|
74
|
+
if (Array.isArray(t)) return t // already plain
|
|
75
|
+
const dict = t.dict ?? {}
|
|
76
|
+
return t.rows.map((row) => {
|
|
77
|
+
const o = {}
|
|
78
|
+
t.cols.forEach((c, i) => {
|
|
79
|
+
const v = row[i]
|
|
80
|
+
const d = dict[c]
|
|
81
|
+
o[c] = d && typeof v === "number" && v >= 0 && v < d.length ? d[v] : v
|
|
82
|
+
})
|
|
83
|
+
return o
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Examples
|
|
89
|
+
|
|
90
|
+
A `list-sessions` result interns the repetitive `agent`, `model`, `directory`, and
|
|
91
|
+
`project_id` columns:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"sessions": {
|
|
96
|
+
"cols": ["id", "title", "agent", "model", "directory", "cost"],
|
|
97
|
+
"dict": {
|
|
98
|
+
"agent": ["build"],
|
|
99
|
+
"model": [{ "id": "claude-opus" }],
|
|
100
|
+
"directory": ["/projects/app"],
|
|
101
|
+
"project_id": []
|
|
102
|
+
},
|
|
103
|
+
"rows": [
|
|
104
|
+
["ses_a1", "Fix retry bug", 0, 0, 0, 0.42]
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"has_more": false
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Apply the decode rule to recover the records, then read `cost` (a literal column)
|
|
112
|
+
directly.
|
|
113
|
+
|
|
114
|
+
## Related Docs
|
|
115
|
+
|
|
116
|
+
- Tool catalog: [tools.md](tools.md)
|
|
117
|
+
- Search surfaces and channels: [search-surfaces.md](search-surfaces.md)
|
|
118
|
+
- Four-layer architecture: [architecture.md](architecture.md)
|
|
119
|
+
- Configuration and environment overrides: [configuration.md](configuration.md)
|
|
120
|
+
- Troubleshooting: [../support/troubleshooting.md](../support/troubleshooting.md)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Search Surfaces Reference
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
This page documents the retrieval presets (`surface`) and the underlying channels
|
|
6
|
+
that `search-text` and `grep-session` use to decide *what* exported content to
|
|
7
|
+
search. Raw session data always stays lossless in the database and export tree;
|
|
8
|
+
channels are derived search views that let default recall search high-signal content
|
|
9
|
+
first while preserving raw drill-down through part and message ids.
|
|
10
|
+
|
|
11
|
+
Both tools accept a `surface` argument and an optional `channels` override. If you
|
|
12
|
+
pass `channels` explicitly, it takes precedence over the surface-derived set.
|
|
13
|
+
|
|
14
|
+
## Surfaces
|
|
15
|
+
|
|
16
|
+
A surface is a named preset that expands to a curated set of channels. The default
|
|
17
|
+
is `recall`.
|
|
18
|
+
|
|
19
|
+
| Surface | Channels Searched | Use For |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| `recall` | `conversation`, `session-summary` | Default. Session-first, high-signal recall — "where did I mention X", "find sessions about Y". |
|
|
22
|
+
| `debug_trace` | `conversation`, `session-summary`, `tool-error`, `tool-input-summary` | Investigating failures and what led to them — errors, exceptions, stack traces, logs. |
|
|
23
|
+
| `tool_audit` | `tool-input-summary`, `tool-error` | Auditing tool usage — bash commands, tool calls, MCP calls, and their errors. |
|
|
24
|
+
| `code` | `conversation`, `session-summary`, `code-touch`, `patch-summary`, `tool-input-summary` | Tracing file and code changes — paths, diffs, edits, patches. |
|
|
25
|
+
| `forensics` | `raw` | Exhaustive replay over raw exported bodies, including full tool output and reasoning. Slowest; use when curated channels miss something. |
|
|
26
|
+
|
|
27
|
+
### Surface Inference
|
|
28
|
+
|
|
29
|
+
When `surface` is left at its default (`recall`), the query text is inspected and
|
|
30
|
+
the surface may be auto-promoted:
|
|
31
|
+
|
|
32
|
+
- Error vocabulary (`error`, `exception`, `stack trace`, `failed`, `timeout`,
|
|
33
|
+
`logs`, `stderr`, `stdout`) promotes to `debug_trace`.
|
|
34
|
+
- Tool vocabulary (`tool calls`, `bash`, `command`, `grep`, `read tool`,
|
|
35
|
+
`edit tool`, `apply_patch`, `mcp`, …) promotes to `tool_audit`.
|
|
36
|
+
- Code vocabulary (`file`, `path`, `class`, `function`, `symbol`, `diff`, `patch`,
|
|
37
|
+
`edited`, `src/`, `.ts`, `.kt`, `.py`, …) promotes to `code`.
|
|
38
|
+
|
|
39
|
+
Passing an explicit non-`recall` surface disables inference and uses that surface
|
|
40
|
+
as-is.
|
|
41
|
+
|
|
42
|
+
## Channels
|
|
43
|
+
|
|
44
|
+
Channels are the derived views the export tree materializes under
|
|
45
|
+
`by-channel/<channel>/by-session/<ses_id>/`. The raw, lossless export lives under
|
|
46
|
+
`by-session/<ses_id>/` and is reachable through the `raw` channel.
|
|
47
|
+
|
|
48
|
+
| Channel | Contents |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `conversation` | User and assistant text, plus subtask prompts. |
|
|
51
|
+
| `session-summary` | Per-session synthesized summary: title, directory, first and last user prompt. |
|
|
52
|
+
| `tool-input-summary` | Compact summary of each tool invocation's inputs (command, paths, query, ids). |
|
|
53
|
+
| `tool-error` | Normalized error text from failed tool calls. |
|
|
54
|
+
| `code-touch` | File paths touched by file tools and patches. |
|
|
55
|
+
| `tool-output` | Raw output bodies produced by tool calls. |
|
|
56
|
+
| `patch-summary` | Files changed per patch, with hash and file count. |
|
|
57
|
+
| `reasoning` | Assistant reasoning text. |
|
|
58
|
+
| `file` | File-reference parts (filename, URL, source path). |
|
|
59
|
+
| `raw` | The full-fidelity per-session export, including every searchable body. Selected by the `forensics` surface. |
|
|
60
|
+
|
|
61
|
+
## Grep Defaults
|
|
62
|
+
|
|
63
|
+
`grep-session` defaults to the same curated channels as the active surface
|
|
64
|
+
(`recall` → `conversation`, `session-summary`) when the curated channel export is
|
|
65
|
+
available. To search the raw exported bodies of a single session — including tool
|
|
66
|
+
output and reasoning — set `surface:'forensics'` or pass `channels:['raw']`.
|
|
67
|
+
|
|
68
|
+
If the curated channel export is only partial (not yet backfilled), both tools fall
|
|
69
|
+
back to the raw `by-session` export to avoid false negatives and add a warning;
|
|
70
|
+
running `opencode-sessions-explorer-bulk-export --reset` backfills the curated
|
|
71
|
+
channels. See [export-and-maintenance.md](../guides/export-and-maintenance.md).
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
Default recall search across all sessions:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
opencode-sessions-explorer-search-text { "q": "rate limiting" }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Force a raw forensic sweep with explicit channels:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
opencode-sessions-explorer-search-text { "q": "AKIA", "surface": "forensics" }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Grep one session's raw bodies (tool output included):
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
opencode-sessions-explorer-grep-session { "session_id": "ses_…", "pattern": "ETIMEDOUT", "channels": ["raw"] }
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Audit tool inputs and errors only:
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
opencode-sessions-explorer-search-text { "q": "git push", "surface": "tool_audit" }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Related Docs
|
|
100
|
+
|
|
101
|
+
- Tool catalog: [tools.md](tools.md)
|
|
102
|
+
- Compact result format: [response-format.md](response-format.md)
|
|
103
|
+
- Four-layer architecture: [architecture.md](architecture.md)
|
|
104
|
+
- Search and grep workflow: [../guides/search-and-grep.md](../guides/search-and-grep.md)
|
|
105
|
+
- Export and maintenance workflow: [../guides/export-and-maintenance.md](../guides/export-and-maintenance.md)
|
|
106
|
+
- Troubleshooting: [../support/troubleshooting.md](../support/troubleshooting.md)
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Tools Reference
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
This page is the complete catalog of the tools `opencode-sessions-explorer`
|
|
6
|
+
registers with the LLM. There are 18 tools: 17 are read-only and one
|
|
7
|
+
(`unarchive-session`) performs a single, deliberate write. Every tool is exposed
|
|
8
|
+
under the public key `opencode-sessions-explorer-<name>`; the short names below
|
|
9
|
+
(for example `get-session`) are used for brevity.
|
|
10
|
+
|
|
11
|
+
Tools are grouped by intent. The `Read/Write` column states whether the tool only
|
|
12
|
+
reads the OpenCode session database or mutates it. For the curated search surfaces
|
|
13
|
+
and channels that `search-text` and `grep-session` accept, see
|
|
14
|
+
[search-surfaces.md](search-surfaces.md). For the compact result shape that
|
|
15
|
+
list-shaped tools return, see [response-format.md](response-format.md).
|
|
16
|
+
|
|
17
|
+
## Recall And Navigation
|
|
18
|
+
|
|
19
|
+
Find your bearings and pull conversation content by id.
|
|
20
|
+
|
|
21
|
+
| Tool | What It Does | Read/Write |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| `current-session` | Identifies the session the assistant is currently running in: id, message id, agent, model, directory, worktree, parent, cost-so-far, message/part/tool-call counters, child sessions, and useful filesystem paths (database, export tree, this session's export dir + `meta.json`). Pass `detail:'full'` for counters, children, and paths. | Read |
|
|
24
|
+
| `get-session` | Fetches one session's metadata and aggregate counts by id (parts by type, tool-call status breakdown, immediate child session ids). Returns no message bodies. | Read |
|
|
25
|
+
| `session-summary` | One-call human-readable overview: metadata, first and last user prompt, top files touched, top tools used (with completed/error counts), error count, duration, and cost. | Read |
|
|
26
|
+
| `session-timeline` | Chronological event stream — one row per part with a short per-type summary and no raw bodies. Filter by part type and time window; cursor-paginated. | Read |
|
|
27
|
+
| `get-message` | Fetches one message and its parts by message id. Each part body is capped via `max_part_bytes` to keep the response bounded. | Read |
|
|
28
|
+
| `get-part` | Fetches one fully decoded part by id. Optionally dereferences an externalized tool-output file when `dereference_output_path:true` (path-guarded — see [configuration.md](configuration.md)). | Read |
|
|
29
|
+
|
|
30
|
+
## Genealogy
|
|
31
|
+
|
|
32
|
+
Trace how sessions relate.
|
|
33
|
+
|
|
34
|
+
| Tool | What It Does | Read/Write |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `session-genealogy` | Walks the session parent/child tree to trace subagent dispatches and pair-execution chains. `direction` selects `ancestors` (up the `parent_id` chain), `descendants` (down to child sessions), or `both`. Depth-bounded by `max_depth`. | Read |
|
|
37
|
+
|
|
38
|
+
## Browse And Filter
|
|
39
|
+
|
|
40
|
+
List and filter sessions by structured metadata. Both return metadata only — never
|
|
41
|
+
message bodies.
|
|
42
|
+
|
|
43
|
+
| Tool | What It Does | Read/Write |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `list-sessions` | Browses sessions newest-first with combinable structured filters: `project_id`, `agent`, `model_id`, `directory_prefix`, `archived`, `since_ms`/`until_ms`, and `title_like`. Cursor-paginated. | Read |
|
|
46
|
+
| `search-sessions-meta` | Filters sessions by structured metadata plus cost/token thresholds (`min_cost`, `min_tokens_input`) — the same envelope as `list-sessions` with spend filters added. | Read |
|
|
47
|
+
|
|
48
|
+
## Content Search (ck-backed)
|
|
49
|
+
|
|
50
|
+
Search the bodies of sessions and the tool calls inside them. `search-text` and
|
|
51
|
+
`grep-session` shell out to the optional [`ck`](https://github.com/BeaconBay/ck)
|
|
52
|
+
CLI; if `ck` is absent they return `CK_NOT_FOUND` cleanly and the other tools keep
|
|
53
|
+
working. `search-tool-calls` queries the database directly and does not need `ck`.
|
|
54
|
+
|
|
55
|
+
| Tool | What It Does | Read/Write |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `search-text` | Full-text search across the bodies of all sessions (user prompts, assistant responses, tool input/output, reasoning, file references, patches, subtask prompts). Surface- and channel-aware; supports `regex`, `lex` (BM25), `sem`, and `hybrid` modes, a `role` filter, and `group_by_session` rollups. | Read |
|
|
58
|
+
| `grep-session` | grep/regex search inside one session's exported body content (fast; operates on that session's part files only). Supports `fixed_string`, `case_sensitive`, `whole_word`, and `context_lines`. | Read |
|
|
59
|
+
| `search-tool-calls` | Finds tool invocations across sessions, filtered by tool name (exact or `LIKE` wildcard), status, or substring on input/output/error. Returns capped snippets; cursor-paginated, newest-first. | Read |
|
|
60
|
+
|
|
61
|
+
## Cost And Usage Analysis
|
|
62
|
+
|
|
63
|
+
Aggregate spend, tokens, failures, and prompt patterns.
|
|
64
|
+
|
|
65
|
+
| Tool | What It Does | Read/Write |
|
|
66
|
+
| --- | --- | --- |
|
|
67
|
+
| `cost-by-project` | Aggregates cost and token usage grouped by `project_id`, `directory`, `agent`, or `model`, sorted by cost. Surfaces a `cost_known` flag for groups whose sessions predate the usage-tracking migration. | Read |
|
|
68
|
+
| `cost-by-period` | Time-series cost and tokens bucketed by `day`, `week`, or `month`, newest-first. Supports `tz_offset_min` to shift bucket boundaries to a local day. | Read |
|
|
69
|
+
| `list-tool-failures` | Aggregates tool errors grouped by `tool`, `error` message prefix, or `session`, sorted by count. | Read |
|
|
70
|
+
| `list-repeated-prompts` | Clusters sessions by the normalized prefix of their first user prompt to surface "have I asked this before" patterns. | Read |
|
|
71
|
+
|
|
72
|
+
## Health
|
|
73
|
+
|
|
74
|
+
| Tool | What It Does | Read/Write |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `db-stats` | Health and schema-drift probe for the OpenCode SQLite database: migration head, table counts (session/message/part), json1 status, `busy_timeout`, and drift warnings. | Read |
|
|
77
|
+
|
|
78
|
+
## Write
|
|
79
|
+
|
|
80
|
+
The single mutation surface in the plugin.
|
|
81
|
+
|
|
82
|
+
| Tool | What It Does | Read/Write |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| `unarchive-session` | Restores a previously archived session: clears `session.time_archived` **and** refreshes `session.time_updated` so the session resurfaces at the top of OpenCode's recency-ordered list. Returns `NOT_FOUND` only when the id does not exist. | **Write** |
|
|
85
|
+
|
|
86
|
+
The write is intentionally narrow: it runs through an isolated, short-lived
|
|
87
|
+
read-write connection while every other tool uses a read-only handle. The
|
|
88
|
+
`time_updated` refresh is required, not cosmetic — OpenCode loads sessions ordered
|
|
89
|
+
by `time_updated DESC` with a default limit per directory, so a long-archived
|
|
90
|
+
session would otherwise stay buried below that window and fail to open. See
|
|
91
|
+
[architecture.md](architecture.md) for the single-writer model.
|
|
92
|
+
|
|
93
|
+
### CLI Executables
|
|
94
|
+
|
|
95
|
+
These ship as standalone commands (run with `bunx`) for materializing and
|
|
96
|
+
maintaining the search export and for verifying install health.
|
|
97
|
+
|
|
98
|
+
| Executable | What It Does |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `opencode-sessions-explorer-bulk-export` | Materializes (and incrementally refreshes) the filesystem search export tree. `--reset` rebuilds from scratch; `--root <path>` targets a non-default export root. |
|
|
101
|
+
| `opencode-sessions-explorer-dedupe-export` | One-shot maintenance that removes duplicate part files (same part id, different sequence prefix). Dry-run by default; pass `--apply` to delete. |
|
|
102
|
+
| `opencode-sessions-explorer-check-deps` | Install health probe: database reachability, schema head and drift, SQLite `json1`, `busy_timeout`, export tree, channel views, `ck` CLI and index, and tool-output directory. `--json` emits machine-readable output. |
|
|
103
|
+
|
|
104
|
+
## Examples
|
|
105
|
+
|
|
106
|
+
Identify the current session, then summarize it:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
opencode-sessions-explorer-current-session # returns this session's id
|
|
110
|
+
opencode-sessions-explorer-session-summary { "session_id": "ses_…" }
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Find every failed `read` tool call in the last week:
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
opencode-sessions-explorer-search-tool-calls { "tool": "read", "status": "error", "since_ms": 1717200000000 }
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Search all sessions for a topic, rolled up per session:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
opencode-sessions-explorer-search-text { "q": "retry backoff", "group_by_session": true }
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Fresh install health flow:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
bunx opencode-sessions-explorer-check-deps # warnings for missing export/ck are okay initially
|
|
129
|
+
bunx opencode-sessions-explorer-bulk-export
|
|
130
|
+
bunx opencode-sessions-explorer-check-deps
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Restore an archived session you located with `archived:'only'`:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
opencode-sessions-explorer-list-sessions { "archived": "only" }
|
|
137
|
+
opencode-sessions-explorer-unarchive-session { "session_id": "ses_…" }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Related Docs
|
|
141
|
+
|
|
142
|
+
- Configuration and environment overrides: [configuration.md](configuration.md)
|
|
143
|
+
- Search surfaces and channels: [search-surfaces.md](search-surfaces.md)
|
|
144
|
+
- Compact result format: [response-format.md](response-format.md)
|
|
145
|
+
- Four-layer architecture: [architecture.md](architecture.md)
|
|
146
|
+
- Recall and navigation workflow: [../guides/recall-and-navigation.md](../guides/recall-and-navigation.md)
|
|
147
|
+
- Search and grep workflow: [../guides/search-and-grep.md](../guides/search-and-grep.md)
|
|
148
|
+
- Cost and usage analysis workflow: [../guides/cost-and-usage-analysis.md](../guides/cost-and-usage-analysis.md)
|
|
149
|
+
- Export and maintenance workflow: [../guides/export-and-maintenance.md](../guides/export-and-maintenance.md)
|
|
150
|
+
- Managing archived sessions: [../guides/manage-archived-sessions.md](../guides/manage-archived-sessions.md)
|
|
151
|
+
- Troubleshooting: [../support/troubleshooting.md](../support/troubleshooting.md)
|