Repository navigation
devcontainer: add agent variant with host-mirrored worktree paths - #2365
Merged
Merged
Conversation
Curtis Man (curtisman)
had a problem deploying
to
development-fork
May 19, 2026 15:43 — with
GitHub Actions
Error
Curtis Man (curtisman)
had a problem deploying
to
development-fork
May 19, 2026 15:43 — with
GitHub Actions
Error
Adds .devcontainer/agent/ - a local-only variant designed for VS Code agent windows that auto-create git worktrees. VS Code's Copilot CLI agent writes worktrees to a hardcoded <dirname(repo)>/<basename(repo)>.worktrees and that path is not configurable, so a host VS Code window cannot otherwise open a worktree the in-container agent created. The agent variant mirrors the host path inside the container so both sides see identical paths: - bind-mounts the repo at its host absolute path (instead of /workspaces/<repo>) - bind-mounts <repo>.worktrees at the matching host path - initializeCommand pre-creates the worktrees dir on the host - updateRemoteUserUID: true so codespace can write through the bind - keeps ts/node_modules on a named volume (native modules stay container-local) Hardening on the agent variant: userEnvProbe none, cap-drop ALL with a minimal allowlist for the post-create chown/sudo path, and pids-limit. Other devcontainer changes: - start-devcontainer.sh --config accepts short names (vnc, agent) that resolve to .devcontainer/<name>/devcontainer.json. - Remove the unused typeagent-agent-worktrees-* named volume from standard and vnc. The volume only existed to give agent worktrees a writable spot inside the container, but the worktrees weren't visible from the host so the agent flow didn't actually work end-to-end. Codespaces handles agent worktrees natively (single VM, shared paths); local Docker uses the agent variant. - Drop the matching worktree-prep step from post-create.sh, and the matching prefix from start-devcontainer.sh --clean. - Make post-create.sh discover ts/node_modules via git rev-parse rather than scanning /workspaces, so it works for variants that bind-mount outside /workspaces. README: reorganized by reader intent (TL;DR -> variant selection -> quick start -> variants in detail -> working inside -> SSH -> AI agents + hardening -> reference -> troubleshooting). Clarified that VS Code 'Reopen in Container' projects host ~/.gitconfig automatically via dev.containers.copyGitConfig, distinguishing the three startup paths (VS Code, CLI wrapper, Codespaces). De-duplicated EACCES recipes and removed a stale chown -R workspace footgun.
Curtis Man (curtisman)
force-pushed
the
agentcontainer
branch
from
May 19, 2026 16:13
f39c6dc to
4753384
Compare
Curtis Man (curtisman)
had a problem deploying
to
development-fork
May 19, 2026 16:13 — with
GitHub Actions
Error
Curtis Man (curtisman)
had a problem deploying
to
development-fork
May 19, 2026 16:13 — with
GitHub Actions
Error
Curtis Man (curtisman)
had a problem deploying
to
development-fork
May 19, 2026 16:27 — with
GitHub Actions
Error
Curtis Man (curtisman)
had a problem deploying
to
development-fork
May 19, 2026 16:27 — with
GitHub Actions
Error
Curtis Man (curtisman)
had a problem deploying
to
development-fork
May 19, 2026 16:33 — with
GitHub Actions
Failure
Curtis Man (curtisman)
had a problem deploying
to
development-fork
May 19, 2026 16:33 — with
GitHub Actions
Failure
Curtis Man (curtisman)
enabled auto-merge
May 19, 2026 16:33
This branch had an error being deployed
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
Adds a new
.devcontainer/agent/variant designed for VS Code agent windows that auto-create git worktrees, and cleans up some related dead code in the existing variants.Why
VS Code's Copilot agent window creates worktrees at
<dirname(repo)>/<basename(repo)>.worktrees/<branch>. That base path is computed as a pure function of the repository root, with no setting to override it. In the existing devcontainer setup the worktree therefore lives at/workspaces/<repo>.worktrees/<branch>inside the container, which a separate host VS Code window cannot open. Theagentvariant mirrors the host path inside the container so both sides see identical paths.(Note: this only applies to the agent-host code path. The Git extension's manual
Create Worktreecommand is a separate code path that does honor a stored root and prompts for a destination; it is unaffected by this change.)Tracked upstream as microsoft/vscode#293884.
What changed
New
agentvariant (.devcontainer/agent/devcontainer.json, local-only):/workspaces/<repo>)<repo>.worktreesat the matching host pathinitializeCommandpre-creates the worktrees dir on the hostupdateRemoteUserUID: truesocodespacecan write through the bind mountts/node_moduleson a named volume (native modules stay container-local)userEnvProbe: none,--cap-drop=ALLwith a minimal allowlist for the post-create chown/sudo path and sshd, and--pids-limitCleanup in standard / vnc:
typeagent-agent-worktrees-*named volume. The volume only existed to give agent worktrees a writable spot inside the container, but the worktrees were not visible from the host so the agent flow did not actually work end-to-end. Codespaces handles agent worktrees natively (single VM, shared paths); local Docker uses the agent variant.post-create.shand the matching prefix fromstart-devcontainer.sh --clean.post-create.shnow discoversts/node_modulesviagit rev-parserather than scanning/workspaces, so it works for variants that bind-mount outside/workspaces.start-devcontainer.sh:--configaccepts short names (vnc,agent) that resolve to.devcontainer/<name>/devcontainer.json. Full paths still work.README: reorganized by reader intent (TL;DR -> variant selection -> quick start -> variants in detail -> working inside -> SSH -> AI agents + hardening -> reference -> troubleshooting). Clarified the three startup paths (VS Code "Reopen in Container", CLI wrapper, Codespaces) and how each handles
~/.gitconfig. De-duplicated EACCES recipes and removed a stalechown -Rworkspace footgun.Validation
.devcontainer/scripts/start-devcontainer.sh --config agent --recreatebuilds and runs post-create cleanly.