throughline 0.10.3 → 0.10.6

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +82 -29
  2. package/README.ja.md +79 -47
  3. package/README.md +103 -78
  4. package/bin/throughline.mjs +32 -13
  5. package/docs/00_overview.md +56 -43
  6. package/docs/01_l1_l2_l3_redesign.md +1 -1
  7. package/docs/02_clear_auto_handoff_plan.md +39 -333
  8. package/docs/04_public_release_plan.md +77 -190
  9. package/docs/05_codex_first_roadmap.md +4 -4
  10. package/docs/06_codex_trim_rollback_fix_plan.md +1 -1
  11. package/docs/08_codex_dual_support.md +1 -1
  12. package/docs/09_rollback_context_trim_insight.md +1 -1
  13. package/docs/12_desktop_clear_handoff_plan.md +6 -213
  14. package/docs/15_windows_ci_release_latency_plan.md +6 -87
  15. package/docs/16_readonly_handoff_context_plan.md +7 -38
  16. package/docs/adr/0005-observer-read-pagination.md +1 -1
  17. package/docs/adr/0014-two-phase-handoff-ghost-baton.md +1 -1
  18. package/docs/adr/0019-product-owned-database-migration-acceptance.md +1 -1
  19. package/docs/adr/0021-grok-host-capture.md +1 -1
  20. package/docs/archive/02_clear_auto_handoff_plan.md +350 -0
  21. package/docs/{03_inheritance_on_clear_only.md → archive/03_inheritance_on_clear_only.md} +22 -22
  22. package/docs/{07_codex_trim_implementation_plan.md → archive/07_codex_trim_implementation_plan.md} +8 -8
  23. package/docs/{10_transcript_injection_plan.md → archive/10_transcript_injection_plan.md} +12 -12
  24. package/docs/archive/12_desktop_clear_handoff_plan.md +218 -0
  25. package/docs/{14_observer_completed_turn_feed_plan.md → archive/14_observer_completed_turn_feed_plan.md} +7 -7
  26. package/docs/archive/15_windows_ci_release_latency_plan.md +89 -0
  27. package/docs/archive/16_readonly_handoff_context_plan.md +40 -0
  28. package/docs/archive/README.md +28 -15
  29. package/docs/archive/plan_grok-successor-launch.md +99 -0
  30. package/docs/archive/room-log_throughline_20260830-155052.md +285 -0
  31. package/docs/plan_grok-successor-launch.md +6 -97
  32. package/package.json +11 -4
  33. package/rag/INDEX.md +2 -2
  34. package/src/baton.mjs +11 -9
  35. package/src/cli/handoff-context.test.mjs +36 -0
  36. package/src/cli/help.test.mjs +5 -0
  37. package/src/cli/runtime-errors.mjs +9 -3
  38. package/src/cli/runtime-errors.test.mjs +13 -13
  39. package/src/cli/self-update.mjs +402 -0
  40. package/src/cli/self-update.test.mjs +525 -0
  41. package/src/db.mjs +1 -1
  42. package/src/docs-contract.test.mjs +153 -0
  43. package/src/product-ci-contract.test.mjs +14 -0
  44. package/src/prompt-submit.mjs +8 -10
  45. package/src/resume-context.mjs +4 -4
  46. package/src/runtime-error-hook.test.mjs +4 -6
  47. package/src/runtime-error-store.mjs +40 -18
  48. package/src/runtime-error-store.test.mjs +53 -26
  49. package/src/session-merger.mjs +16 -7
  50. package/src/session-merger.test.mjs +27 -0
  51. package/src/spike-transcript-writer.mjs +1 -1
  52. /package/docs/{11_codex_monitor_implementation_plan.md → archive/11_codex_monitor_implementation_plan.md} +0 -0
  53. /package/docs/{13_native_factory_diagnostics_plan.md → archive/13_native_factory_diagnostics_plan.md} +0 -0
  54. /package/docs/{BUGHUB_RUNTIME_ERROR_STORE_PLAN.md → archive/BUGHUB_RUNTIME_ERROR_STORE_PLAN.md} +0 -0
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src=".github/og.png" alt="Throughline — a whale family carrying direction and memory across changing boundaries" width="100%">
2
+ <img src="https://raw.githubusercontent.com/kitepon/Throughline/main/.github/og.png" alt="Throughline — a whale family carrying direction and memory across changing boundaries" width="100%">
3
3
  <br>
4
4
  <sub><em>This image represents continuity that preserves relationships, direction, and memory even as environments and boundaries change.</em></sub>
5
5
  </p>
