Skip to content
Closed
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
14 changes: 11 additions & 3 deletions base-action/src/parse-sdk-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,17 @@ function parseClaudeArgsToExtraArgs(
if (!claudeArgs?.trim()) return {};

const result: Record<string, string | null> = {};
const args = parseShellArgs(claudeArgs).filter(
(arg): arg is string => typeof arg === "string",
);
const args = parseShellArgs(claudeArgs)
.map((arg) => {
if (typeof arg === "string") return arg;
// shell-quote treats # as a comment and returns {comment: "..."} objects.
// Convert these back to strings since # is valid in flag values.
if (typeof arg === "object" && arg !== null && "comment" in arg) {
return `#${(arg as { comment: string }).comment}`;
}
return undefined;
})
.filter((arg): arg is string => arg !== undefined);

for (let i = 0; i < args.length; i++) {
const arg = args[i];
Expand Down
27 changes: 27 additions & 0 deletions base-action/test/parse-sdk-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,33 @@ describe("parseSdkOptions", () => {
});
});

describe("hash character handling", () => {
test("should preserve # in flag values instead of treating as comment", () => {
const options: ClaudeOptions = {
claudeArgs: '--append-system-prompt "# Use best practices"',
};

const result = parseSdkOptions(options);

expect(result.sdkOptions.extraArgs?.["append-system-prompt"]).toBe(
"# Use best practices",
);
});

test("should handle unquoted # by converting comment object back to string", () => {
const options: ClaudeOptions = {
claudeArgs:
"--model claude-sonnet-4-5-20250929 --append-system-prompt #Use",
};

const result = parseSdkOptions(options);

expect(result.sdkOptions.extraArgs?.["append-system-prompt"]).toBe(
"#Use",
);
});
});

describe("other extraArgs passthrough", () => {
test("should pass through json-schema in extraArgs", () => {
const options: ClaudeOptions = {
Expand Down