@devries-cameron20 / composio-1 / commits / b2f868c85
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(docs): Safely stringify ReactNode names in llms.txt

Add nodeText() helper that only converts string/number ReactNode values, returning null for React elements to avoid [object Object] headings. Also fix missing closing brace in switch case. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Sushmithamallesh committed Feb 11, 2026 at 12:15 UTC b2f868c85d0d4c540c68b85c55bd4806311790f3
1 file changed +17 -6
docs/app/llms.txt/route.ts
+17 -6
@@ -24,6 +24,13 @@ interface FolderNode {
24
25 type TreeNode = PageNode | SeparatorNode | FolderNode;
26
27 +/** Extract plain text from a ReactNode (handles strings, numbers, skips elements). */
28 +function nodeText(name: ReactNode): string | null {
29 + if (typeof name === 'string') return name;
30 + if (typeof name === 'number') return String(name);
31 + return null;
32 +}
33 +
34 /**
35 * Walk the fumadocs page tree and generate a markdown index.
36 * Separators become ## headings, pages become URL entries, folders recurse.
@@ -33,20 +40,23 @@ function walkPageTree(nodes: TreeNode[], depth = 2): string {
40
41 for (const node of nodes) {
42 switch (node.type) {
36 - case 'separator':
37 - if (node.name) {
38 - lines.push('', `${'#'.repeat(depth)} ${String(node.name)}`, '');
43 + case 'separator': {
44 + const text = nodeText(node.name);
45 + if (text) {
46 + lines.push('', `${'#'.repeat(depth)} ${text}`, '');
47 }
48 break;
49 + }
50
51 case 'page':
52 lines.push(`- https://docs.composio.dev${node.url}.md`);
53 break;
54
46 - case 'folder':
55 + case 'folder': {
56 // Folders are sub-sections within separator sections, so one level deeper
48 - if (node.name) {
49 - lines.push('', `${'#'.repeat(depth + 1)} ${String(node.name)}`, '');
57 + const text = nodeText(node.name);
58 + if (text) {
59 + lines.push('', `${'#'.repeat(depth + 1)} ${text}`, '');
60 }
61 // If folder has an index page, include it
62 if (node.index) {
@@ -57,6 +67,7 @@ function walkPageTree(nodes: TreeNode[], depth = 2): string {
67 lines.push(walkPageTree(node.children, depth + 1));
68 }
69 break;
70 + }
71 }
72 }
73