|
1 | 1 | import { test, expect } from "bun:test" |
2 | 2 | import { Effect, Layer } from "effect" |
3 | 3 | import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner" |
4 | | -import path from "path" |
5 | | -import { provideInstance, tmpdirScoped } from "../fixture/fixture" |
6 | 4 | import { Config } from "@/config/config" |
7 | 5 | import { Agent as AgentSvc } from "../../src/agent/agent" |
8 | 6 | import { Color } from "@/util/color" |
9 | | -import { AppRuntime } from "../../src/effect/app-runtime" |
10 | 7 | import { testEffect } from "../lib/effect" |
11 | 8 |
|
12 | | -const it = testEffect(Layer.mergeAll(AgentSvc.defaultLayer, CrossSpawnSpawner.defaultLayer)) |
| 9 | +const it = testEffect(Layer.mergeAll(Config.defaultLayer, AgentSvc.defaultLayer, CrossSpawnSpawner.defaultLayer)) |
13 | 10 |
|
14 | | -const writeConfig = (dir: string, agent: Config.Info["agent"]) => |
15 | | - Effect.promise(() => |
16 | | - Bun.write( |
17 | | - path.join(dir, "opencode.json"), |
18 | | - JSON.stringify({ |
19 | | - $schema: "https://opencode.ai/config.json", |
20 | | - agent, |
21 | | - }), |
22 | | - ), |
23 | | - ) |
24 | | - |
25 | | -it.live("agent color parsed from project config", () => |
26 | | - Effect.gen(function* () { |
27 | | - const dir = yield* tmpdirScoped() |
28 | | - yield* writeConfig(dir, { |
29 | | - build: { color: "#FFA500" }, |
30 | | - plan: { color: "primary" }, |
31 | | - }) |
32 | | - |
33 | | - yield* Effect.gen(function* () { |
34 | | - const cfg = yield* Effect.promise(() => AppRuntime.runPromise(Config.Service.use((svc) => svc.get()))) |
| 11 | +it.instance( |
| 12 | + "agent color parsed from project config", |
| 13 | + () => |
| 14 | + Effect.gen(function* () { |
| 15 | + const cfg = yield* Config.Service.use((svc) => svc.get()) |
35 | 16 | expect(cfg.agent?.["build"]?.color).toBe("#FFA500") |
36 | 17 | expect(cfg.agent?.["plan"]?.color).toBe("primary") |
37 | | - }).pipe(provideInstance(dir)) |
38 | | - }), |
| 18 | + }), |
| 19 | + { |
| 20 | + git: true, |
| 21 | + config: { |
| 22 | + agent: { |
| 23 | + build: { color: "#FFA500" }, |
| 24 | + plan: { color: "primary" }, |
| 25 | + }, |
| 26 | + }, |
| 27 | + }, |
39 | 28 | ) |
40 | 29 |
|
41 | | -it.live("Agent.get includes color from config", () => |
42 | | - Effect.gen(function* () { |
43 | | - const dir = yield* tmpdirScoped() |
44 | | - yield* writeConfig(dir, { |
45 | | - plan: { color: "#A855F7" }, |
46 | | - build: { color: "accent" }, |
47 | | - }) |
48 | | - |
49 | | - yield* Effect.gen(function* () { |
| 30 | +it.instance( |
| 31 | + "Agent.get includes color from config", |
| 32 | + () => |
| 33 | + Effect.gen(function* () { |
50 | 34 | const plan = yield* AgentSvc.Service.use((svc) => svc.get("plan")) |
51 | 35 | expect(plan?.color).toBe("#A855F7") |
52 | 36 | const build = yield* AgentSvc.Service.use((svc) => svc.get("build")) |
53 | 37 | expect(build?.color).toBe("accent") |
54 | | - }).pipe(provideInstance(dir)) |
55 | | - }), |
| 38 | + }), |
| 39 | + { |
| 40 | + git: true, |
| 41 | + config: { |
| 42 | + agent: { |
| 43 | + plan: { color: "#A855F7" }, |
| 44 | + build: { color: "accent" }, |
| 45 | + }, |
| 46 | + }, |
| 47 | + }, |
56 | 48 | ) |
57 | 49 |
|
58 | 50 | test("Color.hexToAnsiBold converts valid hex to ANSI", () => { |
|
0 commit comments