feat(effect-zod): add tuple support; migrate config/plugin to Effect Schema (#23178)

This commit is contained in:
Kit Langton
2026-04-17 17:06:55 -04:00
committed by GitHub
parent 89029a20ef
commit 5980b0a5ee
5 changed files with 48 additions and 12 deletions

View File

@@ -113,7 +113,7 @@ export const Info = z
"Enable or disable snapshot tracking. When false, filesystem snapshots are not recorded and undoing or reverting will not undo/redo file changes. Defaults to true.",
),
// User-facing plugin config is stored as Specs; provenance gets attached later while configs are merged.
plugin: ConfigPlugin.Spec.array().optional(),
plugin: ConfigPlugin.Spec.zod.array().optional(),
share: z
.enum(["manual", "auto", "disabled"])
.optional()

View File

@@ -1,16 +1,21 @@
import { Glob } from "@opencode-ai/shared/util/glob"
import z from "zod"
import { Schema } from "effect"
import { pathToFileURL } from "url"
import { isPathPluginSpec, parsePluginSpecifier, resolvePathPluginTarget } from "@/plugin/shared"
import { zod } from "@/util/effect-zod"
import { withStatics } from "@/util/schema"
import path from "path"
const Options = z.record(z.string(), z.unknown())
export type Options = z.infer<typeof Options>
export const Options = Schema.Record(Schema.String, Schema.Unknown).pipe(withStatics((s) => ({ zod: zod(s) })))
export type Options = Schema.Schema.Type<typeof Options>
// Spec is the user-config value: either just a plugin identifier, or the identifier plus inline options.
// It answers "what should we load?" but says nothing about where that value came from.
export const Spec = z.union([z.string(), z.tuple([z.string(), Options])])
export type Spec = z.infer<typeof Spec>
export const Spec = Schema.Union([
Schema.String,
Schema.mutable(Schema.Tuple([Schema.String, Options])),
]).pipe(withStatics((s) => ({ zod: zod(s) })))
export type Spec = Schema.Schema.Type<typeof Spec>
export type Scope = "global" | "local"