summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src
diff options
context:
space:
mode:
authorJoel Hooks <[email protected]>2025-12-17 11:57:09 -0800
committerGitHub <[email protected]>2025-12-17 13:57:09 -0600
commit24430287c5a304ee35ad0089bad1907d7917dee2 (patch)
tree57aaab0c13cb8cc56786ab2a8b4fe7c8a36d5054 /packages/web/src
parent1f527312554c3015286811fc33bb5348d0a27dae (diff)
downloadopencode-24430287c5a304ee35ad0089bad1907d7917dee2.tar.gz
opencode-24430287c5a304ee35ad0089bad1907d7917dee2.zip
feat(plugin): add experimental.session.compacting hook for pre-compaction context injection (#5698)
Co-authored-by: Aiden Cline <[email protected]>
Diffstat (limited to 'packages/web/src')
-rw-r--r--packages/web/src/content/docs/plugins.mdx28
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.