Skip to content

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

Sushmithamalleshe04bad5ff69a
diff --git a/fern/scripts/build-llms-txt.ts b/fern/scripts/build-llms-txt.ts
index 6eb2d972f..c0bb92f6d 100644
--- a/fern/scripts/build-llms-txt.ts
+++ b/fern/scripts/build-llms-txt.ts
@@ -4,14 +4,14 @@
import fs from 'fs';
import path from 'path';
import {
- LLMS_TXT_PATH,
FERN_DIR,
+ LLMS_TXT_PATH,
loadDocsConfig,
ensureOutputDir,
type DocsConfig,
type ContentItem,
type LayoutItem,
-} from './lib/docs-utils';
+} from './utils';
interface LlmsEntry {
title: string;
diff --git a/fern/scripts/build-tools-json.ts b/fern/scripts/build-tools-json.ts
index 66132bf9f..efa6250d1 100644
--- a/fern/scripts/build-tools-json.ts
+++ b/fern/scripts/build-tools-json.ts
@@ -3,7 +3,7 @@
import fs from 'fs';
import path from 'path';
-import { TOOLKITS_DIR, TOOLS_JSON_PATH, ensureOutputDir } from './lib/docs-utils';
+import { TOOLKITS_DIR, TOOLS_JSON_PATH, ensureOutputDir } from './utils';
interface ToolkitInfo {
slug: string;
diff --git a/fern/scripts/lib/docs-utils.ts b/fern/scripts/lib/docs-utils.ts
deleted file mode 100644
index a098c492f..000000000
--- a/fern/scripts/lib/docs-utils.ts
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/usr/bin/env bun
-
-import fs from 'fs';
-import path from 'path';
-import yaml from 'yaml';
-
-// Define directories
-export const FERN_DIR = path.join(import.meta.dir, '../..');
-export const DOCS_YML_PATH = path.join(FERN_DIR, 'docs.yml');
-export const LLMS_TXT_PATH = path.join(FERN_DIR, 'llms-txt-worker', 'public', 'llms.txt');
-export const TOOLS_JSON_PATH = path.join(
- FERN_DIR,
- 'llms-txt-worker',
- 'public',
- 'robots-only',
- 'tools.json'
-);
-export const PAGES_DIR = path.join(FERN_DIR, 'pages');
-export const TOOLKITS_DIR = path.join(FERN_DIR, 'toolkits');
-
-export interface DocsConfig {
- title: string;
- navigation: Array<{
- tab: string;
- layout?: LayoutItem[];
- }>;
- tabs?: {
- [key: string]: {
- 'display-name': string;
- 'skip-slug'?: boolean;
- };
- };
-}
-
-export interface LayoutItem {
- section?: string;
- contents?: ContentItem[];
- page?: string;
- path?: string;
- slug?: string;
-}
-
-export interface ContentItem {
- page?: string;
- path?: string;
- slug?: string;
- section?: string;
- contents?: ContentItem[];
-}
-
-export function loadDocsConfig(): DocsConfig {
- const docsYmlContent = fs.readFileSync(DOCS_YML_PATH, 'utf8');
- return yaml.parse(docsYmlContent) as DocsConfig;
-}
-
-// Extract description from MDX content
-export function extractDescription(mdxPath: string): string | undefined {
- try {
- const fullPath = path.join(FERN_DIR, mdxPath);
- if (!fs.existsSync(fullPath)) {
- console.warn(`⚠️ File not found: ${fullPath}`);
- return undefined;
- }
-
- const content = fs.readFileSync(fullPath, 'utf8');
-
- // Try to extract from frontmatter description
- const frontmatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);
- if (frontmatterMatch) {
- const frontmatter = frontmatterMatch[1];
- const descMatch = frontmatter.match(/description:\s*["']?(.+?)["']?\s*$/m);
- if (descMatch) {
- return descMatch[1].trim();
- }
- }
-
- // Extract first meaningful paragraph after the title
- const lines = content.split('\n');
- let inFrontmatter = false;
- let foundTitle = false;
- let description = '';
-
- for (const line of lines) {
- const trimmedLine = line.trim();
-
- // Handle frontmatter
- if (trimmedLine === '---') {
- inFrontmatter = !inFrontmatter;
- continue;
- }
-
- if (inFrontmatter) continue;
-
- // Skip titles
- if (trimmedLine.startsWith('#')) {
- foundTitle = true;
- continue;
- }
-
- // Skip empty lines, code blocks, and JSX
- if (
- !trimmedLine ||
- trimmedLine.startsWith('```') ||
- trimmedLine.startsWith('<') ||
- trimmedLine.startsWith('import ') ||
- trimmedLine.startsWith('export ')
- ) {
- continue;
- }
-
- // Found a paragraph
- if (foundTitle && trimmedLine.length > 20) {
- description = trimmedLine;
- break;
- }
- }
-
- // Clean up the description
- if (description) {
- // Remove MDX components and markdown syntax
- description = description
- .replace(/<[^>]+>/g, '') // Remove HTML/JSX tags
- .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Convert [text](url) to text
- .replace(/`([^`]+)`/g, '$1') // Remove inline code backticks
- .replace(/\*\*([^*]+)\*\*/g, '$1') // Remove bold
- .replace(/\*([^*]+)\*/g, '$1') // Remove italic
- .trim();
-
- // Truncate if too long
- if (description.length > 150) {
- description = description.substring(0, 147) + '...';
- }
-
- return description;
- }
-
- return undefined;
- } catch (error) {
- console.warn(`⚠️ Error reading ${mdxPath}:`, error);
- return undefined;
- }
-}
-
-// Ensure output directory exists
-export function ensureOutputDir(filePath: string): void {
- const dir = path.dirname(filePath);
- if (!fs.existsSync(dir)) {
- fs.mkdirSync(dir, { recursive: true });
- }
-}
\ No newline at end of file
diff --git a/fern/scripts/utils.ts b/fern/scripts/utils.ts
new file mode 100644
index 000000000..f3b390846
--- /dev/null
+++ b/fern/scripts/utils.ts
@@ -0,0 +1,61 @@
+#!/usr/bin/env bun
+
+import fs from 'fs';
+import path from 'path';
+import yaml from 'yaml';
+
+// Shared directories
+export const FERN_DIR = path.join(import.meta.dir, '..');
+export const DOCS_YML_PATH = path.join(FERN_DIR, 'docs.yml');
+export const LLMS_TXT_PATH = path.join(FERN_DIR, 'llms-txt-worker', 'public', 'llms.txt');
+export const TOOLS_JSON_PATH = path.join(
+ FERN_DIR,
+ 'llms-txt-worker',
+ 'public',
+ 'robots-only',
+ 'tools.json'
+);
+export const PAGES_DIR = path.join(FERN_DIR, 'pages');
+export const TOOLKITS_DIR = path.join(FERN_DIR, 'toolkits');
+
+export interface DocsConfig {
+ title: string;
+ navigation: Array<{
+ tab: string;
+ layout?: LayoutItem[];
+ }>;
+ tabs?: {
+ [key: string]: {
+ 'display-name': string;
+ 'skip-slug'?: boolean;
+ };
+ };
+}
+
+export interface LayoutItem {
+ section?: string;
+ contents?: ContentItem[];
+ page?: string;
+ path?: string;
+ slug?: string;
+}
+
+export interface ContentItem {
+ page?: string;
+ path?: string;
+ slug?: string;
+ section?: string;
+ contents?: ContentItem[];
+}
+
+export function loadDocsConfig(): DocsConfig {
+ const docsYmlContent = fs.readFileSync(DOCS_YML_PATH, 'utf8');
+ return yaml.parse(docsYmlContent) as DocsConfig;
+}
+
+export function ensureOutputDir(filePath: string): void {
+ const dir = path.dirname(filePath);
+ if (!fs.existsSync(dir)) {
+ fs.mkdirSync(dir, { recursive: true });
+ }
+}
\ No newline at end of file