opencode-sessions-explorer 0.1.0 → 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 CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.2] - 2026-06-13
11
+
12
+ ### Changed
13
+ - Clarified installation, source-dev, and first-run docs, including plugin
14
+ registration troubleshooting, platform-specific database paths, and export/index
15
+ setup; shipped `docs/` in the npm package so README guide links resolve for
16
+ package consumers.
17
+
18
+ ## [0.1.1] - 2026-06-13
19
+
20
+ ### Changed
21
+ - Documentation restructure: organized the `docs/` tree (getting started, install, guides,
22
+ reference, support, maintainers) and reworked `README.md` into a concise entry point that
23
+ links out to the new docs.
24
+ - Generalized the product descriptions and wording across `package.json`, `README.md`, and
25
+ the docs tree so they are non-parochial (removed machine- and author-specific phrasing).
26
+ No runtime or API changes.
27
+
10
28
  ## [0.1.0] - 2026-06-13
11
29
 
12
30
  Initial public release on npm.
package/README.md CHANGED
@@ -1,62 +1,46 @@
1
1
  # opencode-sessions-explorer
2
2
 
3
- > Access to every prior OpenCode session on your machine — recall, search/grep, and historical analysis via 18 LLM-discoverable tools (17 read-only + one explicit unarchive write).
4
-
5
3
  [![CI](https://github.com/iamironz/opencode-sessions-explorer/actions/workflows/ci.yml/badge.svg)](https://github.com/iamironz/opencode-sessions-explorer/actions/workflows/ci.yml)
6
4
  [![npm version](https://img.shields.io/npm/v/opencode-sessions-explorer.svg)](https://www.npmjs.com/package/opencode-sessions-explorer)
7
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
6
 
9
- `opencode-sessions-explorer` is an [OpenCode](https://opencode.ai) plugin that exposes your local SQLite session history (`~/.local/share/opencode/opencode.db`) to the running LLM as a set of named tools. Ask in natural language *"Where in my history did I mention X?"*, *"How much did I spend on Claude this month?"*, *"Which tool fails most for me?"* — and the LLM picks the right tool automatically.
10
-
11
- ---
7
+ Recall, search, and analyze every past [OpenCode](https://opencode.ai) session —
8
+ 18 LLM-discoverable tools over the OpenCode SQLite database.
12
9
 
13
- ## Install
10
+ `opencode-sessions-explorer` is an OpenCode plugin that exposes your OpenCode
11
+ session history (`~/.local/share/opencode/opencode.db`) to the running model as a
12
+ set of named tools — 17 read-only (recall, search/grep, cost/usage analysis) plus
13
+ one explicit `unarchive-session` write. Ask in natural language and the model picks
14
+ the right tool automatically; nothing leaves your device.
14
15
 
15
- This is published on npm as
16
- [`opencode-sessions-explorer`](https://www.npmjs.com/package/opencode-sessions-explorer).
17
- Add it to the `plugin` array in your OpenCode config — OpenCode auto-installs npm
18
- plugins with Bun on startup (cached under `~/.cache/opencode/node_modules/`), so
19
- there is no separate `npm install` step:
16
+ Example questions it answers:
20
17
 
21
- ```jsonc
22
- // ~/.config/opencode/opencode.json
23
- {
24
- "$schema": "https://opencode.ai/config.json",
25
-
26
- "plugin": [
27
- "opencode-sessions-explorer"
28
- ],
29
-
30
- "permission": {
31
- "external_directory": {
32
- "~/.local/share/opencode/**": "allow"
33
- }
34
- }
35
- }
18
+ ```text
19
+ Where in my history did I mention the export codec?
20
+ Summarize session ses_… and list the files it touched.
21
+ How much did I spend on Claude this month, by project?
22
+ Which tool fails most for me, and what errors keep recurring?
23
+ Unarchive session ses_… so I can open it again.
36
24
  ```
37
25
 
38
- To pin a version, use `"opencode-sessions-explorer@0.1.0"`.
26
+ ## Compatibility
39
27
 
40
- Then **quit and restart OpenCode**. All 18 tools auto-register.
28
+ | Area | Support | Notes |
29
+ | --- | --- | --- |
30
+ | OpenCode | Plugin host compatible with `@opencode-ai/plugin >= 1.15.0` | Loads the plugin and owns the source database |
31
+ | Bun | `>= 1.0` | Runtime; the plugin uses `bun:sqlite` (OpenCode ships Bun), which should include SQLite `json1`; `check-deps` / `db-stats` verify it |
32
+ | `ck` | `>= 0.7`, optional | Only `search-text` / `grep-session` need it; the other 16 tools work without it |
33
+ | OS | macOS / Linux | Windows paths resolve via `%LOCALAPPDATA%` |
41
34
 
42
- The `external_directory` permission is required because the OpenCode DB lives
43
- outside your project workspace; you grant read+write to it explicitly (the lone
44
- write is `unarchive-session` — see [Writes](#writes)).
35
+ ## Quick Start
45
36
 
46
- ### From source (dev)
47
-
48
- To run a local checkout, point the `plugin` entry at the built file instead of
49
- the npm package:
37
+ 1. Add the plugin and grant access to the OpenCode data directory:
50
38
 
51
39
  ```jsonc
52
40
  // ~/.config/opencode/opencode.json
53
41
  {
54
42
  "$schema": "https://opencode.ai/config.json",
55
-
56
- "plugin": [
57
- "file:///absolute/path/to/opencode-sessions-explorer/dist/plugin.js"
58
- ],
59
-
43
+ "plugin": ["opencode-sessions-explorer"],
60
44
  "permission": {
61
45
  "external_directory": {
62
46
  "~/.local/share/opencode/**": "allow"
@@ -65,239 +49,128 @@ the npm package:
65
49
  }
66
50
  ```
67
51
 
68
- Run `bun run build` first to produce `dist/plugin.js`. For active development you
69
- can point at `src/plugin.ts` directly — Bun loads TS without a build step. Then
70
- **quit and restart OpenCode**.
52
+ The `external_directory` snippet covers the common macOS/Linux default path. If
53
+ `$XDG_DATA_HOME`, Windows `%LOCALAPPDATA%`, or
54
+ `OPENCODE_SESSIONS_EXPLORER_DB` points elsewhere, allow the actual containing
55
+ directory and restart OpenCode. Some existing global configs use
56
+ `external_directory: "allow"`; that also permits access, but the scoped path rule
57
+ above is preferred for normal users.
71
58
 
72
- ---
73
-
74
- ## First run
75
-
76
- The text-search tools (`search-text`, `grep-session`) need a filesystem export of your session content (used by `ck` for indexed search). The export contains both raw replay files and derived channel views used for cleaner default recall:
77
-
78
- ```bash
79
- # One-time, ~30-60s for typical histories
80
- bunx opencode-sessions-explorer-bulk-export
81
-
82
- # After upgrading from pre-channel versions, backfill curated recall views
83
- bunx opencode-sessions-explorer-bulk-export --reset
84
-
85
- # Optional: build the semantic search index (~5 h for ~150k parts; resumable)
86
- cd ~/.local/share/opencode-sessions-explorer && ck --index .
87
- ```
88
-
89
- After the first export, the plugin auto-syncs new parts on every search call (3-4s budget).
90
-
91
- Run the health check anytime:
59
+ 1. **Quit and restart OpenCode.** All 18 tools auto-register. OpenCode auto-installs
60
+ npm plugins with Bun on startup, so there is no separate `npm install` step.
61
+ 1. Run the health probe once. Warnings for the missing export tree, missing `ck`, or
62
+ missing `ck` index are okay at this stage:
92
63
 
93
64
  ```bash
94
65
  bunx opencode-sessions-explorer-check-deps
95
66
  ```
96
67
 
97
- ---
98
-
99
- ## External dependencies
100
-
101
- | Dependency | Required for | Install |
102
- | ---------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
103
- | **Bun ≥ 1.0** | Everything (the plugin uses `bun:sqlite`) | OpenCode ships Bun. If running CLIs standalone: <https://bun.sh> |
104
- | **OpenCode DB** | Everything (the source of truth) | Auto-created at `~/.local/share/opencode/opencode.db` by OpenCode. Override path via `$OPENCODE_SESSIONS_EXPLORER_DB` |
105
- | **`ck` CLI ≥ 0.7** | `search-text` + `grep-session` (the other 16 tools work without) | `cargo install ck-search` — see <https://github.com/BeaconBay/ck> |
106
-
107
- If `ck` is missing, `search-text`/`grep-session` cleanly return `CK_NOT_FOUND`; the other 16 tools work fine.
108
-
109
- ---
110
-
111
- ## The 18 tools
112
-
113
- ### Recall
114
-
115
- | Tool | Answers |
116
- | ----------------------------------- | ---------------------------------------------------------------------- |
117
- | `opencode-sessions-explorer-current-session` | *"What session am I in / who am I / where am I"* |
118
- | `opencode-sessions-explorer-get-session` | *"Tell me about session ses_…"* (metadata + counts + children) |
119
- | `opencode-sessions-explorer-session-summary` | *"Summarize session ses_…"* (prompts, files, tools, errors, cost) |
120
- | `opencode-sessions-explorer-session-timeline` | *"Walk through session ses_… chronologically"* |
121
- | `opencode-sessions-explorer-get-message` | *"Fetch message msg_… with its parts"* |
122
- | `opencode-sessions-explorer-get-part` | *"Show me part prt_…"* (+ optional tool-output dereference) |
123
- | `opencode-sessions-explorer-session-genealogy` | *"Parent chain / subagents spawned from ses_…"* |
124
-
125
- ### Browse / filter
126
-
127
- | Tool | Answers |
128
- | -------------------------------------- | ------------------------------------------------------------------------------- |
129
- | `opencode-sessions-explorer-list-sessions` | *"List my recent sessions / sessions using agent X / sessions in directory Y"* |
130
- | `opencode-sessions-explorer-search-sessions-meta` | *"Find sessions costing more than $5 / title matching X / under directory Y"* |
131
-
132
- ### Content search
133
-
134
- | Tool | Answers |
135
- | ----------------------------------- | ------------------------------------------------------------------------------------------------ |
136
- | `opencode-sessions-explorer-search-text` | *"Where in my history did I mention X?"* (curated session-first recall by default; `surface:'forensics'` for raw replay) |
137
- | `opencode-sessions-explorer-grep-session` | *"Inside session ses_…, grep for X"* (curated channels by default; raw via `surface:'forensics'`) |
138
- | `opencode-sessions-explorer-search-tool-calls` | *"Every time I ran git push / every read that errored / all my Jira MCP calls"* |
139
-
140
- ### Analysis
141
-
142
- | Tool | Answers |
143
- | --------------------------------------- | ------------------------------------------------------ |
144
- | `opencode-sessions-explorer-cost-by-project` | *"Cost by project / directory / agent / model"* |
145
- | `opencode-sessions-explorer-cost-by-period` | *"OpenCode spend per day / week / month"* |
146
- | `opencode-sessions-explorer-list-tool-failures` | *"Which tool fails most / what errors keep recurring"* |
147
- | `opencode-sessions-explorer-list-repeated-prompts` | *"Have I asked this question before / repeated prompts"* |
148
-
149
- ### Health
150
-
151
- | Tool | Answers |
152
- | -------------------------- | ---------------------------------------------------- |
153
- | `opencode-sessions-explorer-db-stats` | *"Is the local OpenCode DB healthy / any schema drift"* |
154
-
155
- ### Mutate (the one write tool)
68
+ 1. Materialize the search export once:
156
69
 
157
- | Tool | Answers |
158
- | ------------------------------------------ | ------------------------------------------------------------------------- |
159
- | `opencode-sessions-explorer-unarchive-session` | *"Unarchive / restore an archived session ses_…"* (clears `time_archived` + resurfaces) |
160
-
161
- This is the **only** tool that writes to `opencode.db`; see [Writes](#writes) below.
162
-
163
- ### Search Surfaces
164
-
165
- `search-text` and `grep-session` are curated by default. They preserve raw recall by reference instead of dumping every matching byte.
166
-
167
- | Surface | Default channels | Use when |
168
- | ------- | ---------------- | -------- |
169
- | `recall` | `conversation`, `session-summary` | normal "have I discussed X?" memory questions |
170
- | `debug_trace` | `conversation`, `session-summary`, `tool-error`, `tool-input-summary` | errors, stack traces, failed commands, logs |
171
- | `tool_audit` | `tool-input-summary`, `tool-error` | tool invocation history |
172
- | `code` | `conversation`, `session-summary`, `code-touch`, `patch-summary`, `tool-input-summary` | files, symbols, diffs, code paths |
173
- | `forensics` | `raw` | exhaustive raw replay, including tool output and reasoning |
174
-
175
- ---
176
-
177
- ## Compact result format (columnar + interning)
178
-
179
- List-shaped results (`list-sessions`, `search-sessions-meta`, `search-tool-calls`, `session-timeline`, `cost-by-project`, `cost-by-period`, `list-tool-failures`, `list-repeated-prompts`, `search-text`, `grep-session`, `session-genealogy` ancestors) are returned as a **lossless columnar table** instead of an array-of-objects. This removes per-row key repetition and interns high-repetition values (model, directory, agent, project, channel, event type) into a small dictionary — measured **−33% to −56%** payload size with no information removed.
180
-
181
- ```jsonc
182
- "sessions": {
183
- "cols": ["id","title","agent","model","directory", "...", "archived"],
184
- "dict": { "agent": ["build","executor-gpt"], "model": [{"id":"gpt-5.5-fast", "...": "..."}], "directory": ["/Users/you"] },
185
- "rows": [ ["ses_…","Title…",0,0,0, "…", true] ]
186
- }
187
- ```
188
-
189
- **Decode rule (single):** a cell in a column whose name is a key in `dict` is an integer index into `dict[col]`; otherwise it is the literal value. Scalars next to the table (`has_more`, `mode`, `suppressed`, …) are unchanged. A reference decoder ships as `decodeTable()` in `src/lib/table.ts`. The envelope (`ok`/`data`/`meta`/`warnings`) is unchanged.
190
-
191
- ---
192
-
193
- ## Architecture (4 layers)
194
-
195
- ```
196
- L1 SQLite DB ← source of truth (read-only access)
197
- ↓ (delta sync, runs before every search call)
198
- L2 opencode-sessions-explorer/ tree ← raw by-session replay + derived by-channel views
199
- ↓ (conversation, session-summary, tool-error,
200
- ↓ code-touch, tool-output, reasoning, etc.)
201
- L3 .ck/ index ← BM25 (Tantivy) + embeddings (bge-small),
202
- ↓ auto-incremental via blake3 chunk hash
203
- L4 enriched response ← every hit re-fetches session/part metadata
204
- from SQLite for accuracy
70
+ ```bash
71
+ bunx opencode-sessions-explorer-bulk-export
205
72
  ```
206
73
 
207
- All **reads** go through a shared `bun:sqlite` handle opened `readonly: true` + `PRAGMA query_only = 1`; any accidental write on that path throws. The single exception is the `unarchive-session` tool — see [Writes](#writes).
208
-
209
- ---
210
-
211
- ## Writes
212
-
213
- 17 of the 18 tools are strictly read-only. The lone exception is **`unarchive-session`**, which restores an archived session so it can be opened and prompted again.
214
-
215
- - **Why a direct DB write?** OpenCode exposes no archive/unarchive endpoint that can *clear* the flag: its HTTP `UpdatePayload` types `time.archived` as a finite number and the handler ignores `undefined`, so a clear/`null` can't be sent over the wire (verified against v1.15.12 source). `opencode session` only offers `list`/`delete`. A direct DB write is the only mechanism.
216
- - **What it writes.** It clears `time_archived` **and** refreshes `time_updated` to now, in one `UPDATE`, via a separate short-lived read-write connection (`src/lib/db-write.ts`); the shared read handle stays read-only. It **always restores to a usable state** — including an already-active-but-buried session (e.g. one unarchived by an older build that didn't refresh `time_updated`) — so it is not a silent no-op on active sessions; it is idempotent in effect (active + at the top). Only a non-existent id is rejected (`NOT_FOUND`).
217
- - **Why bump `time_updated`?** OpenCode's app/server load the session list ordered by `time_updated DESC` with a default `LIMIT 100` **per directory**. A long-archived session keeps an old `time_updated`, so merely clearing `time_archived` leaves it buried below that window — the app never loads it and prompting fails with *"Unable to retrieve session"*. Refreshing `time_updated` resurfaces the restored session at the top, where the app loads it (this is also the intuitive meaning of "restore").
218
- - **Permission.** No extra permission is needed: the existing `external_directory: { "~/.local/share/opencode/**": "allow" }` rule already covers read+write access to the DB file.
219
- - **After restoring.** An external write emits no `session.updated` event, so an already-open OpenCode window won't update live. **Reload/restart the window** and open OpenCode in the session's **directory** (sessions are listed per directory). Because `time_updated` is refreshed, the restored session then appears at the top of the list.
220
-
221
- ---
222
-
223
- ## Configuration
224
-
225
- All paths are env-overridable:
226
-
227
- | Env var | Default | Purpose |
228
- | -------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------ |
229
- | `OPENCODE_SESSIONS_EXPLORER_DB` | `$XDG_DATA_HOME/opencode/opencode.db` (Linux/Mac) / `%LOCALAPPDATA%/opencode/opencode.db` (Win) | Path to the OpenCode SQLite DB |
230
- | `OPENCODE_SESSIONS_EXPLORER_EXPORT_ROOT` | `$XDG_DATA_HOME/opencode-sessions-explorer` | Where to materialize searchable session content |
231
- | `OPENCODE_SESSIONS_EXPLORER_TOOL_OUTPUT_DIR` | `$XDG_DATA_HOME/opencode/tool-output` | Whitelist root for `get-part` dereference |
232
- | `OPENCODE_SESSIONS_EXPLORER_CK_BIN` | `ck` (via $PATH) | Override `ck` binary location |
233
-
234
- ---
235
-
236
- ## Privacy
237
-
238
- The plugin exposes **all your prior OpenCode conversations** to the LLM — including tool inputs/outputs that may contain credentials, API tokens, file contents, and other sensitive material. Consider:
239
-
240
- - The `search-text` and `grep-session` tools redact common secret shapes (`AKIA…`, `ghp_…`, `sk-…`, JWTs, bearer tokens, etc.) in returned snippets by default. Pass `redact:false` only for explicit local forensics.
241
- - All access is **local read-only** — no data leaves your machine via this plugin.
242
- - The `external_directory` permission rule is required because the DB lives outside your project workspace; you grant it explicitly.
243
-
244
- ---
245
-
246
- ## Development
74
+ 1. (Optional) Build the `ck` index from the export root, not the repo root:
247
75
 
248
76
  ```bash
249
- # Install
250
- bun install
251
-
252
- # Typecheck
253
- bun run typecheck
254
-
255
- # Build to dist/
256
- bun run build
257
-
258
- # Run the rehearsal harness (hermetic by default; live DB via OPENCODE_SESSIONS_EXPLORER_LIVE=1)
259
- bun test
260
-
261
- # End-to-end verifier (compares tool output vs ground-truth SQL; needs a live DB)
262
- bun tests/verify-end-to-end.ts
263
-
264
- # Plugin invocation (sanity)
265
- bun src/plugin.ts
77
+ cd ~/.local/share/opencode-sessions-explorer
78
+ ck --index . # run in the export root, not the repo root
266
79
  ```
267
80
 
268
- ### Repo layout
81
+ 1. Run the health probe again to confirm the export and optional index state:
269
82
 
83
+ ```bash
84
+ bunx opencode-sessions-explorer-check-deps
270
85
  ```
271
- src/
272
- ├── plugin.ts default Plugin export — registers all 18 tools
273
- ├── tools/
274
- │ ├── index.ts registry { "opencode-sessions-explorer-…": toolDefinition, … }
275
- │ ├── current-session.ts 1 per tool — named const, not default export
276
- │ ├── unarchive-session.ts the only write tool (clears time_archived + resurfaces)
277
- │ └── (16 more)
278
- ├── lib/ shared internals (db, db-write, ck, export, decode, …)
279
- └── bin/
280
- ├── bulk-export.ts materializes session content for ck
281
- ├── dedupe-export.ts maintenance
282
- └── check-deps.ts install health probe
283
-
284
- tests/
285
- ├── rehearsal.test.ts read-only probes (hermetic fixture by default; live DB opt-in)
286
- ├── unarchive.test.ts write-path probes (run against a throwaway DB copy)
287
- ├── helpers.ts
288
- ├── fixtures.json session IDs used by the rehearsal probes
289
- └── verify-end-to-end.ts smoke verifier — runs every tool + compares vs SQL
290
- ```
291
-
292
- ---
293
-
294
- ## Status
295
86
 
296
- - 18 tools registered (17 read-only + 1 unarchive write)
297
- - Published on npm as [`opencode-sessions-explorer`](https://www.npmjs.com/package/opencode-sessions-explorer)
298
- - Test suite passing **hermetically by default** against a synthetic fixture DB (live-DB probes opt-in via `OPENCODE_SESSIONS_EXPLORER_LIVE=1`; unarchive write-path probes run against a throwaway DB copy)
299
- - 17/17 end-to-end tool verification passing (unarchive probed via the zero-mutation NOT_FOUND path)
300
- - Local and npm plugin installs verified end-to-end
87
+ The `external_directory` permission is required because the OpenCode database lives
88
+ outside your project workspace. For installing from source, version pinning, and the
89
+ full first-run walkthrough, see [docs/install.md](docs/install.md) and
90
+ [docs/getting-started.md](docs/getting-started.md).
91
+
92
+ ## Features
93
+
94
+ ### Recall and Navigation
95
+
96
+ - **Find your bearings.** `current-session`, `get-session`, and `session-summary`
97
+ report where you are and what a session contains.
98
+ - **Walk a session.** `session-timeline` and `session-genealogy` trace the
99
+ chronology and the parent/subagent chain.
100
+ - **Drill into detail.** `get-message` and `get-part` fetch individual messages and
101
+ parts, with optional tool-output dereference.
102
+ - **Browse and filter.** `list-sessions` and `search-sessions-meta` find sessions by
103
+ recency, agent, directory, title, or cost.
104
+ - See [docs/guides/recall-and-navigation.md](docs/guides/recall-and-navigation.md).
105
+
106
+ ### Content Search and Grep
107
+
108
+ - **Search across history.** `search-text` answers "where did I mention X?" with
109
+ curated session-first recall by default.
110
+ - **Grep one session.** `grep-session` scans a single session's curated channels,
111
+ with raw replay via `surface:'forensics'`.
112
+ - **Audit tool calls.** `search-tool-calls` finds every invocation of a command,
113
+ every read that errored, or all calls to a given MCP.
114
+ - See [docs/guides/search-and-grep.md](docs/guides/search-and-grep.md).
115
+
116
+ ### Cost and Usage Analysis
117
+
118
+ - **Spend by dimension.** `cost-by-project` breaks cost down by project, directory,
119
+ agent, or model.
120
+ - **Spend over time.** `cost-by-period` reports OpenCode spend per day, week, or month.
121
+ - **Failure and repetition signals.** `list-tool-failures` and
122
+ `list-repeated-prompts` surface recurring errors and duplicated questions.
123
+ - See [docs/guides/cost-and-usage-analysis.md](docs/guides/cost-and-usage-analysis.md).
124
+
125
+ ### Export and Maintenance
126
+
127
+ - **One-time export.** `bulk-export` materializes searchable session content for `ck`.
128
+ - **Stay current.** The plugin auto-syncs new parts before each search call; rebuild
129
+ the optional semantic index when you want embeddings.
130
+ - **Health probe.** `check-deps` and the `db-stats` tool report dependency and schema
131
+ health.
132
+ - See [docs/guides/export-and-maintenance.md](docs/guides/export-and-maintenance.md).
133
+
134
+ ### Archived Session Recovery
135
+
136
+ - **Restore a buried session.** `unarchive-session` is the one write tool — it clears
137
+ `time_archived` **and** refreshes `time_updated` so the session resurfaces at the
138
+ top of the per-directory list and can be opened again.
139
+ - See [docs/guides/manage-archived-sessions.md](docs/guides/manage-archived-sessions.md).
140
+
141
+ ### Privacy and Safety
142
+
143
+ - **Local and read-only by default.** 17 of 18 tools never write; no data leaves your
144
+ device through this plugin.
145
+ - **Secret redaction.** `search-text` / `grep-session` redact common secret shapes in
146
+ snippets by default; `get-part` dereference is path-guarded to a whitelist root.
147
+ - See [docs/reference/configuration.md](docs/reference/configuration.md) and
148
+ [.github/SECURITY.md](.github/SECURITY.md).
149
+
150
+ ## Documentation
151
+
152
+ Docs home: [docs/README.md](docs/README.md)
153
+
154
+ | Goal | Doc |
155
+ | --- | --- |
156
+ | Install and first run | [docs/install.md](docs/install.md), [docs/getting-started.md](docs/getting-started.md) |
157
+ | Recall and navigation | [docs/guides/recall-and-navigation.md](docs/guides/recall-and-navigation.md) |
158
+ | Search and grep | [docs/guides/search-and-grep.md](docs/guides/search-and-grep.md) |
159
+ | Cost and usage analysis | [docs/guides/cost-and-usage-analysis.md](docs/guides/cost-and-usage-analysis.md) |
160
+ | Export and maintenance | [docs/guides/export-and-maintenance.md](docs/guides/export-and-maintenance.md) |
161
+ | Archived session recovery | [docs/guides/manage-archived-sessions.md](docs/guides/manage-archived-sessions.md) |
162
+ | Tool reference | [docs/reference/tools.md](docs/reference/tools.md) |
163
+ | Configuration | [docs/reference/configuration.md](docs/reference/configuration.md) |
164
+ | Search surfaces | [docs/reference/search-surfaces.md](docs/reference/search-surfaces.md) |
165
+ | Response format | [docs/reference/response-format.md](docs/reference/response-format.md) |
166
+ | Architecture | [docs/reference/architecture.md](docs/reference/architecture.md) |
167
+ | Troubleshooting | [docs/support/troubleshooting.md](docs/support/troubleshooting.md) |
168
+ | Maintainer and release | [docs/maintainers/development.md](docs/maintainers/development.md), [docs/maintainers/release.md](docs/maintainers/release.md) |
169
+ | Change log | [CHANGELOG.md](CHANGELOG.md) |
170
+
171
+ ## Contributing
172
+
173
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
301
174
 
302
175
  ## License
303
176
 
package/dist/plugin.js CHANGED
@@ -13633,7 +13633,7 @@ function safe(fn) {
13633
13633
 
13634
13634
  // src/tools/db-stats.ts
13635
13635
  var dbStats = tool({
13636
- description: "opencode-sessions-explorer: health probe for the local OpenCode SQLite database (~/.local/share/opencode/opencode.db). " + "Returns migration head, table counts (session/message/part), json1 extension status, busy_timeout, and any schema-drift warnings. " + "Run this when troubleshooting: any opencode-sessions-explorer-* tool returning SCHEMA_DRIFT, after an OpenCode upgrade, when verifying the DB is reachable, or when answering 'is opencode.db healthy / what schema is it on / how many sessions are stored'.",
13636
+ description: "opencode-sessions-explorer: health probe for the OpenCode SQLite database (~/.local/share/opencode/opencode.db). " + "Returns migration head, table counts (session/message/part), json1 extension status, busy_timeout, and any schema-drift warnings. " + "Run this when troubleshooting: any opencode-sessions-explorer-* tool returning SCHEMA_DRIFT, after an OpenCode upgrade, when verifying the DB is reachable, or when answering 'is opencode.db healthy / what schema is it on / how many sessions are stored'.",
13637
13637
  args: {},
13638
13638
  async execute() {
13639
13639
  return runWithEnvelope("db_stats", 8, async () => {
package/docs/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Documentation
2
+
3
+ This documentation is organized by intent so you can find the shortest path from
4
+ a question about your OpenCode session history to the tool or command that answers it.
5
+
6
+ ## How To Navigate This Docs Set
7
+
8
+ - Start pages help with install and the first successful query.
9
+ - Guides explain workflows and decision points across the 18 tools and 3 CLIs.
10
+ - Reference pages define stable tools, options, search surfaces, and response shapes.
11
+ - Support pages diagnose failures.
12
+ - Maintainer pages describe contributor and release operations.
13
+
14
+ ## Start Here
15
+
16
+ - [Getting Started](getting-started.md): prerequisites, setup, and first successful query.
17
+ - [Install](install.md): plugin registration, version pinning, and from-source setup.
18
+
19
+ ## Find By Task
20
+
21
+ | If You Need To... | Read |
22
+ | --- | --- |
23
+ | Install the plugin and run a first query | [getting-started.md](getting-started.md), [install.md](install.md) |
24
+ | Recall a session and drill into its content | [guides/recall-and-navigation.md](guides/recall-and-navigation.md) |
25
+ | Search across your whole session history | [guides/search-and-grep.md](guides/search-and-grep.md) |
26
+ | Grep inside one known session | [guides/search-and-grep.md](guides/search-and-grep.md) |
27
+ | Analyze cost and usage | [guides/cost-and-usage-analysis.md](guides/cost-and-usage-analysis.md) |
28
+ | Export and maintain the search tree | [guides/export-and-maintenance.md](guides/export-and-maintenance.md) |
29
+ | Recover an archived session | [guides/manage-archived-sessions.md](guides/manage-archived-sessions.md) |
30
+ | Read the full tool reference | [reference/tools.md](reference/tools.md) |
31
+ | Configure paths, env vars, and behavior | [reference/configuration.md](reference/configuration.md) |
32
+ | Understand the response/envelope format | [reference/response-format.md](reference/response-format.md) |
33
+ | Understand the architecture | [reference/architecture.md](reference/architecture.md) |
34
+ | Diagnose an environment or workflow failure | [support/troubleshooting.md](support/troubleshooting.md) |
35
+
36
+ ## Maintainers
37
+
38
+ - [Development Guide](maintainers/development.md)
39
+ - [Release Guide](maintainers/release.md)
40
+ - [Triage Guide](maintainers/triage.md)
41
+ - [Docs Writing Standard](maintainers/docs-writing.md)
42
+
43
+ ## Roadmap
44
+
45
+ - [Changelog](../CHANGELOG.md)
@@ -0,0 +1,96 @@
1
+ # Getting Started
2
+
3
+ ## Purpose
4
+
5
+ Get from a fresh install to a first successful query against your OpenCode session
6
+ history, then branch into the right workflow guide.
7
+
8
+ ## Prerequisites
9
+
10
+ | Area | Requirement |
11
+ | --- | --- |
12
+ | OpenCode | A working OpenCode install that has run at least once (it owns the source database) and a plugin host compatible with `@opencode-ai/plugin >= 1.15.0` |
13
+ | Bun | `>= 1.0` runtime; the plugin uses `bun:sqlite`, which should include SQLite `json1`. OpenCode ships Bun, so a standalone install is only needed to run the bundled CLIs directly. `check-deps` / `db-stats` verify it. |
14
+ | `ck` (optional) | [`ck`](https://github.com/BeaconBay/ck) `>= 0.7`, required only by `search-text` and `grep-session`; the other 16 tools work without it |
15
+
16
+ ## Steps
17
+
18
+ 1. Register the plugin and grant access to the OpenCode data directory in
19
+ `~/.config/opencode/opencode.json`:
20
+
21
+ ```jsonc
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
+ The `external_directory` allow rule is required because the OpenCode database
34
+ lives outside your project workspace. This snippet covers the common macOS/Linux
35
+ default path. If `$XDG_DATA_HOME`, Windows `%LOCALAPPDATA%`, or
36
+ `OPENCODE_SESSIONS_EXPLORER_DB` points elsewhere, allow the actual containing
37
+ directory and restart OpenCode. Some global configs use
38
+ `external_directory: "allow"`; that also permits access, but the scoped path rule
39
+ is preferred for normal users.
40
+
41
+ 1. Quit and restart OpenCode. It auto-installs npm plugins with Bun on startup, so
42
+ there is no separate `npm install` step, and all 18 tools auto-register.
43
+
44
+ 1. Run the install health probe before exporting. Warnings for a missing export
45
+ tree, missing `ck`, or missing `ck` index are expected on a fresh install:
46
+
47
+ ```bash
48
+ bunx opencode-sessions-explorer-check-deps
49
+ ```
50
+
51
+ 1. Materialize the searchable export tree once so content search has data to scan:
52
+
53
+ ```bash
54
+ bunx opencode-sessions-explorer-bulk-export
55
+ ```
56
+
57
+ 1. (Optional) Build the semantic index to enable `mode:'sem'` and `mode:'hybrid'`
58
+ search. This is a slow, one-time pass. Run it in the export root, not in the
59
+ repository checkout:
60
+
61
+ ```bash
62
+ cd ~/.local/share/opencode-sessions-explorer
63
+ ck --index . # run in the export root, not the repo root
64
+ ```
65
+
66
+ 1. Run the install health probe again and confirm there are no hard failures:
67
+
68
+ ```bash
69
+ bunx opencode-sessions-explorer-check-deps
70
+ ```
71
+
72
+ ## Validate
73
+
74
+ 1. Read the final `check-deps` output. It reports database reachability, schema and
75
+ drift, SQLite `json1`, `busy_timeout`, export tree, channel views, `ck` CLI,
76
+ `ck` index, and tool-output directory status. Exit code `0` means all green, `1`
77
+ means optional pieces are missing, and `2` means the plugin cannot work yet.
78
+
79
+ 1. In OpenCode, ask an orientation question such as "what session am I in?" — the
80
+ model routes to `current-session` and returns this session's id, agent, model,
81
+ directory, and useful paths.
82
+
83
+ ## Next Steps
84
+
85
+ - Recall and navigation: [guides/recall-and-navigation.md](guides/recall-and-navigation.md)
86
+ - Search and grep: [guides/search-and-grep.md](guides/search-and-grep.md)
87
+ - Cost and usage analysis: [guides/cost-and-usage-analysis.md](guides/cost-and-usage-analysis.md)
88
+ - Export and maintenance: [guides/export-and-maintenance.md](guides/export-and-maintenance.md)
89
+ - Manage archived sessions: [guides/manage-archived-sessions.md](guides/manage-archived-sessions.md)
90
+
91
+ ## Related Docs
92
+
93
+ - [Install](install.md)
94
+ - [Tool reference](reference/tools.md)
95
+ - [Configuration reference](reference/configuration.md)
96
+ - [Troubleshooting](support/troubleshooting.md)