OpenWriterControle/packages/plugin-abilities/test-plugin.ts
Darren Hinde bf02ad0d5c
refactor: Rename repository to OpenAgents Control (#100)
* refactor: Rename repository to OpenAgents Control

Update all project references from "OpenAgents" to "OpenAgents Control":
- Updated core config files (package.json, registry.json)
- Updated documentation (README.md, docs/)
- Updated scripts (install.sh, update.sh, test scripts)
- Updated agent and command files
- Updated integrations and packages
- Updated all GitHub URLs to use OpenAgentsControl

Naming convention:
- Display name: "OpenAgents Control"
- Repository URL: OpenAgentsControl

* feat: Enable subagent-to-subagent delegation (ContextScout integration)

Allow coding-related subagents to call ContextScout for context discovery:
- CoderAgent: Can now discover coding standards on-demand
- TestEngineer: Can now discover test coverage and TDD guidelines
- CodeReviewer: Can now discover code review and security patterns
- BuildAgent: Can now discover build validation standards
- DocWriter: Can now discover documentation formatting guidelines

Changes per subagent:
- Added `task: true` to tools section
- Added permission allowlist for ContextScout only (deny all other delegation)
- Added Context Discovery workflow section with when-to-call guidance

This enables subagents to be self-sufficient for finding relevant standards
instead of relying on orchestrator to provide all context files.

Benefits:
- Subagents can discover what they need when context isn't explicit
- Maintains security (only ContextScout allowed via task tool)
- Follows existing patterns (uses task tool like main agents)

* fix: Set OPENCODE_BRANCH in CI tests to use PR branch for downloads

- Add OPENCODE_BRANCH environment variable to E2E tests
- Add OPENCODE_BRANCH environment variable to profile smoke tests
- Ensures tests download files from the PR branch instead of main
- Fixes E2E test failures after repository rename to OpenAgentsControl
2026-01-18 09:31:35 +00:00

87 lines
2.4 KiB
TypeScript

#!/usr/bin/env bun
// Usage: bun test-plugin.ts
import { createAbilitiesPlugin } from './src/plugin.js'
async function main() {
console.log('🧪 Testing Abilities Plugin\n')
console.log('='.repeat(50))
const mockClient = {
session: {
get: async () => ({}),
list: async () => [],
command: async () => ({}),
prompt: async () => ({}),
todo: async () => ({})
},
events: {
publish: async (options: unknown) => {
console.log('[Event Published]', JSON.stringify(options, null, 2))
}
}
}
const mockContext = {
directory: process.cwd(),
worktree: process.cwd(),
client: mockClient,
$: () => ({ text: async () => '' })
}
console.log('\n📦 Initializing plugin...\n')
const projectRoot = process.cwd().replace('/packages/plugin-abilities', '')
const plugin = await createAbilitiesPlugin(mockContext as any, {
abilities: {
directories: [`${projectRoot}/.opencode/abilities`]
}
})
console.log('\n📋 Testing ability.list tool...\n')
const tools = plugin.tool
const listResult = await tools['ability.list'].execute({})
console.log(listResult)
console.log('\n='.repeat(50))
console.log('\n✅ Testing ability.validate tool...\n')
const validateResult = await tools['ability.validate'].execute({ name: 'hello-world' })
console.log(validateResult)
console.log('\n='.repeat(50))
console.log('\n🚀 Testing ability.run tool...\n')
const runResult = await tools['ability.run'].execute({
name: 'hello-world',
inputs: { name: 'OpenAgents Control' }
})
console.log(JSON.stringify(runResult, null, 2))
console.log('\n='.repeat(50))
console.log('\n📊 Testing ability.status tool...\n')
const statusResult = await tools['ability.status'].execute({})
console.log(JSON.stringify(statusResult, null, 2))
console.log('\n='.repeat(50))
console.log('\n🔍 Testing trigger detection (chat.message hook)...\n')
const mockOutput = {
parts: [
{ type: 'text', text: 'hello can you greet me?', synthetic: false }
]
}
await plugin['chat.message']({}, mockOutput)
if (mockOutput.parts.length > 1) {
console.log('✅ Ability detected! Injected message:')
console.log(mockOutput.parts[0].text)
} else {
console.log('❌ No ability detected')
}
console.log('\n='.repeat(50))
console.log('\n✅ All tests completed!')
}
main().catch(console.error)