Skip to content

fix: smart legacy ~/GitHub detection based on worktree layout#986

Merged
web3dev1337 merged 1 commit intomainfrom
fix/smart-projects-root-detection
Mar 21, 2026
Merged

fix: smart legacy ~/GitHub detection based on worktree layout#986
web3dev1337 merged 1 commit intomainfrom
fix/smart-projects-root-detection

Conversation

@web3dev1337
Copy link
Copy Markdown
Owner

Summary

  • bootstrapProjectsRoot() previously grandfathered ~/GitHub as the projects root whenever it had ANY visible entries, even flat clones
  • On machines with ~/GitHub full of flat clones (no master/ subdirectory), this caused worktree creation to fail with "missing master/main directory"
  • Now recursively scans ~/GitHub (up to 6 levels deep, max 200 dirs) to detect repos and count how many use worktree layout
  • Skips grandfathering when:
    • Zero repos have worktree layout (all flat clones)
    • Less than 25% of repos use worktree layout (when 4+ repos exist)
  • Supports deep nesting like ~/GitHub/games/hytopia/games/PROJECT/master/.git
  • Scan is efficient: stops recursing into repo directories, runs once at startup

Test plan

  • Machine with ~/GitHub full of flat clones → should use ~/.agent-workspace/projects/ instead
  • Machine with ~/GitHub using worktree layout (like your Linux) → should keep using ~/GitHub
  • Machine with no ~/GitHub → should use ~/.agent-workspace/projects/
  • 14 unit tests pass including deep nesting scenarios

🤖 Generated with Claude Code

bootstrapProjectsRoot() previously fell back to ~/GitHub any time it had
visible entries, even if every repo was a flat clone with no master/
subdirectory. This caused worktree creation to fail on machines where
~/GitHub existed but repos weren't in the worktree layout.

Now recursively scans (depth-limited to 8, stops at repo boundaries) to
find repos and count how many use worktree layout (master/.git or main/.git)
vs flat clones (.git at root). Skips grandfathering when zero repos use
worktree layout or when less than 25% of 4+ repos do. New repos get created
under ~/.agent-workspace/projects/ with proper layout instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@web3dev1337 web3dev1337 force-pushed the fix/smart-projects-root-detection branch from 54751e0 to fc83923 Compare March 21, 2026 04:03
@web3dev1337 web3dev1337 merged commit 8c514b6 into main Mar 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant