Files
oh-my-openagent/src/plugin/tool-execute-after.test.ts
2026-03-09 11:27:58 +09:00

36 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "bun:test"
import { createToolExecuteAfterHandler } from "./tool-execute-after"
describe("createToolExecuteAfterHandler", () => {
it("#given truncator changes output #when tool.execute.after runs #then claudeCodeHooks receives truncated output", async () => {
const callOrder: string[] = []
let claudeSawOutput = ""
const handler = createToolExecuteAfterHandler({
ctx: { directory: "/repo" } as never,
hooks: {
toolOutputTruncator: {
"tool.execute.after": async (_input, output) => {
callOrder.push("truncator")
output.output = "truncated output"
},
},
claudeCodeHooks: {
"tool.execute.after": async (_input, output) => {
callOrder.push("claude")
claudeSawOutput = output.output
},
},
} as never,
})
await handler(
{ tool: "hashline_edit", sessionID: "ses_test", callID: "call_test" },
{ title: "result", output: "original output", metadata: {} }
)
expect(callOrder).toEqual(["truncator", "claude"])
expect(claudeSawOutput).toBe("truncated output")
})
})