refactor(core): move database schema ownership (#29068)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import { pathToFileURL } from "url"
|
||||
import { Effect, Layer, Context, Schema } from "effect"
|
||||
import { NamedError } from "@opencode-ai/core/util/error"
|
||||
import type { Agent } from "@/agent/agent"
|
||||
import { Bus } from "@/bus"
|
||||
import { EventV2Bridge } from "@/event-v2-bridge"
|
||||
import { InstanceState } from "@/effect/instance-state"
|
||||
import { Global } from "@opencode-ai/core/global"
|
||||
import { Permission } from "@/permission"
|
||||
@@ -101,7 +101,7 @@ export interface Interface {
|
||||
readonly available: (agent?: Agent.Info) => Effect.Effect<Info[]>
|
||||
}
|
||||
|
||||
const add = Effect.fnUntraced(function* (state: State, match: string, bus: Bus.Interface) {
|
||||
const add = Effect.fnUntraced(function* (state: State, match: string, events: EventV2Bridge.Service["Service"]) {
|
||||
const md = yield* Effect.tryPromise({
|
||||
try: () => ConfigMarkdown.parse(match),
|
||||
catch: (err) => err,
|
||||
@@ -112,7 +112,7 @@ const add = Effect.fnUntraced(function* (state: State, match: string, bus: Bus.I
|
||||
? err.data.message
|
||||
: `Failed to parse skill ${match}`
|
||||
const { Session } = yield* Effect.promise(() => import("@/session/session"))
|
||||
yield* bus.publish(Session.Event.Error, { error: new NamedError.Unknown({ message }).toObject() })
|
||||
yield* events.publish(Session.Event.Error, { error: new NamedError.Unknown({ message }).toObject() })
|
||||
log.error("failed to load skill", { skill: match, err })
|
||||
return undefined
|
||||
}),
|
||||
@@ -232,8 +232,8 @@ const discoverSkills = Effect.fnUntraced(function* (
|
||||
}
|
||||
})
|
||||
|
||||
const loadSkills = Effect.fnUntraced(function* (state: State, discovered: DiscoveryState, bus: Bus.Interface) {
|
||||
yield* Effect.forEach(discovered.matches, (match) => add(state, match, bus), {
|
||||
const loadSkills = Effect.fnUntraced(function* (state: State, discovered: DiscoveryState, events: EventV2Bridge.Service["Service"]) {
|
||||
yield* Effect.forEach(discovered.matches, (match) => add(state, match, events), {
|
||||
concurrency: "unbounded",
|
||||
discard: true,
|
||||
})
|
||||
@@ -248,7 +248,7 @@ export const layer = Layer.effect(
|
||||
Effect.gen(function* () {
|
||||
const discovery = yield* Discovery.Service
|
||||
const config = yield* Config.Service
|
||||
const bus = yield* Bus.Service
|
||||
const events = yield* EventV2Bridge.Service
|
||||
const fsys = yield* AppFileSystem.Service
|
||||
const global = yield* Global.Service
|
||||
const flags = yield* RuntimeFlags.Service
|
||||
@@ -277,7 +277,7 @@ export const layer = Layer.effect(
|
||||
location: "<built-in>",
|
||||
content: CUSTOMIZE_OPENCODE_SKILL_BODY,
|
||||
}
|
||||
yield* loadSkills(s, yield* InstanceState.get(discovered), bus)
|
||||
yield* loadSkills(s, yield* InstanceState.get(discovered), events)
|
||||
return s
|
||||
}),
|
||||
)
|
||||
@@ -317,7 +317,7 @@ export const layer = Layer.effect(
|
||||
export const defaultLayer = layer.pipe(
|
||||
Layer.provide(Discovery.defaultLayer),
|
||||
Layer.provide(Config.defaultLayer),
|
||||
Layer.provide(Bus.layer),
|
||||
Layer.provide(EventV2Bridge.defaultLayer),
|
||||
Layer.provide(AppFileSystem.defaultLayer),
|
||||
Layer.provide(Global.layer),
|
||||
Layer.provide(RuntimeFlags.defaultLayer),
|
||||
|
||||
Reference in New Issue
Block a user