mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-11 16:38:32 +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
96 lines
3.4 KiB
TypeScript
96 lines
3.4 KiB
TypeScript
import { describe, expect } from "bun:test"
|
|
import { Effect, Exit, Layer, Scope } from "effect"
|
|
import { AbsolutePath } from "@opencode-ai/core/schema"
|
|
import { Global } from "@opencode-ai/core/global"
|
|
import { Reference } from "@opencode-ai/core/reference"
|
|
import { Repository } from "@opencode-ai/core/repository"
|
|
import { RepositoryCache } from "@opencode-ai/core/repository-cache"
|
|
import { EventV2 } from "@opencode-ai/core/event"
|
|
import { it } from "./lib/effect"
|
|
|
|
const cache = Layer.mock(RepositoryCache.Service, {
|
|
ensure: () => Effect.die("unexpected Git materialization"),
|
|
})
|
|
|
|
describe("Reference", () => {
|
|
it.effect("registers normalized sources for the owning scope", () =>
|
|
Effect.gen(function* () {
|
|
const references = yield* Reference.Service
|
|
const scope = yield* Scope.make()
|
|
const update = yield* references.transform().pipe(Effect.provideService(Scope.Scope, scope))
|
|
const path = AbsolutePath.make("/docs")
|
|
const source = new Reference.LocalSource({
|
|
type: "local",
|
|
path,
|
|
description: "Use for API documentation",
|
|
hidden: true,
|
|
})
|
|
yield* update((editor) => editor.add("docs", source))
|
|
|
|
expect(yield* references.list()).toEqual([
|
|
new Reference.Info({ name: "docs", path, description: "Use for API documentation", hidden: true, source }),
|
|
])
|
|
|
|
yield* Scope.close(scope, Exit.void)
|
|
expect(yield* references.list()).toEqual([])
|
|
}).pipe(
|
|
Effect.provide(Reference.layer),
|
|
Effect.provide(cache),
|
|
Effect.provide(EventV2.defaultLayer),
|
|
Effect.provide(Global.defaultLayer),
|
|
),
|
|
)
|
|
|
|
it.effect("derives Git paths without exposing cache operations", () =>
|
|
Effect.gen(function* () {
|
|
const references = yield* Reference.Service
|
|
const update = yield* references.transform()
|
|
const repository = Repository.parseRemote("owner/repo")
|
|
const source = new Reference.GitSource({ type: "git", repository: "owner/repo", branch: "main" })
|
|
yield* update((editor) => editor.add("sdk", source))
|
|
|
|
expect(yield* references.list()).toEqual([
|
|
new Reference.Info({
|
|
name: "sdk",
|
|
path: AbsolutePath.make(Repository.cachePath(Global.Path.repos, repository)),
|
|
source,
|
|
}),
|
|
])
|
|
}).pipe(
|
|
Effect.scoped,
|
|
Effect.provide(Reference.layer),
|
|
Effect.provide(cache),
|
|
Effect.provide(EventV2.defaultLayer),
|
|
Effect.provide(Global.defaultLayer),
|
|
),
|
|
)
|
|
|
|
it.effect("preserves configured Git descriptions", () =>
|
|
Effect.gen(function* () {
|
|
const references = yield* Reference.Service
|
|
const update = yield* references.transform()
|
|
const repository = Repository.parseRemote("owner/repo")
|
|
const source = new Reference.GitSource({
|
|
type: "git",
|
|
repository: "owner/repo",
|
|
description: "Use for SDK implementation details",
|
|
})
|
|
yield* update((editor) => editor.add("sdk", source))
|
|
|
|
expect(yield* references.list()).toEqual([
|
|
new Reference.Info({
|
|
name: "sdk",
|
|
path: AbsolutePath.make(Repository.cachePath(Global.Path.repos, repository)),
|
|
description: "Use for SDK implementation details",
|
|
source,
|
|
}),
|
|
])
|
|
}).pipe(
|
|
Effect.scoped,
|
|
Effect.provide(Reference.layer),
|
|
Effect.provide(cache),
|
|
Effect.provide(EventV2.defaultLayer),
|
|
Effect.provide(Global.defaultLayer),
|
|
),
|
|
)
|
|
})
|