cc-hindsight 1.3.1 → 1.5.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 cc-hindsight
17
17
  ```
18
18
 
19
- cc-hindsight mines your coding-agent session history (Claude Code, kiro-cli)
19
+ cc-hindsight mines your coding-agent session history (Claude Code, Codex, kiro-cli)
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
@@ -24,7 +24,7 @@ into two things you can use tomorrow morning:
24
24
  written in your own voice.
25
25
  2. **A distilled preference set.** The things you keep re-telling your agent
26
26
  ("diagnose before acting", "pin the versions", "be terse"), surfaced as a
27
- paste-ready `CLAUDE.md` block so every future session starts aligned.
27
+ paste-ready `CLAUDE.md` or `AGENTS.md` block so every future session starts aligned.
28
28
 
29
29
  ## The t=0 problem
30
30
 
@@ -38,8 +38,11 @@ project instead of stating them once, upfront, where every future session reads
38
38
  them from the first message.
39
39
 
40
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/`; kiro-cli keeps its
42
- own store under `~/.kiro/sessions/cli`. Plenty of tools read that data for
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
43
46
  dashboards and transcripts. **Nobody closes the loop from history back to
44
47
  better prompting.**
45
48
 
@@ -64,7 +67,7 @@ One command builds the whole library and shows it to you when it's done:
64
67
 
65
68
  ```bash
66
69
  npx cc-hindsight distill # offers to export first, then digest → cluster →
67
- # author (asks before any claude call), then shows
70
+ # author (asks before any runner call), then shows
68
71
  # you the finished library
69
72
  ```
70
73
 
@@ -80,6 +83,7 @@ Then browse and curate the results:
80
83
 
81
84
  ```bash
82
85
  npx cc-hindsight list # your library (✎ edited / ▲▼ rating badges)
86
+ npx cc-hindsight gui # browse, search, and copy in your browser
83
87
  npx cc-hindsight show <slug> # read a oneshot
84
88
  npx cc-hindsight copy <slug> # → clipboard, paste into a fresh session
85
89
  npx cc-hindsight edit <slug> # open in $EDITOR; your edits are protected
@@ -87,27 +91,115 @@ npx cc-hindsight rate <slug> up # record a verdict (up|down)
87
91
  npx cc-hindsight prune # remove orphaned entries (asks first)
88
92
  npx cc-hindsight preferences # → CLAUDE.md block
89
93
  npx cc-hindsight status # pipeline funnel + orphan/skip flags
94
+ npx cc-hindsight retention # optional: preview longer local retention
90
95
  ```
91
96
 
92
97
  Requires Node ≥ 22 on macOS or Linux (Windows is untested and currently
93
98
  unsupported). `scan` and `export` are fully deterministic: no LLM, no
94
- network. `distill` uses the `claude` CLI you already have, and never without
95
- asking.
99
+ network. `distill` uses your installed `claude`, `codex`, or `kiro-cli`,
100
+ with a consent prompt (or your explicit `--yes`).
96
101
 
97
- ### Multiple backends (Claude Code + kiro-cli)
102
+ ### A small local library viewer
98
103
 
