throughline 0.4.6 → 0.4.8

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/CHANGELOG.md CHANGED
@@ -10,6 +10,35 @@ shipped to npm but were not individually tagged on GitHub.
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.4.8] — 2026-05-09
14
+
15
+ ### Changed
16
+
17
+ - Codex install now registers `UserPromptSubmit` and `PostToolUse` hooks in
18
+ addition to the Stop hook. These hooks read the current Codex rollout
19
+ `token_count` directly and, at the verified 80% threshold, inject a
20
+ current-session `$throughline` instruction before the assistant answers or
21
+ continues a tool loop. This keeps automatic refresh independent of
22
+ token-monitor and available to users who never run the monitor.
23
+ - `throughline install` now enables both `[features].codex_hooks = true` and
24
+ `[features].hooks = true` for Codex hook compatibility.
25
+
26
+ ## [0.4.7] — 2026-05-09
27
+
28
+ ### Changed
29
+
30
+ - Codex Stop hook auto-refresh now uses an 80% verified-usage threshold instead
31
+ of 90%, so Throughline can refresh before Codex native auto-compact while
32
+ still staying above the monitor's 70% warning band. Estimate-only usage and
33
+ estimated context windows still do not mutate the thread.
34
+ - Token monitor now discovers active Codex rollout files directly from
35
+ `~/.codex/sessions/**/rollout-*.jsonl`, so current Codex sessions appear even
36
+ when the Codex Stop hook has not written a Throughline state file.
37
+ - Token monitor now displays Codex session ids as the raw first 8 thread-id
38
+ characters (`019e085c`) instead of the confusing prefixed slice (`codex:01`).
39
+ Codex in-flight turns still overlay transient `output_tokens` in the token
40
+ count, but the model column no longer adds a separate `live+<tokens>` marker.
41
+
13
42
  ## [0.4.6] — 2026-05-09
14
43
 
15
44
  ### Changed
package/README.ja.md CHANGED
@@ -18,13 +18,18 @@
18
18
 
19
19
  ```bash
20
20
  npm install -g throughline
21
- throughline install # ~/.claude/settings.json hook を登録
21
+ throughline install # hook / Codex skill / VS Code monitor task を登録
22
22
  ```
23
23
 
24
24
  これだけ。Claude Code のセッションを開けば、以後すべてのターンが
25
25
  `~/.throughline/throughline.db` に自動で流れていく。50 ターン作業した後、
26
- 次のセッションへ記憶を引き継ぎたければ `/clear` の前に `/tl` を打つ。新セッションは
27
- ゼロからのスタートではなく、**思考の途中から再開** される。
26
+ `/clear` を打てば新セッションはゼロからではなく、**思考の途中から再開** される。
27
+ `/clear` を経由しない新規 chat / VS Code 再起動では `/tl` で前任を指名できる。
28
+
29
+ Codex では `UserPromptSubmit` / `PostToolUse` / `Stop` hook と `$throughline`
30
+ skill も登録する。80% 自動発火は token-monitor 依存ではなく、当該 Codex
31
+ セッションの rollout `token_count` を hook が読み、prompt 送信時または tool loop
32
+ 途中の閾値到達時に同じセッションへ `$throughline` 実行指示を注入する。
28
33
 
29
34
  ## 他の手段との比較
30
35
 
@@ -32,10 +37,10 @@ throughline install # ~/.claude/settings.json に hook を登録
32
37
  |---|---|---|---|
33
38
  | **圧縮の軸** | コンテンツの **種類** (テキスト vs ツール I/O) | **新旧** (古い → 要約) | 無し |
34
39
  | **コーディング用途への適合** | 高 — ツール I/O こそ重い 80% | 中 — 残したい部分まで圧縮される | — |
35
- | **`/clear` 後の生存** | ✅ SQLite + `/tl` バトン | ホスト依存 | ❌ |
36
- | **誤継承リスク** | ゼロ (明示的な `/tl`) | 高 | — |
40
+ | **`/clear` 後の生存** | ✅ SQLite + typed `/clear` / `/tl` バトン | ホスト依存 | ❌ |
41
+ | **誤継承リスク** | (typed `/clear` / `/tl` が前任を指名) | 高 | — |
37
42
  | **ランタイム依存** | **ゼロ** (Node 22.5+ 同梱の `node:sqlite`) | 多数 | — |
38
- | **マルチセッション トークン監視** | ✅ 実測 `message.usage`、`len/4` 推定なし | — | — |
43
+ | **マルチセッション トークン監視** | ✅ Claude 実測 `message.usage`、Codex rollout `token_count` | — | — |
39
44
 
40
45
  <details>
41
46
  <summary><b>なぜこれが効くのか — 80% ツール I/O 問題</b></summary>
