fix(coding-agent): Clean up Path Handling (#4873)
This commit is contained in:
@@ -3,6 +3,7 @@ import { homedir } from "os";
|
||||
import { basename, dirname, join, resolve, sep, win32 } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { spawnProcessSync } from "./utils/child-process.ts";
|
||||
import { normalizePath } from "./utils/paths.ts";
|
||||
|
||||
// =============================================================================
|
||||
// Package Detection
|
||||
@@ -330,9 +331,7 @@ export function getPackageDir(): string {
|
||||
// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly)
|
||||
const envDir = process.env.PI_PACKAGE_DIR;
|
||||
if (envDir) {
|
||||
if (envDir === "~") return homedir();
|
||||
if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
|
||||
return envDir;
|
||||
return normalizePath(envDir);
|
||||
}
|
||||
|
||||
if (isBunBinary) {
|
||||
@@ -454,9 +453,7 @@ export const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;
|
||||
export const ENV_SESSION_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_SESSION_DIR`;
|
||||
|
||||
export function expandTildePath(path: string): string {
|
||||
if (path === "~") return homedir();
|
||||
if (path.startsWith("~/")) return homedir() + path.slice(1);
|
||||
return path;
|
||||
return normalizePath(path);
|
||||
}
|
||||
|
||||
const DEFAULT_SHARE_VIEWER_URL = "https://pi.dev/session/";
|
||||
|
||||
Reference in New Issue
Block a user