Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions eng/generate-website-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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 })),
];
Expand All @@ -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);
Expand Down Expand Up @@ -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(),
});
}

Expand All @@ -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(),
});
}

Expand Down
2 changes: 1 addition & 1 deletion website/src/scripts/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
Loading