human-hindsight 1.6.0 → 1.7.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.**
@@ -117,9 +118,9 @@ npx human-hindsight status # pipeline funnel + orphan/skip flags
117
118
  npx human-hindsight retention # optional: preview longer local retention
118
119
  ```
119
120
 
120
- Requires Node ≥ 22 on macOS or Linux (Windows is untested and currently
121
+ Requires Node 22.13+ on Node 22, or Node 23.4+ on newer releases, on macOS or Linux (Windows is untested and currently
121
122
  unsupported). `scan` and `export` are fully deterministic: no LLM, no
122
- network. `distill` uses your installed `claude`, `codex`, or `kiro-cli`,
123
+ network. `distill` uses your installed `claude`, `codex`, `kiro-cli`, or `opencode`,
123
124
  with a consent prompt (or your explicit `--yes`).
124
125
 
125
126
  ### A small local library viewer
@@ -142,9 +143,9 @@ no additional dependencies, frontend framework, database, or external assets.
142
143
  It listens only on `127.0.0.1`, serves a read-only library API, and stops with
143
144
  Ctrl+C. The GUI doesn't invoke an agent or modify your library.
144
145
 
145
- ### Multiple backends (Claude Code + Codex + kiro-cli)
146
+ ### Multiple backends (Claude Code + Codex + Kiro + OpenCode)
146
147
 
147
- Every command takes `--source claude|codex|kiro|auto` (default `auto`: read
148
+ Every command takes `--source claude|codex|kiro|opencode|auto` (default `auto`: read
148
149
  whichever stores exist). Select the source after the subcommand. Directory
149
150
  flags work before or after it:
150
151
 
@@ -153,6 +154,15 @@ flags work before or after it:
153
154
  | Claude Code | `--claude-dir` | `CLAUDE_CONFIG_DIR` | `~/.claude` |
154
155
  | Codex | `--codex-dir` | `CODEX_HOME` | `~/.codex` |
155
156
  | kiro-cli | `--kiro-dir` | `KIRO_CONFIG_DIR` | `~/.kiro` |
157
+ | OpenCode | `--opencode-dir` | `HUMAN_HINDSIGHT_OPENCODE_DIR`, then `XDG_DATA_HOME` | `~/.local/share/opencode` |
158
+
159
+ For OpenCode, `--opencode-db` selects a database explicitly; relative names
160
+ resolve under the data directory. It overrides `HUMAN_HINDSIGHT_OPENCODE_DB`
161
+ and OpenCode's `OPENCODE_DB`, with `opencode.db` as the default. An in-memory
162
+ database has no persisted history to read. Configuration is separate:
163
+ `OPENCODE_CONFIG_DIR` or the XDG config directory, normally `~/.config/opencode`.
164
+ Human Hindsight's directory/database flags select source history; the OpenCode
165
+ runner uses the CLI's normal data location and authentication.
156
166
 
157
167
  Multiple stores merge into one library; the manifest tags each session's
158
168
  `origin` and the export summary breaks the count down. Codex discovery includes
@@ -163,9 +173,9 @@ survive extraction. The kiro backend
163
173
  reads both on-disk store layouts (the flat v2 store and the newer v3 per-session
164
174
  store), preferring the v3 copy when a session was migrated into both.
165
175
 
166
- `distill --runner claude|codex|kiro|auto` chooses which CLI does the distilling,
176
+ `distill --runner claude|codex|kiro|opencode|auto` chooses which CLI does the distilling,
167
177
  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
178
+ then falls back in the order Claude → Codex → Kiro → OpenCode. Models are passed through
169
179
  with `--model`; without it, the chosen CLI uses its configured default.
170
180
 
171
181
  ```bash
@@ -173,9 +183,13 @@ npx human-hindsight export --source codex
173
183
  npx human-hindsight distill --source codex --runner codex
174
184
  npx human-hindsight distill --source claude --runner codex
175
185
  npx human-hindsight preferences --target codex # AGENTS.md; alias of --target agents
