2e6d36a855
Constants match SPEC §16.9 for tests and docs; runtime v1 does not match follow-up text. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
import {
|
|
effectiveIntegration,
|
|
type ReinjectDeliveryMode,
|
|
type SkillReinjectSettings,
|
|
} from "./settings";
|
|
import type { AutoCompactIntegration, RuntimeFlags } from "./state";
|
|
|
|
/** Detect @capyup/pi-auto-compact via public getCommands API (SPEC §16.4). */
|
|
export function detectPiAutoCompact(pi: ExtensionAPI): boolean {
|
|
return pi.getCommands().some((command) => command.name === "auto-compact");
|
|
}
|
|
|
|
/** Detect pi-auto-compact and cache result in runtime flags (SPEC §16.4). */
|
|
export function detectAndCachePiAutoCompact(pi: ExtensionAPI, runtime: RuntimeFlags): boolean {
|
|
runtime.autoCompactDetected = detectPiAutoCompact(pi);
|
|
return runtime.autoCompactDetected;
|
|
}
|
|
|
|
/** Resolve re-inject delivery mode from settings, detect cache, and session override (SPEC §6.5.3). */
|
|
export function resolveDeliveryMode(
|
|
settings: SkillReinjectSettings,
|
|
runtime: RuntimeFlags,
|
|
sessionIntegrationOverride?: AutoCompactIntegration | null,
|
|
): ReinjectDeliveryMode {
|
|
return effectiveIntegration(settings, runtime.autoCompactDetected, sessionIntegrationOverride);
|
|
}
|
|
|
|
/** pi-auto-compact follow-up message prefixes (SPEC §16.9); documentation/tests only, not runtime v1. */
|
|
export const PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES = [
|
|
"Auto-compact ran before this turn.",
|
|
"Auto-compact ran mid-turn.",
|
|
"Emergency auto-compact ran.",
|
|
"Auto-compact ran on session resume.",
|
|
] as const;
|