Moving a bunch of stuff around to make the file easier to read

This commit is contained in:
Aaron Powell 2025-10-23 16:57:38 +11:00
parent 4ecaab0924
commit 553ef42856
4 changed files with 139 additions and 137 deletions

113
eng/constants.js Normal file
View File

@ -0,0 +1,113 @@
// Template sections for the README
const TEMPLATES = {
instructionsSection: `## 📋 Custom Instructions
Team and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices.`,
instructionsUsage: `### How to Use Custom Instructions
**To Install:**
- Click the **VS Code** or **VS Code Insiders** install button for the instruction you want to use
- Download the \`*.instructions.md\` file and manually add it to your project's instruction collection
**To Use/Apply:**
- Copy these instructions to your \`.github/copilot-instructions.md\` file in your workspace
- Create task-specific \`.github/.instructions.md\` files in your workspace's \`.github/instructions\` folder
- Instructions automatically apply to Copilot behavior once installed in your workspace`,
promptsSection: `## 🎯 Reusable Prompts
Ready-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.`,
promptsUsage: `### How to Use Reusable Prompts
**To Install:**
- Click the **VS Code** or **VS Code Insiders** install button for the prompt you want to use
- Download the \`*.prompt.md\` file and manually add it to your prompt collection
**To Run/Execute:**
- Use \`/prompt-name\` in VS Code chat after installation
- Run the \`Chat: Run Prompt\` command from the Command Palette
- Hit the run button while you have a prompt file open in VS Code`,
chatmodesSection: `## 💭 Custom Chat Modes
Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows.`,
chatmodesUsage: `### How to Use Custom Chat Modes
**To Install:**
- Click the **VS Code** or **VS Code Insiders** install button for the chat mode you want to use
- Download the \`*.chatmode.md\` file and manually install it in VS Code using the Command Palette
**To Activate/Use:**
- Import the chat mode configuration into your VS Code settings
- Access the installed chat modes through the VS Code Chat interface
- Select the desired chat mode from the available options in VS Code Chat`,
collectionsSection: `## 📦 Collections
Curated collections of related prompts, instructions, and chat modes organized around specific themes, workflows, or use cases.`,
collectionsUsage: `### How to Use Collections
**Browse Collections:**
- Featured collections are highlighted and appear at the top of the list
- Explore themed collections that group related customizations
- Each collection includes prompts, instructions, and chat modes for specific workflows
- Collections make it easy to adopt comprehensive toolkits for particular scenarios
**Install Items:**
- Click install buttons for individual items within collections
- Or browse to the individual files to copy content manually
- Collections help you discover related customizations you might have missed`,
featuredCollectionsSection: `## 🌟 Featured Collections
Discover our curated collections of prompts, instructions, and chat modes organized around specific themes and workflows.`,
agentsSection: `## 🤖 Custom Agents
Custom GitHub Copilot agents that integrate with MCP servers to provide enhanced capabilities for specific workflows and tools.`,
agentsUsage: `### How to Use Custom Agents
**To Install:**
- Click the **VS Code** or **VS Code Insiders** install button for the agent you want to use
- Download the \`*.agent.md\` file and manually add it to your repository
**MCP Server Setup:**
- Each agent may require one or more MCP servers to function
- Click the MCP server to view it on the GitHub MCP registry
- Agents will automatically install the MCP servers they need when activated
**To Activate/Use:**
- Access installed agents through the VS Code Chat interface, through Copilot CLI, or assign them in Coding Agent
- Agents will have access to tools from configured MCP servers
- Follow agent-specific instructions for optimal usage`,
};
exports.TEMPLATES = TEMPLATES;
/**
* Generate badges for installation links in VS Code and VS Code Insiders.
* @param {string} link - The relative link to the instructions or prompts file.
* @returns {string} - Markdown formatted badges for installation.
*/
const vscodeInstallImage =
"https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white";
exports.vscodeInstallImage = vscodeInstallImage;
const vscodeInsidersInstallImage =
"https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white";
exports.vscodeInsidersInstallImage = vscodeInsidersInstallImage;
const repoBaseUrl =
"https://raw.githubusercontent.com/github/awesome-copilot/main";
exports.repoBaseUrl = repoBaseUrl;
// Map install types to aka.ms short links. Both VS Code and Insiders will use
// the same aka.ms target; the redirect base (vscode vs insiders) is preserved
// so VS Code or Insiders opens correctly but the installation URL is uniform.
const AKA_INSTALL_URLS = {
instructions: "https://aka.ms/awesome-copilot/install/instructions",
prompt: "https://aka.ms/awesome-copilot/install/prompt",
mode: "https://aka.ms/awesome-copilot/install/chatmode",
agent: "https://aka.ms/awesome-copilot/install/agent",
};
exports.AKA_INSTALL_URLS = AKA_INSTALL_URLS;

View File

