fix(coding-agent): Clean up Path Handling (#4873)
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
* createAgentSession() options. The SDK does the heavy lifting.
|
||||
*/
|
||||
|
||||
import { resolve } from "node:path";
|
||||
import { createInterface } from "node:readline";
|
||||
import { type ImageContent, modelsAreEqual } from "@earendil-works/pi-ai";
|
||||
import { ProcessTerminal, setKeybindings, TUI } from "@earendil-works/pi-tui";
|
||||
@@ -46,7 +45,7 @@ import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.ts";
|
||||
import { ExtensionSelectorComponent } from "./modes/interactive/components/extension-selector.ts";
|
||||
import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.ts";
|
||||
import { handleConfigCommand, handlePackageCommand } from "./package-manager-cli.ts";
|
||||
import { isLocalPath } from "./utils/paths.ts";
|
||||
import { isLocalPath, normalizePath, resolvePath } from "./utils/paths.ts";
|
||||
import { cleanupWindowsSelfUpdateQuarantine } from "./utils/windows-self-update.ts";
|
||||
|
||||
/**
|
||||
@@ -147,9 +146,9 @@ type ResolvedSession =
|
||||
* If it looks like a path, use as-is. Otherwise try to match as session ID prefix.
|
||||
*/
|
||||
async function resolveSessionPath(sessionArg: string, cwd: string, sessionDir?: string): Promise<ResolvedSession> {
|
||||
// If it looks like a file path, use as-is
|
||||
// If it looks like a file path, resolve it before handing it to the session manager.
|
||||
if (sessionArg.includes("/") || sessionArg.includes("\\") || sessionArg.endsWith(".jsonl")) {
|
||||
return { type: "path", path: sessionArg };
|
||||
return { type: "path", path: resolvePath(sessionArg, cwd) };
|
||||
}
|
||||
|
||||
// Try to match as session ID in current project first
|
||||
@@ -381,7 +380,7 @@ function buildSessionOptions(
|
||||
}
|
||||
|
||||
function resolveCliPaths(cwd: string, paths: string[] | undefined): string[] | undefined {
|
||||
return paths?.map((value) => (isLocalPath(value) ? resolve(cwd, value) : value));
|
||||
return paths?.map((value) => (isLocalPath(value) ? resolvePath(value, cwd) : value));
|
||||
}
|
||||
|
||||
async function promptForMissingSessionCwd(
|
||||
@@ -501,7 +500,7 @@ export async function main(args: string[], options?: MainOptions) {
|
||||
// sessionDir lookup during session selection.
|
||||
const envSessionDir = process.env[ENV_SESSION_DIR];
|
||||
const sessionDir =
|
||||
parsed.sessionDir ??
|
||||
(parsed.sessionDir ? normalizePath(parsed.sessionDir) : undefined) ??
|
||||
(envSessionDir ? expandTildePath(envSessionDir) : undefined) ??
|
||||
startupSettingsManager.getSessionDir();
|
||||
let sessionManager = await createSessionManager(parsed, cwd, sessionDir, startupSettingsManager);
|
||||
|
||||
Reference in New Issue
Block a user