cc-hindsight 1.5.0 → 1.6.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
@@ -1,358 +1,22 @@
1
- # cc-hindsight
1
+ # cc-hindsight has moved to Human Hindsight
2
2
 
3
- > **The prompt you'd write if you knew then what you know now.**
4
-
5
- [![npm](https://img.shields.io/npm/v/cc-hindsight?color=cb3837&logo=npm)](https://www.npmjs.com/package/cc-hindsight)
6
- [![CI](https://github.com/adityaarunsinghal/cc-hindsight/actions/workflows/ci.yml/badge.svg)](https://github.com/adityaarunsinghal/cc-hindsight/actions/workflows/ci.yml)
7
- [![node](https://img.shields.io/node/v/cc-hindsight?logo=node.js&color=339933)](https://nodejs.org)
8
- [![license](https://img.shields.io/github/license/adityaarunsinghal/cc-hindsight?color=blue)](LICENSE)
9
- [![local-first](https://img.shields.io/badge/data-local--only-brightgreen)](#privacy--trust)
10
-
11
- <p align="center">
12
- <img src="https://raw.githubusercontent.com/adityaarunsinghal/cc-hindsight/main/.github/assets/demo.gif" alt="cc-hindsight building a oneshot prompt library from coding-agent session history" width="800">
13
- </p>
14
-
15
- ```bash
16
- npx cc-hindsight
17
- ```
18
-
19
- cc-hindsight mines your coding-agent session history (Claude Code, Codex, kiro-cli)
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
- ## The t=0 problem
30
-
31
- You get better results the more context you front-load into your first prompt,
32
- yet we underspecify at t=0 and spend the session steering: correcting course,
33
- restating preferences, answering questions the agent shouldn't have had to ask.
34
-
35
- And the cost repeats every session. Your working preferences are stable facts
36
- about how you like to work, yet you re-derive and re-type them project after
37
- project instead of stating them once, upfront, where every future session reads
38
- them from the first message.
39
-
40
- All the evidence of what you *should* have said is already on disk. Claude Code
41
- saves session JSONL under `~/.claude/projects/`; Codex keeps rollouts under
42
- `~/.codex/sessions/` and `~/.codex/archived_sessions/`; kiro-cli keeps its
43
- own store under `~/.kiro/sessions` (both the flat `cli/<uuid>.jsonl` layout and
44
- the newer per-session `<hash>/sess_<uuid>/messages.jsonl` layout). Plenty of
45
- tools read that data for
46
- dashboards and transcripts. **Nobody closes the loop from history back to
47
- better prompting.**
48
-
49
- **Before** (what you actually typed at t=0):
50
-
51
- > help me script blocking a device on my home router
52
-
53
- **After** (what cc-hindsight distilled from how that session actually went):
54
-
55
- > I want to automate my home router, starting with blocking a device. Get API
56
- > access working first, and store any credentials securely instead of asking me
57
- > to paste them in the clear. Anything that changes the network should be safe
58
- > by default: show me what it'll do and let me confirm before it runs. Then
59
- > prove it end-to-end on a real device. Research how others have done this
60
- > first, and keep the setup written down so I can reproduce it.
61
-
62
- The second prompt was knowable at t=0. You just hadn't written it yet.
63
-
64
- ## Quickstart
65
-
66
- One command builds the whole library and shows it to you when it's done:
67
-
68
- ```bash
69
- npx cc-hindsight distill # offers to export first, then digest → cluster →
70
- # author (asks before any runner call), then shows
71
- # you the finished library
72
- ```
73
-
74
- Prefer to drive each stage yourself? The pipeline is just three verbs:
75
-
76
- ```bash
77
- npx cc-hindsight # 1. scan: inventory your projects (read-only)
78
- npx cc-hindsight export # 2. export: human-only markdown per session
79
- npx cc-hindsight distill # 3. distill: digest → cluster → author (asks first)
80
- ```
81
-
82
- Then browse and curate the results:
83
-
84
- ```bash
85
- npx cc-hindsight list # your library (✎ edited / ▲▼ rating badges)
86
- npx cc-hindsight gui # browse, search, and copy in your browser
87
- npx cc-hindsight show <slug> # read a oneshot
88
- npx cc-hindsight copy <slug> # → clipboard, paste into a fresh session
89
- npx cc-hindsight edit <slug> # open in $EDITOR; your edits are protected
90
- npx cc-hindsight rate <slug> up # record a verdict (up|down)
91
- npx cc-hindsight prune # remove orphaned entries (asks first)
92
- npx cc-hindsight preferences # → CLAUDE.md block
93
- npx cc-hindsight status # pipeline funnel + orphan/skip flags
94
- npx cc-hindsight retention # optional: preview longer local retention
95
- ```
96
-
97
- Requires Node ≥ 22 on macOS or Linux (Windows is untested and currently
98
- unsupported). `scan` and `export` are fully deterministic: no LLM, no
99
- network. `distill` uses your installed `claude`, `codex`, or `kiro-cli`,
100
- with a consent prompt (or your explicit `--yes`).
101
-
102
- ### A small local library viewer
103
-
104
- ```bash
105
- npx cc-hindsight gui # start locally and open your browser
106
- npx cc-hindsight gui --no-open # print the address without opening it
107
- npx cc-hindsight gui --port 3210 # choose a port (default: any available port)
108
- npx cc-hindsight gui --home /path/to/library-home
109
- ```
110
-
111
- Search prompt titles and text, filter by domain, sort, and copy the prompt
112
- body with one click. The viewer shows your existing library, including local
113
- edits, ratings, and session counts. Use **Refresh** after changing files.
114
- Light and dark appearance follow your system setting, and the layout works
115
- on narrow screens. Press `/` to focus search.
116
-
117
- The GUI uses Node's built-in HTTP server and bundled HTML/CSS/JavaScript:
118
- no additional dependencies, frontend framework, database, or external assets.
119
- It listens only on `127.0.0.1`, serves a read-only library API, and stops with
120
- Ctrl+C. The GUI doesn't invoke an agent or modify your library.
121
-
122
- ### Multiple backends (Claude Code + Codex + kiro-cli)
123
-
124
- Every command takes `--source claude|codex|kiro|auto` (default `auto`: read
125
- whichever stores exist). Select the source after the subcommand. Directory
126
- flags work before or after it:
127
-
128
- | Source | Directory flag | Environment variable | Default |
129
- |---|---|---|---|
130
- | Claude Code | `--claude-dir` | `CLAUDE_CONFIG_DIR` | `~/.claude` |
131
- | Codex | `--codex-dir` | `CODEX_HOME` | `~/.codex` |
132
- | kiro-cli | `--kiro-dir` | `KIRO_CONFIG_DIR` | `~/.kiro` |
133
-
134
- Multiple stores merge into one library; the manifest tags each session's
135
- `origin` and the export summary breaks the count down. Codex discovery includes
136
- active and archived rollouts from the CLI, IDE extension, and app, grouped by
137
- their working directory. Mirrored user/assistant events are paired, injected
138
- context and subagent sessions are excluded, and human decisions and images
139
- survive extraction. The kiro backend
140
- reads both on-disk store layouts (the flat v2 store and the newer v3 per-session
141
- store), preferring the v3 copy when a session was migrated into both.
142
-
143
- `distill --runner claude|codex|kiro|auto` chooses which CLI does the distilling,
144
- independently of `--source`. `auto` prefers the CLI matching an explicit source,
145
- then falls back in the order Claude → Codex → Kiro. Models are passed through
146
- with `--model`; without it, the chosen CLI uses its configured default.
147
-
148
- ```bash
149
- npx cc-hindsight export --source codex
150
- npx cc-hindsight distill --source codex --runner codex
151
- npx cc-hindsight distill --source claude --runner codex
152
- npx cc-hindsight preferences --target codex # AGENTS.md; alias of --target agents
153
- ```
154
-
155
- `preferences --target claude|codex|kiro|agents` emits a `CLAUDE.md` block,
156
- an `AGENTS.md` section, or a block for `~/.kiro/steering/`. An explicit Codex
157
- source defaults to `AGENTS.md`. The Codex runner uses `codex exec` with a JSON
158
- schema, a read-only sandbox, and ephemeral sessions; generated distill sessions
159
- do not become new source history. Claude supports current `structured_output`
160
- results as well as legacy `result` objects/strings and verbose event arrays.
161
- It disables session persistence when the installed CLI advertises the flag.
162
-
163
- ### Optional: keep more local history
164
-
165
- ```bash
166
- npx cc-hindsight retention # read-only preview
167
- npx cc-hindsight retention --apply # preview, then confirm
168
- npx cc-hindsight retention --apply --yes # explicit opt-in for scripting
169
- npx cc-hindsight retention --source codex --apply
170
- ```
171
-
172
- The default reviews existing tool directories. An explicit `--source` can
173
- create that tool's settings file. `--yes` alone never applies changes, and
174
- `--dry-run` always keeps the command read-only.
175
-
176
- - **Claude Code:** raises `cleanupPeriodDays` to 365,000 days (about 1,000
177
- years), preserving an already longer value. Claude requires a positive whole
178
- number; `0` is invalid. If desktop cleanup is capped, sets
179
- `desktopSessionCleanupPeriodDays` to `0`, its supported no-age-limit value.
180
- An absent desktop setting already has no age limit.
181
- - **Codex:** sets `[history] persistence = "save-all"` and removes
182
- `history.max_bytes`, leaving prompt history uncapped. This controls
183
- `history.jsonl`; full session rollouts are stored separately. Avoid
184
- `--ephemeral` for your own sessions you want to retain.
185
- - **kiro-cli:** explains automatic persistence and `/chat save <path>` for
186
- additional copies. Its public settings reference does not document a
187
- retention-limit switch, so no configuration key is invented.
188
-
189
- Applying creates owner-only backups next to existing configuration files, then
190
- replaces each file atomically. Other settings are preserved; common Codex TOML
191
- layouts retain comments, while unusual layouts may be reformatted after a
192
- preview notice. Malformed configurations are left untouched.
193
-
194
- Longer retention keeps prompt contents on disk longer and can use more space.
195
- Restart running tools after applying settings. Project settings, profiles,
196
- managed policy, and startup flags can override user defaults; this command
197
- does not change those controls, remote retention, or telemetry. It cannot
198
- recover already deleted history.
199
-
200
- Setting references: [Claude retention](https://code.claude.com/docs/en/settings-reference#cleanupperioddays),
201
- [Codex configuration](https://developers.openai.com/codex/config-reference),
202
- and [Kiro conversation persistence](https://kiro.dev/docs/cli/chat/).
203
-
204
- ## Privacy & trust
205
-
206
- For a tool that reads your entire conversation history, auditability is the
207
- product:
208
-
209
- - **Local-only.** Everything is read from your disk and written to your disk
210
- (`~/.cc-hindsight`). No server, no accounts, no telemetry. The only network
211
- traffic is through your chosen agent CLI during consented distillation or
212
- preference consolidation.
213
- - **Four runtime dependencies.** [`citty`](https://github.com/unjs/citty)
214
- (zero-dependency CLI framework), [`zod`](https://zod.dev) (schema
215
- validation), and [`@clack/prompts`](https://github.com/bombshell-dev/clack)
216
- (progress spinners), plus [`smol-toml`](https://github.com/squirrelchat/smol-toml)
217
- for safely preserving Codex configuration values during optional retention
218
- edits. All four are
219
- exact-pinned, and the entire transitive tree ships locked via
220
- `npm-shrinkwrap.json`. The whole data path is small enough to audit in one
221
- sitting.
222
- - **Consent-gated LLM use.** `distill` states the exact invocation count and
223
- waits for `[y/N]` before anything runs on your subscription/credits.
224
- `--dry-run` shows the full plan for free. If you decline, it exits without
225
- invoking anything (exit code 2).
226
- - **Plain statement:** exports contain your raw prompts, including anything
227
- sensitive you ever pasted into a session (keys, internal names, that one
228
- angry message). They live in your home directory with your permissions, and
229
- nothing ships them anywhere. A `--redact` option is on the roadmap.
230
-
231
- ## How it works
232
-
233
- ```mermaid
234
- flowchart TD
235
- A["~/.claude/projects/**/*.jsonl"] -->|"scan (read-only)"| B["inventory"]
236
- X["~/.codex/{sessions,archived_sessions}/**/rollout-*.jsonl"] --> B
237
- K["~/.kiro/sessions/"] --> B
238
- A -->|"export (deterministic)"| C["exports/*.md + manifest.json"]
239
- X --> C
240
- K --> C
241
- A -->|"anaphora + outcome evidence"| D["anaphora.json + outcomes.json"]
242
- X --> D
243
- K --> D
244
- C --> E
245
- D --> E
246
- subgraph distill ["distill: opt-in, consent-gated, resumable"]
247
- E["digest: 1 runner call / session"] --> F["cluster: 1 call"]
248
- F --> G["author: 1 call / task"]
249
- end
250
- G --> H["library/&lt;slug&gt;/ oneshot + provenance"]
251
- H --> I["list / show / copy / status"]
252
- H --> J["preferences → CLAUDE.md / AGENTS.md / Kiro steering"]
253
- ```
254
-
255
- The extraction layer is a fidelity contract: eleven audited rules decide what
256
- counts as human input (attachments typed while the agent was busy, recovered
257
- slash commands, `[decision]` lines from option picks, `[image pasted]`
258
- markers), with a regression fixture per rule. Fork/resume duplicates are
259
- deduped globally. Short replies like "yes" and "option 2" get their antecedent
260
- attached so the author stage knows what you approved. Sessions carry an
261
- outcome classification, so a task where nothing ever succeeded gets skipped
262
- instead of becoming a confident prompt that reproduces a failure path.
263
-
264
- Authored oneshots pass a **"knowable at t=0" test**: they front-load intent,
265
- constraints, preferences, and quality bars, while leaving out facts you only
266
- discovered mid-session (paths, root causes, error messages). And they respect
267
- an **effort budget**, staying around the length a motivated human would
268
- actually type rather than ballooning into a 700-word spec.
269
-
270
- Every distill stage checkpoints to disk after each unit of work: Ctrl-C loses
271
- nothing, re-running resumes, `--fresh` resets deliberately, and `status` flags
272
- library entries orphaned by re-clustering.
273
-
274
- ## How it compares
275
-
276
- | Tool | Reads `~/.claude` | Output | Direction |
277
- |---|---|---|---|
278
- | ccusage | ✓ | usage/cost tables | backward (metrics) |
279
- | sniffly | ✓ | analytics dashboard | backward (behavior) |
280
- | claude-code-transcripts | ✓ | shareable HTML transcripts | backward (record) |
281
- | cctrace / exporters | ✓ | markdown/XML exports | backward (archive) |
282
- | **cc-hindsight** | ✓ | **oneshot prompt library + CLAUDE.md preferences** | **forward (better next session)** |
283
-
284
- Closest kin is Simon Willison's `claude-code-transcripts`: same local-first
285
- values, same belief that transcripts are undervalued artifacts. The difference
286
- is the direction of gaze: it renders your sessions (backward, for others);
287
- cc-hindsight distills them (forward, for you).
288
-
289
- ## FAQ
290
-
291
- **Does my data leave my machine?**
292
- The deterministic commands (`scan`, `export`, and `retention`) never touch the
293
- network. `distill` and `preferences --consolidate` send content through your
294
- chosen local agent CLI to its configured provider, using its authentication.
295
-
296
- **What does distill cost?**
297
- Whatever your chosen agent CLI costs you: it runs on your existing subscription or
298
- API credits. The consent prompt states the exact invocation count up front
299
- (one call per session digested, one to cluster, one per task authored), and
300
- `--dry-run` prints the same plan without running anything. Checkpoints mean an
301
- interrupted run isn't wasted money. Sessions too large for the input budget
302
- (default 400k chars, `--input-budget`) are **refused before anything is
303
- spent**. Re-run with `--truncate=extreme` to cut them (recorded in
304
- provenance) or narrow the scope. Digest and author calls run 3 at a time by
305
- default (`--concurrency`; `1` = sequential).
306
-
307
- **Subscription or API?**
308
- cc-hindsight shells out to `claude -p`, `codex exec`, or `kiro-cli chat`;
309
- however your chosen CLI is authenticated is how calls are billed. `--model`
310
- passes through without pinning a model version.
311
-
312
- **Why is a session missing from my exports?**
313
- Sessions with zero human messages are skipped naturally, `--min-messages`
314
- filters thin ones, and fork/resume copies are deduped into their original
315
- session. Note that dedupe is global across all projects: with `--project`, a
316
- message duplicated by fork/resume is attributed to its earliest session even
317
- when that session is outside the filter. Run `export --verbose` to see every
318
- dropped piece with a reason. If genuine human input was dropped, that's a
319
- bug: file an extraction-fidelity report.
320
-
321
- **Can I regenerate everything from scratch?**
322
- `cc-hindsight distill --fresh` clears the checkpoints (after confirming) and
323
- re-runs. Old library entries from previous generations are flagged as orphans
324
- in `status`.
325
-
326
- ## Roadmap
327
-
328
- - Claude Code **plugin packaging** for existing marketplaces (for
329
- distribution, without standing up a separate marketplace)
330
- - An in-session **skill variant** ("distill this session as we go")
331
- - **Agent SDK** orchestration exploration
332
- - **parentUuid-aware anaphora** (branch-correct antecedents on forked
333
- conversations)
334
- - **`--redact` patterns** for exports
335
- - An opt-in **community oneshot showcase**
336
-
337
- ## Development
3
+ Install or run the renamed app:
338
4
 
339
5
  ```bash
340
- npm install
341
- npm test # vitest: fixtures only, never reads your agent stores
342
- npm run lint # biome
343
- npm run typecheck # tsc --noEmit
344
- npm run build # tsdown → dist/
6
+ npx human-hindsight@latest gui
7
+ npm install -g human-hindsight
345
8
  ```
346
9
 
347
- See [CONTRIBUTING.md](CONTRIBUTING.md), especially the guide to adding a
348
- fixture when you hit an unhandled transcript shape.
349
-
350
- ## License
10
+ This deprecated package keeps the `cc-hindsight` command working by forwarding
11
+ to the matching version of `human-hindsight`. It contains no separate copy of
12
+ the application, and all arguments and exit codes pass through unchanged.
351
13
 
352
- [MIT](LICENSE)
14
+ Existing `~/.cc-hindsight` libraries and `CC_HINDSIGHT_HOME` remain supported.
15
+ The new command uses `~/.human-hindsight` for fresh installations and also
16
+ accepts `HUMAN_HINDSIGHT_HOME`. You do not need to move or re-distill your data.
353
17
 
354
- ## Author
18
+ Both packages can be installed together: `human-hindsight` owns the new command
19
+ and this package owns the old one.
355
20
 
356
- Built by [Aditya Singhal](https://adityasinghal.com). If cc-hindsight surfaces
357
- a pattern you didn't know you had, [I'd love to hear about
358
- it](https://github.com/adityaarunsinghal/cc-hindsight/issues).
21
+ Source, documentation, and releases:
22
+ [Human Hindsight](https://github.com/adityaarunsinghal/human-hindsight).
package/cli.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Same process, arguments, stdin, exit status, and signals as the new command.
4
+ import "human-hindsight/cli";
package/package.json CHANGED
@@ -1,62 +1,32 @@
1
1
  {
2
2
  "name": "cc-hindsight",
3
- "version": "1.5.0",
4
- "description": "Mine your coding-agent session history (Claude Code, Codex, kiro-cli) into a oneshot prompt library and CLAUDE.md/AGENTS.md preferences. The prompt you'd write if you knew then what you know now.",
3
+ "version": "1.6.0",
4
+ "description": "Compatibility command for Human Hindsight. Install human-hindsight for the renamed application.",
5
+ "deprecated": "Renamed to human-hindsight. Use npx human-hindsight or npm install -g human-hindsight. This package forwards the legacy cc-hindsight command.",
5
6
  "type": "module",
6
7
  "author": "Aditya Singhal (https://adityasinghal.com)",
7
8
  "license": "MIT",
8
- "keywords": [
9
- "claude",
10
- "claude-code",
11
- "codex",
12
- "kiro",
13
- "kiro-cli",
14
- "agents",
15
- "prompt",
16
- "prompt-library",
17
- "prompt-engineering",
18
- "cli",
19
- "transcripts",
20
- "local-first"
21
- ],
22
9
  "repository": {
23
10
  "type": "git",
24
- "url": "git+https://github.com/adityaarunsinghal/cc-hindsight.git"
11
+ "url": "git+https://github.com/adityaarunsinghal/human-hindsight.git",
12
+ "directory": "compat/cc-hindsight"
25
13
  },
26
- "homepage": "https://github.com/adityaarunsinghal/cc-hindsight#readme",
14
+ "homepage": "https://github.com/adityaarunsinghal/human-hindsight#readme",
27
15
  "bugs": {
28
- "url": "https://github.com/adityaarunsinghal/cc-hindsight/issues"
16
+ "url": "https://github.com/adityaarunsinghal/human-hindsight/issues"
29
17
  },
30
18
  "bin": {
31
- "cc-hindsight": "./dist/cli.js"
19
+ "cc-hindsight": "./cli.js"
32
20
  },
33
21
  "files": [
34
- "dist",
35
- "npm-shrinkwrap.json"
22
+ "cli.js",
23
+ "README.md",
24
+ "LICENSE"
36
25
  ],
37
26
  "engines": {
38
27
  "node": ">=22"
39
28
  },
40
- "scripts": {
41
- "build": "tsdown",
42
- "prepare": "npm run build --silent 1>&2",
43
- "test": "vitest run",
44
- "lint": "biome check .",
45
- "format": "biome format --write .",
46
- "typecheck": "tsc --noEmit",
47
- "prepublishOnly": "npm run lint && npm run typecheck && npm test && npm run build && npm pack --dry-run --json --ignore-scripts > pack.json && node scripts/check-pack.mjs pack.json && rm pack.json"
48
- },
49
29
  "dependencies": {
50
- "@clack/prompts": "1.7.0",
51
- "citty": "0.2.2",
52
- "smol-toml": "1.9.1",
53
- "zod": "4.4.3"
54
- },
55
- "devDependencies": {
56
- "@biomejs/biome": "^2.5.3",
57
- "@types/node": "^22.20.1",
58
- "tsdown": "^0.22.7",
59
- "typescript": "^5.9.3",
60
- "vitest": "^4.1.10"
30
+ "human-hindsight": "1.6.0"
61
31
  }
62
32
  }
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export { };