human-hindsight 1.6.0 → 1.8.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.
package/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  npx human-hindsight
17
17
  ```
18
18
 
19
- Human Hindsight mines your coding-agent session history (Claude Code, Codex, kiro-cli)
19
+ Human Hindsight mines your coding-agent session history (Claude Code, Codex, Kiro, OpenCode)
20
20
  into two things you can use tomorrow morning:
21
21
 
22
22
  1. **A oneshot prompt library.** For each real task you've done, the realistic
@@ -64,7 +64,8 @@ All the evidence of what you *should* have said is already on disk. Claude Code
64
64
  saves session JSONL under `~/.claude/projects/`; Codex keeps rollouts under
65
65
  `~/.codex/sessions/` and `~/.codex/archived_sessions/`; kiro-cli keeps its
66
66
  own store under `~/.kiro/sessions` (both the flat `cli/<uuid>.jsonl` layout and
67
- the newer per-session `<hash>/sess_<uuid>/messages.jsonl` layout). Plenty of
67
+ the newer per-session `<hash>/sess_<uuid>/messages.jsonl` layout). OpenCode keeps
68
+ its SQLite history under `~/.local/share/opencode/`. Plenty of
68
69
  tools read that data for
69
70
  dashboards and transcripts. **Nobody closes the loop from history back to
70
71
  better prompting.**
@@ -86,12 +87,28 @@ The second prompt was knowable at t=0. You just hadn't written it yet.
86
87
 
87
88
  ## Quickstart
88
89
 
89
- One command builds the whole library and shows it to you when it's done:
90
+ Start the guided terminal workflow:
91
+
92
+ ```bash
93
+ npx human-hindsight@latest
94
+ ```
95
+
96
+ After scanning, the CLI suggests **export** and asks whether to run it.
97
+ Type `y` to continue. Export offers **distill**, and a successful distillation
98
+ offers the browser library. Your library directory, source, project filter,
99
+ runner, and model stay selected through the handoffs.
100
+
101
+ Distillation still shows its model-call plan and asks for spending consent.
102
+ Follow-up offers default to No and appear only in an interactive terminal.
103
+ Use `--no-follow-up` for one command at a time; pipes, dry runs, and scripted
104
+ `--yes` invocations never start these follow-up commands automatically.
105
+
106
+ You can also start directly with distillation:
90
107
 
91
108
  ```bash
92
109
  npx human-hindsight distill # offers to export first, then digest → cluster →
93
110
  # author (asks before any runner call), then shows
94
- # you the finished library
111
+ # offers the finished library in your browser
95
112
  ```
96
113
 
97
114
  Prefer to drive each stage yourself? The pipeline is just three verbs:
@@ -117,9 +134,9 @@ npx human-hindsight status # pipeline funnel + orphan/skip flags
117
134
  npx human-hindsight retention # optional: preview longer local retention
118
135
  ```
119
136
 