@@ -126,33 +131,34 @@ L3 に保存された `kind` 別 (ツール入力 / ツール出力 / hook 出
126
131
 
127
132
  ---
128
133
 
129
- ## 引き継ぎ: `/clear` で自動、env で OFF、`/tl` で明示
130
-
131
- Throughline 0.4.0 から引き継ぎは 2 経路:
132
-
133
- ### auto path (デフォルト): `/clear` で自動引き継ぎ
134
+ ## 引き継ぎ: typed `/clear` / `/tl` が前任を指名、source-`clear` は補助
134
135
 
135
- Claude Code 2.1.128 以降は `/clear` 直後の SessionStart hook に
136
- `source='clear'` が確実に乗ります。Throughline がこれを検出して、前セッションの
137
- メモリを新セッションに自動 merge します。**ユーザー操作不要** — `/clear`
138
- だけで新チャットが「途中から」再開されます。
136
+ Throughline 0.4.1+ の引き継ぎは 2 経路です。主経路は typed `/clear` または
137
+ `/tl` が書く baton で、`source='clear'` auto path は `/clear` が
138
+ UserPromptSubmit hook に届かない場合の補助です。
139
139
 
140
- `THROUGHLINE_DISABLE_AUTO_HANDOFF=1` を環境変数に立てると auto path OFF にできます。
140
+ ### baton path (primary): typed `/clear` または `/tl`
141
141
 
142
- ### baton path (`/tl`): 明示意思マーカー
142
+ ユーザーが prompt `/clear` または `/tl` を打つと、UserPromptSubmit hook が
143
+ **そのセッションの** `session_id` を `handoff_batons` に書きます。次の
144
+ SessionStart は 1 時間以内の baton を消費し、その前任を確定的に merge します。
145
+ 複数ウィンドウで「最新更新セッション」と「今 `/clear` したセッション」が違っても、
146
+ 指名された前任だけを引き継ぎます。
143
147
 
144
- 次のいずれかのユーザー向け:
148
+ ### auto path (fallback): `source='clear'`
145
149
 
146
- - `THROUGHLINE_DISABLE_AUTO_HANDOFF=1` を立てている、**または**
147
- - `/clear` 経由しないで引き継ぎたい (新 chat / VSCode 再起動など)
150
+ baton が無く、SessionStart の `source='clear'` が届いた場合だけ、同 project の
151
+ 最新 Claude predecessor を選んで merge します。これは VS Code 拡張メニューなど、
152
+ typed `/clear` が UserPromptSubmit hook に届かない経路のための補助です。
148
153
 
149
- 新セッションを開く前に `/tl` を打つと `UserPromptSubmit` hook baton を書き、
150
- 次の `SessionStart` (1 時間以内) baton を消費して merge します。
151
- `source` 値関係なく発火します。
154
+ `THROUGHLINE_DISABLE_AUTO_HANDOFF=1` はこの fallback path だけを OFF にします。
155
+ typed `/clear` と `/tl` はユーザーの明示意思なので、この env に関係なく baton
156
+ 書いて引き継ぎます。
152
157
 
153
158
  ```
154
- auto path: Session A → /clear → Session B (A auto-merge)
155
- baton path: Session A → /tl (新 chat / 再起動) → Session B (baton を消費して A を merge)
159
+ typed /clear: Session A → /clear → Session B (A baton を消費して merge)
160
+ typed /tl: Session A → /tl → 新 chat / 再起動 → Session B (A の baton を消費して merge)
161
+ fallback: baton 無し + source='clear' → latest predecessor を merge
156
162
  ```
157
163
 
158
164
  ### 注入されるもの
@@ -214,10 +220,12 @@ throughline monitor --session <id-prefix>
214
220
  ```
215
221
 
216
222
  監視中は Claude transcript / Codex rollout をライブに読み、Stop hook の state
217
- snapshot はライブ usage が取れない場合の控えとして使います。これにより表示更新は
218
- Stop 完了待ちではなくなります。
219
- Codex は open turn 中だけ `input_tokens + output_tokens` を表示し、モデル欄に
220
- `live+<tokens>` を付けます。`task_complete` 後は verified `input_tokens` のみに戻ります。
223
+ snapshot はライブ usage が取れない場合の控えとして使います。Codex については
224
+ `~/.codex/sessions/**/rollout-*.jsonl` も直接 discovery するため、Stop hook が
225
+ Throughline state をまだ書いていない現在セッションも表示できます。Codex は open turn
226
+ 中だけ `input_tokens + output_tokens` を表示し、`task_complete` 後は verified
227
+ `input_tokens` のみに戻ります。表示 ID は `codex:01` ではなく、raw thread id の
228
+ 先頭 8 桁 (`019e085c` など) です。
221
229
 
222
230
  詳細仕様 (resize 追従、1M context 検出、ステイル隠し、Stop hook の非同期化など) は
223
231
  [英語版 README](README.md#multi-session-token-monitor) を参照してください。
@@ -228,7 +236,7 @@ Codex は open turn 中だけ `input_tokens + output_tokens` を表示し、モ
228
236
 
229
237
  | コマンド | 役割 |
230
238
  | --- | --- |
231
- | `throughline install` | hook / Codex skill を登録し、VS Code 配下なら現プロジェクトの monitor task も配置 |
239
+ | `throughline install` | hook / Codex UserPromptSubmit・PostToolUse・Stop hook / Codex skill を登録し、VS Code 配下なら現プロジェクトの monitor task も配置 |
232
240
  | `throughline install --project` | 現リポジトリの `.claude/settings.json` だけに hook を登録 |
233
241
  | `throughline uninstall` | hook を削除 |
234
242
  | `throughline monitor` | マルチセッション監視を起動 |
package/README.md CHANGED
@@ -27,16 +27,20 @@ type `/clear` — the new session resumes mid-thought instead of starting from
27
27
  zero. (For non-`/clear` boundaries such as a brand-new chat or a VSCode
28
28
  restart, type `/tl` first to mark the predecessor.)
29
29
 
30
- Global install also registers a Codex Stop hook in `~/.codex/hooks.json` and
31
- enables `[features].codex_hooks = true` in `~/.codex/config.toml`. The Codex
32
- hook invokes the installed `bin/throughline.mjs` through an absolute Node path,
33
- so Codex App Server PATH differences do not hide the command. It is registered
34
- synchronously (`async: false`), matching the Codex hook behavior verified in
35
- Caveat. Existing non-Throughline Codex hooks are preserved. It also installs a
36
- global `$throughline` Codex skill. Bare `$throughline` runs the scripted
37
- current-thread rollback + Throughline DB memory injection directly; ask
38
- explicitly for status, resume, summarize, diagnostics, or fresh-thread handoff
39
- when you want those read-only surfaces instead.
30
+ Global install also registers Codex `UserPromptSubmit`, `PostToolUse`, and
31
+ `Stop` hooks in `~/.codex/hooks.json` and enables both
32
+ `[features].codex_hooks = true` and `[features].hooks = true` in
33
+ `~/.codex/config.toml`. The Codex hooks invoke the installed
34
+ `bin/throughline.mjs` through an absolute Node path, so Codex App Server PATH
35
+ differences do not hide the command. They are registered synchronously
36
+ (`async: false`), matching the Codex hook behavior verified in Caveat. Existing
37
+ non-Throughline Codex hooks are preserved. The prompt and tool-loop hooks read
38
+ the current rollout `token_count` themselves and inject `$throughline` at the
39
+ verified 80% threshold; token-monitor is display-only and is never the trigger
40
+ source. It also installs a global `$throughline` Codex skill. Bare
41
+ `$throughline` runs the scripted current-thread rollback + Throughline DB memory
42
+ injection directly; ask explicitly for status, resume, summarize, diagnostics,
43
+ or fresh-thread handoff when you want those read-only surfaces instead.
40
44
 
41
45
  ## How it compares
42
46
 
@@ -249,8 +253,12 @@ looked like a rolled-back user prompt could reappear after VS Code restart /
249
253
  reconnect, but controlled model-visible rollback smokes did not reproduce that
250
254
  path. `throughline trim --execute --host codex` now sends the guarded
251
255
  rollback + Throughline DB memory injection when app-server turn-count guards and
252
- injectable DB memory are available. Codex Stop hook auto-refresh also attempts
253
- the same live refresh when verified usage reaches the 90% threshold.
256
+ injectable DB memory are available. Codex current-session auto-refresh is not a
257
+ token-monitor feature: the Codex `UserPromptSubmit` hook reads the current
258
+ rollout `token_count` and, at the verified 80% threshold, injects a same-session
259
+ instruction to run the installed `$throughline` workflow before answering. The
260
+ Codex Stop hook still attempts the guarded live refresh when it naturally fires,
261
+ so non-monitor users get the same threshold behavior.
254
262
 
255
263
  `throughline codex-host-primitive-audit` can inspect the installed Codex
256
264
  app-server schema read-only. On the current tested Codex CLI, it finds
@@ -508,7 +516,7 @@ Example output:
508
516
  ```
509
517
  [Throughline] 1 セッション
510
518
  ▶ Throughline Claude 2ed5039c just now ██░░░░░░░░ 205.1k / 1.0M claude-opus-4-6
511
- Throughline Codex codex:01 just now ██████░░░░ 151.9k / 258.4k gpt-5.5
519
+ Throughline Codex 019e085c just now ██████░░░░ 151.9k / 258.4k gpt-5.5
512
520
  ```
513
521
 
514
522
  - **Claude token counts are accurate.** Read straight from the latest
@@ -517,27 +525,34 @@ Example output:
517
525
  (`input_tokens + cache_creation_input_tokens + cache_read_input_tokens`).
518
526
  No `length / 4` approximation.
519
527
  - **Codex token counts use the rollout `token_count` event when present.** The
520
- Codex Stop hook writes `codex:<thread_id>` monitor state with the rollout
521
- path. While the monitor is running it reads the live rollout every tick and
522
- prefers the latest verified `token_count` sample. During an open Codex turn,
523
- the monitor overlays transient `output_tokens` on top of `input_tokens` and
524
- marks the model with `live+<tokens>`; when `task_complete` arrives it drops
525
- back to verified `input_tokens` only. If a Codex rollout has no token-count
526
- event, Throughline can show an explicit estimate with `estimated: true` and
527
- the monitor marks it with `est`; it is not presented as exact usage.
528
- - **Codex auto-refresh mutates at the verified 90% threshold.** The Codex Stop
529
- hook captures DB memory, writes monitor state, and when verified usage reaches
530
- the threshold it attempts rollback + Throughline DB memory injection for the
531
- current thread.
528
+ monitor discovers live Codex rollouts directly from
529
+ `~/.codex/sessions/**/rollout-*.jsonl`, so a current Codex session can appear
530
+ even before the Codex Stop hook writes `codex:<thread_id>` monitor state.
531
+ While the monitor is running it reads the live rollout every tick and prefers
532
+ the latest verified `token_count` sample. During an open Codex turn, the
533
+ monitor overlays transient `output_tokens` on top of `input_tokens`; when
534
+ `task_complete` arrives it drops back to verified `input_tokens` only. If a
535
+ Codex rollout has no token-count event, Throughline can show an explicit
536
+ estimate with `estimated: true` and the monitor marks it with `est`; it is not
537
+ presented as exact usage.
538
+ - **Codex auto-refresh is driven by the current Codex session, not the monitor.**
539
+ The Codex `UserPromptSubmit` and `PostToolUse` hooks capture rollout memory
540
+ and, when verified usage reaches 80%, inject a current-session `$throughline`
541
+ instruction before the assistant answers or continues a tool loop. The Codex
542
+ Stop hook also captures DB memory, writes monitor state, and attempts guarded
543
+ rollback + Throughline DB memory injection when it naturally fires above the
544
+ threshold.
532
545
  - **1M-context detection** is automatic. It checks the `[1m]` suffix in the
533
546
  transcript, falls back to string matching on `1M context`, and finally
534
547
  promotes to 1M if observed usage exceeds 200k.
535
548
  - **Multi-session view.** Each Claude Code or Codex session writes its own
536
- state file (`~/.throughline/state/<session_id>.json`). Codex session ids are
537
- stored as `codex:<thread_id>` in the JSON payload; filenames are URL-encoded
538
- so the state directory remains portable. The monitor scans the directory every
539
- second and displays one row per live session, sorted by last activity. The
540
- most recent one is highlighted with `▶`.
549
+ state file (`~/.throughline/state/<session_id>.json`), and active Codex
550
+ rollouts are discovered directly from the Codex session directory. Codex
551
+ session ids are stored as `codex:<thread_id>` in JSON state, while the display
552
+ shows the raw first 8 thread-id characters (for example `019e085c`) to avoid
553
+ the ambiguous `codex:01` prefix slice. The monitor scans every second and
554
+ displays one row per live session, sorted by last activity. The most recent
555
+ one is highlighted with `▶`.
541
556
  - **Stale hiding.** Sessions that haven't been touched in 15 minutes drop out of
542
557
  the default view; files older than 24 hours are deleted entirely. This is the
543
558
  only time threshold in the system and is used solely for display hygiene — no
@@ -592,7 +607,7 @@ monitor appears in a dedicated terminal panel the next time you open that
592
607
  folder.
593
608
 
594
609
  **How it works.** `ensureMonitorTaskFile` is called from `throughline install`
595
- and from **all three hooks (SessionStart, UserPromptSubmit, Stop)**. Whichever
610
+ and from **all three Claude hooks (SessionStart, UserPromptSubmit, Stop)**. Whichever
596
611
  one fires first in your environment creates the file; the rest are idempotent
597
612
  no-ops. Once per project it inspects `.vscode/tasks.json`:
598
613
 
@@ -652,7 +667,7 @@ entry to the `tasks` array yourself:
652
667
 
653
668
  | Command | What it does |
654
669
  | ---------------------------------------------- | ------------------------------------------------------------ |
655
- | `throughline install` | Register Claude user hooks/slash commands, the global Codex Stop hook, the global `$throughline` Codex skill, and the current VS Code monitor task when applicable |
670
+ | `throughline install` | Register Claude user hooks/slash commands, the global Codex UserPromptSubmit/PostToolUse/Stop hooks, the global `$throughline` Codex skill, and the current VS Code monitor task when applicable |
656
671
  | `throughline install --project` | Register Claude hooks/slash commands in this repo only |
657
672
  | `throughline uninstall` | Remove Throughline-managed Claude hooks/slash commands, only the Throughline-managed Codex hook, and the `$throughline` Codex skill |
658
673
  | `throughline monitor [--all] [--session <id>]` | Run the multi-session token monitor |
@@ -11,6 +11,8 @@
11
11
  * throughline detail <時刻> # L2+L3 詳細取得 (Claude が Bash 経由で呼ぶ想定)
12
12
  * throughline handoff-preview # Codex-facing throughline_handoff JSON preview
13
13
  * throughline codex-capture # Capture active Codex rollout turns into Throughline DB
14
+ * throughline codex-hook user-prompt-submit # Codex current-session auto-refresh prompt hook
15
+ * throughline codex-hook post-tool-use # Codex current-session auto-refresh tool-loop hook
14
16
  * throughline codex-hook stop # Codex native Stop hook (capture + L1 summarize)
15
17
  * throughline codex-summarize # Summarize captured Codex L2 turns into L1 via Codex CLI
16
18
  * throughline codex-resume # Render Codex active-work context from DB
@@ -149,8 +151,17 @@ Usage:
149
151
  throughline handoff-preview Print Codex-facing throughline_handoff JSON
150
152
  throughline codex-capture Capture active Codex rollout turns into DB
151
153
  (requires --codex-thread-id or env thread id)
152
- throughline codex-hook stop Codex native Stop hook: capture rollout and
153
- summarize old L2 turns into L1 via Codex CLI
154
+ throughline codex-hook user-prompt-submit
155
+ Codex UserPromptSubmit hook: capture rollout and,
156
+ at 80%, inject current-session $throughline
157
+ instruction from verified rollout token_count
158
+ throughline codex-hook post-tool-use
159
+ Codex PostToolUse hook: during tool loops, capture
160
+ rollout and inject the same 80% $throughline
161
+ instruction from verified rollout token_count
162
+ throughline codex-hook stop Codex native Stop hook: capture rollout,
163
+ summarize old L2 turns into L1, and run guarded
164
+ auto-refresh when verified usage reaches 80%
154
165
  throughline codex-summarize Summarize captured Codex L2 into L1 via Codex CLI
155
166
  (requires a codex:<thread-id> session)
156
167
  throughline codex-resume Render Codex active-work context from DB
@@ -243,6 +254,8 @@ Hook subcommands (called by Claude Code / Codex):
243
254
  throughline session-start SessionStart hook
244
255
  throughline process-turn Stop hook
245
256
  throughline prompt-submit UserPromptSubmit hook (/tl & /clear baton writer)
257
+ throughline codex-hook user-prompt-submit Codex current-session refresh prompt hook
258
+ throughline codex-hook post-tool-use Codex current-session refresh tool-loop hook
246
259
  throughline codex-hook stop Codex Stop hook
247
260
  `);
248
261
  }
@@ -119,7 +119,7 @@ schema v4 で PostToolUse (`capture-tool`) は廃止、L2/L3 は Stop 内で一
119
119
  | **npm 公開 (v0.3.24)** | 2026-05-02 v0.3.23 の補完: `.vscode/tasks.json` には現環境の絶対パスが書き込まれるため、**そもそも commit すべきではない**。`shouldRecommendGitignore` を [src/vscode-task.mjs](../src/vscode-task.mjs) に追加し、`ensureMonitorTaskFile` が created / merged / repaired を返すタイミングで「git リポジトリ内かつ `.gitignore` に `.vscode/tasks.json` 系エントリが無い」を判定。該当時に `<system-reminder>` で `.gitignore` 追加推奨を 1 度だけ stdout 通知 (`.throughline-gitignore-noted` marker で抑止)。否定パターン (`!.vscode/tasks.json`) はスキップ判定 = 推奨を出す。README Troubleshooting にも明示。配布物 (npm tarball) には絶対パスは入っていない (`files` フィールドが `.vscode/` を含まない、ソースに hard-coded path 無し) ことを再確認 |
120
120
  | **npm 公開 (v0.3.25): Claude-primary / Codex-sidecar groundwork** | `HandoffRecord` projection、`throughline handoff-preview`、`throughline_handoff` example、`codex-sidecar-diagnostics` / `codex-sidecar-dry-run` を追加。Claude Code hooks / slash command / transcript / baton / resume behavior は正本として維持し、Codex 対応は adapter / projection として足す |
121
121
  | **npm 公開 (v0.3.25): optional Codex-sidecar L1 summarization** | Claude primary の L2→L1 要約は、`codex-sidecar` が `summarize-l1` preset で configured の場合だけ sidecar を使う。disabled / unavailable / run failure では、ユーザー許可済み互換経路として既存 Claude Haiku 要約を維持する。Codex primary の L2→L1 backend は次フェーズ計画で Codex CLI 本線として扱う。Claude CLI smoke / test で Claude を呼ぶ場合は Haiku を使う |
122
- | **npm 公開 (v0.3.25): `/tl-trim` dry-run** | `throughline trim --dry-run`、`--preflight`、guarded `--execute`、`--host`、`--keep-recent`、`--all`、`--memo-stdin`、`--preview-max-chars`、`--codex-thread-id`、`THROUGHLINE_CODEX_THREAD_ID` / `CODEX_THREAD_ID`、`throughline codex-threads`、`throughline doctor --trim`、Claude slash command `/tl-trim` を追加。Codex app-server の rollback / inject primitive は live app-server 上で実測済み。2026-05-06 incident 後は一時 blocked としたが、2026-05-08 の controlled rollback model-visible smoke が app-server restart 境界と VS Code reload/reconnect 境界の両方で `not-reproduced` だったため、過剰 blocker は解除済み。`trim --execute --host codex` は明示実行で current-thread rollback + Throughline DB memory inject を送り、Codex Stop hook auto-refresh は verified usage 90% 以上で同じ guarded path を試行する。DB memory 不在、Codex thread identity 不在、rollout/app-server turn-count 不一致は mutation 前に拒否する。restore-safety / planned restore-safety / host primitive audit は diagnostics として表示する |
122
+ | **npm 公開 (v0.3.25): `/tl-trim` dry-run** | `throughline trim --dry-run`、`--preflight`、guarded `--execute`、`--host`、`--keep-recent`、`--all`、`--memo-stdin`、`--preview-max-chars`、`--codex-thread-id`、`THROUGHLINE_CODEX_THREAD_ID` / `CODEX_THREAD_ID`、`throughline codex-threads`、`throughline doctor --trim`、Claude slash command `/tl-trim` を追加。Codex app-server の rollback / inject primitive は live app-server 上で実測済み。2026-05-06 incident 後は一時 blocked としたが、2026-05-08 の controlled rollback model-visible smoke が app-server restart 境界と VS Code reload/reconnect 境界の両方で `not-reproduced` だったため、過剰 blocker は解除済み。`trim --execute --host codex` は明示実行で current-thread rollback + Throughline DB memory inject を送り、Codex Stop hook auto-refresh は verified usage 80% 以上で同じ guarded path を試行する。DB memory 不在、Codex thread identity 不在、rollout/app-server turn-count 不一致は mutation 前に拒否する。restore-safety / planned restore-safety / host primitive audit は diagnostics として表示する |
123
123
  | **npm 公開 (v0.3.25): Codex primary capture** | `throughline codex-capture --codex-thread-id <id>` を追加。Codex rollout JSONL の active turns を `codex:<thread_id>` session として DB `bodies` に保存し、`function_call` / `function_call_output` を DB `details` の L3 tool input / output として保存する。`thread_rolled_back` 適用後の active thread だけを再構成し、rollback 済み tail は current L2/L3 に残さない。Codex thread id は明示指定または env 指定のみで、自動推測しない |
124
124
  | **npm 公開 (v0.3.25): Codex-primary L1 backend** | `summarizeToL1` に `hostMode` 分岐を追加。Claude primary は既存の `codex-sidecar` / Claude Haiku 互換経路を維持し、Codex primary は Codex CLI backend を使う。Codex CLI failure は `source = codex-cli` / `reason` 付き explicit error とし、Claude Haiku / `raw_l2` に silent fallback しない |
125
125
  | **npm 公開 (v0.3.25): Codex-primary L1 CLI** | `throughline codex-summarize --session codex:<thread_id>` を追加。captured Codex L2 が L2 window を超えた場合、最古の未要約 turn を Codex CLI backend で L1 skeleton に書く。Codex CLI failure は explicit error |
@@ -131,11 +131,13 @@ schema v4 で PostToolUse (`capture-tool`) は廃止、L2/L3 は Stop 内で一
131
131
  | **npm 公開 (v0.3.25): Codex VS Code restore smoke protocol** | `throughline codex-vscode-restore-smoke --prepare/--verify --codex-thread-id <id>` を追加。`--prepare` は hidden active-work marker memory を app-server へ注入し、VS Code reload / reconnect 後に marker を含まない prompt を送る二段階手順を出す。`--verify` は rollout を読み、prepare 後の marker-free smoke prompt、assistant の marker-only answer、user prompt への marker leak 不在を確認する。prepare は `THROUGHLINE_EXPERIMENTAL_CODEX_VSCODE_RESTORE_SMOKE=1` 必須。実 VS Code reload / reconnect marker proof は `TL_CODEX_VSCODE_RESTORE_46888202` で成功済み。ただしこれは hidden developer memory visibility 証明であり、rollback 済み user turn の非復活証明ではない |
