Skip to content

Commit bceeba8

Browse files
committed
feat(hooks): enable tool-output-truncator by default
Enable tool-output-truncator hook by default instead of requiring experimental config opt-in. Users can disable it via disabled_hooks if needed. Changes: - Add tool-output-truncator to HookNameSchema - Remove tool_output_truncator from ExperimentalConfigSchema - Update all README files (EN, KO, JA, ZH-CN) 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent d8f10f5 commit bceeba8

File tree

6 files changed

+11
-20
lines changed

6 files changed

+11
-20
lines changed

README.ja.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ Oh My OpenCode は以下の場所からフックを読み込んで実行しま
874874
}
875875
```
876876

877-
利用可能なフック:`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`
877+
利用可能なフック:`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`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`, `ralph-loop`
878878

879879
**`auto-update-checker``startup-toast`について**: `startup-toast` フックは `auto-update-checker` のサブ機能です。アップデートチェックは有効なまま起動トースト通知のみを無効化するには、`disabled_hooks``"startup-toast"` を追加してください。すべてのアップデートチェック機能(トーストを含む)を無効化するには、`"auto-update-checker"` を追加してください。
880880

@@ -926,7 +926,6 @@ OpenCode でサポートされるすべての LSP 構成およびカスタム設
926926
```json
927927
{
928928
"experimental": {
929-
"tool_output_truncator": true,
930929
"preemptive_compaction": true,
931930
"truncate_all_tool_outputs": true,
932931
"aggressive_truncation": true,
@@ -937,10 +936,9 @@ OpenCode でサポートされるすべての LSP 構成およびカスタム設
937936

938937
| オプション | デフォルト | 説明 |
939938
| --------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
940-
| `tool_output_truncator` | `false` | コンテキストウィンドウの使用状況に基づいてツール出力(Grep、Glob、LSP、AST-grepなど)を動的に切り詰めます。プロンプトが長くなりすぎるのを防ぎます。 |
941939
| `preemptive_compaction` | `false` | トークン制限に達する前にセッションを事前にコンパクションします。デフォルトでコンテキストウィンドウ使用率80%で実行されます。 |
942940
| `preemptive_compaction_threshold` | `0.80` | プリエンプティブコンパクションをトリガーする閾値(0.5-0.95)。`preemptive_compaction`が有効な場合のみ適用されます。 |
943-
| `truncate_all_tool_outputs` | `false` | `tool_output_truncator`が有効な場合、ホワイトリストのツール(Grep、Glob、LSP、AST-grep)だけでなく、すべてのツール出力を切り詰めます。 |
941+
| `truncate_all_tool_outputs` | `false` | ホワイトリストのツール(Grep、Glob、LSP、AST-grep)だけでなく、すべてのツール出力を切り詰めます。Tool output truncator はデフォルトで有効です - `disabled_hooks`で無効化できます。 |
944942
| `aggressive_truncation` | `false` | トークン制限を超えた場合、ツール出力を積極的に切り詰めて制限内に収めます。デフォルトの切り詰めより積極的です。不十分な場合は要約/復元にフォールバックします。 |
945943
| `auto_resume` | `false` | thinking block エラーや thinking disabled violation からの回復成功後、自動的にセッションを再開します。最後のユーザーメッセージを抽出して続行します。 |
946944
| `dcp_for_compaction` | `false` | コンパクション用DCP(動的コンテキスト整理)を有効化 - トークン制限超過時に最初に実行されます。コンパクション前に重複したツール呼び出しと古いツール出力を整理します。 |

README.ko.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ Schema 자동 완성이 지원됩니다:
871871
}
872872
```
873873

