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
package/docs/install.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Install
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Register `opencode-sessions-explorer` in OpenCode, optionally pin a version, and
|
|
6
|
+
grant the one permission it needs to read the OpenCode session database.
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
| Area | Requirement |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| OpenCode | A working OpenCode install with plugin host compatibility for `@opencode-ai/plugin >= 1.15.0` |
|
|
13
|
+
| Bun | `>= 1.0`; bundled with OpenCode, needed standalone only to run the CLIs directly. The plugin uses `bun:sqlite`, which should include SQLite `json1`; `check-deps` / `db-stats` verify it. |
|
|
14
|
+
| `ck` (optional) | `>= 0.7`, only for `search-text` and `grep-session` |
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
1. Add the plugin to the `plugin` array in `~/.config/opencode/opencode.json`:
|
|
19
|
+
|
|
20
|
+
```jsonc
|
|
21
|
+
{
|
|
22
|
+
"$schema": "https://opencode.ai/config.json",
|
|
23
|
+
"plugin": ["opencode-sessions-explorer"]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
OpenCode auto-installs npm plugins with Bun on startup and caches them under
|
|
28
|
+
`~/.cache/opencode/node_modules`, so there is no separate install command.
|
|
29
|
+
|
|
30
|
+
1. (Optional) Pin a version to avoid surprise upgrades by appending the version to
|
|
31
|
+
the package spec (for example, the current latest):
|
|
32
|
+
|
|
33
|
+
```jsonc
|
|
34
|
+
{
|
|
35
|
+
"plugin": ["opencode-sessions-explorer@0.1.1"]
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
1. Grant access to the OpenCode data directory. This is required because the
|
|
40
|
+
database lives outside your project workspace:
|
|
41
|
+
|
|
42
|
+
```jsonc
|
|
43
|
+
{
|
|
44
|
+
"permission": {
|
|
45
|
+
"external_directory": {
|
|
46
|
+
"~/.local/share/opencode/**": "allow"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This default snippet covers the common macOS/Linux path. If `$XDG_DATA_HOME`,
|
|
53
|
+
Windows `%LOCALAPPDATA%`, or `OPENCODE_SESSIONS_EXPLORER_DB` points elsewhere,
|
|
54
|
+
allow the actual containing directory and restart OpenCode. Some current global
|
|
55
|
+
configs may use `external_directory: "allow"`; that works, but the scoped path
|
|
56
|
+
rule above is preferred for normal users.
|
|
57
|
+
|
|
58
|
+
1. Quit and restart OpenCode. All 18 tools auto-register on the next launch.
|
|
59
|
+
|
|
60
|
+
### From Source (Dev)
|
|
61
|
+
|
|
62
|
+
To run a local checkout instead of the published package, install dependencies in
|
|
63
|
+
the checkout first:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
bun install --frozen-lockfile
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Then choose one source-dev mode.
|
|
70
|
+
|
|
71
|
+
#### Option A: Source TypeScript For Iteration
|
|
72
|
+
|
|
73
|
+
Point the `plugin` array at the source entrypoint using an absolute path:
|
|
74
|
+
|
|
75
|
+
```jsonc
|
|
76
|
+
{
|
|
77
|
+
"plugin": ["/absolute/path/to/opencode-sessions-explorer/src/plugin.ts"]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This is the fastest iteration path because there is no `dist/` rebuild step, but a
|
|
82
|
+
full OpenCode restart is still required after config or code changes. Do not assume
|
|
83
|
+
hot reload.
|
|
84
|
+
|
|
85
|
+
#### Option B: Built JavaScript
|
|
86
|
+
|
|
87
|
+
Build the bundle, then point OpenCode at the built entrypoint:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
bun run build
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```jsonc
|
|
94
|
+
{
|
|
95
|
+
"plugin": ["/absolute/path/to/opencode-sessions-explorer/dist/plugin.js"]
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
When using `dist/`, rebuild and fully restart OpenCode after code changes. There is
|
|
100
|
+
no hot reload guarantee for local plugin paths.
|
|
101
|
+
|
|
102
|
+
For contributor commands, quality gates, and source-dev maintenance pointers, see
|
|
103
|
+
the [Development Guide](maintainers/development.md).
|
|
104
|
+
|
|
105
|
+
## Validate
|
|
106
|
+
|
|
107
|
+
Confirm the install resolved and the database is reachable:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
bunx opencode-sessions-explorer-check-deps
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
For source checkouts, run local checkout commands instead of `bunx` while iterating:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
bun src/bin/check-deps.ts
|
|
117
|
+
bun src/bin/bulk-export.ts
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
If you selected the built-JS option and have already run `bun run build`, you can
|
|
121
|
+
also validate the built CLI:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
bun dist/bin/check-deps.js
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
A `0` exit code is all green; `1` flags optional pieces (such as a missing export
|
|
128
|
+
tree or `ck`); `2` means a hard failure that must be fixed before the tools work.
|
|
129
|
+
|
|
130
|
+
## Next Steps
|
|
131
|
+
|
|
132
|
+
Continue with [getting-started.md](getting-started.md) to materialize the search
|
|
133
|
+
export and run a first query.
|
|
134
|
+
|
|
135
|
+
## Related Docs
|
|
136
|
+
|
|
137
|
+
- [Getting Started](getting-started.md)
|
|
138
|
+
- [Configuration reference](reference/configuration.md)
|
|
139
|
+
- [Development Guide](maintainers/development.md)
|
|
140
|
+
- [Troubleshooting](support/troubleshooting.md)
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Development Guide
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define the local contributor workflow, quality gates, and project-specific
|
|
6
|
+
gotchas for `opencode-sessions-explorer`.
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
- [Bun](https://bun.sh) >= 1.0. OpenCode ships Bun; install it standalone only if
|
|
11
|
+
you run the bundled CLIs directly. The runtime is Bun, not Node — the plugin
|
|
12
|
+
uses `bun:sqlite`, which should include SQLite `json1`; `check-deps` / `db-stats`
|
|
13
|
+
verify it.
|
|
14
|
+
- An OpenCode plugin host compatible with `@opencode-ai/plugin >= 1.15.0`.
|
|
15
|
+
- [`ck`](https://github.com/BeaconBay/ck) >= 0.7 — required only when working on
|
|
16
|
+
`search-text` / `grep-session`; the other 16 tools work without it.
|
|
17
|
+
- A populated OpenCode SQLite DB at `~/.local/share/opencode/opencode.db` —
|
|
18
|
+
required only for live testing and the end-to-end verifier.
|
|
19
|
+
|
|
20
|
+
## Local Setup
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bun install --frozen-lockfile
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Load the plugin into a running OpenCode while iterating by pointing the config at
|
|
27
|
+
your local checkout. Use the source TypeScript or built JavaScript options in
|
|
28
|
+
[Install: From Source (Dev)](../install.md#from-source-dev); that page is the
|
|
29
|
+
authoritative source-dev registration flow, including the full-restart requirement.
|
|
30
|
+
|
|
31
|
+
## Local Dev Loop
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
bun run typecheck # tsc --noEmit (strict mode)
|
|
35
|
+
bun test # hermetic by default
|
|
36
|
+
bun run build # bundle to dist/
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For changes that affect tool output, also run the end-to-end verifier, which
|
|
40
|
+
compares each tool against ground-truth SQL (this one needs a live DB):
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun tests/verify-end-to-end.ts
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Check install health any time:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bun src/bin/check-deps.ts
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For source-dev first-run validation, use the local checkout CLIs from
|
|
53
|
+
[Install](../install.md#validate) (`bun src/bin/check-deps.ts`,
|
|
54
|
+
`bun src/bin/bulk-export.ts`, or `bun dist/bin/check-deps.js` after a build) rather
|
|
55
|
+
than `bunx`, which exercises the published npm package.
|
|
56
|
+
|
|
57
|
+
## Architecture (pointer)
|
|
58
|
+
|
|
59
|
+
The plugin is a 4-layer pipeline:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
SQLite DB (read-only source of truth)
|
|
63
|
+
-> filesystem export tree (~/.local/share/opencode-sessions-explorer; by-session + by-channel)
|
|
64
|
+
-> ck index (.ck/; BM25 + embeddings; optional)
|
|
65
|
+
-> enriched response (re-fetches session/part metadata from SQLite per hit)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
See the [Architecture Reference](../reference/architecture.md) for the full layer
|
|
69
|
+
diagram and read-only / single-writer invariants, and the
|
|
70
|
+
[Export And Maintenance Guide](../guides/export-and-maintenance.md) for export/index
|
|
71
|
+
operations. `AGENTS.md` holds the authoritative per-tool contract.
|
|
72
|
+
|
|
73
|
+
## Environment Overrides
|
|
74
|
+
|
|
75
|
+
All paths are env-overridable, which is the easiest way to point tests or a dev
|
|
76
|
+
session at non-default locations:
|
|
77
|
+
|
|
78
|
+
| Env var | Purpose |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `OPENCODE_SESSIONS_EXPLORER_DB` | Path to the OpenCode SQLite DB |
|
|
81
|
+
| `OPENCODE_SESSIONS_EXPLORER_EXPORT_ROOT` | Where searchable session content is materialized |
|
|
82
|
+
| `OPENCODE_SESSIONS_EXPLORER_TOOL_OUTPUT_DIR` | Whitelist root for `get-part` dereference |
|
|
83
|
+
| `OPENCODE_SESSIONS_EXPLORER_CK_BIN` | Override the `ck` binary location |
|
|
84
|
+
|
|
85
|
+
## Tests: Hermetic vs Live
|
|
86
|
+
|
|
87
|
+
- `bun test` is **hermetic by default** — it runs against a synthetic fixture DB
|
|
88
|
+
and does not need your real history. This is what CI runs.
|
|
89
|
+
- To exercise the suite against your real `~/.local/share/opencode/opencode.db`,
|
|
90
|
+
opt in:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
OPENCODE_SESSIONS_EXPLORER_LIVE=1 bun test
|
|
94
|
+
# or
|
|
95
|
+
bun run test:live
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Live runs read real `ses_/msg_/prt_` IDs and minimum counts from your OpenCode
|
|
99
|
+
database; failures there reflect your own data, not necessarily a regression.
|
|
100
|
+
|
|
101
|
+
## The `.js`-Import Gotcha (do not "fix" it)
|
|
102
|
+
|
|
103
|
+
Inside `src/`, sibling imports use a **`.js`** extension even though the files are
|
|
104
|
+
`.ts`:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { stmt } from "../lib/db.js"; // the file is db.ts — this is correct
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
This is required by `tsc` (`moduleResolution: bundler`) and `bun build`. Rewriting
|
|
111
|
+
these to `.ts` will break typecheck and the build. Files under `tests/` import
|
|
112
|
+
`src` with `.ts`; that is fine, because Bun runs them unbuilt.
|
|
113
|
+
|
|
114
|
+
## Adding or Editing a Tool
|
|
115
|
+
|
|
116
|
+
- One tool per file in `src/tools/`, exported as a **named const** (not default).
|
|
117
|
+
- Register it in `src/tools/index.ts` under the
|
|
118
|
+
`opencode-sessions-explorer-<name>` key and the re-export block.
|
|
119
|
+
- Wrap the body in `runWithEnvelope("<fn_name>", capKb, async (ctx) => { … })`.
|
|
120
|
+
- Raise recoverable errors via `fail(code, msg, hint)` using a code from
|
|
121
|
+
`src/lib/errors.ts`; do not invent ad-hoc error shapes.
|
|
122
|
+
- Wrap list-shaped results in `table(records, { dict: [...] })` (lossless
|
|
123
|
+
columnar + interning).
|
|
124
|
+
|
|
125
|
+
See `AGENTS.md` for the authoritative, fully detailed version of this contract.
|
|
126
|
+
|
|
127
|
+
## Change Checklist
|
|
128
|
+
|
|
129
|
+
- Run `bun run typecheck`, `bun test`, and `bun run build` locally.
|
|
130
|
+
- For tool-output changes, run `bun tests/verify-end-to-end.ts`.
|
|
131
|
+
- Update [`README.md`](../../README.md) for any user-facing change.
|
|
132
|
+
- Add a note under `## [Unreleased]` in [`CHANGELOG.md`](../../CHANGELOG.md).
|
|
133
|
+
- Keep commit scope focused.
|
|
134
|
+
|
|
135
|
+
## Related Docs
|
|
136
|
+
|
|
137
|
+
- [Docs Writing Standard](docs-writing.md)
|
|
138
|
+
- [Install Guide](../install.md)
|
|
139
|
+
- [Release Guide](release.md)
|
|
140
|
+
- [Triage Guide](triage.md)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Docs Writing Standard
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define consistent structure, markdown style, and explanation patterns for
|
|
6
|
+
project docs.
|
|
7
|
+
|
|
8
|
+
## Core Principles
|
|
9
|
+
|
|
10
|
+
- Lead with user outcome, then steps, then edge cases.
|
|
11
|
+
- One page should have one clear intent.
|
|
12
|
+
- Prefer short concrete statements over broad prose.
|
|
13
|
+
- Use stable terms (`search-text`, `unarchive-session`, `OPENCODE_SESSIONS_EXPLORER_DB`)
|
|
14
|
+
consistently.
|
|
15
|
+
|
|
16
|
+
## Page Type Templates
|
|
17
|
+
|
|
18
|
+
### Start Pages
|
|
19
|
+
|
|
20
|
+
Use sections in this order:
|
|
21
|
+
|
|
22
|
+
1. `Purpose`
|
|
23
|
+
1. `Prerequisites`
|
|
24
|
+
1. `Setup` or `Steps`
|
|
25
|
+
1. `Validate` (how to confirm success)
|
|
26
|
+
1. `Next steps`
|
|
27
|
+
|
|
28
|
+
### Guides
|
|
29
|
+
|
|
30
|
+
Use sections in this order:
|
|
31
|
+
|
|
32
|
+
1. `Purpose`
|
|
33
|
+
1. `Default behavior` or `Mental model`
|
|
34
|
+
1. `Controls` or `Entry points`
|
|
35
|
+
1. `Recommended flow`
|
|
36
|
+
1. `Related docs`
|
|
37
|
+
|
|
38
|
+
### Reference Pages
|
|
39
|
+
|
|
40
|
+
Use sections in this order:
|
|
41
|
+
|
|
42
|
+
1. `Scope`
|
|
43
|
+
1. `Definitions/Tables`
|
|
44
|
+
1. `Examples`
|
|
45
|
+
1. `Related docs`
|
|
46
|
+
|
|
47
|
+
### Troubleshooting Pages
|
|
48
|
+
|
|
49
|
+
Use sections in this order:
|
|
50
|
+
|
|
51
|
+
1. `How to use this page`
|
|
52
|
+
1. `Baseline checks`
|
|
53
|
+
1. Symptom blocks (`Quick checks`, `Fix`)
|
|
54
|
+
1. `Related docs`
|
|
55
|
+
|
|
56
|
+
## Markdown Conventions
|
|
57
|
+
|
|
58
|
+
- Keep headings concise and in Title Case.
|
|
59
|
+
- Use numbered lists (`1.` style) for procedures.
|
|
60
|
+
- Use tables for command/option/tool inventories.
|
|
61
|
+
- Wrap commands, paths, options, env vars, and tool names in backticks.
|
|
62
|
+
- Prefer fenced code blocks with language identifiers.
|
|
63
|
+
- End pages with a `Related Docs` section.
|
|
64
|
+
|
|
65
|
+
## Explanation Pattern
|
|
66
|
+
|
|
67
|
+
Use this order for each important concept:
|
|
68
|
+
|
|
69
|
+
1. What it is
|
|
70
|
+
1. Why it matters
|
|
71
|
+
1. How to use it
|
|
72
|
+
1. How to validate it
|
|
73
|
+
1. Where to go next
|
|
74
|
+
|
|
75
|
+
## Link Policy
|
|
76
|
+
|
|
77
|
+
- Keep canonical maintainer pages under `docs/maintainers/`.
|
|
78
|
+
- Use relative links between docs and back to root files (`../../README.md`).
|
|
79
|
+
- Update the "Maintainer Docs" list in [`CONTRIBUTING.md`](../../CONTRIBUTING.md)
|
|
80
|
+
whenever docs paths or ownership change.
|
|
81
|
+
|
|
82
|
+
## Related Docs
|
|
83
|
+
|
|
84
|
+
- [Development Guide](development.md)
|
|
85
|
+
- [Release Guide](release.md)
|
|
86
|
+
- [Triage Guide](triage.md)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Release Guide
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define repeatable steps to cut and publish a release of
|
|
6
|
+
`opencode-sessions-explorer` to npm and GitHub.
|
|
7
|
+
|
|
8
|
+
## Versioning
|
|
9
|
+
|
|
10
|
+
Use [SemVer](https://semver.org/spec/v2.0.0.html):
|
|
11
|
+
|
|
12
|
+
- Major: breaking changes
|
|
13
|
+
- Minor: new features
|
|
14
|
+
- Patch: fixes and docs
|
|
15
|
+
|
|
16
|
+
## Release Checklist
|
|
17
|
+
|
|
18
|
+
1. Bump the version in `package.json` to the target `x.y.z`.
|
|
19
|
+
1. Move the `## [Unreleased]` notes in `CHANGELOG.md` into a new
|
|
20
|
+
`## [x.y.z] - YYYY-MM-DD` section, and leave an empty `## [Unreleased]`
|
|
21
|
+
above it for the next cycle.
|
|
22
|
+
1. Run the quality gates locally and confirm they pass:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bun run typecheck
|
|
26
|
+
bun test
|
|
27
|
+
bun run build
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
1. Confirm the **CI** workflow (`.github/workflows/ci.yml`) is green on the
|
|
31
|
+
commit you intend to tag.
|
|
32
|
+
1. Commit the version bump and changelog (for example
|
|
33
|
+
`chore(release): vX.Y.Z`).
|
|
34
|
+
1. Create an annotated tag and push it:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git tag -a vX.Y.Z -m "vX.Y.Z"
|
|
38
|
+
git push origin vX.Y.Z
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Pushing a `vX.Y.Z` tag triggers `.github/workflows/publish.yml`, which publishes
|
|
42
|
+
the package to npm with provenance and creates the GitHub Release from the
|
|
43
|
+
changelog entry.
|
|
44
|
+
|
|
45
|
+
## Publish Bootstrap (first release only)
|
|
46
|
+
|
|
47
|
+
The publish workflow is configured for npm
|
|
48
|
+
[Trusted Publishing (OIDC)](https://docs.npmjs.com/trusted-publishers), which
|
|
49
|
+
needs the package to already exist on npm before OIDC can be linked. Bootstrap it
|
|
50
|
+
once:
|
|
51
|
+
|
|
52
|
+
1. Create a short-lived **automation** npm token and add it to the repository as
|
|
53
|
+
the `NPM_TOKEN` secret.
|
|
54
|
+
1. Cut the first release (`v0.1.0`) so `publish.yml` publishes the initial
|
|
55
|
+
version to npm using that token.
|
|
56
|
+
1. In the npm package settings, configure **Trusted Publishing** for this repo's
|
|
57
|
+
`.github/workflows/publish.yml`.
|
|
58
|
+
1. **Revoke** the `NPM_TOKEN` secret and the npm token. Subsequent releases
|
|
59
|
+
authenticate via OIDC with no long-lived secret.
|
|
60
|
+
|
|
61
|
+
## Post-Release
|
|
62
|
+
|
|
63
|
+
- Verify the new version is live on
|
|
64
|
+
[npm](https://www.npmjs.com/package/opencode-sessions-explorer) and that the
|
|
65
|
+
GitHub Release was created.
|
|
66
|
+
- Monitor issues for regressions.
|
|
67
|
+
- Triage and label follow-up reports (see [Triage Guide](triage.md)).
|
|
68
|
+
|
|
69
|
+
## Related Docs
|
|
70
|
+
|
|
71
|
+
- [Development Guide](development.md)
|
|
72
|
+
- [Triage Guide](triage.md)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Triage Guide
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define issue intake, labeling, and follow-up policy. The canonical label
|
|
6
|
+
definitions live in [`.github/labels.yml`](../../.github/labels.yml); this guide
|
|
7
|
+
documents how they are applied.
|
|
8
|
+
|
|
9
|
+
## Intake Flow
|
|
10
|
+
|
|
11
|
+
1. Confirm issue template quality (clear repro, version, environment).
|
|
12
|
+
1. Reproduce the issue when possible.
|
|
13
|
+
1. Apply labels for type, status, and scope.
|
|
14
|
+
|
|
15
|
+
## Label Set
|
|
16
|
+
|
|
17
|
+
Issue type:
|
|
18
|
+
|
|
19
|
+
- `bug` — something is not working
|
|
20
|
+
- `enhancement` — new feature or request
|
|
21
|
+
- `documentation` — documentation updates
|
|
22
|
+
- `security` — security related issues
|
|
23
|
+
- `question` — further information requested
|
|
24
|
+
|
|
25
|
+
Contributor signals:
|
|
26
|
+
|
|
27
|
+
- `help wanted` — extra attention is needed
|
|
28
|
+
- `good first issue` — good for newcomers
|
|
29
|
+
|
|
30
|
+
Implementation focus:
|
|
31
|
+
|
|
32
|
+
- `tests` — test coverage or fixes
|
|
33
|
+
- `refactor` — refactoring or cleanup
|
|
34
|
+
- `chore` — maintenance tasks
|
|
35
|
+
|
|
36
|
+
Triage status:
|
|
37
|
+
|
|
38
|
+
- `triage/needs-info` — needs more information from the reporter
|
|
39
|
+
- `triage/confirmed` — repro confirmed by maintainers
|
|
40
|
+
- `triage/blocked` — blocked on an external dependency or upstream (e.g.
|
|
41
|
+
OpenCode or `ck`)
|
|
42
|
+
- `triage/duplicate` — duplicate of an existing issue
|
|
43
|
+
- `triage/wontfix` — will not be addressed
|
|
44
|
+
|
|
45
|
+
## Follow-Up Policy
|
|
46
|
+
|
|
47
|
+
- Close `triage/needs-info` after 14 days without a response.
|
|
48
|
+
- For `triage/blocked`, document the blocker and a recheck date.
|
|
49
|
+
- Close `triage/duplicate` with a link to the canonical issue.
|
|
50
|
+
- Close `triage/wontfix` with a concise rationale and alternatives when possible.
|
|
51
|
+
|
|
52
|
+
## Related Docs
|
|
53
|
+
|
|
54
|
+
- [Development Guide](development.md)
|
|
55
|
+
- [Release Guide](release.md)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Architecture Reference
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
This page describes the four-layer pipeline that turns the OpenCode session
|
|
6
|
+
database into enriched, searchable tool responses, and the single-writer exception
|
|
7
|
+
to the otherwise read-only design. It is a conceptual reference; for the
|
|
8
|
+
contributor-facing build and code layout, see the
|
|
9
|
+
[Development Guide](../maintainers/development.md).
|
|
10
|
+
|
|
11
|
+
## The Four Layers
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
L1 SQLite DB (read-only source of truth)
|
|
15
|
+
| PRAGMA query_only = 1; opened readonly
|
|
16
|
+
v
|
|
17
|
+
L2 filesystem export tree (~/.local/share/opencode-sessions-explorer)
|
|
18
|
+
| by-session/<ses_id>/... + by-channel/<channel>/by-session/<ses_id>/...
|
|
19
|
+
| delta-synced before each search call
|
|
20
|
+
v
|
|
21
|
+
L3 ck index (.ck/, BM25 + embeddings; optional)
|
|
22
|
+
| incremental; built by the ck CLI
|
|
23
|
+
v
|
|
24
|
+
L4 enriched response
|
|
25
|
+
| re-fetches session/part metadata from SQLite per hit
|
|
26
|
+
v
|
|
27
|
+
{ ok, data, meta, warnings } envelope
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### L1 — SQLite Source Of Truth
|
|
31
|
+
|
|
32
|
+
The OpenCode database is the authoritative source. The shared handle opens it
|
|
33
|
+
read-only and sets `PRAGMA query_only = 1` as a belt-and-braces guard, so any
|
|
34
|
+
accidental write through that handle throws. The live OpenCode process may be
|
|
35
|
+
writing concurrently — the database runs in WAL mode and multiple readers plus a
|
|
36
|
+
writer is safe, with a `busy_timeout` covering rare lock collisions. All metadata,
|
|
37
|
+
counts, and message/part bodies ultimately come from here.
|
|
38
|
+
|
|
39
|
+
### L2 — Filesystem Export Tree
|
|
40
|
+
|
|
41
|
+
Searchable content is materialized to a filesystem tree (default
|
|
42
|
+
`~/.local/share/opencode-sessions-explorer`, overridable via
|
|
43
|
+
`OPENCODE_SESSIONS_EXPLORER_EXPORT_ROOT`). It has two arms:
|
|
44
|
+
|
|
45
|
+
- `by-session/<ses_id>/` — the raw, lossless per-part export plus `meta.json`.
|
|
46
|
+
- `by-channel/<channel>/by-session/<ses_id>/` — curated channel views derived from
|
|
47
|
+
the raw parts (see [search-surfaces.md](search-surfaces.md)).
|
|
48
|
+
|
|
49
|
+
The tree is built once by `opencode-sessions-explorer-bulk-export` and then
|
|
50
|
+
delta-synced automatically before each `search-text` / `grep-session` call, so new
|
|
51
|
+
parts become searchable without a manual re-export. Sync is cursor-based on
|
|
52
|
+
`(time_updated, id)`, which also re-exports parts whose status mutated since the last
|
|
53
|
+
pass.
|
|
54
|
+
|
|
55
|
+
### L3 — ck Index (Optional)
|
|
56
|
+
|
|
57
|
+
`search-text` and `grep-session` shell out to the [`ck`](https://github.com/BeaconBay/ck)
|
|
58
|
+
CLI, which walks the export tree. `ck` supports plain regex with no index, a BM25
|
|
59
|
+
full-text index, and semantic embeddings; the index lives under `.ck/` in the export
|
|
60
|
+
root and is incremental. `ck` is optional: when it is absent these two tools return
|
|
61
|
+
`CK_NOT_FOUND` cleanly and the other 16 tools are unaffected.
|
|
62
|
+
|
|
63
|
+
### L4 — Enriched Response
|
|
64
|
+
|
|
65
|
+
Search hits from `ck` carry file paths, not domain objects. The final layer parses
|
|
66
|
+
the session and part ids out of each hit path and re-fetches fresh metadata from
|
|
67
|
+
SQLite (session title, agent, model, part type, message role) before returning
|
|
68
|
+
results. Every tool wraps its payload in a uniform `{ ok, data, meta, warnings }`
|
|
69
|
+
envelope; list-shaped data inside `data` uses the compact format described in
|
|
70
|
+
[response-format.md](response-format.md).
|
|
71
|
+
|
|
72
|
+
## Single-Writer Exception
|
|
73
|
+
|
|
74
|
+
The plugin is read-only with exactly one sanctioned write: `unarchive-session`.
|
|
75
|
+
Reads never write through the shared read-only handle. The write goes through a
|
|
76
|
+
separate, short-lived read-write connection that performs a single statement —
|
|
77
|
+
`UPDATE session SET time_archived = NULL, time_updated = <now>` — and closes
|
|
78
|
+
immediately.
|
|
79
|
+
|
|
80
|
+
Both fields are updated deliberately. OpenCode loads sessions ordered by
|
|
81
|
+
`time_updated DESC` with a default limit per directory, so clearing `time_archived`
|
|
82
|
+
alone would leave a long-archived session buried below that window, and opening it
|
|
83
|
+
would fail with "Unable to retrieve session". Refreshing `time_updated` resurfaces
|
|
84
|
+
the session at the top of the list, which is also the intuitive meaning of
|
|
85
|
+
"restore". OpenCode exposes no HTTP or SDK endpoint that can *clear* the archived
|
|
86
|
+
flag, so the direct database write is the only mechanism.
|
|
87
|
+
|
|
88
|
+
## Examples
|
|
89
|
+
|
|
90
|
+
Materialize the export tree (L2), then build the optional `ck` index (L3):
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
bunx opencode-sessions-explorer-bulk-export
|
|
94
|
+
cd ~/.local/share/opencode-sessions-explorer
|
|
95
|
+
ck --index . # run in the export root, not the repository checkout
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Verify all four layers are healthy:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
bunx opencode-sessions-explorer-check-deps
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Related Docs
|
|
105
|
+
|
|
106
|
+
- Tool catalog: [tools.md](tools.md)
|
|
107
|
+
- Search surfaces and channels: [search-surfaces.md](search-surfaces.md)
|
|
108
|
+
- Compact result format: [response-format.md](response-format.md)
|
|
109
|
+
- Configuration and environment overrides: [configuration.md](configuration.md)
|
|
110
|
+
- Export and maintenance workflow: [../guides/export-and-maintenance.md](../guides/export-and-maintenance.md)
|
|
111
|
+
- Development Guide: [../maintainers/development.md](../maintainers/development.md)
|
|
112
|
+
- Troubleshooting: [../support/troubleshooting.md](../support/troubleshooting.md)
|