throughline 0.10.13 → 0.10.14

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,15 @@ shipped to npm but were not individually tagged on GitHub.
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.10.14] — 2026-09-02
14
+
15
+ ### Added
16
+
17
+ - `handoff-context --project <path> --json`で、指定project内の会話本文を持つ最新sessionを
18
+ read-onlyで選び、本文がなければ`empty`を返せるようにした。
19
+ - `--disclosure silent`を補足ファイルなしで指定できるようにし、埋込製品が短期記憶だけを
20
+ 基盤案内なしで受け取れるようにした。
21
+
13
22
  ## [0.10.13] — 2026-09-02
14
23
 
15
24
  ### Fixed
@@ -1430,7 +1439,8 @@ two attempts, instrument first instead of patching again.
1430
1439
 
1431
1440
  ---
1432
1441
 
1433
- [Unreleased]: https://github.com/kitepon/Throughline/compare/v0.10.13...HEAD
1442
+ [Unreleased]: https://github.com/kitepon/Throughline/compare/v0.10.14...HEAD
1443
+ [0.10.14]: https://github.com/kitepon/Throughline/compare/v0.10.13...v0.10.14
1434
1444
  [0.10.13]: https://github.com/kitepon/Throughline/compare/v0.10.12...v0.10.13
1435
1445
  [0.10.12]: https://github.com/kitepon/Throughline/compare/v0.10.11...v0.10.12
1436
1446
  [0.10.11]: https://github.com/kitepon/Throughline/compare/v0.10.10...v0.10.11
package/README.ja.md CHANGED
@@ -75,8 +75,9 @@ cwd は源セッションの `project_path` であり、呼び出し元 cwd は
75
75
  macOS Terminal のみ。
76
76
 
77
77
  通常のhandoff-contextは、引き継いだことを最初の応答で一度だけ案内し、後続応答では
78
- 繰り返させない。project束縛済み補足へ`handoffDisclosure: "silent"`を指定した埋込製品だけは
79
- 案内を出さない。旧版がassistant本文へ付けた固定宣言は次回引き継ぎから除外し、ユーザーの
78
+ 繰り返させない。埋込製品は`handoff-context --disclosure silent`で案内を消せる。
79
+ project束縛済み補足の`handoffDisclosure: "silent"`も同じ扱いになる。旧版がassistant本文へ
80
+ 付けた固定宣言は次回引き継ぎから除外し、ユーザーの
80
81
  引用と実際の応答本文は保持する。
81
82
 
82
83
  新席は `~/.grok/sessions/<encodeURIComponent(cwd)>/` のトップレベル
@@ -395,7 +396,7 @@ v0.10.4以前には `self-update` が存在しない。該当版からの初回
395
396
  | `throughline runtime-errors snapshot --json` | boundedなlocal aggregateを読み取る(network I/Oなし) |
396
397
  | `throughline runtime-errors diagnostics --json` | collection/store状態をpathやraw errorなしで診断 |
397
398
  | `throughline handoff-preview --session <id>` | Codex 向け `throughline_handoff` JSON projection を表示 |
398
- | `throughline handoff-context --session <id> --json [--supplement-file <path>]` | SessionStartと同じ引き継ぎ文脈を取得。任意のproject束縛済み補足を、長期記憶・知識として同じ9,500字枠へ合成できる |
399
+ | `throughline handoff-context (--session <id> \| --project <path>) --json` | SessionStartと同じ引き継ぎ文脈を取得。project指定時は会話本文を持つ最新sessionを選び、`--disclosure silent`に対応し、本文がなければ`empty`を返す。session指定時はproject束縛済み補足を同じ9,500字枠へ合成できる |
399
400
  | `throughline latest-session --project <absolute-path> --json` | 指定した1プロジェクトだけを対象に直近セッションIDを読み取る。既存DBをread-onlyで開き、記録がなければ`empty`を返す |