874-
사용 가능한 훅: `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`
874+
사용 가능한 훅: `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`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`, `ralph-loop`
875875

876876
**`auto-update-checker``startup-toast`에 대한 참고사항**: `startup-toast` 훅은 `auto-update-checker`의 하위 기능입니다. 업데이트 확인은 유지하면서 시작 토스트 알림만 비활성화하려면 `disabled_hooks``"startup-toast"`를 추가하세요. 모든 업데이트 확인 기능(토스트 포함)을 비활성화하려면 `"auto-update-checker"`를 추가하세요.
877877

@@ -923,7 +923,6 @@ OpenCode 에서 지원하는 모든 LSP 구성 및 커스텀 설정 (opencode.js
923923
```json
924924
{
925925
"experimental": {
926-
"tool_output_truncator": true,
927926
"preemptive_compaction": true,
928927
"truncate_all_tool_outputs": true,
929928
"aggressive_truncation": true,
@@ -934,10 +933,9 @@ OpenCode 에서 지원하는 모든 LSP 구성 및 커스텀 설정 (opencode.js
934933

935934
| 옵션 | 기본값 | 설명 |
936935
| --------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
937-
| `tool_output_truncator` | `false` | 컨텍스트 윈도우 사용량에 따라 도구 출력(Grep, Glob, LSP, AST-grep 등)을 동적으로 잘라냅니다. 프롬프트가 너무 길어지는 것을 방지합니다. |
938936
| `preemptive_compaction` | `false` | 토큰 제한에 도달하기 전에 세션을 미리 컴팩션합니다. 기본적으로 컨텍스트 윈도우 사용량이 80%일 때 실행됩니다. |
939937
| `preemptive_compaction_threshold` | `0.80` | 선제적 컴팩션을 트리거할 임계값 비율(0.5-0.95). `preemptive_compaction`이 활성화된 경우에만 적용됩니다. |
940-
| `truncate_all_tool_outputs` | `false` | `tool_output_truncator`가 활성화된 경우, 화이트리스트 도구(Grep, Glob, LSP, AST-grep)만이 아닌 모든 도구 출력을 잘라냅니다. |
938+
| `truncate_all_tool_outputs` | `false` | 화이트리스트 도구(Grep, Glob, LSP, AST-grep)만이 아닌 모든 도구 출력을 잘라냅니다. Tool output truncator는 기본적으로 활성화됩니다 - `disabled_hooks`로 비활성화 가능합니다. |
941939
| `aggressive_truncation` | `false` | 토큰 제한을 초과하면 도구 출력을 공격적으로 잘라내어 제한 내에 맞춥니다. 기본 truncation보다 더 공격적입니다. 부족하면 요약/복구로 fallback합니다. |
942940
| `auto_resume` | `false` | thinking block 에러나 thinking disabled violation으로부터 성공적으로 복구한 후 자동으로 세션을 재개합니다. 마지막 사용자 메시지를 추출하여 계속합니다. |
943941
| `dcp_for_compaction` | `false` | 컴팩션용 DCP(동적 컨텍스트 정리) 활성화 - 토큰 제한 초과 시 먼저 실행됩니다. 컴팩션 전에 중복 도구 호출과 오래된 도구 출력을 정리합니다. |

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ Disable specific built-in hooks via `disabled_hooks` in `~/.config/opencode/oh-m
910910
}
911911
```
912912

913-
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`
913+
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`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`, `ralph-loop`
914914

915915
**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`.
916916

@@ -962,7 +962,6 @@ Opt-in experimental features that may change or be removed in future versions. U
962962
```json
963963
{
964964
"experimental": {
965-
"tool_output_truncator": true,
966965
"preemptive_compaction": true,
967966
"truncate_all_tool_outputs": true,
968967
"aggressive_truncation": true,
@@ -973,10 +972,9 @@ Opt-in experimental features that may change or be removed in future versions. U
973972

974973
| Option | Default | Description |
975974
| --------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
976-
| `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. |
977975
| `preemptive_compaction` | `false` | Compacts session proactively before hitting hard token limits. Runs at 80% context window usage by default. |
978976
| `preemptive_compaction_threshold` | `0.80` | Threshold percentage (0.5-0.95) to trigger preemptive compaction. Only applies when `preemptive_compaction` is enabled. |
979-
| `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). |
977+
| `truncate_all_tool_outputs` | `false` | Truncates ALL tool outputs instead of just whitelisted tools (Grep, Glob, LSP, AST-grep). Tool output truncator is enabled by default - disable via `disabled_hooks`. |
980978
| `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. |
981979
| `auto_resume` | `false` | Automatically resumes session after successful recovery from thinking block errors or thinking disabled violations. Extracts the last user message and continues. |
982980
| `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. |

README.zh-cn.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ Sisyphus Agent 也能自定义:
878878
}
879879
```
880880

881-
可关的 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`
881+
可关的 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``compaction-context-injector``thinking-block-validator``claude-code-hooks``ralph-loop`
882882

883883
**关于 `auto-update-checker``startup-toast`**: `startup-toast` hook 是 `auto-update-checker` 的子功能。若想保持更新检查但只禁用启动提示通知,在 `disabled_hooks` 中添加 `"startup-toast"`。若要禁用所有更新检查功能(包括提示),添加 `"auto-update-checker"`
884884

@@ -930,7 +930,6 @@ Oh My OpenCode 送你重构工具(重命名、代码操作)。
930930
```json
931931
{
932932
"experimental": {
933-
"tool_output_truncator": true,
934933
"preemptive_compaction": true,
935934
"truncate_all_tool_outputs": true,
936935
"aggressive_truncation": true,
@@ -941,10 +940,9 @@ Oh My OpenCode 送你重构工具(重命名、代码操作)。
941940

942941
| 选项 | 默认值 | 说明 |
943942
| --------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
944-
| `tool_output_truncator` | `false` | 根据上下文窗口使用情况动态截断工具输出(Grep、Glob、LSP、AST-grep 等)。防止提示过长。 |
945943
| `preemptive_compaction` | `false` | 在达到 token 限制之前主动压缩会话。默认在上下文窗口使用率达到 80% 时运行。 |
946944
| `preemptive_compaction_threshold` | `0.80` | 触发预先压缩的阈值比例(0.5-0.95)。仅在 `preemptive_compaction` 启用时生效。 |
947-
| `truncate_all_tool_outputs` | `false` | `tool_output_truncator` 启用时,截断所有工具输出,而不仅仅是白名单工具(Grep、Glob、LSP、AST-grep)。 |
945+
| `truncate_all_tool_outputs` | `false` | 截断所有工具输出,而不仅仅是白名单工具(Grep、Glob、LSP、AST-grep)。Tool output truncator 默认启用 - 使用 `disabled_hooks` 禁用。 |
948946
| `aggressive_truncation` | `false` | 超出 token 限制时,激进地截断工具输出以适应限制。比默认截断更激进。不够的话会回退到摘要/恢复。 |
949947
| `auto_resume` | `false` | 从 thinking block 错误或 thinking disabled violation 成功恢复后,自动恢复会话。提取最后一条用户消息继续执行。 |
950948
| `dcp_for_compaction` | `false` | 启用压缩用 DCP(动态上下文剪枝)- 在超出 token 限制时首先执行。在压缩前清理重复的工具调用和旧的工具输出。 |

src/config/schema.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const HookNameSchema = z.enum([
4949
"session-notification",
5050
"comment-checker",
5151
"grep-output-truncator",
52+
"tool-output-truncator",
5253
"directory-agents-injector",
5354
"directory-readme-injector",
5455
"empty-task-response-detector",
@@ -163,13 +164,11 @@ export const DynamicContextPruningConfigSchema = z.object({
163164
export const ExperimentalConfigSchema = z.object({
164165
aggressive_truncation: z.boolean().optional(),
165166
auto_resume: z.boolean().optional(),
166-
/** Enable tool output truncator - dynamically truncates tool outputs based on context window (default: false) */
167-
tool_output_truncator: z.boolean().optional(),
168167
/** Enable preemptive compaction at threshold (default: false) */
169168
preemptive_compaction: z.boolean().optional(),
170169
/** Threshold percentage to trigger preemptive compaction (default: 0.80) */
171170
preemptive_compaction_threshold: z.number().min(0.5).max(0.95).optional(),
172-
/** Truncate all tool outputs, not just whitelisted tools (default: false, only applies when tool_output_truncator is enabled) */
171+
/** Truncate all tool outputs, not just whitelisted tools (default: false). Tool output truncator is enabled by default - disable via disabled_hooks. */
173172
truncate_all_tool_outputs: z.boolean().optional(),
174173
/** Dynamic context pruning configuration */
175174
dynamic_context_pruning: DynamicContextPruningConfigSchema.optional(),

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
255255
const commentChecker = isHookEnabled("comment-checker")
256256
? createCommentCheckerHooks(pluginConfig.comment_checker)
257257
: null;
258-
const toolOutputTruncator = pluginConfig.experimental?.tool_output_truncator === true
258+
const toolOutputTruncator = isHookEnabled("tool-output-truncator")
259259
? createToolOutputTruncatorHook(ctx, { experimental: pluginConfig.experimental })
260260
: null;
261261
const directoryAgentsInjector = isHookEnabled("directory-agents-injector")

0 commit comments

Comments
 (0)