186
+ npx human-hindsight export --source opencode
187
+ npx human-hindsight distill --source opencode --runner opencode
188
+ npx human-hindsight distill --source claude --runner opencode --model provider/model
189
+ npx human-hindsight preferences --target opencode # AGENTS.md
176
190
  ```
177
191
 
178
- `preferences --target claude|codex|kiro|agents` emits a `CLAUDE.md` block,
192
+ `preferences --target claude|codex|kiro|opencode|agents` emits a `CLAUDE.md` block,
179
193
  an `AGENTS.md` section, or a block for `~/.kiro/steering/`. An explicit Codex
180
194
  source defaults to `AGENTS.md`. The Codex runner uses `codex exec` with a JSON
181
195
  schema, a read-only sandbox, and ephemeral sessions; generated distill sessions
@@ -183,6 +197,42 @@ do not become new source history. Claude supports current `structured_output`
183
197
  results as well as legacy `result` objects/strings and verbose event arrays.
184
198
  It disables session persistence when the installed CLI advertises the flag.
185
199
 
200
+ ### OpenCode 1 and 2
201
+
202
+ OpenCode support covers both current release families: `opencode-ai` 1.19
203
+ (verified with 1.19.4) and `@opencode/cli` 2.1 (verified with 2.1.3).
204
+ Both install an `opencode` command. Source discovery does not need the CLI.
205
+
206
+ The reader handles OpenCode 1's session/message/part SQLite tables, OpenCode 2's
207
+ ordered message records, and recognized older `storage/session`, `storage/message`,
208
+ and `storage/part` JSON directories. It includes archived sessions, preserves
209
+ question answers and attachment markers, and excludes generated subagent and
210
+ distillation sessions. Completed compaction resets short-reply context;
211
+ explicit execution failures are included in the outcome evidence.
212
+
213
+ Read-only SQLite connections include committed WAL data. Human Hindsight never
214
+ migrates the source database. An unreadable, busy, unsupported, or incompletely
215
+ migrated OpenCode database stops export before replacing the manifest or pruning
216
+ existing exports. If migrated copies coexist, matching human turns are deduplicated;
217
+ divergent older copies keep distinct export names. Reverted tails are excluded.
218
+ Only committed conversation messages are read, not pending inbox items.
219
+
220
+ The OpenCode runner uses JSON events, validates the final answer, and permits one
221
+ corrective retry. It copies provider/model settings from JSON or JSONC into an
222
+ owner-only temporary configuration, while OpenCode continues to handle credentials.
223
+ Project instructions, external agent plugins, and MCP configuration are not copied.
224
+ A dedicated agent denies tools; OpenCode 2 uses an owned private server.
225
+ Providers that require external agent plugins may need a built-in or compatible
226
+ provider configuration for this runner.
227
+
228
+ Generated sessions are marked and excluded from future exports. After the run,
229
+ cleanup deletes only captured IDs whose title and working directory prove they
230
+ belong to that run. Interrupted runs or cleanup failures can leave marked sessions
231
+ behind. User settings and unrelated sessions are preserved.
232
+
233
+ OpenCode preferences can go into the project's `AGENTS.md`, or the global
234
+ `AGENTS.md` under your OpenCode config directory.
235
+
186
236
  ### Optional: keep more local history
187
237
 
188
238
  ```bash
@@ -208,6 +258,13 @@ create that tool's settings file. `--yes` alone never applies changes, and
208
258
  - **kiro-cli:** explains automatic persistence and `/chat save <path>` for
209
259
  additional copies. Its public settings reference does not document a
210
260
  retention-limit switch, so no configuration key is invented.
261
+ - **OpenCode:** reports the local data/config locations and archival guidance.
262
+ No supported full-session age/size retention setting is documented. OpenCode 2
263
+ keeps earlier messages after compaction and ignores the older `compaction.prune`
264
+ setting. Temporary overflow tool-output files have separate cleanup (seven days
265
+ in 2.1); output-size limits do not change that lifetime. This integration is
266
+ advisory and leaves compaction settings untouched. For an extra copy, use
267
+ `opencode session export <id>` on OpenCode 2 or `opencode export <id>` on OpenCode 1.
211
268
 
