UNPKG

mcp-ai-agent-guidelines

Version:

A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices

47 lines 1.7 kB
import { BaseDiagramHandler } from "./base.handler.js"; /** * Handler for mindmap diagrams. * Generates hierarchical mindmap visualizations. */ export class MindmapHandler extends BaseDiagramHandler { diagramType = "mindmap"; generate(description, theme) { this.validateInput(description); const lines = ["mindmap"]; if (theme) lines.unshift(`%%{init: {'theme':'${theme}'}}%%`); const { root, children } = this.parseMindmapDescription(description); lines.push(` root((${root}))`); if (children.length > 0) { for (const child of children) { lines.push(child); } } else { // Fallback template lines.push(" Topic 1", " Subtopic 1.1", " Subtopic 1.2", " Topic 2", " Subtopic 2.1"); } return lines.join("\n"); } /** * Parse natural language description to extract mindmap structure. * @param description - Natural language description * @returns Parsed mindmap configuration */ parseMindmapDescription(description) { const sentences = description .split(/[.!?\n]+/) .map((s) => s.trim()) .filter((s) => s.length > 0); const root = sentences[0] || "Main Topic"; const children = []; for (let i = 1; i < Math.min(sentences.length, 6); i++) { const topic = sentences[i].length > 30 ? `${sentences[i].substring(0, 27)}...` : sentences[i]; children.push(` ${topic}`); } return { root, children }; } } //# sourceMappingURL=mindmap.handler.js.map