Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
/**
* Synthetic Claude Code transcript lines, shaped like the real JSONL (the
* keys, flags and wrappers Claude Code writes) with made-up repos, prompts and
* output. Shared by the trace tests; not a test file itself.
*/
let n = 0;
const uuid = () => `00000000-0000-4000-8000-${String(++n).padStart(12, "0")}`;
const SESSION = "5f0c1a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b";
function base(extra: Record<string, unknown> = {}) {
return {
parentUuid: null,
isSidechain: false,
userType: "external",
cwd: "/home/dev/shop",
sessionId: SESSION,
version: "2.1.29",
gitBranch: "main",
entrypoint: "cli",
uuid: uuid(),
timestamp: "2026-10-01T10:00:00.000Z",
...extra,
};
}
/** A prompt the person typed, as newer builds stamp it. */
export const typed = (content: unknown, extra: Record<string, unknown> = {}) =>
base({ type: "user", message: { role: "user", content }, origin: { kind: "human" }, promptId: uuid(), permissionMode: "default", ...extra });
/** A prompt from a build that predates `origin`. */
export const typedOld = (content: unknown, extra: Record<string, unknown> = {}) => base({ type: "user", message: { role: "user", content }, ...extra });
export const ideOpened = (path = "/home/dev/shop/src/cart.ts") => ({
type: "text",
text: `<ide_opened_file>The user opened the file ${path} in the IDE. This may or may not be related to the current task.</ide_opened_file>`,
});
export const ideSelection = () => ({
type: "text",
text: "<ide_selection>The user selected the lines 3 to 4 from /home/dev/shop/src/cart.ts:\nconst total = 0;\nreturn total;\n\nThis may or may not be related to the current task.</ide_selection>",
});
export const reminder = () => ({ type: "text", text: "<system-reminder>\nThe date is 2026-10-01.\n</system-reminder>" });
export const text = (t: string) => ({ type: "text", text: t });
export const compactBoundary = (extra: Record<string, unknown> = {}) =>
base({ type: "system", subtype: "compact_boundary", content: "Conversation compacted", level: "info", compactMetadata: { trigger: "auto", preTokens: 160000 }, ...extra });
export const compactSummary = (extra: Record<string, unknown> = {}) =>
base({
type: "user",
isCompactSummary: true,
isVisibleInTranscriptOnly: true,
message: { role: "user", content: "This session is being continued from a previous conversation that ran out of context. The summary below covers the earlier portion.\n\n1. Primary request: fix the cart total." },
...extra,
});
export const meta = () =>
base({ type: "user", isMeta: true, message: { role: "user", content: "<local-command-caveat>Caveat: The messages below were generated by the user while running local commands.</local-command-caveat>" } });
export const taskNotification = (withOrigin = true) =>
base({
type: "user",
...(withOrigin ? { origin: { kind: "task-notification", producer: "bash", runId: "r1" }, promptSource: "system" } : {}),
message: { role: "user", content: "<task-notification>\n<task-id>b1x9</task-id>\n<status>completed</status>\n<summary>Background command \"npm test\" completed (exit code 0)</summary>\n</task-notification>" },
});
export const commandWrapper = () =>
typedOld("<command-message>review is running…</command-message>\n<command-name>/review</command-name>\n<command-args>the cart module</command-args>");
export const localStdout = () => typedOld("<local-command-stdout>Set model to a faster one</local-command-stdout>");
export const bashInput = () => typedOld("<bash-input>ls -la</bash-input>");
export const peer = () =>
base({
type: "user",
isMeta: true,
origin: { kind: "peer", from: "worker-2", handback: true },
message: { role: "user", content: "<agent-message from=\"worker-2\">Finished: tests pass.</agent-message>" },
});
export const sidechain = (content = "Explore the repo and report where the cart total is computed") =>
base({ type: "user", isSidechain: true, message: { role: "user", content } });
export const interrupted = () => typedOld([text("[Request interrupted by user]")]);
export const toolUse = (id: string, name: string, input: unknown, extra: Record<string, unknown> = {}) =>
base({
type: "assistant",
message: { id: `msg_${id}`, type: "message", role: "assistant", model: "claude-sonnet-5-5", content: [{ type: "tool_use", id, name, input }], stop_reason: "tool_use" },
...extra,
});
export const toolResult = (id: string, content: unknown, isError?: boolean, extra: Record<string, unknown> = {}) =>
base({
type: "user",
message: { role: "user", content: [{ tool_use_id: id, type: "tool_result", content, ...(isError === undefined ? {} : { is_error: isError }) }] },
toolUseResult: isError ? `Error: ${typeof content === "string" ? content : "failed"}` : { stdout: typeof content === "string" ? content : "", stderr: "", interrupted: false, isImage: false, noOutputExpected: false },
sourceToolAssistantUUID: uuid(),
...extra,
});
export const said = (t: string, extra: Record<string, unknown> = {}) =>
base({ type: "assistant", message: { id: `msg_${uuid()}`, type: "message", role: "assistant", model: "claude-sonnet-5-5", content: [{ type: "text", text: t }] }, ...extra });
export const thinking = () =>
base({ type: "assistant", message: { id: `msg_${uuid()}`, role: "assistant", content: [{ type: "thinking", thinking: "Let me look.", signature: "c2lnbmF0dXJl" }] } });
export const queuedPrompt = (prompt: unknown) =>
base({ type: "attachment", attachment: { type: "queued_command", commandMode: "prompt", origin: { kind: "human" }, prompt, source_uuid: uuid(), timestamp: "2026-10-01T10:00:05.000Z" } });
export const queuedNotification = () =>
base({ type: "attachment", attachment: { type: "queued_command", commandMode: "task-notification", prompt: "<task-notification>\n<status>completed</status>\n</task-notification>", timestamp: "2026-10-01T10:00:05.000Z" } });
export const hookContext = (content: string) =>
base({ type: "attachment", attachment: { type: "hook_additional_context", content: [content], hookEvent: "UserPromptSubmit", hookName: "UserPromptSubmit", toolUseID: uuid() } });
export const hookSuccess = () =>
base({ type: "attachment", attachment: { type: "hook_success", hookEvent: "Stop", hookName: "Stop", command: "trail hook stop", content: "", stdout: "", stderr: "", exitCode: 0, durationMs: 12, toolUseID: uuid() } });
export const title = () => ({ type: "custom-title", customTitle: "Fix the cart", sessionId: SESSION });
export function jsonl(entries: object[]): string {
return entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
}