Skip to content

Commit 8aa465d

Browse files
authored
fix: agent files not loading from agents folder (#1473)
1 parent 2f972ba commit 8aa465d

2 files changed

Lines changed: 39 additions & 11 deletions

File tree

eng/generate-website-data.mjs

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,21 @@ function getSkillFiles(skillPath, relativePath) {
492492
return files;
493493
}
494494

495+
/**
496+
* Get all agent markdown files from a folder
497+
*/
498+
function getAgentFiles(agentDir, pluginRootPath) {
499+
if (!fs.existsSync(agentDir)) return [];
500+
501+
return fs
502+
.readdirSync(agentDir)
503+
.filter((f) => f.endsWith(".md"))
504+
.map((f) => ({
505+
kind: "agent",
506+
path: `${pluginRootPath}/agents/${f}`,
507+
}));
508+
}
509+
495510
/**
496511
* Generate plugins metadata
497512
*/
@@ -517,9 +532,25 @@ function generatePluginsData(gitDates) {
517532
const relPath = `plugins/${dir.name}`;
518533
const dates = gitDates[relPath] || gitDates[`${relPath}/`] || {};
519534

535+
const agentItems = (data.agents || []).flatMap((agent) => {
536+
const agentPath = agent.replace("./", "");
537+
const fullPath = path.join(pluginDir, agentPath);
538+
539+
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {
540+
return getAgentFiles(fullPath, relPath);
541+
}
542+
543+
return [
544+
{
545+
kind: "agent",
546+
path: `${relPath}/${agentPath}`,
547+
},
548+
];
549+
});
550+
520551
// Build items list from spec fields (agents, commands, skills)
521552
const items = [
522-
...(data.agents || []).map((p) => ({ kind: "agent", path: p })),
553+
...agentItems,
523554
...(data.commands || []).map((p) => ({ kind: "prompt", path: p })),
524555
...(data.skills || []).map((p) => ({ kind: "skill", path: p })),
525556
];
@@ -535,9 +566,8 @@ function generatePluginsData(gitDates) {
535566
itemCount: items.length,
536567
items: items,
537568
lastUpdated: dates.lastModified || null,
538-
searchText: `${data.name || dir.name} ${
539-
data.description || ""
540-
} ${tags.join(" ")}`.toLowerCase(),
569+
searchText: `${data.name || dir.name} ${data.description || ""
570+
} ${tags.join(" ")}`.toLowerCase(),
541571
});
542572
} catch (e) {
543573
console.warn(`Failed to parse plugin: ${dir.name}`, e.message);
@@ -704,9 +734,8 @@ function generateSearchIndex(
704734
description: instruction.description,
705735
path: instruction.path,
706736
lastUpdated: instruction.lastUpdated,
707-
searchText: `${instruction.title} ${instruction.description} ${
708-
instruction.applyTo || ""
709-
}`.toLowerCase(),
737+
searchText: `${instruction.title} ${instruction.description} ${instruction.applyTo || ""
738+
}`.toLowerCase(),
710739
});
711740
}
712741

@@ -732,9 +761,8 @@ function generateSearchIndex(
732761
description: workflow.description,
733762
path: workflow.path,
734763
lastUpdated: workflow.lastUpdated,
735-
searchText: `${workflow.title} ${
736-
workflow.description
737-
} ${workflow.triggers.join(" ")}`.toLowerCase(),
764+
searchText: `${workflow.title} ${workflow.description
765+
} ${workflow.triggers.join(" ")}`.toLowerCase(),
738766
});
739767
}
740768

website/src/scripts/modal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ function renderLocalPluginModal(
12351235

12361236
switch (itemType) {
12371237
case "agent":
1238-
path = path.replace(".md", ".agent.md");
1238+
// path = path.replace(".md", ".agent.md");
12391239
break;
12401240
case "skill":
12411241
path = `${path}/SKILL.md`;

0 commit comments

Comments
 (0)