Files
pi-auto-reinject/test/reinject-max-skills.test.ts
grayhook 66d9a39a18 Phase 12: maxSkills soft warn — SPEC §15.
Optional maxSkills setting sets the warn threshold; when unset, re-injecting more than three tracked skills emits a one-time UI warning without blocking delivery.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 13:12:21 +07:00

41 lines
1.1 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { maybeWarnManySkills } from "../src/reinject";
import { createDefaultSettings } from "../src/settings";
describe("maybeWarnManySkills", () => {
it("warns above 3 when maxSkills is unset", () => {
const notify = vi.fn();
const ctx = { hasUI: true, ui: { notify } } as never;
maybeWarnManySkills(4, createDefaultSettings(), ctx);
expect(notify).toHaveBeenCalledWith(
"skill-reinject: re-injecting 4 tracked skills (soft warn above 3)",
"warning",
);
});
it("does not warn at 3 skills when maxSkills is unset", () => {
const notify = vi.fn();
const ctx = { hasUI: true, ui: { notify } } as never;
maybeWarnManySkills(3, createDefaultSettings(), ctx);
expect(notify).not.toHaveBeenCalled();
});
it("uses configured maxSkills threshold", () => {
const notify = vi.fn();
const ctx = { hasUI: true, ui: { notify } } as never;
const settings = createDefaultSettings();
settings.maxSkills = 2;
maybeWarnManySkills(3, settings, ctx);
expect(notify).toHaveBeenCalledWith(
"skill-reinject: re-injecting 3 skills (maxSkills warn threshold: 2)",
"warning",
);
});
});