feat(coding-agent): added JSON syntax support for array and record config values
- Added support for setting array and record configuration values using JSON syntax. - Implemented JSON parsing and validation for array and record types in config CLI. - Added 2 integration tests covering array and record configuration workflows. - Enhanced test setup with temporary directory management and settings reset for isolation.
This commit is contained in:
@@ -195,6 +195,32 @@ function parseAndSetValue(path: SettingPath, rawValue: string): void {
|
||||
parsedValue = trimmed;
|
||||
break;
|
||||
}
|
||||
case "array": {
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(trimmed);
|
||||
} catch {
|
||||
throw new Error(`Invalid array JSON: ${rawValue}`);
|
||||
}
|
||||
if (!Array.isArray(parsed)) {
|
||||
throw new Error(`Invalid array JSON: ${rawValue}`);
|
||||
}
|
||||
parsedValue = parsed;
|
||||
break;
|
||||
}
|
||||
case "record": {
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(trimmed);
|
||||
} catch {
|
||||
throw new Error(`Invalid record JSON: ${rawValue}`);
|
||||
}
|
||||
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
||||
throw new Error(`Invalid record JSON: ${rawValue}`);
|
||||
}
|
||||
parsedValue = parsed;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
parsedValue = trimmed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user