mirror of
https://github.com/mvschwarz/openrig.git
synced 2026-11-07 05:56:21 -10:00
* fix(restore): skip non-record JSON values in both transcript parsers Signed-off-by: Rudy Celekli <[email protected]> * fix(cli): skip non-object records during restore runtime detection Signed-off-by: Rudy Celekli <[email protected]> --------- Signed-off-by: Rudy Celekli <[email protected]>
24 lines
1.3 KiB
TypeScript
24 lines
1.3 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { parseCodexJsonl } from "../src/restore-packet/codex-jsonl-parser.js";
|
|
import { parseClaudeTranscript } from "../src/restore-packet/claude-transcript-parser.js";
|
|
|
|
const invalid = ["null", "[]", '"unexpected string"', "23", "true", "{broken"];
|
|
|
|
it("keeps Codex messages around malformed JSONL records", () => {
|
|
const message = (text: string) => JSON.stringify({ type: "response_item", payload: { type: "message", role: "user", content: text } });
|
|
const parsed = parseCodexJsonl([message("before"), ...invalid, message("after")].join("\n"));
|
|
expect(parsed.messages.map(message => message.text)).toEqual(["before", "after"]);
|
|
expect(parsed.lineCount).toBe(8);
|
|
expect(parsed.messageCount).toBe(2);
|
|
expect(parsed.typeCounts).toEqual({ response_item: 2 });
|
|
});
|
|
|
|
it("keeps Claude messages around malformed JSONL records", () => {
|
|
const message = (text: string) => JSON.stringify({ type: "user", message: { role: "user", content: text } });
|
|
const parsed = parseClaudeTranscript([message("before"), ...invalid, message("after")].join("\n"));
|
|
expect(parsed.messages.map(message => message.text)).toEqual(["before", "after"]);
|
|
expect(parsed.lineCount).toBe(8);
|
|
expect(parsed.messageCount).toBe(2);
|
|
expect(parsed.typeCounts).toEqual({ user: 2 });
|
|
});
|