From 553ef42856e645e22a0413294eb5218970c8f425 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 23 Oct 2025 16:57:38 +1100 Subject: [PATCH] Moving a bunch of stuff around to make the file easier to read --- eng/constants.js | 113 +++++++++++++++++++++++++++ eng/update-readme.js | 151 ++++++------------------------------ eng/validate-collections.js | 10 +-- package.json | 2 +- 4 files changed, 139 insertions(+), 137 deletions(-) create mode 100644 eng/constants.js diff --git a/eng/constants.js b/eng/constants.js new file mode 100644 index 0000000..ef9a8e2 --- /dev/null +++ b/eng/constants.js @@ -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; diff --git a/eng/update-readme.js b/eng/update-readme.js index f482e12..4727555 100755 --- a/eng/update-readme.js +++ b/eng/update-readme.js @@ -6,96 +6,14 @@ const { parseCollectionYaml, extractMcpServers, parseAgentFrontmatter, -} = require("../yaml-parser"); - -// 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`, -}; +} = require("./yaml-parser"); +const { + TEMPLATES, + AKA_INSTALL_URLS, + repoBaseUrl, + vscodeInstallImage, + vscodeInsidersInstallImage, +} = require("./constants"); // 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) { const aka = AKA_INSTALL_URLS[type] || AKA_INSTALL_URLS.instructions; @@ -827,14 +723,14 @@ function generateCollectionReadme(collection, collectionId) { const items = [...collection.items]; if (collection.display?.ordering === "alpha") { items.sort((a, b) => { - const titleA = extractTitle(path.join(__dirname, a.path)); - const titleB = extractTitle(path.join(__dirname, b.path)); + const titleA = extractTitle(path.join(rootFolder, a.path)); + const titleB = extractTitle(path.join(rootFolder, b.path)); return titleA.localeCompare(titleB); }); } for (const item of items) { - const filePath = path.join(__dirname, item.path); + const filePath = path.join(rootFolder, item.path); const title = extractTitle(filePath); 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._`; } +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 try { 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 const instructionsHeader = TEMPLATES.instructionsSection.replace( /^##\s/m, @@ -1013,17 +910,17 @@ try { // Write category outputs writeFileIfChanged( - path.join(__dirname, "README.instructions.md"), + path.join(rootFolder, "README.instructions.md"), instructionsReadme ); - writeFileIfChanged(path.join(__dirname, "README.prompts.md"), promptsReadme); + writeFileIfChanged(path.join(rootFolder, "README.prompts.md"), promptsReadme); writeFileIfChanged( - path.join(__dirname, "README.chatmodes.md"), + path.join(rootFolder, "README.chatmodes.md"), chatmodesReadme ); - writeFileIfChanged(path.join(__dirname, "README.agents.md"), agentsReadme); + writeFileIfChanged(path.join(rootFolder, "README.agents.md"), agentsReadme); writeFileIfChanged( - path.join(__dirname, "README.collections.md"), + path.join(rootFolder, "README.collections.md"), collectionsReadme ); @@ -1057,7 +954,7 @@ try { const featuredSection = generateFeaturedCollectionsSection(collectionsDir); if (featuredSection) { - const mainReadmePath = path.join(__dirname, "README.md"); + const mainReadmePath = path.join(rootFolder, "README.md"); if (fs.existsSync(mainReadmePath)) { let readmeContent = fs.readFileSync(mainReadmePath, "utf8"); diff --git a/eng/validate-collections.js b/eng/validate-collections.js index 579eb92..34ecd15 100755 --- a/eng/validate-collections.js +++ b/eng/validate-collections.js @@ -5,18 +5,10 @@ const path = require("path"); const { parseCollectionYaml, parseAgentFrontmatter, -} = require("../yaml-parser"); +} = require("./yaml-parser"); // Maximum number of items allowed in a collection 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 function validateCollectionId(id) { diff --git a/package.json b/package.json index 8fc3de7..bd01d47 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "update-readme.js", "private": true, "scripts": { - "start": "node run build", + "start": "npm run build", "build": "node ./eng/update-readme.js", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate",