feat(hooks): integrate Claude Code hooks with plugin system

- Create factory function createClaudeCodeHooksHook()
- Wire tool.execute.before → executePreToolUseHooks
- Wire tool.execute.after → executePostToolUseHooks
- Wire event (session.idle) → executeStopHooks
- Register hooks in src/index.ts
- Claude hooks execute first in handler chain

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-09 18:10:30 +09:00
parent bd67419d1d
commit 441fc1a219
4 changed files with 207 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import {
createDirectoryAgentsInjectorHook,
createEmptyTaskResponseDetectorHook,
createThinkModeHook,
createClaudeCodeHooksHook,
} from "./hooks";
import {
loadUserCommands,
@@ -76,6 +77,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const directoryAgentsInjector = createDirectoryAgentsInjectorHook(ctx);
const emptyTaskResponseDetector = createEmptyTaskResponseDetectorHook(ctx);
const thinkMode = createThinkModeHook();
const claudeCodeHooks = createClaudeCodeHooksHook(ctx);
updateTerminalTitle({ sessionId: "main" });
@@ -129,6 +131,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
},
event: async (input) => {
await claudeCodeHooks.event(input);
await todoContinuationEnforcer(input);
await contextWindowMonitor.event(input);
await directoryAgentsInjector.event(input);
@@ -229,6 +232,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
},
"tool.execute.before": async (input, output) => {
await claudeCodeHooks["tool.execute.before"](input, output);
await commentChecker["tool.execute.before"](input, output);
if (input.sessionID === getMainSessionID()) {
@@ -243,6 +247,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
},
"tool.execute.after": async (input, output) => {
await claudeCodeHooks["tool.execute.after"](input, output);
await grepOutputTruncator["tool.execute.after"](input, output);
await contextWindowMonitor["tool.execute.after"](input, output);
await commentChecker["tool.execute.after"](input, output);