plugin-agent-regression.test.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { expect } from "bun:test"
  2. import { Npm } from "@kirincode-ai/core/npm"
  3. import { Effect } from "effect"
  4. import path from "path"
  5. import { pathToFileURL } from "url"
  6. import { Agent } from "../../src/agent/agent"
  7. import { Account } from "../../src/account/account"
  8. import { Auth } from "../../src/auth"
  9. import { RuntimeFlags } from "../../src/effect/runtime-flags"
  10. import { Plugin } from "../../src/plugin"
  11. import { Provider } from "../../src/provider/provider"
  12. import { Skill } from "../../src/skill"
  13. import { AccountTest } from "../fake/account"
  14. import { AuthTest } from "../fake/auth"
  15. import { NpmTest } from "../fake/npm"
  16. import { ProviderTest } from "../fake/provider"
  17. import { SkillTest } from "../fake/skill"
  18. import { testEffect } from "../lib/effect"
  19. import { PLUGIN_AGENT } from "../fixture/agent-plugin.constants"
  20. import { AppNodeBuilder } from "@kirincode-ai/core/effect/app-node-builder"
  21. import { LayerNode } from "@kirincode-ai/core/effect/layer-node"
  22. // `it.instance` skips InstanceBootstrap so LSP / MCP don't spin up — those
  23. // services hang during scope teardown on Windows and aren't needed
  24. // to verify plugin → config hook → Agent.list.
  25. const pluginUrl = pathToFileURL(path.join(import.meta.dir, "..", "fixture", "agent-plugin.ts")).href
  26. const provider = ProviderTest.fake()
  27. const it = testEffect(
  28. AppNodeBuilder.build(LayerNode.group([Agent.node, Plugin.node]), [
  29. [Auth.node, AuthTest.empty],
  30. [Account.node, AccountTest.empty],
  31. [Npm.node, NpmTest.noop],
  32. [Provider.node, provider.layer],
  33. [Skill.node, SkillTest.empty],
  34. [RuntimeFlags.node, RuntimeFlags.layer({ disableDefaultPlugins: true })],
  35. ]),
  36. )
  37. it.instance(
  38. "plugin-registered agents appear in Agent.list",
  39. () =>
  40. Effect.gen(function* () {
  41. yield* Plugin.Service.use((p) => p.init())
  42. const agents = yield* Agent.use.list()
  43. const added = agents.find((agent) => agent.name === PLUGIN_AGENT.name)
  44. expect(added?.description).toBe(PLUGIN_AGENT.description)
  45. expect(added?.mode).toBe(PLUGIN_AGENT.mode)
  46. }),
  47. { config: { plugin: [pluginUrl] } },
  48. )