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
@@ -1,6 +1,7 @@
import * as path from "node:path";
import { createInterface } from "node:readline/promises";
import { $env } from "@oh-my-pi/pi-utils";
import { getProjectDir } from "@oh-my-pi/pi-utils/dirs";
import { applyChangelogProposals } from "../../commit/changelog";
import { detectChangelogBoundaries } from "../../commit/changelog/detect";
import { parseUnreleasedSection } from "../../commit/changelog/parse";
@@ -26,7 +27,7 @@ interface CommitExecutionContext {
}
export async function runAgenticCommit(args: CommitCommandArgs): Promise<void> {
const cwd = process.cwd();
const cwd = getProjectDir();
const git = new ControlledGit(cwd);
const [settings, authStorage] = await Promise.all([Settings.init({ cwd }), discoverAuthStorage()]);
+2 -1
View File
@@ -1,6 +1,7 @@
import * as path from "node:path";
import type { Api, Model } from "@oh-my-pi/pi-ai";
import { logger } from "@oh-my-pi/pi-utils";
import { getProjectDir } from "@oh-my-pi/pi-utils/dirs";
import { ModelRegistry } from "../config/model-registry";
import { renderPromptTemplate } from "../config/prompt-templates";
import { Settings } from "../config/settings";
@@ -38,7 +39,7 @@ export async function runCommitCommand(args: CommitCommandArgs): Promise<void> {
}
async function runLegacyCommitCommand(args: CommitCommandArgs): Promise<void> {
const cwd = process.cwd();
const cwd = getProjectDir();
const settings = await Settings.init();
const commitSettings = settings.getGroup("commit");
const authStorage = await discoverAuthStorage();