refactor(config): migrate skills, formatter, console-state to Effect Schema (#23162)

This commit is contained in:
Kit Langton
2026-04-17 20:49:36 +00:00
committed by GitHub
parent dc16013b4f
commit b1307d5c2a
6 changed files with 46 additions and 36 deletions
+2 -2
View File
@@ -100,7 +100,7 @@ export const Info = z
.record(z.string(), ConfigCommand.Info) .record(z.string(), ConfigCommand.Info)
.optional() .optional()
.describe("Command configuration, see https://opencode.ai/docs/commands"), .describe("Command configuration, see https://opencode.ai/docs/commands"),
skills: ConfigSkills.Info.optional().describe("Additional skill folder paths"), skills: ConfigSkills.Info.zod.optional().describe("Additional skill folder paths"),
watcher: z watcher: z
.object({ .object({
ignore: z.array(z.string()).optional(), ignore: z.array(z.string()).optional(),
@@ -188,7 +188,7 @@ export const Info = z
) )
.optional() .optional()
.describe("MCP (Model Context Protocol) server configurations"), .describe("MCP (Model Context Protocol) server configurations"),
formatter: ConfigFormatter.Info.optional(), formatter: ConfigFormatter.Info.zod.optional(),
lsp: ConfigLSP.Info.zod.optional(), lsp: ConfigLSP.Info.zod.optional(),
instructions: z.array(z.string()).optional().describe("Additional instruction files or patterns to include"), instructions: z.array(z.string()).optional().describe("Additional instruction files or patterns to include"),
layout: Layout.optional().describe("@deprecated Always uses stretch layout."), layout: Layout.optional().describe("@deprecated Always uses stretch layout."),
+11 -10
View File
@@ -1,15 +1,16 @@
import z from "zod" import { Schema } from "effect"
import { zod } from "@/util/effect-zod"
export const ConsoleState = z.object({ export class ConsoleState extends Schema.Class<ConsoleState>("ConsoleState")({
consoleManagedProviders: z.array(z.string()), consoleManagedProviders: Schema.mutable(Schema.Array(Schema.String)),
activeOrgName: z.string().optional(), activeOrgName: Schema.optional(Schema.String),
switchableOrgCount: z.number().int().nonnegative(), switchableOrgCount: Schema.Number,
}) }) {
static readonly zod = zod(this)
}
export type ConsoleState = z.infer<typeof ConsoleState> export const emptyConsoleState: ConsoleState = ConsoleState.make({
export const emptyConsoleState: ConsoleState = {
consoleManagedProviders: [], consoleManagedProviders: [],
activeOrgName: undefined, activeOrgName: undefined,
switchableOrgCount: 0, switchableOrgCount: 0,
} })
+13 -9
View File
@@ -1,13 +1,17 @@
export * as ConfigFormatter from "./formatter" export * as ConfigFormatter from "./formatter"
import z from "zod" import { Schema } from "effect"
import { zod } from "@/util/effect-zod"
import { withStatics } from "@/util/schema"
export const Entry = z.object({ export const Entry = Schema.Struct({
disabled: z.boolean().optional(), disabled: Schema.optional(Schema.Boolean),
command: z.array(z.string()).optional(), command: Schema.optional(Schema.mutable(Schema.Array(Schema.String))),
environment: z.record(z.string(), z.string()).optional(), environment: Schema.optional(Schema.Record(Schema.String, Schema.String)),
extensions: z.array(z.string()).optional(), extensions: Schema.optional(Schema.mutable(Schema.Array(Schema.String))),
}) }).pipe(withStatics((s) => ({ zod: zod(s) })))
export const Info = z.union([z.boolean(), z.record(z.string(), Entry)]) export const Info = Schema.Union([Schema.Boolean, Schema.Record(Schema.String, Entry)]).pipe(
export type Info = z.infer<typeof Info> withStatics((s) => ({ zod: zod(s) })),
)
export type Info = Schema.Schema.Type<typeof Info>
+12 -9
View File
@@ -1,13 +1,16 @@
import z from "zod" import { Schema } from "effect"
import { zod } from "@/util/effect-zod"
import { withStatics } from "@/util/schema"
export const Info = z.object({ export const Info = Schema.Struct({
paths: z.array(z.string()).optional().describe("Additional paths to skill folders"), paths: Schema.optional(Schema.Array(Schema.String)).annotate({
urls: z description: "Additional paths to skill folders",
.array(z.string()) }),
.optional() urls: Schema.optional(Schema.Array(Schema.String)).annotate({
.describe("URLs to fetch skills from (e.g., https://example.com/.well-known/skills/)"), description: "URLs to fetch skills from (e.g., https://example.com/.well-known/skills/)",
}) }),
}).pipe(withStatics((s) => ({ zod: zod(s) })))
export type Info = z.infer<typeof Info> export type Info = Schema.Schema.Type<typeof Info>
export * as ConfigSkills from "./skills" export * as ConfigSkills from "./skills"
@@ -49,7 +49,7 @@ export const ExperimentalRoutes = lazy(() =>
description: "Active Console provider metadata", description: "Active Console provider metadata",
content: { content: {
"application/json": { "application/json": {
schema: resolver(ConsoleState), schema: resolver(ConsoleState.zod),
}, },
}, },
}, },
+7 -5
View File
@@ -1807,6 +1807,12 @@ export type Provider = {
} }
} }
export type ConsoleState = {
consoleManagedProviders: Array<string>
activeOrgName?: string
switchableOrgCount: number
}
export type ToolIds = Array<string> export type ToolIds = Array<string>
export type ToolListItem = { export type ToolListItem = {
@@ -2933,11 +2939,7 @@ export type ExperimentalConsoleGetResponses = {
/** /**
* Active Console provider metadata * Active Console provider metadata
*/ */
200: { 200: ConsoleState
consoleManagedProviders: Array<string>
activeOrgName?: string
switchableOrgCount: number
}
} }
export type ExperimentalConsoleGetResponse = ExperimentalConsoleGetResponses[keyof ExperimentalConsoleGetResponses] export type ExperimentalConsoleGetResponse = ExperimentalConsoleGetResponses[keyof ExperimentalConsoleGetResponses]