Skip to content

Commit 970ee34

Browse files
authored
fix: use absolute TASK_AUTOSTART path in workspace mode (#71)
In workspace mode, task PROMPT.md lives in the config repo (shared-libs) but workers execute in other repos' worktrees (api-service, web-client). Relative paths from repoRoot don't exist in cross-repo worktrees. Always use absolute paths in workspace mode.
1 parent 4bb386e commit 970ee34

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

extensions/taskplane/execution.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,30 @@ export function buildLaneEnvVars(
155155
repoRoot: string,
156156
workspaceRoot?: string,
157157
): Record<string, string> {
158-
// TASK_AUTOSTART needs a path relative to the worktree root.
159-
// The promptPath is absolute (from the main repo). We need the
160-
// relative portion from the repo root, which will be the same
161-
// relative path in the worktree since worktrees mirror the repo structure.
158+
// TASK_AUTOSTART: resolve the prompt path for the lane session.
159+
//
160+
// In workspace mode, tasks may live in a different repo than the lane's
161+
// worktree (e.g., task PROMPT.md in shared-libs, worker runs in api-service).
162+
// Always use the absolute path — task-runner's resolve(cwd, autoPath) handles
163+
// absolute paths correctly, and this avoids broken relative paths when the
164+
// task folder is outside the lane's repo.
165+
//
166+
// In repo mode (no workspace), we still use relative paths from repoRoot
167+
// because the worktree mirrors the repo structure and the task folder is
168+
// inside the repo.
162169
const repoRootNorm = resolve(repoRoot).replace(/\\/g, "/");
163170
const promptNorm = resolve(promptPath).replace(/\\/g, "/");
164171

165172
let relativePath: string;
166-
if (promptNorm.startsWith(repoRootNorm + "/")) {
173+
if (workspaceRoot) {
174+
// Workspace mode: always use absolute path for cross-repo safety
175+
relativePath = resolve(promptPath);
176+
} else if (promptNorm.startsWith(repoRootNorm + "/")) {
177+
// Repo mode: relative path from repo root (mirrors into worktree)
167178
relativePath = promptNorm.slice(repoRootNorm.length + 1);
168179
} else {
169-
// External task folder (workspace mode): prompt path is outside repo root.
170-
// Use the absolute path as-is — task-runner accepts absolute TASK_AUTOSTART paths.
171-
relativePath = promptPath;
180+
// Fallback: absolute path
181+
relativePath = resolve(promptPath);
172182
}
173183

174184
const nodePathEntries: string[] = [join(repoRoot, "node_modules")];

0 commit comments

Comments
 (0)