task.test.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { describe, expect, test } from "bun:test"
  2. import { Agent } from "../../src/agent/agent"
  3. import { Instance } from "../../src/project/instance"
  4. import { TaskTool } from "../../src/tool/task"
  5. import { tmpdir } from "../fixture/fixture"
  6. describe("tool.task", () => {
  7. test("description sorts subagents by name and is stable across calls", async () => {
  8. await using tmp = await tmpdir({
  9. config: {
  10. agent: {
  11. zebra: {
  12. description: "Zebra agent",
  13. mode: "subagent",
  14. },
  15. alpha: {
  16. description: "Alpha agent",
  17. mode: "subagent",
  18. },
  19. },
  20. },
  21. })
  22. await Instance.provide({
  23. directory: tmp.path,
  24. fn: async () => {
  25. const build = await Agent.get("build")
  26. const first = await TaskTool.init({ agent: build })
  27. const second = await TaskTool.init({ agent: build })
  28. expect(first.description).toBe(second.description)
  29. const alpha = first.description.indexOf("- alpha: Alpha agent")
  30. const explore = first.description.indexOf("- explore:")
  31. const general = first.description.indexOf("- general:")
  32. const zebra = first.description.indexOf("- zebra: Zebra agent")
  33. expect(alpha).toBeGreaterThan(-1)
  34. expect(explore).toBeGreaterThan(alpha)
  35. expect(general).toBeGreaterThan(explore)
  36. expect(zebra).toBeGreaterThan(general)
  37. },
  38. })
  39. })
  40. })