feat(preemptive-compaction): add onBeforeSummarize callback and context injection

- Added BeforeSummarizeCallback type to allow injecting context before session summarization
- Added onBeforeSummarize option to PreemptiveCompactionOptions
- Created compaction-context-injector module that injects summarization instructions with sections:
  - User Requests (As-Is)
  - Final Goal
  - Work Completed
  - Remaining Tasks
  - MUST NOT Do (Critical Constraints)
- Wired up callback invocation in preemptive-compaction before calling summarize API
- Exported new hook from src/hooks/index.ts

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-20 15:39:54 +09:00
parent 8406f3d6d7
commit a3ff28b250
4 changed files with 83 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ import {
createClaudeCodeHooksHook,
createAnthropicAutoCompactHook,
createPreemptiveCompactionHook,
createCompactionContextInjector,
createRulesInjectorHook,
createBackgroundNotificationHook,
createAutoUpdateCheckerHook,
@@ -256,7 +257,11 @@ 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 compactionContextInjector = createCompactionContextInjector();
const preemptiveCompaction = createPreemptiveCompactionHook(ctx, {
experimental: pluginConfig.experimental,
onBeforeSummarize: compactionContextInjector,
});
const rulesInjector = isHookEnabled("rules-injector")
? createRulesInjectorHook(ctx)
: null;