From 3b5745a6e83f2cfab3b3c14ae0ccf7f3c6274680 Mon Sep 17 00:00:00 2001 From: kilhyeonjun Date: Fri, 10 Apr 2026 09:59:59 +0900 Subject: [PATCH] fix: wire claudeCodeHooks into createHooks() to enable .claude/settings.json hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit createClaudeCodeHooksHook() was fully implemented but never instantiated in createHooks(). All .claude/settings.json hooks (PreToolUse, PostToolUse, Stop, UserPromptSubmit) were silently skipped because hooks.claudeCodeHooks was always undefined (optional chaining masked the issue). Add claudeCodeHooks creation to createHooks() using the existing isHookEnabled('claude-code-hooks') gate and safeCreateHook wrapper. Note: This is a necessary fix but may require additional debugging for full hook execution — the dispatch/stdin format compatibility between OpenCode and Claude Code hook scripts needs runtime verification. Fixes #3297 --- src/create-hooks.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/create-hooks.ts b/src/create-hooks.ts index 0e40ad480..827913754 100644 --- a/src/create-hooks.ts +++ b/src/create-hooks.ts @@ -8,6 +8,8 @@ import type { ModelCacheState } from "./plugin-state" import { createCoreHooks } from "./plugin/hooks/create-core-hooks" import { createContinuationHooks } from "./plugin/hooks/create-continuation-hooks" import { createSkillHooks } from "./plugin/hooks/create-skill-hooks" +import { createClaudeCodeHooksHook } from "./hooks/claude-code-hooks" +import { safeCreateHook } from "./shared/safe-create-hook" export type CreatedHooks = ReturnType @@ -78,10 +80,17 @@ export function createHooks(args: { availableSkills, }) + const claudeCodeHooks = isHookEnabled("claude-code-hooks") + ? safeHookEnabled + ? safeCreateHook("claude-code-hooks", () => createClaudeCodeHooksHook(ctx, {}), { enabled: true }) + : createClaudeCodeHooksHook(ctx, {}) + : null + const hooks = { ...core, ...continuation, ...skill, + claudeCodeHooks, } return {