132
132
  | **npm 公開 (v0.3.25): Codex VS Code rollback smoke verifier** | `throughline codex-vscode-rollback-smoke --verify --codex-thread-id <id>` を追加。rollout を read-only で読み、rollback event、rollback 済み user text、rollback 後 user turn、`restoreSafety.status = ok` を必須条件にする。`--after-vscode-restart` がある場合だけ `restartSafe: true` を返す。実 incident-shaped live rollback run では `thread_rolled_back` と injected memory は記録されたが、rollback 対象 user text が `compacted.replacement_history` に残り、後続 verifier では rollback 済み user text の再出現も観測した。後続分類で app-server response 上の retained text は `aggregatedOutput` に限定され、controlled rollback model-visible smoke は再現しなかったため、これは現在は diagnostic evidence として扱う |
133
133
  | **npm 公開 (v0.3.25): Codex primary doctor** | `throughline doctor --codex` を追加。現在 project の Codex thread env identity、rollout candidates、captured `codex:<thread_id>` DB sessions、context-refresh memory contract、new-thread handoff readiness、safe continuation status、host primitive audit status、次に使う capture / handoff / resume / audit command を表示する。doctor 自体は read-only で、Codex thread / DB / Claude settings を変更しない。`doctor --trim --host codex` も host primitive audit status を表示する |
134
- | **npm 公開 (v0.3.25): Codex global Stop hook / skill install** | `throughline install` が Claude hooks / slash commands に加えて `~/.codex/hooks.json` に絶対 node + installed `bin/throughline.mjs codex-hook stop` を `async: false` で登録し、`~/.codex/config.toml` の `[features].codex_hooks = true` を有効化し、`~/.codex/skills/throughline` に `$throughline` skill を配置する。Codex App Server / VSCode host の PATH 差分で bare `throughline` が見えない可能性があるため、hook は Caveat と同じ絶対パス型に寄せる。既存 Caveat / Spotter などの Codex hooks は保持し、`throughline uninstall` は Throughline 管理の Codex hook / skill だけを削除する。既に bare command または `async: true` で登録済みの Throughline Codex Stop hook は次回 install で更新する。実環境では `codex exec --json` child thread `019dfd4f-93ff-7522-8f89-bd1e1996c8d7` が Stop hook で自然 capture され、`doctor --codex` の latest DB session が `codex:019dfd4f-93ff-7522-8f89-bd1e1996c8d7` に進むことを確認した。さらに絶対パス型へ更新後、child thread `019dfd5e-1248-7c11-8ddc-97e1b0701e10` でも latest DB session が `codex:019dfd5e-1248-7c11-8ddc-97e1b0701e10` に進むことを確認した。hook shape 変更後に新規開始した VSCode-origin thread `019dfd62-9a9d-7211-bf91-89d8e3fc908e` でも `doctor --codex` の current thread と latest DB session が一致し、自然 Stop hook capture を確認済み。hook shape 変更前から開いていた VSCode-origin parent thread は、変更後の自然 Stop smoke としては扱わない。Caveat 側にも `async: false` Stop hook が動く実測があるため、Codex 側は Caveat と同じ同期 hook 方針に寄せる。`codex-capture` / `codex-summarize` / `codex-resume --memo-stdin` は診断・明示操作 surface として維持し、model-visible smoke は明示 opt-in。2026-05-08 以降、Stop hook auto-refresh は verified usage 90% 以上で guarded rollback / inject を試行し、estimate usage では mutation しない |
134
+ | **npm 公開 (v0.3.25): Codex global Stop hook / skill install** | `throughline install` が Claude hooks / slash commands に加えて `~/.codex/hooks.json` に絶対 node + installed `bin/throughline.mjs codex-hook stop` を `async: false` で登録し、`~/.codex/config.toml` の `[features].codex_hooks = true` を有効化し、`~/.codex/skills/throughline` に `$throughline` skill を配置する。Codex App Server / VSCode host の PATH 差分で bare `throughline` が見えない可能性があるため、hook は Caveat と同じ絶対パス型に寄せる。既存 Caveat / Spotter などの Codex hooks は保持し、`throughline uninstall` は Throughline 管理の Codex hook / skill だけを削除する。既に bare command または `async: true` で登録済みの Throughline Codex Stop hook は次回 install で更新する。実環境では `codex exec --json` child thread `019dfd4f-93ff-7522-8f89-bd1e1996c8d7` が Stop hook で自然 capture され、`doctor --codex` の latest DB session が `codex:019dfd4f-93ff-7522-8f89-bd1e1996c8d7` に進むことを確認した。さらに絶対パス型へ更新後、child thread `019dfd5e-1248-7c11-8ddc-97e1b0701e10` でも latest DB session が `codex:019dfd5e-1248-7c11-8ddc-97e1b0701e10` に進むことを確認した。hook shape 変更後に新規開始した VSCode-origin thread `019dfd62-9a9d-7211-bf91-89d8e3fc908e` でも `doctor --codex` の current thread と latest DB session が一致し、自然 Stop hook capture を確認済み。hook shape 変更前から開いていた VSCode-origin parent thread は、変更後の自然 Stop smoke としては扱わない。Caveat 側にも `async: false` Stop hook が動く実測があるため、Codex 側は Caveat と同じ同期 hook 方針に寄せる。`codex-capture` / `codex-summarize` / `codex-resume --memo-stdin` は診断・明示操作 surface として維持し、model-visible smoke は明示 opt-in。2026-05-08 以降、Stop hook auto-refresh は verified usage 80% 以上で guarded rollback / inject を試行し、estimate usage では mutation しない。2026-05-09 以降は Codex native auto-compact より先に Throughline refresh を走らせつつ、70% warning よりは mutation を遅らせる |
135
135
  | **npm 公開 (v0.3.25): Codex-first roadmap** | [THROUGHLINE_CODEX_FIRST_ROADMAP.md](THROUGHLINE_CODEX_FIRST_ROADMAP.md) を追加。次フェーズは Codex primary 実用化、Codex Rewind 互換、Claude 側 finalization の順で進める。Codex primary の L2→L1 backend は Codex CLI を本線とし、`codex-sidecar` は Claude primary からの review / risk-check / second opinion / 互換 L2→L1 経路として整理する |
136
136
  | **npm 公開 (v0.3.25): npm docs packaging** | README から参照する `docs/` と `CHANGELOG.md` を npm `files` に追加。`docs/throughline-handoff-context.example.json` を含め、README の sidecar dry-run 例が tarball 内でも成立するようにする |
137
137
  | **npm 公開 (v0.4.0): /clear auto-handoff + memo / save-inflight / /tl-trim retire** | 2026-05-08 Claude Code 2.1.128 で `source='clear'` が reliable になったため、`/clear` で自動引継ぎがデフォルト ON になる auto path を追加。`THROUGHLINE_DISABLE_AUTO_HANDOFF=1` で OFF にできる。`/tl` slash command は明示意思マーカーへ簡素化 (memo 4 項目入力廃止、`save-inflight` CLI 削除、`/tl-trim` slash command 廃止、`updateBatonMemo` 関数削除、`handoff_batons.memo_text` を schema v8 で drop)。注入は L1 + L2 + L3 references のみに簡素化し、memo / 中断直前 thinking セクションを削除。Codex 側 trim path は維持。詳細は [CHANGELOG.md](../CHANGELOG.md) と [THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md](THROUGHLINE_CLEAR_AUTO_HANDOFF_PLAN.md) |
