fix(hooks): simplify project-scope injection and dispatch config - #272
Merged
Conversation
Two changes: 1. hook-dispatch-cli now prefers detectProjectConfig(stdin.cwd) over the hardcoded loadLocalConfig(), so filterHandlersForConfig honours project-level repo.kind (e.g. suppressing gitOnly handlers for HTTP projects). 2. resolveHookScopeTargets no longer writes a redundant copy of hook entries into <projectRoot>/.claude/settings.json — HOME already covers every cwd. hooksRemove still cleans up legacy projectRoot entries left by older versions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Align the #85 E2E assertions with the new behaviour: project-scope inject now writes only to HOME, and the redundant projectRoot copy is no longer created. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Closes #264.
hook-dispatch-clinow callsdetectProjectConfig(stdin.cwd)before falling back toloadLocalConfig(), sofilterHandlersForConfigcan honour a project-levelrepo.kind(e.g. suppressinggitOnlyhandlers for HTTP-only projects)resolveHookScopeTargetsno longer duplicates hook entries into<projectRoot>/.claude/settings.json— HOME already covers every cwdhooksRemovestill cleans up old projectRoot entries left by previous versionspull.tsis intentionally unchanged — its per-scope reconcile uses separate manifests and baseDirs, which is correct for the different teamDefs each scope may have.Test plan
npx tsc --noEmit— type check passesnpx vitest run src/__tests__/hooks-cmd.test.ts— 11 tests pass (inject/remove/list updated for 简化 hooks 下发:project scope 无需两边写 settings.json,dispatch 应按 cwd 识别项目 #264)npx vitest run src/__tests__/hook-dispatch.test.ts src/__tests__/hook-handlers.test.ts— 38 tests passnpx vitest run— all 1885 tests passnpm run build— builds successfully🤖 Generated with Claude Code