Skip to content

Commit 9a2dbf2

Browse files
committed
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
1 parent 42f5dc9 commit 9a2dbf2

2 files changed

Lines changed: 99 additions & 90 deletions

File tree

eng/generate-website-data.mjs

Lines changed: 3 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import {
2626
} from "./yaml-parser.mjs";
2727

2828
const __filename = fileURLToPath(import.meta.url);
29-
const __dirname = dirname(__filename);
3029

31-
const WEBSITE_DATA_DIR = path.join(ROOT_FOLDER, "website", "public", "data");
32-
const WEBSITE_SOURCE_DATA_DIR = path.join(ROOT_FOLDER, "website", "data");
30+
const WEBSITE_DIR = path.join(ROOT_FOLDER, "website");
31+
const WEBSITE_DATA_DIR = path.join(WEBSITE_DIR, "public", "data");
32+
const WEBSITE_SOURCE_DATA_DIR = path.join(WEBSITE_DIR, "data");
3333

3434
/**
3535
* Ensure the output directory exists
@@ -695,84 +695,6 @@ function generateSamplesData() {
695695
};
696696
}
697697

698-
/**
699-
* Generate llms.txt content according to the llmstxt.org specification
700-
*/
701-
function generateLlmsTxt(agents, prompts, instructions, skills) {
702-
let content = "";
703-
704-
// H1 header (required)
705-
content += "# Awesome GitHub Copilot\n\n";
706-
707-
// Summary blockquote (optional but recommended)
708-
content +=
709-
"> 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";
710-
711-
// Add overview section
712-
content += "## Overview\n\n";
713-
content +=
714-
"This repository provides resources to customize and enhance GitHub Copilot:\n\n";
715-
content +=
716-
"- **Agents**: Specialized GitHub Copilot agents that integrate with MCP servers\n";
717-
content +=
718-
"- **Prompts**: Task-specific prompts for code generation and problem-solving\n";
719-
content +=
720-
"- **Instructions**: Coding standards and best practices applied to specific file patterns\n";
721-
content +=
722-
"- **Skills**: Self-contained folders with instructions and bundled resources for specialized tasks\n\n";
723-
724-
// Process Agents
725-
content += "## Agents\n\n";
726-
for (const agent of agents) {
727-
const description = (agent.description || "No description available").replace(/\s+/g, " ").trim();
728-
content += `- [${agent.title}](${agent.path}): ${description}\n`;
729-
}
730-
content += "\n";
731-
732-
// Process Prompts
733-
content += "## Prompts\n\n";
734-
for (const prompt of prompts) {
735-
const description = (prompt.description || "No description available").replace(/\s+/g, " ").trim();
736-
content += `- [${prompt.title}](${prompt.path}): ${description}\n`;
737-
}
738-
content += "\n";
739-
740-
// Process Instructions
741-
content += "## Instructions\n\n";
742-
for (const instruction of instructions) {
743-
const description = (instruction.description || "No description available").replace(/\s+/g, " ").trim();
744-
content += `- [${instruction.title}](${instruction.path}): ${description}\n`;
745-
}
746-
content += "\n";
747-
748-
// Process Skills
749-
content += "## Skills\n\n";
750-
for (const skill of skills) {
751-
const description = (skill.description || "No description available").replace(/\s+/g, " ").trim();
752-
content += `- [${skill.title}](${skill.skillFile}): ${description}\n`;
753-
}
754-
content += "\n";
755-
756-
// Add documentation links
757-
content += "## Documentation\n\n";
758-
content +=
759-
"- [README.md](README.md): Main documentation and getting started guide\n";
760-
content +=
761-
"- [CONTRIBUTING.md](CONTRIBUTING.md): Guidelines for contributing to this repository\n";
762-
content +=
763-
"- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md): Community standards and expectations\n";
764-
content += "- [SECURITY.md](SECURITY.md): Security policies and reporting\n";
765-
content += "- [AGENTS.md](AGENTS.md): Project overview and setup commands\n\n";
766-
767-
// Add repository information
768-
content += "## Repository\n\n";
769-
content += "- **GitHub**: https://github.com/github/awesome-copilot\n";
770-
content += "- **License**: MIT\n";
771-
content += "- **Website**: https://github.github.io/awesome-copilot\n";
772-
773-
return content;
774-
}
775-
776698
/**
777699
* Main function
778700
*/
@@ -894,15 +816,6 @@ async function main() {
894816
);
895817

896818
console.log(`\n✓ All data written to website/public/data/`);
897-
898-
// Generate llms.txt
899-
const llmsTxtContent = generateLlmsTxt(agents, prompts, instructions, skills);
900-
fs.writeFileSync(
901-
path.join(ROOT_FOLDER, "website", "public", "llms.txt"),
902-
llmsTxtContent,
903-
"utf8"
904-
);
905-
console.log(`✓ llms.txt generated with ${agents.length} agents, ${prompts.length} prompts, ${instructions.length} instructions, ${skills.length} skills`);
906819
}
907820

908821
main().catch((err) => {

website/src/pages/llms.txt.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import type { APIRoute } from "astro";
2+
import agentsData from "../../public/data/agents.json";
3+
import promptsData from "../../public/data/prompts.json";
4+
import instructionsData from "../../public/data/instructions.json";
5+
import skillsData from "../../public/data/skills.json";
6+
7+
export const GET: APIRoute = () => {
8+
const agents = agentsData.items;
9+
const prompts = promptsData.items;
10+
const instructions = instructionsData.items;
11+
const skills = skillsData.items;
12+
13+
let content = "";
14+
15+
// H1 header (required)
16+
content += "# Awesome GitHub Copilot\n\n";
17+
18+
// Summary blockquote (optional but recommended)
19+
content +=
20+
"> 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";
21+
22+
// Add overview section
23+
content += "## Overview\n\n";
24+
content +=
25+
"This repository provides resources to customize and enhance GitHub Copilot:\n\n";
26+
content +=
27+
"- **Agents**: Specialized GitHub Copilot agents that integrate with MCP servers\n";
28+
content +=
29+
"- **Prompts**: Task-specific prompts for code generation and problem-solving\n";
30+
content +=
31+
"- **Instructions**: Coding standards and best practices applied to specific file patterns\n";
32+
content +=
33+
"- **Skills**: Self-contained folders with instructions and bundled resources for specialized tasks\n\n";
34+
35+
// Process Agents
36+
content += "## Agents\n\n";
37+
for (const agent of agents) {
38+
const description = (agent.description || "No description available")
39+
.replace(/\s+/g, " ")
40+
.trim();
41+
content += `- [${agent.title}](${agent.path}): ${description}\n`;
42+
}
43+
content += "\n";
44+
45+
// Process Prompts
46+
content += "## Prompts\n\n";
47+
for (const prompt of prompts) {
48+
const description = (prompt.description || "No description available")
49+
.replace(/\s+/g, " ")
50+
.trim();
51+
content += `- [${prompt.title}](${prompt.path}): ${description}\n`;
52+
}
53+
content += "\n";
54+
55+
// Process Instructions
56+
content += "## Instructions\n\n";
57+
for (const instruction of instructions) {
58+
const description = (instruction.description || "No description available")
59+
.replace(/\s+/g, " ")
60+
.trim();
61+
content += `- [${instruction.title}](${instruction.path}): ${description}\n`;
62+
}
63+
content += "\n";
64+
65+
// Process Skills
66+
content += "## Skills\n\n";
67+
for (const skill of skills) {
68+
const description = (skill.description || "No description available")
69+
.replace(/\s+/g, " ")
70+
.trim();
71+
content += `- [${skill.title}](${skill.skillFile}): ${description}\n`;
72+
}
73+
content += "\n";
74+
75+
// Add documentation links
76+
content += "## Documentation\n\n";
77+
content +=
78+
"- [README.md](README.md): Main documentation and getting started guide\n";
79+
content +=
80+
"- [CONTRIBUTING.md](CONTRIBUTING.md): Guidelines for contributing to this repository\n";
81+
content +=
82+
"- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md): Community standards and expectations\n";
83+
content += "- [SECURITY.md](SECURITY.md): Security policies and reporting\n";
84+
content +=
85+
"- [AGENTS.md](AGENTS.md): Project overview and setup commands\n\n";
86+
87+
// Add repository information
88+
content += "## Repository\n\n";
89+
content += "- **GitHub**: https://github.com/github/awesome-copilot\n";
90+
content += "- **License**: MIT\n";
91+
content += "- **Website**: https://github.github.io/awesome-copilot\n";
92+
93+
return new Response(content, {
94+
headers: { "Content-Type": "text/plain; charset=utf-8" },
95+
});
96+
};

0 commit comments

Comments
 (0)