human-hindsight 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +446 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +8304 -0
- package/npm-shrinkwrap.json +2205 -0
- package/package.json +67 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cc-hindsight contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,447 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Human Hindsight
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **The prompt you'd write if you knew then what you know now.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/human-hindsight)
|
|
6
|
+
[](https://github.com/adityaarunsinghal/human-hindsight/actions/workflows/ci.yml)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](#privacy--trust)
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://raw.githubusercontent.com/adityaarunsinghal/human-hindsight/main/.github/assets/demo.gif" alt="Human Hindsight local prompt library" width="800">
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx human-hindsight
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Human Hindsight mines your coding-agent session history (Claude Code, Codex, Kiro, OpenCode)
|
|
20
|
+
into two things you can use tomorrow morning:
|
|
21
|
+
|
|
22
|
+
1. **A oneshot prompt library.** For each real task you've done, the realistic
|
|
23
|
+
ideal *first* prompt: everything you knew and wanted at t=0 but didn't say,
|
|
24
|
+
written in your own voice.
|
|
25
|
+
2. **A distilled preference set.** The things you keep re-telling your agent
|
|
26
|
+
("diagnose before acting", "pin the versions", "be terse"), surfaced as a
|
|
27
|
+
paste-ready `CLAUDE.md` or `AGENTS.md` block so every future session starts aligned.
|
|
28
|
+
|
|
29
|
+
Previously published as **cc-hindsight**. The `cc-hindsight` npm package is now a
|
|
30
|
+
deprecated compatibility command that forwards to the matching Human Hindsight
|
|
31
|
+
release. Existing libraries, edits, ratings, and checkpoints remain usable.
|
|
32
|
+
|
|
33
|
+
### Upgrading from cc-hindsight
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx human-hindsight@latest gui
|
|
37
|
+
# Or install the new command globally:
|
|
38
|
+
npm install -g human-hindsight
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
No data move or re-distillation is required. Data-directory precedence is:
|
|
42
|
+
`--home` → `HUMAN_HINDSIGHT_HOME` → legacy `CC_HINDSIGHT_HOME` → an existing
|
|
43
|
+
`~/.human-hindsight` → an existing `~/.cc-hindsight` → `~/.human-hindsight` for
|
|
44
|
+
a fresh installation. If both directories exist, the new one wins; use
|
|
45
|
+
`--home` to choose explicitly. Directories are never merged automatically.
|
|
46
|
+
|
|
47
|
+
Updating the old npm package installs the small compatibility wrapper, so
|
|
48
|
+
`npx cc-hindsight@latest gui` also works. Both global commands can coexist:
|
|
49
|
+
the main package owns `human-hindsight`, and the wrapper owns `cc-hindsight`.
|
|
50
|
+
The GitHub repository was renamed in place; old repository links redirect.
|
|
51
|
+
|
|
52
|
+
## The t=0 problem
|
|
53
|
+
|
|
54
|
+
You get better results the more context you front-load into your first prompt,
|
|
55
|
+
yet we underspecify at t=0 and spend the session steering: correcting course,
|
|
56
|
+
restating preferences, answering questions the agent shouldn't have had to ask.
|
|
57
|
+
|
|
58
|
+
And the cost repeats every session. Your working preferences are stable facts
|
|
59
|
+
about how you like to work, yet you re-derive and re-type them project after
|
|
60
|
+
project instead of stating them once, upfront, where every future session reads
|
|
61
|
+
them from the first message.
|
|
62
|
+
|
|
63
|
+
All the evidence of what you *should* have said is already on disk. Claude Code
|
|
64
|
+
saves session JSONL under `~/.claude/projects/`; Codex keeps rollouts under
|
|
65
|
+
`~/.codex/sessions/` and `~/.codex/archived_sessions/`; kiro-cli keeps its
|
|
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). OpenCode keeps
|
|
68
|
+
its SQLite history under `~/.local/share/opencode/`. Plenty of
|
|
69
|
+
tools read that data for
|
|
70
|
+
dashboards and transcripts. **Nobody closes the loop from history back to
|
|
71
|
+
better prompting.**
|
|
72
|
+
|
|
73
|
+
**Before** (what you actually typed at t=0):
|
|
74
|
+
|
|
75
|
+
> help me script blocking a device on my home router
|
|
76
|
+
|
|
77
|
+
**After** (what human-hindsight distilled from how that session actually went):
|
|
78
|
+
|
|
79
|
+
> I want to automate my home router, starting with blocking a device. Get API
|
|
80
|
+
> access working first, and store any credentials securely instead of asking me
|
|
81
|
+
> to paste them in the clear. Anything that changes the network should be safe
|
|
82
|
+
> by default: show me what it'll do and let me confirm before it runs. Then
|
|
83
|
+
> prove it end-to-end on a real device. Research how others have done this
|
|
84
|
+
> first, and keep the setup written down so I can reproduce it.
|
|
85
|
+
|
|
86
|
+
The second prompt was knowable at t=0. You just hadn't written it yet.
|
|
87
|
+
|
|
88
|
+
## Quickstart
|
|
89
|
+
|
|
90
|
+
One command builds the whole library and shows it to you when it's done:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npx human-hindsight distill # offers to export first, then digest → cluster →
|
|
94
|
+
# author (asks before any runner call), then shows
|
|
95
|
+
# you the finished library
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Prefer to drive each stage yourself? The pipeline is just three verbs:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx human-hindsight # 1. scan: inventory your projects (read-only)
|
|
102
|
+
npx human-hindsight export # 2. export: human-only markdown per session
|
|
103
|
+
npx human-hindsight distill # 3. distill: digest → cluster → author (asks first)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Then browse and curate the results:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npx human-hindsight list # your library (✎ edited / ▲▼ rating badges)
|
|
110
|
+
npx human-hindsight gui # browse, search, and copy in your browser
|
|
111
|
+
npx human-hindsight show <slug> # read a oneshot
|
|
112
|
+
npx human-hindsight copy <slug> # → clipboard, paste into a fresh session
|
|
113
|
+
npx human-hindsight edit <slug> # open in $EDITOR; your edits are protected
|
|
114
|
+
npx human-hindsight rate <slug> up # record a verdict (up|down)
|
|
115
|
+
npx human-hindsight prune # remove orphaned entries (asks first)
|
|
116
|
+
npx human-hindsight preferences # → CLAUDE.md block
|
|
117
|
+
npx human-hindsight status # pipeline funnel + orphan/skip flags
|
|
118
|
+
npx human-hindsight retention # optional: preview longer local retention
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Requires Node 22.13+ on Node 22, or Node 23.4+ on newer releases, on macOS or Linux (Windows is untested and currently
|
|
122
|
+
unsupported). `scan` and `export` are fully deterministic: no LLM, no
|
|
123
|
+
network. `distill` uses your installed `claude`, `codex`, `kiro-cli`, or `opencode`,
|
|
124
|
+
with a consent prompt (or your explicit `--yes`).
|
|
125
|
+
|
|
126
|
+
### A small local library viewer
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npx human-hindsight gui # start locally and open your browser
|
|
130
|
+
npx human-hindsight gui --no-open # print the address without opening it
|
|
131
|
+
npx human-hindsight gui --port 3210 # choose a port (default: any available port)
|
|
132
|
+
npx human-hindsight gui --home /path/to/library-home
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Search prompt titles and text, filter by domain, sort, and copy the prompt
|
|
136
|
+
body with one click. The viewer shows your existing library, including local
|
|
137
|
+
edits, ratings, and session counts. Use **Refresh** after changing files.
|
|
138
|
+
Light and dark appearance follow your system setting, and the layout works
|
|
139
|
+
on narrow screens. Press `/` to focus search.
|
|
140
|
+
|
|
141
|
+
The GUI uses Node's built-in HTTP server and bundled HTML/CSS/JavaScript:
|
|
142
|
+
no additional dependencies, frontend framework, database, or external assets.
|
|
143
|
+
It listens only on `127.0.0.1`, serves a read-only library API, and stops with
|
|
144
|
+
Ctrl+C. The GUI doesn't invoke an agent or modify your library.
|
|
145
|
+
|
|
146
|
+
### Multiple backends (Claude Code + Codex + Kiro + OpenCode)
|
|
147
|
+
|
|
148
|
+
Every command takes `--source claude|codex|kiro|opencode|auto` (default `auto`: read
|
|
149
|
+
whichever stores exist). Select the source after the subcommand. Directory
|
|
150
|
+
flags work before or after it:
|
|
151
|
+
|
|
152
|
+
| Source | Directory flag | Environment variable | Default |
|
|
153
|
+
|---|---|---|---|
|
|
154
|
+
| Claude Code | `--claude-dir` | `CLAUDE_CONFIG_DIR` | `~/.claude` |
|
|
155
|
+
| Codex | `--codex-dir` | `CODEX_HOME` | `~/.codex` |
|
|
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.
|
|
166
|
+
|
|
167
|
+
Multiple stores merge into one library; the manifest tags each session's
|
|
168
|
+
`origin` and the export summary breaks the count down. Codex discovery includes
|
|
169
|
+
active and archived rollouts from the CLI, IDE extension, and app, grouped by
|
|
170
|
+
their working directory. Mirrored user/assistant events are paired, injected
|
|
171
|
+
context and subagent sessions are excluded, and human decisions and images
|
|
172
|
+
survive extraction. The kiro backend
|
|
173
|
+
reads both on-disk store layouts (the flat v2 store and the newer v3 per-session
|
|
174
|
+
store), preferring the v3 copy when a session was migrated into both.
|
|
175
|
+
|
|
176
|
+
`distill --runner claude|codex|kiro|opencode|auto` chooses which CLI does the distilling,
|
|
177
|
+
independently of `--source`. `auto` prefers the CLI matching an explicit source,
|
|
178
|
+
then falls back in the order Claude → Codex → Kiro → OpenCode. Models are passed through
|
|
179
|
+
with `--model`; without it, the chosen CLI uses its configured default.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npx human-hindsight export --source codex
|
|
183
|
+
npx human-hindsight distill --source codex --runner codex
|
|
184
|
+
npx human-hindsight distill --source claude --runner codex
|
|
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
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`preferences --target claude|codex|kiro|opencode|agents` emits a `CLAUDE.md` block,
|
|
193
|
+
an `AGENTS.md` section, or a block for `~/.kiro/steering/`. An explicit Codex
|
|
194
|
+
source defaults to `AGENTS.md`. The Codex runner uses `codex exec` with a JSON
|
|
195
|
+
schema, a read-only sandbox, and ephemeral sessions; generated distill sessions
|
|
196
|
+
do not become new source history. Claude supports current `structured_output`
|
|
197
|
+
results as well as legacy `result` objects/strings and verbose event arrays.
|
|
198
|
+
It disables session persistence when the installed CLI advertises the flag.
|
|
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
|
+
|
|
236
|
+
### Optional: keep more local history
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
npx human-hindsight retention # read-only preview
|
|
240
|
+
npx human-hindsight retention --apply # preview, then confirm
|
|
241
|
+
npx human-hindsight retention --apply --yes # explicit opt-in for scripting
|
|
242
|
+
npx human-hindsight retention --source codex --apply
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The default reviews existing tool directories. An explicit `--source` can
|
|
246
|
+
create that tool's settings file. `--yes` alone never applies changes, and
|
|
247
|
+
`--dry-run` always keeps the command read-only.
|
|
248
|
+
|
|
249
|
+
- **Claude Code:** raises `cleanupPeriodDays` to 365,000 days (about 1,000
|
|
250
|
+
years), preserving an already longer value. Claude requires a positive whole
|
|
251
|
+
number; `0` is invalid. If desktop cleanup is capped, sets
|
|
252
|
+
`desktopSessionCleanupPeriodDays` to `0`, its supported no-age-limit value.
|
|
253
|
+
An absent desktop setting already has no age limit.
|
|
254
|
+
- **Codex:** sets `[history] persistence = "save-all"` and removes
|
|
255
|
+
`history.max_bytes`, leaving prompt history uncapped. This controls
|
|
256
|
+
`history.jsonl`; full session rollouts are stored separately. Avoid
|
|
257
|
+
`--ephemeral` for your own sessions you want to retain.
|
|
258
|
+
- **kiro-cli:** explains automatic persistence and `/chat save <path>` for
|
|
259
|
+
additional copies. Its public settings reference does not document a
|
|
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.
|
|
268
|
+
|
|
269
|
+
Applying creates owner-only backups next to existing configuration files, then
|
|
270
|
+
replaces each file atomically. Other settings are preserved; common Codex TOML
|
|
271
|
+
layouts retain comments, while unusual layouts may be reformatted after a
|
|
272
|
+
preview notice. Malformed configurations are left untouched.
|
|
273
|
+
|
|
274
|
+
Longer retention keeps prompt contents on disk longer and can use more space.
|
|
275
|
+
Restart running tools after applying settings. Project settings, profiles,
|
|
276
|
+
managed policy, and startup flags can override user defaults; this command
|
|
277
|
+
does not change those controls, remote retention, or telemetry. It cannot
|
|
278
|
+
recover already deleted history.
|
|
279
|
+
|
|
280
|
+
Setting references: [Claude retention](https://code.claude.com/docs/en/settings-reference#cleanupperioddays),
|
|
281
|
+
[Codex configuration](https://developers.openai.com/codex/config-reference),
|
|
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).
|
|
287
|
+
|
|
288
|
+
## Privacy & trust
|
|
289
|
+
|
|
290
|
+
For a tool that reads your entire conversation history, auditability is the
|
|
291
|
+
product:
|
|
292
|
+
|
|
293
|
+
- **Local-only.** Everything is read from your disk and written to your disk
|
|
294
|
+
(`~/.human-hindsight`). No hosted service, accounts, or telemetry. The only network
|
|
295
|
+
traffic is through your chosen agent CLI during consented distillation or
|
|
296
|
+
preference consolidation.
|
|
297
|
+
- **Five runtime dependencies.** [`citty`](https://github.com/unjs/citty)
|
|
298
|
+
(zero-dependency CLI framework), [`zod`](https://zod.dev) (schema
|
|
299
|
+
validation), and [`@clack/prompts`](https://github.com/bombshell-dev/clack)
|
|
300
|
+
(progress spinners), plus [`smol-toml`](https://github.com/squirrelchat/smol-toml)
|
|
301
|
+
for safely preserving Codex configuration values during optional retention
|
|
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
|
|
305
|
+
exact-pinned, and the entire transitive tree ships locked via
|
|
306
|
+
`npm-shrinkwrap.json`. The whole data path is small enough to audit in one
|
|
307
|
+
sitting.
|
|
308
|
+
- **Consent-gated LLM use.** `distill` states the exact invocation count and
|
|
309
|
+
waits for `[y/N]` before anything runs on your subscription/credits.
|
|
310
|
+
`--dry-run` shows the full plan for free. If you decline, it exits without
|
|
311
|
+
invoking anything (exit code 2).
|
|
312
|
+
- **Plain statement:** exports contain your raw prompts, including anything
|
|
313
|
+
sensitive you ever pasted into a session (keys, internal names, that one
|
|
314
|
+
angry message). They live in your home directory with your permissions, and
|
|
315
|
+
nothing ships them anywhere. A `--redact` option is on the roadmap.
|
|
316
|
+
|
|
317
|
+
## How it works
|
|
318
|
+
|
|
319
|
+
```mermaid
|
|
320
|
+
flowchart TD
|
|
321
|
+
A["~/.claude/projects/**/*.jsonl"] -->|"scan (read-only)"| B["inventory"]
|
|
322
|
+
X["~/.codex/{sessions,archived_sessions}/**/rollout-*.jsonl"] --> B
|
|
323
|
+
K["~/.kiro/sessions/"] --> B
|
|
324
|
+
O["~/.local/share/opencode/opencode.db"] --> B
|
|
325
|
+
A -->|"export (deterministic)"| C["exports/*.md + manifest.json"]
|
|
326
|
+
X --> C
|
|
327
|
+
K --> C
|
|
328
|
+
O --> C
|
|
329
|
+
A -->|"anaphora + outcome evidence"| D["anaphora.json + outcomes.json"]
|
|
330
|
+
X --> D
|
|
331
|
+
K --> D
|
|
332
|
+
O --> D
|
|
333
|
+
C --> E
|
|
334
|
+
D --> E
|
|
335
|
+
subgraph distill ["distill: opt-in, consent-gated, resumable"]
|
|
336
|
+
E["digest: 1 runner call / session"] --> F["cluster: 1 call"]
|
|
337
|
+
F --> G["author: 1 call / task"]
|
|
338
|
+
end
|
|
339
|
+
G --> H["library/<slug>/ oneshot + provenance"]
|
|
340
|
+
H --> I["list / show / copy / status"]
|
|
341
|
+
H --> J["preferences → CLAUDE.md / AGENTS.md / Kiro steering"]
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
The extraction layer is a fidelity contract: eleven audited rules decide what
|
|
345
|
+
counts as human input (attachments typed while the agent was busy, recovered
|
|
346
|
+
slash commands, `[decision]` lines from option picks, `[image pasted]`
|
|
347
|
+
markers), with a regression fixture per rule. Fork/resume duplicates are
|
|
348
|
+
deduped globally. Short replies like "yes" and "option 2" get their antecedent
|
|
349
|
+
attached so the author stage knows what you approved. Sessions carry an
|
|
350
|
+
outcome classification, so a task where nothing ever succeeded gets skipped
|
|
351
|
+
instead of becoming a confident prompt that reproduces a failure path.
|
|
352
|
+
|
|
353
|
+
Authored oneshots pass a **"knowable at t=0" test**: they front-load intent,
|
|
354
|
+
constraints, preferences, and quality bars, while leaving out facts you only
|
|
355
|
+
discovered mid-session (paths, root causes, error messages). And they respect
|
|
356
|
+
an **effort budget**, staying around the length a motivated human would
|
|
357
|
+
actually type rather than ballooning into a 700-word spec.
|
|
358
|
+
|
|
359
|
+
Every distill stage checkpoints to disk after each unit of work: Ctrl-C loses
|
|
360
|
+
nothing, re-running resumes, `--fresh` resets deliberately, and `status` flags
|
|
361
|
+
library entries orphaned by re-clustering.
|
|
362
|
+
|
|
363
|
+
## How it compares
|
|
364
|
+
|
|
365
|
+
| Tool | Reads `~/.claude` | Output | Direction |
|
|
366
|
+
|---|---|---|---|
|
|
367
|
+
| ccusage | ✓ | usage/cost tables | backward (metrics) |
|
|
368
|
+
| sniffly | ✓ | analytics dashboard | backward (behavior) |
|
|
369
|
+
| claude-code-transcripts | ✓ | shareable HTML transcripts | backward (record) |
|
|
370
|
+
| cctrace / exporters | ✓ | markdown/XML exports | backward (archive) |
|
|
371
|
+
| **human-hindsight** | ✓ | **oneshot prompt library + CLAUDE.md preferences** | **forward (better next session)** |
|
|
372
|
+
|
|
373
|
+
Closest kin is Simon Willison's `claude-code-transcripts`: same local-first
|
|
374
|
+
values, same belief that transcripts are undervalued artifacts. The difference
|
|
375
|
+
is the direction of gaze: it renders your sessions (backward, for others);
|
|
376
|
+
human-hindsight distills them (forward, for you).
|
|
377
|
+
|
|
378
|
+
## FAQ
|
|
379
|
+
|
|
380
|
+
**Does my data leave my machine?**
|
|
381
|
+
The deterministic commands (`scan`, `export`, and `retention`) never touch the
|
|
382
|
+
network. `distill` and `preferences --consolidate` send content through your
|
|
383
|
+
chosen local agent CLI to its configured provider, using its authentication.
|
|
384
|
+
|
|
385
|
+
**What does distill cost?**
|
|
386
|
+
Whatever your chosen agent CLI costs you: it runs on your existing subscription or
|
|
387
|
+
API credits. The consent prompt states the exact invocation count up front
|
|
388
|
+
(one call per session digested, one to cluster, one per task authored), and
|
|
389
|
+
`--dry-run` prints the same plan without running anything. Checkpoints mean an
|
|
390
|
+
interrupted run isn't wasted money. Sessions too large for the input budget
|
|
391
|
+
(default 400k chars, `--input-budget`) are **refused before anything is
|
|
392
|
+
spent**. Re-run with `--truncate=extreme` to cut them (recorded in
|
|
393
|
+
provenance) or narrow the scope. Digest and author calls run 3 at a time by
|
|
394
|
+
default (`--concurrency`; `1` = sequential).
|
|
395
|
+
|
|
396
|
+
**Subscription or API?**
|
|
397
|
+
human-hindsight shells out to `claude -p`, `codex exec`, `kiro-cli chat`, or `opencode run`;
|
|
398
|
+
however your chosen CLI is authenticated is how calls are billed. `--model`
|
|
399
|
+
passes through without pinning a model version.
|
|
400
|
+
|
|
401
|
+
**Why is a session missing from my exports?**
|
|
402
|
+
Sessions with zero human messages are skipped naturally, `--min-messages`
|
|
403
|
+
filters thin ones, and fork/resume copies are deduped into their original
|
|
404
|
+
session. Note that dedupe is global across all projects: with `--project`, a
|
|
405
|
+
message duplicated by fork/resume is attributed to its earliest session even
|
|
406
|
+
when that session is outside the filter. Run `export --verbose` to see every
|
|
407
|
+
dropped piece with a reason. If genuine human input was dropped, that's a
|
|
408
|
+
bug: file an extraction-fidelity report.
|
|
409
|
+
|
|
410
|
+
**Can I regenerate everything from scratch?**
|
|
411
|
+
`human-hindsight distill --fresh` clears the checkpoints (after confirming) and
|
|
412
|
+
re-runs. Old library entries from previous generations are flagged as orphans
|
|
413
|
+
in `status`.
|
|
414
|
+
|
|
415
|
+
## Roadmap
|
|
416
|
+
|
|
417
|
+
- Claude Code **plugin packaging** for existing marketplaces (for
|
|
418
|
+
distribution, without standing up a separate marketplace)
|
|
419
|
+
- An in-session **skill variant** ("distill this session as we go")
|
|
420
|
+
- **Agent SDK** orchestration exploration
|
|
421
|
+
- **parentUuid-aware anaphora** (branch-correct antecedents on forked
|
|
422
|
+
conversations)
|
|
423
|
+
- **`--redact` patterns** for exports
|
|
424
|
+
- An opt-in **community oneshot showcase**
|
|
425
|
+
|
|
426
|
+
## Development
|
|
427
|
+
|
|
428
|
+
```bash
|
|
429
|
+
npm install
|
|
430
|
+
npm test # vitest: fixtures only, never reads your agent stores
|
|
431
|
+
npm run lint # biome
|
|
432
|
+
npm run typecheck # tsc --noEmit
|
|
433
|
+
npm run build # tsdown → dist/
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md), especially the guide to adding a
|
|
437
|
+
fixture when you hit an unhandled transcript shape.
|
|
438
|
+
|
|
439
|
+
## License
|
|
440
|
+
|
|
441
|
+
[MIT](LICENSE)
|
|
442
|
+
|
|
443
|
+
## Author
|
|
444
|
+
|
|
445
|
+
Built by [Aditya Singhal](https://adityasinghal.com). If human-hindsight surfaces
|
|
446
|
+
a pattern you didn't know you had, [I'd love to hear about
|
|
447
|
+
it](https://github.com/adityaarunsinghal/human-hindsight/issues).
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|