From c1140632aa3d26d1c59a6f5db68805434ad135a0 Mon Sep 17 00:00:00 2001 From: aezanpathan Date: Wed, 22 Apr 2026 23:34:08 +0530 Subject: [PATCH] fix: agent files not loading from agents folder --- eng/generate-website-data.mjs | 48 +++++++++++++++++++++++++++-------- website/src/scripts/modal.ts | 2 +- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/eng/generate-website-data.mjs b/eng/generate-website-data.mjs index a2e2dca03..1823dcc9d 100644 --- a/eng/generate-website-data.mjs +++ b/eng/generate-website-data.mjs @@ -492,6 +492,21 @@ function getSkillFiles(skillPath, relativePath) { return files; } +/** + * Get all agent markdown files from a folder + */ +function getAgentFiles(agentDir, pluginRootPath) { + if (!fs.existsSync(agentDir)) return []; + + return fs + .readdirSync(agentDir) + .filter((f) => f.endsWith(".md")) + .map((f) => ({ + kind: "agent", + path: `${pluginRootPath}/agents/${f}`, + })); +} + /** * Generate plugins metadata */ @@ -517,9 +532,25 @@ function generatePluginsData(gitDates) { const relPath = `plugins/${dir.name}`; const dates = gitDates[relPath] || gitDates[`${relPath}/`] || {}; + const agentItems = (data.agents || []).flatMap((agent) => { + const agentPath = agent.replace("./", ""); + const fullPath = path.join(pluginDir, agentPath); + + if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) { + return getAgentFiles(fullPath, relPath); + } + + return [ + { + kind: "agent", + path: `${relPath}/${agentPath}`, + }, + ]; + }); + // Build items list from spec fields (agents, commands, skills) const items = [ - ...(data.agents || []).map((p) => ({ kind: "agent", path: p })), + ...agentItems, ...(data.commands || []).map((p) => ({ kind: "prompt", path: p })), ...(data.skills || []).map((p) => ({ kind: "skill", path: p })), ]; @@ -535,9 +566,8 @@ function generatePluginsData(gitDates) { itemCount: items.length, items: items, lastUpdated: dates.lastModified || null, - searchText: `${data.name || dir.name} ${ - data.description || "" - } ${tags.join(" ")}`.toLowerCase(), + searchText: `${data.name || dir.name} ${data.description || "" + } ${tags.join(" ")}`.toLowerCase(), }); } catch (e) { console.warn(`Failed to parse plugin: ${dir.name}`, e.message); @@ -704,9 +734,8 @@ function generateSearchIndex( description: instruction.description, path: instruction.path, lastUpdated: instruction.lastUpdated, - searchText: `${instruction.title} ${instruction.description} ${ - instruction.applyTo || "" - }`.toLowerCase(), + searchText: `${instruction.title} ${instruction.description} ${instruction.applyTo || "" + }`.toLowerCase(), }); } @@ -732,9 +761,8 @@ function generateSearchIndex( description: workflow.description, path: workflow.path, lastUpdated: workflow.lastUpdated, - searchText: `${workflow.title} ${ - workflow.description - } ${workflow.triggers.join(" ")}`.toLowerCase(), + searchText: `${workflow.title} ${workflow.description + } ${workflow.triggers.join(" ")}`.toLowerCase(), }); } diff --git a/website/src/scripts/modal.ts b/website/src/scripts/modal.ts index 5472d61bd..4cd5b0ba2 100644 --- a/website/src/scripts/modal.ts +++ b/website/src/scripts/modal.ts @@ -1221,7 +1221,7 @@ function renderLocalPluginModal( switch (itemType) { case "agent": - path = path.replace(".md", ".agent.md"); + // path = path.replace(".md", ".agent.md"); break; case "skill": path = `${path}/SKILL.md`;