@signalridge/pi-worktree 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/session.ts +10 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/session.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { resolve as normalizeTargetPath } from "node:path";
|
|
2
3
|
import type { ExtensionCommandContext, SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
3
4
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
4
5
|
import { stripTerminalControls } from "./git.js";
|
|
@@ -67,6 +68,14 @@ export function createTargetSession(ctx: ExtensionCommandContext, targetPath: st
|
|
|
67
68
|
return writeTargetSession(targetPath, [], undefined, null);
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
export function sessionCwdMatches(
|
|
72
|
+
actual: string,
|
|
73
|
+
expected: string,
|
|
74
|
+
resolvePath: (path: string) => string = normalizeTargetPath,
|
|
75
|
+
): boolean {
|
|
76
|
+
return resolvePath(actual) === resolvePath(expected);
|
|
77
|
+
}
|
|
78
|
+
|
|
70
79
|
function writeTargetSession(
|
|
71
80
|
targetPath: string,
|
|
72
81
|
entries: readonly SessionEntry[],
|
|
@@ -84,7 +93,7 @@ function writeTargetSession(
|
|
|
84
93
|
mode: 0o600,
|
|
85
94
|
});
|
|
86
95
|
const verified = SessionManager.open(targetFile);
|
|
87
|
-
if (verified.getCwd()
|
|
96
|
+
if (!sessionCwdMatches(verified.getCwd(), targetPath) || verified.getLeafId() !== expectedLeaf) {
|
|
88
97
|
throw new Error("Pi could not verify the target session cwd and active branch.");
|
|
89
98
|
}
|
|
90
99
|
return targetFile;
|