The best way to control Claude Code, Codex and more from any computer or phone
fix(shared): stop parsing CLI flags after -- (#25204)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>
maria committed
Oct 29, 2026 at 17:51 UTC
8084e00bced3939c93c87f70301a7135c2f9d794
3 files changed
+52
-2
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+15
@@ -235,6 +235,21 @@ function makeClaudeTestTurnInput(input: {
235
}
236
237
describe("ClaudeAdapterV2 runtime query policy", () => {
238
+ it.each([
239
+ "-- --thinking-display omitted",
240
+ "--thinking-display summarized -- --thinking-display omitted",
241
+ ])("does not treat operands after -- as SDK flags: %s", (launchArgs) => {
242
+ const options = ClaudeAdapterV2.makeClaudeQueryOptions({
243
+ modelSelection: CLAUDE_TEST_MODEL_SELECTION,
244
+ nativeThreadId: "thinking-thread",
245
+ resume: false,
246
+ cwd: "/workspace",
247
+ settings: { ...DEFAULT_CLAUDE_SETTINGS, launchArgs },
248
+ });
249
+ assert.deepEqual(options.thinking, { type: "adaptive", display: "summarized" });
250
+ assert.equal(options.extraArgs?.["thinking-display"], "summarized");
251
+ });
252
+
253
it.each([
254
["--permission-mode acceptEdits", "acceptEdits"],
255
["--dangerously-skip-permissions", "bypassPermissions"],
packages/shared/src/cliArgs.test.ts
+32
-1
@@ -54,10 +54,41 @@ describe("parseCliArgs", () => {
54
});
55
});
56
57
- it("ignores bare -- with no flag name", () => {
57
+ it("accepts a trailing -- without operands", () => {
58
expect(parseCliArgs("--")).toEqual({ flags: {}, positionals: [] });
59
});
60
61
+ it.each([
62
+ { args: "--effort low -- --effort high --chrome" },
63
+ { args: ["--effort", "low", "--", "--effort", "high", "--chrome"] },
64
+ ])("ends option parsing at -- for $args", ({ args }) => {
65
+ expect(parseCliArgs(args)).toEqual({
66
+ flags: { effort: "low" },
67
+ positionals: ["--effort", "high", "--chrome"],
68
+ });
69
+ });
70
+
71
+ it("preserves all operands after --, including empty strings and another --", () => {
72
+ expect(parseCliArgs(["--", "", "--", "--model=example", "-x"])).toEqual({
73
+ flags: {},
74
+ positionals: ["", "--", "--model=example", "-x"],
75
+ });
76
+ });
77
+
78
+ it("ends option parsing with explicit boolean flags too", () => {
79
+ expect(parseCliArgs(["--chrome", "--", "--verbose"], { booleanFlags: ["chrome"] })).toEqual({
80
+ flags: { chrome: null },
81
+ positionals: ["--verbose"],
82
+ });
83
+ });
84
+
85
+ it("keeps -- inside an equals-form option value", () => {
86
+ expect(parseCliArgs("--append-system-prompt=-- --chrome")).toEqual({
87
+ flags: { "append-system-prompt": "--", chrome: null },
88
+ positionals: [],
89
+ });
90
+ });
91
+
92
it("boolean flag does not consume next token as value", () => {
93
expect(parseCliArgs(["--github-output", "1.2.3"], { booleanFlags: ["github-output"] })).toEqual(
94
{
packages/shared/src/cliArgs.ts
+5
-1
@@ -77,9 +77,13 @@ export function parseCliArgs(
77
for (let i = 0; i < tokens.length; i++) {
78
const token = tokens[i]!;
79
80
+ if (token === "--") {
81
+ positionals.push(...tokens.slice(i + 1));
82
+ break;
83
+ }
84
+
85
if (token.startsWith("--")) {
86
const rest = token.slice(2);
82
- if (!rest) continue;
87
88
const eqIndex = rest.indexOf("=");
89
if (eqIndex !== -1) {