test(opencode): migrate skill fixtures to app filesystem (#29040)
This commit is contained in:
parent
ed95ba73f4
commit
e2fd4413c8
1 changed files with 11 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
||||||
|
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
||||||
import { Cause, Effect, Exit, Layer } from "effect"
|
import { Cause, Effect, Exit, Layer } from "effect"
|
||||||
import { afterEach, describe, expect } from "bun:test"
|
import { afterEach, describe, expect } from "bun:test"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
|
@ -7,6 +8,7 @@ import type { Permission } from "../../src/permission"
|
||||||
import type { Tool } from "@/tool/tool"
|
import type { Tool } from "@/tool/tool"
|
||||||
import { SkillTool } from "../../src/tool/skill"
|
import { SkillTool } from "../../src/tool/skill"
|
||||||
import { ToolRegistry } from "@/tool/registry"
|
import { ToolRegistry } from "@/tool/registry"
|
||||||
|
import { ModelID, ProviderID } from "../../src/provider/schema"
|
||||||
import { disposeAllInstances, provideTmpdirInstance } from "../fixture/fixture"
|
import { disposeAllInstances, provideTmpdirInstance } from "../fixture/fixture"
|
||||||
import { SessionID, MessageID } from "../../src/session/schema"
|
import { SessionID, MessageID } from "../../src/session/schema"
|
||||||
import { testEffect } from "../lib/effect"
|
import { testEffect } from "../lib/effect"
|
||||||
|
|
@ -27,17 +29,16 @@ afterEach(async () => {
|
||||||
|
|
||||||
const node = CrossSpawnSpawner.defaultLayer
|
const node = CrossSpawnSpawner.defaultLayer
|
||||||
|
|
||||||
const it = testEffect(Layer.mergeAll(ToolRegistry.defaultLayer, node))
|
const it = testEffect(Layer.mergeAll(ToolRegistry.defaultLayer, node, AppFileSystem.defaultLayer))
|
||||||
|
|
||||||
describe("tool.skill", () => {
|
describe("tool.skill", () => {
|
||||||
it.live("execute returns skill content block with files", () =>
|
it.live("execute returns skill content block with files", () =>
|
||||||
provideTmpdirInstance((dir) =>
|
provideTmpdirInstance((dir) =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const skill = path.join(dir, ".opencode", "skill", "tool-skill")
|
const skill = path.join(dir, ".opencode", "skill", "tool-skill")
|
||||||
yield* Effect.promise(() =>
|
yield* AppFileSystem.use.writeWithDirs(
|
||||||
Bun.write(
|
path.join(skill, "SKILL.md"),
|
||||||
path.join(skill, "SKILL.md"),
|
`---
|
||||||
`---
|
|
||||||
name: tool-skill
|
name: tool-skill
|
||||||
description: Skill for tool tests.
|
description: Skill for tool tests.
|
||||||
---
|
---
|
||||||
|
|
@ -46,9 +47,8 @@ description: Skill for tool tests.
|
||||||
|
|
||||||
Use this skill.
|
Use this skill.
|
||||||
`,
|
`,
|
||||||
),
|
|
||||||
)
|
)
|
||||||
yield* Effect.promise(() => Bun.write(path.join(skill, "scripts", "demo.txt"), "demo"))
|
yield* AppFileSystem.use.writeWithDirs(path.join(skill, "scripts", "demo.txt"), "demo")
|
||||||
|
|
||||||
const home = process.env.OPENCODE_TEST_HOME
|
const home = process.env.OPENCODE_TEST_HOME
|
||||||
process.env.OPENCODE_TEST_HOME = dir
|
process.env.OPENCODE_TEST_HOME = dir
|
||||||
|
|
@ -61,8 +61,8 @@ Use this skill.
|
||||||
const registry = yield* ToolRegistry.Service
|
const registry = yield* ToolRegistry.Service
|
||||||
const agent = { name: "build", mode: "primary" as const, permission: [], options: {} }
|
const agent = { name: "build", mode: "primary" as const, permission: [], options: {} }
|
||||||
const tool = (yield* registry.tools({
|
const tool = (yield* registry.tools({
|
||||||
providerID: "opencode" as any,
|
providerID: ProviderID.opencode,
|
||||||
modelID: "gpt-5" as any,
|
modelID: ModelID.make("gpt-5"),
|
||||||
agent,
|
agent,
|
||||||
})).find((tool) => tool.id === SkillTool.id)
|
})).find((tool) => tool.id === SkillTool.id)
|
||||||
if (!tool) throw new Error("Skill tool not found")
|
if (!tool) throw new Error("Skill tool not found")
|
||||||
|
|
@ -105,8 +105,8 @@ Use this skill.
|
||||||
const registry = yield* ToolRegistry.Service
|
const registry = yield* ToolRegistry.Service
|
||||||
const agent = { name: "build", mode: "primary" as const, permission: [], options: {} }
|
const agent = { name: "build", mode: "primary" as const, permission: [], options: {} }
|
||||||
const tool = (yield* registry.tools({
|
const tool = (yield* registry.tools({
|
||||||
providerID: "opencode" as any,
|
providerID: ProviderID.opencode,
|
||||||
modelID: "gpt-5" as any,
|
modelID: ModelID.make("gpt-5"),
|
||||||
agent,
|
agent,
|
||||||
})).find((tool) => tool.id === SkillTool.id)
|
})).find((tool) => tool.id === SkillTool.id)
|
||||||
if (!tool) throw new Error("Skill tool not found")
|
if (!tool) throw new Error("Skill tool not found")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue