Phase 14: add debug reinject diag logging — B-002 filter visibility
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>
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
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",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -54,6 +54,10 @@ describe("parseSkillReinjectPartial", () => {
|
||||
}),
|
||||
).toEqual({ enabled: true, suffix: "custom" });
|
||||
});
|
||||
|
||||
it("parses debug flag", () => {
|
||||
expect(parseSkillReinjectPartial({ debug: true })).toEqual({ debug: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe("mergeSkillReinjectSettings", () => {
|
||||
|
||||
Reference in New Issue
Block a user