212
269
  Applying creates owner-only backups next to existing configuration files, then
213
270
  replaces each file atomically. Other settings are preserved; common Codex TOML
@@ -223,6 +280,10 @@ recover already deleted history.
223
280
  Setting references: [Claude retention](https://code.claude.com/docs/en/settings-reference#cleanupperioddays),
224
281
  [Codex configuration](https://developers.openai.com/codex/config-reference),
225
282
  and [Kiro conversation persistence](https://kiro.dev/docs/cli/chat/).
283
+ OpenCode references, pinned to the supported v2 release:
284
+ [compaction](https://github.com/anomalyco/opencode/blob/v2.1.3/services/www/src/docs/content/compaction.mdx),
285
+ [migration](https://github.com/anomalyco/opencode/blob/v2.1.3/services/www/src/docs/content/migrate-v1.mdx), and
286
+ [session commands](https://github.com/anomalyco/opencode/blob/v2.1.3/services/www/src/docs/content/cli/commands.mdx).
226
287
 
227
288
  ## Privacy & trust
228
289
 
@@ -230,15 +291,17 @@ For a tool that reads your entire conversation history, auditability is the
230
291
  product:
231
292
 
232
293
  - **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
294
+ (`~/.human-hindsight`). No hosted service, accounts, or telemetry. The only network
234
295
  traffic is through your chosen agent CLI during consented distillation or
235
296
  preference consolidation.
236
- - **Four runtime dependencies.** [`citty`](https://github.com/unjs/citty)
297
+ - **Five runtime dependencies.** [`citty`](https://github.com/unjs/citty)
237
298
  (zero-dependency CLI framework), [`zod`](https://zod.dev) (schema
238
299
  validation), and [`@clack/prompts`](https://github.com/bombshell-dev/clack)
239
300
  (progress spinners), plus [`smol-toml`](https://github.com/squirrelchat/smol-toml)
240
301
  for safely preserving Codex configuration values during optional retention
241
- edits. All four are
302
+ edits, and [`jsonc-parser`](https://github.com/microsoft/node-jsonc-parser)
303
+ for reading OpenCode provider configuration without executing it. SQLite
304
+ comes from Node itself; no database addon or native compilation is required. All five are
242
305
  exact-pinned, and the entire transitive tree ships locked via
243
306
  `npm-shrinkwrap.json`. The whole data path is small enough to audit in one
244
307
  sitting.
@@ -258,12 +321,15 @@ flowchart TD
258
321
  A["~/.claude/projects/**/*.jsonl"] -->|"scan (read-only)"| B["inventory"]
259
322
  X["~/.codex/{sessions,archived_sessions}/**/rollout-*.jsonl"] --> B
260
323
  K["~/.kiro/sessions/"] --> B
324
+ O["~/.local/share/opencode/opencode.db"] --> B
261
325
  A -->|"export (deterministic)"| C["exports/*.md + manifest.json"]
262
326
  X --> C
263
327
  K --> C
328
+ O --> C
264
329
  A -->|"anaphora + outcome evidence"| D["anaphora.json + outcomes.json"]
265
330
  X --> D
266
331
  K --> D
332
+ O --> D
267
333
  C --> E
268
334
  D --> E
269
335
  subgraph distill ["distill: opt-in, consent-gated, resumable"]
@@ -328,7 +394,7 @@ provenance) or narrow the scope. Digest and author calls run 3 at a time by
328
394
  default (`--concurrency`; `1` = sequential).
329
395
 
330
396
  **Subscription or API?**
331
- human-hindsight shells out to `claude -p`, `codex exec`, or `kiro-cli chat`;
397
+ human-hindsight shells out to `claude -p`, `codex exec`, `kiro-cli chat`, or `opencode run`;
332
398
  however your chosen CLI is authenticated is how calls are billed. `--model`
333
399
  passes through without pinning a model version.
334
400