refactor: implemented $PWD > cwd to prevent macOS symlink resolution

- Replaced all direct `process.cwd()` calls with `getProjectDir()` utility function across 40+ files to centralize project directory resolution logic.
- Added `getProjectDir()` and `setProjectDir()` functions to `@oh-my-pi/pi-utils/dirs` module to provide abstracted project directory management.
- Made `SessionManager.list()` method asynchronous to support asynchronous session discovery operations.
- Updated default working directory resolution throughout codebase to use `getProjectDir()` instead of `process.cwd()` for improved project directory detection.
This commit is contained in:
can1357
2026-02-13 23:40:02 +01:00
parent f8e915e14e
commit d1e16d2101
43 changed files with 161 additions and 111 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
import * as path from "node:path";
import { createInterface } from "node:readline/promises";
import { Shell } from "@oh-my-pi/pi-natives";
import { APP_NAME } from "@oh-my-pi/pi-utils/dirs";
import { APP_NAME, getProjectDir } from "@oh-my-pi/pi-utils/dirs";
import chalk from "chalk";
import { Settings } from "../config/settings";
import { getOrCreateSnapshot } from "../utils/shell-snapshot";
@@ -47,7 +47,7 @@ export async function runShellCommand(cmd: ShellCommandArgs): Promise<void> {
process.exit(1);
}
const cwd = cmd.cwd ? path.resolve(cmd.cwd) : process.cwd();
const cwd = cmd.cwd ? path.resolve(cmd.cwd) : getProjectDir();
const settings = await Settings.init({ cwd });
const { shell, env: shellEnv } = settings.getShellConfig();
const snapshotPath = cmd.noSnapshot || !shell.includes("bash") ? null : await getOrCreateSnapshot(shell, shellEnv);