core: refactor tool system to remove agent context from initialization (#21052)
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { Effect } from "effect"
|
||||
import { afterEach, describe, expect, test } from "bun:test"
|
||||
import path from "path"
|
||||
import { pathToFileURL } from "url"
|
||||
import type { Permission } from "../../src/permission"
|
||||
import type { Tool } from "../../src/tool/tool"
|
||||
import { Instance } from "../../src/project/instance"
|
||||
import { SkillTool } from "../../src/tool/skill"
|
||||
import { SkillTool, SkillDescription } from "../../src/tool/skill"
|
||||
import { tmpdir } from "../fixture/fixture"
|
||||
import { SessionID, MessageID } from "../../src/session/schema"
|
||||
|
||||
@@ -48,9 +49,10 @@ description: Skill for tool tests.
|
||||
await Instance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const tool = await SkillTool.init()
|
||||
const skillPath = path.join(tmp.path, ".opencode", "skill", "tool-skill", "SKILL.md")
|
||||
expect(tool.description).toContain(`**tool-skill**: Skill for tool tests.`)
|
||||
const desc = await Effect.runPromise(
|
||||
SkillDescription({ name: "build", mode: "primary" as const, permission: [], options: {} }),
|
||||
)
|
||||
expect(desc).toContain(`**tool-skill**: Skill for tool tests.`)
|
||||
},
|
||||
})
|
||||
} finally {
|
||||
@@ -89,14 +91,15 @@ description: ${description}
|
||||
await Instance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const first = await SkillTool.init()
|
||||
const second = await SkillTool.init()
|
||||
const agent = { name: "build", mode: "primary" as const, permission: [], options: {} }
|
||||
const first = await Effect.runPromise(SkillDescription(agent))
|
||||
const second = await Effect.runPromise(SkillDescription(agent))
|
||||
|
||||
expect(first.description).toBe(second.description)
|
||||
expect(first).toBe(second)
|
||||
|
||||
const alpha = first.description.indexOf("**alpha-skill**: Alpha skill.")
|
||||
const middle = first.description.indexOf("**middle-skill**: Middle skill.")
|
||||
const zeta = first.description.indexOf("**zeta-skill**: Zeta skill.")
|
||||
const alpha = first.indexOf("**alpha-skill**: Alpha skill.")
|
||||
const middle = first.indexOf("**middle-skill**: Middle skill.")
|
||||
const zeta = first.indexOf("**zeta-skill**: Zeta skill.")
|
||||
|
||||
expect(alpha).toBeGreaterThan(-1)
|
||||
expect(middle).toBeGreaterThan(alpha)
|
||||
|
||||
Reference in New Issue
Block a user