diff --git a/services/www/src/docs/content/build/client/effect.mdx b/services/www/src/docs/content/build/client/effect.mdx index f9b49b70bd36..9358c63e72a0 100644 --- a/services/www/src/docs/content/build/client/effect.mdx +++ b/services/www/src/docs/content/build/client/effect.mdx @@ -6,7 +6,7 @@ title: "Effect" and decodes responses into OpenCode schema values. ```sh -bun add @opencode/client effect +bun add @opencode/client effect@4.0.1 ``` ## Create a client @@ -114,7 +114,7 @@ The Node-only `@opencode/client/effect/service` entrypoint discovers, starts, au background service as Effects. ```sh -bun add @effect/platform-node +bun add @effect/platform-node@4.0.1 ``` Create an authenticated client for the ensured service. @@ -132,7 +132,9 @@ const program = Effect.gen(function* () { const client = yield* OpenCode.make({ baseUrl: endpoint.url }).pipe( Effect.provideService( HttpClient.HttpClient, - HttpClient.mapRequest(httpClient, (request) => HttpClientRequest.setHeaders(request, Service.headers(endpoint))), + HttpClient.mapRequest(httpClient, (request) => + HttpClientRequest.setHeaders(request, Service.headers(endpoint) ?? {}), + ), ), ) return yield* client.server.info() diff --git a/services/www/src/docs/content/build/plugins/cli.mdx b/services/www/src/docs/content/build/plugins/cli.mdx index 07d9ff213862..4ebabf78f24d 100644 --- a/services/www/src/docs/content/build/plugins/cli.mdx +++ b/services/www/src/docs/content/build/plugins/cli.mdx @@ -110,9 +110,9 @@ context.data.session.permission.invalidate(sessionID) Forms can be listed, refreshed, replied to, or cancelled at a location. ```ts -import type { FormCancelInput, FormReplyInput } from "@opencode/client" +import type { SessionFormCancelInput, SessionFormReplyInput } from "@opencode/client" -async function handleForm(reply: FormReplyInput, cancel: FormCancelInput) { +async function handleForm(reply: SessionFormReplyInput, cancel: SessionFormCancelInput) { const location = context.location await context.data.session.form.sync(sessionID, location) const forms = context.data.session.form.list(sessionID, location) ?? [] diff --git a/services/www/src/docs/content/build/plugins/effect.mdx b/services/www/src/docs/content/build/plugins/effect.mdx index f5a3b7e7d721..9de81ec5aba6 100644 --- a/services/www/src/docs/content/build/plugins/effect.mdx +++ b/services/www/src/docs/content/build/plugins/effect.mdx @@ -10,7 +10,7 @@ plugins and their `node_modules` dependencies. Install them as peer/dev dependen rather than bundling them into your plugin. ```sh -bun add --peer @opencode/plugin effect +bun add --peer @opencode/plugin effect@4.0.1 ``` Export an Effect plugin from `.opencode/plugins/` to load it automatically. @@ -721,7 +721,7 @@ effect: (ctx) => const plugin = ctx.plugin const active = yield* plugin.list().pipe( Effect.orDie, - Effect.map((result) => result.data.filter((item) => item.status === "active")), + Effect.map((result) => result.data.filter((item) => item.state.status === "active")), ) yield* Effect.logInfo("active plugin count", { count: active.length }) }), @@ -817,7 +817,7 @@ effect: (ctx) => const summary = yield* session .generate({ sessionID: created.id, prompt: "Summarize this project" }) .pipe(Effect.orDie) - yield* session.command({ sessionID: created.id, command: "review", arguments: "--staged" }).pipe(Effect.orDie) + yield* session.command({ sessionID: created.id, name: "review", text: "--staged" }).pipe(Effect.orDie) yield* session .synthetic({ sessionID: created.id, text: `Summary generated: ${summary.text}`, resume: false }) .pipe(Effect.orDie) @@ -892,7 +892,7 @@ Read skills at the current location. effect: (ctx) => Effect.gen(function* () { const skill = ctx.skill - const skills = yield* skill.list() + const skills = yield* skill.list().pipe(Effect.orDie) yield* Effect.logInfo("skills", { ids: skills.data.map((item) => item.id) }) }), ``` @@ -909,7 +909,7 @@ effect: (ctx) => id: Skill.ID.make("review"), name: Skill.Name.make("Review"), description: "Review the current changes", - path: "/workspace/.opencode/skills/review/SKILL.md", + path: Skill.Info.fields.path.make("/workspace/.opencode/skills/review/SKILL.md"), content: "Review the current changes for correctness and missing tests.", })) const review = editor.get("review") @@ -1071,7 +1071,7 @@ effect: (ctx) => Effect.gen(function* () { const vcs = ctx.vcs const info = yield* vcs.get().pipe(Effect.orDie) - const branches = yield* vcs.branches({ search: "feature", limit: 10 }).pipe(Effect.orDie) + const branches = yield* vcs.branch.list({ search: "feature", limit: 10 }).pipe(Effect.orDie) const changes = yield* vcs.status().pipe(Effect.orDie) const diff = yield* vcs.diff({ mode: "working", context: 3 }).pipe(Effect.orDie) yield* Effect.logInfo("vcs", { branch: info.data.branch.current, files: changes.data.length }) @@ -1517,7 +1517,8 @@ type Transform = (callback: (input: Input) => void) => Effect.Effect prompt(input: SessionPromptInput, requestOptions?: RequestOptions): Promise generate(input: SessionGenerateInput, requestOptions?: RequestOptions): Promise<{ text: string }> - command(input: SessionCommandInput, requestOptions?: RequestOptions): Promise + command(input: SessionCommandInput, requestOptions?: RequestOptions): Promise compact(input: SessionCompactInput, requestOptions?: RequestOptions): Promise synthetic(input: SessionSyntheticInput, requestOptions?: RequestOptions): Promise - interrupt(input: SessionInterruptInput, requestOptions?: RequestOptions): Promise + interrupt(input: SessionInterruptInput, requestOptions?: RequestOptions): Promise<{ interrupted: boolean }> wait(input: SessionWaitInput, requestOptions?: RequestOptions): Promise } ``` @@ -874,13 +874,15 @@ Register a transform to inspect, add, update, or remove skills. `get(id)` return when the skill is absent. ```ts +import { Skill } from "@opencode/plugin" + await ctx.skill.transform((editor) => { const skills = editor.list() editor.add({ - id: "review", - name: "Review", + id: Skill.ID.make("review"), + name: Skill.Name.make("Review"), description: "Review the current changes", - path: "/workspace/.opencode/skills/review/SKILL.md", + path: Skill.Info.fields.path.make("/workspace/.opencode/skills/review/SKILL.md"), content: "Review the current changes for correctness and missing tests.", }) const review = editor.get("review") @@ -1069,7 +1071,7 @@ Read repository information, working-copy status, or file diffs. ```ts const info = await ctx.vcs.get() -const branches = await ctx.vcs.branches({ search: "feature", limit: 10 }) +const branches = await ctx.vcs.branch.list({ search: "feature", limit: 10 }) const changes = await ctx.vcs.status() const diff = await ctx.vcs.diff({ mode: "working", context: 3 }) ``` @@ -1108,7 +1110,9 @@ Schemas: [`Vcs.Info`](/api#schema-Vcs.Info), [`Vcs.FileStatus`](/api#schema-Vcs. ```ts interface VcsContext { get(input?: VcsGetInput, requestOptions?: RequestOptions): Promise - branches(input?: VcsBranchesInput, requestOptions?: RequestOptions): Promise + branch: { + list(input?: VcsBranchListInput, requestOptions?: RequestOptions): Promise + } status(input?: VcsStatusInput, requestOptions?: RequestOptions): Promise diff(input: VcsDiffInput, requestOptions?: RequestOptions): Promise transform(callback: (editor: VcsEditor) => void): Promise @@ -1268,7 +1272,7 @@ await ctx.websearch.transform((editor) => { name: "Internal search", execute: async ({ query }, { signal }) => { const response = await fetch(`https://search.example.com?q=${encodeURIComponent(query)}`, { signal }) - const result = await response.json() + const result = (await response.json()) as { url: string; title: string; content: string } return [{ url: result.url, title: result.title, content: result.content, time: {} }] }, }) diff --git a/services/www/src/docs/content/build/plugins/migrate-v1.mdx b/services/www/src/docs/content/build/plugins/migrate-v1.mdx index 7c1b5e143d67..1cd6a5afee37 100644 --- a/services/www/src/docs/content/build/plugins/migrate-v1.mdx +++ b/services/www/src/docs/content/build/plugins/migrate-v1.mdx @@ -28,7 +28,7 @@ Rename `plugin` to `plugins`. Replace a package-and-options tuple with an object "plugins": [ "opencode-example-plugin", { - "package": "./plugin/local.ts", + "package": "./plugin/local", "options": { "enabled": true } } ] @@ -36,6 +36,8 @@ Rename `plugin` to `plugins`. Replace a package-and-options tuple with an object ``` V2 discovers local plugins from both `.opencode/plugin/` and `.opencode/plugins/`; use `.opencode/plugins/` for V2 files. +Configured local paths must name directories. For the example above, move the ported implementation to +`./plugin/local/index.ts`; a configured `./plugin/local.ts` file is skipped with a warning in the log. Keep supporting modules beside the plugin when moving it. Local plugins and package plugins use the same implementation API. @@ -180,7 +182,9 @@ V2 separates prompt admission, model-visible context, semantic model options, an layer your plugin needs. ```ts title="V1" -export const RequestPlugin = async () => ({ +import type { Plugin } from "@opencode-ai/plugin" + +export const RequestPlugin: Plugin = async () => ({ "chat.params": async (_input, output) => { output.temperature = 0.2 output.maxOutputTokens = 8_000 diff --git a/services/www/src/docs/content/build/sdk/effect.mdx b/services/www/src/docs/content/build/sdk/effect.mdx index a91deec12149..a7ab85e3e842 100644 --- a/services/www/src/docs/content/build/sdk/effect.mdx +++ b/services/www/src/docs/content/build/sdk/effect.mdx @@ -6,7 +6,7 @@ title: "Effect" the owning Scope releases the router, Location services, fibers, and plugin registrations. ```sh -bun add @opencode/sdk effect +bun add @opencode/sdk effect@4.0.1 ``` ## Create a host