fix: respect disabled_hooks for keyword-detector in claude-code-hooks (#562)
* fix: respect disabled_hooks for keyword-detector in claude-code-hooks The keyword detection in claude-code-hooks was running regardless of whether keyword-detector was in disabled_hooks. This caused analyze and search modes to trigger even when explicitly disabled. Pass keywordDetectorDisabled flag to createClaudeCodeHooksHook and skip keyword detection when the hook is disabled. Fixes #530 * refactor: restore keyword types in log output Add types array back to keyword detection log for better observability
This commit is contained in:
@@ -138,15 +138,19 @@ export function createClaudeCodeHooksHook(ctx: PluginInput, config: PluginConfig
|
||||
return
|
||||
}
|
||||
|
||||
const keywordMessages: string[] = []
|
||||
if (!config.keywordDetectorDisabled) {
|
||||
const detectedKeywords = detectKeywordsWithType(removeCodeBlocks(prompt), input.agent)
|
||||
const keywordMessages = detectedKeywords.map((k) => k.message)
|
||||
keywordMessages.push(...detectedKeywords.map((k) => k.message))
|
||||
|
||||
if (keywordMessages.length > 0) {
|
||||
log("[claude-code-hooks] Detected keywords", {
|
||||
sessionID: input.sessionID,
|
||||
keywordCount: keywordMessages.length,
|
||||
types: detectedKeywords.map((k) => k.type),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const allMessages = [...keywordMessages, ...result.messages]
|
||||
|
||||
|
||||
@@ -200,4 +200,5 @@ export interface ClaudeCodeMessage {
|
||||
|
||||
export interface PluginConfig {
|
||||
disabledHooks?: boolean | ClaudeHookEvent[]
|
||||
keywordDetectorDisabled?: boolean
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
||||
const thinkMode = isHookEnabled("think-mode") ? createThinkModeHook() : null;
|
||||
const claudeCodeHooks = createClaudeCodeHooksHook(ctx, {
|
||||
disabledHooks: (pluginConfig.claude_code?.hooks ?? true) ? undefined : true,
|
||||
keywordDetectorDisabled: !isHookEnabled("keyword-detector"),
|
||||
});
|
||||
const anthropicContextWindowLimitRecovery = isHookEnabled(
|
||||
"anthropic-context-window-limit-recovery"
|
||||
|
||||
Reference in New Issue
Block a user