fix(cli): serialize object daemon arguments (#2797)

## Summary

Fix daemon argument serialization for object-valued CLI options.

`serializeArgs()` currently falls back to `String(value)` for
non-boolean, non-array values. Yargs parses options such as `wsHeaders`
into an object, so direct serialization produces `[object Object]` and
the daemon cannot reconstruct the value.

This change serializes object values with `JSON.stringify()` while
preserving the existing behavior for primitive, boolean, and array
options.

## Review follow-up

The earlier review also identified CLI-injected `isolated` / `headless`
defaults interacting badly with `--config`. Current upstream `main` has
since removed those assignments entirely, so after rebasing there is no
additional default-guard change to carry in this PR.

## Validation

- focused `serializeArgs` regression for object values
- `git diff --check`

Signed-off-by: Robert McConnell <robert@mcc0nnell.org>
This commit is contained in:
Robert McConnell authored and GitHub committed 2026-10-16 09:35:29 +00:00
1 parent c6ad84a23b
commit f73a440b49
2 files changed
+18 -1

No files matched your search

+3 -1
View File
@@ -189,7 +189,9 @@ export function serializeArgs(
args.push(`--${kebabKey}=${String(item)}`);
}
} else {
args.push(`--${kebabKey}=${String(value)}`);
const serializedValue =
typeof value === 'object' ? JSON.stringify(value) : String(value);
args.push(`--${kebabKey}=${serializedValue}`);
}
}
return args;
+15
View File
@@ -125,6 +125,21 @@ describe('serializeArgs', () => {
assert.deepStrictEqual(result, ['--foo=string', '--bar=42']);
});
it('should serialize object values as JSON', () => {
const options: Record<string, YargsOptions> = {wsHeaders: {}};
const argv = {
wsHeaders: {
Authorization: 'Bearer token',
},
_: [],
$0: 'test',
} as unknown as ParsedArguments;
const result = serializeArgs(options, argv);
assert.deepStrictEqual(result, [
'--ws-headers={"Authorization":"Bearer token"}',
]);
});
it('should convert camelCase keys to kebab-case', () => {
const options: Record<string, YargsOptions> = {
camelCaseKey: {},