Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 18:15 UTC
fix
Sushmithamallesh committed
Nov 5, 2025 at 21:48 UTC
e04bad5ff69aa385883c73b06722b4f53303ef3b
4 files changed
+64
-153
fern/scripts/build-llms-txt.ts
+2
-2
@@ -4,14 +4,14 @@
4
import fs from 'fs';
5
import path from 'path';
6
import {
7
- LLMS_TXT_PATH,
7
FERN_DIR,
8
+ LLMS_TXT_PATH,
9
loadDocsConfig,
10
ensureOutputDir,
11
type DocsConfig,
12
type ContentItem,
13
type LayoutItem,
14
-} from './lib/docs-utils';
14
+} from './utils';
15
16
interface LlmsEntry {
17
title: string;
fern/scripts/build-tools-json.ts
+1
-1
@@ -3,7 +3,7 @@
3
4
import fs from 'fs';
5
import path from 'path';
6
-import { TOOLKITS_DIR, TOOLS_JSON_PATH, ensureOutputDir } from './lib/docs-utils';
6
+import { TOOLKITS_DIR, TOOLS_JSON_PATH, ensureOutputDir } from './utils';
7
8
interface ToolkitInfo {
9
slug: string;
fern/scripts/lib/docs-utils.ts
deleted
-150
@@ -1,150 +0,0 @@
1
-#!/usr/bin/env bun
2
-
3
-import fs from 'fs';
4
-import path from 'path';
5
-import yaml from 'yaml';
6
-
7
-// Define directories
8
-export const FERN_DIR = path.join(import.meta.dir, '../..');
9
-export const DOCS_YML_PATH = path.join(FERN_DIR, 'docs.yml');
10
-export const LLMS_TXT_PATH = path.join(FERN_DIR, 'llms-txt-worker', 'public', 'llms.txt');
11
-export const TOOLS_JSON_PATH = path.join(
12
- FERN_DIR,
13
- 'llms-txt-worker',
14
- 'public',
15
- 'robots-only',
16
- 'tools.json'
17
-);
18
-export const PAGES_DIR = path.join(FERN_DIR, 'pages');
19
-export const TOOLKITS_DIR = path.join(FERN_DIR, 'toolkits');
20
-
21
-export interface DocsConfig {
22
- title: string;
23
- navigation: Array<{
24
- tab: string;
25
- layout?: LayoutItem[];
26
- }>;
27
- tabs?: {
28
- [key: string]: {
29
- 'display-name': string;
30
- 'skip-slug'?: boolean;
31
- };
32
- };
33
-}
34
-
35
-export interface LayoutItem {
36
- section?: string;
37
- contents?: ContentItem[];
38
- page?: string;
39
- path?: string;
40
- slug?: string;
41
-}
42
-
43
-export interface ContentItem {
44
- page?: string;
45
- path?: string;
46
- slug?: string;
47
- section?: string;
48
- contents?: ContentItem[];
49
-}
50
-
51
-export function loadDocsConfig(): DocsConfig {
52
- const docsYmlContent = fs.readFileSync(DOCS_YML_PATH, 'utf8');
53
- return yaml.parse(docsYmlContent) as DocsConfig;
54
-}
55
-
56
-// Extract description from MDX content
57
-export function extractDescription(mdxPath: string): string | undefined {
58
- try {
59
- const fullPath = path.join(FERN_DIR, mdxPath);
60
- if (!fs.existsSync(fullPath)) {
61
- console.warn(`⚠️ File not found: ${fullPath}`);
62
- return undefined;
63
- }
64
-
65
- const content = fs.readFileSync(fullPath, 'utf8');
66
-
67
- // Try to extract from frontmatter description
68
- const frontmatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);
69
- if (frontmatterMatch) {
70
- const frontmatter = frontmatterMatch[1];
71
- const descMatch = frontmatter.match(/description:\s*["']?(.+?)["']?\s*$/m);
72
- if (descMatch) {
73
- return descMatch[1].trim();
74
- }
75
- }
76
-
77
- // Extract first meaningful paragraph after the title
78
- const lines = content.split('\n');
79
- let inFrontmatter = false;
80
- let foundTitle = false;
81
- let description = '';
82
-
83
- for (const line of lines) {
84
- const trimmedLine = line.trim();
85
-
86
- // Handle frontmatter
87
- if (trimmedLine === '---') {
88
- inFrontmatter = !inFrontmatter;
89
- continue;
90
- }
91
-
92
- if (inFrontmatter) continue;
93
-
94
- // Skip titles
95
- if (trimmedLine.startsWith('#')) {
96
- foundTitle = true;
97
- continue;
98
- }
99
-
100
- // Skip empty lines, code blocks, and JSX
101
- if (
102
- !trimmedLine ||
103
- trimmedLine.startsWith('```') ||
104
- trimmedLine.startsWith('<') ||
105
- trimmedLine.startsWith('import ') ||
106
- trimmedLine.startsWith('export ')
107
- ) {
108
- continue;
109
- }
110
-
111
- // Found a paragraph
112
- if (foundTitle && trimmedLine.length > 20) {
113
- description = trimmedLine;
114
- break;
115
- }
116
- }
117
-
118
- // Clean up the description
119
- if (description) {
120
- // Remove MDX components and markdown syntax
121
- description = description
122
- .replace(/<[^>]+>/g, '') // Remove HTML/JSX tags
123
- .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Convert [text](url) to text
124
- .replace(/`([^`]+)`/g, '$1') // Remove inline code backticks
125
- .replace(/\*\*([^*]+)\*\*/g, '$1') // Remove bold
126
- .replace(/\*([^*]+)\*/g, '$1') // Remove italic
127
- .trim();
128
-
129
- // Truncate if too long
130
- if (description.length > 150) {
131
- description = description.substring(0, 147) + '...';
132
- }
133
-
134
- return description;
135
- }
136
-
137
- return undefined;
138
- } catch (error) {
139
- console.warn(`⚠️ Error reading ${mdxPath}:`, error);
140
- return undefined;
141
- }
142
-}
143
-
144
-// Ensure output directory exists
145
-export function ensureOutputDir(filePath: string): void {
146
- const dir = path.dirname(filePath);
147
- if (!fs.existsSync(dir)) {
148
- fs.mkdirSync(dir, { recursive: true });
149
- }
150
-}
\ No newline at end of file
fern/scripts/utils.ts
new
+61
@@ -0,0 +1,61 @@
1
+#!/usr/bin/env bun
2
+
3
+import fs from 'fs';
4
+import path from 'path';
5
+import yaml from 'yaml';
6
+
7
+// Shared directories
8
+export const FERN_DIR = path.join(import.meta.dir, '..');
9
+export const DOCS_YML_PATH = path.join(FERN_DIR, 'docs.yml');
10
+export const LLMS_TXT_PATH = path.join(FERN_DIR, 'llms-txt-worker', 'public', 'llms.txt');
11
+export const TOOLS_JSON_PATH = path.join(
12
+ FERN_DIR,
13
+ 'llms-txt-worker',
14
+ 'public',
15
+ 'robots-only',
16
+ 'tools.json'
17
+);
18
+export const PAGES_DIR = path.join(FERN_DIR, 'pages');
19
+export const TOOLKITS_DIR = path.join(FERN_DIR, 'toolkits');
20
+
21
+export interface DocsConfig {
22
+ title: string;
23
+ navigation: Array<{
24
+ tab: string;
25
+ layout?: LayoutItem[];
26
+ }>;
27
+ tabs?: {
28
+ [key: string]: {
29
+ 'display-name': string;
30
+ 'skip-slug'?: boolean;
31
+ };
32
+ };
33
+}
34
+
35
+export interface LayoutItem {
36
+ section?: string;
37
+ contents?: ContentItem[];
38
+ page?: string;
39
+ path?: string;
40
+ slug?: string;
41
+}
42
+
43
+export interface ContentItem {
44
+ page?: string;
45
+ path?: string;
46
+ slug?: string;
47
+ section?: string;
48
+ contents?: ContentItem[];
49
+}
50
+
51
+export function loadDocsConfig(): DocsConfig {
52
+ const docsYmlContent = fs.readFileSync(DOCS_YML_PATH, 'utf8');
53
+ return yaml.parse(docsYmlContent) as DocsConfig;
54
+}
55
+
56
+export function ensureOutputDir(filePath: string): void {
57
+ const dir = path.dirname(filePath);
58
+ if (!fs.existsSync(dir)) {
59
+ fs.mkdirSync(dir, { recursive: true });
60
+ }
61
+}
\ No newline at end of file