51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { Effect } from "effect"
|
|
import { afterEach, describe, expect, test } from "bun:test"
|
|
import { Agent } from "../../src/agent/agent"
|
|
import { Instance } from "../../src/project/instance"
|
|
import { TaskDescription } from "../../src/tool/task"
|
|
import { tmpdir } from "../fixture/fixture"
|
|
|
|
afterEach(async () => {
|
|
await Instance.disposeAll()
|
|
})
|
|
|
|
describe("tool.task", () => {
|
|
test("description sorts subagents by name and is stable across calls", async () => {
|
|
await using tmp = await tmpdir({
|
|
config: {
|
|
agent: {
|
|
zebra: {
|
|
description: "Zebra agent",
|
|
mode: "subagent",
|
|
},
|
|
alpha: {
|
|
description: "Alpha agent",
|
|
mode: "subagent",
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
await Instance.provide({
|
|
directory: tmp.path,
|
|
fn: async () => {
|
|
const agent = { name: "build", mode: "primary" as const, permission: [], options: {} }
|
|
const first = await Effect.runPromise(TaskDescription(agent))
|
|
const second = await Effect.runPromise(TaskDescription(agent))
|
|
|
|
expect(first).toBe(second)
|
|
|
|
const alpha = first.indexOf("- alpha: Alpha agent")
|
|
const explore = first.indexOf("- explore:")
|
|
const general = first.indexOf("- general:")
|
|
const zebra = first.indexOf("- zebra: Zebra agent")
|
|
|
|
expect(alpha).toBeGreaterThan(-1)
|
|
expect(explore).toBeGreaterThan(alpha)
|
|
expect(general).toBeGreaterThan(explore)
|
|
expect(zebra).toBeGreaterThan(general)
|
|
},
|
|
})
|
|
})
|
|
})
|