Skip to content

AIgency worktree service

The worktree service isolates concurrent writable tasks into real git worktrees and preserves useful prior state across retries when it's safe to.

AgentDock Pro

AIgency is available only in AgentDock Pro.

aigency-worktree-service.ts decides, per task, whether it gets an isolated git worktree or runs directly in the shared workspace — and manages the worktree's lifecycle when it does.

Key operations

  • planTaskWorkspace — decides worktree vs. shared workspace for a task, based on the run's workspace-mode preference and current concurrency.
  • assessPriorWorkspace — checks whether a prior attempt's worktree still exists and whether it has useful edits worth preserving before deciding to reuse or discard it.
  • detectFileScopeOverlap — flags when two tasks that could run concurrently declare overlapping file scope, feeding conflict and integration handling.
  • buildIntegrationBriefing — summarizes what each contributing task changed, for the integration-kind task that reconciles isolated work back together.
  • cleanupRunWorktrees — removes worktrees and branches once a task or run no longer needs them.

Naming

Worktrees are created under <project>/.aigency-worktrees/<runId8>/<taskId> on a branch named aigency/<runId8>/<taskId8>-<slug>, so any worktree or branch left on disk is immediately identifiable as AIgency's.