Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
EXAMPLE_ECHO_TOOL_NAME,
|
|
EXAMPLE_SUMMARY_PROMPT_NAME,
|
|
type CapabilityRegistration,
|
|
createCapabilityRegistry,
|
|
registerCapabilities,
|
|
registerCoreCapabilities,
|
|
} from "../src/capabilities/index.js";
|
|
|
|
describe("capability registration", () => {
|
|
it("aggregates core registrations through plain function composition", () => {
|
|
const registry = registerCapabilities();
|
|
|
|
expect(registry.tools.map((entry) => entry.name)).toEqual([
|
|
EXAMPLE_ECHO_TOOL_NAME,
|
|
]);
|
|
expect(registry.resources.map((entry) => entry.name)).toEqual([
|
|
"template://status",
|
|
]);
|
|
expect(registry.prompts.map((entry) => entry.name)).toEqual([
|
|
EXAMPLE_SUMMARY_PROMPT_NAME,
|
|
]);
|
|
});
|
|
|
|
it("supports explicit composition with custom registrations", () => {
|
|
const registerCustom: CapabilityRegistration = (registry) => {
|
|
registry.tools.push({
|
|
name: "custom.tool",
|
|
kind: "tool",
|
|
description: "Custom tool descriptor",
|
|
});
|
|
};
|
|
|
|
const registry = registerCapabilities([
|
|
registerCoreCapabilities,
|
|
registerCustom,
|
|
]);
|
|
|
|
expect(registry.tools.map((entry) => entry.name)).toEqual([
|
|
EXAMPLE_ECHO_TOOL_NAME,
|
|
"custom.tool",
|
|
]);
|
|
expect(registry.resources).toHaveLength(1);
|
|
expect(registry.prompts).toHaveLength(1);
|
|
});
|
|
|
|
it("lets callers register into an existing registry", () => {
|
|
const registry = createCapabilityRegistry();
|
|
|
|
registerCoreCapabilities(registry);
|
|
|
|
expect(registry.tools).toHaveLength(1);
|
|
expect(registry.resources).toHaveLength(1);
|
|
expect(registry.prompts).toHaveLength(1);
|
|
});
|
|
});
|