Skip to content

feat(instances): add multi-repo agent sessions#314

Merged
asheshgoplani merged 4 commits intoasheshgoplani:mainfrom
binikingi:feature/implement-multi-repo-agent
Mar 16, 2026
Merged

feat(instances): add multi-repo agent sessions#314
asheshgoplani merged 4 commits intoasheshgoplani:mainfrom
binikingi:feature/implement-multi-repo-agent

Conversation

@binikingi
Copy link

@binikingi binikingi commented Mar 10, 2026

Summary

  • Multi-repo mode: a single session can now operate across multiple repositories simultaneously, giving the agent access to all repos without context loss
  • UI: "m" hotkey toggles multi-repo mode; stacked path list with inline editing, Tab autocomplete, and parent-dir pre-fill when adding paths
  • Worktree layout: all worktrees are created inside a single persistent parent dir at ~/.agent-deck/multi-repo-worktrees/<branch>-<id>/, named after each repo (e.g., server/, webapp/). This co-locates all repos under the agent's cwd, eliminating cross-repo permission prompts
  • Without worktree: multi-repo sessions use the same parent dir layout with symlinks to the original repos
  • Docker sandbox: mounts each repo under /workspace/<dirname> with automatic name deduplication
  • Persistence: extends existing tool_data JSON blob — no schema migration needed
  • Fork support: multi-repo state (paths, worktrees, parent dir) propagates correctly to forked sessions
  • Cleanup: deleting a session removes git worktrees and the persistent parent dir

Directory layout example

# Multi-repo + worktree (branch: implement-changes)
~/.agent-deck/multi-repo-worktrees/implement-changes-eeea2993/
├── server/      ← git worktree (branch: implement-changes)
└── webapp/      ← git worktree (branch: implement-changes)

# Multi-repo without worktree
~/.agent-deck/multi-repo-worktrees/a1b2c3d4/
├── server/      ← symlink → ~/projects/server
└── webapp/      ← symlink → ~/projects/webapp

Test plan

  • go build ./cmd/... ./internal/ui/... ./internal/session/... ./internal/docker/... ./internal/statedb/... — compiles without errors
  • go test ./internal/ui/... — all tests pass
  • go test ./internal/docker/... — all tests pass (including new WithMultiRepoPaths tests)
  • go test ./internal/statedb/... — all tests pass (including new marshal/unmarshal round-trip tests)
  • go test ./internal/session/... -run "MultiRepo|Deduplicate" — all new unit tests pass
  • go fmt — no formatting issues
  • Manual: toggle multi-repo in new dialog, add 2+ paths with Tab autocomplete, submit session
  • Manual: verify worktrees created under ~/.agent-deck/multi-repo-worktrees/
  • Manual: verify agent cwd is the parent dir with repo subdirs
  • Manual: delete multi-repo session, verify parent dir and worktrees cleaned up
  • Manual: fork a multi-repo session, verify state propagated

🤖 Generated with Claude Code

binikingi and others added 4 commits March 10, 2026 12:25
Allow a single session to operate across multiple repositories simultaneously.
Users can toggle multi-repo mode via "m" hotkey, add/remove paths with
autocomplete, and the agent receives all paths via --add-dir flags.

Key changes:
- Data model: MultiRepoEnabled, AdditionalPaths, MultiRepoTempDir,
  MultiRepoWorktrees fields on Instance
- UI: Multi-repo checkbox, stacked path list with inline editing,
  Tab autocomplete, parent-dir pre-fill on add
- Session lifecycle: temp working dir, per-repo worktrees, cleanup on delete
- Docker sandbox: WithMultiRepoPaths mounts each repo under /workspace/<name>
- Persistence: extended tool_data JSON blob (no schema migration needed)
- Fork support: propagates multi-repo state to forked sessions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of creating worktrees inside each original repo's .worktrees/
directory, create them all inside a single persistent parent dir at
~/.agent-deck/multi-repo-worktrees/<branch>-<id>/. Each worktree is
named after its repo (e.g., server/, webapp/), making them co-located
and avoiding permission prompts from the agent trying to access files
across separate repo directories.

For multi-repo without worktree, the same parent dir layout is used
with symlinks instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Integrate upstream sandbox persistence changes (sandboxJSON,
sandboxContainer fields in UnmarshalToolData/MarshalToolData)
alongside multi-repo fields. Updated statedb test to match
the new 22-value return signature.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflict in single-repo worktree creation: combine upstream's
worktree reuse detection (GetWorktreeForBranch) with our multiRepoEnabled
guard that skips single-repo creation when multi-repo handles it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@binikingi binikingi changed the title feat: add multi-repo agent sessions feat(instances): add multi-repo agent sessions Mar 16, 2026
@asheshgoplani asheshgoplani merged commit 3f18a75 into asheshgoplani:main Mar 16, 2026
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.

2 participants