Compare commits

..

1 Commits

Author SHA1 Message Date
James Long 537ce02685 test(core): simplify command layer wiring 2026-06-20 21:46:35 -04:00
7 changed files with 27 additions and 25 deletions
-2
View File
@@ -7,7 +7,6 @@ import { PermissionSchema } from "./permission/schema"
import { ProviderV2 } from "./provider"
import { PositiveInt } from "./schema"
import { State } from "./state"
import { LayerNode } from "./effect/layer-node"
export const ID = Schema.String.pipe(Schema.brand("AgentV2.ID"))
export type ID = typeof ID.Type
@@ -141,4 +140,3 @@ export const layer = Layer.effect(
)
export const locationLayer = layer
export const node = LayerNode.make(layer, [])
+2
View File
@@ -2,6 +2,7 @@ export * as CommandV2 from "./command"
import { Context, Effect, Layer, Schema } from "effect"
import { castDraft, type Draft } from "immer"
import { LayerNode } from "./effect/layer-node"
import { ModelV2 } from "./model"
import { State } from "./state"
@@ -68,3 +69,4 @@ export const layer = Layer.effect(
)
export const locationLayer = layer
export const node = LayerNode.make(layer, [])
-3
View File
@@ -11,7 +11,6 @@ import { Identifier } from "./util/identifier"
import { Wildcard } from "./util/wildcard"
import { PermissionSchema } from "./permission/schema"
import { PermissionSaved } from "./permission/saved"
import { LayerNode } from "./effect/layer-node"
export { Effect, Rule, Ruleset } from "./permission/schema"
type Effect = PermissionSchema.Effect
@@ -328,5 +327,3 @@ export const layer = Layer.effect(
)
export const locationLayer = layer.pipe(Layer.provideMerge(AgentV2.locationLayer))
export const node = (location: LayerNode.Node<Location.Service>) =>
LayerNode.make(layer, [EventV2.node, location, AgentV2.node, SessionStore.node, PermissionSaved.node])
-2
View File
@@ -7,7 +7,6 @@ import { ProjectV2 } from "../project"
import { withStatics } from "../schema"
import { Identifier } from "../util/identifier"
import { PermissionTable } from "./sql"
import { LayerNode } from "../effect/layer-node"
export const ID = Schema.String.pipe(
Schema.brand("PermissionSaved.ID"),
@@ -86,4 +85,3 @@ export const layer = Layer.effect(
)
export const defaultLayer = layer.pipe(Layer.provide(Database.defaultLayer))
export const node = LayerNode.make(layer, [Database.node])
-2
View File
@@ -9,7 +9,6 @@ import { SessionMessage } from "./message"
import { SessionSchema } from "./schema"
import { SessionMessageTable, SessionTable } from "./sql"
import { fromRow } from "./info"
import { LayerNode } from "../effect/layer-node"
export interface Interface {
readonly get: (sessionID: SessionSchema.ID) => Effect.Effect<SessionSchema.Info | undefined>
@@ -61,4 +60,3 @@ export const layer = Layer.effect(
)
export const defaultLayer = layer.pipe(Layer.provide(Database.defaultLayer))
export const node = LayerNode.make(layer, [Database.node])
+3 -2
View File
@@ -1,10 +1,11 @@
import fs from "fs/promises"
import path from "path"
import { describe, expect } from "bun:test"
import { Effect, Layer, Schema } from "effect"
import { Effect, Schema } from "effect"
import { CommandV2 } from "@opencode-ai/core/command"
import { Config } from "@opencode-ai/core/config"
import { ConfigCommandPlugin } from "@opencode-ai/core/config/plugin/command"
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { FSUtil } from "@opencode-ai/core/fs-util"
import { ModelV2 } from "@opencode-ai/core/model"
import { ProviderV2 } from "@opencode-ai/core/provider"
@@ -12,7 +13,7 @@ import { AbsolutePath } from "@opencode-ai/core/schema"
import { tmpdir } from "../fixture/tmpdir"
import { testEffect } from "../lib/effect"
const it = testEffect(Layer.mergeAll(CommandV2.locationLayer, FSUtil.defaultLayer))
const it = testEffect(LayerNode.buildLayer(LayerNode.group([CommandV2.node, FSUtil.node])))
const decode = Schema.decodeUnknownSync(Config.Info)
describe("ConfigCommandPlugin.Plugin", () => {
+22 -14
View File
@@ -2,7 +2,6 @@ import { describe, expect } from "bun:test"
import { Deferred, Effect, Fiber, Layer } from "effect"
import { AgentV2 } from "@opencode-ai/core/agent"
import { Database } from "@opencode-ai/core/database/database"
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { EventV2 } from "@opencode-ai/core/event"
import { Location } from "@opencode-ai/core/location"
import { PermissionV2 } from "@opencode-ai/core/permission"
@@ -13,26 +12,35 @@ import { ProjectTable } from "@opencode-ai/core/project/sql"
import { AbsolutePath } from "@opencode-ai/core/schema"
import { SessionV2 } from "@opencode-ai/core/session"
import { SessionTable } from "@opencode-ai/core/session/sql"
import { SessionExecution } from "@opencode-ai/core/session/execution"
import { SessionStore } from "@opencode-ai/core/session/store"
import { eq } from "drizzle-orm"
import { location } from "./fixture/location"
import { testEffect } from "./lib/effect"
const database = Database.layerFromPath(":memory:")
const current = LayerNode.make(
Layer.succeed(Location.Service, Location.Service.of(location({ directory: AbsolutePath.make("/project") }))),
[],
const current = Layer.succeed(
Location.Service,
Location.Service.of(location({ directory: AbsolutePath.make("/project") })),
)
const layer = LayerNode.buildLayer(
LayerNode.group([
PermissionV2.node(current),
Database.node,
EventV2.node,
AgentV2.node,
SessionStore.node,
PermissionSaved.node,
]),
{ replacements: [LayerNode.replace(Database.node, database)] },
const events = EventV2.layer.pipe(Layer.provide(database))
const store = SessionStore.layer.pipe(Layer.provide(database))
const sessions = SessionV2.layer.pipe(
Layer.provide(events),
Layer.provide(database),
Layer.provide(store),
Layer.provide(Project.defaultLayer),
Layer.provide(SessionExecution.noopLayer),
)
const saved = PermissionSaved.layer.pipe(Layer.provide(database))
const layer = PermissionV2.locationLayer.pipe(
Layer.provideMerge(database),
Layer.provideMerge(store),
Layer.provideMerge(events),
Layer.provideMerge(current),
Layer.provideMerge(sessions),
Layer.provideMerge(SessionExecution.noopLayer),
Layer.provideMerge(saved),
)
const it = testEffect(layer)