Phase 6: add PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES — document pi-auto-compact phrases.
Constants match SPEC §16.9 for tests and docs; runtime v1 does not match follow-up text. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
detectAndCachePiAutoCompact,
|
||||
detectPiAutoCompact,
|
||||
PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES,
|
||||
resolveDeliveryMode,
|
||||
} from "../src/auto-compact";
|
||||
import { createDefaultSettings } from "../src/settings";
|
||||
import { createRuntimeFlags } from "../src/state";
|
||||
|
||||
describe("detectPiAutoCompact", () => {
|
||||
it("returns true when auto-compact command is registered", () => {
|
||||
const pi = {
|
||||
getCommands: () => [{ name: "auto-compact" }],
|
||||
};
|
||||
expect(detectPiAutoCompact(pi as never)).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when auto-compact command is absent", () => {
|
||||
const pi = {
|
||||
getCommands: () => [{ name: "skill-reinject" }],
|
||||
};
|
||||
expect(detectPiAutoCompact(pi as never)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("detectAndCachePiAutoCompact", () => {
|
||||
it("writes detect result into runtime flags", () => {
|
||||
const runtime = createRuntimeFlags();
|
||||
const pi = {
|
||||
getCommands: () => [{ name: "auto-compact" }],
|
||||
};
|
||||
expect(detectAndCachePiAutoCompact(pi as never, runtime)).toBe(true);
|
||||
expect(runtime.autoCompactDetected).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveDeliveryMode", () => {
|
||||
it("defers when pi-auto-compact is cached as detected", () => {
|
||||
const runtime = createRuntimeFlags();
|
||||
runtime.autoCompactDetected = true;
|
||||
expect(resolveDeliveryMode(createDefaultSettings(), runtime)).toBe("defer");
|
||||
});
|
||||
});
|
||||
|
||||
describe("PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES", () => {
|
||||
it("documents pi-auto-compact follow-up phrases from SPEC §16.9", () => {
|
||||
expect([...PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES]).toEqual([
|
||||
"Auto-compact ran before this turn.",
|
||||
"Auto-compact ran mid-turn.",
|
||||
"Emergency auto-compact ran.",
|
||||
"Auto-compact ran on session resume.",
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user