Support global `.worktreeinclude` (e.g. `~/.config/worktrunk/worktreeinclude`)
Problem
Currently .worktreeinclude is per-repo only — checked at worktree_path.join(".worktreeinclude") in step_commands.rs:568. Users who use worktrunk across many repos want to globally exclude large directories like .conductor/, .entire/, etc. from copy-ignored.
Without a global option, users must add .worktreeinclude to every repo, which isn't feasible at scale.
Proposed behavior
- Check
~/.config/worktrunk/worktreeinclude(or XDG equivalent) and merge patterns with per-repo.worktreeinclude - If global file exists but no per-repo file, use global patterns as the allowlist
- If both exist, use union of patterns
Use case
I use worktrunk across dozens of repos. Without .worktreeinclude, copy-ignored copies everything gitignored — including .conductor/, .entire/, .jj/, .worktrees/ — which is slow and unnecessary. VCS metadata dirs (.jj, .hg, etc.) are already excluded in code via VCS_METADATA_DIRS, but other tool-specific dirs aren't.
I want to globally say "only copy .env* and node_modules/" without maintaining .worktreeinclude in every repo.
Thanks for the suggestion! I searched the codebase and confirmed that .worktreeinclude is currently only read from the worktree root (worktree_path.join(".worktreeinclude") in src/commands/step_commands.rs:568) — there's no global equivalent.
The closest related infrastructure is the user config system (src/config/user/path.rs), which already uses etcetera for XDG-aware paths (~/.config/worktrunk/ on Linux, ~/Library/Application Support/worktrunk/ on macOS). A global worktreeinclude file could follow the same pattern.
I'll leave it for a maintainer to evaluate and prioritize.
the goal is very reasonable!
but would the global config go the wrong way; would we instead need a global .worktreeexclude?
possibly we could use the configs for this.
another alternative, which would be much simpler if we could find the paths, is just to add more things onto our exclusions, like .conductor. is there some principle like "if it's related to VCS then we we exclude it", and we can build that finite list?
Good point about the direction — .worktreeinclude is an allowlist ("only copy these"), so a global allowlist would mean maintaining a list of everything you want across all repos. A global .worktreeexclude ("copy everything except these") would be more natural for the "I want to exclude .conductor/ everywhere" use case.
On expanding the built-in exclusions: the current VCS_METADATA_DIRS list follows a clear principle — "directories that contain VCS internal state tied to a specific working directory." .conductor/ and .entire/ don't fit that principle (they're tool-specific caches/state, not VCS metadata), so we'd need a broader category or a separate list.
Some options in order of simplicity:
-
Expand built-in exclusions with a second list like
TOOL_STATE_DIRSfor well-known tool directories that shouldn't be copied between worktrees. The principle could be "directories containing machine-local or worktree-specific state." Easy to maintain but requires code changes for each new tool. -
Add
copy_ignored.excludetowt.tomlconfig (per-repo or user config). Fits the existing config system, no new file format. Something like:[step.copy-ignored] exclude = [".conductor/", ".entire/"] -
Global
.worktreeexcludefile in~/.config/worktrunk/— a new file but a familiar pattern.
Option 2 seems like the sweet spot — it reuses existing config infrastructure, works at both user and project level, and is more discoverable than a standalone file.