From 9a2dbf276b2809139ff42120f6035f7ab2cd3499 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Tue, 3 Feb 2026 14:51:28 +1100 Subject: [PATCH] Move llms.txt generation to Astro endpoint - Create website/src/pages/llms.txt.ts as an Astro static endpoint - Remove generateLlmsTxt function from generate-website-data.mjs - llms.txt is now generated at build time by Astro alongside other pages --- eng/generate-website-data.mjs | 93 ++------------------------------- website/src/pages/llms.txt.ts | 96 +++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 90 deletions(-) create mode 100644 website/src/pages/llms.txt.ts diff --git a/eng/generate-website-data.mjs b/eng/generate-website-data.mjs index 79bdaefc..4a9b895c 100644 --- a/eng/generate-website-data.mjs +++ b/eng/generate-website-data.mjs @@ -26,10 +26,10 @@ import { } from "./yaml-parser.mjs"; const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); -const WEBSITE_DATA_DIR = path.join(ROOT_FOLDER, "website", "public", "data"); -const WEBSITE_SOURCE_DATA_DIR = path.join(ROOT_FOLDER, "website", "data"); +const WEBSITE_DIR = path.join(ROOT_FOLDER, "website"); +const WEBSITE_DATA_DIR = path.join(WEBSITE_DIR, "public", "data"); +const WEBSITE_SOURCE_DATA_DIR = path.join(WEBSITE_DIR, "data"); /** * Ensure the output directory exists @@ -695,84 +695,6 @@ function generateSamplesData() { }; } -/** - * Generate llms.txt content according to the llmstxt.org specification - */ -function generateLlmsTxt(agents, prompts, instructions, skills) { - let content = ""; - - // H1 header (required) - content += "# Awesome GitHub Copilot\n\n"; - - // Summary blockquote (optional but recommended) - content += - "> A community-driven collection of custom agents, prompts, instructions, and skills to enhance GitHub Copilot experiences across various domains, languages, and use cases.\n\n"; - - // Add overview section - content += "## Overview\n\n"; - content += - "This repository provides resources to customize and enhance GitHub Copilot:\n\n"; - content += - "- **Agents**: Specialized GitHub Copilot agents that integrate with MCP servers\n"; - content += - "- **Prompts**: Task-specific prompts for code generation and problem-solving\n"; - content += - "- **Instructions**: Coding standards and best practices applied to specific file patterns\n"; - content += - "- **Skills**: Self-contained folders with instructions and bundled resources for specialized tasks\n\n"; - - // Process Agents - content += "## Agents\n\n"; - for (const agent of agents) { - const description = (agent.description || "No description available").replace(/\s+/g, " ").trim(); - content += `- [${agent.title}](${agent.path}): ${description}\n`; - } - content += "\n"; - - // Process Prompts - content += "## Prompts\n\n"; - for (const prompt of prompts) { - const description = (prompt.description || "No description available").replace(/\s+/g, " ").trim(); - content += `- [${prompt.title}](${prompt.path}): ${description}\n`; - } - content += "\n"; - - // Process Instructions - content += "## Instructions\n\n"; - for (const instruction of instructions) { - const description = (instruction.description || "No description available").replace(/\s+/g, " ").trim(); - content += `- [${instruction.title}](${instruction.path}): ${description}\n`; - } - content += "\n"; - - // Process Skills - content += "## Skills\n\n"; - for (const skill of skills) { - const description = (skill.description || "No description available").replace(/\s+/g, " ").trim(); - content += `- [${skill.title}](${skill.skillFile}): ${description}\n`; - } - content += "\n"; - - // Add documentation links - content += "## Documentation\n\n"; - content += - "- [README.md](README.md): Main documentation and getting started guide\n"; - content += - "- [CONTRIBUTING.md](CONTRIBUTING.md): Guidelines for contributing to this repository\n"; - content += - "- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md): Community standards and expectations\n"; - content += "- [SECURITY.md](SECURITY.md): Security policies and reporting\n"; - content += "- [AGENTS.md](AGENTS.md): Project overview and setup commands\n\n"; - - // Add repository information - content += "## Repository\n\n"; - content += "- **GitHub**: https://github.com/github/awesome-copilot\n"; - content += "- **License**: MIT\n"; - content += "- **Website**: https://github.github.io/awesome-copilot\n"; - - return content; -} - /** * Main function */ @@ -894,15 +816,6 @@ async function main() { ); console.log(`\nāœ“ All data written to website/public/data/`); - - // Generate llms.txt - const llmsTxtContent = generateLlmsTxt(agents, prompts, instructions, skills); - fs.writeFileSync( - path.join(ROOT_FOLDER, "website", "public", "llms.txt"), - llmsTxtContent, - "utf8" - ); - console.log(`āœ“ llms.txt generated with ${agents.length} agents, ${prompts.length} prompts, ${instructions.length} instructions, ${skills.length} skills`); } main().catch((err) => { diff --git a/website/src/pages/llms.txt.ts b/website/src/pages/llms.txt.ts new file mode 100644 index 00000000..cf4ae811 --- /dev/null +++ b/website/src/pages/llms.txt.ts @@ -0,0 +1,96 @@ +import type { APIRoute } from "astro"; +import agentsData from "../../public/data/agents.json"; +import promptsData from "../../public/data/prompts.json"; +import instructionsData from "../../public/data/instructions.json"; +import skillsData from "../../public/data/skills.json"; + +export const GET: APIRoute = () => { + const agents = agentsData.items; + const prompts = promptsData.items; + const instructions = instructionsData.items; + const skills = skillsData.items; + + let content = ""; + + // H1 header (required) + content += "# Awesome GitHub Copilot\n\n"; + + // Summary blockquote (optional but recommended) + content += + "> A community-driven collection of custom agents, prompts, instructions, and skills to enhance GitHub Copilot experiences across various domains, languages, and use cases.\n\n"; + + // Add overview section + content += "## Overview\n\n"; + content += + "This repository provides resources to customize and enhance GitHub Copilot:\n\n"; + content += + "- **Agents**: Specialized GitHub Copilot agents that integrate with MCP servers\n"; + content += + "- **Prompts**: Task-specific prompts for code generation and problem-solving\n"; + content += + "- **Instructions**: Coding standards and best practices applied to specific file patterns\n"; + content += + "- **Skills**: Self-contained folders with instructions and bundled resources for specialized tasks\n\n"; + + // Process Agents + content += "## Agents\n\n"; + for (const agent of agents) { + const description = (agent.description || "No description available") + .replace(/\s+/g, " ") + .trim(); + content += `- [${agent.title}](${agent.path}): ${description}\n`; + } + content += "\n"; + + // Process Prompts + content += "## Prompts\n\n"; + for (const prompt of prompts) { + const description = (prompt.description || "No description available") + .replace(/\s+/g, " ") + .trim(); + content += `- [${prompt.title}](${prompt.path}): ${description}\n`; + } + content += "\n"; + + // Process Instructions + content += "## Instructions\n\n"; + for (const instruction of instructions) { + const description = (instruction.description || "No description available") + .replace(/\s+/g, " ") + .trim(); + content += `- [${instruction.title}](${instruction.path}): ${description}\n`; + } + content += "\n"; + + // Process Skills + content += "## Skills\n\n"; + for (const skill of skills) { + const description = (skill.description || "No description available") + .replace(/\s+/g, " ") + .trim(); + content += `- [${skill.title}](${skill.skillFile}): ${description}\n`; + } + content += "\n"; + + // Add documentation links + content += "## Documentation\n\n"; + content += + "- [README.md](README.md): Main documentation and getting started guide\n"; + content += + "- [CONTRIBUTING.md](CONTRIBUTING.md): Guidelines for contributing to this repository\n"; + content += + "- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md): Community standards and expectations\n"; + content += "- [SECURITY.md](SECURITY.md): Security policies and reporting\n"; + content += + "- [AGENTS.md](AGENTS.md): Project overview and setup commands\n\n"; + + // Add repository information + content += "## Repository\n\n"; + content += "- **GitHub**: https://github.com/github/awesome-copilot\n"; + content += "- **License**: MIT\n"; + content += "- **Website**: https://github.github.io/awesome-copilot\n"; + + return new Response(content, { + headers: { "Content-Type": "text/plain; charset=utf-8" }, + }); +};