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
1 change: 0 additions & 1 deletion packages/opencode/src/file/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createWrapper } from "@parcel/watcher/wrapper"
import type ParcelWatcher from "@parcel/watcher"
import { readdir } from "fs/promises"
import path from "path"
import z from "zod"
import { Bus } from "@/bus"
import { BusEvent } from "@/bus/bus-event"
import { InstanceState } from "@/effect/instance-state"
Expand Down
15 changes: 5 additions & 10 deletions packages/opencode/src/installation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
import { withTransientReadRetry } from "@/util/effect-http-client"
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
import path from "path"
import z from "zod"
import { BusEvent } from "@/bus/bus-event"
import { Flag } from "@opencode-ai/core/flag/flag"
import * as Log from "@opencode-ai/core/util/log"
Expand Down Expand Up @@ -45,15 +44,11 @@ export function getReleaseType(current: string, latest: string): ReleaseType {
return "patch"
}

export const Info = z
.object({
version: z.string(),
latest: z.string(),
})
.meta({
ref: "InstallationInfo",
})
export type Info = z.infer<typeof Info>
export const Info = Schema.Struct({
version: Schema.String,
latest: Schema.String,
}).annotate({ identifier: "InstallationInfo" })
export type Info = Schema.Schema.Type<typeof Info>

export const USER_AGENT = `opencode/${InstallationChannel}/${InstallationVersion}/${Flag.OPENCODE_CLIENT}`

Expand Down
9 changes: 4 additions & 5 deletions packages/opencode/src/patch/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import z from "zod"
import { Schema } from "effect"
import * as path from "path"
import * as fs from "fs/promises"
import { readFileSync } from "fs"
Expand All @@ -7,12 +7,11 @@ import * as Bom from "../util/bom"

const log = Log.create({ service: "patch" })

// Schema definitions
export const PatchSchema = z.object({
patchText: z.string().describe("The full patch text that describes all changes to be made"),
export const PatchSchema = Schema.Struct({
patchText: Schema.String.annotate({ description: "The full patch text that describes all changes to be made" }),
})

export type PatchParams = z.infer<typeof PatchSchema>
export type PatchParams = Schema.Schema.Type<typeof PatchSchema>

// Core types matching the Rust implementation
export interface ApplyPatchArgs {
Expand Down
10 changes: 6 additions & 4 deletions packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ModelMessage, ToolResultPart } from "ai"
import { mergeDeep, unique } from "remeda"
import type { JSONSchema7 } from "@ai-sdk/provider"
import type { JSONSchema } from "zod/v4/core"
import type * as Provider from "./provider"
import type * as ModelsDev from "./models"
import { iife } from "@/util/iife"
Expand Down Expand Up @@ -1281,7 +1280,7 @@ export function maxOutputTokens(model: Provider.Model): number {
return Math.min(model.limit.output, OUTPUT_TOKEN_MAX) || OUTPUT_TOKEN_MAX
}

export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JSONSchema7): JSONSchema7 {
export function schema(model: Provider.Model, schema: JSONSchema7): JSONSchema7 {
/*
if (["openai", "azure"].includes(providerID)) {
if (schema.type === "object" && schema.properties) {
Expand Down Expand Up @@ -1312,7 +1311,10 @@ export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JS
return result
}

schema = sanitizeMoonshot(schema) as JSONSchema.BaseSchema | JSONSchema7
const sanitized = sanitizeMoonshot(schema)
if (typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized)) {
schema = sanitized
}
}

// Convert integer enums to string enums for Google/Gemini
Expand Down Expand Up @@ -1394,7 +1396,7 @@ export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JS
schema = sanitizeGemini(schema)
}

return schema as JSONSchema7
return schema
}

export * as ProviderTransform from "./transform"
Loading