diff --git a/README.ja.md b/README.ja.md index f76c152..12d1fbc 100644 --- a/README.ja.md +++ b/README.ja.md @@ -874,7 +874,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-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`, `ralph-loop` +利用可能なフック:`todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-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`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`, `ralph-loop` **`auto-update-checker`と`startup-toast`について**: `startup-toast` フックは `auto-update-checker` のサブ機能です。アップデートチェックは有効なまま起動トースト通知のみを無効化するには、`disabled_hooks` に `"startup-toast"` を追加してください。すべてのアップデートチェック機能(トーストを含む)を無効化するには、`"auto-update-checker"` を追加してください。 @@ -926,19 +926,24 @@ OpenCode でサポートされるすべての LSP 構成およびカスタム設 ```json { "experimental": { + "tool_output_truncator": true, + "preemptive_compaction": true, + "truncate_all_tool_outputs": true, "aggressive_truncation": true, - "auto_resume": true, - "truncate_all_tool_outputs": false + "auto_resume": true } } ``` -| オプション | デフォルト | 説明 | -| --------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `aggressive_truncation` | `false` | トークン制限を超えた場合、ツール出力を積極的に切り詰めて制限内に収めます。デフォルトの切り詰めより積極的です。不十分な場合は要約/復元にフォールバックします。 | -| `auto_resume` | `false` | thinking block エラーや thinking disabled violation からの回復成功後、自動的にセッションを再開します。最後のユーザーメッセージを抽出して続行します。 | -| `truncate_all_tool_outputs` | `true` | プロンプトが長くなりすぎるのを防ぐため、コンテキストウィンドウの使用状況に基づいてすべてのツール出力を動的に切り詰めます。完全なツール出力が必要な場合は`false`に設定して無効化します。 | -| `dcp_for_compaction` | `false` | コンパクション用DCP(動的コンテキスト整理)を有効化 - トークン制限超過時に最初に実行されます。コンパクション前に重複したツール呼び出しと古いツール出力を整理します。 | +| オプション | デフォルト | 説明 | +| --------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `tool_output_truncator` | `false` | コンテキストウィンドウの使用状況に基づいてツール出力(Grep、Glob、LSP、AST-grepなど)を動的に切り詰めます。プロンプトが長くなりすぎるのを防ぎます。 | +| `preemptive_compaction` | `false` | トークン制限に達する前にセッションを事前にコンパクションします。デフォルトでコンテキストウィンドウ使用率80%で実行されます。 | +| `preemptive_compaction_threshold` | `0.80` | プリエンプティブコンパクションをトリガーする閾値(0.5-0.95)。`preemptive_compaction`が有効な場合のみ適用されます。 | +| `truncate_all_tool_outputs` | `false` | `tool_output_truncator`が有効な場合、ホワイトリストのツール(Grep、Glob、LSP、AST-grep)だけでなく、すべてのツール出力を切り詰めます。 | +| `aggressive_truncation` | `false` | トークン制限を超えた場合、ツール出力を積極的に切り詰めて制限内に収めます。デフォルトの切り詰めより積極的です。不十分な場合は要約/復元にフォールバックします。 | +| `auto_resume` | `false` | thinking block エラーや thinking disabled violation からの回復成功後、自動的にセッションを再開します。最後のユーザーメッセージを抽出して続行します。 | +| `dcp_for_compaction` | `false` | コンパクション用DCP(動的コンテキスト整理)を有効化 - トークン制限超過時に最初に実行されます。コンパクション前に重複したツール呼び出しと古いツール出力を整理します。 | **警告**:これらの機能は実験的であり、予期しない動作を引き起こす可能性があります。影響を理解した場合にのみ有効にしてください。 diff --git a/README.ko.md b/README.ko.md index 8ef87c7..7e5dc9a 100644 --- a/README.ko.md +++ b/README.ko.md @@ -871,7 +871,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-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`, `ralph-loop` +사용 가능한 훅: `todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-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`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`, `ralph-loop` **`auto-update-checker`와 `startup-toast`에 대한 참고사항**: `startup-toast` 훅은 `auto-update-checker`의 하위 기능입니다. 업데이트 확인은 유지하면서 시작 토스트 알림만 비활성화하려면 `disabled_hooks`에 `"startup-toast"`를 추가하세요. 모든 업데이트 확인 기능(토스트 포함)을 비활성화하려면 `"auto-update-checker"`를 추가하세요. @@ -923,19 +923,24 @@ OpenCode 에서 지원하는 모든 LSP 구성 및 커스텀 설정 (opencode.js ```json { "experimental": { + "tool_output_truncator": true, + "preemptive_compaction": true, + "truncate_all_tool_outputs": true, "aggressive_truncation": true, - "auto_resume": true, - "truncate_all_tool_outputs": false + "auto_resume": true } } ``` -| 옵션 | 기본값 | 설명 | -| --------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `aggressive_truncation` | `false` | 토큰 제한을 초과하면 도구 출력을 공격적으로 잘라내어 제한 내에 맞춥니다. 기본 truncation보다 더 공격적입니다. 부족하면 요약/복구로 fallback합니다. | -| `auto_resume` | `false` | thinking block 에러나 thinking disabled violation으로부터 성공적으로 복구한 후 자동으로 세션을 재개합니다. 마지막 사용자 메시지를 추출하여 계속합니다. | -| `truncate_all_tool_outputs` | `true` | 프롬프트가 너무 길어지는 것을 방지하기 위해 컨텍스트 윈도우 사용량에 따라 모든 도구 출력을 동적으로 잘라냅니다. 전체 도구 출력이 필요한 경우 `false`로 설정하여 비활성화하세요. | -| `dcp_for_compaction` | `false` | 컴팩션용 DCP(동적 컨텍스트 정리) 활성화 - 토큰 제한 초과 시 먼저 실행됩니다. 컴팩션 전에 중복 도구 호출과 오래된 도구 출력을 정리합니다. | +| 옵션 | 기본값 | 설명 | +| --------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `tool_output_truncator` | `false` | 컨텍스트 윈도우 사용량에 따라 도구 출력(Grep, Glob, LSP, AST-grep 등)을 동적으로 잘라냅니다. 프롬프트가 너무 길어지는 것을 방지합니다. | +| `preemptive_compaction` | `false` | 토큰 제한에 도달하기 전에 세션을 미리 컴팩션합니다. 기본적으로 컨텍스트 윈도우 사용량이 80%일 때 실행됩니다. | +| `preemptive_compaction_threshold` | `0.80` | 선제적 컴팩션을 트리거할 임계값 비율(0.5-0.95). `preemptive_compaction`이 활성화된 경우에만 적용됩니다. | +| `truncate_all_tool_outputs` | `false` | `tool_output_truncator`가 활성화된 경우, 화이트리스트 도구(Grep, Glob, LSP, AST-grep)만이 아닌 모든 도구 출력을 잘라냅니다. | +| `aggressive_truncation` | `false` | 토큰 제한을 초과하면 도구 출력을 공격적으로 잘라내어 제한 내에 맞춥니다. 기본 truncation보다 더 공격적입니다. 부족하면 요약/복구로 fallback합니다. | +| `auto_resume` | `false` | thinking block 에러나 thinking disabled violation으로부터 성공적으로 복구한 후 자동으로 세션을 재개합니다. 마지막 사용자 메시지를 추출하여 계속합니다. | +| `dcp_for_compaction` | `false` | 컴팩션용 DCP(동적 컨텍스트 정리) 활성화 - 토큰 제한 초과 시 먼저 실행됩니다. 컴팩션 전에 중복 도구 호출과 오래된 도구 출력을 정리합니다. | **경고**: 이 기능들은 실험적이며 예상치 못한 동작을 유발할 수 있습니다. 의미를 이해한 경우에만 활성화하세요. diff --git a/README.md b/README.md index 6ad0292..45bda58 100644 --- a/README.md +++ b/README.md @@ -910,7 +910,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-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`, `ralph-loop` +Available hooks: `todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-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`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`, `ralph-loop` **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`. @@ -962,18 +962,23 @@ Opt-in experimental features that may change or be removed in future versions. U ```json { "experimental": { + "tool_output_truncator": true, + "preemptive_compaction": true, + "truncate_all_tool_outputs": true, "aggressive_truncation": true, - "auto_resume": true, - "truncate_all_tool_outputs": false + "auto_resume": true } } ``` | Option | Default | Description | | --------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `tool_output_truncator` | `false` | Enable dynamic truncation of tool outputs (Grep, Glob, LSP, AST-grep, etc.) based on context window usage. Prevents prompts from becoming too long. | +| `preemptive_compaction` | `false` | Compacts session proactively before hitting hard token limits. Runs at 80% context window usage by default. | +| `preemptive_compaction_threshold` | `0.80` | Threshold percentage (0.5-0.95) to trigger preemptive compaction. Only applies when `preemptive_compaction` is enabled. | +| `truncate_all_tool_outputs` | `false` | When `tool_output_truncator` is enabled, truncates ALL tool outputs instead of just whitelisted tools (Grep, Glob, LSP, AST-grep). | | `aggressive_truncation` | `false` | When token limit is exceeded, aggressively truncates tool outputs to fit within limits. More aggressive than the default truncation behavior. Falls back to summarize/revert if insufficient. | | `auto_resume` | `false` | Automatically resumes session after successful recovery from thinking block errors or thinking disabled violations. Extracts the last user message and continues. | -| `truncate_all_tool_outputs` | `true` | Dynamically truncates ALL tool outputs based on context window usage to prevent prompts from becoming too long. Disable by setting to `false` if you need full tool outputs. | | `dcp_for_compaction` | `false` | Enable DCP (Dynamic Context Pruning) for compaction - runs first when token limit exceeded. Prunes duplicate tool calls and old tool outputs before running compaction. | **Warning**: These features are experimental and may cause unexpected behavior. Enable only if you understand the implications. diff --git a/README.zh-cn.md b/README.zh-cn.md index b794a3b..401ecd6 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -878,7 +878,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-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`、`ralph-loop` +可关的 hook:`todo-continuation-enforcer`、`context-window-monitor`、`session-recovery`、`session-notification`、`comment-checker`、`grep-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`、`compaction-context-injector`、`thinking-block-validator`、`claude-code-hooks`、`ralph-loop` **关于 `auto-update-checker` 和 `startup-toast`**: `startup-toast` hook 是 `auto-update-checker` 的子功能。若想保持更新检查但只禁用启动提示通知,在 `disabled_hooks` 中添加 `"startup-toast"`。若要禁用所有更新检查功能(包括提示),添加 `"auto-update-checker"`。 @@ -930,19 +930,24 @@ Oh My OpenCode 送你重构工具(重命名、代码操作)。 ```json { "experimental": { + "tool_output_truncator": true, + "preemptive_compaction": true, + "truncate_all_tool_outputs": true, "aggressive_truncation": true, - "auto_resume": true, - "truncate_all_tool_outputs": false + "auto_resume": true } } ``` -| 选项 | 默认值 | 说明 | -| --------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| `aggressive_truncation` | `false` | 超出 token 限制时,激进地截断工具输出以适应限制。比默认截断更激进。不够的话会回退到摘要/恢复。 | -| `auto_resume` | `false` | 从 thinking block 错误或 thinking disabled violation 成功恢复后,自动恢复会话。提取最后一条用户消息继续执行。 | -| `truncate_all_tool_outputs` | `true` | 为防止提示过长,根据上下文窗口使用情况动态截断所有工具输出。如需完整工具输出,设置为 `false` 禁用此功能。 | -| `dcp_for_compaction` | `false` | 启用压缩用 DCP(动态上下文剪枝)- 在超出 token 限制时首先执行。在压缩前清理重复的工具调用和旧的工具输出。 | +| 选项 | 默认值 | 说明 | +| --------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| `tool_output_truncator` | `false` | 根据上下文窗口使用情况动态截断工具输出(Grep、Glob、LSP、AST-grep 等)。防止提示过长。 | +| `preemptive_compaction` | `false` | 在达到 token 限制之前主动压缩会话。默认在上下文窗口使用率达到 80% 时运行。 | +| `preemptive_compaction_threshold` | `0.80` | 触发预先压缩的阈值比例(0.5-0.95)。仅在 `preemptive_compaction` 启用时生效。 | +| `truncate_all_tool_outputs` | `false` | 当 `tool_output_truncator` 启用时,截断所有工具输出,而不仅仅是白名单工具(Grep、Glob、LSP、AST-grep)。 | +| `aggressive_truncation` | `false` | 超出 token 限制时,激进地截断工具输出以适应限制。比默认截断更激进。不够的话会回退到摘要/恢复。 | +| `auto_resume` | `false` | 从 thinking block 错误或 thinking disabled violation 成功恢复后,自动恢复会话。提取最后一条用户消息继续执行。 | +| `dcp_for_compaction` | `false` | 启用压缩用 DCP(动态上下文剪枝)- 在超出 token 限制时首先执行。在压缩前清理重复的工具调用和旧的工具输出。 | **警告**:这些功能是实验性的,可能会导致意外行为。只有在理解其影响的情况下才启用。 diff --git a/assets/oh-my-opencode.schema.json b/assets/oh-my-opencode.schema.json index 8b5256d..fd5bf2c 100644 --- a/assets/oh-my-opencode.schema.json +++ b/assets/oh-my-opencode.schema.json @@ -45,7 +45,6 @@ "session-notification", "comment-checker", "grep-output-truncator", - "tool-output-truncator", "directory-agents-injector", "directory-readme-injector", "empty-task-response-detector", @@ -1402,6 +1401,9 @@ "auto_resume": { "type": "boolean" }, + "tool_output_truncator": { + "type": "boolean" + }, "preemptive_compaction": { "type": "boolean" }, @@ -1411,7 +1413,6 @@ "maximum": 0.95 }, "truncate_all_tool_outputs": { - "default": true, "type": "boolean" }, "dynamic_context_pruning": { diff --git a/src/config/schema.ts b/src/config/schema.ts index 1440100..c3eb977 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -49,7 +49,6 @@ export const HookNameSchema = z.enum([ "session-notification", "comment-checker", "grep-output-truncator", - "tool-output-truncator", "directory-agents-injector", "directory-readme-injector", "empty-task-response-detector", @@ -164,12 +163,14 @@ export const DynamicContextPruningConfigSchema = z.object({ export const ExperimentalConfigSchema = z.object({ aggressive_truncation: z.boolean().optional(), auto_resume: z.boolean().optional(), - /** Enable preemptive compaction at threshold (default: true) */ + /** Enable tool output truncator - dynamically truncates tool outputs based on context window (default: false) */ + tool_output_truncator: z.boolean().optional(), + /** Enable preemptive compaction at threshold (default: false) */ preemptive_compaction: z.boolean().optional(), /** Threshold percentage to trigger preemptive compaction (default: 0.80) */ preemptive_compaction_threshold: z.number().min(0.5).max(0.95).optional(), - /** Truncate all tool outputs, not just whitelisted tools (default: true) */ - truncate_all_tool_outputs: z.boolean().default(true), + /** Truncate all tool outputs, not just whitelisted tools (default: false, only applies when tool_output_truncator is enabled) */ + truncate_all_tool_outputs: z.boolean().optional(), /** Dynamic context pruning configuration */ dynamic_context_pruning: DynamicContextPruningConfigSchema.optional(), /** Enable DCP (Dynamic Context Pruning) for compaction - runs first when token limit exceeded (default: false) */ diff --git a/src/hooks/preemptive-compaction/index.ts b/src/hooks/preemptive-compaction/index.ts index ee7a257..5ef89cf 100644 --- a/src/hooks/preemptive-compaction/index.ts +++ b/src/hooks/preemptive-compaction/index.ts @@ -82,7 +82,7 @@ export function createPreemptiveCompactionHook( const experimental = options?.experimental const onBeforeSummarize = options?.onBeforeSummarize const getModelLimit = options?.getModelLimit - const enabled = experimental?.preemptive_compaction !== false + const enabled = experimental?.preemptive_compaction === true const threshold = experimental?.preemptive_compaction_threshold ?? DEFAULT_THRESHOLD if (!enabled) { diff --git a/src/hooks/tool-output-truncator.ts b/src/hooks/tool-output-truncator.ts index b852103..7af9df2 100644 --- a/src/hooks/tool-output-truncator.ts +++ b/src/hooks/tool-output-truncator.ts @@ -24,7 +24,7 @@ interface ToolOutputTruncatorOptions { export function createToolOutputTruncatorHook(ctx: PluginInput, options?: ToolOutputTruncatorOptions) { const truncator = createDynamicTruncator(ctx) - const truncateAll = options?.experimental?.truncate_all_tool_outputs ?? true + const truncateAll = options?.experimental?.truncate_all_tool_outputs ?? false const toolExecuteAfter = async ( input: { tool: string; sessionID: string; callID: string }, diff --git a/src/index.ts b/src/index.ts index ef6b87a..9d11895 100644 --- a/src/index.ts +++ b/src/index.ts @@ -255,7 +255,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { const commentChecker = isHookEnabled("comment-checker") ? createCommentCheckerHooks(pluginConfig.comment_checker) : null; - const toolOutputTruncator = isHookEnabled("tool-output-truncator") + const toolOutputTruncator = pluginConfig.experimental?.tool_output_truncator === true ? createToolOutputTruncatorHook(ctx, { experimental: pluginConfig.experimental }) : null; const directoryAgentsInjector = isHookEnabled("directory-agents-injector")