diff options
Diffstat (limited to 'packages/web/src')
| -rw-r--r-- | packages/web/src/content/docs/plugins.mdx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/web/src/content/docs/plugins.mdx b/packages/web/src/content/docs/plugins.mdx index 58673d46d..6982b4c93 100644 --- a/packages/web/src/content/docs/plugins.mdx +++ b/packages/web/src/content/docs/plugins.mdx @@ -205,3 +205,31 @@ The `tool` helper creates a custom tool that opencode can call. It takes a Zod s - `execute`: Function that runs when the tool is called Your custom tools will be available to opencode alongside built-in tools. + +--- + +### Compaction hooks + +Customize the context included when a session is compacted: + +```ts title=".opencode/plugin/compaction.ts" +import type { Plugin } from "@opencode-ai/plugin" + +export const CompactionPlugin: Plugin = async (ctx) => { + return { + "experimental.session.compacting": async (input, output) => { + // Inject additional context into the compaction prompt + output.context.push(` +## Custom Context + +Include any state that should persist across compaction: +- Current task status +- Important decisions made +- Files being actively worked on +`) + }, + } +} +``` + +The `experimental.session.compacting` hook fires before the LLM generates a continuation summary. Use it to inject domain-specific context that the default compaction prompt would miss. |
