import type { FunctionsRegistry } from "./registry.js"; /** * Render the `` system prompt block. * * Returns null if the registry has no non-skill groups (nothing to advertise). * Groups with a "skill:" prefix are excluded — those are internal to their owning skill. * * @param registry - The functions registry to render groups from. * @returns XML block string, or null when there is nothing to inject. */ export function renderBamlSystemPrompt(registry: FunctionsRegistry): string | null { const groups = registry.listGroups().filter((g) => !g.name.startsWith("skill:")); if (groups.length === 0) { return null; } const lines: string[] = []; lines.push(""); lines.push("BAML function groups callable via the baml_run tool."); lines.push("Call baml_list with a group name to see function signatures and types before invoking."); lines.push("For ad-hoc structured extraction, use baml_exec (see the baml skill for authoring guidance)."); lines.push(""); for (const group of groups) { lines.push(" "); lines.push(` ${group.name}`); if (group.description !== undefined) { lines.push(` ${group.description}`); } lines.push(" "); } lines.push(""); return lines.join("\n"); }