Skip to content

Commit 2da6d86

Browse files
authored
refactor(core): derive provider schema .zod via effect-zod walker (#23753)
1 parent df0c1f6 commit 2da6d86

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/opencode/specs/effect/schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ schema module with a clear domain.
162162
- [ ] `src/control-plane/schema.ts`
163163
- [ ] `src/permission/schema.ts`
164164
- [ ] `src/project/schema.ts`
165-
- [ ] `src/provider/schema.ts`
165+
- [x] `src/provider/schema.ts`
166166
- [ ] `src/pty/schema.ts`
167167
- [ ] `src/question/schema.ts`
168168
- [ ] `src/session/schema.ts`

packages/opencode/src/provider/schema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Schema } from "effect"
2-
import z from "zod"
32

3+
import { zod } from "@/util/effect-zod"
44
import { withStatics } from "@/util/schema"
55

66
const providerIdSchema = Schema.String.pipe(Schema.brand("ProviderID"))
@@ -9,7 +9,7 @@ export type ProviderID = typeof providerIdSchema.Type
99

1010
export const ProviderID = providerIdSchema.pipe(
1111
withStatics((schema: typeof providerIdSchema) => ({
12-
zod: z.string().pipe(z.custom<ProviderID>()),
12+
zod: zod(schema),
1313
// Well-known providers
1414
opencode: schema.make("opencode"),
1515
anthropic: schema.make("anthropic"),
@@ -30,7 +30,7 @@ const modelIdSchema = Schema.String.pipe(Schema.brand("ModelID"))
3030
export type ModelID = typeof modelIdSchema.Type
3131

3232
export const ModelID = modelIdSchema.pipe(
33-
withStatics((_schema: typeof modelIdSchema) => ({
34-
zod: z.string().pipe(z.custom<ModelID>()),
33+
withStatics((schema: typeof modelIdSchema) => ({
34+
zod: zod(schema),
3535
})),
3636
)

0 commit comments

Comments
 (0)