import { describe, expect, it } from "vitest"; import { analysisPrompt, isGoodJobTrigger, parseLearning } from "../core.js"; describe("good-job core", () => { it("matches only explicit standalone praise", () => { for (const trigger of ["gj", "GJ!", " good job ", "Good Job..."]) expect(isGoodJobTrigger(trigger), trigger).toBe(true); for (const other of [ "great job", "good job, now continue", "thanks", "object.gj", "", ]) expect(isGoodJobTrigger(other), other).toBe(false); }); it("parses and bounds structured learnings", () => { const learning = parseLearning(`\`\`\`json { "achievement": " Fixed the shared route ", "evidence": ["All tests passed", "Caller uses one path"], "successful_behaviors": ["Inspected callers first"], "candidate_rule": "Fix shared routes before leaf callers." } \`\`\``); expect(learning).toEqual({ achievement: "Fixed the shared route", evidence: ["All tests passed", "Caller uses one path"], successfulBehaviors: ["Inspected callers first"], candidateRule: "Fix shared routes before leaf callers.", }); }); it("rejects incomplete model output", () => { expect(() => parseLearning('{"achievement":"done","evidence":[]}')).toThrow( "missing required learning fields", ); }); it("asks for evidence-backed reusable behavior without raw secrets", () => { const prompt = analysisPrompt("gj"); expect(prompt).toContain("full conversation"); expect(prompt).toContain("successful_behaviors"); expect(prompt).toContain("Do not reproduce credentials"); }); });