diff --git a/src/config/schema.ts b/src/config/schema.ts index 9f91bbd..125e88d 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -113,6 +113,8 @@ export const ExperimentalConfigSchema = z.object({ 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: false) */ + truncate_all_tool_outputs: z.boolean().optional(), }) export const OhMyOpenCodeConfigSchema = z.object({ diff --git a/src/hooks/tool-output-truncator.ts b/src/hooks/tool-output-truncator.ts index c3a8f08..7af9df2 100644 --- a/src/hooks/tool-output-truncator.ts +++ b/src/hooks/tool-output-truncator.ts @@ -1,4 +1,5 @@ import type { PluginInput } from "@opencode-ai/plugin" +import type { ExperimentalConfig } from "../config/schema" import { createDynamicTruncator } from "../shared/dynamic-truncator" const TRUNCATABLE_TOOLS = [ @@ -17,14 +18,19 @@ const TRUNCATABLE_TOOLS = [ "Interactive_bash", ] -export function createToolOutputTruncatorHook(ctx: PluginInput) { +interface ToolOutputTruncatorOptions { + experimental?: ExperimentalConfig +} + +export function createToolOutputTruncatorHook(ctx: PluginInput, options?: ToolOutputTruncatorOptions) { const truncator = createDynamicTruncator(ctx) + const truncateAll = options?.experimental?.truncate_all_tool_outputs ?? false const toolExecuteAfter = async ( input: { tool: string; sessionID: string; callID: string }, output: { title: string; output: string; metadata: unknown } ) => { - if (!TRUNCATABLE_TOOLS.includes(input.tool)) return + if (!truncateAll && !TRUNCATABLE_TOOLS.includes(input.tool)) return try { const { result, truncated } = await truncator.truncate(input.sessionID, output.output) diff --git a/src/index.ts b/src/index.ts index a728934..accbe66 100644 --- a/src/index.ts +++ b/src/index.ts @@ -251,7 +251,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { ? createCommentCheckerHooks() : null; const toolOutputTruncator = isHookEnabled("tool-output-truncator") - ? createToolOutputTruncatorHook(ctx) + ? createToolOutputTruncatorHook(ctx, { experimental: pluginConfig.experimental }) : null; const directoryAgentsInjector = isHookEnabled("directory-agents-injector") ? createDirectoryAgentsInjectorHook(ctx)