Add multi-repository context support#6
Conversation
4b865f5 to
5d2c6ca
Compare
|
Have you considered using |
Replace hardcoded java-monorepo defaults with a user-centric flow that: - Asks which repository to manage first - Auto-detects default branch from origin/HEAD or main/master - Derives all paths from repo location (e.g., myrepo -> myrepo-master, myrepo-worktrees) - Shows derived config and allows customization
Expand beyond .ijwb to support multiple IDE/editor metadata patterns: - Add WT_METADATA_PATTERNS config variable (space-separated list) - Add WT_KNOWN_METADATA array with 16 known patterns: - JetBrains: .idea, .run, .fleet - Bazel: .ijwb, .aswb, .clwb, .bazelbsp, .bsp - Xcode/iOS: .swiftpm, xcuserdata - VS Code: .vscode - Scala: .metals, .bloop - Eclipse: .settings, .project, .classpath New scripts: - bin/wt-metadata-export: Export all configured patterns to vault - bin/wt-metadata-import: Import all configured patterns to worktree Install flow changes: - Scan repo for existing metadata directories - Interactive checkbox selection (all detected selected by default) - Save selection to WT_METADATA_PATTERNS Updated: - wt-add uses wt-metadata-import - wt.sh adds metadata-export/import commands (keeps ijwb-* as aliases) - All find commands use -L to follow symlinks Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Detection now finds top-level metadata dirs only (e.g., .idea inside .ijwb is not listed separately) - Export deduplicates by sorting paths and skipping nested ones - Add tilde expansion for paths containing ~/ Algorithm: sort all found paths, keep only those not inside another kept path Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement context-based switching to manage multiple git repositories with separate configurations. Each context stores its own worktree paths, metadata vault location, and default branch. New commands: - `wt context` - Interactive context selection - `wt context <name>` - Switch to named context - `wt context --list` - List all contexts - `wt context add` - Full setup flow for new repository Key changes: - Add lib/wt-context for context management functions - Add lib/wt-context-setup for shared setup flow - Add bin/wt-context command - Update all commands to show context banner when contexts are configured - Simplify install.sh to use shared setup library - Add shell completions for context command Storage structure: ~/.config/wt/repos/<name>.conf - Per-context configuration ~/.config/wt/current - Current active context name ~/.config/wt/idea-files/<name>/ - Per-context metadata vault Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use ${arr[@]+"${arr[@]}"} idiom to safely expand potentially empty
arrays when running with set -u (nounset). This prevents "unbound
variable" errors in _wt_detect_metadata_patterns and
_wt_select_metadata_patterns functions.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5d2c6ca to
4ca6b99
Compare
Thanks for the suggestion! I think with git config alone there's a challenge with the "run Options would be:
they are all valid options, and UX preferences, I went with "run from anywhere" since I often run I can see a place where we use a hybrid approach, where the current context is stored globally (e.g., in |
This reverts commit 24c24a1.
IMO to support multi-repo, Somewhat tangential, but making "local context" primary and "global context" secondary can even simplify other things e.g. less reliance on sessions/login-shell/interactivity (e.g. no need for IMO having the core of |
Thought about this a little bit more, here are my thoughts local vs global context priorityI think the real tension is that the layering / POSIX pointI want to understand this better, were you referring to literally targeting POSIX sh, or more about the principle of keeping shell-specific concerns out of the core? Currently the architecture is:
The only reason sourcing is required today is the changes required to make local context take precedenceIf I understand the suggestion correctly, the split would be:
@bezhermoso Does the above resonate with you? |
@guodong-sq Ahh yes, I admit I did not dig into the true state of POSIX-compatibility, but simply assumed it was partly the goal given the use of That resonates. I agree with your analysis of the tension here. Your analysis on what the required changes are for separating core functionality from shell integration is spot-on, and IMO would lead to more correct (or at least least-suprising) behavior, predictability & composability that makes it more attractive to adopt & slot into people's varying workflows. |
Summary
wt contextcommand for managing multiple repository configurationswt context addsubcommand that runs full setup flow (same as install.sh)lib/wt-context-setupfor reuseChanges
New files:
lib/wt-context- Core context management librarylib/wt-context-setup- Shared setup flow for install.sh andwt context addbin/wt-context- Context list/switch/add commandModified files:
lib/wt-common- Loads context config on initinstall.sh- Simplified to use shared setup librarywt.sh- Added context commandbin/wt-*scripts - Added context bannerlib/wt-help- Updated help textUser Experience
Test plan
install.shwt context addwt context🤖 Generated with Claude Code