@oh-my-pi/pi-utils 12.8.2 → 12.10.0
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/package.json +1 -1
- package/src/dirs.ts +17 -7
package/package.json
CHANGED
package/src/dirs.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* PI_CODING_AGENT_DIR to override the agent directory.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import * as fs from "node:fs";
|
|
9
9
|
import * as os from "node:os";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import { version } from "../package.json" with { type: "json" };
|
|
@@ -24,13 +24,23 @@ export const VERSION: string = version;
|
|
|
24
24
|
// Root directories
|
|
25
25
|
// =============================================================================
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
/**
|
|
28
|
+
* On macOS, strip /private prefix only when both paths resolve to the same location.
|
|
29
|
+
* This preserves aliases like /private/tmp -> /tmp without rewriting unrelated paths.
|
|
30
|
+
*/
|
|
31
|
+
function standardizeMacOSPath(p: string): string {
|
|
32
|
+
if (process.platform !== "darwin" || !p.startsWith("/private/")) return p;
|
|
33
|
+
const stripped = p.slice("/private".length);
|
|
34
|
+
try {
|
|
35
|
+
if (fs.realpathSync(p) === fs.realpathSync(stripped)) {
|
|
36
|
+
return stripped;
|
|
37
|
+
}
|
|
38
|
+
} catch {}
|
|
39
|
+
return p;
|
|
32
40
|
}
|
|
33
41
|
|
|
42
|
+
let projectDir = standardizeMacOSPath(process.cwd());
|
|
43
|
+
|
|
34
44
|
/** Get the project directory. */
|
|
35
45
|
export function getProjectDir(): string {
|
|
36
46
|
return projectDir;
|
|
@@ -38,7 +48,7 @@ export function getProjectDir(): string {
|
|
|
38
48
|
|
|
39
49
|
/** Set the project directory. */
|
|
40
50
|
export function setProjectDir(dir: string): void {
|
|
41
|
-
projectDir = path.resolve(dir);
|
|
51
|
+
projectDir = standardizeMacOSPath(path.resolve(dir));
|
|
42
52
|
process.chdir(projectDir);
|
|
43
53
|
}
|
|
44
54
|
|