Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const Info = z
.record(z.string(), ConfigCommand.Info)
.optional()
.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
.object({
ignore: z.array(z.string()).optional(),
Expand Down Expand Up @@ -188,7 +188,7 @@ export const Info = z
)
.optional()
.describe("MCP (Model Context Protocol) server configurations"),
formatter: ConfigFormatter.Info.optional(),
formatter: ConfigFormatter.Info.zod.optional(),
lsp: ConfigLSP.Info.zod.optional(),
instructions: z.array(z.string()).optional().describe("Additional instruction files or patterns to include"),
layout: Layout.optional().describe("@deprecated Always uses stretch layout."),
Expand Down
21 changes: 11 additions & 10 deletions packages/opencode/src/config/console-state.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import z from "zod"
import { Schema } from "effect"
import { zod } from "@/util/effect-zod"

export const ConsoleState = z.object({
consoleManagedProviders: z.array(z.string()),
activeOrgName: z.string().optional(),
switchableOrgCount: z.number().int().nonnegative(),
})

export type ConsoleState = z.infer<typeof ConsoleState>
export class ConsoleState extends Schema.Class<ConsoleState>("ConsoleState")({
consoleManagedProviders: Schema.mutable(Schema.Array(Schema.String)),
activeOrgName: Schema.optional(Schema.String),
switchableOrgCount: Schema.Number,
}) {
static readonly zod = zod(this)
}

export const emptyConsoleState: ConsoleState = {
export const emptyConsoleState: ConsoleState = ConsoleState.make({
consoleManagedProviders: [],
activeOrgName: undefined,
switchableOrgCount: 0,
}
})
22 changes: 13 additions & 9 deletions packages/opencode/src/config/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
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({
disabled: z.boolean().optional(),
command: z.array(z.string()).optional(),
environment: z.record(z.string(), z.string()).optional(),
extensions: z.array(z.string()).optional(),
})
export const Entry = Schema.Struct({
disabled: Schema.optional(Schema.Boolean),
command: Schema.optional(Schema.mutable(Schema.Array(Schema.String))),
environment: Schema.optional(Schema.Record(Schema.String, Schema.String)),
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 type Info = z.infer<typeof Info>
export const Info = Schema.Union([Schema.Boolean, Schema.Record(Schema.String, Entry)]).pipe(
withStatics((s) => ({ zod: zod(s) })),
)
export type Info = Schema.Schema.Type<typeof Info>
21 changes: 12 additions & 9 deletions packages/opencode/src/config/skills.ts
Original file line number Diff line number Diff line change
@@ -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({
paths: z.array(z.string()).optional().describe("Additional paths to skill folders"),
urls: z
.array(z.string())
.optional()
.describe("URLs to fetch skills from (e.g., https://example.com/.well-known/skills/)"),
})
export const Info = Schema.Struct({
paths: Schema.optional(Schema.Array(Schema.String)).annotate({
description: "Additional paths to skill folders",
}),
urls: Schema.optional(Schema.Array(Schema.String)).annotate({
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"
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const ExperimentalRoutes = lazy(() =>
description: "Active Console provider metadata",
content: {
"application/json": {
schema: resolver(ConsoleState),
schema: resolver(ConsoleState.zod),
},
},
},
Expand Down
12 changes: 7 additions & 5 deletions packages/sdk/js/src/v2/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,12 @@ export type Provider = {
}
}

export type ConsoleState = {
consoleManagedProviders: Array<string>
activeOrgName?: string
switchableOrgCount: number
}

export type ToolIds = Array<string>

export type ToolListItem = {
Expand Down Expand Up @@ -2933,11 +2939,7 @@ export type ExperimentalConsoleGetResponses = {
/**
* Active Console provider metadata
*/
200: {
consoleManagedProviders: Array<string>
activeOrgName?: string
switchableOrgCount: number
}
200: ConsoleState
}

export type ExperimentalConsoleGetResponse = ExperimentalConsoleGetResponses[keyof ExperimentalConsoleGetResponses]
Expand Down
Loading