import { expect, it } from "vitest"; import { hasDeepSeekFinalEvent, hasDeepSeekSkillBody, } from "../../../scripts/verify/clients/deepseek-evidence.mjs"; it("requires one terminal DeepSeek headless event with the exact answer", () => { const answer = "fixture answer"; const final = '{"type":"final","text":"fixture answer"}\n'; const preview = '{"type":"text","text":"fixture answer"}\n'; expect(hasDeepSeekFinalEvent(preview + final, answer)).toBe(true); for (const [label, stdout] of [ ["preview only", preview], ["extra answer", final.replace("answer", "answer extra")], ["torn JSON", final.slice(0, -2)], ["missing newline", final.slice(0, -1)], ["second final", final + final], ["trailing event", final + preview], ] as const) expect(hasDeepSeekFinalEvent(stdout, answer), label).toBe(false); }); it("binds the verbatim skill body to the installed directory in one tool result", () => { const directory = "/temporary/skills/author & "; const body = 'Use the installed skill.\r\nKeep a \\ literal and "quotes".'; const hint = "Base directory for this skill: /temporary/skills/author & <team>"; const payload = ` ${hint} Resolve relative paths mentioned by this skill against the base directory before using them. Load referenced resources only as needed. ${body} `; expect(hasDeepSeekSkillBody([{ content: payload }], directory, body)).toBe( true, ); const bodyWithTags = `Literal and \r\n${body}`; expect( hasDeepSeekSkillBody( [{ content: payload.replace(body, bodyWithTags) }], directory, bodyWithTags, ), ).toBe(true); const withoutBody = payload.replace(body, ""); const wrongResults = [ ["different body", [payload.replace("literal", "modified")]], ["lookalike directory", [payload.replace(hint, hint + "-backup")]], ["path in unrelated prose", [payload.replace(hint, `See ${hint}`)]], [ "closed before instructions", [ payload.replace( "", "\n", ), ], ], [ "closed during resources", [payload.replace(hint, `${hint}\n`)], ], ["body only in resources", [withoutBody.replace(hint, `${hint}\n${body}`)]], ["outside wrapper", [withoutBody + body]], ["split tool results", [withoutBody, body]], ] as const; for (const [label, contents] of wrongResults) expect( hasDeepSeekSkillBody( contents.map((content) => ({ content })), directory, body, ), label, ).toBe(false); });