UNPKG

buroventures-harald-code-core

Version:

Harald Code Core - Core functionality for AI-powered coding assistant

47 lines 1.5 kB
/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ export class PromptRegistry { prompts = new Map(); /** * Registers a prompt definition. * @param prompt - The prompt object containing schema and execution logic. */ registerPrompt(prompt) { if (this.prompts.has(prompt.name)) { const newName = `${prompt.serverName}_${prompt.name}`; console.warn(`Prompt with name "${prompt.name}" is already registered. Renaming to "${newName}".`); this.prompts.set(newName, { ...prompt, name: newName }); } else { this.prompts.set(prompt.name, prompt); } } /** * Returns an array of all registered and discovered prompt instances. */ getAllPrompts() { return Array.from(this.prompts.values()).sort((a, b) => a.name.localeCompare(b.name)); } /** * Get the definition of a specific prompt. */ getPrompt(name) { return this.prompts.get(name); } /** * Returns an array of prompts registered from a specific MCP server. */ getPromptsByServer(serverName) { const serverPrompts = []; for (const prompt of this.prompts.values()) { if (prompt.serverName === serverName) { serverPrompts.push(prompt); } } return serverPrompts.sort((a, b) => a.name.localeCompare(b.name)); } } //# sourceMappingURL=prompt-registry.js.map