fix: skip claude hook injection for internal prompts

This commit is contained in:
YeonGyu-Kim
2026-05-27 14:17:46 +09:00
parent c0d3044629
commit 77a268f91e
3 changed files with 76 additions and 3 deletions
@@ -4,6 +4,7 @@ import type {
ClaudeHooksConfig,
} from "./types"
import { findMatchingHooks, log } from "../../shared"
import { isRealUserTextPart } from "../../shared/internal-initiator-marker"
import { dispatchHook, getHookIdentifier } from "./dispatch-hook"
import { isHookCommandDisabled, type PluginExtendedConfig } from "./config-loader"
@@ -44,10 +45,14 @@ export async function executeUserPromptSubmitHooks(
return { block: false, modifiedParts, messages }
}
const realUserTextParts = ctx.parts.filter(isRealUserTextPart)
if (realUserTextParts.length === 0) {
return { block: false, modifiedParts, messages }
}
// Check if hook tags are in the current user input only (not in injected context)
// by checking only the text parts that were provided in this message
const userInputText = ctx.parts
.filter((p) => p.type === "text" && p.text)
const userInputText = realUserTextParts
.map((p) => p.text ?? "")
.join("\n")