400
401
  | `throughline grok-continue --session <id>` | handoff-context を初手 user 文にした対話 Grok 席を立てる。cwd は源の `project_path`。ready でなければ spawn しない。`--rules` なし。macOS Terminal のみ |
401
402
  | `throughline codex-sidecar-diagnostics` | この project の `codex-sidecar` diagnostics status を確認 |
@@ -428,15 +429,18 @@ throughline runtime-errors diagnostics --json
428
429
 
429
430
  ```bash
430
431
  throughline handoff-context --session codex:<thread-id> --json
432
+ throughline handoff-context --project /absolute/bot/project --json --disclosure silent
431
433
  ```
432
434
 
433
- 成功時の`throughline.handoff_context.v1`は`schema`、`status`、`sessionId`、`context`だけを返す。
434
- `context`はSessionStartと同じ予算付き継承文脈である。任意の`--supplement-file <path>`には
435
+ `throughline.handoff_context.v1`は`schema`、`status`、`sessionId`、`context`だけを返す。
436
+ `--project`ではそのproject内で会話本文を持つ最新sessionを選び、存在しなければ`empty`を返す。
437
+ `--disclosure silent`は長期記憶を追加せずThroughlineの案内を消す。`context`はSessionStartと
438
+ 同じ予算付き継承文脈である。`--session`で使える任意の`--supplement-file <path>`には
435
439
  `throughline.handoff_supplement.v1`、源sessionと同じ`projectPath`、`title`と`content`からなる
436
440
  `sections`を指定する。任意の`handoffDisclosure`は`visible`(既定)または`silent`を受け取る。
437
441
  補足は会話記憶と同じ9,500字枠へ入り、別projectの補足は拒否する。
438
442
  DB作成・migration・baton消費・session merge・
439
- latest session推測・`sessions.merged_into`変更・L1/L2/L3 rowの所属変更は行わない。AItermは任意の
443
+ `sessions.merged_into`変更・L1/L2/L3 rowの所属変更は行わない。AItermは任意の
440
444
  別harness portable forkでこの境界を使う。Observer feedはcompleted-turn projectionであり代替ではない。
441
445
 
442
446
  スラッシュコマンド (Claude Code 内でユーザーが叩く):
package/README.md CHANGED
@@ -817,7 +817,7 @@ entry to the `tasks` array yourself:
817
817
 
818
818
  ## Commands
819
819
 
820
- **The current release is v0.10.13.** Throughline supports Claude Code, Codex,
820
+ **The current release is v0.10.14.** Throughline supports Claude Code, Codex,
821
821
  Grok, and Cursor as documented host adapters. The versioned, read-only
822
822
  `handoff-context` boundary opens only an existing database and leaves baton
823
823
  state, session ownership, and memory rows unchanged. Factory diagnostics,
@@ -826,8 +826,9 @@ under the same explicit-failure and local-only contracts.
826
826
 
827
827
  Normal handoffs announce inherited continuity once in the first response and
828
828
  explicitly forbid repeating that line in later responses. A project-bound
829
- supplement may set `handoffDisclosure` to `silent` for an embedded product that
830
- keeps continuity metadata out of its chat. Legacy Throughline disclosure lines
829
+ launcher may pass `--disclosure silent` for an embedded product that keeps
830
+ continuity metadata out of its chat. A supplement may also set
831
+ `handoffDisclosure` to `silent`. Legacy Throughline disclosure lines
831
832
  in assistant memory are omitted from the next handoff; user quotations and the
832
833
  actual reply body remain intact.
833
834
 
@@ -862,7 +863,7 @@ once with `npm install --global throughline@latest`, then run
862
863
  | `throughline runtime-errors reopen <fingerprint> --json` | Explicitly reopen a resolved aggregate without fabricating a new occurrence |
863
864
  | `throughline runtime-errors compact --json` | Remove only acknowledged, resolved aggregates after retention; open or unacknowledged records remain |
864
865
  | `throughline handoff-preview --session <id>` | Print a Codex-facing `throughline_handoff` JSON projection |
