Allow $schema in config files

This commit is contained in:
Mohamed Boudra
2026-06-05 22:38:40 +07:00
parent 59b32ab3be
commit d35bffed8b
3 changed files with 38 additions and 0 deletions

View File

@@ -561,6 +561,39 @@ describe("PersistedConfigSchema voice mode config", () => {
});
});
describe("loadPersistedConfig", () => {
test("accepts the documented config schema marker", () => {
const home = createTempHome();
const configPath = path.join(home, "config.json");
try {
writeFileSync(
configPath,
`${JSON.stringify(
{
$schema: "https://paseo.sh/schemas/paseo.config.v1.json",
version: 1,
daemon: {
listen: "127.0.0.1:6767",
hostnames: ["localhost", ".localhost"],
mcp: { enabled: true },
},
},
null,
2,
)}\n`,
);
const config = loadPersistedConfig(home);
expect(config.daemon?.listen).toBe("127.0.0.1:6767");
expect(config.daemon?.hostnames).toEqual(["localhost", ".localhost"]);
expect(config.daemon?.mcp?.enabled).toBe(true);
} finally {
rmSync(home, { recursive: true, force: true });
}
});
});
describe.skipIf(process.platform === "win32")("persisted config file permissions", () => {
test("initializes config.json with private permissions", () => {
const home = createTempHome();

View File

@@ -203,6 +203,8 @@ function normalizeAgentProviders(value: unknown): unknown {
export const PersistedConfigSchema = z
.object({
$schema: z.string().optional(),
// v1 schema marker
version: z.literal(1).optional(),

View File

@@ -4,6 +4,9 @@
"PaseoConfigV1": {
"type": "object",
"properties": {
"$schema": {
"type": "string"
},
"version": {
"type": "number",
"const": 1