mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 19:20:39 +09:00
feat: polish issue thread markdown and references
This commit is contained in:
parent
548721248e
commit
958c11699e
16 changed files with 659 additions and 44 deletions
|
|
@ -70,4 +70,116 @@ describe("buildTranscript", () => {
|
|||
expect(first).toEqual([]);
|
||||
expect(second).toEqual([{ kind: "stdout", ts, text: "literal:finish" }]);
|
||||
});
|
||||
|
||||
it("converts parser failures into transcript error entries and keeps going", () => {
|
||||
const entries = buildTranscript(
|
||||
[
|
||||
{ ts, stream: "stdout", chunk: "ok\nexplode\nlater\n" },
|
||||
],
|
||||
(line, entryTs) => {
|
||||
if (line === "explode") {
|
||||
throw new Error("boom");
|
||||
}
|
||||
return [{ kind: "stdout", ts: entryTs, text: line }];
|
||||
},
|
||||
);
|
||||
|
||||
expect(entries).toEqual([
|
||||
{ kind: "stdout", ts, text: "ok" },
|
||||
{
|
||||
kind: "result",
|
||||
ts,
|
||||
text: "Chat transcript error: boom. Falling back for line: explode",
|
||||
inputTokens: 0,
|
||||
outputTokens: 0,
|
||||
cachedTokens: 0,
|
||||
costUsd: 0,
|
||||
subtype: "transcript_parse_error",
|
||||
isError: true,
|
||||
errors: [],
|
||||
},
|
||||
{ kind: "stdout", ts, text: "later" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("resets stateful parsers after a failure before parsing later lines", () => {
|
||||
const statefulAdapter: UIAdapterModule = {
|
||||
type: "stateful_test",
|
||||
label: "Stateful Test",
|
||||
parseStdoutLine: (line, entryTs) => [{ kind: "stdout", ts: entryTs, text: line }],
|
||||
createStdoutParser: () => {
|
||||
let pending: string | null = null;
|
||||
return {
|
||||
parseLine: (line, entryTs) => {
|
||||
if (line.startsWith("begin:")) {
|
||||
pending = line.slice("begin:".length);
|
||||
return [];
|
||||
}
|
||||
if (line === "explode") {
|
||||
throw new Error(`bad state:${pending ?? "none"}`);
|
||||
}
|
||||
if (line === "finish" && pending) {
|
||||
const text = `completed:${pending}`;
|
||||
pending = null;
|
||||
return [{ kind: "stdout", ts: entryTs, text }];
|
||||
}
|
||||
return [{ kind: "stdout", ts: entryTs, text: `literal:${line}` }];
|
||||
},
|
||||
reset: () => {
|
||||
pending = null;
|
||||
},
|
||||
};
|
||||
},
|
||||
ConfigFields: () => null,
|
||||
buildAdapterConfig: () => ({}),
|
||||
};
|
||||
|
||||
const entries = buildTranscript(
|
||||
[{ ts, stream: "stdout", chunk: "begin:task-a\nexplode\nfinish\n" }],
|
||||
statefulAdapter,
|
||||
);
|
||||
|
||||
expect(entries).toEqual([
|
||||
{
|
||||
kind: "result",
|
||||
ts,
|
||||
text: "Chat transcript error: bad state:task-a. Falling back for line: explode",
|
||||
inputTokens: 0,
|
||||
outputTokens: 0,
|
||||
cachedTokens: 0,
|
||||
costUsd: 0,
|
||||
subtype: "transcript_parse_error",
|
||||
isError: true,
|
||||
errors: [],
|
||||
},
|
||||
{ kind: "stdout", ts, text: "literal:finish" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("handles trailing buffered parser failures without throwing", () => {
|
||||
const entries = buildTranscript(
|
||||
[{ ts, stream: "stdout", chunk: "explode" }],
|
||||
(line, entryTs) => {
|
||||
if (line === "explode") {
|
||||
throw new Error("trailing boom");
|
||||
}
|
||||
return [{ kind: "stdout", ts: entryTs, text: line }];
|
||||
},
|
||||
);
|
||||
|
||||
expect(entries).toEqual([
|
||||
{
|
||||
kind: "result",
|
||||
ts,
|
||||
text: "Chat transcript error: trailing boom. Falling back for line: explode",
|
||||
inputTokens: 0,
|
||||
outputTokens: 0,
|
||||
cachedTokens: 0,
|
||||
costUsd: 0,
|
||||
subtype: "transcript_parse_error",
|
||||
isError: true,
|
||||
errors: [],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue