feat: make preemptive compaction enabled by default (#372)
This commit is contained in:
@@ -66,6 +66,9 @@ export const HookNameSchema = z.enum([
|
||||
"empty-message-sanitizer",
|
||||
"thinking-block-validator",
|
||||
"ralph-loop",
|
||||
"preemptive-compaction",
|
||||
"compaction-context-injector",
|
||||
"claude-code-hooks",
|
||||
])
|
||||
|
||||
export const BuiltinCommandNameSchema = z.enum([
|
||||
|
||||
@@ -82,10 +82,12 @@ export function createPreemptiveCompactionHook(
|
||||
const experimental = options?.experimental
|
||||
const onBeforeSummarize = options?.onBeforeSummarize
|
||||
const getModelLimit = options?.getModelLimit
|
||||
const enabled = experimental?.preemptive_compaction === true
|
||||
// Preemptive compaction is now enabled by default.
|
||||
// Backward compatibility: explicit false in experimental config disables the hook.
|
||||
const explicitlyDisabled = experimental?.preemptive_compaction === false
|
||||
const threshold = experimental?.preemptive_compaction_threshold ?? DEFAULT_THRESHOLD
|
||||
|
||||
if (!enabled) {
|
||||
if (explicitlyDisabled) {
|
||||
return { event: async () => {} }
|
||||
}
|
||||
|
||||
|
||||
16
src/index.ts
16
src/index.ts
@@ -279,12 +279,16 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
||||
dcpForCompaction: pluginConfig.experimental?.dcp_for_compaction,
|
||||
})
|
||||
: null;
|
||||
const compactionContextInjector = createCompactionContextInjector();
|
||||
const preemptiveCompaction = createPreemptiveCompactionHook(ctx, {
|
||||
experimental: pluginConfig.experimental,
|
||||
onBeforeSummarize: compactionContextInjector,
|
||||
getModelLimit,
|
||||
});
|
||||
const compactionContextInjector = isHookEnabled("compaction-context-injector")
|
||||
? createCompactionContextInjector()
|
||||
: undefined;
|
||||
const preemptiveCompaction = isHookEnabled("preemptive-compaction")
|
||||
? createPreemptiveCompactionHook(ctx, {
|
||||
experimental: pluginConfig.experimental,
|
||||
onBeforeSummarize: compactionContextInjector,
|
||||
getModelLimit,
|
||||
})
|
||||
: null;
|
||||
const rulesInjector = isHookEnabled("rules-injector")
|
||||
? createRulesInjectorHook(ctx)
|
||||
: null;
|
||||
|
||||
Reference in New Issue
Block a user