@@ -9,7 +9,7 @@
9
9
  [![npm version](https://img.shields.io/npm/v/throughline.svg?color=cb3837&logo=npm)](https://www.npmjs.com/package/throughline)
10
10
  [![license](https://img.shields.io/npm/l/throughline.svg?color=blue)](LICENSE)
11
11
  [![node](https://img.shields.io/node/v/throughline.svg?color=339933&logo=node.js&logoColor=white)](https://nodejs.org)
12
- [![CI](https://github.com/kitepon-rgb/Throughline/actions/workflows/test.yml/badge.svg)](https://github.com/kitepon-rgb/Throughline/actions/workflows/test.yml)
12
+ [![CI](https://github.com/kitepon/Throughline/actions/workflows/test.yml/badge.svg)](https://github.com/kitepon/Throughline/actions/workflows/test.yml)
13
13
 
14
14
  **English** · [日本語](README.ja.md)
15
15
 
@@ -20,10 +20,12 @@ Built and maintained by [Quo](https://x.com/QLyun35332) at [kitepon.dev](https:/
20
20
 
21
21
  ## Ownership boundary
22
22
 
23
- This repository owns the database, migrations, capture contracts, release, and
24
- diagnostics. Cross-product installation and host integration are handled by
25
- [dotagents](https://github.com/kitepon-rgb/dotagents), the internal development
26
- toolchain behind kitepon.dev's products.
23
+ This repository owns installation, configuration, state, schema and migrations,
24
+ diagnostics, recovery, updates, and release decisions. Throughline works on its
25
+ own through the documented CLI and does not require a factory controller.
26
+ [dotagents](https://github.com/kitepon/dotagents) may wire Throughline into the
27
+ kitepon.dev development factory, but it integrates the product rather than
28
+ owning its state or controlling its lifecycle.
27
29
  MarkItDown is a separately managed third-party CLI.
28
30
 
29
31
  ## In 30 seconds
@@ -34,10 +36,11 @@ throughline install # registers hooks/skills and provisions the VS Code moni
34
36
  ```
35
37
 
36
38
  That's it. Open any Claude Code session and your turns flow into
37
- `~/.throughline/throughline.db` automatically. After 50 turns of work, just
38
- type `/clear` — the new session resumes mid-thought instead of starting from
39
- zero. (For non-`/clear` boundaries such as a brand-new chat or a VSCode
40
- restart, type `/tl` first to mark the predecessor.)
39
+ `~/.throughline/throughline.db` automatically. In VS Code, `/clear` resumes
40
+ through the `SessionStart source='clear'` auto path. Claude Desktop does not
41
+ emit that source, so type `/tl` before `/clear` there. Use `/tl` before any
42
+ other boundary, such as a brand-new chat or a VS Code restart, when you want
43
+ to name the predecessor exactly.
41
44
 
42
45
  Grok Desktop is also a first-class host. `throughline install` writes
43
46
  `~/.grok/hooks/throughline.json`. On Grok, `/tl` does not inject into the
@@ -114,7 +117,7 @@ one or two turns, then `/tl`.
114
117
  | **Memory after the boundary** | ✅ recent turns verbatim (whole, budget-packed) + everything older via `recall` pull + L3 on demand | ❌ zero | △ lossy single summary | △ lossy summary |
115
118
  | **Tool I/O handling** | retired to L3, retrievable by `/sc-detail HH:MM:SS` | gone | folded into summary, unreadable | folded into summary |
116
119
  | **Coding-assistant fit** | high — tool I/O is the heavy 80% | low — you lose the thread | medium — but irreversible | medium |
117
- | **Auto-inheritance risk** | low (typed `/clear` / `/tl` names the predecessor) | n/a | n/a | high |
120
+ | **Auto-inheritance risk** | low (`/tl` names the predecessor; VS Code `/clear` freezes one transcript-backed candidate) | n/a | n/a | high |
118
121
  | **Runtime deps** | **zero** (Node 22.13+ built-in `node:sqlite`) | n/a | n/a | many |
119
122
  | **Multi-session token monitor** | ✅ real `message.usage` / Codex rollout `token_count` | — | — | — |
120
123
 
@@ -231,18 +234,19 @@ of tool inputs, tool outputs, and hook output captured at L3 for that turn.
231
234
 
232
235
  ---
233
236
 
234
- ## Inheritance: typed `/clear` and `/tl` write a baton, source-`clear` is the fallback
237
+ ## Inheritance: `/tl` writes a baton; VS Code `/clear` uses `source='clear'`
235
238
 
236
- Throughline 0.4.1+ supports two inheritance paths. The **baton path is the
237
- primary route**; the source-`clear` auto path is the fallback for cases where
238
- the user's `/clear` does not reach the `UserPromptSubmit` hook (for example
239
- the VSCode extension's menu-driven `/clear`).
239
+ Throughline supports two inheritance paths. A `/tl` baton names one predecessor
240
+ exactly. If no eligible baton exists, the VS Code `/clear` path can use the
241
+ `SessionStart source='clear'` signal to freeze one transcript-backed predecessor.
242
+ The baton is checked first.
240
243
 
241
244
  ```mermaid
242
245
  flowchart LR
243
- U["User types<br/>/clear or /tl"] -->|UserPromptSubmit| W["writeBaton<br/>(session_id + TTL 1h)"]
246
+ U["User types<br/>/tl"] -->|UserPromptSubmit| W["writeBaton<br/>(session_id + TTL 1h)"]
244
247
  W --> B[("handoff_batons<br/>SQLite")]
245
- M["VSCode menu<br/>clear"] -->|no UserPromptSubmit| X["no baton"]
248
+ M["VS Code<br/>/clear"] -->|SessionStart source='clear'| X["freeze predecessor<br/>no baton"]
249
+ D["Claude Desktop<br/>/clear"] -->|source='startup'| N["no automatic handoff<br/>use /tl first"]
246
250
  NS["Next SessionStart<br/>(registers intent only)"] --> FP["First user prompt<br/>(proof the session is real)"]
247
251
  FP --> C{"baton<br/>present?"}
248
252
  B -.-> C
@@ -261,10 +265,10 @@ flowchart LR
261
265
  class P3,INJ neutral
262
266
  ```
263
267
 
264
- ### baton path (primary): typed `/clear` or `/tl` → deterministic inheritance
268
+ ### baton path: `/tl` → deterministic inheritance
265
269
 
266
- When the user types `/clear` or `/tl` in the prompt, the `UserPromptSubmit`
267
- hook writes a handoff baton with **that session's `session_id`** into the
270
+ When the user types `/tl`, the `UserPromptSubmit` hook writes a handoff baton
271
+ with **that session's `session_id`** into the
268
272
  `handoff_batons` table. The next new session consumes the baton **at its
269
273
  first user prompt** (eligibility: the session must have been born within the
270
274
  1-hour TTL after the baton was written) and merges that exact predecessor's
@@ -281,28 +285,29 @@ started empty. Deferring consumption to the first user prompt closes this:
281
285
  a ghost never submits a prompt, so it can never take the baton (ADR 0014).
282
286
 
283
287
  This path is deterministic: it names the predecessor by id rather than
284
- guessing, so multi-window scenarios where "most recently updated session"
285
- does not equal "the session you just `/clear`-ed" still inherit correctly.
288
+ guessing, so it is the explicit path for multi-window work and for hosts that
289
+ do not emit `source='clear'`.
286
290
 
287
291
  ```
288
- typed /clear: Session A → /clear → Session B (consumes A's baton, merges A)
289
- typed /tl: Session A → /tl → (new chat / restart) → Session B (consumes baton, merges A)
292
+ /tl: Session A → /tl → (/clear, new chat, or restart) → Session B (consumes A's baton)
290
293
  ```
291
294
 
292
- ### auto path (fallback): `source='clear'` → heuristic inheritance
295
+ ### auto path: VS Code `source='clear'` → frozen predecessor
293
296
 
294
- Since Claude Code 2.1.128, the SessionStart hook receives `source='clear'`
295
- reliably after `/clear`. When no baton is present (for example because the
296
- `/clear` was triggered by the VSCode extension's menu and never reached
297
- `UserPromptSubmit`), Throughline resolves the most recent unmerged session
297
+ The built-in `/clear` command does **not** reach `UserPromptSubmit` on the
298
+ tested Claude Code clients. VS Code instead sends `SessionStart source='clear'`.
299
+ When no baton is present, Throughline resolves the most recent unmerged session
298
300
  for the same project **at `SessionStart` time** (freezing that choice, and
299
301
  skipping candidates that have no transcript — i.e. ghosts) and performs the
300
302
  merge + injection at the session's first user prompt.
301
303
 
302
304
  Set `THROUGHLINE_DISABLE_AUTO_HANDOFF=1` in your environment to opt out of
303
- this fallback. **The env var only affects the fallback**; typed `/clear` and
304
- `/tl` still write a baton and inherit because the user explicitly signalled
305
- "continue this work".
305
+ this path. The env var does not disable explicit `/tl` batons.
306
+
307
+ Claude Desktop neither forwards built-in `/clear` to `UserPromptSubmit` nor
308
+ emits `SessionStart source='clear'`; use `/tl` before `/clear` there. The
309
+ cross-client measurements and upstream report are recorded in the archived
310
+ [`docs/12_desktop_clear_handoff_plan.md`](docs/archive/12_desktop_clear_handoff_plan.md).
306
311
 
307
312
  ### What gets injected
308
313
 
@@ -335,7 +340,8 @@ pinning the latest exchange at the top of the injection prevents that drift.
335
340
  Each merged row keeps its `origin_session_id`, so repeated handoffs
336
341
  accumulate memory through chains:
337
342
 
338
- ```
343
+ ```text
344
+ VS Code:
339
345
  S1 (4 turns) --/clear--> S2 (auto-merges S1, adds 3 turns) --/clear--> S3 (auto-merges S2, adds 5 turns)
340
346
  origin=S1×4 origin=S1×4, S2×3, S3×5
341
347
  ```
@@ -454,9 +460,10 @@ rollout text, not an exact host tokenizer measurement. If rollback candidate
454
460
  turns are `0`, there is no current trim saving under the active keep-recent
455
461
  setting.
456
462
 
457
- Claude-side rewind UI itself is not driven by Throughline. The auto-handoff
458
- flow is `/clear` → new session → automatic injection of curated memory at the
459
- session's first user prompt.
463
+ Claude-side rewind UI itself is not driven by Throughline. In VS Code, the
464
+ auto-handoff flow is `/clear` → new session → automatic injection of curated
465
+ memory at the session's first user prompt. Claude Desktop requires `/tl`
466
+ before `/clear`.
460
467
  Throughline does not invoke `/rewind` or any Claude Code internal command.
461
468
 
462
469
  Codex-primary setup has an installed Stop hook after global
@@ -810,18 +817,23 @@ entry to the `tasks` array yourself:
810
817
 
811
818
  ## Commands
812
819
 
813
- **v0.9.0 was published on 2026-08-04.** It adds the versioned, read-only
814
- `handoff-context` boundary for local launchers. The command opens only an
815
- existing database and leaves baton state, session ownership, and memory rows
816
- unchanged. Existing factory diagnostics, Observer, runtime-error, capture, and
817
- normal handoff behavior remain available under the same explicit-failure and
818
- local-only contracts.
820
+ **The current release is v0.10.6.** Throughline supports Claude Code, Codex,
821
+ Grok, and Cursor as documented host adapters. The versioned, read-only
822
+ `handoff-context` boundary opens only an existing database and leaves baton
823
+ state, session ownership, and memory rows unchanged. Factory diagnostics,
824
+ Observer, runtime-error, capture, and normal handoff behavior remain available
825
+ under the same explicit-failure and local-only contracts.
819
826
 
820
827
  | Command | What it does |
821
828
  | ---------------------------------------------- | ------------------------------------------------------------ |
822
829
  | `throughline install` | Register Claude user hooks/slash commands, the global Codex UserPromptSubmit/PostToolUse/Stop hooks, the global `$throughline` Codex skill, `~/.grok/hooks/throughline.json`, and the current VS Code monitor task when applicable |
823
830
  | `throughline install --project` | Register Claude hooks/slash commands in this repo only |
831
+ | `throughline self-update [--json]` | Update the official npm package, verify that public PATH resolves to that new CLI/version, reapply product-owned integrations, migrate an existing database, and verify public diagnostics in one call |
824
832
  | `throughline uninstall` | Remove Throughline-managed Claude hooks/slash commands, only the Throughline-managed Codex hook, and the `$throughline` Codex skill |
833
+
834
+ Versions before v0.10.5 do not contain `self-update`. Upgrade those versions
835
+ once with `npm install --global throughline@latest`, then run
836
+ `throughline self-update`. Later updates use `throughline self-update` alone.
825
837
  | `throughline monitor [--all] [--session <id>]` | Run the multi-session token monitor |
826
838
  | `throughline monitor --diag` | Dump TTY/columns/env diagnostics (for debugging monitor render bugs) |
827
839
  | `throughline detail <time>` | Retrieve L2 body text and L3 tool I/O for a turn (see below) |
@@ -834,7 +846,9 @@ local-only contracts.
834
846
  | `throughline doctor --codex` | Diagnose Codex primary entry state, captured DB sessions, context-refresh memory contract, new-thread handoff readiness, safe continuation status, and host primitive audit |
835
847
  | `throughline factory-diagnostics --json` | Versioned read-only native factory readiness JSON for database schema/migration, connector hooks, and representative capture/restore/handoff; does not emit bodies, secrets, absolute paths, or raw state |
836
848
  | `throughline migrate --json` | Migrate only an existing Throughline database to the current schema and emit a versioned bounded result; a missing database is not created, while future schemas and migration failures exit non-zero |
837
- | `throughline runtime-errors snapshot --json` | Read the bounded product-owned runtime error aggregate. Collection occurs only when canonical dotagents config explicitly sets `collection.enabled: true`; this command performs no network I/O |
849
+ | `throughline runtime-errors enable --json` | Enable product-owned local runtime error collection in Throughline's own config; default is disabled |
850
+ | `throughline runtime-errors disable --json` | Disable product-owned local runtime error collection |
851
+ | `throughline runtime-errors snapshot --json` | Read the bounded product-owned runtime error aggregate; this command performs no network I/O |
838
852
  | `throughline runtime-errors diagnostics --json` | Read bounded collection/store status without exposing the state path or raw errors |
839
853
  | `throughline runtime-errors ack <cursor> --json` | Explicitly acknowledge records through a monotonic cursor; unacknowledged records are never compacted |
840
854
  | `throughline runtime-errors resolve <fingerprint> --json` | Explicitly resolve an aggregate; observing the same fingerprint again reopens it |
@@ -865,6 +879,24 @@ local-only contracts.
865
879
  | `throughline status` | Print DB statistics (sessions, skeletons, bodies, details) |
866
880
  | `throughline --version` | Print the installed version |
867
881
 
882
+ ### Product-owned runtime error collection
883
+
884
+ Collection is off by default. Enable it through Throughline's own CLI:
885
+
886
+ ```bash
887
+ throughline runtime-errors enable --json
888
+ throughline runtime-errors diagnostics --json
889
+ ```
890
+
891
+ The product-owned config is
892
+ `$XDG_CONFIG_HOME/throughline/runtime-errors.config.json` on macOS/Linux
893
+ (`~/.config/throughline/...` when `XDG_CONFIG_HOME` is unset) and
894
+ `%LOCALAPPDATA%\throughline\runtime-errors.config.json` on Windows. The CLI
895
+ writes the versioned `throughline.runtime_error_config.v1` shape with private
896
+ permissions. `disable --json` changes only this product config. Throughline
897
+ does not read dotagents configuration; factory integration consumes the public
898
+ `runtime-errors ... --json` contract.
899
+
868
900
  ### Read-only handoff context for local launchers
869
901
 
870
902
  Use this boundary when a local launcher needs Throughline memory without
@@ -886,21 +918,19 @@ Slash commands (invoked by the user in Claude Code):
886
918
 
887
919
  | Command | What it does |
888
920
  | ------------- | ----------------------------------------------------------------- |
889
- | `/tl` | Write a handoff baton (explicit inheritance signal across non-`/clear` boundaries new chat / VSCode restart). On Grok, also launches `grok-continue` after a successful baton write |
890
- | `/clear` | Built-in Claude Code reset. Throughline's `UserPromptSubmit` hook also writes a baton so the next session inherits the cleared session's memory |
921
+ | `/tl` | Write a handoff baton that names the predecessor exactly (use before a new chat, restart, or Claude Desktop `/clear`). On Grok, also launches `grok-continue` after a successful baton write |
922
+ | `/clear` | Built-in Claude Code reset. VS Code can auto-inherit through `SessionStart source='clear'`; Claude Desktop requires `/tl` first |
891
923
  | `/sc-detail <time>` | Retrieve L2 body text and L3 tool I/O for a past turn |
892
924
 
893
- > Since v0.4.1, both `/clear` and `/tl` typed in the prompt write a baton
894
- > identifying the current session, so the next new session deterministically
895
- > inherits that exact predecessor (merge + injection happen at that session's
896
- > first user prompt — see ADR 0014). The `source='clear'` auto path remains as a
897
- > fallback for `/clear` triggered outside `UserPromptSubmit` (for example via
898
- > the VSCode extension menu); `THROUGHLINE_DISABLE_AUTO_HANDOFF=1` only opts
899
- > out of that fallback.
925
+ > Built-in `/clear` does not reach the tested clients' `UserPromptSubmit` hook.
926
+ > `/tl` is the deterministic baton path. VS Code `/clear` uses the separate
927
+ > `source='clear'` auto path; `THROUGHLINE_DISABLE_AUTO_HANDOFF=1` disables only
928
+ > that auto path.
900
929
 
901
930
  Hook subcommands (invoked by Claude Code, not by humans):
902
931
  `session-start` (SessionStart), `process-turn` (Stop),
903
- `prompt-submit` (UserPromptSubmit — detects `/tl` and `/clear` and writes a baton; Grok `/tl` also launches `grok-continue`).
932
+ `prompt-submit` (UserPromptSubmit — executes pending handoff and writes `/tl`
933
+ batons; Grok `/tl` also launches `grok-continue`).
904
934
 
905
935
  ### Observer completed-turn feed (development)
906
936
 
@@ -998,13 +1028,13 @@ plain `.mjs` files.
998
1028
  └── <session_id>.json Per-session activity state for the monitor
999
1029
  ```
1000
1030
 
1001
- Schema v8:
1031
+ Schema v9:
1002
1032
 
1003
1033
  - `sessions` — one row per `session_id`, with `project_path` and `merged_into`
1004
1034
  - `skeletons` — L1 one-liners, keyed by `(session_id, origin_session_id, turn, role)`
1005
1035
  - `bodies` — L2 verbatim text (user + assistant), same key shape
1006
1036
  - `details` — L3 records with `kind` column (`tool_input` / `tool_output` / `system` / `image` / `thinking`) and `source_id` for idempotent re-processing
1007
- - `handoff_batons` — one row per `project_path`, with `session_id` and `created_at`. Written by the `UserPromptSubmit` hook when the user types `/tl` or `/clear`. Consumed and deleted at the next new session's **first user prompt**, if that session was born within the 1-hour TTL. (v8 dropped the `memo_text` column when memo was retired in v0.4.0.)
1037
+ - `handoff_batons` — one row per `project_path`, with `session_id` and `created_at`. Written by the `UserPromptSubmit` hook for `/tl`. A compatibility `/clear` branch remains in the hook, but tested built-in `/clear` commands are not forwarded to it. The next new session consumes and deletes an eligible baton at its **first user prompt**, if it was born within the 1-hour TTL. (v8 dropped the `memo_text` column when memo was retired in v0.4.0.)
1008
1038
  - `pending_handoffs` — one row per newborn session (`session_id` PK, `project_path`, `source`, `auto_predecessor_id`, `created_at`). Registered by `SessionStart`, consumed exactly once by the session's first `UserPromptSubmit`. Rows belonging to ghost sessions are never consumed and stay behind harmlessly (a few hundred bytes each). Added in v9 (ADR 0014).
1009
1039
  - `injection_log` — audit trail of injection events
1010
1040
 
@@ -1161,23 +1191,21 @@ and `~/.throughline/state/*.json`. A fresh database with schema v9 is created on
1161
1191
  the next hook fire.
1162
1192
 
1163
1193
  **New session didn't inherit memory from the previous one**
1164
- Since v0.4.1, both typed `/clear` and `/tl` write a baton, and the auto path
1165
- falls back on `source='clear'` for menu-driven `/clear`. If inheritance still
1166
- did not happen, the most likely cause is one of: (a) the previous session was
1167
- never recorded (no Stop hook fired — check `throughline status`), (b) the
1168
- 1-hour baton TTL expired before the new session opened, (c) the new session's
1169
- `project_path` (cwd) differs from the previous one, so they live in different
1170
- session chains, or (d) you set `THROUGHLINE_DISABLE_AUTO_HANDOFF=1` and the
1171
- `/clear` came from the VSCode menu which never reaches `UserPromptSubmit`.
1172
- Memory is still in SQLite — you can retrieve specific turns with
1173
- `/sc-detail <time>`.
1194
+ Use `/tl` before the boundary when you need deterministic inheritance. VS Code
1195
+ `/clear` can also use the `source='clear'` auto path; Claude Desktop cannot, so
1196
+ it requires `/tl` before `/clear`. Other likely causes are: (a) the previous
1197
+ session was never recorded (no Stop hook fired — check `throughline status`),
1198
+ (b) the 1-hour baton TTL expired before the new session opened, (c) the new
1199
+ session's `project_path` (cwd) differs from the previous one, or (d)
1200
+ `THROUGHLINE_DISABLE_AUTO_HANDOFF=1` disabled the VS Code auto path. Memory is
1201
+ still in SQLite retrieve specific turns with `/sc-detail <time>`.
1174
1202
 
1175
1203
  ---
1176
1204
 
1177
1205
  ## Development
1178
1206
 
1179
1207
  ```bash
1180
- git clone https://github.com/kitepon-rgb/Throughline.git
1208
+ git clone https://github.com/kitepon/Throughline.git
1181
1209
  cd Throughline
1182
1210
  npm link # Put `throughline` on PATH (dev only)
1183
1211
  throughline install --project # Register hooks for this repo only
@@ -1203,9 +1231,8 @@ the first generation to pick up the auto-start task.
1203
1231
  - [`docs/01_l1_l2_l3_redesign.md`](docs/01_l1_l2_l3_redesign.md) — **core design
1204
1232
  spec** for the L1/L2/L3 differential layer model (schema v4 base + v5 L3
1205
1233
  classification extension). Authoritative for the memory layering rules.
1206
- - [`docs/03_inheritance_on_clear_only.md`](docs/03_inheritance_on_clear_only.md) —
1207
- design record for the `/tl` baton handoff system (schema v6–v7). Explains
1208
- why the current inheritance is opt-in rather than heuristic.
1234
+ - [`docs/02_clear_auto_handoff_plan.md`](docs/02_clear_auto_handoff_plan.md) —
1235
+ current `/clear` and `/tl` handoff contract.
1209
1236
  - [`docs/08_codex_dual_support.md`](docs/08_codex_dual_support.md) —
1210
1237
  architecture brief for adding Codex support without replacing the Claude
1211
1238
  Code hook/slash-command path.
@@ -1215,17 +1242,15 @@ the first generation to pick up the auto-start task.
1215
1242
  - [`docs/05_codex_first_roadmap.md`](docs/05_codex_first_roadmap.md) —
1216
1243
  current next-phase TODO plan: Codex primary first, Codex rewind-compatible
1217
1244
  trim next, Claude rewind finalization after that.
1218
- - [`docs/07_codex_trim_implementation_plan.md`](docs/07_codex_trim_implementation_plan.md) —
1219
- historical integrated TODO plan and implementation record for Claude/Codex
1220
- dual support and rollback trim.
1221
1245
  - [`docs/04_public_release_plan.md`](docs/04_public_release_plan.md) — public
1222
1246
  release plan, implementation status by version, § 0 fallback rule, and
1223
1247
  remaining tasks.
1224
- - [`docs/15_windows_ci_release_latency_plan.md`](docs/15_windows_ci_release_latency_plan.md) —
1225
- Windows CI performance gate and the ACL-preserving release workflow.
1226
- - [`docs/archive/`](docs/archive/) — superseded design documents kept for
1227
- historical reference (original CONCEPT, session-linking experiments,
1228
- pre-publish action list).
1248
+ - [`docs/archive/12_desktop_clear_handoff_plan.md`](docs/archive/12_desktop_clear_handoff_plan.md) —
1249
+ historical Claude Desktop measurements, NO-GO decision, and backfill acceptance.
1250
+ - [`docs/00_overview.md`](docs/00_overview.md) — current/history/evidence map and
1251
+ document lifecycle rules.
1252
+ - [`docs/archive/`](docs/archive/) — completed plans and superseded designs,
1253
+ kept only for historical reference.
1229
1254
 
1230
1255
  ---
1231
1256
 
@@ -16,10 +16,12 @@
16
16
  * throughline auditor-context --json # Read-only bounded auditor context JSON
17
17
  * throughline factory-diagnostics --json # Native factory read-only readiness JSON
18
18
  * throughline migrate --json # Migrate the existing Throughline database only
19
- * throughline runtime-errors snapshot --json # Product-owned runtime error aggregates
19
+ * throughline self-update # Update package, integrations, database, and verify the result
20
+ * throughline runtime-errors enable --json # Enable product-owned runtime error collection
21
+ * throughline runtime-errors snapshot --json # Read product-owned runtime error aggregates
20
22
  * throughline codex-capture # Capture active Codex rollout turns into Throughline DB
21
- * throughline codex-hook user-prompt-submit # Codex current-session auto-refresh prompt hook
22
- * throughline codex-hook post-tool-use # Codex current-session auto-refresh tool-loop hook
23
+ * throughline codex-hook user-prompt-submit # Codex rollout capture + monitor state hook
24
+ * throughline codex-hook post-tool-use # Codex tool-loop capture + monitor state hook
23
25
  * throughline codex-hook stop # Codex native Stop hook (capture + L1 summarize)
24
26
  * throughline codex-summarize # Summarize captured Codex L2 turns into L1 via Codex CLI
25
27
  * throughline codex-resume # Render Codex active-work context from DB
@@ -113,6 +115,11 @@ switch (cmd) {
113
115
  if (exitCode !== 0) process.exitCode = exitCode;
114
116
  break;
115
117
  }
118
+ case 'self-update': {
119
+ const exitCode = (await import('../src/cli/self-update.mjs')).run(rest);
120
+ if (exitCode !== 0) process.exitCode = exitCode;
121
+ break;
122
+ }
116
123
  case 'runtime-errors': {
117
124
  const exitCode = (await import('../src/cli/runtime-errors.mjs')).run(rest);
118
125
  if (exitCode !== 0) process.exitCode = exitCode;
@@ -186,6 +193,15 @@ switch (cmd) {
186
193
  console.log(pkg.version);
187
194
  break;
188
195
  }
196
+ case '--self-update-identity': {
197
+ if (rest.length > 0) {
198
+ process.exitCode = 2;
199
+ break;
200
+ }
201
+ const { buildSelfUpdateIdentity } = await import('../src/cli/self-update.mjs');
202
+ console.log(JSON.stringify(buildSelfUpdateIdentity()));
203
+ break;
204
+ }
189
205
  default:
190
206
  await showHelp();
191
207
  }
@@ -235,22 +251,25 @@ Usage:
235
251
  session/prompt bodies, secrets, absolute paths, or raw state
236
252
  throughline migrate --json Migrate the existing Throughline database only.
237
253
  Does not create a missing database and emits a versioned JSON result
238
- throughline runtime-errors snapshot --json
239
- Read bounded local runtime error aggregates. Also supports
240
- diagnostics, ack <cursor>, resolve <fingerprint>, and compact
254
+ throughline self-update [--json]
255
+ Update the official npm package, reapply product-owned
256
+ integrations, migrate an existing database, and verify
257
+ the installed version and public diagnostics in one call
258
+ throughline runtime-errors enable --json
259
+ Enable product-owned local runtime error collection.
260
+ Also supports disable, snapshot, diagnostics, ack <cursor>,
261
+ resolve <fingerprint>, reopen <fingerprint>, and compact
241
262
  throughline codex-capture Capture active Codex rollout turns into DB
242
263
  (requires --codex-thread-id or env thread id)
243
264
  throughline codex-hook user-prompt-submit
244
- Codex UserPromptSubmit hook: capture rollout and,
245
- at 75%, inject current-session $throughline
246
- instruction from verified rollout token_count
265
+ Codex UserPromptSubmit hook: capture rollout and
266
+ write monitor state; automatic refresh is disabled
247
267
  throughline codex-hook post-tool-use
248
268
  Codex PostToolUse hook: during tool loops, capture
249
- rollout and inject the same 75% $throughline
250
- instruction from verified rollout token_count
269
+ rollout and write monitor state; no instruction injection
251
270
  throughline codex-hook stop Codex native Stop hook: capture rollout,
252
- summarize old L2 turns into L1, and run guarded
253
- auto-refresh when verified usage reaches 75%
271
+ summarize old L2 turns into L1, and write monitor state;
272
+ automatic current-thread refresh is disabled
254
273
  throughline codex-summarize Summarize captured Codex L2 into L1 via Codex CLI
255
274
  (requires a codex:<thread-id> session)
256
275
  throughline codex-resume Render Codex active-work context from DB
@@ -1,59 +1,72 @@
1
1
  # Throughline Documentation Overview
2
2
 
3
- このディレクトリは Throughline の設計・計画・監査記録の入口です。実装判断は常に source を正とし、文書は現行実装へ追従させます。
3
+ Throughline の文書は、現行契約・履歴・証拠を分ける。通常作業で読むのはこのページの
4
+ 「現行契約」だけであり、完了済み計画を無意識に読み込ませない。
4
5
 
5
- ## Canonical Docs
6
+ ## 現行契約
6
7
 
7
8
  | 文書 | 役割 |
8
9
  |---|---|
9
- | [01_l1_l2_l3_redesign.md](01_l1_l2_l3_redesign.md) | L1/L2/L3 記憶レイヤーの設計記録 |
10
- | [02_clear_auto_handoff_plan.md](02_clear_auto_handoff_plan.md) | `/clear` / `/tl` handoff の現行仕様と計画 |
11
- | [03_inheritance_on_clear_only.md](03_inheritance_on_clear_only.md) | 2026-04 段階の継承方式検証履歴 |
12
- | [04_public_release_plan.md](04_public_release_plan.md) | 公開配布化、フォールバック禁止、リリース状態 |
13
- | [05_codex_first_roadmap.md](05_codex_first_roadmap.md) | Codex primary / trim / Claude finalization の実装順 |
14
- | [06_codex_trim_rollback_fix_plan.md](06_codex_trim_rollback_fix_plan.md) | Codex rollback / inject incident 後の修正計画 |
15
- | [07_codex_trim_implementation_plan.md](07_codex_trim_implementation_plan.md) | Codex 両対応 + rollback trim の旧統合計画と実装履歴 |
16
- | [08_codex_dual_support.md](08_codex_dual_support.md) | Claude primary を維持した Codex adapter 方針 |
17
- | [09_rollback_context_trim_insight.md](09_rollback_context_trim_insight.md) | rollback context delete primitive と見る設計メモ |
18
- | [10_transcript_injection_plan.md](10_transcript_injection_plan.md) | transcript injection 検証計画と v0.5 実機結果 |
19
- | [11_codex_monitor_implementation_plan.md](11_codex_monitor_implementation_plan.md) | Codex monitor 対応の実装記録 |
20
- | [13_native_factory_diagnostics_plan.md](13_native_factory_diagnostics_plan.md) | native factory read-only readiness 診断の実装記録 |
21
- | [14_observer_completed_turn_feed_plan.md](14_observer_completed_turn_feed_plan.md) | Observer向けcompleted-only read / wait CLIの完了済み設計・受入記録。v0.7.0で公開済み |
22
- | [15_windows_ci_release_latency_plan.md](15_windows_ci_release_latency_plan.md) | Windows CI 18分の原因、ACL安全網を維持した短縮、release gateの受入条件 |
23
- | [16_readonly_handoff_context_plan.md](16_readonly_handoff_context_plan.md) | DB所有権を変更せずSessionStartと同じ記憶を返す、ローカルランチャー向けread-only I/F。v0.9.0で公開済み |
24
- | [plan_grok-successor-launch.md](plan_grok-successor-launch.md) | Grok `/tl` 後の後継席起動。v0.10.0で公開済み。正本は本ファイルと [ADR 0021](adr/0021-grok-host-capture.md) |
25
- | [BUGHUB_RUNTIME_ERROR_STORE_PLAN.md](BUGHUB_RUNTIME_ERROR_STORE_PLAN.md) | local runtime error aggregate store の契約と実装 TODO |
26
-
27
- ## Supporting Records
10
+ | [../README.md](../README.md) / [../README.ja.md](../README.ja.md) | 利用者向けの導入、設定、コマンド、状態、診断、復旧、更新 |
11
+ | [CLAUDE.md](https://github.com/kitepon/Throughline/blob/main/CLAUDE.md) | Claude Code 作業者向けの製品正本 |
12
+ | [AGENTS.md](https://github.com/kitepon/Throughline/blob/main/AGENTS.md) | Codex など Claude Code 以外の作業者向け入口 |
13
+ | [01_l1_l2_l3_redesign.md](01_l1_l2_l3_redesign.md) | L1/L2/L3 記憶レイヤーの設計 |
14
+ | [02_clear_auto_handoff_plan.md](02_clear_auto_handoff_plan.md) | `/clear` / `/tl` handoff の現行仕様 |
15
+ | [04_public_release_plan.md](04_public_release_plan.md) | 公開配布、明示的失敗、release gate |
16
+ | [05_codex_first_roadmap.md](05_codex_first_roadmap.md) | Codex primary / trim / Claude finalization の現行順序 |
17
+ | [06_codex_trim_rollback_fix_plan.md](06_codex_trim_rollback_fix_plan.md) | Codex rollback / inject incident 後の現行判断 |
18
+ | [08_codex_dual_support.md](08_codex_dual_support.md) | Claude primary を維持する Codex adapter 方針 |
19
+ | [09_rollback_context_trim_insight.md](09_rollback_context_trim_insight.md) | rollback context delete primitive と見る設計 |
20
+ | [adr/](adr/) | 現行実装が依拠する不変の設計判断 |
21
+
22
+ 特に現行 host 契約は [ADR 0021](adr/0021-grok-host-capture.md)
23
+ [ADR 0022](adr/0022-cursor-host-capture.md)、二相 handoff schema v9
24
+ [ADR 0014](adr/0014-two-phase-handoff-ghost-baton.md)、製品所有 migration
25
+ [ADR 0018](adr/0018-product-owned-database-migration.md) を正とする。
26
+
27
+ ## 固定参照の互換入口
28
+
29
+ 次の短い文書は現行契約の正本ではない。旧pathを固定した計画・証拠・公開URLから、
30
+ archiveと現行正本へ案内するためだけに残す。
31
+
32
+ | 互換入口 | 現行正本 |
33
+ |---|---|
34
+ | [12_desktop_clear_handoff_plan.md](12_desktop_clear_handoff_plan.md) | [02_clear_auto_handoff_plan.md](02_clear_auto_handoff_plan.md) |
35
+ | [15_windows_ci_release_latency_plan.md](15_windows_ci_release_latency_plan.md) | [04_public_release_plan.md](04_public_release_plan.md) / [ADR 0020](adr/0020-windows-ci-release-latency.md) |
36
+ | [16_readonly_handoff_context_plan.md](16_readonly_handoff_context_plan.md) | [README.md](../README.md) / [公開JSON例](throughline-handoff-context.example.json) |
37
+ | [plan_grok-successor-launch.md](plan_grok-successor-launch.md) | [ADR 0021](adr/0021-grok-host-capture.md) / [README.md](../README.md) |
38
+
39
+ ## 履歴
28
40
 
29
41
  | 場所 | 役割 |
30
42
  |---|---|
31
- | [adr/](adr/) | 根幹の設計判断 |
43
+ | [archive/](archive/) | 完了済み計画、置換済み設計、過去の実装・受入記録。通常は読まない |
32
44
  | [audit-2026-05/](audit-2026-05/) | 2026-05 の監査・インシデント記録 |
33
- | [archive/](archive/) | 破棄または履歴扱いの旧設計 |
34
- | [../rag/INDEX.md](../rag/INDEX.md) | 外部仕様・調査の再利用棚 |
45
+ | [adr/](adr/) | 判断時点の背景も保持する設計判断記録 |
46
+ | [../CHANGELOG.md](../CHANGELOG.md) | 公開版ごとの変更履歴 |
35
47
 
36
- 現行ADR:
48
+ ## 証拠
37
49
 
38
- - [ADR 0001](adr/0001-claude-primary-codex-adapter.md): Claude primaryを維持し、Codexをadapterとして追加する。
39
- - [ADR 0002](adr/0002-observer-claude-completion-receipt.md): Claude completed turnはThroughline所有のStop receiptで固定する。
40
- - [ADR 0003](adr/0003-observer-completed-chain-cursor.md): Observer cursorをhost固有のcompleted pair chainとprefix検証へ束縛する。
41
- - [ADR 0020](adr/0020-windows-ci-release-latency.md): Windows ACL契約を維持し、境界fixtureと実ACL検証を分離する。
42
- - [ADR 0021](adr/0021-grok-host-capture.md): Grok first-class hook host にし、`/tl` 後の記憶再開は `grok-continue` に固定する。
43
- - [ADR 0022](adr/0022-cursor-host-capture.md): Cursor を first-class hook host にし、注入は sessionStart の `additional_context`、hook は `~/.cursor/hooks.json` への upsert。
50
+ | 場所 | 役割 |
51
+ |---|---|
52
+ | [../rag/INDEX.md](../rag/INDEX.md) | 外部仕様・実機調査の索引 |
53
+ | [evidence/](https://github.com/kitepon/Throughline/tree/main/evidence) | host受入などの固定証拠 |
54
+ | [throughline-handoff-context.example.json](throughline-handoff-context.example.json) | 公開JSON契約の例 |
44
55
 
45
- Observerの公開境界は`throughline observer-read`/`throughline observer-wait`のJSON-only CLIである。
46
- ThroughlineはClaude Stop receiptとCodex rolloutの`task_complete`だけからcompleted cursorを構築し、
47
- ObserverがDB、WAL、rolloutを直接監視するfallbackは持たない。waitは最大3600秒で、`changed`、`timeout`、
48
- `resync_required`、`ambiguous_parent`を返す。
56
+ ## 製品の所有境界
49
57
 
50
- portable contextの公開境界は`throughline handoff-context --session <id> --json`である。既存DBを
51
- read-onlyで開き、SessionStartと同じbudgeted inheritance contextを返すが、baton、merge、
52
- `sessions.merged_into`、L1/L2/L3 rowの`session_id`は変更しない。Observer境界とは用途もschemaも別で、
53
- AIterm v0.23.0はこのCLIだけをconsumer境界として使う。
58
+ Throughline は単独で install、設定、状態保存、schema migration、診断、復旧、更新、
59
+ release 判定まで完結する。状態の正本は `~/.throughline/` と製品コードであり、他製品は
60
+ 公開CLI・JSON契約を介して連携する。dotagents は工場全体の配線と統合契約を管理するが、
61
+ Throughline の状態を直接書き換えず、製品の単独運用やrelease判断を制御しない。
54
62
 
55
- ## Entrypoints
63
+ ## 文書の寿命
56
64
 
57
- - [../CLAUDE.md](../CLAUDE.md): AI 作業者向けの正本。
58
- - [../README.md](../README.md): ユーザー向けの入口。
59
- - [../AGENTS.md](../AGENTS.md): Codex など Claude Code 以外のエージェント向け入口。
65
+ - 現行値・操作・判断は既存の現行文書へ統合し、同じ意味の現行文書を増やさない。
66
+ - 完了した計画、置換済み設計、当時の受入記録は `archive/` へ物理移動する。
67
+ - 履歴・証拠は削除せず、通常の必読経路から外す。
68
+ - source と文書が食い違う場合は source とfocused testで確認し、現行文書を同じ変更で直す。
69
+ - 新しい文書は、現行契約・履歴・証拠のどれかを決めてから置く。
70
+ - `npm run verify:docs` は全local link、top-level分類、archive索引、固定参照の互換stub、
71
+ 公開npm tarball内Markdownの相対link/image閉包を検査する。Markdown-only変更でも
72
+ 製品所有CIがこの入口を実行する。
@@ -1,6 +1,6 @@
1
1
  # 新 L1/L2/L3 設計(再定義)
2
2
 
3
- > **Status**: 実装完了(2026-04-16 時点)。この文書は **L1/L2/L3 再定義の設計記録**であり、schema v4-v5 相当の変更までを扱う。以後の `handoff_batons` (v6)・`memo_text` (v7)・state.usage スナップショット・VSCode 自動起動・monitor 診断機能は本仕様と独立で、[CLAUDE.md](../CLAUDE.md) と [04_public_release_plan.md](04_public_release_plan.md) に索引あり。
3
+ > **Status**: 実装完了(2026-04-16 時点)。この文書は **L1/L2/L3 再定義の設計記録**であり、schema v4-v5 相当の変更までを扱う。以後の `handoff_batons` (v6)・`memo_text` (v7)・state.usage スナップショット・VSCode 自動起動・monitor 診断機能は本仕様と独立で、[CLAUDE.md](https://github.com/kitepon/Throughline/blob/main/CLAUDE.md) と [04_public_release_plan.md](04_public_release_plan.md) に索引あり。
4
4
  > 全ステップ (1〜8) 実装済み。L1/L2/L3 すべて書き込みパスが稼働。schema v5 で details に `kind` / `source_id` 列追加済み。
5
5
  > 進捗の詳細は「実装順序」セクション末尾の進捗表を参照。
6
6