command.test.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { describe, expect } from "bun:test"
  2. import { Effect, Layer } from "effect"
  3. import { CommandV2 } from "@opencode-ai/core/command"
  4. import { Location } from "@opencode-ai/core/location"
  5. import { CommandPlugin } from "@opencode-ai/core/plugin/command"
  6. import { AbsolutePath } from "@opencode-ai/core/schema"
  7. import { location } from "../fixture/location"
  8. import { testEffect } from "../lib/effect"
  9. import { host } from "./host"
  10. const directory = AbsolutePath.make("/repo/packages/app")
  11. const project = AbsolutePath.make("/repo")
  12. const it = testEffect(
  13. CommandV2.locationLayer.pipe(
  14. Layer.provide(
  15. Layer.succeed(Location.Service, Location.Service.of(location({ directory }, { projectDirectory: project }))),
  16. ),
  17. ),
  18. )
  19. describe("CommandPlugin.Plugin", () => {
  20. it.effect("registers built-in init and review commands", () =>
  21. Effect.gen(function* () {
  22. const command = yield* CommandV2.Service
  23. yield* CommandPlugin.Plugin.effect(
  24. host({
  25. command,
  26. location: location({ directory }, { projectDirectory: project }),
  27. }),
  28. )
  29. expect(yield* command.get("init")).toMatchObject({
  30. name: "init",
  31. description: "guided AGENTS.md setup",
  32. })
  33. expect((yield* command.get("init"))?.template).toContain("`/repo`")
  34. expect(yield* command.get("review")).toMatchObject({
  35. name: "review",
  36. description: "review changes [commit|branch|pr], defaults to uncommitted",
  37. subtask: true,
  38. })
  39. }),
  40. )
  41. })