Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,21 @@ function makeClaudeTestTurnInput(input: {
}

describe("ClaudeAdapterV2 runtime query policy", () => {
it.each([
"-- --thinking-display omitted",
"--thinking-display summarized -- --thinking-display omitted",
])("does not treat operands after -- as SDK flags: %s", (launchArgs) => {
const options = ClaudeAdapterV2.makeClaudeQueryOptions({
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
nativeThreadId: "thinking-thread",
resume: false,
cwd: "/workspace",
settings: { ...DEFAULT_CLAUDE_SETTINGS, launchArgs },
});
assert.deepEqual(options.thinking, { type: "adaptive", display: "summarized" });
assert.equal(options.extraArgs?.["thinking-display"], "summarized");
});

it.each([
["--permission-mode acceptEdits", "acceptEdits"],
["--dangerously-skip-permissions", "bypassPermissions"],
Expand Down
33 changes: 32 additions & 1 deletion packages/shared/src/cliArgs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,41 @@ describe("parseCliArgs", () => {
});
});

it("ignores bare -- with no flag name", () => {
it("accepts a trailing -- without operands", () => {
expect(parseCliArgs("--")).toEqual({ flags: {}, positionals: [] });
});

it.each([
{ args: "--effort low -- --effort high --chrome" },
{ args: ["--effort", "low", "--", "--effort", "high", "--chrome"] },
])("ends option parsing at -- for $args", ({ args }) => {
expect(parseCliArgs(args)).toEqual({
flags: { effort: "low" },
positionals: ["--effort", "high", "--chrome"],
});
});

it("preserves all operands after --, including empty strings and another --", () => {
expect(parseCliArgs(["--", "", "--", "--model=example", "-x"])).toEqual({
flags: {},
positionals: ["", "--", "--model=example", "-x"],
});
});

it("ends option parsing with explicit boolean flags too", () => {
expect(parseCliArgs(["--chrome", "--", "--verbose"], { booleanFlags: ["chrome"] })).toEqual({
flags: { chrome: null },
positionals: ["--verbose"],
});
});

it("keeps -- inside an equals-form option value", () => {
expect(parseCliArgs("--append-system-prompt=-- --chrome")).toEqual({
flags: { "append-system-prompt": "--", chrome: null },
positionals: [],
});
});

it("boolean flag does not consume next token as value", () => {
expect(parseCliArgs(["--github-output", "1.2.3"], { booleanFlags: ["github-output"] })).toEqual(
{
Expand Down
6 changes: 5 additions & 1 deletion packages/shared/src/cliArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ export function parseCliArgs(
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i]!;

if (token === "--") {
positionals.push(...tokens.slice(i + 1));
break;
}

if (token.startsWith("--")) {
const rest = token.slice(2);
if (!rest) continue;

const eqIndex = rest.indexOf("=");
if (eqIndex !== -1) {
Expand Down
Loading