test-run-ability.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bun
  2. import { createAbilitiesPlugin } from './src/plugin.js'
  3. async function main() {
  4. console.log('🧪 Running test-abilities ability\n')
  5. const mockClient = {
  6. session: {
  7. get: async () => ({}),
  8. list: async () => [],
  9. command: async () => ({}),
  10. prompt: async () => ({}),
  11. todo: async () => ({})
  12. },
  13. events: {
  14. publish: async () => {}
  15. }
  16. }
  17. const projectRoot = process.cwd().replace('/packages/plugin-abilities', '')
  18. const mockContext = {
  19. directory: projectRoot,
  20. worktree: projectRoot,
  21. client: mockClient,
  22. $: () => ({ text: async () => '' })
  23. }
  24. const plugin = await createAbilitiesPlugin(mockContext as any, {
  25. abilities: {
  26. directories: [`${projectRoot}/.opencode/abilities`]
  27. }
  28. })
  29. console.log('Running test-abilities...\n')
  30. const result = await plugin.tool['ability.run'].execute({
  31. name: 'test-abilities',
  32. inputs: {}
  33. })
  34. console.log(JSON.stringify(result, null, 2))
  35. }
  36. main().catch(console.error)