138
138
  | **npm 公開 (v0.4.1): typed `/clear` も baton を書く + 2 経路の優先順位入れ替え** | 2026-05-09 `/clear` を UserPromptSubmit hook で検出した時点で当該セッションの `session_id` を `handoff_batons` に書き込み、次 SessionStart が確定的にそのセッションを引き継ぐ。これで multi-window で「最新更新セッション ≠ /clear したセッション」になるシナリオで `findLatestClaudePredecessor` heuristic が誤った前任を選ぶ問題を解消。2 経路の優先順位を **baton path = primary、auto path = fallback** に変更 (auto path は VSCode 拡張メニュー由来など UserPromptSubmit に届かない経路のフォールバック)。`THROUGHLINE_DISABLE_AUTO_HANDOFF=1` は fallback path のみに作用するようになった (typed `/clear` / `/tl` は env と無関係に発火する)。あわせて `.vscode/tasks.json` を git 追跡から外し (gitignore)、`ensureMonitorTaskFile` が hook 発火ごとに絶対パスを書き換える挙動による別環境での dirty diff を解消。`src/prompt-submit.test.mjs` を新設し、`isClearCommand` / `isBatonCommand` 判定 14 件と subprocess+DB 実体テスト 3 件を追加。詳細は [CHANGELOG.md](../CHANGELOG.md) |
139
+ | **npm 公開 (v0.4.7): Codex monitor direct discovery + 80% auto-refresh** | 2026-05-09 Codex Stop hook auto-refresh の verified usage threshold を 90% から 80% に変更し、Codex native auto-compact より先に Throughline DB memory refresh を試行する。estimate usage / estimated context window では mutation しない。`throughline monitor` は `~/.throughline/state` に加えて `~/.codex/sessions/**/rollout-*.jsonl` を直接 discovery し、Throughline state が未生成の現在 Codex thread も表示する。既存 state がある場合は state の usage snapshot を保持しつつ discovered rollout path / mtime を合流する。Codex 表示 ID は `codex:01` ではなく raw thread id 先頭 8 桁 (`019e085c`) にした。Codex open turn の transient `output_tokens` は token count に overlay するが、モデル欄の `live+<tokens>` marker は表示しない |
140
+ | **未リリース: Codex current-session 80% trigger** | Codex 自動発火を token-monitor に依存させず、global install が Codex `UserPromptSubmit` / `PostToolUse` hooks も登録する。hook は当該 Codex session の rollout `token_count` を直接読み、verified 80% 以上なら同じ user turn または tool loop 継続前に `$throughline` workflow 実行指示を `additionalContext` で注入する。Stop hook の guarded auto-refresh は残す。`~/.codex/config.toml` は旧 `codex_hooks = true` に加えて現行 `hooks = true` も有効化する |
139
141
  | **グローバル E2E 検証** | 2026-04-17 別ディレクトリから `throughline doctor` 全緑を確認 |
140
142
 
141
143
  ### ❌ 未完タスク
@@ -147,7 +149,7 @@ schema v4 で PostToolUse (`capture-tool`) は廃止、L2/L3 は Stop 内で一
147
149
  | **GitHub Actions 自動 publish** | `release` タグ push をトリガー(Phase 3+、Trusted Publishing 使用) |
148
150
  | **Claude Code プラグインマーケットプレース登録** | npm 公開の後継ステップ(Phase 3+) |
149
151
  | **turn-processor.test.mjs の 10 秒タイムアウト解消** | `main()` が stdin を待ち続けるためテストファイルがハングする既存の問題。実装動作は無影響、テスト個別 9/9 は pass |
150
- | **automatic context rollback / inject** | Codex Stop hook auto-refresh は verified usage 90% 以上で guarded rollback + Throughline DB memory inject を試行する。controlled rollback model-visible smoke で復活が未再現となったため、2026-05-06 incident 後の overbroad blocker は解除済み。estimate usage では実行しない |
152
+ | **automatic context rollback / inject** | Codex Stop hook auto-refresh は verified usage 80% 以上で guarded rollback + Throughline DB memory inject を試行する。controlled rollback model-visible smoke で復活が未再現となったため、2026-05-06 incident 後の overbroad blocker は解除済み。estimate usage では実行しない |
151
153
 
152
154
  ---
153
155
 
@@ -278,7 +278,7 @@ Codex 側 v0.3.25 の以下は本計画で **完全に無変更**:
278
278
  - `codex-capture` / `codex-summarize` / `codex-resume` (Codex primary L1/L2/L3 path)
279
279
  - `codex-resume --format handoff` (新規 Codex thread 用 prompt)
280
280
  - `trim --execute --host codex` / `--preflight --host codex` (app-server `thread/rollback` + `thread/inject_items`)
281
- - Codex Stop hook 90% auto-refresh
281
+ - Codex Stop hook 80% auto-refresh
282
282
  - restore-safety / host primitive audit diagnostics
283
283
  - Codex skill ([codex/skills/throughline](../codex/skills/throughline)) の trim 機能 (= 機能自体は無変更、SKILL.md 内の `/tl-trim` 言及があれば 4 TODO で update)
284
284
  - [src/codex-app-server.mjs](../src/codex-app-server.mjs), [src/codex-rollout-memory.mjs](../src/codex-rollout-memory.mjs)
@@ -28,7 +28,7 @@
28
28
  - Claude-primary の現行 L2 -> L1 要約は `codex-sidecar` が configured の場合に sidecar を優先し、使えない場合は Claude Haiku 経路に戻る。Codex-primary は Codex CLI backend 失敗を明示 error にし、Claude Haiku / raw L2 へ fallback しない。
29
29
  - Codex guarded trim は、Codex app-server の `thread/read` / `thread/resume` / `thread/rollback` / `thread/inject_items` を使う。明示 thread identity、rollout/app-server turn count guard、injectable memory がない場合は mutation 前に拒否する。
30
30
  - Claude `/rewind` 自動化はまだ有効化しない。
31
- - Codex automatic refresh mutation は再有効化済み。`90%` の verified usage threshold で rollback / Throughline DB memory inject を試行し、estimate usage では実行しない。
31
+ - Codex automatic refresh mutation は再有効化済み。`80%` の verified usage threshold で rollback / Throughline DB memory inject を試行し、estimate usage では実行しない。Codex native auto-compact より先に Throughline refresh を走らせつつ、70% warning よりは mutation を遅らせる。
32
32
 
33
33
  ## 新セッション引き継ぎ
34
34
 
@@ -466,9 +466,10 @@ Phase 5 implementation status (2026-05-06):
466
466
  - 削減量の記録: `trim --dry-run --host codex` は rollout text がある場合に `contextReductionEstimate` を返す。2026-05-06 の現在 thread `019dfd62-9a9d-7211-bf91-89d8e3fc908e` では通常 keep-recent preview だと `capturedTurns = 14` / `keepRecent = 20` のため `rollbackTurns = 0`、推定削減量も 0 だった。旧 bare `$throughline` context refresh は `--all` を使っていたため、この keep-recent preview の 0 は「Codex で削減できない」という意味ではない。
467
467
  - historical live-only `$throughline` context refresh smoke: 同じ VSCode-origin thread `019dfd62-9a9d-7211-bf91-89d8e3fc908e` で `trim --dry-run --host codex --all --json` -> `trim --preflight --host codex --all --json` -> `trim --execute --host codex --all` を実行した。preflight は rollout/app-server turn count `20 / 20` match、execute は `rollbackSent = true`、`injectSent = true`、`injectedItems = 1`、`rollback candidate turns = 20`。直前見積もりは `rollbackEstimatedTokens = 179780`、`injectedMemoryEstimatedTokens = 2009`、`netEstimatedTokens = 177771`、`reductionPct = 99` (`chars / 4` heuristic)。これは live app-server smoke であり、restart-safe durability の証明ではない。
