feat(worktree): include parent repo observations in worktree read scope

Worktrees are branches off main; the parent holds the architecture,
decisions, and long-tail history the worktree inherits. Scoping reads
to the worktree alone meant every new worktree started cold on any
question that required prior context.

Expand `allProjects` in a worktree to `[parent, composite]` so reads
pull both. Writes still go through `.primary` (the composite), so
sibling worktrees don't leak into each other.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-04-16 17:55:17 -07:00
parent 193e7e0719
commit dc198d5677
3 changed files with 8 additions and 6 deletions
+4 -2
View File
@@ -64,7 +64,9 @@ export interface ProjectContext {
parent: string | null;
/** True if currently in a worktree */
isWorktree: boolean;
/** Projects to query — always `[primary]` so observations don't cross worktrees */
/** Projects to query for reads. In a worktree: `[parent, composite]` so
* main-repo context flows into every worktree while sibling worktrees stay
* isolated. In the main repo: `[primary]`. Writes always use `.primary`. */
allProjects: string[];
}
@@ -96,7 +98,7 @@ export function getProjectContext(cwd: string | null | undefined): ProjectContex
primary: composite,
parent: worktreeInfo.parentProjectName,
isWorktree: true,
allProjects: [composite]
allProjects: [worktreeInfo.parentProjectName, composite]
};
}