diff --git a/src/backends/native/prompts.ts b/src/backends/native/prompts.ts index 25ff5fb..b984481 100644 --- a/src/backends/native/prompts.ts +++ b/src/backends/native/prompts.ts @@ -25,6 +25,45 @@ Rules: Output format: Return a markdown summary with bullet points. Do not include any preamble or explanation — output only the summary.`; +/** + * Build a compaction system prompt. When `personalAssistant` is true, + * the prompt focuses on continuity context (what the user was working on, + * decisions, preferences, open threads) rather than generic summarization. + * + * The shared rules (preserve facts, 20% length, bullet points, no invention, + * skip transient content) are identical in both variants. + */ +export function buildCompactionPrompt(opts?: { personalAssistant?: boolean }): string { + const focus = opts?.personalAssistant + ? `Focus on: +- What the user was working on and its current status (be specific: which files, commands, or steps were involved) +- Decisions made and why (include rationale when stated) +- Preferences or constraints the user expressed (tools, styles, approaches to avoid or prefer) +- Open threads, unresolved questions, or explicit follow-up items` + : `Focus on: +- Key topics discussed and conclusions reached +- Important decisions, commitments, or action items +- Technical details, code changes, or configurations that were established`; + + const preamble = opts?.personalAssistant + ? 'You are summarising a conversation for a personal assistant. Your summary will be injected at the start of the next session so the assistant can pick up exactly where things left off.' + : 'You are a conversation summarizer. Create a concise summary of the conversation that captures all important information.'; + + return `${preamble} + +${focus} + +Rules: +- Preserve key facts, file paths, error messages, and specific values verbatim. +- Be concise but complete — aim for roughly 20% of the original length. +- Use bullet points under short descriptive headings. +- Never invent information not present in the conversation. +- Skip purely transient content (one-off commands, status messages with no lasting significance). + +Output format: +Return a markdown summary. No preamble — output only the summary.`; +} + /** * Instructs a model to extract persistent facts from conversation text. * Extracted facts are stored in long-term memory for future sessions.