468
468
  - post-refresh confirmation: execute 後の次 user turn で `doctor --codex` は current thread と latest DB session の一致を維持し、latest DB session は `2026-05-06 22:41:10` へ更新された。`trim --dry-run --host codex --all --json` は `activeTurns = 2`、`rollbackEvents = 1`、`rolledBackTurns = 20` を返し、`codex-resume` は rollback 後の短い active work context を L2 として描画した。
469
- - monitor adapter 修正: `throughline monitor` は Claude / Codex host-aware state を読む。Codex Stop hook は `codex:<thread_id>` monitor state を書き、Codex rollout path は Claude transcript 用 `transcriptPath` ではなく `rolloutPath` に保存する。rollout に `event_msg` / `token_count` がある場合は verified usage として表示し、無い場合だけ `estimated: true` / `source = codex-rollout-chars-div-4` の明示 estimate を使う。state filename は URL encode し、`codex:` session id を Windows でも保存可能にした。
469
+ - monitor adapter 修正: `throughline monitor` は Claude / Codex host-aware state を読む。Codex Stop hook は `codex:<thread_id>` monitor state を書き、Codex rollout path は Claude transcript 用 `transcriptPath` ではなく `rolloutPath` に保存する。2026-05-09 以降、monitor は `~/.throughline/state` だけでなく `~/.codex/sessions/**/rollout-*.jsonl` も直接 discovery するため、state 未生成の現在 Codex thread も表示できる。既存 state がある場合は usage snapshot を保持しつつ discovered rollout path / mtime を合流する。rollout に `event_msg` / `token_count` がある場合は verified usage として表示し、無い場合だけ `estimated: true` / `source = codex-rollout-chars-div-4` の明示 estimate を使う。state filename は URL encode し、`codex:` session id を Windows でも保存可能にした。表示 ID は `codex:` prefix を外した raw thread id 先頭 8 桁。
470
470
  - monitor doctor 修正: Codex Stop hook stdout は VSCode chat に必ず見えるとは限らないため、`doctor --codex` に `.vscode/tasks.json` の Throughline Monitor task 診断を追加した。登録済み / 未登録 / JSONC / parse error / broken absolute path と `runOn`、および初回作成後は `Developer: Reload Window` が必要という note を read-only で表示する。
471
- - historical automatic refresh 実装: Codex Stop hook は capture / L1 summarize / monitor state 書き込み後、verified usage が verified context window の `90%` 以上なら automatic refresh を試行する経路を持っていた。2026-05-06 incident 後、この経路は blocker として扱い、monitor state / warning / diagnostics は残しても rollback + inject は送らない。
471
+ - historical automatic refresh 実装: Codex Stop hook は capture / L1 summarize / monitor state 書き込み後、verified usage が verified context window の `90%` 以上なら automatic refresh を試行する経路を持っていた。2026-05-06 incident 後、この経路は blocker として扱い、monitor state / warning / diagnostics は残しても rollback + inject は送らない状態にした。2026-05-08 unblock 後は guarded rollback / inject を再有効化し、2026-05-09 以降は Codex native auto-compact より先に Throughline refresh を走らせるため verified usage `80%` 以上を既定閾値にする。
472
+ - current-session trigger 修正: Codex auto-refresh を token-monitor の描画ループに置かず、Codex `UserPromptSubmit` / `PostToolUse` hooks が当該 session の rollout `token_count` を直接読んで verified 80% 以上なら `$throughline` workflow 実行指示を同じ user turn または tool loop 継続前の `additionalContext` として注入する。monitor は表示専用で、自動発火の判定元にしない。
472
473
 
473
474
  ## Phase 6: Claude Side Finalization
474
475
 
@@ -2,6 +2,9 @@
2
2
 
3
3
  Status: implemented
4
4
  Date: 2026-05-06
5
+ Amended: 2026-05-09 — monitor now also discovers Codex rollouts directly
6
+ from `~/.codex/sessions/**/rollout-*.jsonl`, so Codex visibility no longer
7
+ depends on the Stop hook writing a Throughline state file.
5
8
 
6
9
  この計画は、既存の Claude-primary monitor 経路を置き換えずに、
7
10
  `throughline monitor` へ Codex 対応を追加するためのもの。
@@ -24,6 +27,10 @@ Codex 対応では、既存 monitor contract の周辺に Codex adapter / projec
24
27
  Claude hooks、transcript parsing、slash command、baton、resume behavior は rename / 劣化
25
28
  させない。
26
29
 
30
+ 2026-05-09 以降は、Codex Stop hook が state を書く経路に加えて、
31
+ monitor reader 自体が Codex rollout index を直接 discovery する。これにより、
32
+ host が Stop hook をまだ dispatch していない現在 thread でも monitor に表示される。
33
+
27
34
  ## 非目的
28
35
 
29
36
  - Claude transcript usage parsing を置き換えない。
@@ -39,6 +46,8 @@ Monitor reader:
39
46
 
40
47
  - `throughline monitor` は `src/token-monitor.mjs` に dispatch される。
41
48
  - `~/.throughline/state/` の session state files を読む。
49
+ - Codex については `~/.codex/sessions/**/rollout-*.jsonl` から現在 project の
50
+ rollout candidates も読む。`--all` または `--session` 時は全 project 候補を読む。
42
51
  - 現在の state file は主に次を持つ。
43
52
  `sessionId`, `projectPath`, `transcriptPath`, `pid`, `updatedAt`, optional `usage`
44
53
  - `state.usage` があれば monitor はそれをそのまま表示する。
@@ -50,6 +59,9 @@ Monitor reader:
50
59
  - `pid` は既存 state schema に残っているが、現行 stale 判定は `updatedAt` ベース。
51
60
  Codex Stop hook は短命 process なので、Codex の active 判定に hook process PID を
52
61
  意味づけない。
62
+ - state file が無い Codex rollout candidate は、monitor 内で synthetic state として扱う。
63
+ 既存 state がある場合は、state の `usage` snapshot を保持しつつ discovered
64
+ `rolloutPath` / `updatedAt` を合流する。
53
65
 
54
66
  Claude writer:
55
67
 
@@ -148,6 +160,8 @@ adapter 側に置く。
148
160
  - Claude state + real usage: 既存どおり表示。
149
161
  - Codex state + estimated usage: token bar を表示し、`est` marker を付ける。
150
162
  - Codex state + usage 無し: active session として表示し、token usage は未取得扱い。
163
+ - Codex discovered rollout + state 無し: synthetic Codex state として表示し、live rollout
164
+ usage を読む。表示 ID は `codex:` prefix を外した raw thread id 先頭 8 桁にする。
151
165
 
152
166
  ### 5. VSCode monitor task provision を Codex にも接続する
153
167
 
@@ -181,6 +195,9 @@ Codex Stop hook でも、Claude hooks と同じく
181
195
  - [x] Codex context window が未検証の場合は `contextWindowEstimated: true` を保持する。
