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:
@@ -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,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager";
|
||||
import type { AssistantMessage } from "@oh-my-pi/pi-ai";
|
||||
import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager";
|
||||
import { TempDir } from "@oh-my-pi/pi-utils";
|
||||
|
||||
describe("SessionManager signature persistence", () => {
|
||||
@@ -33,8 +33,11 @@ describe("SessionManager signature persistence", () => {
|
||||
await session.flush();
|
||||
|
||||
const reloaded = await SessionManager.open(session.getSessionFile()!);
|
||||
const assistant = reloaded.getEntries().find(entry => entry.type === "message" && entry.message.role === "assistant")
|
||||
?.message as AssistantMessage | undefined;
|
||||
const assistant = reloaded
|
||||
.getEntries()
|
||||
.find(entry => entry.type === "message" && entry.message.role === "assistant")?.message as
|
||||
| AssistantMessage
|
||||
| undefined;
|
||||
|
||||
expect(assistant).toBeDefined();
|
||||
expect(assistant?.content[0]).toMatchObject({ type: "thinking", thinking: "reasoning", thinkingSignature: "" });
|
||||
|
||||
Reference in New Issue
Block a user