865
- | `throughline handoff-context --session <id> --json [--supplement-file <path>]` | Print the SessionStart inheritance context without moving memory rows; an optional project-bound supplement adds long-term memory and knowledge inside the same 9,500-character budget |
866
+ | `throughline handoff-context (--session <id> \| --project <path>) --json` | Print the SessionStart inheritance context without moving memory rows. Project mode selects the newest captured session with dialogue, supports `--disclosure silent`, and returns `empty` when no dialogue exists. Session mode may add a project-bound supplement inside the same 9,500-character budget |
866
867
  | `throughline latest-session --project <absolute-path> --json` | Read the latest session id strictly scoped to one project; opens the existing database read-only and returns `empty` when the project has no captured session |
867
868
  | `throughline grok-continue --session <id>` | Spawn a person-facing Grok seat whose first user text is the handoff-context body. cwd is the source session `project_path`. Does not spawn without ready context. No `--rules`. macOS Terminal only |
868
869
  | `throughline codex-capture --codex-thread-id <id>` | Capture active Codex rollout turns into a `codex:<thread_id>` DB session |
@@ -912,11 +913,15 @@ performing a normal handoff:
912
913
 
913
914
  ```bash
914
915
  throughline handoff-context --session codex:<thread-id> --json
916
+ throughline handoff-context --project /absolute/bot/project --json --disclosure silent
915
917
  ```
916
918
 
917
- The successful `throughline.handoff_context.v1` object contains only `schema`,
918
- `status`, `sessionId`, and `context`. The context is the same budgeted
919
- inheritance text used by SessionStart. A launcher may append
919
+ The `throughline.handoff_context.v1` object contains only `schema`, `status`,
920
+ `sessionId`, and `context`. With `--project`, Throughline selects the newest
921
+ session in that project that has dialogue context; it returns `status: "empty"`
922
+ when none exists. `--disclosure silent` removes the Throughline announcement
923
+ without adding long-term memory. The context uses the same budget as
924
+ SessionStart. With `--session`, a launcher may append
920
925
  `--supplement-file <path>` with a `throughline.handoff_supplement.v1` JSON object:
921
926
 
