* Generate agents metadata
(gitDates)
| 155 | * Generate agents metadata |
| 156 | */ |
| 157 | function generateAgentsData(gitDates) { |
| 158 | const agents = []; |
| 159 | const files = fs |
| 160 | .readdirSync(AGENTS_DIR) |
| 161 | .filter((f) => f.endsWith(".agent.md")); |
| 162 | |
| 163 | // Track all unique values for filters |
| 164 | const allModels = new Set(); |
| 165 | const allTools = new Set(); |
| 166 | |
| 167 | for (const file of files) { |
| 168 | const filePath = path.join(AGENTS_DIR, file); |
| 169 | const frontmatter = parseFrontmatter(filePath); |
| 170 | const relativePath = path |
| 171 | .relative(ROOT_FOLDER, filePath) |
| 172 | .replace(/\\/g, "/"); |
| 173 | |
| 174 | const model = frontmatter?.model || null; |
| 175 | const tools = frontmatter?.tools || []; |
| 176 | const handoffs = frontmatter?.handoffs || []; |
| 177 | |
| 178 | // Track unique values |
| 179 | if (model) allModels.add(model); |
| 180 | tools.forEach((t) => allTools.add(t)); |
| 181 | |
| 182 | agents.push({ |
| 183 | id: file.replace(".agent.md", ""), |
| 184 | title: extractTitle(filePath, frontmatter), |
| 185 | description: frontmatter?.description || "", |
| 186 | model: model, |
| 187 | tools: tools, |
| 188 | hasHandoffs: handoffs.length > 0, |
| 189 | handoffs: handoffs.map((h) => ({ |
| 190 | label: h.label || "", |
| 191 | agent: h.agent || "", |
| 192 | })), |
| 193 | mcpServers: frontmatter?.["mcp-servers"] |
| 194 | ? Object.keys(frontmatter["mcp-servers"]) |
| 195 | : [], |
| 196 | path: relativePath, |
| 197 | filename: file, |
| 198 | lastUpdated: gitDates.get(relativePath) || null, |
| 199 | }); |
| 200 | } |
| 201 | |
| 202 | // Sort and return with filter metadata |
| 203 | const sortedAgents = agents.sort((a, b) => a.title.localeCompare(b.title)); |
| 204 | |
| 205 | return { |
| 206 | items: sortedAgents, |
| 207 | filters: { |
| 208 | models: ["(none)", ...Array.from(allModels).sort()], |
| 209 | tools: Array.from(allTools).sort(), |
| 210 | }, |
| 211 | }; |
| 212 | } |
| 213 | |
| 214 | /** |
no test coverage detected