ccompactor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +37 -0
  3. package/README.md +101 -0
  4. package/dist/adapters/claude.d.ts +36 -0
  5. package/dist/adapters/claude.js +361 -0
  6. package/dist/adapters/claude.js.map +1 -0
  7. package/dist/adapters/codex.d.ts +11 -0
  8. package/dist/adapters/codex.js +218 -0
  9. package/dist/adapters/codex.js.map +1 -0
  10. package/dist/adapters/index.d.ts +17 -0
  11. package/dist/adapters/index.js +19 -0
  12. package/dist/adapters/index.js.map +1 -0
  13. package/dist/adapters/pi.d.ts +16 -0
  14. package/dist/adapters/pi.js +213 -0
  15. package/dist/adapters/pi.js.map +1 -0
  16. package/dist/adapters/types.d.ts +31 -0
  17. package/dist/adapters/types.js +7 -0
  18. package/dist/adapters/types.js.map +1 -0
  19. package/dist/artifact/expand.d.ts +23 -0
  20. package/dist/artifact/expand.js +71 -0
  21. package/dist/artifact/expand.js.map +1 -0
  22. package/dist/artifact/render.d.ts +59 -0
  23. package/dist/artifact/render.js +357 -0
  24. package/dist/artifact/render.js.map +1 -0
  25. package/dist/artifact/verify.d.ts +12 -0
  26. package/dist/artifact/verify.js +48 -0
  27. package/dist/artifact/verify.js.map +1 -0
  28. package/dist/bench/index.d.ts +71 -0
  29. package/dist/bench/index.js +186 -0
  30. package/dist/bench/index.js.map +1 -0
  31. package/dist/bench/run.d.ts +17 -0
  32. package/dist/bench/run.js +187 -0
  33. package/dist/bench/run.js.map +1 -0
  34. package/dist/cli.d.ts +2 -0
  35. package/dist/cli.js +322 -0
  36. package/dist/cli.js.map +1 -0
  37. package/dist/compact/engine.d.ts +69 -0
  38. package/dist/compact/engine.js +164 -0
  39. package/dist/compact/engine.js.map +1 -0
  40. package/dist/compact/shims.d.ts +24 -0
  41. package/dist/compact/shims.js +14 -0
  42. package/dist/compact/shims.js.map +1 -0
  43. package/dist/discover/index.d.ts +40 -0
  44. package/dist/discover/index.js +164 -0
  45. package/dist/discover/index.js.map +1 -0
  46. package/dist/discover/reference.d.ts +21 -0
  47. package/dist/discover/reference.js +44 -0
  48. package/dist/discover/reference.js.map +1 -0
  49. package/dist/extract.d.ts +26 -0
  50. package/dist/extract.js +103 -0
  51. package/dist/extract.js.map +1 -0
  52. package/dist/handoff/index.d.ts +12 -0
  53. package/dist/handoff/index.js +67 -0
  54. package/dist/handoff/index.js.map +1 -0
  55. package/dist/ir/tokens.d.ts +14 -0
  56. package/dist/ir/tokens.js +36 -0
  57. package/dist/ir/tokens.js.map +1 -0
  58. package/dist/ir/types.d.ts +82 -0
  59. package/dist/ir/types.js +36 -0
  60. package/dist/ir/types.js.map +1 -0
  61. package/dist/ledgers/index.d.ts +66 -0
  62. package/dist/ledgers/index.js +185 -0
  63. package/dist/ledgers/index.js.map +1 -0
  64. package/dist/llm/index.d.ts +43 -0
  65. package/dist/llm/index.js +143 -0
  66. package/dist/llm/index.js.map +1 -0
  67. package/dist/redact.d.ts +39 -0
  68. package/dist/redact.js +104 -0
  69. package/dist/redact.js.map +1 -0
  70. package/dist/skill/index.d.ts +9 -0
  71. package/dist/skill/index.js +48 -0
  72. package/dist/skill/index.js.map +1 -0
  73. package/dist/triage.d.ts +25 -0
  74. package/dist/triage.js +160 -0
  75. package/dist/triage.js.map +1 -0
  76. package/dist/tui/index.d.ts +4 -0
  77. package/dist/tui/index.js +147 -0
  78. package/dist/tui/index.js.map +1 -0
  79. package/package.json +71 -0
  80. package/skill/SKILL.md +54 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ccompactor contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,37 @@
