8f48040eac
Expose settings.debug snapshots on session_compact and before_agent_start so Phase 14 can see which filter stage drops --skill paths. Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
1.8 KiB
TypeScript
82 lines
1.8 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { buildReinjectDiagSnapshot, notifyReinjectDiag } from "../src/diag.js";
|
|
import { createDefaultSettings } from "../src/settings.js";
|
|
import { createInitialState } from "../src/state.js";
|
|
|
|
describe("buildReinjectDiagSnapshot", () => {
|
|
it("collects tracked, kept, registered, planned, and pending", () => {
|
|
const state = createInitialState();
|
|
state.skills.push({
|
|
name: "alpha",
|
|
filePath: "/skills/alpha/SKILL.md",
|
|
baseDir: "/skills/alpha",
|
|
firstSeenAt: 1,
|
|
lastSeenAt: 1,
|
|
sources: ["slash"],
|
|
});
|
|
state.pendingReinject = ["alpha"];
|
|
|
|
expect(
|
|
buildReinjectDiagSnapshot(
|
|
state,
|
|
[{ name: "beta" }],
|
|
new Set(["gamma"]),
|
|
["alpha"],
|
|
),
|
|
).toEqual({
|
|
tracked: ["alpha"],
|
|
kept: ["gamma"],
|
|
registered: ["beta"],
|
|
planned: ["alpha"],
|
|
pending: ["alpha"],
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("notifyReinjectDiag", () => {
|
|
it("no-ops when debug is off", () => {
|
|
const notify = vi.fn();
|
|
notifyReinjectDiag(
|
|
{
|
|
hasUI: true,
|
|
ui: { notify },
|
|
} as never,
|
|
createDefaultSettings(),
|
|
"session_compact",
|
|
{
|
|
tracked: [],
|
|
kept: [],
|
|
registered: [],
|
|
planned: [],
|
|
pending: [],
|
|
},
|
|
);
|
|
expect(notify).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("notifies with JSON snapshot when debug is on", () => {
|
|
const notify = vi.fn();
|
|
const settings = { ...createDefaultSettings(), debug: true };
|
|
const snapshot = {
|
|
tracked: ["a"],
|
|
kept: [],
|
|
registered: [],
|
|
planned: ["a"],
|
|
pending: ["a"],
|
|
};
|
|
notifyReinjectDiag(
|
|
{
|
|
hasUI: true,
|
|
ui: { notify },
|
|
} as never,
|
|
settings,
|
|
"before_agent_start",
|
|
snapshot,
|
|
);
|
|
expect(notify).toHaveBeenCalledWith(
|
|
`skill-reinject [before_agent_start]: ${JSON.stringify(snapshot)}`,
|
|
"info",
|
|
);
|
|
});
|
|
});
|