@arcreflex/agent-transcripts 0.1.15 → 0.1.17

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.
@@ -304,23 +304,25 @@ main {
304
304
  color: var(--fg);
305
305
  }
306
306
 
307
- /* Shiki syntax highlighting - dual theme support */
308
- .content .shiki,
309
- .thinking .shiki {
307
+ /* Markdown-highlighted content (Shiki renders as <pre>, but this is prose) */
308
+ .markdown-body pre {
309
+ white-space: pre-wrap;
310
+ overflow-wrap: break-word;
311
+ }
312
+
313
+ .markdown-body .shiki {
310
314
  background: transparent !important;
311
315
  border: none;
312
316
  padding: 0;
313
317
  margin: 0;
314
318
  }
315
319
 
316
- .content .shiki span,
317
- .thinking .shiki span {
320
+ .markdown-body .shiki span {
318
321
  color: var(--shiki-light);
319
322
  }
320
323
 
321
324
  @media (prefers-color-scheme: dark) {
322
- .content .shiki span,
323
- .thinking .shiki span {
325
+ .markdown-body .shiki span {
324
326
  color: var(--shiki-dark);
325
327
  }
326
328
  }
@@ -755,7 +757,7 @@ async function renderMessage(
755
757
  </div>
756
758
  ${msg.rawJson ? renderRawToggle() : ""}
757
759
  <div class="rendered-view">
758
- <div class="content">${await contentToHtml(msg.content)}</div>
760
+ <div class="content markdown-body">${await contentToHtml(msg.content)}</div>
759
761
  </div>
760
762
  ${msg.rawJson ? `<div class="raw-view">${rawJson}</div>` : ""}
761
763
  </div>`;
@@ -767,13 +769,13 @@ async function renderMessage(
767
769
  rendered += `
768
770
  <details>
769
771
  <summary>thinking...</summary>
770
- <div class="thinking">${await contentToHtml(msg.thinking)}</div>
772
+ <div class="thinking markdown-body">${await contentToHtml(msg.thinking)}</div>
771
773
  </details>`;
772
774
  }
773
775
 
774
776
  if (msg.content.trim()) {
775
777
  rendered += `
776
- <div class="content">${await contentToHtml(msg.content)}</div>`;
778
+ <div class="content markdown-body">${await contentToHtml(msg.content)}</div>`;
777
779
  }
778
780
 
779
781
  const header = ctx.showAssistantHeader
package/src/render.ts CHANGED
@@ -6,10 +6,9 @@ import type { Transcript, Message, ToolCall } from "./types.ts";
6
6
  import { walkTranscriptTree } from "./utils/tree.ts";
7
7
 
8
8
  function formatToolCall(call: ToolCall): string {
9
- if (call.summary) {
10
- return `${call.name} \`${call.summary}\``;
11
- }
12
- return call.name;
9
+ const label = call.summary ? `${call.name} \`${call.summary}\`` : call.name;
10
+ const ref = call.id ? ` <!-- tool:${call.id} -->` : "";
11
+ return `${label}${ref}`;
13
12
  }
14
13
 
15
14
  function formatToolCalls(calls: ToolCall[]): string {
@@ -60,13 +59,14 @@ ${msg.thinking}
60
59
  export interface RenderTranscriptOptions {
61
60
  head?: string; // render branch ending at this message ID
62
61
  sourcePath?: string; // absolute source path for front matter provenance
62
+ title?: string; // override the "# Transcript" heading
63
63
  }
64
64
 
65
65
  export function renderTranscript(
66
66
  transcript: Transcript,
67
67
  options: RenderTranscriptOptions = {},
68
68
  ): string {
69
- const { head, sourcePath } = options;
69
+ const { head, sourcePath, title } = options;
70
70
 
71
71
  const lines: string[] = [];
72
72
 
@@ -79,7 +79,7 @@ export function renderTranscript(
79
79
  }
80
80
 
81
81
  // Header
82
- lines.push("# Transcript");
82
+ lines.push(`# ${title || "Transcript"}`);
83
83
  lines.push("");
84
84
  lines.push(`**Source**: \`${transcript.source.file}\``);
85
85
  lines.push(`**Adapter**: ${transcript.source.adapter}`);
package/src/serve.ts CHANGED
@@ -1,14 +1,20 @@
1
1
  /**
2
2
  * Serve command: HTTP server for transcripts from the archive.
3
3
  *
4
- * Reads archive entries, renders HTML on demand with in-memory LRU cache.
4
+ * Reads archive entries, renders on demand in multiple formats:
5
+ * - .html — rich HTML rendering (LRU cached, shiki highlighting)
6
+ * - .md — markdown (lightweight, agent-friendly)
7
+ * - .json — raw transcript data
5
8
  */
6
9
 
7
10
  import type { ArchiveEntryHeader, TranscriptSummary } from "./archive.ts";
8
11
  import { listEntryHeaders, loadEntry, DEFAULT_ARCHIVE_DIR } from "./archive.ts";
12
+ import type { Transcript } from "./types.ts";
9
13
  import { renderTranscriptHtml } from "./render-html.ts";
14
+ import { renderTranscript } from "./render.ts";
10
15
  import { renderIndexFromSessions, type SessionEntry } from "./render-index.ts";
11
16
  import { formatDateTimePrefix } from "./utils/naming.ts";
17
+ import { truncate } from "./utils/text.ts";
12
18
 
13
19
  export interface ServeOptions {
14
20
  archiveDir?: string;
@@ -25,6 +31,14 @@ interface SessionInfo {
25
31
  baseName: string;
26
32
  }
27
33
 
34
+ type Format = "html" | "md" | "json";
35
+
36
+ const CONTENT_TYPES: Record<Format, string> = {
37
+ html: "text/html; charset=utf-8",
38
+ md: "text/markdown; charset=utf-8",
39
+ json: "application/json; charset=utf-8",
40
+ };
41
+
28
42
  /** Simple LRU cache for rendered HTML. */
29
43
  class HtmlCache {
30
44
  private map = new Map<string, string>();
@@ -93,23 +107,24 @@ function buildSessionMap(
93
107
  return sessions;
94
108
  }
95
109
 
110
+ function sessionTitle(info: SessionInfo): string {
111
+ return (
112
+ info.title || truncate(info.segment.firstUserMessage, 80) || info.baseName
113
+ );
114
+ }
115
+
96
116
  function buildIndexEntries(sessions: Map<string, SessionInfo>): SessionEntry[] {
97
117
  const entries: SessionEntry[] = [];
98
118
 
99
119
  for (const [baseName, info] of sessions) {
100
- const { segment, title } = info;
120
+ const { segment } = info;
101
121
  if (segment.metadata.messageCount === 0) continue;
102
122
 
103
123
  const { messageCount, startTime, endTime, cwd } = segment.metadata;
104
124
 
105
125
  entries.push({
106
126
  filename: `${baseName}.html`,
107
- title:
108
- title ||
109
- (segment.firstUserMessage.length > 80
110
- ? segment.firstUserMessage.slice(0, 80) + "..."
111
- : segment.firstUserMessage) ||
112
- baseName,
127
+ title: sessionTitle(info),
113
128
  firstUserMessage: segment.firstUserMessage,
114
129
  date: startTime,
115
130
  endDate: endTime,
@@ -121,6 +136,128 @@ function buildIndexEntries(sessions: Map<string, SessionInfo>): SessionEntry[] {
121
136
  return entries;
122
137
  }
123
138
 
139
+ // ============================================================================
140
+ // Format-specific renderers
141
+ // ============================================================================
142
+
143
+ function renderTranscriptMd(
144
+ transcript: Transcript,
145
+ baseName: string,
146
+ title: string,
147
+ ): string {
148
+ const nav = `*→ [html](${baseName}.html) · [json](${baseName}.json)*`;
149
+ const md = renderTranscript(transcript, { title });
150
+ // Insert format links after the title line
151
+ return md.replace(/^(# .+)\n/, `$1\n\n${nav}\n`);
152
+ }
153
+
154
+ function renderTranscriptJson(transcript: Transcript): string {
155
+ return JSON.stringify(transcript, null, 2);
156
+ }
157
+
158
+ function renderIndexMd(sessions: Map<string, SessionInfo>): string {
159
+ const sorted = [...sessions.entries()]
160
+ .filter(([, info]) => info.segment.metadata.messageCount > 0)
161
+ .sort(
162
+ (a, b) =>
163
+ new Date(b[1].segment.metadata.startTime).getTime() -
164
+ new Date(a[1].segment.metadata.startTime).getTime(),
165
+ );
166
+
167
+ const lines: string[] = [
168
+ "# Agent Transcripts",
169
+ "",
170
+ `${sorted.length} session${sorted.length !== 1 ? "s" : ""}`,
171
+ "",
172
+ "*→ [html](index.html) · [json](index.json)*",
173
+ "",
174
+ ];
175
+
176
+ // Group by cwd
177
+ const groups = new Map<string, [string, SessionInfo][]>();
178
+ for (const entry of sorted) {
179
+ const cwd = entry[1].segment.metadata.cwd || "(unknown)";
180
+ const group = groups.get(cwd) || [];
181
+ group.push(entry);
182
+ groups.set(cwd, group);
183
+ }
184
+
185
+ for (const [cwd, entries] of groups) {
186
+ lines.push(`## ${cwd}`, "");
187
+ for (const [baseName, info] of entries) {
188
+ const title = sessionTitle(info);
189
+ const msgs = info.segment.metadata.messageCount;
190
+ const preview = truncate(info.segment.firstUserMessage, 100);
191
+ lines.push(`- [${title}](${baseName}.md) — ${msgs} msgs`);
192
+ if (preview) {
193
+ lines.push(` > ${preview}`);
194
+ }
195
+ }
196
+ lines.push("");
197
+ }
198
+
199
+ return lines.join("\n");
200
+ }
201
+
202
+ interface IndexJsonSession {
203
+ title: string;
204
+ links: { html: string; md: string; json: string };
205
+ date: string;
206
+ endDate: string;
207
+ messageCount: number;
208
+ cwd?: string;
209
+ firstUserMessage: string;
210
+ }
211
+
212
+ function renderIndexJson(sessions: Map<string, SessionInfo>): string {
213
+ const sorted = [...sessions.entries()]
214
+ .filter(([, info]) => info.segment.metadata.messageCount > 0)
215
+ .sort(
216
+ (a, b) =>
217
+ new Date(b[1].segment.metadata.startTime).getTime() -
218
+ new Date(a[1].segment.metadata.startTime).getTime(),
219
+ );
220
+
221
+ const result: IndexJsonSession[] = sorted.map(([baseName, info]) => ({
222
+ title: sessionTitle(info),
223
+ links: {
224
+ html: `${baseName}.html`,
225
+ md: `${baseName}.md`,
226
+ json: `${baseName}.json`,
227
+ },
228
+ date: info.segment.metadata.startTime,
229
+ endDate: info.segment.metadata.endTime,
230
+ messageCount: info.segment.metadata.messageCount,
231
+ cwd: info.segment.metadata.cwd,
232
+ firstUserMessage: info.segment.firstUserMessage,
233
+ }));
234
+
235
+ return JSON.stringify({ sessions: result }, null, 2);
236
+ }
237
+
238
+ // ============================================================================
239
+ // Server
240
+ // ============================================================================
241
+
242
+ /** Parse a URL path into baseName + format, or null if unrecognized. */
243
+ function parseRoute(
244
+ path: string,
245
+ ):
246
+ | { type: "index"; format: Format }
247
+ | { type: "session"; baseName: string; format: Format }
248
+ | null {
249
+ if (path === "/") return { type: "index", format: "html" };
250
+
251
+ const match = path.match(/^\/(.+)\.(html|md|json)$/);
252
+ if (!match) return null;
253
+
254
+ const [, name, ext] = match;
255
+ const format = ext as Format;
256
+
257
+ if (name === "index") return { type: "index", format };
258
+ return { type: "session", baseName: name, format };
259
+ }
260
+
124
261
  export async function serve(options: ServeOptions): Promise<void> {
125
262
  const {
126
263
  archiveDir = DEFAULT_ARCHIVE_DIR,
@@ -136,8 +273,10 @@ export async function serve(options: ServeOptions): Promise<void> {
136
273
  const sessions = buildSessionMap(headers);
137
274
  const htmlCache = new HtmlCache(200);
138
275
 
139
- // Index is static (session map doesn't change), so build once
276
+ // Index HTML is static (session map doesn't change), so build once
140
277
  const indexHtml = renderIndexFromSessions(buildIndexEntries(sessions));
278
+ const indexMd = renderIndexMd(sessions);
279
+ const indexJson = renderIndexJson(sessions);
141
280
 
142
281
  if (!quiet) {
143
282
  console.error(`Found ${sessions.size} transcript(s)`);
@@ -148,58 +287,76 @@ export async function serve(options: ServeOptions): Promise<void> {
148
287
  port,
149
288
  async fetch(req) {
150
289
  const url = new URL(req.url);
151
- const path = url.pathname;
290
+ const route = parseRoute(url.pathname);
152
291
 
153
292
  if (!quiet) {
154
- console.error(`${req.method} ${path}`);
293
+ console.error(`${req.method} ${url.pathname}`);
155
294
  }
156
295
 
157
- // Index page
158
- if (path === "/" || path === "/index.html") {
159
- return new Response(indexHtml, {
160
- headers: { "Content-Type": "text/html; charset=utf-8" },
296
+ if (!route) {
297
+ return new Response("Not Found", { status: 404 });
298
+ }
299
+
300
+ // Index
301
+ if (route.type === "index") {
302
+ const body =
303
+ route.format === "html"
304
+ ? indexHtml
305
+ : route.format === "md"
306
+ ? indexMd
307
+ : indexJson;
308
+ return new Response(body, {
309
+ headers: { "Content-Type": CONTENT_TYPES[route.format] },
161
310
  });
162
311
  }
163
312
 
164
- // Session page
165
- if (path.endsWith(".html")) {
166
- const baseName = path.slice(1, -5);
167
- const info = sessions.get(baseName);
168
-
169
- if (info) {
170
- try {
171
- const { sessionId, segmentIndex, sourceHash, title } = info;
172
-
173
- const cached = htmlCache.get(sessionId, segmentIndex, sourceHash);
174
- if (cached) {
175
- return new Response(cached, {
176
- headers: { "Content-Type": "text/html; charset=utf-8" },
177
- });
178
- }
179
-
180
- // Load full entry from disk on demand
181
- const entry = await loadEntry(archiveDir, sessionId);
182
- const transcript = entry?.transcripts[segmentIndex];
183
- if (!transcript) {
184
- return new Response("Not Found", { status: 404 });
185
- }
186
-
187
- const html = await renderTranscriptHtml(transcript, { title });
188
- htmlCache.set(sessionId, segmentIndex, sourceHash, html);
189
- return new Response(html, {
190
- headers: { "Content-Type": "text/html; charset=utf-8" },
313
+ // Session
314
+ const info = sessions.get(route.baseName);
315
+ if (!info) {
316
+ return new Response("Not Found", { status: 404 });
317
+ }
318
+
319
+ try {
320
+ const { sessionId, segmentIndex, sourceHash } = info;
321
+ const title = sessionTitle(info);
322
+
323
+ // HTML — use LRU cache (shiki rendering is expensive)
324
+ if (route.format === "html") {
325
+ const cached = htmlCache.get(sessionId, segmentIndex, sourceHash);
326
+ if (cached) {
327
+ return new Response(cached, {
328
+ headers: { "Content-Type": CONTENT_TYPES.html },
191
329
  });
192
- } catch (error) {
193
- const message =
194
- error instanceof Error ? error.message : String(error);
195
- return new Response(`Error: ${message}`, { status: 500 });
196
330
  }
331
+
332
+ const entry = await loadEntry(archiveDir, sessionId);
333
+ const transcript = entry?.transcripts[segmentIndex];
334
+ if (!transcript) return new Response("Not Found", { status: 404 });
335
+
336
+ const html = await renderTranscriptHtml(transcript, { title });
337
+ htmlCache.set(sessionId, segmentIndex, sourceHash, html);
338
+ return new Response(html, {
339
+ headers: { "Content-Type": CONTENT_TYPES.html },
340
+ });
197
341
  }
198
342
 
199
- return new Response("Not Found", { status: 404 });
200
- }
343
+ // Markdown and JSON render on demand (cheap)
344
+ const entry = await loadEntry(archiveDir, sessionId);
345
+ const transcript = entry?.transcripts[segmentIndex];
346
+ if (!transcript) return new Response("Not Found", { status: 404 });
347
+
348
+ const body =
349
+ route.format === "md"
350
+ ? renderTranscriptMd(transcript, route.baseName, title)
351
+ : renderTranscriptJson(transcript);
201
352
 
202
- return new Response("Not Found", { status: 404 });
353
+ return new Response(body, {
354
+ headers: { "Content-Type": CONTENT_TYPES[route.format] },
355
+ });
356
+ } catch (error) {
357
+ const message = error instanceof Error ? error.message : String(error);
358
+ return new Response(`Error: ${message}`, { status: 500 });
359
+ }
203
360
  },
204
361
  });
205
362
 
package/src/types.ts CHANGED
@@ -60,6 +60,7 @@ export interface ToolCallGroup extends BaseMessage {
60
60
  }
61
61
 
62
62
  export interface ToolCall {
63
+ id?: string;
63
64
  name: string;
64
65
  summary: string;
65
66
  input?: Record<string, unknown>;
@@ -7,9 +7,9 @@ import { truncate } from "./text.ts";
7
7
  type ToolInput = Record<string, unknown>;
8
8
 
9
9
  const extractors: Record<string, (input: ToolInput) => string> = {
10
- Read: (i) => String(i.file_path || ""),
11
- Write: (i) => String(i.file_path || ""),
12
- Edit: (i) => String(i.file_path || ""),
10
+ Read: (i) => String(i.file_path || i.path || ""),
11
+ Write: (i) => String(i.file_path || i.path || ""),
12
+ Edit: (i) => String(i.file_path || i.path || ""),
13
13
  Bash: (i) => {
14
14
  if (i.description) return String(i.description);
15
15
  if (i.command) return truncate(String(i.command), 60);
@@ -1,6 +1,11 @@
1
1
  import { describe, expect, it } from "bun:test";
2
- import { getDefaultSources, getAdapter } from "../src/adapters/index.ts";
2
+ import {
3
+ getDefaultSources,
4
+ getAdapter,
5
+ detectAdapter,
6
+ } from "../src/adapters/index.ts";
3
7
  import { claudeCodeAdapter } from "../src/adapters/claude-code.ts";
8
+ import { piCodingAgentAdapter } from "../src/adapters/pi-coding-agent.ts";
4
9
 
5
10
  describe("getDefaultSources", () => {
6
11
  it("returns claude-code with its defaultSource", () => {
@@ -14,6 +19,14 @@ describe("getDefaultSources", () => {
14
19
  expect(cc?.source.length).toBeGreaterThan(0);
15
20
  });
16
21
 
22
+ it("returns pi-coding-agent with its defaultSource", () => {
23
+ const specs = getDefaultSources();
24
+ const pi = specs.find((s) => s.adapter.name === "pi-coding-agent");
25
+ expect(pi).toBeDefined();
26
+ expect(pi?.adapter).toBe(piCodingAgentAdapter);
27
+ expect(pi?.source).toMatch(/\.pi[/\\]agent[/\\]sessions$/);
28
+ });
29
+
17
30
  it("only includes adapters with defaultSource set", () => {
18
31
  for (const spec of getDefaultSources()) {
19
32
  expect(spec.source).toBeTruthy();
@@ -24,9 +37,30 @@ describe("getDefaultSources", () => {
24
37
  describe("getAdapter", () => {
25
38
  it("returns adapter by name", () => {
26
39
  expect(getAdapter("claude-code")).toBe(claudeCodeAdapter);
40
+ expect(getAdapter("pi-coding-agent")).toBe(piCodingAgentAdapter);
27
41
  });
28
42
 
29
43
  it("returns undefined for unknown adapter", () => {
30
44
  expect(getAdapter("nonexistent")).toBeUndefined();
31
45
  });
32
46
  });
47
+
48
+ describe("detectAdapter", () => {
49
+ it("detects claude-code from .claude/ paths", () => {
50
+ expect(detectAdapter("/home/user/.claude/projects/foo/session.jsonl")).toBe(
51
+ "claude-code",
52
+ );
53
+ });
54
+
55
+ it("detects pi-coding-agent from .pi/agent/sessions/ paths", () => {
56
+ expect(
57
+ detectAdapter(
58
+ "/home/user/.pi/agent/sessions/--project--/12345_abc.jsonl",
59
+ ),
60
+ ).toBe("pi-coding-agent");
61
+ });
62
+
63
+ it("returns undefined for unrecognized paths", () => {
64
+ expect(detectAdapter("/tmp/random/file.jsonl")).toBeUndefined();
65
+ });
66
+ });
@@ -10,6 +10,6 @@
10
10
  Check the files
11
11
 
12
12
  **Tools**:
13
- - Read `/src/main.ts`
14
- - Glob `**/*.test.ts`
15
- - Bash `List files`
13
+ - Read `/src/main.ts` <!-- tool:tool-1 -->
14
+ - Glob `**/*.test.ts` <!-- tool:tool-2 -->
15
+ - Bash `List files` <!-- tool:tool-3 -->
@@ -13,7 +13,7 @@ Read the config file
13
13
 
14
14
  I'll read the config file for you.
15
15
 
16
- **Tool**: Read `/project/config.json`
16
+ **Tool**: Read `/project/config.json` <!-- tool:tool-1 -->
17
17
 
18
18
  ## Assistant
19
19
 
@@ -13,4 +13,4 @@ Read the config file
13
13
 
14
14
  I'll read the config file for you.
15
15
 
16
- **Tool**: Read `/project/config.json`
16
+ **Tool**: Read `/project/config.json` <!-- tool:tool-1 -->
@@ -0,0 +1,5 @@
1
+ {"type":"session","version":3,"id":"abc-123","timestamp":"2024-12-03T14:00:00.000Z","cwd":"/home/user/project"}
2
+ {"type":"message","id":"a1b2c3d4","parentId":null,"timestamp":"2024-12-03T14:00:01.000Z","message":{"role":"user","content":"Hello, can you help me with TypeScript?","timestamp":1733234401000}}
3
+ {"type":"message","id":"b2c3d4e5","parentId":"a1b2c3d4","timestamp":"2024-12-03T14:00:05.000Z","message":{"role":"assistant","content":[{"type":"text","text":"Of course! I'd be happy to help with TypeScript. What do you need?"}],"provider":"anthropic","model":"claude-sonnet-4-5","api":"messages","stopReason":"stop","usage":{"input":100,"output":20,"cacheRead":0,"cacheWrite":0,"totalTokens":120,"cost":{"input":0.001,"output":0.001,"cacheRead":0,"cacheWrite":0,"total":0.002}},"timestamp":1733234405000}}
4
+ {"type":"message","id":"c3d4e5f6","parentId":"b2c3d4e5","timestamp":"2024-12-03T14:00:30.000Z","message":{"role":"user","content":"How do I define a generic type?","timestamp":1733234430000}}
5
+ {"type":"message","id":"d4e5f6g7","parentId":"c3d4e5f6","timestamp":"2024-12-03T14:00:35.000Z","message":{"role":"assistant","content":[{"type":"text","text":"You can define a generic type using angle brackets:\n\n```typescript\ntype Result<T> = { ok: true; value: T } | { ok: false; error: string };\n```\n\nThe `T` is a type parameter that gets filled in when you use the type."}],"provider":"anthropic","model":"claude-sonnet-4-5","api":"messages","stopReason":"stop","usage":{"input":150,"output":50,"cacheRead":0,"cacheWrite":0,"totalTokens":200,"cost":{"input":0.002,"output":0.002,"cacheRead":0,"cacheWrite":0,"total":0.004}},"timestamp":1733234435000}}
@@ -0,0 +1,28 @@
1
+ # Transcript
2
+
3
+ **Source**: `test/fixtures/pi-coding-agent/basic-conversation.input.jsonl`
4
+ **Adapter**: pi-coding-agent
5
+
6
+ ---
7
+
8
+ ## User
9
+
10
+ Hello, can you help me with TypeScript?
11
+
12
+ ## Assistant
13
+
14
+ Of course! I'd be happy to help with TypeScript. What do you need?
15
+
16
+ ## User
17
+
18
+ How do I define a generic type?
19
+
20
+ ## Assistant
21
+
22
+ You can define a generic type using angle brackets:
23
+
24
+ ```typescript
25
+ type Result<T> = { ok: true; value: T } | { ok: false; error: string };
26
+ ```
27
+
28
+ The `T` is a type parameter that gets filled in when you use the type.
@@ -0,0 +1,7 @@
1
+ {"type":"session","version":3,"id":"branch-001","timestamp":"2024-12-03T17:00:00.000Z","cwd":"/home/user/project"}
2
+ {"type":"message","id":"g1000001","parentId":null,"timestamp":"2024-12-03T17:00:01.000Z","message":{"role":"user","content":"Help me pick a web framework","timestamp":1733245201000}}
3
+ {"type":"message","id":"g2000002","parentId":"g1000001","timestamp":"2024-12-03T17:00:05.000Z","message":{"role":"assistant","content":[{"type":"text","text":"I'd recommend considering a few options. What are your priorities?"}],"provider":"anthropic","model":"claude-sonnet-4-5","api":"messages","stopReason":"stop","usage":{"input":100,"output":20,"cacheRead":0,"cacheWrite":0,"totalTokens":120,"cost":{"input":0.001,"output":0.001,"cacheRead":0,"cacheWrite":0,"total":0.002}},"timestamp":1733245205000}}
4
+ {"type":"message","id":"g3000003","parentId":"g2000002","timestamp":"2024-12-03T17:00:30.000Z","message":{"role":"user","content":"I want something with great TypeScript support","timestamp":1733245230000}}
5
+ {"type":"message","id":"g4000004","parentId":"g3000003","timestamp":"2024-12-03T17:00:35.000Z","message":{"role":"assistant","content":[{"type":"text","text":"For great TypeScript support, I'd suggest Next.js or SvelteKit."}],"provider":"anthropic","model":"claude-sonnet-4-5","api":"messages","stopReason":"stop","usage":{"input":150,"output":20,"cacheRead":0,"cacheWrite":0,"totalTokens":170,"cost":{"input":0.002,"output":0.001,"cacheRead":0,"cacheWrite":0,"total":0.003}},"timestamp":1733245235000}}
6
+ {"type":"message","id":"g5000005","parentId":"g2000002","timestamp":"2024-12-03T17:01:00.000Z","message":{"role":"user","content":"I want something minimal and fast","timestamp":1733245260000}}
7
+ {"type":"message","id":"g6000006","parentId":"g5000005","timestamp":"2024-12-03T17:01:05.000Z","message":{"role":"assistant","content":[{"type":"text","text":"For minimal and fast, check out Hono or Elysia — both are lightweight and performant."}],"provider":"anthropic","model":"claude-sonnet-4-5","api":"messages","stopReason":"stop","usage":{"input":150,"output":25,"cacheRead":0,"cacheWrite":0,"totalTokens":175,"cost":{"input":0.002,"output":0.001,"cacheRead":0,"cacheWrite":0,"total":0.003}},"timestamp":1733245265000}}
@@ -0,0 +1,25 @@
1
+ # Transcript
2
+
3
+ **Source**: `test/fixtures/pi-coding-agent/branching.input.jsonl`
4
+ **Adapter**: pi-coding-agent
5
+
6
+ ---
7
+
8
+ ## User
9
+
10
+ Help me pick a web framework
11
+
12
+ ## Assistant
13
+
14
+ I'd recommend considering a few options. What are your priorities?
15
+
16
+ > **Other branches**:
17
+ > - `g3000003` "I want something with great TypeScript support"
18
+
19
+ ## User
20
+
21
+ I want something minimal and fast
22
+
23
+ ## Assistant
24
+
25
+ For minimal and fast, check out Hono or Elysia — both are lightweight and performant.
@@ -0,0 +1,7 @@
1
+ {"type":"session","version":3,"id":"compact-001","timestamp":"2024-12-03T18:00:00.000Z","cwd":"/home/user/project"}
2
+ {"type":"message","id":"h1000001","parentId":null,"timestamp":"2024-12-03T18:00:01.000Z","message":{"role":"user","content":"Start a new project","timestamp":1733248801000}}
3
+ {"type":"message","id":"h2000002","parentId":"h1000001","timestamp":"2024-12-03T18:00:05.000Z","message":{"role":"assistant","content":[{"type":"text","text":"Sure, I'll set up a new project for you."}],"provider":"anthropic","model":"claude-sonnet-4-5","api":"messages","stopReason":"stop","usage":{"input":100,"output":15,"cacheRead":0,"cacheWrite":0,"totalTokens":115,"cost":{"input":0.001,"output":0.001,"cacheRead":0,"cacheWrite":0,"total":0.002}},"timestamp":1733248805000}}
4
+ {"type":"compaction","id":"h3000003","parentId":"h2000002","timestamp":"2024-12-03T18:05:00.000Z","summary":"User asked to start a new project. Assistant agreed and began setup.","firstKeptEntryId":"h2000002","tokensBefore":5000}
5
+ {"type":"model_change","id":"h4000004","parentId":"h3000003","timestamp":"2024-12-03T18:05:01.000Z","provider":"openai","modelId":"gpt-4o"}
6
+ {"type":"message","id":"h5000005","parentId":"h4000004","timestamp":"2024-12-03T18:05:30.000Z","message":{"role":"user","content":"Now add a test framework","timestamp":1733249130000}}
7
+ {"type":"message","id":"h6000006","parentId":"h5000005","timestamp":"2024-12-03T18:05:35.000Z","message":{"role":"assistant","content":[{"type":"text","text":"I'll add vitest as the test framework."}],"provider":"openai","model":"gpt-4o","api":"chat","stopReason":"stop","usage":{"input":200,"output":15,"cacheRead":0,"cacheWrite":0,"totalTokens":215,"cost":{"input":0.002,"output":0.001,"cacheRead":0,"cacheWrite":0,"total":0.003}},"timestamp":1733249135000}}
@@ -0,0 +1,28 @@
1
+ # Transcript
2
+
3
+ **Source**: `test/fixtures/pi-coding-agent/with-compaction.input.jsonl`
4
+ **Adapter**: pi-coding-agent
5
+
6
+ ---
7
+
8
+ ## User
9
+
10
+ Start a new project
11
+
12
+ ## Assistant
13
+
14
+ Sure, I'll set up a new project for you.
15
+
16
+ ## System
17
+
18
+ ```
19
+ [Compaction] User asked to start a new project. Assistant agreed and began setup.
20
+ ```
21
+
22
+ ## User
23
+
24
+ Now add a test framework
25
+
26
+ ## Assistant
27
+
28
+ I'll add vitest as the test framework.
@@ -0,0 +1,3 @@
1
+ {"type":"session","version":3,"id":"ghi-789","timestamp":"2024-12-03T16:00:00.000Z","cwd":"/home/user/project"}
2
+ {"type":"message","id":"f1000001","parentId":null,"timestamp":"2024-12-03T16:00:01.000Z","message":{"role":"user","content":"What's the best sorting algorithm for nearly-sorted data?","timestamp":1733241601000}}
3
+ {"type":"message","id":"f2000002","parentId":"f1000001","timestamp":"2024-12-03T16:00:05.000Z","message":{"role":"assistant","content":[{"type":"thinking","thinking":"The user is asking about sorting algorithms for nearly-sorted data. Insertion sort is O(n) for nearly sorted data, which makes it ideal. Timsort also handles this well since it detects runs."},{"type":"text","text":"For nearly-sorted data, **insertion sort** is excellent — it runs in O(n) time when the data is almost sorted. Python's built-in Timsort also handles this case well since it detects existing sorted runs."}],"provider":"anthropic","model":"claude-sonnet-4-5","api":"messages","stopReason":"stop","usage":{"input":100,"output":80,"cacheRead":0,"cacheWrite":0,"totalTokens":180,"cost":{"input":0.001,"output":0.003,"cacheRead":0,"cacheWrite":0,"total":0.004}},"timestamp":1733241605000}}