feat(plugin): expose app metadata (#38179)

This commit is contained in:
Dax 2026-07-21 18:16:25 -04:00 committed by GitHub
commit 8de40be6ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
71 changed files with 477 additions and 286 deletions

View file

@ -11,7 +11,7 @@ export const create = Effect.fn("OpenCode.create")(function* (options: ServerOpt
ManagedRuntime.make(
createEmbeddedRoutes({
...options,
client: options.client ?? "sdk",
app: { ...options.app, name: options.app?.name ?? "sdk" },
database: { path: ":memory:", ...options.database },
}).pipe(Layer.provide(HttpServer.layerServices)),
),

View file

@ -25,6 +25,27 @@ const sessionID = (fixture: Fixture) => fixture.sdk.Session.ID.create()
const location = (fixture: Fixture) =>
fixture.sdk.Location.Ref.make({ directory: fixture.sdk.AbsolutePath.make(fixture.directory) })
it.live("exposes app metadata to plugins", () =>
withEmbedded("opencode-embedded-app-", (fixture) =>
Effect.gen(function* () {
const opencode = yield* fixture.sdk.OpenCode.create({
app: { name: "test", version: "1.2.3", channel: "beta" },
})
const app = yield* Deferred.make<{ readonly name: string; readonly version: string; readonly channel: string }>()
yield* opencode.plugin({
id: `app-${crypto.randomUUID()}`,
effect: (ctx) => Deferred.succeed(app, ctx.app).pipe(Effect.asVoid),
})
yield* opencode.plugin.list({ location: location(fixture) })
expect(yield* Deferred.await(app).pipe(Effect.timeout("4 seconds"))).toEqual({
name: "test",
version: "1.2.3",
channel: "beta",
})
}),
),
)
it.live(
"reloads every booted Location after SDK plugin registration",
() =>