99
- cc-hindsight also mines [kiro-cli](https://docs.hub.amazon.dev/) session
100
- history the same way. Every command takes `--source claude|kiro|auto` (default
101
- `auto`: read whichever stores exist) and `--kiro-dir` / `KIRO_CONFIG_DIR`
102
- (default `~/.kiro`, parallel to `--claude-dir`). A machine with both stores
103
- merges them into one library; the manifest tags each session's `origin` and the
104
- export summary breaks the count down (`9 claude + 3 kiro`).
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
+ ```
105
171
 
106
- `distill --runner claude|kiro|auto` chooses which CLI does the distilling —
107
- orthogonal to `--source`, so you can mine kiro history and distill with claude
108
- or vice-versa (`auto` prefers the CLI matching your source, else whichever is
109
- installed). `preferences --target claude|kiro|agents` emits a `CLAUDE.md`
110
- block, a `~/.kiro/steering/` file, or a portable `AGENTS.md` section.
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/).
111
203
 
112
204
  ## Privacy & trust
113
205
 
@@ -116,11 +208,14 @@ product:
116
208
 
117
209
  - **Local-only.** Everything is read from your disk and written to your disk
118
210
  (`~/.cc-hindsight`). No server, no accounts, no telemetry. The only network
119
- call is your own `claude` CLI doing what it already does.
120
- - **Three runtime dependencies.** [`citty`](https://github.com/unjs/citty)
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)
121
214
  (zero-dependency CLI framework), [`zod`](https://zod.dev) (schema
122
215
  validation), and [`@clack/prompts`](https://github.com/bombshell-dev/clack)
123
- (progress spinners, five micro-packages under the hood). All three are
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
124
219
  exact-pinned, and the entire transitive tree ships locked via
125
220
  `npm-shrinkwrap.json`. The whole data path is small enough to audit in one
126
221
  sitting.
@@ -138,17 +233,23 @@ product:
138
233
  ```mermaid
139
234
  flowchart TD
140
235
  A["~/.claude/projects/**/*.jsonl"] -->|"scan (read-only)"| B["inventory"]
236
+ X["~/.codex/{sessions,archived_sessions}/**/rollout-*.jsonl"] --> B
237
+ K["~/.kiro/sessions/"] --> B
141
238
  A -->|"export (deterministic)"| C["exports/*.md + manifest.json"]
239
+ X --> C
240
+ K --> C
142
241
  A -->|"anaphora + outcome evidence"| D["anaphora.json + outcomes.json"]
242
+ X --> D
243
+ K --> D
143
244
  C --> E
144
245
  D --> E
145
246
  subgraph distill ["distill: opt-in, consent-gated, resumable"]
146
- E["digest: 1 claude call / session"] --> F["cluster: 1 call"]
247
+ E["digest: 1 runner call / session"] --> F["cluster: 1 call"]
147
248
  F --> G["author: 1 call / task"]
148
249
  end
149
250
  G --> H["library/&lt;slug&gt;/ oneshot + provenance"]
150
251
  H --> I["list / show / copy / status"]
151
- H --> J["preferences → CLAUDE.md block"]
252
+ H --> J["preferences → CLAUDE.md / AGENTS.md / Kiro steering"]
152
253
  ```
153
254
 
154
255
  The extraction layer is a fidelity contract: eleven audited rules decide what
@@ -188,12 +289,12 @@ cc-hindsight distills them (forward, for you).
188
289
  ## FAQ
189
290
 
190
291
  **Does my data leave my machine?**
191
- No. The deterministic commands never touch the network. `distill` pipes
192
- content to your locally installed `claude` CLI, the same thing that happens
193
- when you use Claude Code, and nothing else.
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.
194
295
 
195
296
  **What does distill cost?**
196
- Whatever your `claude` CLI costs you: it runs on your existing subscription or
297
+ Whatever your chosen agent CLI costs you: it runs on your existing subscription or
197
298
  API credits. The consent prompt states the exact invocation count up front
198
299
  (one call per session digested, one to cluster, one per task authored), and
199
300
  `--dry-run` prints the same plan without running anything. Checkpoints mean an
@@ -204,8 +305,9 @@ provenance) or narrow the scope. Digest and author calls run 3 at a time by
204
305
  default (`--concurrency`; `1` = sequential).
205
306
 
206
307
  **Subscription or API?**
207
- Either. cc-hindsight shells out to `claude -p`; however your CLI is
208
- authenticated is how the calls are billed. `--model` passes through.
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.
209
311
 
210
312
  **Why is a session missing from my exports?**
211
313
  Sessions with zero human messages are skipped naturally, `--min-messages`
@@ -236,7 +338,7 @@ in `status`.
236
338
 
237
339
  ```bash
238
340
  npm install
239
- npm test # vitest: fixtures only, never reads your ~/.claude
341
+ npm test # vitest: fixtures only, never reads your agent stores
240
342
  npm run lint # biome
241
343
  npm run typecheck # tsc --noEmit
242
344
  npm run build # tsdown → dist/