-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: respect disabled_hooks for keyword-detector in claude-code-hooks #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: respect disabled_hooks for keyword-detector in claude-code-hooks #562
Conversation
|
All contributors have signed the CLA. Thank you! ✅ |
Greptile SummaryThis PR fixes a bug where the keyword-detector hook was being invoked within Key changes:
Architecture insight:
This fix ensures both respect the same Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Plugin as Plugin (src/index.ts)
participant ClaudeCodeHooks as ClaudeCodeHooks Hook
participant KeywordDetector as Keyword Detector
User->>Plugin: Load plugin with disabled_hooks config
Plugin->>Plugin: isHookEnabled("keyword-detector") = false
Plugin->>ClaudeCodeHooks: createClaudeCodeHooksHook(ctx, {<br/>keywordDetectorDisabled: true})
User->>Plugin: Submit message with keywords
Plugin->>ClaudeCodeHooks: chat.message hook
alt keywordDetectorDisabled = true
ClaudeCodeHooks->>ClaudeCodeHooks: Skip keyword detection
Note over ClaudeCodeHooks: keywordMessages = []
else keywordDetectorDisabled = false
ClaudeCodeHooks->>KeywordDetector: detectKeywordsWithType()
KeywordDetector-->>ClaudeCodeHooks: detected keywords
ClaudeCodeHooks->>ClaudeCodeHooks: Add keyword messages
end
ClaudeCodeHooks->>ClaudeCodeHooks: Combine keyword + hook messages
ClaudeCodeHooks-->>Plugin: Inject messages to prompt
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
|
I have read the CLA Document and I hereby sign the CLA |
|
@sisyphus-dev-ai review |
Code Review: PR #562SummaryThis PR successfully fixes the bug where keyword-detector was being invoked within claude-code-hooks even when disabled via ✅ What's Good1. Correct Logic Implementation
2. Consistent Patterns
3. Edge Case Handling
💡 Suggestions for Improvement1. Test Coverage (Recommended) // src/hooks/claude-code-hooks/index.test.ts (new file)
describe('claude-code-hooks keyword detection', () => {
test('should respect keywordDetectorDisabled config', async () => {
// Test that keyword detection is skipped when keywordDetectorDisabled=true
})
test('should run keyword detection when keywordDetectorDisabled=false', async () => {
// Test that keyword detection runs when enabled
})
})2. Minor Log Information Loss (Optional)
This reduces observability slightly. Consider keeping both: if (keywordMessages.length > 0) {
log("[claude-code-hooks] Detected keywords", {
sessionID: input.sessionID,
keywordCount: keywordMessages.length,
types: detectedKeywords.map((k) => k.type),
})
}However, the current implementation is also fine since you can't access 3. Documentation (Nice-to-have) 🎯 VerdictAPPROVED ✅ This PR is ready to merge. The fix is correct, type-safe, and solves the reported issue. The suggestions above are optional improvements, not blockers. Confidence Score: 5/5
Great work @popododo0720! 🎉 |
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 code-yeongyu#530
51d7695 to
fdac353
Compare
|
recheck |
Add types array back to keyword detection log for better observability
|
Applied the review suggestion: restored log("[claude-code-hooks] Detected keywords", {
sessionID: input.sessionID,
keywordCount: keywordMessages.length,
types: detectedKeywords.map((k) => k.type), // restored
}) |
…#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
Summary
disabled_hooksconfigurationclaude-code-hooksnow checks if the hook is disabled before runningChanges
keywordDetectorDisabledoption toPluginConfigtype insrc/hooks/claude-code-hooks/types.tscreateClaudeCodeHooksHookinsrc/hooks/claude-code-hooks/index.tsto skip keyword detection when disabledkeywordDetectorDisabled: !isHookEnabled("keyword-detector")fromsrc/index.tsTesting
Both pass successfully.
To verify the fix:
"keyword-detector"todisabled_hooksinoh-my-opencode.jsonRelated Issues
Closes #530
Summary by cubic
Keyword detector in claude-code-hooks now respects disabled_hooks and won't run when "keyword-detector" is disabled. This prevents analyze/search modes from triggering when users opt out.
Written for commit 2e5319b. Summary will update on new commits.