fix(coding-agent): resolved symlinked paths before passing to brush

- Resolved symlinked paths before passing to brush shell to keep `pwd` output aligned with canonical Git worktree paths.
- Added `resolveShellCwd` helper that safely resolves symlinks and falls back to original path on error.
- Added test case verifying symlinked directories are canonicalized before execution.
This commit is contained in:
can1357
2026-03-09 15:39:05 +01:00
parent aa18e3f26d
commit 2d732bb033
5 changed files with 41 additions and 7 deletions
@@ -39,6 +39,20 @@ describe("executeBash", () => {
expect(result.output.trim()).toBe(tempDir);
});
it("canonicalizes symlinked cwd before execution", async () => {
if (process.platform === "win32") {
return;
}
const realDir = path.join(tempDir, "real");
const linkDir = path.join(tempDir, "link");
fs.mkdirSync(realDir);
fs.symlinkSync(realDir, linkDir, "dir");
const result = await executeBash("pwd", { cwd: linkDir, timeout: 5000 });
expect(result.output.trim()).toBe(fs.realpathSync(linkDir));
});
it("passes env vars", async () => {
const result = await executeBash("echo $PI_TEST_ENV", {
cwd: tempDir,