Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix build tools json
Sushmithamalleshe5a7941317ab
diff --git a/fern/scripts/build-tools-json.ts b/fern/scripts/build-tools-json.tsindex 4311f25e8..d1e3d58a8 100644--- a/fern/scripts/build-tools-json.ts+++ b/fern/scripts/build-tools-json.ts@@ -25,49 +25,33 @@ interface ToolsData {[key: string]: string[] | ToolkitInfo;}-// Parse tool MDX files to extract toolkit informationfunction parseToolkitMdx(toolMdxPath: string): ToolkitInfo | null {try {const fullPath = path.join(TOOLKITS_DIR, toolMdxPath);if (!fs.existsSync(fullPath)) {- console.warn(`⚠️ Tool file not found: ${fullPath}`);return null;}const content = fs.readFileSync(fullPath, 'utf8');- // Extract frontmatterconst frontmatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);- if (!frontmatterMatch) {- console.warn(`⚠️ No frontmatter found in: ${toolMdxPath}`);- return null;- }+ if (!frontmatterMatch) return null;const frontmatter = frontmatterMatch[1];const titleMatch = frontmatter.match(/title:\s*["']?(.+?)["']?\s*$/m);- if (!titleMatch) {- console.warn(`⚠️ No title found in: ${toolMdxPath}`);- return null;- }+ if (!titleMatch) return null;- // Extract SLUG from contentconst slugMatch = content.match(/\*\*SLUG\*\*:\s*`([^`]+)`/);- if (!slugMatch) {- // Not a toolkit page, skip- return null;- }+ if (!slugMatch) return null;- // Extract descriptionconst descriptionMatch = content.match(/### Description\s*\n(.+?)(?:\n|$)/);const description = descriptionMatch ? descriptionMatch[1].trim() : '';-- // Extract tool names from Accordion titles+const toolNames: string[] = [];const accordionMatches = content.matchAll(/<Accordion title="([^"]+)">/g);for (const match of accordionMatches) {const toolName = match[1];- // Only include tools that start with the toolkit prefixif (toolName.startsWith(slugMatch[1] + '_')) {toolNames.push(toolName);}@@ -79,72 +63,57 @@ function parseToolkitMdx(toolMdxPath: string): ToolkitInfo | null {tools: toolNames,};} catch (error) {- console.warn(`⚠️ Error parsing tool file ${toolMdxPath}:`, error);+ console.warn(`Error parsing ${toolMdxPath}:`, error);return null;}}-// Scan toolkits directory and build tools datafunction buildToolsData(): ToolsData {const toolsData: ToolsData = { toolkitNames: [] };if (!fs.existsSync(TOOLKITS_DIR)) {- console.warn(`⚠️ Toolkits directory not found: ${TOOLKITS_DIR}`);+ console.error(`Toolkits directory not found: ${TOOLKITS_DIR}`);return toolsData;}- // Read all MDX files in toolkits directoryconst files = fs.readdirSync(TOOLKITS_DIR);const mdxFiles = files.filter(file => file.endsWith('.mdx'));-- console.log(`📂 Found ${mdxFiles.length} MDX files in toolkits directory`);+ console.log(`Found ${mdxFiles.length} MDX files`);for (const file of mdxFiles) {const toolkitInfo = parseToolkitMdx(file);if (toolkitInfo) {toolsData.toolkitNames.push(toolkitInfo.slug);toolsData[toolkitInfo.slug] = toolkitInfo;- console.log(` ✓ ${toolkitInfo.slug}: ${toolkitInfo.tools.length} tools`);+ console.log(` ${toolkitInfo.slug}: ${toolkitInfo.tools.length} tools`);}}- // Sort toolkit names alphabeticallytoolsData.toolkitNames.sort();-return toolsData;}-// Main function-async function main(): Promise<void> {- console.log('🔨 Building tools.json...');-+function main() {+ console.log('Building tools.json...');try {- // Build tools dataconst toolsData = buildToolsData();- console.log(`\n📊 Summary:`);- console.log(` - Total toolkits: ${toolsData.toolkitNames.length}`);+ console.log(`\nSummary:`);+ console.log(` Total toolkits: ${toolsData.toolkitNames.length}`);let totalTools = 0;for (const name of toolsData.toolkitNames) {const toolkit = toolsData[name] as ToolkitInfo;totalTools += toolkit.tools.length;}- console.log(` - Total tools: ${totalTools}`);+ console.log(` Total tools: ${totalTools}`);- // Write tools.json- const toolsJsonContent = JSON.stringify(toolsData, null, 2);- fs.writeFileSync(TOOLS_JSON_PATH, toolsJsonContent);-- console.log(`\n✅ Generated tools.json at ${TOOLS_JSON_PATH}`);+ fs.writeFileSync(TOOLS_JSON_PATH, JSON.stringify(toolsData, null, 2));+ console.log(`\nGenerated ${TOOLS_JSON_PATH}`);} catch (error) {- console.error('❌ Error building tools.json:', error);+ console.error('Error:', error);process.exit(1);}}-// Run the script-main().catch(error => {- console.error('❌ Fatal error:', error);- process.exit(1);-});\ No newline at end of file+main();\ No newline at end of file