···59});
6061const nodeMetadataSchema = z.object({
62- title: z.string().describe("Display name for the node"),
63- description: z
64- .string()
65- .describe("Detailed markdown explanation of this component"),
66 links: z
67- .array(
68- z.object({
69- label: z.string().describe("Display text, e.g. src/auth.ts"),
70- url: z.string().describe("File path or URL"),
71- }),
72- )
73- .optional()
74- .describe("Related files or documentation"),
75- codeSnippet: z.string().optional().describe("Optional code example"),
76- threadID: z
77- .string()
78- .optional()
79- .describe("Optional link to deeper exploration thread"),
80});
8182server.registerTool("walkthrough_diagram", {
83 title: "Walkthrough Diagram",
84- description:
85- "Render an interactive Mermaid diagram where users can click nodes to see detailed information about each component. Use plain text labels in Mermaid code, no HTML tags or custom styling.",
00000000000086 inputSchema: z.object({
87- code: z
88- .string()
89- .describe(
90- "Mermaid diagram code. Use plain text labels, no HTML tags. No custom styling/colors.",
91- ),
92- summary: z
93- .string()
94- .describe("One-sentence summary of what the diagram illustrates"),
95- nodes: z
96- .record(z.string(), nodeMetadataSchema)
97- .describe(
98- "Metadata for clickable nodes, keyed by node ID from mermaid code",
99- ),
100 }),
101}, async ({ code, summary, nodes }) => {
102 const id = String(++diagramCounter);
···59});
6061const nodeMetadataSchema = z.object({
62+ title: z.string(),
63+ description: z.string(),
0064 links: z
65+ .array(z.object({ label: z.string(), url: z.string() }))
66+ .optional(),
67+ codeSnippet: z.string().optional(),
000000000068});
6970server.registerTool("walkthrough_diagram", {
71 title: "Walkthrough Diagram",
72+ description: `Render an interactive Mermaid diagram where users can click nodes to see details.
73+74+BEFORE calling this tool, deeply explore the codebase:
75+1. Use search/read tools to find key files, entry points, and architecture patterns
76+2. Trace execution paths and data flow between components
77+3. Read source files — don't guess from filenames
78+79+Then build the diagram:
80+- Use \`flowchart TB\` with plain text labels, no HTML or custom styling
81+- 5-12 nodes at the right abstraction level (not too granular, not too high-level)
82+- Node keys must match Mermaid node IDs exactly
83+- Descriptions: 2-3 paragraphs of markdown per node. Write for someone who has never seen this codebase — explain what the component does, how it works, and why it matters. Use \`code spans\` for identifiers and markdown headers to organize longer explanations
84+- Links: include file:line references from your exploration
85+- Code snippets: key excerpts (under 15 lines) showing the most important or representative code`,
86 inputSchema: z.object({
87+ code: z.string(),
88+ summary: z.string(),
89+ nodes: z.record(z.string(), nodeMetadataSchema),
000000000090 }),
91}, async ({ code, summary, nodes }) => {
92 const id = String(++diagramCounter);