1
+ # NOTICE
2
+
3
+ ## No Anthropic-derived code
4
+
5
+ CCompactor contains **no code derived from Anthropic's Claude Code CLI**, and no code from any fork
6
+ of it.
7
+
8
+ An earlier iteration vendored two modules (`prompt.ts`, `grouping.ts`) from
9
+ [openclaude](https://github.com/Gitlawb/openclaude) to reach behavioural parity while the engine was
10
+ being written. Those files were never imported by anything: `src/compact/engine.ts` has always
11
+ delegated to `summariseWithContract`, which is written against the published nine-section contract
12
+ with ccompactor's own wording. The vendored directory has been deleted, and with it the only obstacle
13
+ to publishing.
14
+
15
+ The nine-section contract — Primary Request and Intent, Key Technical Concepts, Files and Code
16
+ Sections, Errors and fixes, Problem Solving, All user messages, Pending Tasks, Current Work, Optional
17
+ Next Step — is the published behaviour of Claude Code's `/compact`, described in `docs/SPEC.md`.
18
+ Section structure is an idea, not protectable expression; implementing it from its description is
19
+ ordinary engineering.
20
+
21
+ `packages/ccompactor/scripts/guard-vendor.mjs` remains and runs on `prepack`, so the mistake cannot
22
+ be reintroduced silently.
23
+
24
+ ## What ccompactor owes to sctxx
25
+
26
+ The product framing — cross-agent handoff, provenance on every claim, a verify step, layered
27
+ artifacts — follows [sctxx](https://github.com/handyutils/sctxx) by the same author. None of its code
28
+ is used; sctxx is Rust, ccompactor is TypeScript, and the two agree on behaviour rather than
29
+ implementation. The handoff benchmark is a port, so the two tools' numbers are comparable, and they
30
+ are compared in the open — including where ccompactor is behind.
31
+
32
+ ## What ccompactor owes to published research
33
+
34
+ The compaction-side design follows the survey sctxx's `docs/research/` records: observation masking
35
+ as the cheapest strategy with an ablation (arXiv:2508.21433), addressable recall as what makes
36
+ dropping safe (arXiv:2607.25066), and the finding that no published result measures a handoff to a
37
+ different agent (arXiv:2606.02875).
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # ccompactor
2
+
3
+ **Extract any coding-agent session into a compact, verified, provenance-linked handoff that any other
4
+ agent can continue from.**
5
+
6
+ Claude Code, Codex CLI and Pi keep their transcripts on disk. `ccompactor` reads one, builds
7
+ deterministic ledgers of what actually happened, and writes an artifact you can hand to a *different*
8
+ agent so it starts where the last one stopped instead of re-deriving ten days of work.
9
+
10
+ ```sh
11
+ npm i -g ccompactor
12
+ ccompactor list --any-project
13
+ ccompactor extract claude:last --out .ccompactor
14
+ ```
15
+
16
+ Then point any agent at `.ccompactor/handoff.md`:
17
+
18
+ ```sh
19
+ ccompactor handoff claude:last --to codex --run
20
+ ```
21
+
22
+ ## What it does
23
+
24
+ | command | what it does |
25
+ | --- | --- |
26
+ | `ccompactor doctor` | which agent stores are on this machine |
27
+ | `ccompactor list` | sessions, newest first |
28
+ | `ccompactor find <query>` | fuzzy search over id, project, and the first thing the human asked for |
29
+ | `ccompactor extract <ref>` | the handoff artifact |
30
+ | `ccompactor expand <ref> a..b` | the events behind an `[evt a–b]` pointer, in exact pages |
31
+ | `ccompactor verify <dir>` | re-check an artifact: are the quotes still in the transcript, do the files still exist |
32
+ | `ccompactor handoff <ref> --to <agent>` | launch Claude, Codex or Pi with the context preloaded |
33
+ | `ccompactor skill install` | the Agent Skill, so agents know to use it |
34
+ | `ccompactor --tui` | an interactive browser — filter, search, extract, handoff |
35
+ | `ccompactor bench <refs...>` | measure whether a handoff actually hands anything off |
36
+
37
+ Session references are `claude:7c1e8f82`, `codex:last`, `pi:<id>`, or a path to a transcript.
38
+
39
+ ## Deterministic first
40
+
41
+ `--llm none` produces a complete artifact with **no model and no network**. On a real 103,757-event
42
+ session that is **4,050 tokens in 2 seconds**.
43
+
44
+ The artifact has four layers, cheapest first, so a reader can stop as soon as it knows enough:
45
+
46
+ - **L0 Brief** — the goal, the hard constraints quoted verbatim, where the work was, what it
47
+ committed, the last commands, what to verify first.
48
+ - **L1 Continuation summary** — model-written, or an explicit notice that none ran.
49
+ - **L2 Ledgers** — files touched with edit counts, commands with outcomes, error signatures ranked by
50
+ repetition, a tool census. All deterministic.
51
+ - **L3 Retrieval** — an index of every episode the artifact did not carry, with event ranges, so
52
+ anything dropped is still reachable.
53
+
54
+ Every claim carries a pointer, and the pointer works:
55
+
56
+ ```sh
57
+ ccompactor expand claude:7c1e8f82 4122..4381 --context 3
58
+ ```
59
+
60
+ ## The model is optional
61
+
62
+ ```sh
63
+ ccompactor extract claude:last --llm none # nothing leaves the machine
64
+ ccompactor extract claude:last --llm api:anthropic # ANTHROPIC_API_KEY
65
+ ccompactor extract claude:last --llm api:openai # OPENAI_API_KEY
66
+ ccompactor extract claude:last --llm api:compat/<model> # CCOMPACTOR_BASE_URL + CCOMPACTOR_API_KEY
67
+ ```
68
+
69
+ Secrets are redacted before any model call and again in the rendered artifact. Transcript content is
70
+ treated as data, never as instructions.
71
+
72
+ ## Benchmarked, including where it loses
73
+
74
+ `ccompactor` ships a handoff benchmark with four arms — `none`, `tail`, `artifact`, and
75
+ `retrieval` (the successor can ask for an event range and be given the real events).
76
+
77
+ Measured head to head against its Rust sister project [sctxx](https://github.com/handyutils/sctxx) on
78
+ the same session, same questions, same backend, three runs each:
79
+
80
+ | arm | ccompactor | sctxx |
81
+ | --- | --- | --- |
82
+ | none | 0% | 0% |
83
+ | tail | 0–5% | 9% |
84
+ | artifact | 25% | 23% |
85
+ | **retrieval** | **~38%** | **~73%** |
86
+
87
+ **ccompactor is behind, and the site says so.** The gap is real — the ranges do not overlap across
88
+ repeated runs — and the cause is not yet identified.
89
+
90
+ ## Install without Node
91
+
92
+ Standalone binaries for macOS (arm64, x64), Linux (x64, arm64, plus `.deb`) and Windows (x64, arm64)
93
+ are attached to each [GitHub release](https://github.com/ccompactor/ccompactor/releases).
94
+
95
+ ## Requirements
96
+
97
+ Node ≥ 20 for the npm install. The standalone binaries need nothing.
98
+
99
+ ## Licence
100
+
101
+ MIT. Contains no code derived from Anthropic's Claude Code CLI — see [NOTICE](NOTICE).
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Claude Code session adapter.
3
+ *
4
+ * The store is `~/.claude/projects/<slugified-cwd>/<session-uuid>.jsonl`, one
5
+ * JSON object per line. Two properties of that format decide this adapter's
6
+ * shape:
7
+ *
8
+ * 1. **It is a tree, not a log.** Every record carries `uuid` and `parentUuid`.
9
+ * When a session is rewound or a message is edited, the file keeps the
10
+ * abandoned branch. Replaying the file in line order would hand a successor
11
+ * work the human explicitly walked away from, so the active branch is
12
+ * resolved by walking parent pointers back from the newest record.
13
+ *
14
+ * 2. **The provider compacts its own context.** A `summary` record, or a user
15
+ * turn that is the provider's continuation preamble, marks a boundary.
16
+ * Everything before it was already summarised once; re-summarising a summary
17
+ * is how meaning is lost, so the boundary is recorded and honoured downstream.
18
+ */
19
+ import type { AgentKind, SessionIR, SessionRef } from '../ir/types.js';
20
+ import type { Adapter, ListOptions, ReadOptions } from './types.js';
21
+ export declare function claudeStore(): string;
22
+ /**
23
+ * Claude Code encodes the project directory into the store path by replacing
24
+ * every non-alphanumeric character with `-`. It is not reversible — two
25
+ * different paths can produce the same slug — which is why the cwd recorded
26
+ * inside the transcript is preferred wherever it exists.
27
+ */
28
+ export declare function slugifyProject(path: string): string;
29
+ export declare class ClaudeAdapter implements Adapter {
30
+ kind: AgentKind;
31
+ label: string;
32
+ store(): string;
33
+ available(): boolean;
34
+ list(options: ListOptions): Promise<SessionRef[]>;
35
+ read(ref: SessionRef, options?: ReadOptions): Promise<SessionIR>;
36
+ }
@@ -0,0 +1,361 @@
1
+ /**
2
+ * Claude Code session adapter.
3
+ *
4
+ * The store is `~/.claude/projects/<slugified-cwd>/<session-uuid>.jsonl`, one
5
+ * JSON object per line. Two properties of that format decide this adapter's
6
+ * shape:
7
+ *
8
+ * 1. **It is a tree, not a log.** Every record carries `uuid` and `parentUuid`.
9
+ * When a session is rewound or a message is edited, the file keeps the
10
+ * abandoned branch. Replaying the file in line order would hand a successor
11
+ * work the human explicitly walked away from, so the active branch is
12
+ * resolved by walking parent pointers back from the newest record.
13
+ *
14
+ * 2. **The provider compacts its own context.** A `summary` record, or a user
15
+ * turn that is the provider's continuation preamble, marks a boundary.
16
+ * Everything before it was already summarised once; re-summarising a summary
17
+ * is how meaning is lost, so the boundary is recorded and honoured downstream.
18
+ */
19
+ import { existsSync } from 'node:fs';
20
+ import { readdir, stat } from 'node:fs/promises';
21
+ import { homedir } from 'node:os';
22
+ import { basename, join, resolve } from 'node:path';
23
+ import { readLines } from './types.js';
24
+ export function claudeStore() {
25
+ return process.env['CLAUDE_ROOT'] ?? join(homedir(), '.claude', 'projects');
26
+ }
27
+ /**
28
+ * Claude Code encodes the project directory into the store path by replacing
29
+ * every non-alphanumeric character with `-`. It is not reversible — two
30
+ * different paths can produce the same slug — which is why the cwd recorded
31
+ * inside the transcript is preferred wherever it exists.
32
+ */
33
+ export function slugifyProject(path) {
34
+ return path.replace(/[^a-zA-Z0-9]/g, '-');
35
+ }
36
+ export class ClaudeAdapter {
37
+ kind = 'claude';
38
+ label = 'Claude Code';
39
+ store() {
40
+ return claudeStore();
41
+ }
42
+ available() {
43
+ return existsSync(this.store());
44
+ }
45
+ async list(options) {
46
+ const root = this.store();
47
+ const wanted = options.project ? slugifyProject(resolve(options.project)) : undefined;
48
+ const dirs = options.project && !options.anyProject ? [wanted] : await safeReaddir(root);
49
+ const refs = [];
50
+ for (const dir of dirs) {
51
+ const dirPath = join(root, dir);
52
+ for (const entry of await safeReaddir(dirPath)) {
53
+ if (!entry.endsWith('.jsonl'))
54
+ continue;
55
+ const path = join(dirPath, entry);
56
+ const info = await stat(path).catch(() => null);
57
+ if (!info || !info.isFile())
58
+ continue;
59
+ if (options.maxBytes !== undefined && info.size > options.maxBytes)
60
+ continue;
61
+ refs.push({
62
+ agent: 'claude',
63
+ id: basename(entry, '.jsonl'),
64
+ path,
65
+ projectPath: join(root, dir),
66
+ mtime: info.mtimeMs,
67
+ bytes: info.size,
68
+ });
69
+ }
70
+ }
71
+ return refs.sort((a, b) => b.mtime - a.mtime);
72
+ }
73
+ async read(ref, options = {}) {
74
+ const lines = await readLines(ref.path);
75
+ const diagnostics = [];
76
+ const records = [];
77
+ for (const [index, line] of lines.entries()) {
78
+ try {
79
+ records.push({ index, raw: JSON.parse(line) });
80
+ }
81
+ catch (error) {
82
+ // One bad line is a diagnostic, never a failed session. A truncated
83
+ // final line is common when a session is read while it is being written.
84
+ diagnostics.push({
85
+ line: index + 1,
86
+ message: `unparseable: ${error.message}`,
87
+ });
88
+ }
89
+ }
90
+ const byUuid = new Map();
91
+ for (const record of records) {
92
+ if (record.raw.uuid)
93
+ byUuid.set(record.raw.uuid, record);
94
+ }
95
+ const onBranch = resolveActiveBranch(records, byUuid, diagnostics);
96
+ const compactBoundaries = [];
97
+ const messages = [];
98
+ const metadata = {};
99
+ for (const { index, raw } of onBranch) {
100
+ if (raw.cwd && metadata['cwd'] === undefined)
101
+ metadata['cwd'] = raw.cwd;
102
+ if (raw.gitBranch && metadata['branch'] === undefined)
103
+ metadata['branch'] = raw.gitBranch;
104
+ if (raw.version && metadata['version'] === undefined)
105
+ metadata['version'] = raw.version;
106
+ if (raw.message?.model && metadata['model'] === undefined)
107
+ metadata['model'] = raw.message.model;
108
+ if (raw.isSidechain && !options.includeSidechains)
109
+ continue;
110
+ if (raw.type === 'summary') {
111
+ compactBoundaries.push(index);
112
+ messages.push({
113
+ uuid: raw.uuid ?? `evt-${index}`,
114
+ role: 'attachment',
115
+ text: raw.summary ?? '',
116
+ eventIndex: index,
117
+ raw,
118
+ });
119
+ continue;
120
+ }
121
+ const message = toMessage(raw, index);
122
+ if (!message)
123
+ continue;
124
+ messages.push(message);
125
+ if (isCompactionPreamble(message))
126
+ compactBoundaries.push(index);
127
+ }
128
+ if (typeof metadata['cwd'] !== 'string') {
129
+ // Fall back to the slug only when the transcript recorded no cwd, and say
130
+ // so: the slug is lossy.
131
+ metadata['cwdGuessedFromSlug'] = ref.projectPath ? basename(ref.projectPath) : undefined;
132
+ }
133
+ metadata['keptPreBoundary'] = compactBoundaries.length > 0 && options.sinceCompact !== true;
134
+ return {
135
+ ref,
136
+ messages,
137
+ compactBoundaries,
138
+ metadata,
139
+ diagnostics,
140
+ };
141
+ }
142
+ }
143
+ function isCompactionPreamble(message) {
144
+ if (message.role !== 'user' || !message.text)
145
+ return false;
146
+ return message.text.includes('This session is being continued from a previous conversation');
147
+ }
148
+ function toMessage(raw, index) {
149
+ const uuid = raw.uuid ?? `evt-${index}`;
150
+ const base = {
151
+ uuid,
152
+ ...(raw.parentUuid ? { parentUuid: raw.parentUuid } : {}),
153
+ ...(raw.timestamp ? { timestamp: raw.timestamp } : {}),
154
+ eventIndex: index,
155
+ raw,
156
+ };
157
+ if (raw.type === 'assistant') {
158
+ const content = raw.message?.content;
159
+ const text = textOf(content);
160
+ const tool = firstToolUse(content);
161
+ if (tool) {
162
+ return {
163
+ ...base,
164
+ role: 'assistant',
165
+ text: text || undefined,
166
+ toolName: tool.name,
167
+ toolUseId: tool.id,
168
+ toolInput: tool.input,
169
+ };
170
+ }
171
+ return { ...base, role: 'assistant', text: text || undefined };
172
+ }
173
+ if (raw.type === 'user') {
174
+ const content = raw.message?.content;
175
+ const result = firstToolResult(content);
176
+ if (result) {
177
+ return {
178
+ ...base,
179
+ role: 'tool',
180
+ toolUseId: result.toolUseId,
181
+ toolResult: result.content,
182
+ isError: result.isError,
183
+ text: typeof result.content === 'string' ? result.content : undefined,
184
+ };
185
+ }
186
+ const text = typeof content === 'string' ? content : textOf(content);
187
+ const meta = raw.isMeta === true || isHarnessNoise(text);
188
+ return {
189
+ ...base,
190
+ role: 'user',
191
+ text: text || undefined,
192
+ isMeta: meta,
193
+ // The whole point of the flag: intent is what the human typed, and only that.
194
+ isHumanTurn: !meta && text.trim().length > 0,
195
+ };
196
+ }
197
+ if (raw.type === 'system') {
198
+ return { ...base, role: 'system', text: textOf(raw.message?.content) || undefined, isMeta: true };
199
+ }
200
+ return undefined;
201
+ }
202
+ /** Harness-injected user turns. Present in the file, never typed by a person. */
203
+ function isHarnessNoise(text) {
204
+ const trimmed = text.trimStart();
205
+ return (trimmed.startsWith('<command-name>') ||
206
+ trimmed.startsWith('<command-message>') ||
207
+ trimmed.startsWith('<local-command') ||
208
+ trimmed.startsWith('<system-reminder') ||
209
+ trimmed.includes('<system-reminder>') ||
210
+ trimmed.startsWith('[Request interrupted'));
211
+ }
212
+ function textOf(content) {
213
+ if (typeof content === 'string')
214
+ return content;
215
+ if (!Array.isArray(content))
216
+ return '';
217
+ const parts = [];
218
+ for (const block of content) {
219
+ if (typeof block !== 'object' || block === null)
220
+ continue;
221
+ const b = block;
222
+ if (b['type'] === 'text' && typeof b['text'] === 'string')
223
+ parts.push(b['text']);
224
+ if (b['type'] === 'thinking' && typeof b['thinking'] === 'string')
225
+ parts.push(b['thinking']);
226
+ }
227
+ return parts.join('\n\n');
228
+ }
229
+ function firstToolUse(content) {
230
+ if (!Array.isArray(content))
231
+ return undefined;
232
+ for (const block of content) {
233
+ if (typeof block !== 'object' || block === null)
234
+ continue;
235
+ const b = block;
236
+ if (b['type'] === 'tool_use') {
237
+ return {
238
+ name: typeof b['name'] === 'string' ? b['name'] : undefined,
239
+ id: typeof b['id'] === 'string' ? b['id'] : undefined,
240
+ input: b['input'],
241
+ };
242
+ }
243
+ }
244
+ return undefined;
245
+ }
246
+ function firstToolResult(content) {
247
+ if (!Array.isArray(content))
248
+ return undefined;
249
+ for (const block of content) {
250
+ if (typeof block !== 'object' || block === null)
251
+ continue;
252
+ const b = block;
253
+ if (b['type'] === 'tool_result') {
254
+ return {
255
+ toolUseId: typeof b['tool_use_id'] === 'string' ? b['tool_use_id'] : undefined,
256
+ content: b['content'],
257
+ isError: b['is_error'] === true,
258
+ };
259
+ }
260
+ }
261
+ return undefined;
262
+ }
263
+ /**
264
+ * The records that make up the session, in source order.
265
+ *
266
+ * Three facts about this format decide the algorithm, and getting any of them
267
+ * wrong silently changes what the successor is told:
268
+ *
269
+ * 1. **It is a tree.** `uuid` / `parentUuid` let a rewind or an edit leave the
270
+ * abandoned branch in the file. Replaying in line order would hand a
271
+ * successor work the human explicitly walked away from, so the live branch is
272
+ * resolved by walking parent pointers back from the newest record.
273
+ *
274
+ * 2. **A compaction starts a new root.** `/compact` writes a summary and
275
+ * continues with records whose `parentUuid` is null; the chain genuinely does
276
+ * not cross that boundary. Measured on a real 103,757-event session, walking
277
+ * parents from the last record reached 1,770 records and 7 user turns — the
278
+ * walk stopped at the boundary and discarded every earlier turn, which are
279
+ * the record of what the human actually asked for.
280
+ *
281
+ * 3. **The roots cannot be recognised by looking at them.** In that session the
282
+ * boundary record was `type: system`, and 39,754 records carry a null parent
283
+ * without starting anything. Classifying roots by type was the first attempt
284
+ * and it silently dropped the session back to 853 events.
285
+ *
286
+ * So there is no classification: walk the newest record's parent chain; when the
287
+ * walk stops, take the record immediately *before* the oldest one it reached and
288
+ * walk that chain; repeat. Each pass recovers the tip of one earlier segment.
289
+ * Branch resolution is preserved wherever a rewind happened, history survives
290
+ * every boundary, and a malformed file terminates because the cursor strictly
291
+ * decreases. `--since-compact` keeps the first pass only.
292
+ */
293
+ function resolveActiveBranch(records, byUuid, diagnostics) {
294
+ if (records.length === 0)
295
+ return [];
296
+ const byIndex = new Map(records.map((r) => [r.index, r]));
297
+ const kept = new Map();
298
+ let failedWalks = 0;
299
+ let cursor = records[records.length - 1];
300
+ while (cursor) {
301
+ const chain = new Map();
302
+ const guard = new Set();
303
+ let node = cursor;
304
+ while (node) {
305
+ if (chain.has(node.index))
306
+ break;
307
+ chain.set(node.index, node);
308
+ const parentUuid = node.raw.parentUuid;
309
+ if (!parentUuid)
310
+ break;
311
+ // A cycle would hang the process on a corrupt file.
312
+ if (guard.has(parentUuid)) {
313
+ diagnostics.push({ line: node.index + 1, message: 'parentUuid cycle; walk stopped' });
314
+ break;
315
+ }
316
+ guard.add(parentUuid);
317
+ const parent = byUuid.get(parentUuid);
318
+ if (!parent) {
319
+ // A dangling parent is common when a session is read mid-write or when
320
+ // the provider rewrote the head. Keep what was found and say so.
321
+ failedWalks += 1;
322
+ break;
323
+ }
324
+ node = parent;
325
+ }
326
+ for (const record of chain.values())
327
+ kept.set(record.index, record);
328
+ const oldest = Math.min(...chain.keys());
329
+ const previous = byIndex.get(oldest - 1);
330
+ if (!previous || oldest === 0)
331
+ break;
332
+ diagnostics.push({
333
+ line: 0,
334
+ message: `continuation at record ${oldest + 1}: recovered ${chain.size} record(s) before it and continued`,
335
+ });
336
+ cursor = previous;
337
+ }
338
+ const off = records.length - kept.size;
339
+ if (off > 0) {
340
+ diagnostics.push({
341
+ line: 0,
342
+ message: `${off} record(s) are not on any active branch (rewound or edited) and were skipped`,
343
+ });
344
+ }
345
+ if (failedWalks > 0) {
346
+ diagnostics.push({
347
+ line: 0,
348
+ message: `${failedWalks} parent pointer(s) were dangling; ${kept.size} record(s) kept`,
349
+ });
350
+ }
351
+ return [...kept.values()].sort((a, b) => a.index - b.index);
352
+ }
353
+ async function safeReaddir(path) {
354
+ try {
355
+ return await readdir(path);
356
+ }
357
+ catch {
358
+ return [];
359
+ }
360
+ }
361
+ //# sourceMappingURL=claude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/adapters/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA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AAE,GAAG,GAAG,8EAA8E;SAC9F,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;QACpB,WAAW,CAAC,IAAI,CAAC;YACf,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,GAAG,WAAW,qCAAqC,IAAI,CAAC,IAAI,iBAAiB;SACvF,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAA;AAC7D,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,IAAY;IACrC,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { AgentKind, SessionIR, SessionRef } from '../ir/types.js';
2
+ import type { Adapter, ListOptions, ReadOptions } from './types.js';
3
+ export declare function codexStore(): string;
4
+ export declare class CodexAdapter implements Adapter {
5
+ kind: AgentKind;
6
+ label: string;
7
+ store(): string;
8
+ available(): boolean;
9
+ list(options: ListOptions): Promise<SessionRef[]>;
10
+ read(ref: SessionRef, _options?: ReadOptions): Promise<SessionIR>;
11
+ }