pi-forge 1.2.0 → 1.2.2
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/README.md +1 -1
- package/dist/client/assets/{CodeMirrorEditor-DXdXoCjw.js → CodeMirrorEditor-BwTPp-8p.js} +2 -2
- package/dist/client/assets/{CodeMirrorEditor-DXdXoCjw.js.map → CodeMirrorEditor-BwTPp-8p.js.map} +1 -1
- package/dist/client/assets/{index-DRa0fybV.js → index--G_jkVyP.js} +71 -71
- package/dist/client/assets/index--G_jkVyP.js.map +1 -0
- package/dist/client/assets/index-B4ryaCak.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.map +1 -1
- package/dist/server/git-hunk-stager.js +137 -0
- package/dist/server/git-hunk-stager.js.map +1 -0
- package/dist/server/index.js +4 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/export.js +66 -0
- package/dist/server/routes/export.js.map +1 -0
- package/dist/server/routes/git.js +61 -0
- package/dist/server/routes/git.js.map +1 -1
- package/dist/server/routes/search.js +108 -0
- package/dist/server/routes/search.js.map +1 -0
- package/dist/server/session-exporter.js +490 -0
- package/dist/server/session-exporter.js.map +1 -0
- package/dist/server/session-searcher.js +490 -0
- package/dist/server/session-searcher.js.map +1 -0
- package/package.json +1 -1
- package/dist/client/assets/index-DRa0fybV.js.map +0 -1
- package/dist/client/assets/index-b30wYoh-.css +0 -1
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { discoverSessionsOnDisk, findSessionLocation } from "./session-registry.js";
|
|
4
|
+
import { getProject, readProjects } from "./project-manager.js";
|
|
5
|
+
/**
|
|
6
|
+
* Single-session exporter. Two output formats:
|
|
7
|
+
*
|
|
8
|
+
* - **JSONL** — the raw on-disk session JSONL with subagent child
|
|
9
|
+
* JSONLs inlined between the parent's `subagent` tool call and its
|
|
10
|
+
* matching tool result. Inline boundaries use synthetic envelope
|
|
11
|
+
* types `subagent_inline_start` / `subagent_inline_end` so SDK
|
|
12
|
+
* consumers that don't understand them treat them as unknown and
|
|
13
|
+
* skip (matching the SDK's own forward-compat policy).
|
|
14
|
+
* - **Markdown** — a flat human-readable transcript: user / assistant
|
|
15
|
+
* bubbles, tool calls as fenced code blocks, tool results as
|
|
16
|
+
* blockquotes (capped at TOOL_RESULT_CAP bytes per result).
|
|
17
|
+
* Subagent children render nested at h3 under the parent's tool
|
|
18
|
+
* call section.
|
|
19
|
+
*
|
|
20
|
+
* Sub-agent matching is **positional**: the Nth `subagent` tool call
|
|
21
|
+
* gets the Nth chronologically-sorted child. pi-subagents creates the
|
|
22
|
+
* child JSONL at tool invocation time so this ordering holds in
|
|
23
|
+
* practice. Mismatched counts (e.g. a failed call that never spawned
|
|
24
|
+
* a child) inline what we have and skip the rest — better than
|
|
25
|
+
* pretending the data isn't there.
|
|
26
|
+
*/
|
|
27
|
+
/** Soft cap per tool-result rendering in markdown — keeps exports skim-able. */
|
|
28
|
+
const TOOL_RESULT_CAP = 2_000;
|
|
29
|
+
export class SessionNotFoundError extends Error {
|
|
30
|
+
constructor(sessionId) {
|
|
31
|
+
super(`session ${sessionId} not found`);
|
|
32
|
+
this.name = "SessionNotFoundError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Locate a session by id. Walks every project's on-disk session dir
|
|
37
|
+
* (delegating to `discoverSessionsOnDisk` so subagent children are
|
|
38
|
+
* resolvable too) and returns the discovered metadata for the match.
|
|
39
|
+
*/
|
|
40
|
+
async function findSessionFile(sessionId) {
|
|
41
|
+
const loc = await findSessionLocation(sessionId);
|
|
42
|
+
if (loc === undefined)
|
|
43
|
+
return undefined;
|
|
44
|
+
const discovered = await discoverSessionsOnDisk(loc.projectId, loc.workspacePath);
|
|
45
|
+
const match = discovered.find((d) => d.sessionId === sessionId);
|
|
46
|
+
if (match === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
const out = {
|
|
49
|
+
filePath: match.path,
|
|
50
|
+
projectId: loc.projectId,
|
|
51
|
+
workspacePath: loc.workspacePath,
|
|
52
|
+
};
|
|
53
|
+
if (match.name !== undefined)
|
|
54
|
+
out.sessionName = match.name;
|
|
55
|
+
if (match.parentSessionId !== undefined)
|
|
56
|
+
out.parentSessionId = match.parentSessionId;
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Discover and chronologically-sort the subagent children of `parentSessionId`
|
|
61
|
+
* within the same project. Returns `[]` for sessions with no children,
|
|
62
|
+
* including sessions that ARE themselves children (we don't recurse beyond
|
|
63
|
+
* one level — see the module doc).
|
|
64
|
+
*/
|
|
65
|
+
async function loadChildSessions(parentSessionId, projectId, workspacePath) {
|
|
66
|
+
const discovered = await discoverSessionsOnDisk(projectId, workspacePath);
|
|
67
|
+
const children = discovered
|
|
68
|
+
.filter((d) => d.parentSessionId === parentSessionId)
|
|
69
|
+
.map((d) => ({ sessionId: d.sessionId, filePath: d.path, createdAt: d.createdAt }))
|
|
70
|
+
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
71
|
+
return children;
|
|
72
|
+
}
|
|
73
|
+
/* ----------------------------- JSONL export ----------------------------- */
|
|
74
|
+
export async function exportAsJsonl(sessionId) {
|
|
75
|
+
const located = await findSessionFile(sessionId);
|
|
76
|
+
if (located === undefined)
|
|
77
|
+
throw new SessionNotFoundError(sessionId);
|
|
78
|
+
const parentContent = await readFile(located.filePath, "utf8");
|
|
79
|
+
const parentLines = splitLines(parentContent);
|
|
80
|
+
// For child sessions, no further inlining — return the file as-is.
|
|
81
|
+
// The user is exporting "this conversation" and the child is already
|
|
82
|
+
// a complete conversation in itself.
|
|
83
|
+
const isChild = located.parentSessionId !== undefined;
|
|
84
|
+
if (isChild) {
|
|
85
|
+
return {
|
|
86
|
+
content: parentContent.endsWith("\n") ? parentContent : parentContent + "\n",
|
|
87
|
+
filename: filenameFor(located.sessionName ?? sessionId, "jsonl"),
|
|
88
|
+
contentType: "application/x-ndjson",
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const children = await loadChildSessions(sessionId, located.projectId, located.workspacePath);
|
|
92
|
+
// Pre-load every child's content so the inline pass doesn't await
|
|
93
|
+
// per-line. Children typically count in the single digits.
|
|
94
|
+
const childContents = await Promise.all(children.map(async (c) => ({ ...c, lines: splitLines(await readFile(c.filePath, "utf8")) })));
|
|
95
|
+
// Walk the parent's lines; when we see an assistant message with a
|
|
96
|
+
// `subagent` tool-call block, immediately after the parent line emit
|
|
97
|
+
// the next child's full JSONL bracketed by inline-boundary envelopes.
|
|
98
|
+
const out = [];
|
|
99
|
+
let childCursor = 0;
|
|
100
|
+
for (const line of parentLines) {
|
|
101
|
+
out.push(line);
|
|
102
|
+
const callId = subagentToolCallIdFromLine(line);
|
|
103
|
+
if (callId === undefined)
|
|
104
|
+
continue;
|
|
105
|
+
const child = childContents[childCursor];
|
|
106
|
+
if (child === undefined)
|
|
107
|
+
continue;
|
|
108
|
+
childCursor += 1;
|
|
109
|
+
out.push(JSON.stringify({
|
|
110
|
+
type: "subagent_inline_start",
|
|
111
|
+
parentToolCallId: callId,
|
|
112
|
+
childSessionId: child.sessionId,
|
|
113
|
+
}));
|
|
114
|
+
for (const childLine of child.lines)
|
|
115
|
+
out.push(childLine);
|
|
116
|
+
out.push(JSON.stringify({
|
|
117
|
+
type: "subagent_inline_end",
|
|
118
|
+
childSessionId: child.sessionId,
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
// Trailing-orphan children (counts didn't match): append them at the
|
|
122
|
+
// tail wrapped in the same envelope. Better to surface than to drop.
|
|
123
|
+
for (let i = childCursor; i < childContents.length; i++) {
|
|
124
|
+
const child = childContents[i];
|
|
125
|
+
if (child === undefined)
|
|
126
|
+
continue;
|
|
127
|
+
out.push(JSON.stringify({
|
|
128
|
+
type: "subagent_inline_start",
|
|
129
|
+
parentToolCallId: null,
|
|
130
|
+
childSessionId: child.sessionId,
|
|
131
|
+
note: "orphaned — no matching parent tool call",
|
|
132
|
+
}));
|
|
133
|
+
for (const childLine of child.lines)
|
|
134
|
+
out.push(childLine);
|
|
135
|
+
out.push(JSON.stringify({
|
|
136
|
+
type: "subagent_inline_end",
|
|
137
|
+
childSessionId: child.sessionId,
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
content: out.join("\n") + "\n",
|
|
142
|
+
filename: filenameFor(located.sessionName ?? sessionId, "jsonl"),
|
|
143
|
+
contentType: "application/x-ndjson",
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/* ----------------------------- Markdown export ----------------------------- */
|
|
147
|
+
export async function exportAsMarkdown(sessionId) {
|
|
148
|
+
const located = await findSessionFile(sessionId);
|
|
149
|
+
if (located === undefined)
|
|
150
|
+
throw new SessionNotFoundError(sessionId);
|
|
151
|
+
const parentContent = await readFile(located.filePath, "utf8");
|
|
152
|
+
const parentLines = splitLines(parentContent);
|
|
153
|
+
const project = await getProject(located.projectId);
|
|
154
|
+
const projectName = project?.name ?? "(unknown project)";
|
|
155
|
+
const isChild = located.parentSessionId !== undefined;
|
|
156
|
+
const children = isChild
|
|
157
|
+
? []
|
|
158
|
+
: await loadChildSessions(sessionId, located.projectId, located.workspacePath);
|
|
159
|
+
const childContents = await Promise.all(children.map(async (c) => ({ ...c, lines: splitLines(await readFile(c.filePath, "utf8")) })));
|
|
160
|
+
const out = [];
|
|
161
|
+
out.push(...renderHeader(parentLines, located.sessionName, sessionId, projectName));
|
|
162
|
+
out.push("");
|
|
163
|
+
let childCursor = 0;
|
|
164
|
+
for (const line of parentLines) {
|
|
165
|
+
const parsed = safeParse(line);
|
|
166
|
+
if (parsed === undefined)
|
|
167
|
+
continue;
|
|
168
|
+
const md = renderLine(parsed, /* depth */ 2);
|
|
169
|
+
if (md.length === 0)
|
|
170
|
+
continue;
|
|
171
|
+
out.push(md);
|
|
172
|
+
out.push("");
|
|
173
|
+
// Inline a child after the matching subagent tool call.
|
|
174
|
+
const callId = subagentToolCallIdFromParsed(parsed);
|
|
175
|
+
if (callId === undefined)
|
|
176
|
+
continue;
|
|
177
|
+
const child = childContents[childCursor];
|
|
178
|
+
if (child === undefined)
|
|
179
|
+
continue;
|
|
180
|
+
childCursor += 1;
|
|
181
|
+
out.push(`<details><summary>↳ subagent ${child.sessionId}</summary>`);
|
|
182
|
+
out.push("");
|
|
183
|
+
for (const childLine of child.lines) {
|
|
184
|
+
const childParsed = safeParse(childLine);
|
|
185
|
+
if (childParsed === undefined)
|
|
186
|
+
continue;
|
|
187
|
+
// Nest one heading-depth deeper so the child's user/assistant
|
|
188
|
+
// sections render as h3 under the parent's h2 tool-call entry.
|
|
189
|
+
const childMd = renderLine(childParsed, /* depth */ 3);
|
|
190
|
+
if (childMd.length === 0)
|
|
191
|
+
continue;
|
|
192
|
+
out.push(childMd);
|
|
193
|
+
out.push("");
|
|
194
|
+
}
|
|
195
|
+
out.push("</details>");
|
|
196
|
+
out.push("");
|
|
197
|
+
}
|
|
198
|
+
// Orphaned children (count mismatch) at the tail.
|
|
199
|
+
for (let i = childCursor; i < childContents.length; i++) {
|
|
200
|
+
const child = childContents[i];
|
|
201
|
+
if (child === undefined)
|
|
202
|
+
continue;
|
|
203
|
+
out.push("---");
|
|
204
|
+
out.push("");
|
|
205
|
+
out.push(`### ↳ subagent ${child.sessionId} (orphaned — no matching parent tool call)`);
|
|
206
|
+
out.push("");
|
|
207
|
+
for (const childLine of child.lines) {
|
|
208
|
+
const childParsed = safeParse(childLine);
|
|
209
|
+
if (childParsed === undefined)
|
|
210
|
+
continue;
|
|
211
|
+
const childMd = renderLine(childParsed, 3);
|
|
212
|
+
if (childMd.length === 0)
|
|
213
|
+
continue;
|
|
214
|
+
out.push(childMd);
|
|
215
|
+
out.push("");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
content: out
|
|
220
|
+
.join("\n")
|
|
221
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
222
|
+
.trimEnd() + "\n",
|
|
223
|
+
filename: filenameFor(located.sessionName ?? sessionId, "md"),
|
|
224
|
+
contentType: "text/markdown; charset=utf-8",
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function splitLines(content) {
|
|
228
|
+
return content.split("\n").filter((l) => l.length > 0);
|
|
229
|
+
}
|
|
230
|
+
function safeParse(line) {
|
|
231
|
+
try {
|
|
232
|
+
return JSON.parse(line);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function renderHeader(lines, sessionName, sessionId, projectName) {
|
|
239
|
+
let createdAt;
|
|
240
|
+
let cwd;
|
|
241
|
+
let model;
|
|
242
|
+
for (const line of lines) {
|
|
243
|
+
const parsed = safeParse(line);
|
|
244
|
+
if (parsed === undefined)
|
|
245
|
+
continue;
|
|
246
|
+
if (parsed.type === "session") {
|
|
247
|
+
if (typeof parsed.timestamp === "string")
|
|
248
|
+
createdAt = parsed.timestamp;
|
|
249
|
+
if (typeof parsed.cwd === "string")
|
|
250
|
+
cwd = parsed.cwd;
|
|
251
|
+
}
|
|
252
|
+
else if (parsed.type === "model_change" && model === undefined) {
|
|
253
|
+
const provider = typeof parsed.provider === "string" ? parsed.provider : undefined;
|
|
254
|
+
const modelId = typeof parsed.modelId === "string" ? parsed.modelId : undefined;
|
|
255
|
+
if (provider !== undefined && modelId !== undefined)
|
|
256
|
+
model = `${provider} / ${modelId}`;
|
|
257
|
+
else if (modelId !== undefined)
|
|
258
|
+
model = modelId;
|
|
259
|
+
}
|
|
260
|
+
if (createdAt !== undefined && cwd !== undefined && model !== undefined)
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
const out = [];
|
|
264
|
+
out.push(`# ${sessionName ?? "Session"}`);
|
|
265
|
+
out.push("");
|
|
266
|
+
out.push(`- **Session id:** \`${sessionId}\``);
|
|
267
|
+
out.push(`- **Project:** ${projectName}`);
|
|
268
|
+
if (createdAt !== undefined)
|
|
269
|
+
out.push(`- **Created:** ${createdAt}`);
|
|
270
|
+
if (model !== undefined)
|
|
271
|
+
out.push(`- **Model:** ${model}`);
|
|
272
|
+
if (cwd !== undefined)
|
|
273
|
+
out.push(`- **Workspace:** \`${cwd}\``);
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
function renderLine(parsed, depth) {
|
|
277
|
+
if (parsed.type !== "message")
|
|
278
|
+
return "";
|
|
279
|
+
const msg = parsed.message;
|
|
280
|
+
if (msg === undefined || msg === null || typeof msg !== "object")
|
|
281
|
+
return "";
|
|
282
|
+
const role = msg.role;
|
|
283
|
+
const ts = typeof parsed.timestamp === "string" ? prettyTimestamp(parsed.timestamp) : "";
|
|
284
|
+
if (role === "user") {
|
|
285
|
+
return renderUserMessage(msg, depth, ts);
|
|
286
|
+
}
|
|
287
|
+
if (role === "assistant") {
|
|
288
|
+
return renderAssistantMessage(msg, depth, ts);
|
|
289
|
+
}
|
|
290
|
+
if (role === "toolResult") {
|
|
291
|
+
return renderStandaloneToolResult(msg);
|
|
292
|
+
}
|
|
293
|
+
return "";
|
|
294
|
+
}
|
|
295
|
+
function renderUserMessage(msg, depth, ts) {
|
|
296
|
+
const heading = depth === 2 ? "## You" : "### You";
|
|
297
|
+
const out = [ts.length > 0 ? `${heading} — ${ts}` : heading, ""];
|
|
298
|
+
out.push(...renderContent(msg.content));
|
|
299
|
+
return out.join("\n");
|
|
300
|
+
}
|
|
301
|
+
function renderAssistantMessage(msg, depth, ts) {
|
|
302
|
+
const heading = depth === 2 ? "## Assistant" : "### Assistant";
|
|
303
|
+
const out = [ts.length > 0 ? `${heading} — ${ts}` : heading, ""];
|
|
304
|
+
out.push(...renderContent(msg.content));
|
|
305
|
+
return out.join("\n");
|
|
306
|
+
}
|
|
307
|
+
function renderStandaloneToolResult(msg) {
|
|
308
|
+
// toolResult lines render as blockquote bodies under the tool call
|
|
309
|
+
// they pair with — rendered separately when the SDK doesn't emit
|
|
310
|
+
// them inline with the call (loose pre-pairing).
|
|
311
|
+
const text = pickToolResultText(msg);
|
|
312
|
+
if (text.length === 0)
|
|
313
|
+
return "";
|
|
314
|
+
return blockquote(truncate(text, TOOL_RESULT_CAP));
|
|
315
|
+
}
|
|
316
|
+
function renderContent(content) {
|
|
317
|
+
// String form: simple "user typed text" — render as a paragraph.
|
|
318
|
+
if (typeof content === "string") {
|
|
319
|
+
return content.length > 0 ? [content] : [];
|
|
320
|
+
}
|
|
321
|
+
if (!Array.isArray(content))
|
|
322
|
+
return [];
|
|
323
|
+
const out = [];
|
|
324
|
+
for (const block of content) {
|
|
325
|
+
if (block === undefined || block === null || typeof block !== "object")
|
|
326
|
+
continue;
|
|
327
|
+
const b = block;
|
|
328
|
+
if (b.type === "text" && typeof b.text === "string") {
|
|
329
|
+
out.push(b.text);
|
|
330
|
+
}
|
|
331
|
+
else if (b.type === "thinking") {
|
|
332
|
+
const t = typeof b.text === "string" ? b.text : "";
|
|
333
|
+
// Thinking blocks fold into a <details> so the transcript stays
|
|
334
|
+
// skim-able; reviewers can expand to see the full chain.
|
|
335
|
+
out.push("<details><summary>Thinking</summary>");
|
|
336
|
+
out.push("");
|
|
337
|
+
if (t.length > 0)
|
|
338
|
+
out.push(t);
|
|
339
|
+
out.push("</details>");
|
|
340
|
+
}
|
|
341
|
+
else if (b.type === "toolCall") {
|
|
342
|
+
out.push(renderToolCall(b));
|
|
343
|
+
}
|
|
344
|
+
else if (b.type === "image") {
|
|
345
|
+
const filename = typeof b.filename === "string" ? b.filename : "image";
|
|
346
|
+
const mime = typeof b.mimeType === "string" ? b.mimeType : "";
|
|
347
|
+
out.push(`*[image: ${filename}${mime !== "" ? " (" + mime + ")" : ""}]*`);
|
|
348
|
+
}
|
|
349
|
+
else if (b.type === "file") {
|
|
350
|
+
const filename = typeof b.filename === "string" ? b.filename : "file";
|
|
351
|
+
out.push(`*[file: ${filename}]*`);
|
|
352
|
+
}
|
|
353
|
+
else if (b.type === "toolResult") {
|
|
354
|
+
// toolResult content blocks carry the result payload either as a
|
|
355
|
+
// top-level `content` (string or block list) or under `details`;
|
|
356
|
+
// pickToolResultText accepts either shape.
|
|
357
|
+
const text = pickToolResultText(b);
|
|
358
|
+
if (text.length > 0)
|
|
359
|
+
out.push(blockquote(truncate(text, TOOL_RESULT_CAP)));
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return out;
|
|
363
|
+
}
|
|
364
|
+
function renderToolCall(b) {
|
|
365
|
+
const name = typeof b.name === "string" ? b.name : "tool";
|
|
366
|
+
const args = (b.arguments ?? b.input);
|
|
367
|
+
// Per-tool language hints make the rendered code blocks meaningful
|
|
368
|
+
// to clipboard / GitHub renderers. Default to plain text.
|
|
369
|
+
const lang = languageForTool(name);
|
|
370
|
+
const body = stringifyArgs(name, args);
|
|
371
|
+
return `**${name}**\n\n\`\`\`${lang}\n${body}\n\`\`\``;
|
|
372
|
+
}
|
|
373
|
+
function languageForTool(name) {
|
|
374
|
+
if (name === "bash")
|
|
375
|
+
return "bash";
|
|
376
|
+
if (name === "edit" || name === "write")
|
|
377
|
+
return "diff";
|
|
378
|
+
if (name === "read" || name === "ls" || name === "find" || name === "grep")
|
|
379
|
+
return "";
|
|
380
|
+
return "";
|
|
381
|
+
}
|
|
382
|
+
function stringifyArgs(name, args) {
|
|
383
|
+
if (args === undefined || args === null || typeof args !== "object")
|
|
384
|
+
return "";
|
|
385
|
+
// Special-case `bash` so the command renders as a bare shell line —
|
|
386
|
+
// most natural form for the most common tool.
|
|
387
|
+
if (name === "bash" && typeof args.command === "string") {
|
|
388
|
+
return args.command;
|
|
389
|
+
}
|
|
390
|
+
// Generic: pretty-print the args object.
|
|
391
|
+
return JSON.stringify(args, null, 2);
|
|
392
|
+
}
|
|
393
|
+
function pickToolResultText(b) {
|
|
394
|
+
// Tool results in pi can be either:
|
|
395
|
+
// - top-level string (legacy)
|
|
396
|
+
// - content[].text (assistant-style block list)
|
|
397
|
+
// - details.text / details.diff (SDK envelope variant)
|
|
398
|
+
// Render whichever the line happens to carry; never guess.
|
|
399
|
+
const details = b.details;
|
|
400
|
+
if (typeof details?.text === "string")
|
|
401
|
+
return details.text;
|
|
402
|
+
if (typeof details?.diff === "string")
|
|
403
|
+
return details.diff;
|
|
404
|
+
if (typeof b.content === "string")
|
|
405
|
+
return b.content;
|
|
406
|
+
if (Array.isArray(b.content)) {
|
|
407
|
+
const text = b.content
|
|
408
|
+
.filter((block) => block !== null &&
|
|
409
|
+
typeof block === "object" &&
|
|
410
|
+
block.type === "text" &&
|
|
411
|
+
typeof block.text === "string")
|
|
412
|
+
.map((block) => block.text)
|
|
413
|
+
.join("\n");
|
|
414
|
+
if (text.length > 0)
|
|
415
|
+
return text;
|
|
416
|
+
}
|
|
417
|
+
return "";
|
|
418
|
+
}
|
|
419
|
+
function blockquote(text) {
|
|
420
|
+
return text
|
|
421
|
+
.split("\n")
|
|
422
|
+
.map((line) => `> ${line}`)
|
|
423
|
+
.join("\n");
|
|
424
|
+
}
|
|
425
|
+
function truncate(text, cap) {
|
|
426
|
+
if (text.length <= cap)
|
|
427
|
+
return text;
|
|
428
|
+
return `${text.slice(0, cap)}\n… (truncated, ${text.length} bytes total)`;
|
|
429
|
+
}
|
|
430
|
+
function prettyTimestamp(iso) {
|
|
431
|
+
// Strip the millisecond + Z noise so the rendered transcript isn't
|
|
432
|
+
// dominated by timestamps; ISO date + HH:MM:SS is plenty.
|
|
433
|
+
const m = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})/.exec(iso);
|
|
434
|
+
if (m === null)
|
|
435
|
+
return iso;
|
|
436
|
+
return `${m[1]} ${m[2]}`;
|
|
437
|
+
}
|
|
438
|
+
function subagentToolCallIdFromLine(line) {
|
|
439
|
+
const parsed = safeParse(line);
|
|
440
|
+
if (parsed === undefined)
|
|
441
|
+
return undefined;
|
|
442
|
+
return subagentToolCallIdFromParsed(parsed);
|
|
443
|
+
}
|
|
444
|
+
function subagentToolCallIdFromParsed(parsed) {
|
|
445
|
+
if (parsed.type !== "message")
|
|
446
|
+
return undefined;
|
|
447
|
+
const msg = parsed.message;
|
|
448
|
+
if (msg === undefined || msg === null || typeof msg !== "object")
|
|
449
|
+
return undefined;
|
|
450
|
+
if (msg.role !== "assistant")
|
|
451
|
+
return undefined;
|
|
452
|
+
const content = msg.content;
|
|
453
|
+
if (!Array.isArray(content))
|
|
454
|
+
return undefined;
|
|
455
|
+
for (const block of content) {
|
|
456
|
+
if (block === undefined || block === null || typeof block !== "object")
|
|
457
|
+
continue;
|
|
458
|
+
const b = block;
|
|
459
|
+
if (b.type === "toolCall" && b.name === "subagent" && typeof b.id === "string") {
|
|
460
|
+
return b.id;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return undefined;
|
|
464
|
+
}
|
|
465
|
+
function filenameFor(label, ext) {
|
|
466
|
+
const slug = label
|
|
467
|
+
.toLowerCase()
|
|
468
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
469
|
+
.replace(/^-+|-+$/g, "")
|
|
470
|
+
.slice(0, 64);
|
|
471
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
472
|
+
const base = slug.length > 0 ? slug : "session";
|
|
473
|
+
return `${base}-${date}.${ext}`;
|
|
474
|
+
}
|
|
475
|
+
/** Test helper — never called from the route. */
|
|
476
|
+
export function _readProjectsForTest() {
|
|
477
|
+
return readProjects();
|
|
478
|
+
}
|
|
479
|
+
/** Test helper — fully resolves a session file (without reading contents). */
|
|
480
|
+
export async function _findSessionFileForTest(sessionId) {
|
|
481
|
+
const f = await findSessionFile(sessionId);
|
|
482
|
+
if (f === undefined)
|
|
483
|
+
return undefined;
|
|
484
|
+
return { filePath: f.filePath, projectId: f.projectId };
|
|
485
|
+
}
|
|
486
|
+
/** Used by the route to compute a deterministic dirname for diagnostics. */
|
|
487
|
+
export function _exportDirForTest(filePath) {
|
|
488
|
+
return dirname(filePath);
|
|
489
|
+
}
|
|
490
|
+
//# sourceMappingURL=session-exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-exporter.js","sourceRoot":"","sources":["../src/session-exporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,gFAAgF;AAChF,MAAM,eAAe,GAAG,KAAK,CAAC;AAW9B,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,SAAiB;QAC3B,KAAK,CAAC,WAAW,SAAS,YAAY,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;GAIG;AACH,KAAK,UAAU,eAAe,CAAC,SAAiB;IAU9C,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,UAAU,GAAG,MAAM,sBAAsB,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IAClF,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IAChE,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,GAAG,GAML;QACF,QAAQ,EAAE,KAAK,CAAC,IAAI;QACpB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,aAAa,EAAE,GAAG,CAAC,aAAa;KACjC,CAAC;IACF,IAAI,KAAK,CAAC,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