11#!/usr/bin/env node
22
3- const fs = require ( "fs" ) ;
4- const path = require ( " path" ) ;
3+ const fs = require ( 'fs' ) ;
4+ const path = require ( ' path' ) ;
55
66/**
77 * Exports agents.json to CSV format for easy database import
88 */
99
10- const agentsFilePath = path . join ( __dirname , ".." , " protocol" , " agents.json" ) ;
11- const outputPath = path . join ( __dirname , ".." , " data" , " agents" , " agents.csv" ) ;
10+ const agentsFilePath = path . join ( __dirname , '..' , ' protocol' , ' agents.json' ) ;
11+ const outputPath = path . join ( __dirname , '..' , ' data' , ' agents' , ' agents.csv' ) ;
1212
1313// Load agents data
14- const agents = JSON . parse ( fs . readFileSync ( agentsFilePath , " utf8" ) ) ;
14+ const agents = JSON . parse ( fs . readFileSync ( agentsFilePath , ' utf8' ) ) ;
1515
1616// CSV header
17- const csvHeader = " identifier,versioned,type,source,product,name" ;
17+ const csvHeader = ' identifier,versioned,type,source,product,name' ;
1818
1919// Process agents
2020const csvRows = [ csvHeader ] ;
2121
2222agents . agents . forEach ( ( agent ) => {
2323 // Extract fields, using empty string for missing optional fields
24- const identifier = agent . identifier || "" ;
25- const versioned = agent . versioned !== undefined ? agent . versioned : "" ;
26- const type = agent . type || "" ;
27- const source = agent . source || "" ;
28- const product = agent . product || "" ;
29- const name = agent . name || "" ;
24+ const identifier = agent . identifier || '' ;
25+ const versioned = agent . versioned !== undefined ? agent . versioned : '' ;
26+ const type = agent . type || '' ;
27+ const source = agent . source || '' ;
28+ const product = agent . product || '' ;
29+ const name = agent . name || '' ;
3030
3131 // Escape fields that might contain commas
3232 const escapeCsvField = ( field ) => {
3333 const str = String ( field ) ;
34- if ( str . includes ( "," ) || str . includes ( '"' ) || str . includes ( "\n" ) ) {
34+ if ( str . includes ( ',' ) || str . includes ( '"' ) || str . includes ( '\n' ) ) {
3535 return `"${ str . replace ( / " / g, '""' ) } "` ;
3636 }
3737 return str ;
@@ -45,7 +45,7 @@ agents.agents.forEach((agent) => {
4545 escapeCsvField ( source ) ,
4646 escapeCsvField ( product ) ,
4747 escapeCsvField ( name ) ,
48- ] . join ( "," ) ;
48+ ] . join ( ',' ) ;
4949
5050 csvRows . push ( row ) ;
5151} ) ;
@@ -57,7 +57,7 @@ if (!fs.existsSync(outputDir)) {
5757}
5858
5959// Write CSV file
60- const csvContent = csvRows . join ( "\n" ) ;
60+ const csvContent = csvRows . join ( '\n' ) ;
6161fs . writeFileSync ( outputPath , csvContent ) ;
6262
6363console . log ( `✅ Exported ${ agents . agents . length } agents to ${ outputPath } ` ) ;
@@ -68,7 +68,7 @@ agents.agents.forEach((agent) => {
6868 typeCounts [ agent . type ] = ( typeCounts [ agent . type ] || 0 ) + 1 ;
6969} ) ;
7070
71- console . log ( " \nSummary by type:" ) ;
71+ console . log ( ' \nSummary by type:' ) ;
7272Object . entries ( typeCounts ) . forEach ( ( [ type , count ] ) => {
7373 console . log ( ` - ${ type } : ${ count } agents` ) ;
7474} ) ;
@@ -86,7 +86,7 @@ agents.agents.forEach((agent) => {
8686} ) ;
8787
8888if ( Object . keys ( productCounts ) . length > 0 ) {
89- console . log ( " \nSummary by product:" ) ;
89+ console . log ( ' \nSummary by product:' ) ;
9090 Object . entries ( productCounts ) . forEach ( ( [ product , count ] ) => {
9191 console . log ( ` - ${ product } : ${ count } agents` ) ;
9292 } ) ;
0 commit comments