Do not scan ~/.claude as project scope when launched from the home directory - #2
Open
sukidev07 wants to merge 1 commit into
Open
Do not scan ~/.claude as project scope when launched from the home directory#2sukidev07 wants to merge 1 commit into
sukidev07 wants to merge 1 commit into
Conversation
…rectory Launched with cwd = ~, the project-scope walk-up finds ~/.claude and labels it project scope while the same physical directory is also added as the user root - so every artifact in it is captured twice (observed live: a 6-artifact user inventory listed as 12, each once per scope). The user root is the true owner of ~/.claude; discover() now drops the project-scope alias, and an --add-dir resolving to ~/.claude is skipped by the same guard, mirroring the existing add-dir dedupe. Regression test: discover(start=home, home_dir=home) yields exactly one root for ~/.claude, labelled user, and the inventory captures each artifact once. 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
When capdisc runs with the working directory set to the home directory itself (a real case: running it right after install, before
cd-ing anywhere),ScopeRoots.discoverwalks up fromstart = ~, finds~/.claude, and labels it project scope — while the same physical directory is also added as the user root. Every artifact in~/.claudeis then captured twice, once per scope label. Observed live: a 6-artifact user inventory (5 commands + hooks) reported as 12 entries.This is the same double-capture class the existing add-dir dedupe comment in
discoveralready guards against, just via the home-launch path.Fix:
~/.claudeis owned by user scope.discover()now drops a project-scope base that resolves tohome_dir/.claude, and the same resolved path is added toseen_project_basesso an--add-dirpointing at home is skipped by the existing guard. Behavior withhome_dir=Noneis unchanged.Testing
test_home_launch_does_not_double_scan_user_claude:discover(start=home, home_dir=home)yields exactly one root for~/.claude, labelled user, and the scanned inventory captures each artifact once.Generated with Claude Code