Merge remote-tracking branch 'upstream/main' into feat/profiles-and-alias

# Conflicts:
#	packages/coding-agent/src/cli/args.ts
#	packages/coding-agent/src/commands/launch.ts
This commit is contained in:
Ogrodev
2026-06-07 20:42:45 -03:00
65 changed files with 3037 additions and 302 deletions
+1 -1
View File
@@ -225,7 +225,7 @@ export function getExtraHelpText(): string {
NODE_EXTRA_CA_CERTS - CA bundle path (or inline PEM) for server certificate validation
OPENAI_API_KEY - OpenAI GPT models
GEMINI_API_KEY - Google Gemini models
GITHUB_TOKEN - GitHub Copilot (or GH_TOKEN, COPILOT_GITHUB_TOKEN)
COPILOT_GITHUB_TOKEN - GitHub Copilot
${chalk.dim("# Additional LLM Providers")}
AZURE_OPENAI_API_KEY - Azure OpenAI models
@@ -94,6 +94,9 @@ const setResume: OptionalSetter = (result, value) => {
* token starts with `-`.
*/
export const STRING_SETTERS: Record<string, StringSetter> = {
"--cwd": (result, value) => {
result.cwd = value;
},
"--mode": (result, value) => {
if (value === "text" || value === "json" || value === "rpc" || value === "acp" || value === "rpc-ui") {
result.mode = value;
@@ -0,0 +1,68 @@
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { getProjectDir, normalizePathForComparison, setProjectDir } from "@oh-my-pi/pi-utils";
import type { Args } from "./args";
async function maybeAutoChdir(parsed: Args): Promise<void> {
if (parsed.allowHome || parsed.cwd) {
return;
}
const home = os.homedir();
if (!home) {
return;
}
const normalizePath = normalizePathForComparison;
const cwd = normalizePath(getProjectDir());
const normalizedHome = normalizePath(home);
if (cwd !== normalizedHome) {
return;
}
const isDirectory = async (p: string) => {
try {
const s = await fs.stat(p);
return s.isDirectory();
} catch {
return false;
}
};
const candidates = [path.join(home, "tmp"), "/tmp", "/var/tmp"];
for (const candidate of candidates) {
try {
if (!(await isDirectory(candidate))) {
continue;
}
setProjectDir(candidate);
return;
} catch {
// Try next candidate.
}
}
try {
const fallback = os.tmpdir();
if (fallback && normalizePath(fallback) !== cwd && (await isDirectory(fallback))) {
setProjectDir(fallback);
}
} catch {
// Ignore fallback errors.
}
}
export async function applyStartupCwd(parsed: Args): Promise<void> {
if (parsed.cwd) {
setProjectDir(parsed.cwd);
// setProjectDir resolves the (possibly relative) target against the launch
// cwd and chdirs into it. Re-sync parsed.cwd to the resolved absolute path
// so downstream consumers (buildSessionOptions, settings/discovery, session
// persistence) don't re-resolve a relative string against the new cwd.
parsed.cwd = getProjectDir();
return;
}
await maybeAutoChdir(parsed);
}