feat(chat): /summary slash command for non-destructive session summaries

Typing /summary (optionally with a topic hint) produces a structured
summary as a normal assistant message — without compacting or mutating
session history. Reuses the existing "Start new session from this answer"
button for hand-off.

Prompts are customizable in Settings → Magic Prompts under a new Session
group. Autocomplete shows an 'openchamber' badge to distinguish our
commands from OpenCode-built-in ones.
This commit is contained in:
Bohdan Triapitsyn
2026-04-22 21:56:35 +03:00
parent f24e6de21b
commit 863be8073b
5 changed files with 108 additions and 3 deletions
+42 -2
View File
@@ -22,13 +22,15 @@ export type MagicPromptId =
| 'plan.improve.visible'
| 'plan.improve.instructions'
| 'plan.implement.visible'
| 'plan.implement.instructions';
| 'plan.implement.instructions'
| 'session.summary.visible'
| 'session.summary.instructions';
export interface MagicPromptDefinition {
id: MagicPromptId;
title: string;
description: string;
group: 'Git' | 'GitHub' | 'Planning';
group: 'Git' | 'GitHub' | 'Planning' | 'Session';
template: string;
placeholders?: Array<{ key: string; description: string }>;
}
@@ -466,6 +468,44 @@ Do the implementation work continuously. When a plan step is ambiguous, do not s
Do not expand scope beyond the plan. If during implementation you find the plan itself is wrong or genuinely blocks completion (not merely ambiguous), stop, state exactly what is broken and why, and propose a plan adjustment to save back into this same file ({{plan_path}}) before continuing.`,
},
{
id: 'session.summary.visible',
title: 'Session Summary Visible Prompt',
group: 'Session',
description: 'Visible user message sent by the /summary command.',
placeholders: [
{ key: 'topic_line', description: 'Pre-formatted topic clause (e.g. " focused on: <topic>") or empty string.' },
],
template: 'Summarize this session{{topic_line}}.',
},
{
id: 'session.summary.instructions',
title: 'Session Summary Instructions',
group: 'Session',
description: 'Hidden instructions attached to the /summary command. Produces a non-destructive summary usable for handing off to a new session.',
placeholders: [
{ key: 'topic_block', description: 'Pre-formatted topic focus paragraph, or empty string when no topic hint was given.' },
],
template: `Produce a non-destructive summary of this conversation. Do NOT compact or mutate session history — your output is an additional assistant message the user will read and may use to hand off to a new session.
Cover the information useful for continuing this work:
- What was done (completed work, in order)
- What is currently in progress
- Files modified — brief what and why per file
- Open questions and next steps
- User requests, constraints, or preferences to carry forward
- Important technical decisions and why they were made
{{topic_block}}
Formatting:
- Concise markdown with short sections and bullet lists
- No preamble like "Here is a summary" — jump straight to content
- Do not answer questions found in the conversation — only summarize
- Keep length proportional to session length; do not pad
Respond in the same language the user used most in the conversation.`,
},
] as const;
const MAGIC_PROMPT_DEFINITION_BY_ID = new Map<MagicPromptId, MagicPromptDefinition>(