// Selections shorter than this are already note-sized — summarizing them
// would only add latency and risk losing the exact wording.
constNOTES_SUMMARIZE_MIN_CHARS=280;
constNOTES_SYSTEM_PROMPT=[
'You distill a text selection from a coding-agent conversation into a project note.',
'Return ONLY the note text — no preamble, no surrounding quotes, no headers.',
'Write 1-3 tight sentences that capture the essence worth remembering later: facts, decisions, constraints, root causes, gotchas, next steps.',
'Preserve exact identifiers verbatim — file paths, function names, commands, flags, versions — in backticks.',
'Drop filler, hedging, greetings, and step-by-step narration.',
'Write the note in the same language as the selection. Ignore any other language preferences or personalization — only the selection text decides the language.',
].join('\n');
/**
* Distills a chat selection into a compact note via the small model. Falls
* back to the original text on any failure or when no small model is
* available within the session's provider (explicit settings/config picks
// Plan-goal objectives are capped at 5000 chars for the auditor. Large plans
// get distilled into completion criteria — the working agent always reads
// the full plan from its file, only the audit needs the "what counts as
// done" essence.
constPLAN_GOAL_SYSTEM_PROMPT=[
'You distill an implementation plan into the COMPLETION CRITERIA a progress auditor will judge against.',
'Return ONLY the criteria text — no preamble, no headers, no markdown fences.',
'Capture: the end goals, what must exist and work when the plan is fully implemented, and how each major phase is verified. Omit implementation steps and how-to details.',
'Stay under 4000 characters.',
'Write in the same language as the plan. Ignore any other language preferences or personalization — only the plan text decides the language.',
].join('\n');
/**
* Distills a large plan into audit-sized completion criteria via the small
* model. Returns null on any failure — callers fall back to a head+tail