#!/usr/bin/env node
import { createHook } from './_runtime.mjs';

const REMINDER = `⚠️ Context compaction imminent. Before proceeding:
1. If you have uncommitted decisions, call: knowledge({ action: "remember", title: "Pre-compact save", content: "<key decisions and state>", category: "session" })
2. If a flow is active, call: stash({ action: "set", key: "pre-compact-state", value: "<current progress>" })
3. After compaction, call: search({ query: "SESSION CHECKPOINT", origin: "curated" }) to recover context.`;

/** Injects a save-state reminder immediately before context compaction. */
export const preCompactSave = async (context) =>
  context.event === 'PreCompact' ? { additionalContext: REMINDER } : { decision: 'allow' };

createHook(preCompactSave);
