fix(coding-agent): parse launch cwd flag

This commit is contained in:
DarkPhilosophy
2026-06-07 20:57:14 +03:00
parent b6d422ff65
commit a58f0bcbeb
4 changed files with 27 additions and 0 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed the `--cwd` launch flag so it is parsed and can override the startup directory instead of always falling back to the current process directory or home auto-switch target.
## [15.10.1] - 2026-06-07
### Added
+2
View File
@@ -109,6 +109,8 @@ export function parseArgs(inputArgs: string[], extensionFlags?: Map<string, { ty
result.version = true;
} else if (arg === "--allow-home") {
result.allowHome = true;
} else if (arg === "--cwd" && i + 1 < args.length) {
result.cwd = args[++i];
} else if (arg === "--mode" && i + 1 < args.length) {
const mode = args[++i];
if (mode === "text" || mode === "json" || mode === "rpc" || mode === "acp" || mode === "rpc-ui") {
@@ -49,6 +49,9 @@ export default class Index extends Command {
"allow-home": Flags.boolean({
description: "Allow starting in ~ without auto-switching to a temp dir",
}),
cwd: Flags.string({
description: "Directory to start in (overrides the launch cwd)",
}),
mode: Flags.string({
description: "Output mode: text (default), json, rpc, or rpc-ui",
options: ["text", "json", "rpc", "acp", "rpc-ui"],
@@ -0,0 +1,18 @@
import { describe, expect, it } from "bun:test";
import { parseArgs } from "../src/cli/args";
describe("parseArgs — --cwd flag", () => {
it("parses --cwd with a space-separated directory", () => {
const result = parseArgs(["--cwd", "/work/project", "hello"]);
expect(result.cwd).toBe("/work/project");
expect(result.messages).toEqual(["hello"]);
});
it("parses --cwd=value without leaking the value into messages", () => {
const result = parseArgs(["--cwd=/work/project", "hello"]);
expect(result.cwd).toBe("/work/project");
expect(result.messages).toEqual(["hello"]);
});
});