feat(preemptive-compaction): implement automatic session compaction at token threshold

Monitor token usage after assistant responses and automatically trigger session
compaction when exceeding configured threshold (default 80%). Toast notifications
provide user feedback on compaction status.

Controlled via experimental.preemptive_compaction config option.

🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-20 13:19:32 +09:00
parent 6e72173cde
commit 3c039cba49
6 changed files with 236 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ import {
createThinkModeHook,
createClaudeCodeHooksHook,
createAnthropicAutoCompactHook,
createPreemptiveCompactionHook,
createRulesInjectorHook,
createBackgroundNotificationHook,
createAutoUpdateCheckerHook,
@@ -255,6 +256,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const anthropicAutoCompact = isHookEnabled("anthropic-auto-compact")
? createAnthropicAutoCompactHook(ctx, { experimental: pluginConfig.experimental })
: null;
const preemptiveCompaction = createPreemptiveCompactionHook(ctx, { experimental: pluginConfig.experimental });
const rulesInjector = isHookEnabled("rules-injector")
? createRulesInjectorHook(ctx)
: null;
@@ -442,6 +444,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
await rulesInjector?.event(input);
await thinkMode?.event(input);
await anthropicAutoCompact?.event(input);
await preemptiveCompaction?.event(input);
await agentUsageReminder?.event(input);
await interactiveBashSession?.event(input);