feat(claudecode): support user-defined hooks from settings.json#14823
Closed
xvweirong wants to merge 3 commits into
Closed
feat(claudecode): support user-defined hooks from settings.json#14823xvweirong wants to merge 3 commits into
xvweirong wants to merge 3 commits into
Conversation
…kill files - Add user-hooks.ts to load and merge user-defined hooks from project-level, user-level, and Cherry Studio-isolated settings.json files. - Convert command-type hooks into SDK HookCallbacks with stdin/stdout protocol, timeout support, and abort signal handling. - Merge system hooks (RTK rewrite, permission gate) with user hooks so both run together — system first, user second. - Auto-allow Read/Write/Edit on planning files (task_plan.md, findings.md, progress.md) to prevent approval fatigue from skills. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Remove planning file auto-allow (task_plan.md, findings.md, progress.md) — this was an inappropriate special-case for a specific skill; users should configure their own permissions. - Remove changeset file (main app changes don't use changesets). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
Contributor
Author
|
Superseded by #14977 — cleaner branch with prompt-based hook support and no merge conflicts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for user-defined hooks in Cherry Studio's Claude Code integration, enabling skills like planning-with-files and other hook-dependent workflows to function correctly.
What changed
New
user-hooks.ts— loads and merges user-defined hooks from threesettings.jsonsources (project-level → user-level → Cherry Studio-isolated). Supports all SDKHookEventtypes (PreToolUse,PostToolUse,Stop,UserPromptSubmit, etc.).Hook merging in
index.ts— replaces the hardcodedhooks: { PreToolUse: [...] }withmergeHooks(systemHooks, userHooks), so Cherry Studio's RTK rewrite and permission gate continue to run alongside user hooks.Why this matters
Many community skills (e.g., planning-with-files) rely on hooks for:
StopUserPromptSubmitfor routingPreviously, Cherry Studio hardcoded
hooksinOptions, which silently overrode any user-defined hooks loaded viasettingSources. This PR makes the two coexist.Test plan
pnpm typecheck:nodepassestransform.test.ts(8 tests) passesRelated
🤖 Generated with Claude Code