182
196
  - [x] `src/cli/codex-hook.mjs` で Codex Stop hook state writing を追加する。
183
197
  - [x] monitor session id は `codex:<thread_id>` にする。
198
+ - [x] monitor が Codex rollout を直接 discovery し、state 未生成の current thread も表示する。
199
+ - [x] discovered rollout と既存 Codex state を merge し、state の usage snapshot を保持する。
200
+ - [x] Codex 表示 ID は `codex:` prefix を外した raw thread id 先頭 8 桁にする。
184
201
  - [x] Codex state の `pid` を active 判定に使わないことを test / docs で固定する。
185
202
  - [x] Codex state では `transcriptPath: null` とし、rollout path は `rolloutPath` に保存する。
186
203
  - [x] Codex Stop hook から `ensureMonitorTaskFile` を呼ぶ。
@@ -203,6 +220,8 @@ Codex Stop hook でも、Claude hooks と同じく
203
220
  ## 受け入れ条件
204
221
 
205
222
  - Codex Stop hook capture 後、`throughline monitor` に現在の Codex session が出る。
223
+ - Codex Stop hook state が無くても、現在 project の Codex rollout があれば
224
+ `throughline monitor` に現在の Codex session が出る。
206
225
  - Claude monitor behavior は既存どおり。
207
226
  - Codex session は Codex と分かる。
208
227
  - Codex token usage が estimate の場合、estimate と分かる。
@@ -372,13 +372,13 @@ Phase 6 result (2026-05-06):
372
372
  - `thread/inject_items` に raw Responses API item `{ type: "message", role: "developer", content: [{ type: "input_text", text: "..." }] }` を渡し、次の `turn/start` で injected memory が model-visible になることを確認した。marker `TL_PHASE6_INJECT_OK` を正しく返した。
373
373
  - その後の Codex primary 実装で、`codex-resume` が描画する active-work developer message も実 Codex host で model-visible になることを確認した。marker `TL_CODEX_VISIBLE_REAL_20260506_C` が `item/agentMessage/delta` に出た。詳細な実測値は [THROUGHLINE_CODEX_FIRST_ROADMAP.md](THROUGHLINE_CODEX_FIRST_ROADMAP.md) の Phase 3 result を正とする。
374
374
  - さらに `thread/inject_items` 後にもう一度 `thread/resume` してから `turn/start` を呼ぶ smoke も追加し、実 Codex host で marker `TL_CODEX_RESUME_AFTER_INJECT_REAL_20260506` が `item/agentMessage/delta` に出ることを確認した。
375
- - Codex host primitive は live app-server 上では実測済み。ただし restart-safe durability は未証明。現在は明示 `--codex-thread-id` または env thread identity と rollout/app-server turn count guard が live mutation の最低条件であり、durable success は別分類で扱う。2026-05-06 incident 後はいったん Codex Stop hook 後の automatic refresh mutation を blocked としたが、2026-05-08 unblock 後は verified usage 90% 以上で guarded rollback / inject を試行する。
375
+ - Codex host primitive は live app-server 上では実測済み。ただし restart-safe durability は未証明。現在は明示 `--codex-thread-id` または env thread identity と rollout/app-server turn count guard が live mutation の最低条件であり、durable success は別分類で扱う。2026-05-06 incident 後はいったん Codex Stop hook 後の automatic refresh mutation を blocked としたが、2026-05-08 unblock 後は guarded rollback / inject を試行する。2026-05-09 以降は Codex native auto-compact より先に Throughline refresh を走らせるため、verified usage 80% 以上を既定閾値にする。
376
376
  - Claude `/rewind conversation only` は手動 UX として扱う。外部ツールからの自動化 surface は未確認。Claude host の automatic rollback / inject は `manual-only`。
377
377
  - Phase 8 では dry-run / preflight を本線にしつつ、Codex だけ guarded execute を追加した。Claude は manual-only のまま扱う。
378
378
 
379
379
  完了条件:
380
380
 
381
- - [x] rollback trim を自動実装してよい host と、手動案内に留める host が判断できる。Codex は 2026-05-08 unblock 後、verified usage 90% 以上の Stop hook auto-refresh と明示 execute を許可する。Claude は manual-only。
381
+ - [x] rollback trim を自動実装してよい host と、手動案内に留める host が判断できる。Codex は 2026-05-08 unblock 後、Stop hook auto-refresh と明示 execute を許可する。2026-05-09 以降の auto-refresh 既定閾値は verified usage 80%。Claude は manual-only。
382
382
 
383
383
  ## Phase 7: Trim Handoff Model
384
384
 
@@ -19,7 +19,7 @@ model-visible input に入ることは controlled smoke で再現していませ
19
19
  run の retained text は risk evidence として残す一方、単独では mutation 前 blocker にしません。
20
20
  Codex current-thread trim は、明示 `--execute`、Throughline DB injectable memory、
21
21
  Codex thread identity、rollout/app-server turn-count guard を条件に実行します。Codex Stop hook
22
- auto-refresh は verified usage 90% 以上で同じ guarded path を試行し、estimate usage では実行しません。
22
+ auto-refresh は verified usage 80% 以上で同じ guarded path を試行し、estimate usage では実行しません。
23
23
 
24
24
  最初のインシデント仮説に対する重要な訂正:
25
25
 
@@ -644,8 +644,13 @@ TODO:
644
644
  という記述を訂正する。
645
645
  - [x] hypothesis を compacted replacement-history restore に言及する形へ更新する。
646
646
  - [x] Codex Rewind-equivalent trim が complete だという roadmap claim を格下げする。
647
- - [x] Codex auto-refresh は verified usage 90% 以上で guarded rollback / inject を
647
+ - [x] Codex auto-refresh は verified usage 80% 以上で guarded rollback / inject を
648
648
  実行する。estimate usage では実行しない。
649
+ - [x] Codex 80% trigger は token-monitor 依存にしない。Codex `UserPromptSubmit`
650
+ / `PostToolUse` hooks が当該 session の rollout `token_count` を直接読み、
651
+ verified 80% 以上なら current session へ `$throughline` workflow 実行指示を
652
+ 注入する。`PostToolUse` により、tool loop 中に閾値を超えた場合も次の継続前に
653
+ 同じ判定を走らせる。
649
654
  - [x] 新セッションが古い「Codex side complete」claim ではなく、この fix plan から
650
655
  再開できるように `CLAUDE.md` を更新する。
651
656
 
@@ -263,7 +263,7 @@ Codex で考えられる流れ:
263
263
  9. ユーザーは同じ Codex thread で続行する。
264
264
  ```
265
265
 
266
- 現行実装では、Codex Stop hook 後の 90% automatic refresh は guarded rollback / inject
266
+ 現行実装では、Codex Stop hook 後の 80% automatic refresh は guarded rollback / inject
267
267
  mutation を試行する。明示 CLI の `throughline trim --execute --host codex --codex-thread-id <id>`
268
268
  も env gate なしで実行する。明示 Codex thread identity、injectable Throughline DB memory、
269
269
  rollout/app-server turn count guard は live mutation の最低条件であり、durable success は
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "throughline",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "type": "module",
5
5
  "description": "Claude Code hooks plugin for structured context compression (/clear-safe persistent memory)",
6
6
  "keywords": [