120
- Requires Node ≥ 22 on macOS or Linux (Windows is untested and currently
137
+ Requires Node 22.13+ on Node 22, or Node 23.4+ on newer releases, on macOS or Linux (Windows is untested and currently
121
138
  unsupported). `scan` and `export` are fully deterministic: no LLM, no
122
- network. `distill` uses your installed `claude`, `codex`, or `kiro-cli`,
139
+ network. `distill` uses your installed `claude`, `codex`, `kiro-cli`, or `opencode`,
123
140
  with a consent prompt (or your explicit `--yes`).
124
141
 
125
142
  ### A small local library viewer
@@ -131,20 +148,26 @@ npx human-hindsight gui --port 3210 # choose a port (default: any availab
131
148
  npx human-hindsight gui --home /path/to/library-home
132
149
  ```
133
150
 
134
- Search prompt titles and text, filter by domain, sort, and copy the prompt
135
- body with one click. The viewer shows your existing library, including local
136
- edits, ratings, and session counts. Use **Refresh** after changing files.
137
- Light and dark appearance follow your system setting, and the layout works
138
- on narrow screens. Press `/` to focus search.
151
+ Search titles and text, filter by domain, sort, and copy prompts with one click.
152
+ **Preview** renders Markdown headings, lists, tables, links, blockquotes, task
153
+ lists, and code blocks. **Markdown** shows the original source. Copy always
154
+ uses that original Markdown, including when the preview is selected.
155
+
156
+ The viewer uses a minimal black-and-white palette and system monospace fonts.
157
+ Light and dark appearance follow your system setting. Local edits, ratings,
158
+ and session counts remain visible. Use **Refresh** after changing files and
159
+ press `/` to focus search.
139
160
 
140
161
  The GUI uses Node's built-in HTTP server and bundled HTML/CSS/JavaScript:
141
- no additional dependencies, frontend framework, database, or external assets.
162
+ no frontend framework, database, font download, or external assets.
163
+ Markdown parsing and sanitization ship inside the bundle. Raw HTML stays
164
+ inert and remote images are represented by their alt text, without fetching them.
142
165
  It listens only on `127.0.0.1`, serves a read-only library API, and stops with
143
166
  Ctrl+C. The GUI doesn't invoke an agent or modify your library.
144
167
 
145
- ### Multiple backends (Claude Code + Codex + kiro-cli)
168
+ ### Multiple backends (Claude Code + Codex + Kiro + OpenCode)
146
169
 
147
- Every command takes `--source claude|codex|kiro|auto` (default `auto`: read
170
+ Every command takes `--source claude|codex|kiro|opencode|auto` (default `auto`: read
148
171
  whichever stores exist). Select the source after the subcommand. Directory
149
172
  flags work before or after it:
150
173
 
@@ -153,6 +176,15 @@ flags work before or after it:
153
176
  | Claude Code | `--claude-dir` | `CLAUDE_CONFIG_DIR` | `~/.claude` |
154
177
  | Codex | `--codex-dir` | `CODEX_HOME` | `~/.codex` |
155
178
  | kiro-cli | `--kiro-dir` | `KIRO_CONFIG_DIR` | `~/.kiro` |
179
+ | OpenCode | `--opencode-dir` | `HUMAN_HINDSIGHT_OPENCODE_DIR`, then `XDG_DATA_HOME` | `~/.local/share/opencode` |
180
+
181
+ For OpenCode, `--opencode-db` selects a database explicitly; relative names
182
+ resolve under the data directory. It overrides `HUMAN_HINDSIGHT_OPENCODE_DB`
183
+ and OpenCode's `OPENCODE_DB`, with `opencode.db` as the default. An in-memory
184
+ database has no persisted history to read. Configuration is separate:
185
+ `OPENCODE_CONFIG_DIR` or the XDG config directory, normally `~/.config/opencode`.
186
+ Human Hindsight's directory/database flags select source history; the OpenCode
187
+ runner uses the CLI's normal data location and authentication.
156
188
 
157
189
  Multiple stores merge into one library; the manifest tags each session's
158
190
  `origin` and the export summary breaks the count down. Codex discovery includes
@@ -163,9 +195,9 @@ survive extraction. The kiro backend
163
195
  reads both on-disk store layouts (the flat v2 store and the newer v3 per-session
164
196
  store), preferring the v3 copy when a session was migrated into both.
165
197
 
166
- `distill --runner claude|codex|kiro|auto` chooses which CLI does the distilling,
198
+ `distill --runner claude|codex|kiro|opencode|auto` chooses which CLI does the distilling,
167
199
  independently of `--source`. `auto` prefers the CLI matching an explicit source,
168
- then falls back in the order Claude → Codex → Kiro. Models are passed through
200
+ then falls back in the order Claude → Codex → Kiro → OpenCode. Models are passed through
169
201
  with `--model`; without it, the chosen CLI uses its configured default.
170
202
 
171
203
  ```bash
@@ -173,9 +205,13 @@ npx human-hindsight export --source codex
173
205
  npx human-hindsight distill --source codex --runner codex
174
206
  npx human-hindsight distill --source claude --runner codex
175
207
  npx human-hindsight preferences --target codex # AGENTS.md; alias of --target agents
208
+ npx human-hindsight export --source opencode
209
+ npx human-hindsight distill --source opencode --runner opencode
210
+ npx human-hindsight distill --source claude --runner opencode --model provider/model
211
+ npx human-hindsight preferences --target opencode # AGENTS.md
176
212
  ```
177
213
 
178
- `preferences --target claude|codex|kiro|agents` emits a `CLAUDE.md` block,
214
+ `preferences --target claude|codex|kiro|opencode|agents` emits a `CLAUDE.md` block,
179
215
  an `AGENTS.md` section, or a block for `~/.kiro/steering/`. An explicit Codex
180
216
  source defaults to `AGENTS.md`. The Codex runner uses `codex exec` with a JSON
181
217
  schema, a read-only sandbox, and ephemeral sessions; generated distill sessions
@@ -183,6 +219,42 @@ do not become new source history. Claude supports current `structured_output`
183
219
  results as well as legacy `result` objects/strings and verbose event arrays.
184
220
  It disables session persistence when the installed CLI advertises the flag.
185
221
 
222
+ ### OpenCode 1 and 2
223
+
224
+ OpenCode support covers both current release families: `opencode-ai` 1.19
225
+ (verified with 1.19.4) and `@opencode/cli` 2.1 (verified with 2.1.3).
226
+ Both install an `opencode` command. Source discovery does not need the CLI.
227
+
228
+ The reader handles OpenCode 1's session/message/part SQLite tables, OpenCode 2's
229
+ ordered message records, and recognized older `storage/session`, `storage/message`,
230
+ and `storage/part` JSON directories. It includes archived sessions, preserves
231
+ question answers and attachment markers, and excludes generated subagent and
232
+ distillation sessions. Completed compaction resets short-reply context;
233
+ explicit execution failures are included in the outcome evidence.
234
+
235
+ Read-only SQLite connections include committed WAL data. Human Hindsight never
236
+ migrates the source database. An unreadable, busy, unsupported, or incompletely
237
+ migrated OpenCode database stops export before replacing the manifest or pruning
238
+ existing exports. If migrated copies coexist, matching human turns are deduplicated;
239
+ divergent older copies keep distinct export names. Reverted tails are excluded.
240
+ Only committed conversation messages are read, not pending inbox items.
241
+
242
+ The OpenCode runner uses JSON events, validates the final answer, and permits one
243
+ corrective retry. It copies provider/model settings from JSON or JSONC into an
244
+ owner-only temporary configuration, while OpenCode continues to handle credentials.
245
+ Project instructions, external agent plugins, and MCP configuration are not copied.
246
+ A dedicated agent denies tools; OpenCode 2 uses an owned private server.
247
+ Providers that require external agent plugins may need a built-in or compatible
248
+ provider configuration for this runner.
249
+
250
+ Generated sessions are marked and excluded from future exports. After the run,
251
+ cleanup deletes only captured IDs whose title and working directory prove they
252
+ belong to that run. Interrupted runs or cleanup failures can leave marked sessions
253
+ behind. User settings and unrelated sessions are preserved.
254
+
255
+ OpenCode preferences can go into the project's `AGENTS.md`, or the global
256
+ `AGENTS.md` under your OpenCode config directory.
257
+
186
258
  ### Optional: keep more local history
187
259
 
188
260
  ```bash
@@ -208,6 +280,13 @@ create that tool's settings file. `--yes` alone never applies changes, and
208
280
  - **kiro-cli:** explains automatic persistence and `/chat save <path>` for
209
281
  additional copies. Its public settings reference does not document a
210
282
  retention-limit switch, so no configuration key is invented.
283
+ - **OpenCode:** reports the local data/config locations and archival guidance.
284
+ No supported full-session age/size retention setting is documented. OpenCode 2
285
+ keeps earlier messages after compaction and ignores the older `compaction.prune`
286
+ setting. Temporary overflow tool-output files have separate cleanup (seven days
287
+ in 2.1); output-size limits do not change that lifetime. This integration is
288
+ advisory and leaves compaction settings untouched. For an extra copy, use
289
+ `opencode session export <id>` on OpenCode 2 or `opencode export <id>` on OpenCode 1.
211
290
 
212
291
  Applying creates owner-only backups next to existing configuration files, then
213
292
  replaces each file atomically. Other settings are preserved; common Codex TOML
@@ -223,6 +302,10 @@ recover already deleted history.
223
302
  Setting references: [Claude retention](https://code.claude.com/docs/en/settings-reference#cleanupperioddays),
224
303
  [Codex configuration](https://developers.openai.com/codex/config-reference),
225
304
  and [Kiro conversation persistence](https://kiro.dev/docs/cli/chat/).
305
+ OpenCode references, pinned to the supported v2 release:
306
+ [compaction](https://github.com/anomalyco/opencode/blob/v2.1.3/services/www/src/docs/content/compaction.mdx),
307
+ [migration](https://github.com/anomalyco/opencode/blob/v2.1.3/services/www/src/docs/content/migrate-v1.mdx), and
308
+ [session commands](https://github.com/anomalyco/opencode/blob/v2.1.3/services/www/src/docs/content/cli/commands.mdx).
226
309
 
227
310
  ## Privacy & trust
228
311
 
@@ -230,18 +313,16 @@ For a tool that reads your entire conversation history, auditability is the
230
313
  product:
231
314
 
232
315
  - **Local-only.** Everything is read from your disk and written to your disk
233
- (`~/.human-hindsight`). No server, no accounts, no telemetry. The only network
316
+ (`~/.human-hindsight`). No hosted service, accounts, or telemetry. The only network
234
317
  traffic is through your chosen agent CLI during consented distillation or
235
318
  preference consolidation.
236
- - **Four runtime dependencies.** [`citty`](https://github.com/unjs/citty)
237
- (zero-dependency CLI framework), [`zod`](https://zod.dev) (schema
238
- validation), and [`@clack/prompts`](https://github.com/bombshell-dev/clack)
239
- (progress spinners), plus [`smol-toml`](https://github.com/squirrelchat/smol-toml)
240
- for safely preserving Codex configuration values during optional retention
241
- edits. All four are
242
- exact-pinned, and the entire transitive tree ships locked via
243
- `npm-shrinkwrap.json`. The whole data path is small enough to audit in one
244
- sitting.
319
+ - **One self-contained npm package.** JavaScript libraries are bundled into
320
+ the CLI; the published package has no npm dependencies or installation
321
+ scripts. SQLite comes from Node. Starting the app does not install compilers,
322
+ platform bindings, or build tools. The development dependency tree is pinned
323
+ in the repository's `package-lock.json`, which is not published. Bundled
324
+ libraries include citty, Zod, Clack, smol-toml, jsonc-parser, Marked, and
325
+ DOMPurify; their license texts ship in `dist/THIRD_PARTY_NOTICES.txt`.
245
326
  - **Consent-gated LLM use.** `distill` states the exact invocation count and
246
327
  waits for `[y/N]` before anything runs on your subscription/credits.
247
328
  `--dry-run` shows the full plan for free. If you decline, it exits without
@@ -258,12 +339,15 @@ flowchart TD
258
339
  A["~/.claude/projects/**/*.jsonl"] -->|"scan (read-only)"| B["inventory"]
259
340
  X["~/.codex/{sessions,archived_sessions}/**/rollout-*.jsonl"] --> B
260
341
  K["~/.kiro/sessions/"] --> B
342
+ O["~/.local/share/opencode/opencode.db"] --> B
261
343
  A -->|"export (deterministic)"| C["exports/*.md + manifest.json"]
262
344
  X --> C
263
345
  K --> C
346
+ O --> C
264
347
  A -->|"anaphora + outcome evidence"| D["anaphora.json + outcomes.json"]
265
348
  X --> D
266
349
  K --> D
350
+ O --> D
267
351
  C --> E
268
352
  D --> E
269
353
  subgraph distill ["distill: opt-in, consent-gated, resumable"]
@@ -328,7 +412,7 @@ provenance) or narrow the scope. Digest and author calls run 3 at a time by
328
412
  default (`--concurrency`; `1` = sequential).
329
413
 
330
414
  **Subscription or API?**
331
- human-hindsight shells out to `claude -p`, `codex exec`, or `kiro-cli chat`;
415
+ human-hindsight shells out to `claude -p`, `codex exec`, `kiro-cli chat`, or `opencode run`;
332
416
  however your chosen CLI is authenticated is how calls are billed. `--model`
333
417
  passes through without pinning a model version.
334
418