mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-12 13:58:27 +00:00
Some checks failed
deploy / deploy (push) Waiting to run
docs-locale-sync / sync-locales (push) Waiting to run
generate / generate (push) Waiting to run
nix-eval / nix-eval (push) Waiting to run
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Waiting to run
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Waiting to run
nix-hashes / compute-hash (macos-15-intel, x86_64-darwin) (push) Waiting to run
nix-hashes / compute-hash (macos-latest, aarch64-darwin) (push) Waiting to run
nix-hashes / update-hashes (push) Blocked by required conditions
publish / version (push) Waiting to run
publish / build-cli (push) Blocked by required conditions
publish / sign-cli-windows (push) Blocked by required conditions
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Blocked by required conditions
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Blocked by required conditions
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Blocked by required conditions
publish / publish (push) Blocked by required conditions
storybook / storybook build (push) Waiting to run
test / unit (linux) (push) Waiting to run
test / unit (windows) (push) Waiting to run
test / e2e (linux) (push) Waiting to run
test / e2e (windows) (push) Waiting to run
typecheck / typecheck (push) Waiting to run
containers / build (push) Has been cancelled
77 lines
3 KiB
TypeScript
77 lines
3 KiB
TypeScript
import { describe, expect } from "bun:test"
|
|
import { Effect, Layer } from "effect"
|
|
import { AbsolutePath } from "@opencode-ai/core/schema"
|
|
import { PluginBoot } from "@opencode-ai/core/plugin/boot"
|
|
import { Reference } from "@opencode-ai/core/reference"
|
|
import { ReferenceGuidance } from "@opencode-ai/core/reference/guidance"
|
|
import { SystemContext } from "@opencode-ai/core/system-context/index"
|
|
import { it } from "./lib/effect"
|
|
|
|
describe("ReferenceGuidance", () => {
|
|
it.effect("lists available references in the system context", () =>
|
|
Effect.gen(function* () {
|
|
const guidance = yield* ReferenceGuidance.Service
|
|
const generation = yield* SystemContext.initialize(yield* guidance.load())
|
|
|
|
expect(generation.baseline).toContain("<available_references>")
|
|
expect(generation.baseline).toContain("<name>docs</name>")
|
|
expect(generation.baseline).toContain("<path>/docs</path>")
|
|
expect(generation.baseline).toContain("<description>Use for product documentation</description>")
|
|
}).pipe(
|
|
Effect.provide(ReferenceGuidance.layer),
|
|
Effect.provide(
|
|
Layer.mock(Reference.Service, {
|
|
list: () =>
|
|
Effect.succeed([
|
|
new Reference.Info({
|
|
name: "docs",
|
|
path: AbsolutePath.make("/docs"),
|
|
description: "Use for product documentation",
|
|
source: new Reference.LocalSource({
|
|
type: "local",
|
|
path: AbsolutePath.make("/docs"),
|
|
description: "Use for product documentation",
|
|
}),
|
|
}),
|
|
]),
|
|
}),
|
|
),
|
|
Effect.provide(Layer.mock(PluginBoot.Service, { wait: () => Effect.void })),
|
|
),
|
|
)
|
|
|
|
it.effect("omits guidance when no references are available", () =>
|
|
Effect.gen(function* () {
|
|
const guidance = yield* ReferenceGuidance.Service
|
|
const generation = yield* SystemContext.initialize(yield* guidance.load())
|
|
expect(generation.baseline).toBe("")
|
|
}).pipe(
|
|
Effect.provide(ReferenceGuidance.layer),
|
|
Effect.provide(Layer.mock(Reference.Service, { list: () => Effect.succeed([]) })),
|
|
Effect.provide(Layer.mock(PluginBoot.Service, { wait: () => Effect.void })),
|
|
),
|
|
)
|
|
|
|
it.effect("omits references without descriptions", () =>
|
|
Effect.gen(function* () {
|
|
const guidance = yield* ReferenceGuidance.Service
|
|
const generation = yield* SystemContext.initialize(yield* guidance.load())
|
|
expect(generation.baseline).toBe("")
|
|
}).pipe(
|
|
Effect.provide(ReferenceGuidance.layer),
|
|
Effect.provide(
|
|
Layer.mock(Reference.Service, {
|
|
list: () =>
|
|
Effect.succeed([
|
|
new Reference.Info({
|
|
name: "docs",
|
|
path: AbsolutePath.make("/docs"),
|
|
source: new Reference.LocalSource({ type: "local", path: AbsolutePath.make("/docs") }),
|
|
}),
|
|
]),
|
|
}),
|
|
),
|
|
Effect.provide(Layer.mock(PluginBoot.Service, { wait: () => Effect.void })),
|
|
),
|
|
)
|
|
})
|