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:
Dax
2026-05-30 21:08:38 -04:00
committed by GitHub
parent 6bcb9cb9bb
commit 7f571d36ea
390 changed files with 11127 additions and 9164 deletions

View File

@@ -6,17 +6,18 @@ import { AppFileSystem } from "@opencode-ai/core/filesystem"
import { EffectFlock } from "@opencode-ai/core/util/effect-flock"
import path from "path"
import { pathToFileURL } from "url"
import { Bus } from "../../src/bus"
import { EventV2Bridge } from "../../src/event-v2-bridge"
import { Config } from "../../src/config/config"
import { Env } from "../../src/env"
import { RuntimeFlags } from "../../src/effect/runtime-flags"
import { Plugin } from "../../src/plugin/index"
import { ModelID, ProviderID } from "../../src/provider/schema"
import { provideTmpdirInstance } from "../fixture/fixture"
import { TestInstance } from "../fixture/fixture"
import { testEffect } from "../lib/effect"
import { AccountTest } from "../fake/account"
import { AuthTest } from "../fake/auth"
import { NpmTest } from "../fake/npm"
import { ProviderV2 } from "@opencode-ai/core/provider"
const configLayer = Config.layer.pipe(
Layer.provide(EffectFlock.defaultLayer),
@@ -30,7 +31,7 @@ const configLayer = Config.layer.pipe(
const it = testEffect(
Layer.mergeAll(
Plugin.layer.pipe(
Layer.provide(Bus.layer),
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(configLayer),
Layer.provide(RuntimeFlags.layer({ disableDefaultPlugins: true })),
),
@@ -40,31 +41,30 @@ const it = testEffect(
const systemHook = "experimental.chat.system.transform"
function withProject<A, E, R>(source: string, self: Effect.Effect<A, E, R>) {
return provideTmpdirInstance((dir) =>
Effect.gen(function* () {
const file = path.join(dir, "plugin.ts")
yield* Effect.all(
[
Effect.promise(() => Bun.write(file, source)),
Effect.promise(() =>
Bun.write(
path.join(dir, "opencode.json"),
JSON.stringify(
{
$schema: "https://opencode.ai/config.json",
plugin: [pathToFileURL(file).href],
},
null,
2,
),
return Effect.gen(function* () {
const test = yield* TestInstance
const file = path.join(test.directory, "plugin.ts")
yield* Effect.all(
[
Effect.promise(() => Bun.write(file, source)),
Effect.promise(() =>
Bun.write(
path.join(test.directory, "opencode.json"),
JSON.stringify(
{
$schema: "https://opencode.ai/config.json",
plugin: [pathToFileURL(file).href],
},
null,
2,
),
),
],
{ discard: true, concurrency: 2 },
)
return yield* self
}),
)
),
],
{ discard: true, concurrency: 2 },
)
return yield* self
})
}
const triggerSystemTransform = Effect.fn("PluginTriggerTest.triggerSystemTransform")(function* () {
@@ -74,8 +74,8 @@ const triggerSystemTransform = Effect.fn("PluginTriggerTest.triggerSystemTransfo
systemHook,
{
model: {
providerID: ProviderID.anthropic,
modelID: ModelID.make("claude-sonnet-4-6"),
providerID: ProviderV2.ID.anthropic,
modelID: ProviderV2.ModelID.make("claude-sonnet-4-6"),
},
},
out,
@@ -84,7 +84,7 @@ const triggerSystemTransform = Effect.fn("PluginTriggerTest.triggerSystemTransfo
})
describe("plugin.trigger", () => {
it.live("runs synchronous hooks without crashing", () =>
it.instance("runs synchronous hooks without crashing", () =>
withProject(
[
"export default async () => ({",
@@ -100,7 +100,7 @@ describe("plugin.trigger", () => {
),
)
it.live("awaits asynchronous hooks", () =>
it.instance("awaits asynchronous hooks", () =>
withProject(
[
"export default async () => ({",