refactor: rename anthropic-auto-compact to anthropic-context-window-limit-recovery
The old name 'auto-compact' was misleading - the hook does much more than just compaction. It's a full recovery pipeline for context window limit errors including: - DCP (Dynamic Context Pruning) - Aggressive/single truncation - Summarize with retry - Emergency message revert The new name accurately describes its purpose: recovering from Anthropic context window limit exceeded errors. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -868,7 +868,7 @@ Oh My OpenCode は以下の場所からフックを読み込んで実行しま
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
利用可能なフック:`todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-output-truncator`, `tool-output-truncator`, `directory-agents-injector`, `directory-readme-injector`, `empty-task-response-detector`, `think-mode`, `anthropic-auto-compact`, `rules-injector`, `background-notification`, `auto-update-checker`, `startup-toast`, `keyword-detector`, `agent-usage-reminder`, `non-interactive-env`, `interactive-bash-session`, `empty-message-sanitizer`, `preemptive-compaction`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`
|
利用可能なフック:`todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-output-truncator`, `tool-output-truncator`, `directory-agents-injector`, `directory-readme-injector`, `empty-task-response-detector`, `think-mode`, `anthropic-context-window-limit-recovery`, `rules-injector`, `background-notification`, `auto-update-checker`, `startup-toast`, `keyword-detector`, `agent-usage-reminder`, `non-interactive-env`, `interactive-bash-session`, `empty-message-sanitizer`, `preemptive-compaction`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`
|
||||||
|
|
||||||
**`auto-update-checker`と`startup-toast`について**: `startup-toast` フックは `auto-update-checker` のサブ機能です。アップデートチェックは有効なまま起動トースト通知のみを無効化するには、`disabled_hooks` に `"startup-toast"` を追加してください。すべてのアップデートチェック機能(トーストを含む)を無効化するには、`"auto-update-checker"` を追加してください。
|
**`auto-update-checker`と`startup-toast`について**: `startup-toast` フックは `auto-update-checker` のサブ機能です。アップデートチェックは有効なまま起動トースト通知のみを無効化するには、`disabled_hooks` に `"startup-toast"` を追加してください。すべてのアップデートチェック機能(トーストを含む)を無効化するには、`"auto-update-checker"` を追加してください。
|
||||||
|
|
||||||
|
|||||||
@@ -865,7 +865,7 @@ Schema 자동 완성이 지원됩니다:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
사용 가능한 훅: `todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-output-truncator`, `tool-output-truncator`, `directory-agents-injector`, `directory-readme-injector`, `empty-task-response-detector`, `think-mode`, `anthropic-auto-compact`, `rules-injector`, `background-notification`, `auto-update-checker`, `startup-toast`, `keyword-detector`, `agent-usage-reminder`, `non-interactive-env`, `interactive-bash-session`, `empty-message-sanitizer`, `preemptive-compaction`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`
|
사용 가능한 훅: `todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-output-truncator`, `tool-output-truncator`, `directory-agents-injector`, `directory-readme-injector`, `empty-task-response-detector`, `think-mode`, `anthropic-context-window-limit-recovery`, `rules-injector`, `background-notification`, `auto-update-checker`, `startup-toast`, `keyword-detector`, `agent-usage-reminder`, `non-interactive-env`, `interactive-bash-session`, `empty-message-sanitizer`, `preemptive-compaction`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`
|
||||||
|
|
||||||
**`auto-update-checker`와 `startup-toast`에 대한 참고사항**: `startup-toast` 훅은 `auto-update-checker`의 하위 기능입니다. 업데이트 확인은 유지하면서 시작 토스트 알림만 비활성화하려면 `disabled_hooks`에 `"startup-toast"`를 추가하세요. 모든 업데이트 확인 기능(토스트 포함)을 비활성화하려면 `"auto-update-checker"`를 추가하세요.
|
**`auto-update-checker`와 `startup-toast`에 대한 참고사항**: `startup-toast` 훅은 `auto-update-checker`의 하위 기능입니다. 업데이트 확인은 유지하면서 시작 토스트 알림만 비활성화하려면 `disabled_hooks`에 `"startup-toast"`를 추가하세요. 모든 업데이트 확인 기능(토스트 포함)을 비활성화하려면 `"auto-update-checker"`를 추가하세요.
|
||||||
|
|
||||||
|
|||||||
@@ -904,7 +904,7 @@ Disable specific built-in hooks via `disabled_hooks` in `~/.config/opencode/oh-m
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Available hooks: `todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-output-truncator`, `tool-output-truncator`, `directory-agents-injector`, `directory-readme-injector`, `empty-task-response-detector`, `think-mode`, `anthropic-auto-compact`, `rules-injector`, `background-notification`, `auto-update-checker`, `startup-toast`, `keyword-detector`, `agent-usage-reminder`, `non-interactive-env`, `interactive-bash-session`, `empty-message-sanitizer`, `preemptive-compaction`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`
|
Available hooks: `todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-output-truncator`, `tool-output-truncator`, `directory-agents-injector`, `directory-readme-injector`, `empty-task-response-detector`, `think-mode`, `anthropic-context-window-limit-recovery`, `rules-injector`, `background-notification`, `auto-update-checker`, `startup-toast`, `keyword-detector`, `agent-usage-reminder`, `non-interactive-env`, `interactive-bash-session`, `empty-message-sanitizer`, `preemptive-compaction`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`
|
||||||
|
|
||||||
**Note on `auto-update-checker` and `startup-toast`**: The `startup-toast` hook is a sub-feature of `auto-update-checker`. To disable only the startup toast notification while keeping update checking enabled, add `"startup-toast"` to `disabled_hooks`. To disable all update checking features (including the toast), add `"auto-update-checker"` to `disabled_hooks`.
|
**Note on `auto-update-checker` and `startup-toast`**: The `startup-toast` hook is a sub-feature of `auto-update-checker`. To disable only the startup toast notification while keeping update checking enabled, add `"startup-toast"` to `disabled_hooks`. To disable all update checking features (including the toast), add `"auto-update-checker"` to `disabled_hooks`.
|
||||||
|
|
||||||
|
|||||||
@@ -872,7 +872,7 @@ Sisyphus Agent 也能自定义:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
可关的 hook:`todo-continuation-enforcer`、`context-window-monitor`、`session-recovery`、`session-notification`、`comment-checker`、`grep-output-truncator`、`tool-output-truncator`、`directory-agents-injector`、`directory-readme-injector`、`empty-task-response-detector`、`think-mode`、`anthropic-auto-compact`、`rules-injector`、`background-notification`、`auto-update-checker`、`startup-toast`、`keyword-detector`、`agent-usage-reminder`、`non-interactive-env`、`interactive-bash-session`、`empty-message-sanitizer`、`preemptive-compaction`、`compaction-context-injector`、`thinking-block-validator`、`claude-code-hooks`
|
可关的 hook:`todo-continuation-enforcer`、`context-window-monitor`、`session-recovery`、`session-notification`、`comment-checker`、`grep-output-truncator`、`tool-output-truncator`、`directory-agents-injector`、`directory-readme-injector`、`empty-task-response-detector`、`think-mode`、`anthropic-context-window-limit-recovery`、`rules-injector`、`background-notification`、`auto-update-checker`、`startup-toast`、`keyword-detector`、`agent-usage-reminder`、`non-interactive-env`、`interactive-bash-session`、`empty-message-sanitizer`、`preemptive-compaction`、`compaction-context-injector`、`thinking-block-validator`、`claude-code-hooks`
|
||||||
|
|
||||||
**关于 `auto-update-checker` 和 `startup-toast`**: `startup-toast` hook 是 `auto-update-checker` 的子功能。若想保持更新检查但只禁用启动提示通知,在 `disabled_hooks` 中添加 `"startup-toast"`。若要禁用所有更新检查功能(包括提示),添加 `"auto-update-checker"`。
|
**关于 `auto-update-checker` 和 `startup-toast`**: `startup-toast` hook 是 `auto-update-checker` 的子功能。若想保持更新检查但只禁用启动提示通知,在 `disabled_hooks` 中添加 `"startup-toast"`。若要禁用所有更新检查功能(包括提示),添加 `"auto-update-checker"`。
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
"directory-readme-injector",
|
"directory-readme-injector",
|
||||||
"empty-task-response-detector",
|
"empty-task-response-detector",
|
||||||
"think-mode",
|
"think-mode",
|
||||||
"anthropic-auto-compact",
|
"anthropic-context-window-limit-recovery",
|
||||||
"rules-injector",
|
"rules-injector",
|
||||||
"background-notification",
|
"background-notification",
|
||||||
"auto-update-checker",
|
"auto-update-checker",
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const HookNameSchema = z.enum([
|
|||||||
"directory-readme-injector",
|
"directory-readme-injector",
|
||||||
"empty-task-response-detector",
|
"empty-task-response-detector",
|
||||||
"think-mode",
|
"think-mode",
|
||||||
"anthropic-auto-compact",
|
"anthropic-context-window-limit-recovery",
|
||||||
"rules-injector",
|
"rules-injector",
|
||||||
"background-notification",
|
"background-notification",
|
||||||
"auto-update-checker",
|
"auto-update-checker",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Lifecycle hooks that intercept/modify agent behavior. Inject context, enforce ru
|
|||||||
```
|
```
|
||||||
hooks/
|
hooks/
|
||||||
├── agent-usage-reminder/ # Remind to use specialized agents
|
├── agent-usage-reminder/ # Remind to use specialized agents
|
||||||
├── anthropic-auto-compact/ # Auto-compact Claude at token limit
|
├── anthropic-context-window-limit-recovery/ # Auto-compact Claude at token limit
|
||||||
├── auto-update-checker/ # Version update notifications
|
├── auto-update-checker/ # Version update notifications
|
||||||
├── background-notification/ # OS notify on background task complete
|
├── background-notification/ # OS notify on background task complete
|
||||||
├── claude-code-hooks/ # Claude Code settings.json integration
|
├── claude-code-hooks/ # Claude Code settings.json integration
|
||||||
@@ -40,7 +40,7 @@ hooks/
|
|||||||
| Category | Hooks | Purpose |
|
| Category | Hooks | Purpose |
|
||||||
|----------|-------|---------|
|
|----------|-------|---------|
|
||||||
| Context Injection | directory-agents-injector, directory-readme-injector, rules-injector, compaction-context-injector | Auto-inject relevant context |
|
| Context Injection | directory-agents-injector, directory-readme-injector, rules-injector, compaction-context-injector | Auto-inject relevant context |
|
||||||
| Session Management | session-recovery, anthropic-auto-compact, preemptive-compaction, empty-message-sanitizer | Handle session lifecycle |
|
| Session Management | session-recovery, anthropic-context-window-limit-recovery, preemptive-compaction, empty-message-sanitizer | Handle session lifecycle |
|
||||||
| Output Control | comment-checker, tool-output-truncator | Control agent output quality |
|
| Output Control | comment-checker, tool-output-truncator | Control agent output quality |
|
||||||
| Notifications | session-notification, background-notification, auto-update-checker | OS/user notifications |
|
| Notifications | session-notification, background-notification, auto-update-checker | OS/user notifications |
|
||||||
| Behavior Enforcement | todo-continuation-enforcer, keyword-detector, think-mode, agent-usage-reminder | Enforce agent behavior |
|
| Behavior Enforcement | todo-continuation-enforcer, keyword-detector, think-mode, agent-usage-reminder | Enforce agent behavior |
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import { parseAnthropicTokenLimitError } from "./parser"
|
|||||||
import { executeCompact, getLastAssistant } from "./executor"
|
import { executeCompact, getLastAssistant } from "./executor"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
|
|
||||||
export interface AnthropicAutoCompactOptions {
|
export interface AnthropicContextWindowLimitRecoveryOptions {
|
||||||
experimental?: ExperimentalConfig
|
experimental?: ExperimentalConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAutoCompactState(): AutoCompactState {
|
function createRecoveryState(): AutoCompactState {
|
||||||
return {
|
return {
|
||||||
pendingCompact: new Set<string>(),
|
pendingCompact: new Set<string>(),
|
||||||
errorDataBySession: new Map<string, ParsedTokenLimitError>(),
|
errorDataBySession: new Map<string, ParsedTokenLimitError>(),
|
||||||
@@ -22,8 +22,8 @@ function createAutoCompactState(): AutoCompactState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createAnthropicAutoCompactHook(ctx: PluginInput, options?: AnthropicAutoCompactOptions) {
|
export function createAnthropicContextWindowLimitRecoveryHook(ctx: PluginInput, options?: AnthropicContextWindowLimitRecoveryOptions) {
|
||||||
const autoCompactState = createAutoCompactState()
|
const autoCompactState = createRecoveryState()
|
||||||
const experimental = options?.experimental
|
const experimental = options?.experimental
|
||||||
|
|
||||||
const eventHandler = async ({ event }: { event: { type: string; properties?: unknown } }) => {
|
const eventHandler = async ({ event }: { event: { type: string; properties?: unknown } }) => {
|
||||||
@@ -7,7 +7,7 @@ export { createToolOutputTruncatorHook } from "./tool-output-truncator";
|
|||||||
export { createDirectoryAgentsInjectorHook } from "./directory-agents-injector";
|
export { createDirectoryAgentsInjectorHook } from "./directory-agents-injector";
|
||||||
export { createDirectoryReadmeInjectorHook } from "./directory-readme-injector";
|
export { createDirectoryReadmeInjectorHook } from "./directory-readme-injector";
|
||||||
export { createEmptyTaskResponseDetectorHook } from "./empty-task-response-detector";
|
export { createEmptyTaskResponseDetectorHook } from "./empty-task-response-detector";
|
||||||
export { createAnthropicAutoCompactHook, type AnthropicAutoCompactOptions } from "./anthropic-auto-compact";
|
export { createAnthropicContextWindowLimitRecoveryHook, type AnthropicContextWindowLimitRecoveryOptions } from "./anthropic-context-window-limit-recovery";
|
||||||
export { createPreemptiveCompactionHook, type PreemptiveCompactionOptions, type SummarizeContext, type BeforeSummarizeCallback } from "./preemptive-compaction";
|
export { createPreemptiveCompactionHook, type PreemptiveCompactionOptions, type SummarizeContext, type BeforeSummarizeCallback } from "./preemptive-compaction";
|
||||||
export { createCompactionContextInjector } from "./compaction-context-injector";
|
export { createCompactionContextInjector } from "./compaction-context-injector";
|
||||||
export { createThinkModeHook } from "./think-mode";
|
export { createThinkModeHook } from "./think-mode";
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
createEmptyTaskResponseDetectorHook,
|
createEmptyTaskResponseDetectorHook,
|
||||||
createThinkModeHook,
|
createThinkModeHook,
|
||||||
createClaudeCodeHooksHook,
|
createClaudeCodeHooksHook,
|
||||||
createAnthropicAutoCompactHook,
|
createAnthropicContextWindowLimitRecoveryHook,
|
||||||
createPreemptiveCompactionHook,
|
createPreemptiveCompactionHook,
|
||||||
createCompactionContextInjector,
|
createCompactionContextInjector,
|
||||||
createRulesInjectorHook,
|
createRulesInjectorHook,
|
||||||
@@ -266,8 +266,8 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
const claudeCodeHooks = createClaudeCodeHooksHook(ctx, {
|
const claudeCodeHooks = createClaudeCodeHooksHook(ctx, {
|
||||||
disabledHooks: (pluginConfig.claude_code?.hooks ?? true) ? undefined : true,
|
disabledHooks: (pluginConfig.claude_code?.hooks ?? true) ? undefined : true,
|
||||||
});
|
});
|
||||||
const anthropicAutoCompact = isHookEnabled("anthropic-auto-compact")
|
const anthropicContextWindowLimitRecovery = isHookEnabled("anthropic-context-window-limit-recovery")
|
||||||
? createAnthropicAutoCompactHook(ctx, { experimental: pluginConfig.experimental })
|
? createAnthropicContextWindowLimitRecoveryHook(ctx, { experimental: pluginConfig.experimental })
|
||||||
: null;
|
: null;
|
||||||
const compactionContextInjector = createCompactionContextInjector();
|
const compactionContextInjector = createCompactionContextInjector();
|
||||||
const preemptiveCompaction = createPreemptiveCompactionHook(ctx, {
|
const preemptiveCompaction = createPreemptiveCompactionHook(ctx, {
|
||||||
@@ -566,7 +566,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
await directoryReadmeInjector?.event(input);
|
await directoryReadmeInjector?.event(input);
|
||||||
await rulesInjector?.event(input);
|
await rulesInjector?.event(input);
|
||||||
await thinkMode?.event(input);
|
await thinkMode?.event(input);
|
||||||
await anthropicAutoCompact?.event(input);
|
await anthropicContextWindowLimitRecovery?.event(input);
|
||||||
await preemptiveCompaction?.event(input);
|
await preemptiveCompaction?.event(input);
|
||||||
await agentUsageReminder?.event(input);
|
await agentUsageReminder?.event(input);
|
||||||
await interactiveBashSession?.event(input);
|
await interactiveBashSession?.event(input);
|
||||||
|
|||||||
Reference in New Issue
Block a user