@ -6,96 +6,14 @@ const {
parseCollectionYaml, parseCollectionYaml,
extractMcpServers, extractMcpServers,
parseAgentFrontmatter, parseAgentFrontmatter,
} = require("../yaml-parser"); } = require("./yaml-parser");
const {
// Template sections for the README TEMPLATES,
const TEMPLATES = { AKA_INSTALL_URLS,
instructionsSection: `## 📋 Custom Instructions repoBaseUrl,
vscodeInstallImage,
Team and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices.`, vscodeInsidersInstallImage,
} = require("./constants");
instructionsUsage: `### How to Use Custom Instructions
**To Install:**
- Click the **VS Code** or **VS Code Insiders** install button for the instruction you want to use
- Download the \`*.instructions.md\` file and manually add it to your project's instruction collection
**To Use/Apply:**
- Copy these instructions to your \`.github/copilot-instructions.md\` file in your workspace
- Create task-specific \`.github/.instructions.md\` files in your workspace's \`.github/instructions\` folder
- Instructions automatically apply to Copilot behavior once installed in your workspace`,
promptsSection: `## 🎯 Reusable Prompts
Ready-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.`,
promptsUsage: `### How to Use Reusable Prompts
**To Install:**
- Click the **VS Code** or **VS Code Insiders** install button for the prompt you want to use
- Download the \`*.prompt.md\` file and manually add it to your prompt collection
**To Run/Execute:**
- Use \`/prompt-name\` in VS Code chat after installation
- Run the \`Chat: Run Prompt\` command from the Command Palette
- Hit the run button while you have a prompt file open in VS Code`,
chatmodesSection: `## 💭 Custom Chat Modes
Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows.`,
chatmodesUsage: `### How to Use Custom Chat Modes
**To Install:**
- Click the **VS Code** or **VS Code Insiders** install button for the chat mode you want to use
- Download the \`*.chatmode.md\` file and manually install it in VS Code using the Command Palette
**To Activate/Use:**
- Import the chat mode configuration into your VS Code settings
- Access the installed chat modes through the VS Code Chat interface
- Select the desired chat mode from the available options in VS Code Chat`,
collectionsSection: `## 📦 Collections
Curated collections of related prompts, instructions, and chat modes organized around specific themes, workflows, or use cases.`,
collectionsUsage: `### How to Use Collections
**Browse Collections:**
- Featured collections are highlighted and appear at the top of the list
- Explore themed collections that group related customizations
- Each collection includes prompts, instructions, and chat modes for specific workflows
- Collections make it easy to adopt comprehensive toolkits for particular scenarios
**Install Items:**
- Click install buttons for individual items within collections
- Or browse to the individual files to copy content manually
- Collections help you discover related customizations you might have missed`,
featuredCollectionsSection: `## 🌟 Featured Collections
Discover our curated collections of prompts, instructions, and chat modes organized around specific themes and workflows.`,
agentsSection: `## 🤖 Custom Agents
Custom GitHub Copilot agents that integrate with MCP servers to provide enhanced capabilities for specific workflows and tools.`,
agentsUsage: `### How to Use Custom Agents
**To Install:**
- Click the **VS Code** or **VS Code Insiders** install button for the agent you want to use
- Download the \`*.agent.md\` file and manually add it to your repository
**MCP Server Setup:**
- Each agent may require one or more MCP servers to function
- Click the MCP server to view it on the GitHub MCP registry
- Agents will automatically install the MCP servers they need when activated
**To Activate/Use:**
- Access installed agents through the VS Code Chat interface, through Copilot CLI, or assign them in Coding Agent
- Agents will have access to tools from configured MCP servers
- Follow agent-specific instructions for optimal usage`,
};
// Add error handling utility // Add error handling utility
/** /**
@ -343,28 +261,6 @@ function extractDescription(filePath) {
); );
} }
/**
* Generate badges for installation links in VS Code and VS Code Insiders.
* @param {string} link - The relative link to the instructions or prompts file.
* @returns {string} - Markdown formatted badges for installation.
*/
const vscodeInstallImage =
"https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white";
const vscodeInsidersInstallImage =
"https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white";
const repoBaseUrl =
"https://raw.githubusercontent.com/github/awesome-copilot/main";
// Map install types to aka.ms short links. Both VS Code and Insiders will use
// the same aka.ms target; the redirect base (vscode vs insiders) is preserved
// so VS Code or Insiders opens correctly but the installation URL is uniform.
const AKA_INSTALL_URLS = {
instructions: "https://aka.ms/awesome-copilot/install/instructions",
prompt: "https://aka.ms/awesome-copilot/install/prompt",
mode: "https://aka.ms/awesome-copilot/install/chatmode",
agent: "https://aka.ms/awesome-copilot/install/agent",
};
function makeBadges(link, type) { function makeBadges(link, type) {
const aka = AKA_INSTALL_URLS[type] || AKA_INSTALL_URLS.instructions; const aka = AKA_INSTALL_URLS[type] || AKA_INSTALL_URLS.instructions;
@ -827,14 +723,14 @@ function generateCollectionReadme(collection, collectionId) {
const items = [...collection.items]; const items = [...collection.items];
if (collection.display?.ordering === "alpha") { if (collection.display?.ordering === "alpha") {
items.sort((a, b) => { items.sort((a, b) => {
const titleA = extractTitle(path.join(__dirname, a.path)); const titleA = extractTitle(path.join(rootFolder, a.path));
const titleB = extractTitle(path.join(__dirname, b.path)); const titleB = extractTitle(path.join(rootFolder, b.path));
return titleA.localeCompare(titleB); return titleA.localeCompare(titleB);
}); });
} }
for (const item of items) { for (const item of items) {
const filePath = path.join(__dirname, item.path); const filePath = path.join(rootFolder, item.path);
const title = extractTitle(filePath); const title = extractTitle(filePath);
const description = extractDescription(filePath) || "No description"; const description = extractDescription(filePath) || "No description";
@ -953,16 +849,17 @@ function buildCategoryReadme(sectionBuilder, dirPath, headerLine, usageLine) {
return `${headerLine}\n\n${usageLine}\n\n_No entries found yet._`; return `${headerLine}\n\n${usageLine}\n\n_No entries found yet._`;
} }
const rootFolder = path.join(__dirname, "..");
const instructionsDir = path.join(rootFolder, "instructions");
const promptsDir = path.join(rootFolder, "prompts");
const chatmodesDir = path.join(rootFolder, "chatmodes");
const agentsDir = path.join(rootFolder, "agents");
const collectionsDir = path.join(rootFolder, "collections");
// Main execution // Main execution
try { try {
console.log("Generating category README files..."); console.log("Generating category README files...");
const instructionsDir = path.join(__dirname, "instructions");
const promptsDir = path.join(__dirname, "prompts");
const chatmodesDir = path.join(__dirname, "chatmodes");
const agentsDir = path.join(__dirname, "agents");
const collectionsDir = path.join(__dirname, "collections");
// Compose headers for standalone files by converting section headers to H1 // Compose headers for standalone files by converting section headers to H1
const instructionsHeader = TEMPLATES.instructionsSection.replace( const instructionsHeader = TEMPLATES.instructionsSection.replace(
/^##\s/m, /^##\s/m,
@ -1013,17 +910,17 @@ try {
// Write category outputs // Write category outputs
writeFileIfChanged( writeFileIfChanged(
path.join(__dirname, "README.instructions.md"), path.join(rootFolder, "README.instructions.md"),
instructionsReadme instructionsReadme
); );
writeFileIfChanged(path.join(__dirname, "README.prompts.md"), promptsReadme); writeFileIfChanged(path.join(rootFolder, "README.prompts.md"), promptsReadme);
writeFileIfChanged( writeFileIfChanged(
path.join(__dirname, "README.chatmodes.md"), path.join(rootFolder, "README.chatmodes.md"),
chatmodesReadme chatmodesReadme
); );
writeFileIfChanged(path.join(__dirname, "README.agents.md"), agentsReadme); writeFileIfChanged(path.join(rootFolder, "README.agents.md"), agentsReadme);
writeFileIfChanged( writeFileIfChanged(
path.join(__dirname, "README.collections.md"), path.join(rootFolder, "README.collections.md"),
collectionsReadme collectionsReadme
); );
@ -1057,7 +954,7 @@ try {
const featuredSection = generateFeaturedCollectionsSection(collectionsDir); const featuredSection = generateFeaturedCollectionsSection(collectionsDir);
if (featuredSection) { if (featuredSection) {
const mainReadmePath = path.join(__dirname, "README.md"); const mainReadmePath = path.join(rootFolder, "README.md");
if (fs.existsSync(mainReadmePath)) { if (fs.existsSync(mainReadmePath)) {
let readmeContent = fs.readFileSync(mainReadmePath, "utf8"); let readmeContent = fs.readFileSync(mainReadmePath, "utf8");

View File

@ -5,18 +5,10 @@ const path = require("path");
const { const {
parseCollectionYaml, parseCollectionYaml,
parseAgentFrontmatter, parseAgentFrontmatter,
} = require("../yaml-parser"); } = require("./yaml-parser");
// Maximum number of items allowed in a collection // Maximum number of items allowed in a collection
const MAX_COLLECTION_ITEMS = 50; const MAX_COLLECTION_ITEMS = 50;
function safeFileOperation(operation, filePath, defaultValue = null) {
try {
return operation();
} catch (error) {
console.error(`Error processing file ${filePath}: ${error.message}`);
return defaultValue;
}
}
// Validation functions // Validation functions
function validateCollectionId(id) { function validateCollectionId(id) {

View File

@ -5,7 +5,7 @@
"main": "update-readme.js", "main": "update-readme.js",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "node run build", "start": "npm run build",
"build": "node ./eng/update-readme.js", "build": "node ./eng/update-readme.js",
"contributors:add": "all-contributors add", "contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate", "contributors:generate": "all-contributors generate",