cc-hindsight 1.4.0 → 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,7 +38,8 @@ 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
41
+ saves session JSONL under `~/.claude/projects/`; Codex keeps rollouts under
42
+ `~/.codex/sessions/` and `~/.codex/archived_sessions/`; kiro-cli keeps its
42
43
  own store under `~/.kiro/sessions` (both the flat `cli/<uuid>.jsonl` layout and
43
44
  the newer per-session `<hash>/sess_<uuid>/messages.jsonl` layout). Plenty of
44
45
  tools read that data for
@@ -66,7 +67,7 @@ One command builds the whole library and shows it to you when it's done:
66
67
 
67
68
  ```bash
68
69
  npx cc-hindsight distill # offers to export first, then digest → cluster →
69
- # author (asks before any claude call), then shows
70
+ # author (asks before any runner call), then shows
70
71
  # you the finished library
71
72
  ```
72
73
 
@@ -82,6 +83,7 @@ Then browse and curate the results:
82
83
 
83
84
  ```bash
84
85
  npx cc-hindsight list # your library (✎ edited / ▲▼ rating badges)
86
+ npx cc-hindsight gui # browse, search, and copy in your browser
85
87
  npx cc-hindsight show <slug> # read a oneshot
86
88
  npx cc-hindsight copy <slug> # → clipboard, paste into a fresh session
87
89
  npx cc-hindsight edit <slug> # open in $EDITOR; your edits are protected
@@ -89,29 +91,115 @@ npx cc-hindsight rate <slug> up # record a verdict (up|down)
89
91
  npx cc-hindsight prune # remove orphaned entries (asks first)
90
92
  npx cc-hindsight preferences # → CLAUDE.md block
91
93
  npx cc-hindsight status # pipeline funnel + orphan/skip flags
94
+ npx cc-hindsight retention # optional: preview longer local retention
92
95
  ```
93
96
 
94
97
  Requires Node ≥ 22 on macOS or Linux (Windows is untested and currently
95
98
  unsupported). `scan` and `export` are fully deterministic: no LLM, no
96
- network. `distill` uses the `claude` CLI you already have, and never without
97
- asking.
99
+ network. `distill` uses your installed `claude`, `codex`, or `kiro-cli`,
100
+ with a consent prompt (or your explicit `--yes`).
98
101
 
99
- ### Multiple backends (Claude Code + kiro-cli)
102
+ ### A small local library viewer
100
103
 
101
- cc-hindsight also mines [kiro-cli](https://docs.hub.amazon.dev/) session
102
- history the same way. Every command takes `--source claude|kiro|auto` (default
103
- `auto`: read whichever stores exist) and `--kiro-dir` / `KIRO_CONFIG_DIR`
104
- (default `~/.kiro`, parallel to `--claude-dir`). A machine with both stores
105
- merges them into one library; the manifest tags each session's `origin` and the
106
- export summary breaks the count down (`9 claude + 3 kiro`). The kiro backend
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
107
140
  reads both on-disk store layouts (the flat v2 store and the newer v3 per-session
108
141
  store), preferring the v3 copy when a session was migrated into both.
109
142
 
110
- `distill --runner claude|kiro|auto` chooses which CLI does the distilling —
111
- orthogonal to `--source`, so you can mine kiro history and distill with claude
112
- or vice-versa (`auto` prefers the CLI matching your source, else whichever is
113
- installed). `preferences --target claude|kiro|agents` emits a `CLAUDE.md`
114
- block, a `~/.kiro/steering/` file, or a portable `AGENTS.md` section.
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/).
115
203
 
116
204
  ## Privacy & trust
117
205
 
@@ -120,11 +208,14 @@ product:
120
208
 
121
209
  - **Local-only.** Everything is read from your disk and written to your disk
122
210
  (`~/.cc-hindsight`). No server, no accounts, no telemetry. The only network
123
- call is your own `claude` CLI doing what it already does.
124
- - **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)
125
214
  (zero-dependency CLI framework), [`zod`](https://zod.dev) (schema
126
215
  validation), and [`@clack/prompts`](https://github.com/bombshell-dev/clack)
127
- (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
128
219
  exact-pinned, and the entire transitive tree ships locked via
129
220
  `npm-shrinkwrap.json`. The whole data path is small enough to audit in one
130
221
  sitting.
@@ -142,17 +233,23 @@ product:
142
233
  ```mermaid
143
234
  flowchart TD
144
235
  A["~/.claude/projects/**/*.jsonl"] -->|"scan (read-only)"| B["inventory"]
236
+ X["~/.codex/{sessions,archived_sessions}/**/rollout-*.jsonl"] --> B
237
+ K["~/.kiro/sessions/"] --> B
145
238
  A -->|"export (deterministic)"| C["exports/*.md + manifest.json"]
239
+ X --> C
240
+ K --> C
146
241
  A -->|"anaphora + outcome evidence"| D["anaphora.json + outcomes.json"]
242
+ X --> D
243
+ K --> D
147
244
  C --> E
148
245
  D --> E
149
246
  subgraph distill ["distill: opt-in, consent-gated, resumable"]
150
- E["digest: 1 claude call / session"] --> F["cluster: 1 call"]
247
+ E["digest: 1 runner call / session"] --> F["cluster: 1 call"]
151
248
  F --> G["author: 1 call / task"]
152
249
  end
153
250
  G --> H["library/&lt;slug&gt;/ oneshot + provenance"]
154
251
  H --> I["list / show / copy / status"]
155
- H --> J["preferences → CLAUDE.md block"]
252
+ H --> J["preferences → CLAUDE.md / AGENTS.md / Kiro steering"]
156
253
  ```
157
254
 
158
255
  The extraction layer is a fidelity contract: eleven audited rules decide what
@@ -192,12 +289,12 @@ cc-hindsight distills them (forward, for you).
192
289
  ## FAQ
193
290
 
194
291
  **Does my data leave my machine?**
195
- No. The deterministic commands never touch the network. `distill` pipes
196
- content to your locally installed `claude` CLI, the same thing that happens
197
- 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.
198
295
 
199
296
  **What does distill cost?**
200
- 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
201
298
  API credits. The consent prompt states the exact invocation count up front
202
299
  (one call per session digested, one to cluster, one per task authored), and
203
300
  `--dry-run` prints the same plan without running anything. Checkpoints mean an
@@ -208,8 +305,9 @@ provenance) or narrow the scope. Digest and author calls run 3 at a time by
208
305
  default (`--concurrency`; `1` = sequential).
209
306
 
210
307
  **Subscription or API?**
211
- Either. cc-hindsight shells out to `claude -p`; however your CLI is
212
- 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.
213
311
 
214
312
  **Why is a session missing from my exports?**
215
313
  Sessions with zero human messages are skipped naturally, `--min-messages`
@@ -240,7 +338,7 @@ in `status`.
240
338
 
241
339
  ```bash
242
340
  npm install
243
- npm test # vitest: fixtures only, never reads your ~/.claude
341
+ npm test # vitest: fixtures only, never reads your agent stores
244
342
  npm run lint # biome
245
343
  npm run typecheck # tsc --noEmit
246
344
  npm run build # tsdown → dist/