From 8f7b0120eb6b4aa3da1f82b1a9094a9fb4db2d06 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Sat, 17 Oct 2026 15:24:22 -0700 Subject: [PATCH] docs(www): format yield* in Effect snippets (#56568) --- .../src/docs/content/build/client/effect.mdx | 50 ++++++++++--------- .../src/docs/content/build/plugins/effect.mdx | 24 ++++----- .../docs/content/build/plugins/effect/rpc.mdx | 10 ++-- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/services/www/src/docs/content/build/client/effect.mdx b/services/www/src/docs/content/build/client/effect.mdx index 75b53998f2f..f9b49b70bd3 100644 --- a/services/www/src/docs/content/build/client/effect.mdx +++ b/services/www/src/docs/content/build/client/effect.mdx @@ -39,33 +39,34 @@ Configure default headers on the supplied `HttpClient`. Native operations use normal Effect interruption for cancellation. RPC methods additionally accept per-call location, header, and signal options. +{/* prettier-ignore */} ```ts import { HttpClient, HttpClientRequest } from "effect/http" -const httpClient = yield * HttpClient.HttpClient -const client = - yield * - OpenCode.make({ baseUrl: "https://opencode.example.com" }).pipe( - Effect.provideService( - HttpClient.HttpClient, - HttpClient.mapRequest(httpClient, (request) => - HttpClientRequest.setHeaders(request, { authorization: `Bearer ${process.env.OPENCODE_TOKEN}` }), - ), +const httpClient = yield* HttpClient.HttpClient +const client = yield* OpenCode.make({ baseUrl: "https://opencode.example.com" }).pipe( + Effect.provideService( + HttpClient.HttpClient, + HttpClient.mapRequest(httpClient, (request) => + HttpClientRequest.setHeaders(request, { authorization: `Bearer ${process.env.OPENCODE_TOKEN}` }), ), - ) + ), +) -const sessions = yield * client.session.list() +const sessions = yield* client.session.list() ``` ## Stream events Streaming operations such as `event.subscribe()` and `session.log()` return Effect Streams. +{/* prettier-ignore */} ```ts import { Effect, Stream } from "effect" -yield * - client.event.subscribe().pipe(Stream.runForEach((event) => Effect.logInfo("OpenCode event", { type: event.type }))) +yield* client.event + .subscribe() + .pipe(Stream.runForEach((event) => Effect.logInfo("OpenCode event", { type: event.type }))) ``` Native and RPC event Streams share one lazy connection per client. Constructing @@ -78,20 +79,20 @@ receive the current connection marker before live events. Use the same shared contract as Promise clients and server plugins: +{/* prettier-ignore */} ```ts import { Acme } from "opencode-acme-plugin/rpc" const acme = client.rpc(Acme) -const result = yield * acme.search({ query: "hello" }, { location: { directory: "/workspace" } }) +const result = yield* acme.search({ query: "hello" }, { location: { directory: "/workspace" } }) -yield * - acme.events - .subscribe("updated") - .pipe( - Stream.runForEach((event) => - Effect.logInfo("Plugin event", { type: event.type, location: event.location, text: event.data.text }), - ), - ) +yield* acme.events + .subscribe("updated") + .pipe( + Stream.runForEach((event) => + Effect.logInfo("Plugin event", { type: event.type, location: event.location, text: event.data.text }), + ), + ) ``` Method arguments and results are inferred from the contract. The second optional @@ -144,7 +145,8 @@ const health = await Effect.runPromise( Discover without starting, or stop the exact registered service. +{/* prettier-ignore */} ```ts -const endpoint = yield * Service.discover() -yield * Service.stop() +const endpoint = yield* Service.discover() +yield* Service.stop() ``` diff --git a/services/www/src/docs/content/build/plugins/effect.mdx b/services/www/src/docs/content/build/plugins/effect.mdx index 1b4654b61ea..f5a3b7e7d72 100644 --- a/services/www/src/docs/content/build/plugins/effect.mdx +++ b/services/www/src/docs/content/build/plugins/effect.mdx @@ -348,14 +348,14 @@ effect: (ctx) => For account-specific discovery, pass the connection used to load the inventory as `sourceConnection`. OpenCode excludes that provider while another connection is selected, until your plugin publishes its refreshed inventory. +{/* prettier-ignore */} ```ts -const connection = yield * ctx.integration.connection.active("acme") +const connection = yield* ctx.integration.connection.active("acme") if (!connection) return -const inventory = yield * loadInventory(connection) -yield * - ctx.provider.transform((editor) => { - editor.add({ info: inventory.provider, models: inventory.models, sourceConnection: connection }) - }) +const inventory = yield* loadInventory(connection) +yield* ctx.provider.transform((editor) => { + editor.add({ info: inventory.provider, models: inventory.models, sourceConnection: connection }) +}) ``` Schemas: [`Provider.Info`](/api#schema-Provider.Info), [`Model.Info`](/api#schema-Model.Info). @@ -1020,14 +1020,14 @@ namespaces and unsupported characters in tool names become `_`. Missing names ar `add` with a complete definition. Updates preserve the name and namespace. Assign new schemas or options to replace them rather than mutating nested values. Invalid updates are logged and leave the previous definition intact. +{/* prettier-ignore */} ```ts -yield * - ctx.tool.transform((editor) => { - editor.update("acme_greeting", (tool) => { - tool.description = "Greet the user by name" - }) - editor.remove("acme_obsolete") +yield* ctx.tool.transform((editor) => { + editor.update("acme_greeting", (tool) => { + tool.description = "Greet the user by name" }) + editor.remove("acme_obsolete") +}) ``` Updates and removals replay in order with additions, including after MCP catalog refreshes. diff --git a/services/www/src/docs/content/build/plugins/effect/rpc.mdx b/services/www/src/docs/content/build/plugins/effect/rpc.mdx index 9234b292972..73cee5ce301 100644 --- a/services/www/src/docs/content/build/plugins/effect/rpc.mdx +++ b/services/www/src/docs/content/build/plugins/effect/rpc.mdx @@ -154,16 +154,16 @@ effect: (ctx) => RPC events are Streams. Subscribe by event name and run the Stream in a scoped fiber: +{/* prettier-ignore */} ```ts import { Effect, Stream } from "effect" const acme = ctx.rpc(Acme) -yield * - acme.events.subscribe("updated").pipe( - Stream.runForEach((event) => Effect.logInfo(event.data.text)), - Effect.forkScoped, - ) +yield* acme.events.subscribe("updated").pipe( + Stream.runForEach((event) => Effect.logInfo(event.data.text)), + Effect.forkScoped, +) ``` Subscriptions are live only and close when Stream consumption stops.