Repository navigation
feat: let agent sessions work across all worktrees of a repo - #36
Merged
Merged
Conversation
Sandboxed agents could only reach the directory they started in, so worktrees created by wt next to the repository were out of reach for the running session. Keeping each repository as a container that holds a bare .git and one folder per worktree lets the launcher grant the whole container up front. Add git wtclone to clone straight into that layout and git wtmigrate to convert existing clones, both with man pages. The nono launcher now grants the folder holding .git, and the worktrunk template places new worktrees inside the container.
Some repositories live where another tool puts them, such as the chezmoi source directory, so they cannot become a bare container. With the container-only template, wt would place their worktrees in the parent folder, outside what the agent sandbox grants. The worktrunk template now sends worktrees of classic clones to a central folder under ~/.local/share/worktrees, keyed by the checkout path. The nono launcher derives the same key and grants that folder alongside the checkout, so a session can work across those worktrees too. The git wtclone and git wtmigrate man pages describe this case.
chezmoi source-path only knows targets backed by a source file, so a config file that a run_* script edits, such as the worktrunk config, reports "not managed". Agents following the skill then edited the target directly, and the next apply would have reverted the change. Tell the skill to search the run_* scripts for the target path first and to change values in the owning script.
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
Sandboxed agents could only reach the folder they started in, so worktrees that
wtcreated next to a repository were out of reach for a running session. This branch gives every repository a predictable place for its worktrees and has the nono launcher grant that place at launch. Repositories we control use a bare layout (<repo>/.gitplus one folder per worktree); classic clones whose location another tool decides keep working, with their worktrees in a central folder.Key Decisions
🌳 Bare worktree layout
New
git wtcloneclones into<repo>/.git(bare) plus<repo>/<default-branch>, behaving like a normal clone otherwise: remote-tracking branches,origin/HEAD, one local branch with upstream, submodules initialized.git wtmigrateconverts an existing clone in place, keeping uncommitted, staged, untracked, and ignored files, and moves linked worktrees into the container. It refuses cases it cannot convert safely, such as initialized submodules or an operation in progress. Both ship man pages, sogit wtclone --helpworks.The commands are git subcommands rather than shell aliases so the vendored oh-my-zsh git plugin, which refreshes weekly, cannot collide with them.
🗂️ Classic clones
Some repositories cannot become a container, such as the chezmoi source directory. For these, the worktrunk template sends worktrees to
~/.local/share/worktrees/<key>/<branch>, where the key is the checkout path with/,\, and.replaced by-. The template tells the two layouts apart by whetherrepo_pathends in/.git.🔐 Launcher grants
_nono_agent_runnow grants the folder holding.git(the container for bare repos, the checkout for classic ones), never widening to$HOMEor/. For classic clones it also creates and grants the central worktree folder, derived with the same key rule as the worktrunk template. A tampered.gitpointer can only redirect that extra grant within the central root.🧭 Script-owned config in the chezmoi skill
chezmoi source-pathreports files edited byrun_*scripts as "not managed", which led to editing the worktrunk config directly instead of its owning script. Themanaging-chezmoiskill now says to search therun_*scripts first and change values there.🔄 Before & After
../<repo>-<branch>, outside the sandbox grant<repo>/<branch>(bare) or~/.local/share/worktrees/<key>/<branch>(classic).gitgit clonegit wtclonefor the bare layoutgit wtmigrateconverts in placerun_*scripts first