Skip to main content

Class: CapabilityRegistry

Defined in: src/ai/capability-registry.ts:48

Queryable registry of Praman API capabilities for AI agents.

Intent​

Expose Praman API surface to LLMs for test generation.

Capability​

AI context building, capability discovery.

Example​

const registry = new CapabilityRegistry();
const caps = registry.byCategory('navigation');

Constructors​

Constructor​

new CapabilityRegistry(): CapabilityRegistry

Defined in: src/ai/capability-registry.ts:69

Constructs a registry pre-seeded from the generated capability list.

Returns​

CapabilityRegistry

Example​

const registry = new CapabilityRegistry();
logger.info(registry.list().length);

Properties​

registryVersion​

readonly static registryVersion: 1 = 1

Defined in: src/ai/capability-registry.ts:56

Registry schema version.

Remarks​

Bumped when the entry shape changes. Consumers can use this to detect incompatible generated files at runtime.

Methods​

byCategory()​

byCategory(category): CapabilityEntry[]

Defined in: src/ai/capability-registry.ts:102

Returns capabilities matching the given category.

Parameters​

category​

string

Category string to filter by (case-sensitive).

Returns​

CapabilityEntry[]

Entries whose category matches exactly.

Example​

const navCaps = registry.byCategory('navigation');

find()​

find(query): CapabilityEntry[]

Defined in: src/ai/capability-registry.ts:137

Searches capabilities by partial match against name or description.

Parameters​

query​

string

Substring to search for.

Returns​

CapabilityEntry[]

Entries whose name or description contains the query.

Remarks​

Case-insensitive substring match. For semantic search, feed the result list into an embedding model or pass forAI() output to an LLM.

Example​

const clickCaps = registry.find('click');

findByName()​

findByName(name): CapabilityEntry | undefined

Defined in: src/ai/capability-registry.ts:161

Returns the first capability entry matching the given name, or undefined.

Parameters​

name​

string

Human-readable capability name to look up (case-sensitive).

Returns​

CapabilityEntry | undefined

The matching entry, or undefined if not found.

Remarks​

Searches by human-readable name (not id). For exact ID lookup use get().

Example​

const cap = registry.findByName('clickButton');
if (cap !== undefined) {
logger.info(cap.usage_example);
}

forAI()​

forAI(): CapabilitiesJSON

Defined in: src/ai/capability-registry.ts:237

Returns the full registry as structured JSON optimised for AI agent consumption.

Returns​

CapabilitiesJSON

Structured JSON snapshot of the entire registry.

Remarks​

Currently an alias for toJSON(). Future releases may apply provider-specific formatting or token-budget-aware truncation.

Example​

const aiContext = registry.forAI();
const prompt = JSON.stringify(aiContext);

forProvider()​

forProvider(provider): string

Defined in: src/ai/capability-registry.ts:261

Returns capabilities formatted for a specific AI provider.

Parameters​

provider​

AiProviderName

Target AI provider name.

Returns​

string

Formatted capability descriptions as a string.

Remarks​

Each provider receives a format optimised for its native consumption pattern:

  • 'claude' — XML-structured {@literal <capability>} elements with attributes
  • 'openai' — JSON array of function-calling tool schemas
  • 'gemini' — Plain text listing with name, description, and example

Example​

const registry = new CapabilityRegistry();
const claudeContext = registry.forProvider('claude');
const openaiTools = registry.forProvider('openai');
const geminiText = registry.forProvider('gemini');

get()​

get(id): CapabilityEntry | undefined

Defined in: src/ai/capability-registry.ts:365

Returns the capability entry with the given id, or undefined.

Parameters​

id​

string

Unique kebab-case capability identifier.

Returns​

CapabilityEntry | undefined

The matching entry, or undefined if not registered.

Example​

const cap = registry.get('click-button');
if (cap !== undefined) {
logger.info(cap.usage_example);
}

getStatistics()​

getStatistics(): CapabilityStats

Defined in: src/ai/capability-registry.ts:179

Returns a statistical summary of the capability registry.

Returns​

CapabilityStats

Statistics including total count, categories, and priority breakdown.

Example​

const stats = registry.getStatistics();
logger.info(`Total: ${stats.totalMethods}`);

has()​

has(name): boolean

Defined in: src/ai/capability-registry.ts:386

Returns true if a capability with the given name is registered.

Parameters​

name​

string

Human-readable capability name to look up.

Returns​

boolean

true when at least one entry matches.

Remarks​

Searches by name (not id). Names are not guaranteed unique but are human-readable and match the TSDoc @capability tag value.

Example​

if (registry.has('clickButton')) {
// safe to use
}

list()​

list(): CapabilityEntry[]

Defined in: src/ai/capability-registry.ts:87

Returns all registered capability entries.

Returns​

CapabilityEntry[]

Shallow copy of the full capability list.

Example​

const all = registry.list();
logger.info(all.length);

listByPriority()​

listByPriority(priority): CapabilityEntry[]

Defined in: src/ai/capability-registry.ts:118

Returns capabilities matching the given priority tier.

Parameters​

priority​

Priority level to filter by.

"fixture" | "namespace" | "implementation"

Returns​

CapabilityEntry[]

Entries whose priority matches exactly.

Example​

const fixtures = registry.listByPriority('fixture');
const handlers = registry.listByPriority('namespace');

register()​

register(entry): void

Defined in: src/ai/capability-registry.ts:414

Registers a new capability entry or overwrites an existing one by id.

Parameters​

entry​

CapabilityEntry

Capability entry to add or replace.

Returns​

void

Remarks​

Intended for use in tests and plugins. The generated file should not call this method — run npm run generate:capabilities instead.

Example​

registry.register({
id: 'my-capability',
name: 'myCapability',
description: 'Does something useful',
category: 'custom',
usage_example: 'await custom.doSomething()',
registryVersion: 1,
});

toJSON()​

toJSON(): CapabilitiesJSON

Defined in: src/ai/capability-registry.ts:209

Exports the full registry as a structured JSON object.

Returns​

CapabilitiesJSON

Structured JSON snapshot of the entire registry.

Remarks​

Fixtures are listed first (Playwright best practice), then all methods.

Example​

const json = registry.toJSON();
logger.info(JSON.stringify(json, null, 2));