cc-hindsight 1.0.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 +240 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3639 -0
- package/dist/runner-GBOB7lxq.js +2 -0
- package/dist/runner-_HierHih.js +313 -0
- package/npm-shrinkwrap.json +2185 -0
- package/package.json +56 -0
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
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# cc-hindsight
|
|
2
|
+
|
|
3
|
+
> **The prompt you'd write if you knew then what you know now.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/cc-hindsight)
|
|
6
|
+
[](https://github.com/adityaarunsinghal/cc-hindsight/actions/workflows/ci.yml)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](#privacy--trust)
|
|
10
|
+
|
|
11
|
+
<!-- DEMO: drop the asciinema/GIF here (Adi records it last). Suggested capture:
|
|
12
|
+
npx cc-hindsight → distill --dry-run (the consent plan) → distill (watch the
|
|
13
|
+
library build) → show <slug>. Record against a synthetic ~/.claude fixture. -->
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx cc-hindsight
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
cc-hindsight mines your Claude Code session history into two things you can use
|
|
20
|
+
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` 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 every session as JSONL under `~/.claude/projects/`. Plenty of tools read
|
|
42
|
+
that data for dashboards and transcripts. **Nobody closes the loop from history
|
|
43
|
+
back to better prompting.**
|
|
44
|
+
|
|
45
|
+
**Before** (what you actually typed at t=0):
|
|
46
|
+
|
|
47
|
+
> help me script blocking a device on my home router
|
|
48
|
+
|
|
49
|
+
**After** (what cc-hindsight distilled from how that session actually went):
|
|
50
|
+
|
|
51
|
+
> I want to automate my home router, starting with blocking a device. Get API
|
|
52
|
+
> access working first, and store any credentials securely instead of asking me
|
|
53
|
+
> to paste them in the clear. Anything that changes the network should be safe
|
|
54
|
+
> by default: show me what it'll do and let me confirm before it runs. Then
|
|
55
|
+
> prove it end-to-end on a real device. Research how others have done this
|
|
56
|
+
> first, and keep the setup written down so I can reproduce it.
|
|
57
|
+
|
|
58
|
+
The second prompt was knowable at t=0. You just hadn't written it yet.
|
|
59
|
+
|
|
60
|
+
## Quickstart
|
|
61
|
+
|
|
62
|
+
One command builds the whole library and shows it to you when it's done:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npx cc-hindsight distill # offers to export first, then digest → cluster →
|
|
66
|
+
# author (asks before any claude call), then shows
|
|
67
|
+
# you the finished library
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Prefer to drive each stage yourself? The pipeline is just three verbs:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npx cc-hindsight # 1. scan: inventory your projects (read-only)
|
|
74
|
+
npx cc-hindsight export # 2. export: human-only markdown per session
|
|
75
|
+
npx cc-hindsight distill # 3. distill: digest → cluster → author (asks first)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then browse and curate the results:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx cc-hindsight list # your library (✎ edited / ▲▼ rating badges)
|
|
82
|
+
npx cc-hindsight show <slug> # read a oneshot
|
|
83
|
+
npx cc-hindsight copy <slug> # → clipboard, paste into a fresh session
|
|
84
|
+
npx cc-hindsight edit <slug> # open in $EDITOR; your edits are protected
|
|
85
|
+
npx cc-hindsight rate <slug> up # record a verdict (up|down)
|
|
86
|
+
npx cc-hindsight prune # remove orphaned entries (asks first)
|
|
87
|
+
npx cc-hindsight preferences # → CLAUDE.md block
|
|
88
|
+
npx cc-hindsight status # pipeline funnel + orphan/skip flags
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Requires Node ≥ 22 on macOS or Linux (Windows is untested and currently
|
|
92
|
+
unsupported). `scan` and `export` are fully deterministic: no LLM, no
|
|
93
|
+
network. `distill` uses the `claude` CLI you already have, and never without
|
|
94
|
+
asking.
|
|
95
|
+
|
|
96
|
+
## Privacy & trust
|
|
97
|
+
|
|
98
|
+
For a tool that reads your entire conversation history, auditability is the
|
|
99
|
+
product:
|
|
100
|
+
|
|
101
|
+
- **Local-only.** Everything is read from your disk and written to your disk
|
|
102
|
+
(`~/.cc-hindsight`). No server, no accounts, no telemetry. The only network
|
|
103
|
+
call is your own `claude` CLI doing what it already does.
|
|
104
|
+
- **Three runtime dependencies.** [`citty`](https://github.com/unjs/citty)
|
|
105
|
+
(zero-dependency CLI framework), [`zod`](https://zod.dev) (schema
|
|
106
|
+
validation), and [`@clack/prompts`](https://github.com/bombshell-dev/clack)
|
|
107
|
+
(progress spinners, five micro-packages under the hood). All three are
|
|
108
|
+
exact-pinned, and the entire transitive tree ships locked via
|
|
109
|
+
`npm-shrinkwrap.json`. The whole data path is small enough to audit in one
|
|
110
|
+
sitting.
|
|
111
|
+
- **Consent-gated LLM use.** `distill` states the exact invocation count and
|
|
112
|
+
waits for `[y/N]` before anything runs on your subscription/credits.
|
|
113
|
+
`--dry-run` shows the full plan for free. If you decline, it exits without
|
|
114
|
+
invoking anything (exit code 2).
|
|
115
|
+
- **Plain statement:** exports contain your raw prompts, including anything
|
|
116
|
+
sensitive you ever pasted into a session (keys, internal names, that one
|
|
117
|
+
angry message). They live in your home directory with your permissions, and
|
|
118
|
+
nothing ships them anywhere. A `--redact` option is on the roadmap.
|
|
119
|
+
|
|
120
|
+
## How it works
|
|
121
|
+
|
|
122
|
+
```mermaid
|
|
123
|
+
flowchart TD
|
|
124
|
+
A["~/.claude/projects/**/*.jsonl"] -->|"scan (read-only)"| B["inventory"]
|
|
125
|
+
A -->|"export (deterministic)"| C["exports/*.md + manifest.json"]
|
|
126
|
+
A -->|"anaphora + outcome evidence"| D["anaphora.json + outcomes.json"]
|
|
127
|
+
C --> E
|
|
128
|
+
D --> E
|
|
129
|
+
subgraph distill ["distill: opt-in, consent-gated, resumable"]
|
|
130
|
+
E["digest: 1 claude call / session"] --> F["cluster: 1 call"]
|
|
131
|
+
F --> G["author: 1 call / task"]
|
|
132
|
+
end
|
|
133
|
+
G --> H["library/<slug>/ oneshot + provenance"]
|
|
134
|
+
H --> I["list / show / copy / status"]
|
|
135
|
+
H --> J["preferences → CLAUDE.md block"]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The extraction layer is a fidelity contract: eleven audited rules decide what
|
|
139
|
+
counts as human input (attachments typed while the agent was busy, recovered
|
|
140
|
+
slash commands, `[decision]` lines from option picks, `[image pasted]`
|
|
141
|
+
markers), with a regression fixture per rule. Fork/resume duplicates are
|
|
142
|
+
deduped globally. Short replies like "yes" and "option 2" get their antecedent
|
|
143
|
+
attached so the author stage knows what you approved. Sessions carry an
|
|
144
|
+
outcome classification, so a task where nothing ever succeeded gets skipped
|
|
145
|
+
instead of becoming a confident prompt that reproduces a failure path.
|
|
146
|
+
|
|
147
|
+
Authored oneshots pass a **"knowable at t=0" test**: they front-load intent,
|
|
148
|
+
constraints, preferences, and quality bars, while leaving out facts you only
|
|
149
|
+
discovered mid-session (paths, root causes, error messages). And they respect
|
|
150
|
+
an **effort budget**, staying around the length a motivated human would
|
|
151
|
+
actually type rather than ballooning into a 700-word spec.
|
|
152
|
+
|
|
153
|
+
Every distill stage checkpoints to disk after each unit of work: Ctrl-C loses
|
|
154
|
+
nothing, re-running resumes, `--fresh` resets deliberately, and `status` flags
|
|
155
|
+
library entries orphaned by re-clustering.
|
|
156
|
+
|
|
157
|
+
## How it compares
|
|
158
|
+
|
|
159
|
+
| Tool | Reads `~/.claude` | Output | Direction |
|
|
160
|
+
|---|---|---|---|
|
|
161
|
+
| ccusage | ✓ | usage/cost tables | backward (metrics) |
|
|
162
|
+
| sniffly | ✓ | analytics dashboard | backward (behavior) |
|
|
163
|
+
| claude-code-transcripts | ✓ | shareable HTML transcripts | backward (record) |
|
|
164
|
+
| cctrace / exporters | ✓ | markdown/XML exports | backward (archive) |
|
|
165
|
+
| **cc-hindsight** | ✓ | **oneshot prompt library + CLAUDE.md preferences** | **forward (better next session)** |
|
|
166
|
+
|
|
167
|
+
Closest kin is Simon Willison's `claude-code-transcripts`: same local-first
|
|
168
|
+
values, same belief that transcripts are undervalued artifacts. The difference
|
|
169
|
+
is the direction of gaze: it renders your sessions (backward, for others);
|
|
170
|
+
cc-hindsight distills them (forward, for you).
|
|
171
|
+
|
|
172
|
+
## FAQ
|
|
173
|
+
|
|
174
|
+
**Does my data leave my machine?**
|
|
175
|
+
No. The deterministic commands never touch the network. `distill` pipes
|
|
176
|
+
content to your locally installed `claude` CLI, the same thing that happens
|
|
177
|
+
when you use Claude Code, and nothing else.
|
|
178
|
+
|
|
179
|
+
**What does distill cost?**
|
|
180
|
+
Whatever your `claude` CLI costs you: it runs on your existing subscription or
|
|
181
|
+
API credits. The consent prompt states the exact invocation count up front
|
|
182
|
+
(one call per session digested, one to cluster, one per task authored), and
|
|
183
|
+
`--dry-run` prints the same plan without running anything. Checkpoints mean an
|
|
184
|
+
interrupted run isn't wasted money. Sessions too large for the input budget
|
|
185
|
+
(default 400k chars, `--input-budget`) are **refused before anything is
|
|
186
|
+
spent**. Re-run with `--truncate=extreme` to cut them (recorded in
|
|
187
|
+
provenance) or narrow the scope. Digest and author calls run 3 at a time by
|
|
188
|
+
default (`--concurrency`; `1` = sequential).
|
|
189
|
+
|
|
190
|
+
**Subscription or API?**
|
|
191
|
+
Either. cc-hindsight shells out to `claude -p`; however your CLI is
|
|
192
|
+
authenticated is how the calls are billed. `--model` passes through.
|
|
193
|
+
|
|
194
|
+
**Why is a session missing from my exports?**
|
|
195
|
+
Sessions with zero human messages are skipped naturally, `--min-messages`
|
|
196
|
+
filters thin ones, and fork/resume copies are deduped into their original
|
|
197
|
+
session. Note that dedupe is global across all projects: with `--project`, a
|
|
198
|
+
message duplicated by fork/resume is attributed to its earliest session even
|
|
199
|
+
when that session is outside the filter. Run `export --verbose` to see every
|
|
200
|
+
dropped piece with a reason. If genuine human input was dropped, that's a
|
|
201
|
+
bug: file an extraction-fidelity report.
|
|
202
|
+
|
|
203
|
+
**Can I regenerate everything from scratch?**
|
|
204
|
+
`cc-hindsight distill --fresh` clears the checkpoints (after confirming) and
|
|
205
|
+
re-runs. Old library entries from previous generations are flagged as orphans
|
|
206
|
+
in `status`.
|
|
207
|
+
|
|
208
|
+
## Roadmap
|
|
209
|
+
|
|
210
|
+
- Claude Code **plugin packaging** for existing marketplaces (for
|
|
211
|
+
distribution, without standing up a separate marketplace)
|
|
212
|
+
- An in-session **skill variant** ("distill this session as we go")
|
|
213
|
+
- **Agent SDK** orchestration exploration
|
|
214
|
+
- **parentUuid-aware anaphora** (branch-correct antecedents on forked
|
|
215
|
+
conversations)
|
|
216
|
+
- **`--redact` patterns** for exports
|
|
217
|
+
- An opt-in **community oneshot showcase**
|
|
218
|
+
|
|
219
|
+
## Development
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm install
|
|
223
|
+
npm test # vitest: fixtures only, never reads your ~/.claude
|
|
224
|
+
npm run lint # biome
|
|
225
|
+
npm run typecheck # tsc --noEmit
|
|
226
|
+
npm run build # tsdown → dist/
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md), especially the guide to adding a
|
|
230
|
+
fixture when you hit an unhandled transcript shape.
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
[MIT](LICENSE)
|
|
235
|
+
|
|
236
|
+
## Author
|
|
237
|
+
|
|
238
|
+
Built by [Aditya Singhal](https://adityasinghal.com). If cc-hindsight surfaces
|
|
239
|
+
a pattern you didn't know you had, [I'd love to hear about
|
|
240
|
+
it](https://github.com/adityaarunsinghal/cc-hindsight/issues).
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|