922
927
  ```json
@@ -936,7 +941,7 @@ The supplement is included only when `projectPath` matches the source session
936
941
  and shares the 9,500-character budget with conversation memory. If the captured
937
942
  session has no dialogue context yet, a valid project-bound supplement is returned
938
943
  by itself. The command does not create or migrate a
939
- database, consume a baton, merge sessions, infer a latest session, change
944
+ database, consume a baton, merge sessions, change
940
945
  `sessions.merged_into`, or reassign L1/L2/L3 rows. AIterm uses this boundary for
941
946
  its optional cross-harness portable fork; the Observer feed is a separate
942
947
  completed-turn projection and is not a substitute.
@@ -11,7 +11,7 @@
11
11
  * throughline detail <時刻> # L2+L3 詳細取得 (Claude が Bash 経由で呼ぶ想定)
12
12
  * throughline recall --l2|--l1 # 注入案内から辿る pull 用 read-only 記憶取得
13
13
  * throughline handoff-preview # Codex-facing throughline_handoff JSON preview
14
- * throughline handoff-context --session <id> --json [--supplement-file <path>] # Read-only inheritance context JSON
14
+ * throughline handoff-context (--session <id> | --project <path>) --json # Read-only inheritance context JSON
15
15
  * throughline latest-session --project <path> --json # Latest session strictly scoped to one project
16
16
  * throughline grok-continue --session <id> # Spawn a Grok seat whose first user text is handoff-context
17
17
  * throughline auditor-context --json # Read-only bounded auditor context JSON
@@ -236,10 +236,12 @@ Usage:
236
236
  throughline monitor Multi-session token monitor (use --all, --session <id>)
237
237
  throughline detail <time> Retrieve L2+L3 detail for a turn (e.g. 14:23:05 or 14:23-14:30)
238
238
  throughline handoff-preview Print Codex-facing throughline_handoff JSON
239
- throughline handoff-context --session <id> --json [--supplement-file <path>]
239
+ throughline handoff-context (--session <id> | --project <path>) --json
240
240
  Print the exact inheritance context without
241
- changing database ownership; optionally include
242
- project-bound long-term memory and knowledge
241
+ changing database ownership. Project mode selects
242
+ the newest session with dialogue and may use
243
+ --disclosure silent. Session mode may use a
244
+ project-bound --supplement-file
243
245
  throughline latest-session --project <absolute-path> --json
244
246
  Read the latest session id for exactly one project
245
247
  throughline grok-continue --session <id>
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## 現行状態
8
8
 
9
- - release candidateのpackage版は `0.10.13`。tagとnpmの公開確認はpublish後に行う。
9
+ - release candidateのpackage版は `0.10.14`。tagとnpmの公開確認はpublish後に行う。
10
10
  - Claude Code、Codex、Grok、Cursorをfirst-class hostとして扱う。
11
11
  - 現行DB schemaはv9。schemaの正本は [src/db.mjs](../src/db.mjs) の
12
12
  `CURRENT_VERSION`、二相handoffの判断は
@@ -20,8 +20,10 @@ Nターン分の記憶を引き継いだ」と応答冒頭で宣言させてい
20
20
 
21
21
  - 通常の引き継ぎは、引き継ぎの事実と保持ターン数を最初の応答で一度だけ案内する。
22
22
  - 同じhost sessionの2回目以降の応答では案内を繰り返させない。
23
- - project束縛済み`throughline.handoff_supplement.v1`は任意の`handoffDisclosure`として
24
- `visible`(既定)または`silent`を持てる。`silent`を指定した埋込製品では案内しない。
23
+ - `handoff-context`は`--disclosure visible|silent`を受け取り、`silent`を指定した埋込製品では
24
+ 補足ファイルを作らずに案内を消せる。
25
+ - project束縛済み`throughline.handoff_supplement.v1`も任意の`handoffDisclosure`として
26
+ `visible`(既定)または`silent`を持てる。
25
27
  - Throughline自身が旧版でassistantへ付けた固定宣言行は、後継へ渡すassistant本文から除外する。
26
28
  - ユーザー発言に含まれる同じ文字列は会話内容として保持する。
27
29
  - 引き継ぎの成立はsession対応、生成コンテキスト、継続応答の内容で検証する。宣言の反復を
@@ -30,6 +32,6 @@ Nターン分の記憶を引き継いだ」と応答冒頭で宣言させてい
30
32
  ## Consequences
31
33
 
32
34
  - 通常のThroughline利用では従来の引き継ぎ案内が残る。
33
- - 埋込製品は既存のproject分離境界を使って案内だけを非表示にできる。
35
+ - 埋込製品はproject分離境界と公開CLI引数を使って案内だけを非表示にできる。
34
36
  - 旧宣言が保存済みのsessionも、次回の正規引き継ぎでメタ行を持ち越さない。
35
37
  - 保存済みの原会話は監査記録として変更しない。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "throughline",
3
- "version": "0.10.13",
3
+ "version": "0.10.14",
4
4
  "type": "module",
5
5
  "description": "Persistent memory hooks for Claude Code, Codex, Grok, and Cursor (/clear-safe context compression)",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { homedir } from 'node:os';
3
- import { isAbsolute, join } from 'node:path';
3
+ import { isAbsolute, join, resolve } from 'node:path';
4
4
 
5
5
  import { sameProjectPath } from '../project-path.mjs';
6
6
  import { openReadOnlyDb } from '../db.mjs';
@@ -13,23 +13,50 @@ export const HANDOFF_CONTEXT_SCHEMA = 'throughline.handoff_context.v1';
13
13
  export const HANDOFF_SUPPLEMENT_SCHEMA = 'throughline.handoff_supplement.v1';
14
14
 
15
15
  export function parseArgs(argv = []) {
16
- const baseArgsInvalid =
17
- (argv.length !== 3 && argv.length !== 5) ||
18
- argv[0] !== '--session' ||
16
+ if (
17
+ (argv[0] !== '--session' && argv[0] !== '--project') ||
19
18
  typeof argv[1] !== 'string' ||
20
19
  argv[1].length === 0 ||
21
- argv[2] !== '--json';
22
- const supplementArgsValid = argv.length === 3 || (
23
- argv[3] === '--supplement-file' &&
24
- typeof argv[4] === 'string' &&
25
- argv[4].length > 0
26
- );
27
- if (baseArgsInvalid || !supplementArgsValid) {
20
+ argv[2] !== '--json' ||
21
+ argv.length % 2 === 0
22
+ ) {
28
23
  throw new TypeError('usage error');
29
24
  }
25
+
26
+ let supplementFile = null;
27
+ let handoffDisclosure = 'visible';
28
+ const seen = new Set();
29
+ for (let index = 3; index < argv.length; index += 2) {
30
+ const option = argv[index];
31
+ const value = argv[index + 1];
32
+ if (
33
+ seen.has(option) ||
34
+ typeof value !== 'string' ||
35
+ value.length === 0
36
+ ) {
37
+ throw new TypeError('usage error');
38
+ }
39
+ seen.add(option);
40
+ if (option === '--supplement-file') {
41
+ supplementFile = value;
42
+ } else if (option === '--disclosure' && ['visible', 'silent'].includes(value)) {
43
+ handoffDisclosure = value;
44
+ } else {
45
+ throw new TypeError('usage error');
46
+ }
47
+ }
48
+ if (
49
+ (argv[0] === '--project' && supplementFile) ||
50
+ (supplementFile && seen.has('--disclosure'))
51
+ ) {
52
+ throw new TypeError('usage error');
53
+ }
54
+
30
55
  return {
31
- sessionId: argv[1],
32
- supplementFile: argv.length === 5 ? argv[4] : null,
56
+ sessionId: argv[0] === '--session' ? argv[1] : null,
57
+ projectPath: argv[0] === '--project' ? resolve(argv[1]) : null,
58
+ supplementFile,
59
+ handoffDisclosure,
33
60
  };
34
61
  }
35
62
 
@@ -61,13 +88,14 @@ export function renderHandoffSupplement(value, projectPath) {
61
88
  export function readHandoffContext(sessionId, {
62
89
  dbPath = join(homedir(), '.throughline', 'throughline.db'),
63
90
  supplementFile = null,
91
+ handoffDisclosure = 'visible',
64
92
  } = {}) {
65
93
  if (!existsSync(dbPath)) return null;
66
94
 
67
95
  const db = openReadOnlyDb(dbPath);
68
96
  try {
69
97
  let supplementContext = null;
70
- let handoffDisclosure = 'visible';
98
+ let resolvedHandoffDisclosure = handoffDisclosure;
71
99
  if (supplementFile) {
72
100
  const row = db.prepare(
73
101
  'SELECT project_path FROM sessions WHERE session_id = ?',
@@ -75,14 +103,14 @@ export function readHandoffContext(sessionId, {
75
103
  if (!row?.project_path) return null;
76
104
  const supplement = JSON.parse(readFileSync(supplementFile, 'utf8'));
77
105
  supplementContext = renderHandoffSupplement(supplement, row.project_path);
78
- handoffDisclosure = supplement.handoffDisclosure ?? 'visible';
106
+ resolvedHandoffDisclosure = supplement.handoffDisclosure ?? handoffDisclosure;
79
107
  }
80
108
 
81
109
  const separator = supplementContext ? '\n\n' : '';
82
110
  const context = buildBudgetedResumeContext(db, {
83
111
  sessionId,
84
112
  isInheritance: true,
85
- handoffDisclosure,
113
+ handoffDisclosure: resolvedHandoffDisclosure,
86
114
  maxChars: INJECTION_BUDGET_CHARS - (supplementContext?.length ?? 0) - separator.length,
87
115
  })?.text ?? null;
88
116
  if (!context && !supplementContext) return null;
@@ -99,6 +127,34 @@ export function readHandoffContext(sessionId, {
99
127
  }
100
128
  }
101
129
 
130
+ export function readLatestProjectHandoffContext(projectPath, {
131
+ dbPath = join(homedir(), '.throughline', 'throughline.db'),
132
+ handoffDisclosure = 'visible',
133
+ } = {}) {
134
+ if (!existsSync(dbPath)) return null;
135
+
136
+ const db = openReadOnlyDb(dbPath);
137
+ try {
138
+ const sessions = db.prepare(
139
+ `SELECT session_id, project_path
140
+ FROM sessions
141
+ ORDER BY updated_at DESC`,
142
+ ).all();
143
+ for (const session of sessions) {
144
+ if (!sameProjectPath(session.project_path, projectPath)) continue;
145
+ const context = buildBudgetedResumeContext(db, {
146
+ sessionId: session.session_id,
147
+ isInheritance: true,
148
+ handoffDisclosure,
149
+ })?.text ?? null;
150
+ if (context) return { sessionId: session.session_id, context };
151
+ }
152
+ return null;
153
+ } finally {
154
+ db.close();
155
+ }
156
+ }
157
+
102
158
  export function readSessionProjectPath(sessionId, {
103
159
  dbPath = join(homedir(), '.throughline', 'throughline.db'),
104
160
  } = {}) {
@@ -122,26 +178,43 @@ export function run(argv = [], {
122
178
  stdout = process.stdout,
123
179
  stderr = process.stderr,
124
180
  readContext = readHandoffContext,
181
+ readProjectContext = readLatestProjectHandoffContext,
125
182
  } = {}) {
126
183
  let sessionId;
184
+ let projectPath;
127
185
  let supplementFile;
186
+ let handoffDisclosure;
128
187
  try {
129
- ({ sessionId, supplementFile } = parseArgs(argv));
188
+ ({ sessionId, projectPath, supplementFile, handoffDisclosure } = parseArgs(argv));
130
189
  } catch {
131
190
  stderr.write(
132
- 'Usage: throughline handoff-context --session <id> --json [--supplement-file <path>]\n',
191
+ 'Usage: throughline handoff-context (--session <id> | --project <path>) --json [--disclosure visible|silent | --supplement-file <path>]\n',
133
192
  );
134
193
  return 2;
135
194
  }
136
195
 
137
- let context;
196
+ let result;
138
197
  try {
139
- context = readContext(sessionId, { supplementFile });
198
+ result = projectPath
199
+ ? readProjectContext(projectPath, { handoffDisclosure })
200
+ : {
201
+ sessionId,
202
+ context: readContext(sessionId, { supplementFile, handoffDisclosure }),
203
+ };
140
204
  } catch {
141
205
  stderr.write('Throughline handoff context could not be read.\n');
142
206
  return 1;
143
207
  }
144
- if (!context) {
208
+ if (!result?.context && projectPath) {
209
+ stdout.write(`${JSON.stringify({
210
+ schema: HANDOFF_CONTEXT_SCHEMA,
211
+ status: 'empty',
212
+ sessionId: null,
213
+ context: '',
214
+ })}\n`);
215
+ return 0;
216
+ }
217
+ if (!result?.context) {
145
218
  stderr.write('Throughline handoff context is not available for that session.\n');
146
219
  return 1;
147
220
  }
@@ -149,8 +222,8 @@ export function run(argv = [], {
149
222
  stdout.write(`${JSON.stringify({
150
223
  schema: HANDOFF_CONTEXT_SCHEMA,
151
224
  status: 'ready',
152
- sessionId,
153
- context,
225
+ sessionId: result.sessionId,
226
+ context: result.context,
154
227
  })}\n`);
155
228
  return 0;
156
229
  }
@@ -8,7 +8,11 @@ import { fileURLToPath } from 'node:url';
8
8
  import { DatabaseSync } from 'node:sqlite';
9
9
 
10
10
  import { buildBudgetedResumeContext, INJECTION_BUDGET_CHARS } from '../resume-context.mjs';
11
- import { parseArgs, readSessionProjectPath } from './handoff-context.mjs';
11
+ import {
12
+ parseArgs,
13
+ readLatestProjectHandoffContext,
14
+ readSessionProjectPath,
15
+ } from './handoff-context.mjs';
12
16
 
13
17
  const REPO_ROOT = fileURLToPath(new URL('../..', import.meta.url));
14
18
  const BIN_PATH = join(REPO_ROOT, 'bin/throughline.mjs');
@@ -201,6 +205,93 @@ test('handoff-context supplement can silence disclosure without changing normal
201
205
  }
202
206
  });
203
207
 
208
+ test('handoff-context can silence disclosure without a long-term-memory supplement', () => {
209
+ const home = mkdtempSync(join(tmpdir(), 'tl-handoff-direct-silent-'));
210
+ try {
211
+ const { db } = createFixture(home);
212
+ db.close();
213
+
214
+ const result = runCli(home, [
215
+ 'handoff-context', '--session', SESSION_ID, '--json',
216
+ '--disclosure', 'silent',
217
+ ]);
218
+ assert.equal(result.status, 0, result.stderr);
219
+ const context = JSON.parse(result.stdout).context;
220
+ assert.doesNotMatch(context, /この引き継ぎ直後の最初の応答だけ/);
221
+ assert.doesNotMatch(context, /Throughline で前のセッションから .* ターン分/);
222
+ assert.match(context, /所有権を変えずに記憶を渡して/);
223
+ } finally {
224
+ rmSync(home, { recursive: true, force: true });
225
+ }
226
+ });
227
+
228
+ test('handoff-context project selector skips the newest empty session', () => {
229
+ const home = mkdtempSync(join(tmpdir(), 'tl-handoff-project-'));
230
+ try {
231
+ const { db, dbPath } = createFixture(home);
232
+ db.prepare(
233
+ `INSERT INTO sessions
234
+ (session_id, project_path, status, created_at, updated_at, merged_into)
235
+ VALUES ('newest-empty', '/work/project', 'active', ?, ?, NULL)`,
236
+ ).run(1_700_000_005_000, 1_700_000_006_000);
237
+ db.prepare(
238
+ `INSERT INTO sessions
239
+ (session_id, project_path, status, created_at, updated_at, merged_into)
240
+ VALUES ('other-newest', '/work/other', 'active', ?, ?, NULL)`,
241
+ ).run(1_700_000_007_000, 1_700_000_008_000);
242
+ db.prepare(
243
+ `INSERT INTO bodies
244
+ (session_id, origin_session_id, turn_number, role, text, token_count, created_at)
245
+ VALUES ('other-newest', 'other-newest', 1, 'user', 'OTHER_PROJECT_PRIVATE', 4, ?)`,
246
+ ).run(1_700_000_007_500);
247
+ db.close();
248
+
249
+ const selected = readLatestProjectHandoffContext('/work/project', {
250
+ dbPath,
251
+ handoffDisclosure: 'silent',
252
+ });
253
+ assert.equal(selected.sessionId, SESSION_ID);
254
+ assert.match(selected.context, /所有権を変えずに記憶を渡して/);
255
+
256
+ const result = runCli(home, [
257
+ 'handoff-context', '--project', '/work/project', '--json',
258
+ '--disclosure', 'silent',
259
+ ]);
260
+ assert.equal(result.status, 0, result.stderr);
261
+ const payload = JSON.parse(result.stdout);
262
+ assert.equal(payload.status, 'ready');
263
+ assert.equal(payload.sessionId, SESSION_ID);
264
+ assert.match(payload.context, /所有権を変えずに記憶を渡して/);
265
+ assert.doesNotMatch(payload.context, /OTHER_PROJECT_PRIVATE/);
266
+ assert.doesNotMatch(payload.context, /この引き継ぎ直後の最初の応答だけ/);
267
+ } finally {
268
+ rmSync(home, { recursive: true, force: true });
269
+ }
270
+ });
271
+
272
+ test('handoff-context project selector returns empty when the project has no dialogue', () => {
273
+ const home = mkdtempSync(join(tmpdir(), 'tl-handoff-project-empty-'));
274
+ try {
275
+ const { db } = createFixture(home);
276
+ db.exec('DELETE FROM details; DELETE FROM bodies; DELETE FROM skeletons;');
277
+ db.close();
278
+
279
+ const result = runCli(home, [
280
+ 'handoff-context', '--project', '/work/project', '--json',
281
+ '--disclosure', 'silent',
282
+ ]);
283
+ assert.equal(result.status, 0, result.stderr);
284
+ assert.deepEqual(JSON.parse(result.stdout), {
285
+ schema: 'throughline.handoff_context.v1',
286
+ status: 'empty',
287
+ sessionId: null,
288
+ context: '',
289
+ });
290
+ } finally {
291
+ rmSync(home, { recursive: true, force: true });
292
+ }
293
+ });
294
+
204
295
  test('handoff-context returns a project-bound supplement when the captured session has no dialogue yet', () => {
205
296
  const home = mkdtempSync(join(tmpdir(), 'tl-handoff-supplement-only-'));
206
297
  try {
@@ -261,15 +352,33 @@ test('handoff-context refuses a supplement from another bot project', () => {
261
352
  test('handoff-context accepts only the documented supplement argument shape', () => {
262
353
  assert.deepEqual(parseArgs(['--session', 's', '--json']), {
263
354
  sessionId: 's',
355
+ projectPath: null,
264
356
  supplementFile: null,
357
+ handoffDisclosure: 'visible',
265
358
  });
266
359
  assert.deepEqual(parseArgs([
267
360
  '--session', 's', '--json', '--supplement-file', '/tmp/memory.json',
268
361
  ]), {
269
362
  sessionId: 's',
363
+ projectPath: null,
270
364
  supplementFile: '/tmp/memory.json',
365
+ handoffDisclosure: 'visible',
366
+ });
367
+ assert.deepEqual(parseArgs([
368
+ '--project', '.', '--json', '--disclosure', 'silent',
369
+ ]), {
370
+ sessionId: null,
371
+ projectPath: process.cwd(),
372
+ supplementFile: null,
373
+ handoffDisclosure: 'silent',
271
374
  });
272
375
  assert.throws(() => parseArgs(['--session', 's', '--supplement-file', '/tmp/memory.json', '--json']));
376
+ assert.throws(() => parseArgs(['--project', '.', '--json', '--supplement-file', '/tmp/memory.json']));
377
+ assert.throws(() => parseArgs(['--session', 's', '--json', '--disclosure', 'hidden']));
378
+ assert.throws(() => parseArgs([
379
+ '--session', 's', '--json', '--disclosure', 'silent',
380
+ '--supplement-file', '/tmp/memory.json',
381
+ ]));
273
382
  });
274
383
 
275
384
  test('readSessionProjectPath returns the source session project', () => {
@@ -51,7 +51,8 @@ test('CLI help exposes guided Codex handoff and guarded execute semantics', () =
51
51
  assert.match(result.stdout, /Use --execute to/);
52
52
  assert.match(result.stdout, /--open-host auto\|desktop\|vscode\|cli\|none/);
53
53
  assert.match(result.stdout, /throughline trim --execute/);
54
- assert.match(result.stdout, /throughline handoff-context --session <id> --json/);
54
+ assert.match(result.stdout, /throughline handoff-context \(--session <id> \| --project <path>\) --json/);
55
+ assert.match(result.stdout, /--disclosure silent/);
55
56
  assert.match(result.stdout, /throughline latest-session --project <absolute-path> --json/);
56
57
  assert.match(result.stdout, /without\s+changing database ownership/);
57
58
  assert.match(result.stdout, /injectable DB memory/);