@devries-cameron20 / t3code-1 / commits / bf8fd416a2
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Claude append launch text may start with two hyphens (#35598)

Julius Marminge committed Nov 14, 2026 at 20:53 UTC bf8fd416a2b3698adad5670dd6cdf21e34a35c63
4 files changed +51 -4
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+30
@@ -1256,6 +1256,36 @@ describe("ClaudeAdapterV2 append-system-prompt-file launch argument", () => {
1256 const appendSystemPrompt = (options: ClaudeAdapterV2.ClaudeAgentSdkQueryOptions | undefined) =>
1257 (options?.systemPrompt as { readonly append?: string } | undefined)?.append;
1258
1259 + // regression: #35594 append text starting with "--" was read as a missing value
1260 + it.effect("sends append launch text that starts with two hyphens to Claude", () =>
1261 + Effect.scoped(
1262 + Effect.gen(function* () {
1263 + const fileSystem = yield* FileSystem.FileSystem;
1264 + const cwd = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-append-cwd-" });
1265 + const plain = yield* startTurnWithLaunchArgs("", cwd);
1266 + const { exit, opened } = yield* startTurnWithLaunchArgs(
1267 + '--append-system-prompt "-- Always answer in English"',
1268 + cwd,
1269 + );
1270 + assert.isTrue(Exit.isSuccess(exit));
1271 + assert.lengthOf(opened, 1);
1272 + assert.equal(
1273 + appendSystemPrompt(opened[0]),
1274 + `${appendSystemPrompt(plain.opened[0])}\n\n-- Always answer in English`,
1275 + );
1276 + }).pipe(
1277 + Effect.provide(
1278 + Layer.mergeAll(
1279 + IdAllocator.layer,
1280 + McpProviderSessions.layer,
1281 + NodeServices.layer,
1282 + NodeCrypto.layer,
1283 + ),
1284 + ),
1285 + ),
1286 + ),
1287 + );
1288 +
1289 it.effect("sends append launch arguments to Claude after the T3 instructions", () =>
1290 Effect.gen(function* () {
1291 const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+9 -3
@@ -355,6 +355,9 @@ function mergeClaudeStreamUsage(
355 };
356 }
357 export const CLAUDE_DEFAULT_INSTANCE_ID = defaultInstanceIdForDriver(CLAUDE_PROVIDER);
358 +// The Claude CLI takes the next token as this flag's value even when it starts with `--`.
359 +const claudeLaunchArgParseOptions = { valueFlags: ["append-system-prompt"] };
360 +
361 const CLAUDE_SCRIPT_EXTENSIONS = [".js", ".mjs", ".tsx", ".ts", ".jsx"];
362 // The SDK has no control-request deadline; the CLI waits up to 30 s per MCP server.
363 const CLAUDE_MCP_REGISTRATION_TIMEOUT = "90 seconds";
@@ -2150,7 +2153,9 @@ export function makeClaudeQueryOptions(input: {
2153 // The SDK replaces this flag with options.settings, so it arrives read as sdkSettings.
2154 settings: _launchArgSettings,
2155 ...extraArgs
2153 - } = input.settings === undefined ? {} : parseCliArgs(input.settings.launchArgs).flags;
2156 + } = input.settings === undefined
2157 + ? {}
2158 + : parseCliArgs(input.settings.launchArgs, claudeLaunchArgParseOptions).flags;
2159 // Claude Code overwrites its CLI append text with the SDK's initialize
2160 // appendSystemPrompt, so launch-argument text has to travel in that value.
2161 // The CLI puts file text before inline text and trims one trailing newline.
@@ -2320,7 +2325,7 @@ const readClaudeAppendSystemPromptFile = Effect.fnUntraced(function* (input: {
2325 readonly path: Path.Path;
2326 }) {
2327 if (input.settings === undefined) return undefined;
2323 - const flags = parseCliArgs(input.settings.launchArgs).flags;
2328 + const flags = parseCliArgs(input.settings.launchArgs, claudeLaunchArgParseOptions).flags;
2329 // parseCliArgs gives null for a flag with no following value. An explicit
2330 // `--append-system-prompt ""` is a value the CLI accepts, so it stays.
2331 if (flags["append-system-prompt"] === null) {
@@ -2365,7 +2370,8 @@ const readClaudeLaunchArgSettings = Effect.fn("ClaudeAdapterV2.readLaunchArgSett
2370 readonly path: Path.Path;
2371 }) {
2372 if (input.settings === undefined) return undefined;
2368 - const value = parseCliArgs(input.settings.launchArgs).flags.settings;
2373 + const value = parseCliArgs(input.settings.launchArgs, claudeLaunchArgParseOptions).flags
2374 + .settings;
2375 if (value === undefined) return undefined;
2376 const trimmed = value?.trim() ?? "";
2377 if (trimmed.length === 0) return yield* new ClaudeSettingsLaunchArgError({});
packages/shared/src/cliArgs.test.ts
+8
@@ -107,6 +107,14 @@ describe("parseCliArgs", () => {
107 });
108 });
109
110 + it("value flag consumes a next token that starts with --", () => {
111 + expect(
112 + parseCliArgs(["--append-system-prompt", "-- text", "--chrome"], {
113 + valueFlags: ["append-system-prompt"],
114 + }),
115 + ).toEqual({ flags: { "append-system-prompt": "-- text", chrome: null }, positionals: [] });
116 + });
117 +
118 it("boolean flag does not consume next token as value", () => {
119 expect(parseCliArgs(["--github-output", "1.2.3"], { booleanFlags: ["github-output"] })).toEqual(
120 {
packages/shared/src/cliArgs.ts
+4 -1
@@ -5,6 +5,8 @@ export interface ParsedCliArgs {
5
6 export interface ParseCliArgsOptions {
7 readonly booleanFlags?: readonly string[];
8 + /** Flags that always take the next token as their value, even one starting with `--`. */
9 + readonly valueFlags?: readonly string[];
10 }
11
12 export function tokenizeCliArgs(args?: string): ReadonlyArray<string> {
@@ -70,6 +72,7 @@ export function parseCliArgs(
72 ): ParsedCliArgs {
73 const tokens = typeof args === "string" ? tokenizeCliArgs(args) : Array.from(args);
74 const booleanSet = options?.booleanFlags ? new Set(options.booleanFlags) : undefined;
75 + const valueSet = options?.valueFlags ? new Set(options.valueFlags) : undefined;
76
77 const flags: Record<string, string | null> = {};
78 const positionals: string[] = [];
@@ -97,7 +100,7 @@ export function parseCliArgs(
100 }
101
102 const next = tokens[i + 1];
100 - if (next !== undefined && !next.startsWith("--")) {
103 + if (next !== undefined && (valueSet?.has(rest) || !next.startsWith("--"))) {
104 flags[rest] = next;
105 i++;
106 } else {