refactor(opencode): remove app service layer exports

This commit is contained in:
James Long 2026-06-29 18:08:28 -04:00
commit cd3cf08eb0
28 changed files with 31 additions and 324 deletions

View file

@ -141,7 +141,7 @@ export const loaderLayer = Layer.effect(
}), }),
) )
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const loader = yield* Loader const loader = yield* Loader
@ -201,14 +201,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(loaderLayer),
Layer.provide(Provider.defaultLayer),
Layer.provide(Agent.defaultLayer),
Layer.provide(Command.defaultLayer),
Layer.provide(LayerNode.compile(InstanceStore.node, [[InstanceStore.bootstrapNode, InstanceBootstrap.node]])),
)
export const loaderNode = LayerNode.make({ export const loaderNode = LayerNode.make({
service: Loader, service: Loader,
layer: loaderLayer, layer: loaderLayer,

View file

@ -135,7 +135,7 @@ export const contextLimitLoaderLayer = Layer.effect(
}), }),
) )
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const messageLoader = yield* MessageLoader const messageLoader = yield* MessageLoader
@ -226,12 +226,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(contextLimitLoaderLayer),
Layer.provide(Provider.defaultLayer),
Layer.provide(LayerNode.compile(InstanceStore.node, [[InstanceStore.bootstrapNode, InstanceBootstrap.node]])),
)
export const messageLoaderNode = LayerNode.unbound(MessageLoader, Node.tags.values.global) export const messageLoaderNode = LayerNode.unbound(MessageLoader, Node.tags.values.global)
export const contextLimitLoaderNode = makeGlobalNode({ export const contextLimitLoaderNode = makeGlobalNode({

View file

@ -85,7 +85,7 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Ag
export const use = serviceUse(Service) export const use = serviceUse(Service)
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const config = yield* Config.Service const config = yield* Config.Service
@ -438,15 +438,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(Plugin.defaultLayer),
Layer.provide(Provider.defaultLayer),
Layer.provide(Auth.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(Skill.defaultLayer),
Layer.provide(locationServiceMapLayer),
)
const locationServiceMapNode = LayerNode.make({ const locationServiceMapNode = LayerNode.make({
service: LocationServiceMap.Service, service: LocationServiceMap.Service,
layer: locationServiceMapLayer, layer: locationServiceMapLayer,

View file

@ -55,7 +55,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/Command") {} export class Service extends Context.Service<Service, Interface>()("@opencode/Command") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const config = yield* Config.Service const config = yield* Config.Service
@ -172,12 +172,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(Config.defaultLayer),
Layer.provide(MCP.defaultLayer),
Layer.provide(Skill.defaultLayer),
)
export const node = LayerNode.make({ service: Service, layer: layer, deps: [Config.node, MCP.node, Skill.node] }) export const node = LayerNode.make({ service: Service, layer: layer, deps: [Config.node, MCP.node, Skill.node] })
export * as Command from "." export * as Command from "."

View file

@ -150,7 +150,7 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Wo
export const use = serviceUse(Service) export const use = serviceUse(Service)
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const auth = yield* Auth.Service const auth = yield* Auth.Service
@ -893,19 +893,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(Auth.defaultLayer),
Layer.provide(Session.defaultLayer),
Layer.provide(SessionPrompt.defaultLayer),
Layer.provide(Project.defaultLayer),
Layer.provide(Vcs.defaultLayer),
Layer.provide(FSUtil.defaultLayer),
Layer.provide(Database.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(FetchHttpClient.layer),
Layer.provide(RuntimeFlags.defaultLayer),
)
const TIMEOUT = 5000 const TIMEOUT = 5000
type HistoryEvent = { type HistoryEvent = {

View file

@ -135,7 +135,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/LSP") {} export class Service extends Context.Service<Service, Interface>()("@opencode/LSP") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const config = yield* Config.Service const config = yield* Config.Service
@ -496,12 +496,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(Config.defaultLayer),
Layer.provide(RuntimeFlags.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
)
export * as Diagnostic from "./diagnostic" export * as Diagnostic from "./diagnostic"
export const node = LayerNode.make({ export const node = LayerNode.make({

View file

@ -194,7 +194,7 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/MC
export const use = serviceUse(Service) export const use = serviceUse(Service)
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
@ -1003,16 +1003,6 @@ export const layer = Layer.effect(
export type AuthStatus = "authenticated" | "expired" | "not_authenticated" export type AuthStatus = "authenticated" | "expired" | "not_authenticated"
// --- Per-service runtime ---
export const defaultLayer = layer.pipe(
Layer.provide(McpAuth.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(CrossSpawnSpawner.defaultLayer),
Layer.provide(FSUtil.defaultLayer),
)
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: layer,

View file

@ -120,7 +120,7 @@ async function applyPlugin(load: PluginLoader.Loaded, input: PluginInput, hooks:
} }
} }
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const events = yield* EventV2Bridge.Service const events = yield* EventV2Bridge.Service
@ -305,12 +305,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(RuntimeFlags.defaultLayer),
)
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: layer,

View file

@ -14,7 +14,7 @@ import { Service } from "./bootstrap-service"
export { Service } from "./bootstrap-service" export { Service } from "./bootstrap-service"
export type { Interface } from "./bootstrap-service" export type { Interface } from "./bootstrap-service"
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
// Yield each bootstrap dep at layer init so `run` itself has R = never. // Yield each bootstrap dep at layer init so `run` itself has R = never.
@ -49,19 +49,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer: Layer.Layer<Service> = layer.pipe(
Layer.provide([
Config.defaultLayer,
Format.defaultLayer,
LSP.defaultLayer,
Plugin.defaultLayer,
Project.defaultLayer,
ShareNext.defaultLayer,
Snapshot.defaultLayer,
Vcs.defaultLayer,
]),
)
export const node = makeGlobalNode({ export const node = makeGlobalNode({
service: Service, service: Service,
layer: layer, layer: layer,

View file

@ -106,7 +106,7 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Pr
export const use = serviceUse(Service) export const use = serviceUse(Service)
export const layer: Layer.Layer<Service, never, Auth.Service | Plugin.Service> = Layer.effect( const layer: Layer.Layer<Service, never, Auth.Service | Plugin.Service> = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const auth = yield* Auth.Service const auth = yield* Auth.Service
@ -224,10 +224,6 @@ export const layer: Layer.Layer<Service, never, Auth.Service | Plugin.Service> =
}), }),
) )
export const defaultLayer = Layer.suspend(() =>
layer.pipe(Layer.provide(Auth.defaultLayer), Layer.provide(Plugin.defaultLayer)),
)
export const node = LayerNode.make({ service: Service, layer: layer, deps: [Auth.node, Plugin.node] }) export const node = LayerNode.make({ service: Service, layer: layer, deps: [Auth.node, Plugin.node] })
export * as ProviderAuth from "./auth" export * as ProviderAuth from "./auth"

View file

@ -1299,7 +1299,7 @@ function modelSuggestions(provider: Info | undefined, modelID: ModelV2.ID, enabl
.map((item) => item.id) .map((item) => item.id)
} }
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const fs = yield* FSUtil.Service const fs = yield* FSUtil.Service
@ -1949,18 +1949,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = Layer.suspend(() =>
layer.pipe(
Layer.provide(FSUtil.defaultLayer),
Layer.provide(Env.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(Auth.defaultLayer),
Layer.provide(Plugin.defaultLayer),
Layer.provide(ModelsDev.defaultLayer),
Layer.provide(RuntimeFlags.defaultLayer),
),
)
const priority = ["gpt-5", "claude-sonnet-4", "big-pickle", "gemini-3-pro"] const priority = ["gpt-5", "claude-sonnet-4", "big-pickle", "gemini-3-pro"]
const smallModelFamilyPriority = ["gemini-flash", "gpt-nano", "claude-haiku"] const smallModelFamilyPriority = ["gemini-flash", "gpt-nano", "claude-haiku"]
export function sort<T extends { id: string }>(models: T[]) { export function sort<T extends { id: string }>(models: T[]) {

View file

@ -153,7 +153,7 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Se
export const use = serviceUse(Service) export const use = serviceUse(Service)
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const config = yield* Config.Service const config = yield* Config.Service
@ -544,19 +544,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = Layer.suspend(() =>
layer.pipe(
Layer.provide(Provider.defaultLayer),
Layer.provide(Session.defaultLayer),
Layer.provide(SessionProcessor.defaultLayer),
Layer.provide(Agent.defaultLayer),
Layer.provide(Plugin.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(RuntimeFlags.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
),
)
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: layer,

View file

@ -45,7 +45,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/Instruction") {} export class Service extends Context.Service<Service, Interface>()("@opencode/Instruction") {}
export const layer: Layer.Layer< const layer: Layer.Layer<
Service, Service,
never, never,
FSUtil.Service | Config.Service | Global.Service | HttpClient.HttpClient | RuntimeFlags.Service FSUtil.Service | Config.Service | Global.Service | HttpClient.HttpClient | RuntimeFlags.Service
@ -224,14 +224,6 @@ export const layer: Layer.Layer<
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(Config.defaultLayer),
Layer.provide(Global.layer),
Layer.provide(FSUtil.defaultLayer),
Layer.provide(FetchHttpClient.layer),
Layer.provide(RuntimeFlags.defaultLayer),
)
export function loaded(messages: SessionV1.WithParts[]) { export function loaded(messages: SessionV1.WithParts[]) {
return extract(messages) return extract(messages)
} }

View file

@ -8,7 +8,7 @@ import { Context, Effect, Layer } from "effect"
import * as Stream from "effect/Stream" import * as Stream from "effect/Stream"
import { streamText, wrapLanguageModel, type ModelMessage, type Tool } from "ai" import { streamText, wrapLanguageModel, type ModelMessage, type Tool } from "ai"
import type { LLMEvent } from "@opencode-ai/llm" import type { LLMEvent } from "@opencode-ai/llm"
import { LLMClient, RequestExecutor, WebSocketExecutor } from "@opencode-ai/llm/route" import { LLMClient } from "@opencode-ai/llm/route"
import type { LLMClientService } from "@opencode-ai/llm/route" import type { LLMClientService } from "@opencode-ai/llm/route"
import { GitLabWorkflowLanguageModel } from "gitlab-ai-provider" import { GitLabWorkflowLanguageModel } from "gitlab-ai-provider"
import { ProviderTransform } from "@/provider/transform" import { ProviderTransform } from "@/provider/transform"
@ -384,26 +384,11 @@ const live: Layer.Layer<
}), }),
) )
export const layer = live.pipe(Layer.provide(Permission.defaultLayer), Layer.provide(EventV2Bridge.defaultLayer))
export const defaultLayer = Layer.suspend(() =>
layer.pipe(
Layer.provide(Auth.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(Provider.defaultLayer),
Layer.provide(Plugin.defaultLayer),
Layer.provide(
LLMClient.layer.pipe(Layer.provide(Layer.mergeAll(RequestExecutor.defaultLayer, WebSocketExecutor.layer))),
),
Layer.provide(RuntimeFlags.defaultLayer),
),
)
export const hasToolCalls = LLMRequestPrep.hasToolCalls export const hasToolCalls = LLMRequestPrep.hasToolCalls
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: live,
deps: [ deps: [
Auth.node, Auth.node,
Config.node, Config.node,

View file

@ -78,7 +78,7 @@ type StreamEvent = LLMEvent
export class Service extends Context.Service<Service, Interface>()("@opencode/SessionProcessor") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SessionProcessor") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const session = yield* Session.Service const session = yield* Session.Service
@ -694,23 +694,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = Layer.suspend(() =>
layer.pipe(
Layer.provide(Session.defaultLayer),
Layer.provide(Snapshot.defaultLayer),
Layer.provide(Agent.defaultLayer),
Layer.provide(LLM.defaultLayer),
Layer.provide(Permission.defaultLayer),
Layer.provide(Plugin.defaultLayer),
Layer.provide(SessionSummary.defaultLayer),
Layer.provide(SessionStatus.defaultLayer),
Layer.provide(Image.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(Database.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
),
)
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: layer,

View file

@ -110,7 +110,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/SessionPrompt") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SessionPrompt") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const status = yield* SessionStatus.Service const status = yield* SessionStatus.Service
@ -1490,40 +1490,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = Layer.suspend(() =>
layer.pipe(
Layer.provide(SessionRunState.defaultLayer),
Layer.provide(SessionStatus.defaultLayer),
Layer.provide(SessionCompaction.defaultLayer),
Layer.provide(SessionProcessor.defaultLayer),
Layer.provide(Command.defaultLayer),
Layer.provide(Permission.defaultLayer),
Layer.provide(MCP.defaultLayer),
Layer.provide(LSP.defaultLayer),
Layer.provide(ToolRegistry.defaultLayer),
Layer.provide(Truncate.defaultLayer),
Layer.provide(Provider.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(Instruction.defaultLayer),
Layer.provide(FSUtil.defaultLayer),
Layer.provide(Plugin.defaultLayer),
Layer.provide(Session.defaultLayer),
Layer.provide(SessionRevert.defaultLayer),
Layer.provide(SessionSummary.defaultLayer),
Layer.provide(Image.defaultLayer),
Layer.provide(
Layer.mergeAll(
Agent.defaultLayer,
Database.defaultLayer,
SystemPrompt.defaultLayer,
LLM.defaultLayer,
CrossSpawnSpawner.defaultLayer,
RuntimeFlags.defaultLayer,
EventV2Bridge.defaultLayer,
),
),
),
)
const ModelRef = Schema.Struct({ const ModelRef = Schema.Struct({
providerID: ProviderV2.ID, providerID: ProviderV2.ID,
modelID: ModelV2.ID, modelID: ModelV2.ID,

View file

@ -25,7 +25,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/SessionRevert") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SessionRevert") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const sessions = yield* Session.Service const sessions = yield* Session.Service
@ -137,17 +137,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = Layer.suspend(() =>
layer.pipe(
Layer.provide(SessionRunState.defaultLayer),
Layer.provide(Session.defaultLayer),
Layer.provide(Snapshot.defaultLayer),
Layer.provide(Storage.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(SessionSummary.defaultLayer),
),
)
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: layer,

View file

@ -26,7 +26,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/SessionRunState") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SessionRunState") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const background = yield* BackgroundJob.Service const background = yield* BackgroundJob.Service
@ -108,11 +108,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(BackgroundJob.defaultLayer),
Layer.provide(SessionStatus.defaultLayer),
)
const cancelBackgroundJobs = Effect.fn("SessionRunState.cancelBackgroundJobs")(function* ( const cancelBackgroundJobs = Effect.fn("SessionRunState.cancelBackgroundJobs")(function* (
background: BackgroundJob.Interface, background: BackgroundJob.Interface,
sessionID: SessionID, sessionID: SessionID,

View file

@ -488,7 +488,7 @@ export type Patch = Omit<Partial<Info>, "time" | "share" | "summary" | "revert"
permission?: Info["permission"] | null permission?: Info["permission"] | null
} }
export const layer: Layer.Layer< const layer: Layer.Layer<
Service, Service,
never, never,
BackgroundJob.Service | RuntimeFlags.Service | Database.Service | EventV2Bridge.Service BackgroundJob.Service | RuntimeFlags.Service | Database.Service | EventV2Bridge.Service
@ -940,19 +940,6 @@ export const layer: Layer.Layer<
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(BackgroundJob.defaultLayer),
Layer.provide(Database.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(
SessionV2.defaultLayer.pipe(
Layer.provide(SessionExecutionLocal.defaultLayer),
Layer.provide(locationServiceMapLayer),
),
),
Layer.provide(RuntimeFlags.defaultLayer),
)
const cancelBackgroundJobs = Effect.fn("Session.cancelBackgroundJobs")(function* ( const cancelBackgroundJobs = Effect.fn("Session.cancelBackgroundJobs")(function* (
background: BackgroundJob.Interface, background: BackgroundJob.Interface,
sessionID: SessionID, sessionID: SessionID,

View file

@ -18,7 +18,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/SessionStatus") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SessionStatus") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const events = yield* EventV2Bridge.Service const events = yield* EventV2Bridge.Service
@ -51,8 +51,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(Layer.provide(EventV2Bridge.defaultLayer))
export const node = LayerNode.make({ service: Service, layer: layer, deps: [EventV2Bridge.node] }) export const node = LayerNode.make({ service: Service, layer: layer, deps: [EventV2Bridge.node] })
export * as SessionStatus from "./status" export * as SessionStatus from "./status"

View file

@ -71,7 +71,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/SessionSummary") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SessionSummary") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const sessions = yield* Session.Service const sessions = yield* Session.Service
@ -145,15 +145,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = Layer.suspend(() =>
layer.pipe(
Layer.provide(Session.defaultLayer),
Layer.provide(Snapshot.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(Config.defaultLayer),
),
)
export const DiffInput = Schema.Struct({ export const DiffInput = Schema.Struct({
sessionID: SessionID, sessionID: SessionID,
messageID: Schema.optional(MessageID), messageID: Schema.optional(MessageID),

View file

@ -47,7 +47,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/SystemPrompt") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SystemPrompt") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const skill = yield* Skill.Service const skill = yield* Skill.Service
@ -128,12 +128,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(Skill.defaultLayer),
Layer.provide(MCP.defaultLayer),
Layer.provide(locationServiceMapLayer),
)
const locationServiceMapNode = LayerNode.make({ const locationServiceMapNode = LayerNode.make({
service: LocationServiceMap.Service, service: LocationServiceMap.Service,
layer: locationServiceMapLayer, layer: locationServiceMapLayer,

View file

@ -20,7 +20,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/SessionTodo") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SessionTodo") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const events = yield* EventV2Bridge.Service const events = yield* EventV2Bridge.Service
@ -69,8 +69,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(Layer.provide(EventV2Bridge.defaultLayer), Layer.provide(Database.defaultLayer))
export const node = LayerNode.make({ service: Service, layer: layer, deps: [EventV2Bridge.node, Database.node] }) export const node = LayerNode.make({ service: Service, layer: layer, deps: [EventV2Bridge.node, Database.node] })
export * as Todo from "./todo" export * as Todo from "./todo"

View file

@ -14,7 +14,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/SessionShare") {} export class Service extends Context.Service<Service, Interface>()("@opencode/SessionShare") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const cfg = yield* Config.Service const cfg = yield* Config.Service
@ -49,13 +49,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(ShareNext.defaultLayer),
Layer.provide(Session.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(RuntimeFlags.defaultLayer),
)
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: layer,

View file

@ -109,7 +109,7 @@ function key(item: Data) {
} }
} }
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const account = yield* Account.Service const account = yield* Account.Service
@ -362,16 +362,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(Account.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(Database.defaultLayer),
Layer.provide(FetchHttpClient.layer),
Layer.provide(Provider.defaultLayer),
Layer.provide(Session.defaultLayer),
)
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: layer,

View file

@ -247,7 +247,7 @@ const loadSkills = Effect.fnUntraced(function* (
export class Service extends Context.Service<Service, Interface>()("@opencode/Skill") {} export class Service extends Context.Service<Service, Interface>()("@opencode/Skill") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const discovery = yield* Discovery.Service const discovery = yield* Discovery.Service
@ -318,15 +318,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = layer.pipe(
Layer.provide(Discovery.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(FSUtil.defaultLayer),
Layer.provide(Global.layer),
Layer.provide(RuntimeFlags.defaultLayer),
)
export function fmt(list: Info[], opts: { verbose: boolean }) { export function fmt(list: Info[], opts: { verbose: boolean }) {
const described = list.filter((skill) => skill.description !== undefined) const described = list.filter((skill) => skill.description !== undefined)
if (described.length === 0) return "No skills are currently available." if (described.length === 0) return "No skills are currently available."

View file

@ -33,7 +33,6 @@ import { Glob } from "@opencode-ai/core/util/glob"
import path from "path" import path from "path"
import { pathToFileURL } from "url" import { pathToFileURL } from "url"
import { Effect, Layer, Context } from "effect" import { Effect, Layer, Context } from "effect"
import { FetchHttpClient, HttpClient } from "effect/unstable/http"
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner" import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner"
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner" import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
import { Format } from "../format" import { Format } from "../format"
@ -80,7 +79,7 @@ export interface Interface {
export class Service extends Context.Service<Service, Interface>()("@opencode/ToolRegistry") {} export class Service extends Context.Service<Service, Interface>()("@opencode/ToolRegistry") {}
export const layer = Layer.effect( const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const config = yield* Config.Service const config = yield* Config.Service
@ -315,30 +314,6 @@ export const layer = Layer.effect(
}), }),
) )
export const defaultLayer = Layer.suspend(() =>
layer
.pipe(
Layer.provide(Config.defaultLayer),
Layer.provide(Plugin.defaultLayer),
Layer.provide(Question.defaultLayer),
Layer.provide(Todo.defaultLayer),
Layer.provide(Skill.defaultLayer),
Layer.provide(Agent.defaultLayer),
Layer.provide(Session.defaultLayer),
Layer.provide(BackgroundJob.defaultLayer),
Layer.provide(Provider.defaultLayer),
Layer.provide(LSP.defaultLayer),
Layer.provide(Instruction.defaultLayer),
Layer.provide(FSUtil.defaultLayer),
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(FetchHttpClient.layer),
Layer.provide(Format.defaultLayer),
Layer.provide(CrossSpawnSpawner.defaultLayer),
Layer.provide(Truncate.defaultLayer),
)
.pipe(Layer.provide(Database.defaultLayer), Layer.provide(RuntimeFlags.defaultLayer)),
)
function isZodType(value: unknown): value is z.ZodType { function isZodType(value: unknown): value is z.ZodType {
return typeof value === "object" && value !== null && "_zod" in value return typeof value === "object" && value !== null && "_zod" in value
} }
@ -417,7 +392,7 @@ function isJsonSchemaObject(value: unknown): value is Record<string, unknown> {
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer.pipe(Layer.provide(Ripgrep.defaultLayer)), layer,
deps: [ deps: [
Config.node, Config.node,
Plugin.node, Plugin.node,
@ -438,6 +413,7 @@ export const node = LayerNode.make({
Truncate.node, Truncate.node,
RuntimeFlags.node, RuntimeFlags.node,
Database.node, Database.node,
Ripgrep.node,
], ],
}) })

View file

@ -1,7 +1,6 @@
import { LayerNode } from "@opencode-ai/core/effect/layer-node" import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { path } from "@opencode-ai/core/effect/app-node-platform" import { path } from "@opencode-ai/core/effect/app-node-platform"
import { Global } from "@opencode-ai/core/global" import { Global } from "@opencode-ai/core/global"
import { InstanceBootstrap } from "@/project/bootstrap"
import { InstanceStore } from "@/project/instance-store" import { InstanceStore } from "@/project/instance-store"
import { Project } from "@/project/project" import { Project } from "@/project/project"
import { Database } from "@opencode-ai/core/database/database" import { Database } from "@opencode-ai/core/database/database"
@ -14,7 +13,6 @@ import { GlobalBus } from "@/bus/global"
import { Git } from "@/git" import { Git } from "@/git"
import { Effect, Layer, Path, Schema, Scope, Context } from "effect" import { Effect, Layer, Path, Schema, Scope, Context } from "effect"
import { ChildProcess } from "effect/unstable/process" import { ChildProcess } from "effect/unstable/process"
import { NodePath } from "@effect/platform-node"
import { FSUtil } from "@opencode-ai/core/fs-util" import { FSUtil } from "@opencode-ai/core/fs-util"
import { AppProcess } from "@opencode-ai/core/process" import { AppProcess } from "@opencode-ai/core/process"
import { InstanceState } from "@/effect/instance-state" import { InstanceState } from "@/effect/instance-state"
@ -131,7 +129,7 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Wo
type GitResult = { code: number; text: string; stderr: string } type GitResult = { code: number; text: string; stderr: string }
export const layer: Layer.Layer< const layer: Layer.Layer<
Service, Service,
never, never,
| FSUtil.Service | FSUtil.Service
@ -616,19 +614,6 @@ export const layer: Layer.Layer<
}), }),
) )
export const appLayer = layer.pipe(
Layer.provide(Git.defaultLayer),
Layer.provide(AppProcess.defaultLayer),
Layer.provide(Project.defaultLayer),
Layer.provide(Database.defaultLayer),
Layer.provide(FSUtil.defaultLayer),
Layer.provide(NodePath.layer),
)
export const defaultLayer = appLayer.pipe(
Layer.provide(LayerNode.compile(InstanceStore.node, [[InstanceStore.bootstrapNode, InstanceBootstrap.node]])),
)
export const node = LayerNode.make({ export const node = LayerNode.make({
service: Service, service: Service,
layer: layer, layer: layer,