Update documentation and prompts for consistency and clarity
- Standardized description formatting in various markdown files to use single quotes. - Added error handling utility in update-readme.js for safer file operations. - Improved title extraction logic in update-readme.js to handle frontmatter more robustly. - Updated chat modes section in README to reflect new emoji and sorted chat mode links. - Cleaned up various instruction files for better readability and consistency. - Ensured all markdown files end with a newline for better compatibility with version control.
This commit is contained in:
parent
a0754dd249
commit
17405dfc54
15
README.md
15
README.md
@ -68,18 +68,15 @@ Ready-to-use prompt templates for specific development scenarios and tasks, defi
|
|||||||
|
|
||||||
> 💡 **Usage**: Use `/prompt-name` in VS Code chat, run `Chat: Run Prompt` command, or hit the run button while you have a prompt open.
|
> 💡 **Usage**: Use `/prompt-name` in VS Code chat, run `Chat: Run Prompt` command, or hit the run button while you have a prompt open.
|
||||||
|
|
||||||
## 🧩 Custom Chat Modes
|
## 🎭 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.
|
Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows.
|
||||||
|
|
||||||
- [4.1 Beast Mode](chatmodes/4.1-beast.chatmode.md) - A custom prompt to get GPT 4.1 to behave like a top-notch coding agent.
|
- [4.1 Beast Mode](chatmodes/4.1-beast.chatmode.md)
|
||||||
- [Database Administrator Chat Mode](chatmodes/postgresql-dba.chatmode.md) - Work with PostgreSQL databases using the PostgreSQL extension.
|
- [Debug Mode Instructions](chatmodes/debug.chatmode.md)
|
||||||
- [Debug Mode Instructions](chatmodes/debug.chatmode.md) - Debug your application to find and fix a bug
|
- [Planning mode instructions](chatmodes/planner.chatmode.md)
|
||||||
- [Planning mode instructions](chatmodes/planner.chatmode.md) - Generate an implementation plan for new features or refactoring existing code.
|
- [Database Administrator Chat Mode](chatmodes/postgresql-dba.chatmode.md)
|
||||||
- [Refine Requirement or Issue Chat Mode](chatmodes/refine-issue.chatmode.md) - Refine the requirement or issue with Acceptance Criteria, Technical Considerations, Edge Cases, and NFRs
|
- [Refine Requirement or Issue Chat Mode](chatmodes/refine-issue.chatmode.md)
|
||||||
|
|
||||||
|
|
||||||
> 💡 **Usage**: Create new chat modes using the command `Chat: Configure Chat Modes...`, then switch your chat mode in the Chat input from _Agent_ or _Ask_ to your own mode.
|
|
||||||
|
|
||||||
## 📚 Additional Resources
|
## 📚 Additional Resources
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
description: Debug your application to find and fix a bug
|
description: 'Debug your application to find and fix a bug'
|
||||||
tools: ['codebase', 'readFiles', 'editFiles', 'githubRepo', 'runCommands', 'fetch', 'search', 'usages', 'findTestFiles', 'get_errors', 'test_failure', 'run_in_terminal', 'get_terminal_output']
|
tools: ['codebase', 'readFiles', 'editFiles', 'githubRepo', 'runCommands', 'fetch', 'search', 'usages', 'findTestFiles', 'get_errors', 'test_failure', 'run_in_terminal', 'get_terminal_output']
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
description: Generate an implementation plan for new features or refactoring existing code.
|
description: 'Generate an implementation plan for new features or refactoring existing code.'
|
||||||
tools: ['codebase', 'fetch', 'findTestFiles', 'githubRepo', 'search', 'usages']
|
tools: ['codebase', 'fetch', 'findTestFiles', 'githubRepo', 'search', 'usages']
|
||||||
---
|
---
|
||||||
# Planning mode instructions
|
# Planning mode instructions
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Angular-specific coding standards and best practices
|
description: 'Angular-specific coding standards and best practices'
|
||||||
applyTo: "**/*.ts, **/*.html, **/*.scss, **/*.css"
|
applyTo: '**/*.ts, **/*.html, **/*.scss, **/*.css'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Angular Development Instructions
|
# Angular Development Instructions
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Guidelines for building REST APIs with ASP.NET
|
description: 'Guidelines for building REST APIs with ASP.NET'
|
||||||
applyTo: "**/*.cs, **/*.json"
|
applyTo: '**/*.cs, **/*.json'
|
||||||
---
|
---
|
||||||
|
|
||||||
# ASP.NET REST API Development
|
# ASP.NET REST API Development
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: TypeScript patterns for Azure Functions
|
description: 'TypeScript patterns for Azure Functions'
|
||||||
applyTo: "**/*.ts, **/*.js, **/*.json"
|
applyTo: '**/*.ts, **/*.js, **/*.json'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Guidance for Code Generation
|
## Guidance for Code Generation
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Infrastructure as Code with Bicep
|
description: 'Infrastructure as Code with Bicep'
|
||||||
applyTo: "**/*.bicep"
|
applyTo: '**/*.bicep'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Naming Conventions
|
## Naming Conventions
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Blazor component and application patterns
|
description: 'Blazor component and application patterns'
|
||||||
applyTo: "**/*.razor, **/*.razor.cs, **/*.razor.css"
|
applyTo: '**/*.razor, **/*.razor.cs, **/*.razor.css'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Blazor Code Style and Structure
|
## Blazor Code Style and Structure
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: C++ project configuration and package management
|
description: 'C++ project configuration and package management'
|
||||||
applyTo: "**/*.cmake, **/CMakeLists.txt, **/*.cpp, **/*.h, **/*.hpp"
|
applyTo: '**/*.cmake, **/CMakeLists.txt, **/*.cpp, **/*.h, **/*.hpp'
|
||||||
---
|
---
|
||||||
|
|
||||||
This project uses vcpkg in manifest mode. Please keep this in mind when giving vcpkg suggestions. Do not provide suggestions like vcpkg install library, as they will not work as expected.
|
This project uses vcpkg in manifest mode. Please keep this in mind when giving vcpkg suggestions. Do not provide suggestions like vcpkg install library, as they will not work as expected.
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Guidelines for building C# applications
|
description: 'Guidelines for building C# applications'
|
||||||
applyTo: "**/*.cs"
|
applyTo: '**/*.cs'
|
||||||
---
|
---
|
||||||
|
|
||||||
# C# Development
|
# C# Development
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
---
|
---
|
||||||
description: .NET MAUI component and application patterns
|
description: '.NET MAUI component and application patterns'
|
||||||
applyTo: "**/*.xaml, **/*.cs"
|
applyTo: '**/*.xaml, **/*.cs'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
# .NET MAUI
|
||||||
|
|
||||||
## .NET MAUI Code Style and Structure
|
## .NET MAUI Code Style and Structure
|
||||||
|
|
||||||
- Write idiomatic and efficient .NET MAUI and C# code.
|
- Write idiomatic and efficient .NET MAUI and C# code.
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: AI-powered script generation guidelines
|
description: 'AI-powered script generation guidelines'
|
||||||
applyTo: "**/*.genai.*"
|
applyTo: '**/*.genai.*'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Role
|
## Role
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Guidelines for generating modern Terraform code for Azure
|
description: 'Guidelines for generating modern Terraform code for Azure'
|
||||||
applyTo: "**/*.tf"
|
applyTo: '**/*.tf'
|
||||||
---
|
---
|
||||||
|
|
||||||
## 1. Use Latest Terraform and Providers
|
## 1. Use Latest Terraform and Providers
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Guidelines for localizing markdown documents
|
description: 'Guidelines for localizing markdown documents'
|
||||||
applyTo: "**/*.md"
|
applyTo: '**/*.md'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Guidance for Localization
|
# Guidance for Localization
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Documentation and content creation standards
|
description: 'Documentation and content creation standards'
|
||||||
applyTo: "**/*.md"
|
applyTo: '**/*.md'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Markdown Content Rules
|
## Markdown Content Rules
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Next.js + Tailwind development standards and instructions
|
description: 'Next.js + Tailwind development standards and instructions'
|
||||||
applyTo: "**/*.tsx, **/*.ts, **/*.jsx, **/*.js, **/*.css"
|
applyTo: '**/*.tsx, **/*.ts, **/*.jsx, **/*.js, **/*.css'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Next.js + Tailwind Development Instructions
|
# Next.js + Tailwind Development Instructions
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Python coding conventions and guidelines
|
description: 'Python coding conventions and guidelines'
|
||||||
applyTo: "**/*.py"
|
applyTo: '**/*.py'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Python Coding Conventions
|
# Python Coding Conventions
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems']
|
||||||
description: "Create ASP.NET Minimal API endpoints with proper OpenAPI documentation"
|
description: 'Create ASP.NET Minimal API endpoints with proper OpenAPI documentation'
|
||||||
---
|
---
|
||||||
|
|
||||||
Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive OpenAPI/Swagger documentation.
|
Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive OpenAPI/Swagger documentation.
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
mode: agent
|
mode: 'agent'
|
||||||
description: Analyze Azure resources used in the app (IaC files and/or resources in a target rg) and optimize costs - creating GitHub issues for identified optimizations.
|
description: 'Analyze Azure resources used in the app (IaC files and/or resources in a target rg) and optimize costs - creating GitHub issues for identified optimizations.'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems']
|
||||||
description: "Get best practices for C# async programming"
|
description: 'Get best practices for C# async programming'
|
||||||
---
|
---
|
||||||
|
|
||||||
# C# Async Programming Best Practices
|
# C# Async Programming Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems']
|
||||||
description: "Ensure that C# types are documented with XML comments and follow best practices for documentation."
|
description: 'Ensure that C# types are documented with XML comments and follow best practices for documentation.'
|
||||||
---
|
---
|
||||||
|
|
||||||
# C# Documentation Best Practices
|
# C# Documentation Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems", "search"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems', 'search']
|
||||||
description: "Get best practices for MSTest unit testing, including data-driven tests"
|
description: 'Get best practices for MSTest unit testing, including data-driven tests'
|
||||||
---
|
---
|
||||||
|
|
||||||
# MSTest Best Practices
|
# MSTest Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems", "search"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems', 'search']
|
||||||
description: "Get best practices for NUnit unit testing, including data-driven tests"
|
description: 'Get best practices for NUnit unit testing, including data-driven tests'
|
||||||
---
|
---
|
||||||
|
|
||||||
# NUnit Best Practices
|
# NUnit Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems", "search"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems', 'search']
|
||||||
description: "Get best practices for XUnit unit testing, including data-driven tests"
|
description: 'Get best practices for XUnit unit testing, including data-driven tests'
|
||||||
---
|
---
|
||||||
|
|
||||||
# XUnit Best Practices
|
# XUnit Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems", "runCommands"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems', 'runCommands']
|
||||||
description: "Get best practices for Entity Framework Core"
|
description: 'Get best practices for Entity Framework Core'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Entity Framework Core Best Practices
|
# Entity Framework Core Best Practices
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
description: "Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns."
|
description: 'Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.'
|
||||||
---
|
---
|
||||||
|
|
||||||
### Test Structure
|
### Test Structure
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["codebase"]
|
tools: ['codebase']
|
||||||
description: "Create optimized multi-stage Dockerfiles for any language or framework"
|
description: 'Create optimized multi-stage Dockerfiles for any language or framework'
|
||||||
---
|
---
|
||||||
|
|
||||||
Your goal is to help me create efficient multi-stage Dockerfiles that follow best practices, resulting in smaller, more secure container images.
|
Your goal is to help me create efficient multi-stage Dockerfiles that follow best practices, resulting in smaller, more secure container images.
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: agent
|
mode: 'agent'
|
||||||
tools: ['githubRepo', 'github', 'get_issue', 'get_issue_comments', 'get_me', 'list_issues']
|
tools: ['githubRepo', 'github', 'get_issue', 'get_issue_comments', 'get_me', 'list_issues']
|
||||||
description: "List my issues in the current repository"
|
description: 'List my issues in the current repository'
|
||||||
---
|
---
|
||||||
|
|
||||||
Search the current repo (using #githubRepo for the repo info) and list any issues you find (using #list_issues) that are assigned to me.
|
Search the current repo (using #githubRepo for the repo info) and list any issues you find (using #list_issues) that are assigned to me.
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: agent
|
mode: 'agent'
|
||||||
tools: ['githubRepo', 'github', 'get_me', 'get_pull_request', 'get_pull_request_comments', 'get_pull_request_diff', 'get_pull_request_files', 'get_pull_request_reviews', 'get_pull_request_status', 'list_pull_requests', 'request_copilot_review']
|
tools: ['githubRepo', 'github', 'get_me', 'get_pull_request', 'get_pull_request_comments', 'get_pull_request_diff', 'get_pull_request_files', 'get_pull_request_reviews', 'get_pull_request_status', 'list_pull_requests', 'request_copilot_review']
|
||||||
description: "List my pull requests in the current repository"
|
description: 'List my pull requests in the current repository'
|
||||||
---
|
---
|
||||||
|
|
||||||
Search the current repo (using #githubRepo for the repo info) and list any pull requests you find (using #list_pull_requests) that are assigned to me.
|
Search the current repo (using #githubRepo for the repo info) and list any pull requests you find (using #list_pull_requests) that are assigned to me.
|
||||||
|
|||||||
121
standardize-frontmatter.js
Normal file
121
standardize-frontmatter.js
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
function standardizeFrontmatter(content) {
|
||||||
|
const lines = content.split('\n');
|
||||||
|
const result = [];
|
||||||
|
let inFrontmatter = false;
|
||||||
|
let frontmatterEnded = false;
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.trim() === '---') {
|
||||||
|
if (!inFrontmatter) {
|
||||||
|
inFrontmatter = true;
|
||||||
|
result.push(line);
|
||||||
|
} else if (!frontmatterEnded) {
|
||||||
|
frontmatterEnded = true;
|
||||||
|
result.push(line);
|
||||||
|
} else {
|
||||||
|
result.push(line);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inFrontmatter && !frontmatterEnded) {
|
||||||
|
// Convert frontmatter fields to use single quotes
|
||||||
|
let modifiedLine = line;
|
||||||
|
|
||||||
|
// Handle fields that should use single quotes for strings
|
||||||
|
const fieldsToStandardize = ['mode', 'description', 'applyTo', 'title'];
|
||||||
|
|
||||||
|
for (const field of fieldsToStandardize) {
|
||||||
|
// Pattern 1: Convert double quotes to single quotes
|
||||||
|
const doubleQuotePattern = new RegExp(`^(${field}:\\s*)"([^"]*)"(\\s*)$`);
|
||||||
|
const doubleQuoteMatch = modifiedLine.match(doubleQuotePattern);
|
||||||
|
if (doubleQuoteMatch) {
|
||||||
|
modifiedLine = `${doubleQuoteMatch[1]}'${doubleQuoteMatch[2]}'${doubleQuoteMatch[3]}`;
|
||||||
|
continue; // Skip to next field if we found a match
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pattern 2: Fix double single quotes (''text'') to single quotes
|
||||||
|
const doubleSingleQuotePattern = new RegExp(`^(${field}:\\s*)''([^']*?)''(\\s*)$`);
|
||||||
|
const doubleSingleQuoteMatch = modifiedLine.match(doubleSingleQuotePattern);
|
||||||
|
if (doubleSingleQuoteMatch) {
|
||||||
|
modifiedLine = `${doubleSingleQuoteMatch[1]}'${doubleSingleQuoteMatch[2]}'${doubleSingleQuoteMatch[3]}`;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pattern 3: Fix missing space after colon (field:value -> field: value)
|
||||||
|
const noSpacePattern = new RegExp(`^(${field}:)([^\\s])`);
|
||||||
|
const noSpaceMatch = modifiedLine.match(noSpacePattern);
|
||||||
|
if (noSpaceMatch) {
|
||||||
|
modifiedLine = modifiedLine.replace(noSpacePattern, `${noSpaceMatch[1]} ${noSpaceMatch[2]}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pattern 4: Add single quotes to unquoted values (but not arrays or objects)
|
||||||
|
const unquotedPattern = new RegExp(`^(${field}:\\s*)([^'\"\\[\\{][^\\n]*?)(\\s*)$`);
|
||||||
|
const unquotedMatch = modifiedLine.match(unquotedPattern);
|
||||||
|
if (unquotedMatch) {
|
||||||
|
const value = unquotedMatch[2].trim();
|
||||||
|
// Only quote if it's not already quoted and not empty
|
||||||
|
if (value && !value.startsWith('[') && !value.startsWith('{')) {
|
||||||
|
modifiedLine = `${unquotedMatch[1]}'${value}'${unquotedMatch[3]}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle tools array - convert double quotes to single quotes within the array
|
||||||
|
if (modifiedLine.includes('tools:')) {
|
||||||
|
modifiedLine = modifiedLine.replace(/"/g, "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
result.push(modifiedLine);
|
||||||
|
} else {
|
||||||
|
result.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
function processFiles() {
|
||||||
|
const directories = ['prompts', 'instructions', 'chatmodes'];
|
||||||
|
let filesProcessed = 0;
|
||||||
|
|
||||||
|
for (const dir of directories) {
|
||||||
|
const dirPath = path.join(__dirname, dir);
|
||||||
|
|
||||||
|
if (!fs.existsSync(dirPath)) {
|
||||||
|
console.log(`Directory ${dir} does not exist, skipping...`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = fs.readdirSync(dirPath);
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
if (file.endsWith('.md')) {
|
||||||
|
const filePath = path.join(dirPath, file);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const content = fs.readFileSync(filePath, 'utf8');
|
||||||
|
const standardizedContent = standardizeFrontmatter(content);
|
||||||
|
|
||||||
|
// Only write if content has changed
|
||||||
|
if (content !== standardizedContent) {
|
||||||
|
fs.writeFileSync(filePath, standardizedContent);
|
||||||
|
console.log(`Standardized frontmatter in: ${filePath}`);
|
||||||
|
filesProcessed++;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error processing ${filePath}: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\nProcessed ${filesProcessed} files.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
processFiles();
|
||||||
@ -3,8 +3,19 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
function extractTitle(filePath) {
|
// Add error handling utility
|
||||||
|
function safeFileOperation(operation, filePath, defaultValue = null) {
|
||||||
try {
|
try {
|
||||||
|
return operation();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error processing file ${filePath}: ${error.message}`);
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractTitle(filePath) {
|
||||||
|
return safeFileOperation(
|
||||||
|
() => {
|
||||||
const content = fs.readFileSync(filePath, "utf8");
|
const content = fs.readFileSync(filePath, "utf8");
|
||||||
const lines = content.split("\n");
|
const lines = content.split("\n");
|
||||||
|
|
||||||
@ -24,9 +35,12 @@ function extractTitle(filePath) {
|
|||||||
|
|
||||||
if (inFrontmatter && !frontmatterEnded) {
|
if (inFrontmatter && !frontmatterEnded) {
|
||||||
// Look for title field in frontmatter
|
// Look for title field in frontmatter
|
||||||
const titleMatch = line.match(/^title:\s*['"]?(.+?)['"]?$/);
|
if (line.includes('title:')) {
|
||||||
if (titleMatch) {
|
// Extract everything after 'title:'
|
||||||
return titleMatch[1].trim();
|
const afterTitle = line.substring(line.indexOf('title:') + 6).trim();
|
||||||
|
// Remove quotes if present
|
||||||
|
const cleanTitle = afterTitle.replace(/^['"]|['"]$/g, '');
|
||||||
|
return cleanTitle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,17 +88,17 @@ function extractTitle(filePath) {
|
|||||||
return basename
|
return basename
|
||||||
.replace(/[-_]/g, " ")
|
.replace(/[-_]/g, " ")
|
||||||
.replace(/\b\w/g, (l) => l.toUpperCase());
|
.replace(/\b\w/g, (l) => l.toUpperCase());
|
||||||
} catch (error) {
|
},
|
||||||
// Fallback to filename
|
filePath,
|
||||||
const basename = path.basename(filePath, path.extname(filePath));
|
path.basename(filePath, path.extname(filePath))
|
||||||
return basename
|
|
||||||
.replace(/[-_]/g, " ")
|
.replace(/[-_]/g, " ")
|
||||||
.replace(/\b\w/g, (l) => l.toUpperCase());
|
.replace(/\b\w/g, (l) => l.toUpperCase())
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractDescription(filePath) {
|
function extractDescription(filePath) {
|
||||||
try {
|
return safeFileOperation(
|
||||||
|
() => {
|
||||||
const content = fs.readFileSync(filePath, "utf8");
|
const content = fs.readFileSync(filePath, "utf8");
|
||||||
|
|
||||||
// Parse frontmatter for description (for both prompts and instructions)
|
// Parse frontmatter for description (for both prompts and instructions)
|
||||||
@ -147,9 +161,10 @@ function extractDescription(filePath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (error) {
|
},
|
||||||
return null;
|
filePath,
|
||||||
}
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInstructionsSection(
|
function updateInstructionsSection(
|
||||||
@ -391,15 +406,15 @@ function updateChatModesSection(currentReadme, chatmodeFiles, chatmodesDir) {
|
|||||||
console.log(`Found ${newChatModeFiles.length} new chat modes to add.`);
|
console.log(`Found ${newChatModeFiles.length} new chat modes to add.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const chatmodesSection = currentReadme.match(
|
// Look for ANY existing chat modes section (with any emoji)
|
||||||
/## 🧩 Custom Chat Modes\n\nCustom chat modes define.+?(?=\n\n>)/s
|
const chatmodesSectionRegex = /## [🧩🎭].*Custom Chat Modes[\s\S]*?(?=\n## |\n\n## |$)/;
|
||||||
);
|
const chatmodesSection = currentReadme.match(chatmodesSectionRegex);
|
||||||
|
|
||||||
if (chatmodesSection) {
|
if (chatmodesSection) {
|
||||||
let chatmodesListContent = "\n\n";
|
let chatmodesListContent = "\n\n";
|
||||||
|
|
||||||
// Generate list of chat mode links
|
// Generate list of chat mode links (sorted alphabetically)
|
||||||
for (const file of chatmodeFiles) {
|
for (const file of chatmodeFiles.sort()) {
|
||||||
const filePath = path.join(chatmodesDir, file);
|
const filePath = path.join(chatmodesDir, file);
|
||||||
const title = extractTitle(filePath);
|
const title = extractTitle(filePath);
|
||||||
const link = encodeURI(`chatmodes/${file}`);
|
const link = encodeURI(`chatmodes/${file}`);
|
||||||
@ -418,7 +433,7 @@ function updateChatModesSection(currentReadme, chatmodeFiles, chatmodesDir) {
|
|||||||
|
|
||||||
// Replace the current chat modes section with the updated one
|
// Replace the current chat modes section with the updated one
|
||||||
const newChatmodesSection =
|
const newChatmodesSection =
|
||||||
"## 🧩 Custom Chat Modes\n\nCustom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows." +
|
"## 🎭 Custom Chat Modes\n\nCustom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows." +
|
||||||
chatmodesListContent;
|
chatmodesListContent;
|
||||||
|
|
||||||
return currentReadme.replace(chatmodesSection[0], newChatmodesSection);
|
return currentReadme.replace(chatmodesSection[0], newChatmodesSection);
|
||||||
@ -429,6 +444,7 @@ function updateChatModesSection(currentReadme, chatmodeFiles, chatmodesDir) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const chatmodesListContent = chatmodeFiles
|
const chatmodesListContent = chatmodeFiles
|
||||||
|
.sort()
|
||||||
.map((file) => {
|
.map((file) => {
|
||||||
const filePath = path.join(chatmodesDir, file);
|
const filePath = path.join(chatmodesDir, file);
|
||||||
const title = extractTitle(filePath);
|
const title = extractTitle(filePath);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user