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. const directory = AbsolutePath.make("/repo/packages/app")
  10. const project = AbsolutePath.make("/repo")
  11. const it = testEffect(
  12. CommandV2.locationLayer.pipe(
  13. Layer.provide(
  14. Layer.succeed(Location.Service, Location.Service.of(location({ directory }, { projectDirectory: project }))),
  15. ),
  16. ),
  17. )
  18. describe("CommandPlugin.Plugin", () => {
  19. it.effect("registers built-in init and review commands", () =>
  20. Effect.gen(function* () {
  21. const command = yield* CommandV2.Service
  22. yield* CommandPlugin.Plugin.effect.pipe(
  23. Effect.provideService(CommandV2.Service, command),
  24. Effect.provideService(
  25. Location.Service,
  26. Location.Service.of(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. })