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

33
packages/core/src/app.ts Normal file
View file

@ -0,0 +1,33 @@
export * as App from "./app"
import { Context, Layer } from "effect"
import { makeGlobalNode } from "@opencode-ai/util/effect/app-node"
export interface Info {
readonly name: string
readonly version: string
readonly channel: string
}
export const Metadata = Context.Reference<Info>("@opencode/App", {
defaultValue: () => make(),
})
export function make(input: Partial<Info> = {}): Info {
return {
name: input.name ?? "opencode",
version: input.version ?? "unknown",
channel: input.channel ?? "unknown",
}
}
export function useragent(app: Info) {
return `opencode/${app.channel}/${app.version}/${app.name}`
}
export const layer = (input?: Partial<Info>) => Layer.succeed(Metadata, make(input))
export const configured = (input?: Partial<Info>) =>
makeGlobalNode({ service: Metadata, layer: layer(input), deps: [] })
export const node = configured()