diff --git a/src/workspaces.test.ts b/src/workspaces.test.ts index 7b8136fd..9561123b 100644 --- a/src/workspaces.test.ts +++ b/src/workspaces.test.ts @@ -16,11 +16,11 @@ const outsideRoot = await mkdtemp(join(tmpdir(), "devspace-workspace-outside-tes try { const agentDir = join(root, ".pi", "agent"); await mkdir(agentDir, { recursive: true }); - await mkdir(join(agentDir, "skills"), { recursive: true }); - await writeFile(join(agentDir, "skills", "AGENTS.md"), "global instructions\n"); if (platform() === "win32") { await writeFile(join(agentDir, "AGENTS.md"), "global instructions\n"); } else { + await mkdir(join(agentDir, "skills"), { recursive: true }); + await writeFile(join(agentDir, "skills", "AGENTS.md"), "global instructions\n"); await symlink("skills/AGENTS.md", join(agentDir, "AGENTS.md")); } await writeFile(join(root, "AGENTS.md"), "root instructions\n"); @@ -179,6 +179,12 @@ try { mode: "worktree", }); assert.equal(aliasWorkspace.workspace.sourceRoot, join(aliasRoot, "git-project")); + + const aliasCheckout = await new WorkspaceRegistry(aliasConfig).openWorkspace(aliasRoot); + assert.deepEqual( + aliasCheckout.agentsFiles.map((file) => file.content), + ["global instructions\n", "root instructions\n"], + ); } } finally { await rm(root, { recursive: true, force: true }); diff --git a/src/workspaces.ts b/src/workspaces.ts index 466b1b40..844ddab3 100644 --- a/src/workspaces.ts +++ b/src/workspaces.ts @@ -248,12 +248,19 @@ export class WorkspaceRegistry { private async loadInitialAgentsFiles(root: string): Promise { const agentDir = resolve(this.config.agentDir); + const resolvedRoot = (await tryRealpath(root)) ?? root; + const resolvedAgentDir = (await tryRealpath(agentDir)) ?? agentDir; const loadedFiles: LoadedAgentsFile[] = []; for (const file of loadProjectContextFiles({ cwd: root, agentDir })) { const path = resolve(file.path); if (!isInitialAgentsFilePath(path, root, agentDir)) continue; - const content = await readResolvedContextFile(path, file.content, root, agentDir); + const content = await readResolvedContextFile( + path, + file.content, + resolvedRoot, + resolvedAgentDir, + ); if (content === undefined) continue; loadedFiles.push({