oh-my-opencode/src/shared/agent-tool-restrictions.test.ts
ismeth e503697d92 fix(athena): council review fixes — delegation bug, dead code, test coverage
- Add background_output to council-member allowlist (fixes delegation deadlock)
- Replace empty catch with error logging in prepare-council-prompt
- Remove unnecessary type assertion in agent.ts
- Remove dead hasAgentToolRestrictions function
- Fix incorrect test assertions (undefined vs false semantics)
- Add barrel export for athena module
- Add guard function test coverage (5 tests)
- Add parity test for triple-sync restrictions (9 tests)
2026-02-24 22:28:46 +09:00

59 lines
2.2 KiB
TypeScript

import { describe, expect, test } from "bun:test"
import { getAgentToolRestrictions } from "./agent-tool-restrictions"
describe("agent-tool-restrictions", () => {
test("athena restrictions include call_omo_agent", () => {
//#given
//#when
const restrictions = getAgentToolRestrictions("athena")
//#then
expect(restrictions.write).toBe(false)
expect(restrictions.edit).toBe(false)
expect(restrictions.call_omo_agent).toBe(false)
})
test("council-member restrictions include all denied tools", () => {
//#given
//#when
const restrictions = getAgentToolRestrictions("council-member")
//#then
// Wildcard deny key
expect(restrictions["*"]).toBe(false)
// Explicitly allowed tools
expect(restrictions.read).toBe(true)
expect(restrictions.grep).toBe(true)
expect(restrictions.call_omo_agent).toBe(true)
expect(restrictions.background_output).toBe(true)
// Explicitly denied tools
expect(restrictions.todowrite).toBe(false)
expect(restrictions.todoread).toBe(false)
// Unlisted tools are undefined (SDK applies wildcard at runtime)
expect(restrictions.switch_agent).toBeUndefined()
expect(restrictions.background_wait).toBeUndefined()
})
test("#given dynamic council member name #when getAgentToolRestrictions #then returns council-member restrictions", () => {
//#given
const dynamicName = "Council: Claude Opus 4.6"
//#when
const restrictions = getAgentToolRestrictions(dynamicName)
//#then
// Wildcard deny key
expect(restrictions["*"]).toBe(false)
// Explicitly allowed tools
expect(restrictions.read).toBe(true)
expect(restrictions.grep).toBe(true)
expect(restrictions.call_omo_agent).toBe(true)
expect(restrictions.background_output).toBe(true)
// Explicitly denied tools
expect(restrictions.todowrite).toBe(false)
expect(restrictions.todoread).toBe(false)
// Unlisted tools are undefined (SDK applies wildcard at runtime)
expect(restrictions.switch_agent).toBeUndefined()
expect(restrictions.write).toBeUndefined()
expect(restrictions.edit).toBeUndefined()
expect(restrictions.task).toBeUndefined()
expect(restrictions.background_wait).toBeUndefined()
})
})