diff --git a/base-action/src/parse-sdk-options.ts b/base-action/src/parse-sdk-options.ts index 35df281d2..586be2e0c 100644 --- a/base-action/src/parse-sdk-options.ts +++ b/base-action/src/parse-sdk-options.ts @@ -24,6 +24,19 @@ const ACCUMULATING_FLAGS = new Set([ // Delimiter used to join accumulated flag values const ACCUMULATE_DELIMITER = "\x00"; +/** + * Strip shell-style comments from input before parsing. + * Shell-quote treats # as a comment character, swallowing all content after it. + * This function removes lines that start with # (after trimming) to prevent + * flags after comments from being swallowed. + */ +function stripShellComments(input: string): string { + return input + .split("\n") + .filter((line) => !line.trim().startsWith("#")) + .join("\n"); +} + type McpConfig = { mcpServers?: Record; }; @@ -91,8 +104,11 @@ function parseClaudeArgsToExtraArgs( ): Record { if (!claudeArgs?.trim()) return {}; + // Strip shell comments before parsing to prevent # from swallowing subsequent flags + const strippedArgs = stripShellComments(claudeArgs); + const result: Record = {}; - const args = parseShellArgs(claudeArgs).filter( + const args = parseShellArgs(strippedArgs).filter( (arg): arg is string => typeof arg === "string", );