feat(hooks): add grep-output-truncator for context-aware output limiting

This commit is contained in:
YeonGyu-Kim
2025-12-06 10:54:22 +09:00
parent bac304c035
commit 341e5a959d
3 changed files with 135 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
import type { Plugin } from "@opencode-ai/plugin"
import { createBuiltinAgents } from "./agents"
import { createTodoContinuationEnforcer, createContextWindowMonitorHook, createSessionRecoveryHook, createCommentCheckerHooks } from "./hooks"
import { createTodoContinuationEnforcer, createContextWindowMonitorHook, createSessionRecoveryHook, createCommentCheckerHooks, createGrepOutputTruncatorHook } from "./hooks"
import { updateTerminalTitle } from "./features/terminal"
import { builtinTools } from "./tools"
import { createBuiltinMcps } from "./mcp"
@@ -44,6 +44,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const contextWindowMonitor = createContextWindowMonitorHook(ctx)
const sessionRecovery = createSessionRecoveryHook(ctx)
const commentChecker = createCommentCheckerHooks()
const grepOutputTruncator = createGrepOutputTruncatorHook(ctx)
updateTerminalTitle({ sessionId: "main" })
@@ -185,6 +186,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
},
"tool.execute.after": async (input, output) => {
await grepOutputTruncator["tool.execute.after"](input, output)
await contextWindowMonitor["tool.execute.after"](input, output)
await commentChecker["tool.execute.after"](input, output)