Skip to content

Commit a854e6b

Browse files
committed
autofmt
1 parent 4cb8580 commit a854e6b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

typescript-sdk/apps/dojo/scripts/generate-content-json.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ import path from "path";
55
function parseAgentsFile(): Array<{id: string, agentKeys: string[]}> {
66
const agentsFilePath = path.join(__dirname, '../src/agents.ts');
77
const agentsContent = fs.readFileSync(agentsFilePath, 'utf8');
8-
8+
99
const agentConfigs: Array<{id: string, agentKeys: string[]}> = [];
10-
10+
1111
// Split the content to process each agent configuration individually
1212
const agentBlocks = agentsContent.split(/(?=\s*{\s*id:\s*["'])/);
13-
13+
1414
for (const block of agentBlocks) {
1515
// Extract the ID
1616
const idMatch = block.match(/id:\s*["']([^"']+)["']/);
1717
if (!idMatch) continue;
18-
18+
1919
const id = idMatch[1];
20-
20+
2121
// Find the return object by looking for the pattern and then manually parsing balanced braces
2222
const returnMatch = block.match(/agents:\s*async\s*\(\)\s*=>\s*{\s*return\s*{/);
2323
if (!returnMatch) continue;
24-
24+
2525
const startIndex = returnMatch.index! + returnMatch[0].length;
2626
const returnObjectContent = extractBalancedBraces(block, startIndex);
27-
28-
27+
28+
2929
// Extract keys from the return object - only capture keys that are followed by a colon and then 'new'
3030
// This ensures we only get the top-level keys like "agentic_chat: new ..." not nested keys like "url: ..."
3131
const keyRegex = /^\s*(\w+):\s*new\s+\w+/gm;
@@ -34,18 +34,18 @@ function parseAgentsFile(): Array<{id: string, agentKeys: string[]}> {
3434
while ((keyMatch = keyRegex.exec(returnObjectContent)) !== null) {
3535
keys.push(keyMatch[1]);
3636
}
37-
37+
3838
agentConfigs.push({ id, agentKeys: keys });
3939
}
40-
40+
4141
return agentConfigs;
4242
}
4343

4444
// Helper function to extract content between balanced braces
4545
function extractBalancedBraces(text: string, startIndex: number): string {
4646
let braceCount = 0;
4747
let i = startIndex;
48-
48+
4949
while (i < text.length) {
5050
if (text[i] === '{') {
5151
braceCount++;
@@ -58,7 +58,7 @@ function extractBalancedBraces(text: string, startIndex: number): string {
5858
}
5959
i++;
6060
}
61-
61+
6262
return '';
6363
}
6464

@@ -71,23 +71,23 @@ async function getFile(_filePath: string | undefined, _fileName?: string) {
7171
console.warn(`File path is undefined, skipping.`);
7272
return {}
7373
}
74-
74+
7575
const fileName = _fileName ?? _filePath.split('/').pop() ?? ''
7676
const filePath = _fileName ? path.join(_filePath, fileName) : _filePath;
77-
77+
7878
// Check if it's a remote URL
7979
const isRemoteUrl = _filePath.startsWith('http://') || _filePath.startsWith('https://');
80-
80+
8181
let content: string;
82-
82+
8383
try {
8484
if (isRemoteUrl) {
8585
// Convert GitHub URLs to raw URLs for direct file access
8686
let fetchUrl = _filePath;
8787
if (_filePath.includes('github.com') && _filePath.includes('/blob/')) {
8888
fetchUrl = _filePath.replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/');
8989
}
90-
90+
9191
// Fetch remote file content
9292
console.log(`Fetching remote file: ${fetchUrl}`);
9393
const response = await fetch(fetchUrl);
@@ -228,6 +228,6 @@ async function runGenerateContent() {
228228
path.join(__dirname, "../src/files.json"),
229229
JSON.stringify(result, null, 2)
230230
);
231-
231+
232232
console.log("Successfully generated src/files.json");
233233
})();

0 commit comments

Comments
 (0)