Compare commits

...

1 Commits

Author SHA1 Message Date
Kit Langton 55d4cd19e5 fix(opencode): warn on unknown config fields 2026-08-08 18:58:35 +00:00
3 changed files with 14 additions and 1 deletions
+6 -1
View File
@@ -224,7 +224,12 @@ const layer = Layer.effect(
), ),
) )
const parsed = ConfigParse.jsonc(expanded, source) const parsed = ConfigParse.jsonc(expanded, source)
const data = ConfigParse.schema(ConfigV1.Info, normalizeLoadedConfig(parsed), source) const normalized = normalizeLoadedConfig(parsed)
const unrecognized = ConfigParse.unrecognizedKeys(ConfigV1.Info, normalized)
if (unrecognized.length) {
yield* Effect.logWarning("ignoring unrecognized config fields", { source, fields: unrecognized })
}
const data = ConfigParse.schema(ConfigV1.Info, normalized, source)
if (!("path" in options)) return data if (!("path" in options)) return data
yield* Effect.promise(() => resolveLoadedPlugins(data, options.path)) yield* Effect.promise(() => resolveLoadedPlugins(data, options.path))
+7
View File
@@ -59,3 +59,10 @@ export function schema<S extends EffectSchema.Decoder<unknown, never>>(
{ cause: error }, { cause: error },
) )
} }
export function unrecognizedKeys(schema: EffectSchema.Top, data: unknown) {
if (typeof data !== "object" || data === null || Array.isArray(data)) return []
if (schema.ast._tag !== "Objects" || schema.ast.indexSignatures.length > 0) return []
const known = new Set(schema.ast.propertySignatures.map((item) => String(item.name)))
return Object.keys(data).filter((key) => !known.has(key))
}
@@ -1347,6 +1347,7 @@ test("config parser preserves permission order while ignoring unknown top-level
expect(Object.keys(config.permission!)).toEqual(["bash", "*", "edit"]) expect(Object.keys(config.permission!)).toEqual(["bash", "*", "edit"])
expect(config).not.toHaveProperty("plugins") expect(config).not.toHaveProperty("plugins")
expect(ConfigParse.unrecognizedKeys(ConfigV1.Info, { plugins: ["example"] })).toEqual(["plugins"])
}) })
// MCP config merging tests // MCP config merging tests