Skip to content

Glossary

scarecr0w12 edited this page Jun 19, 2026 · 2 revisions

Glossary

In-memory term registry for CortexPrism, providing a centralized dictionary of domain terms with alias resolution and category filtering. Implemented in src/memory/glossary.ts.

Data Model

Each term has:

Field Type Description
Name (key) string Canonical term name, stored lowercase
definition string Term definition text
aliases string[] Alternative names for the same concept
category string Grouping category, default "general"

API

defineTerm()

defineTerm(name: string, definition: string, category?: string, aliases?: string[]): void

Registers a term in the in-memory map. The name is normalized to lowercase. Aliases are also lowercased.

defineTerm("RAG", "Retrieval-Augmented Generation — combines LLMs with external data retrieval", "ai-concepts", ["retrieval-augmented-generation"]);

lookupTerm()

lookupTerm(name: string): { name, definition, aliases, category } | null

Resolves a term by name or alias, case-insensitive. Returns null if not found.

Resolution order:

  1. Direct match against canonical name (lowercase)
  2. Scan all terms for matching alias

Returns the canonical name (original casing), definition, aliases, and category.

listTerms()

listTerms(category?: string): Array<{ name, definition, category }>

Lists all terms, optionally filtered by category. Returns simplified objects (no aliases in output).

getCategories()

getCategories(): string[]

Returns all unique categories in sorted order.

Storage

All terms are stored in a Map<string, { definition, aliases: string[], category }> in memory. Terms persist only for the runtime duration of the process.

REST API

Method Path Description
POST /api/memory/glossary Define a new term
GET /api/memory/glossary/:name Look up a term by name
GET /api/memory/glossary List terms (query: ?category=)
GET /api/memory/glossary/categories List all categories
DELETE /api/memory/glossary/:name Remove a term

Example: Define a Term

curl -X POST http://localhost:3000/api/memory/glossary \
  -H "Content-Type: application/json" \
  -d '{"name":"A2A","definition":"Agent-to-Agent protocol for AI interop","category":"protocols","aliases":["agent2agent","a2a-protocol"]}'

Example: Look Up by Alias

curl http://localhost:3000/api/memory/glossary/agent2agent
# → returns the A2A term (resolved via alias)

Use Cases

  • Agent context injection: Terms relevant to a conversation can be injected into the system prompt
  • Cross-agent shared vocabulary: Ensures consistent terminology across agents
  • User-facing help: /glossary command to look up terms in chat

See Also

Clone this wiki locally