refactor(dcp-for-compaction): migrate from experimental config to hook system

- Add 'dcp-for-compaction' to HookNameSchema
- Remove dcp_for_compaction from ExperimentalConfigSchema
- Update executor.ts to use dcpForCompaction parameter
- Enable DCP by default (can be disabled via disabled_hooks)
- Update all 4 README files (EN, KO, JA, ZH-CN)

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-30 19:08:55 +09:00
parent 61251737d4
commit ec61350664
9 changed files with 35 additions and 24 deletions

View File

@@ -151,6 +151,7 @@ describe("executeCompact lock management", () => {
truncate_all_tool_outputs: false,
aggressive_truncation: true,
}
const dcpForCompaction = true
// #when: Execute compaction with experimental flag
await executeCompact(
@@ -160,6 +161,7 @@ describe("executeCompact lock management", () => {
mockClient,
directory,
experimental,
dcpForCompaction,
)
// #then: Lock should be cleared even on early return

View File

@@ -337,6 +337,7 @@ export async function executeCompact(
client: any,
directory: string,
experimental?: ExperimentalConfig,
dcpForCompaction?: boolean,
): Promise<void> {
if (autoCompactState.compactionInProgress.has(sessionID)) {
await (client as Client).tui
@@ -358,10 +359,10 @@ export async function executeCompact(
const errorData = autoCompactState.errorDataBySession.get(sessionID);
const truncateState = getOrCreateTruncateState(autoCompactState, sessionID);
// DCP FIRST - run before any other recovery attempts when token limit exceeded
// DCP FIRST - run before any other recovery attempts when token limit exceeded (controlled by dcp-for-compaction hook)
const dcpState = getOrCreateDcpState(autoCompactState, sessionID);
if (
experimental?.dcp_for_compaction &&
dcpForCompaction !== false &&
!dcpState.attempted &&
errorData?.currentTokens &&
errorData?.maxTokens &&
@@ -374,7 +375,7 @@ export async function executeCompact(
maxTokens: errorData.maxTokens,
});
const dcpConfig = experimental.dynamic_context_pruning ?? {
const dcpConfig = experimental?.dynamic_context_pruning ?? {
enabled: true,
notification: "detailed" as const,
protected_tools: ["task", "todowrite", "todoread", "lsp_rename", "lsp_code_action_resolve"],
@@ -618,6 +619,7 @@ export async function executeCompact(
client,
directory,
experimental,
dcpForCompaction,
);
}, 500);
return;
@@ -696,6 +698,7 @@ export async function executeCompact(
client,
directory,
experimental,
dcpForCompaction,
);
}, cappedDelay);
return;

View File

@@ -7,6 +7,7 @@ import { log } from "../../shared/logger"
export interface AnthropicContextWindowLimitRecoveryOptions {
experimental?: ExperimentalConfig
dcpForCompaction?: boolean
}
function createRecoveryState(): AutoCompactState {
@@ -25,6 +26,7 @@ function createRecoveryState(): AutoCompactState {
export function createAnthropicContextWindowLimitRecoveryHook(ctx: PluginInput, options?: AnthropicContextWindowLimitRecoveryOptions) {
const autoCompactState = createRecoveryState()
const experimental = options?.experimental
const dcpForCompaction = options?.dcpForCompaction
const eventHandler = async ({ event }: { event: { type: string; properties?: unknown } }) => {
const props = event.properties as Record<string, unknown> | undefined
@@ -81,7 +83,8 @@ export function createAnthropicContextWindowLimitRecoveryHook(ctx: PluginInput,
autoCompactState,
ctx.client,
ctx.directory,
experimental
experimental,
dcpForCompaction
)
}, 300)
}
@@ -140,7 +143,8 @@ export function createAnthropicContextWindowLimitRecoveryHook(ctx: PluginInput,
autoCompactState,
ctx.client,
ctx.directory,
experimental
experimental,
dcpForCompaction
)
}
}