|
|
@@ -1,10 +1,12 @@
|
|
|
export * as ConfigCommand from "./command"
|
|
|
|
|
|
import { Log } from "../util"
|
|
|
-import z from "zod"
|
|
|
+import { Schema } from "effect"
|
|
|
import { NamedError } from "@opencode-ai/shared/util/error"
|
|
|
import { Glob } from "@opencode-ai/shared/util/glob"
|
|
|
import { Bus } from "@/bus"
|
|
|
+import { zod } from "@/util/effect-zod"
|
|
|
+import { withStatics } from "@/util/schema"
|
|
|
import { configEntryNameFromPath } from "./entry-name"
|
|
|
import { InvalidError } from "./error"
|
|
|
import * as ConfigMarkdown from "./markdown"
|
|
|
@@ -12,15 +14,15 @@ import { ConfigModelID } from "./model-id"
|
|
|
|
|
|
const log = Log.create({ service: "config" })
|
|
|
|
|
|
-export const Info = z.object({
|
|
|
- template: z.string(),
|
|
|
- description: z.string().optional(),
|
|
|
- agent: z.string().optional(),
|
|
|
- model: ConfigModelID.optional(),
|
|
|
- subtask: z.boolean().optional(),
|
|
|
-})
|
|
|
+export const Info = Schema.Struct({
|
|
|
+ template: Schema.String,
|
|
|
+ description: Schema.optional(Schema.String),
|
|
|
+ agent: Schema.optional(Schema.String),
|
|
|
+ model: Schema.optional(ConfigModelID),
|
|
|
+ subtask: Schema.optional(Schema.Boolean),
|
|
|
+}).pipe(withStatics((s) => ({ zod: zod(s) })))
|
|
|
|
|
|
-export type Info = z.infer<typeof Info>
|
|
|
+export type Info = Schema.Schema.Type<typeof Info>
|
|
|
|
|
|
export async function load(dir: string) {
|
|
|
const result: Record<string, Info> = {}
|
|
|
@@ -49,7 +51,7 @@ export async function load(dir: string) {
|
|
|
...md.data,
|
|
|
template: md.content.trim(),
|
|
|
}
|
|
|
- const parsed = Info.safeParse(config)
|
|
|
+ const parsed = Info.zod.safeParse(config)
|
|
|
if (parsed.success) {
|
|
|
result[config.name] = parsed.data
|
|
|
continue
|