File size: 116,010 Bytes
bc21fc6 |
1 2 3 4 5 6 |
{"repo_name": "awesome-copilot", "file_name": "/awesome-copilot/update-readme.js", "inference_info": {"prefix_code": "#!/usr/bin/env node\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\n// Template sections for the README\nconst TEMPLATES = {\n header: `# π€ Awesome GitHub Copilot Customizations\n\nEnhance your GitHub Copilot experience with community-contributed instructions, prompts, and configurations. Get consistent AI assistance that follows your team's coding standards and project requirements.\n\n## π― GitHub Copilot Customization Features\n\nGitHub Copilot provides three main ways to customize AI responses and tailor assistance to your specific workflows, team guidelines, and project requirements:\n\n| **π [Custom Instructions](#-custom-instructions)** | **π― [Reusable Prompts](#-reusable-prompts)** | **π§© [Custom Chat Modes](#-custom-chat-modes)** |\n| --- | --- | --- |\n| Define common guidelines for tasks like code generation, reviews, and commit messages. Describe *how* tasks should be performed<br><br>**Benefits:**<br>β’ Automatic inclusion in every chat request<br>β’ Repository-wide consistency<br>β’ Multiple implementation options | Create reusable, standalone prompts for specific tasks. Describe *what* should be done with optional task-specific guidelines<br><br>**Benefits:**<br>β’ Eliminate repetitive prompt writing<br>β’ Shareable across teams<br>β’ Support for variables and dependencies | Define chat behavior, available tools, and codebase interaction patterns within specific boundaries for each request<br><br>**Benefits:**<br>β’ Context-aware assistance<br>β’ Tool configuration<br>β’ Role-specific workflows |\n\n> **π‘ Pro Tip:** Custom instructions only affect Copilot Chat (not inline code completions). You can combine all three customization types - use custom instructions for general guidelines, prompt files for specific tasks, and chat modes to control the interaction context.\n\n\n## π Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details on how to submit new instructions and prompts.`,\n\n instructionsSection: `## π Custom Instructions\n\nTeam and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:`,\n\n instructionsUsage: `> π‘ **Usage**: Copy these instructions to your \\`.github/copilot-instructions.md\\` file or create task-specific \\`.github/.instructions.md\\` files in your workspace's \\`.github/instructions\\` folder.`,\n\n promptsSection: `## π― Reusable Prompts\n\nReady-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.`,\n\n promptsUsage: `> π‘ **Usage**: Use \\`/prompt-name\\` in VS Code chat, run \\`Chat: Run Prompt\\` command, or hit the run button while you have a prompt open.`,\n\n chatmodesSection: `## π§© 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.`,\n\n chatmodesUsage: `> π‘ **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.`,\n\n footer: `## π Additional Resources\n\n- [VS Code Copilot Customization Documentation](https://code.visualstudio.com/docs/copilot/copilot-customization) - Official Microsoft documentation\n- [GitHub Copilot Chat Documentation](https://code.visualstudio.com/docs/copilot/chat/copilot-chat) - Complete chat feature guide\n- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration\n- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide\n\n## π οΈ Development Configuration\n\nThis repository uses various configuration files to ensure consistent code style and avoid issues with line endings:\n\n- [\\`.editorconfig\\`](.editorconfig) - Defines coding styles across different editors and IDEs\n- [\\`.gitattributes\\`](.gitattributes) - Ensures consistent line endings in text files\n- [\\`.vscode/settings.json\\`](.vscode/settings.json) - VS Code-specific settings for this repository\n- [\\`.vscode/extensions.json\\`](.vscode/extensions.json) - Recommended VS Code extensions\n\n> π‘ **Note**: All markdown files in this repository use LF line endings (Unix-style) to avoid mixed line endings issues. The repository is configured to automatically handle line endings conversion.\n\n## π License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## π€ Code of Conduct\n\nPlease note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n\n## β’οΈ Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.`,\n};\n\n// Add error handling utility\nfunction safeFileOperation(operation, filePath, defaultValue = null) {\n try {\n return operation();\n } catch (error) {\n console.error(`Error processing file ${filePath}: ${error.message}`);\n return defaultValue;\n }\n}\n\nfunction extractTitle(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n\n // Step 1: Look for title in frontmatter for all file types\n let inFrontmatter = false;\n let frontmatterEnded = false;\n\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (!frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n\n if (inFrontmatter && !frontmatterEnded) {\n // Look for title field in frontmatter\n if (line.includes(\"title:\")) {\n // Extract everything after 'title:'\n const afterTitle = line\n .substring(line.indexOf(\"title:\") + 6)\n .trim();\n // Remove quotes if present\n const cleanTitle = afterTitle.replace(/^['\"]|['\"]$/g, \"\");\n return cleanTitle;\n }\n }\n }\n\n // Reset for second pass\n inFrontmatter = false;\n frontmatterEnded = false;\n\n // Step 2: For prompt/chatmode/instructions files, look for heading after frontmatter\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".chatmode.md\") ||\n filePath.includes(\".instructions.md\")\n ) {\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (inFrontmatter && !frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n\n if (frontmatterEnded && line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n\n // Step 3: Format filename for prompt/chatmode/instructions files if no heading found\n const basename = path.basename(\n filePath,\n filePath.includes(\".prompt.md\")\n ? \".prompt.md\"\n : filePath.includes(\".chatmode.md\")\n ? \".chatmode.md\"\n : \".instructions.md\"\n );\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n\n // Step 4: For instruction files, look for the first heading\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n\n // Step 5: Fallback to filename\n const basename = path.basename(filePath, path.extname(filePath));\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n },\n filePath,\n path\n .basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase())\n );\n}\n\nfunction extractDescription(filePath) {\n return safeFileOperation(\n ", "suffix_code": ",\n filePath,\n null\n );\n}\n\n/**\n * Generate badges for installation links in VS Code and VS Code Insiders.\n * @param {string} link - The relative link to the instructions or prompts file.\n * @returns {string} - Markdown formatted badges for installation.\n */\nconst vscodeInstallImage =\n \"https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst vscodeInsidersInstallImage =\n \"https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst repoBaseUrl =\n \"https://raw.githubusercontent.com/github/awesome-copilot/main\";\nconst vscodeBaseUrl = \"https://vscode.dev/redirect?url=\";\nconst vscodeInsidersBaseUrl = \"https://insiders.vscode.dev/redirect?url=\";\nfunction makeBadges(link, type) {\n return `[](${vscodeBaseUrl}${encodeURIComponent(\n `vscode:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )} [](${vscodeInsidersBaseUrl}${encodeURIComponent(\n `vscode-insiders:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )}`;\n}\n\n/**\n * Generate the instructions section with a table of all instructions\n */\nfunction generateInstructionsSection(instructionsDir) {\n // Get all instruction files\n const instructionFiles = fs\n .readdirSync(instructionsDir)\n .filter((file) => file.endsWith(\".md\"))\n .sort();\n\n console.log(`Found ${instructionFiles.length} instruction files`);\n\n // Create table header\n let instructionsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each instruction file\n for (const file of instructionFiles) {\n const filePath = path.join(instructionsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`instructions/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"instructions\");\n\n if (customDescription && customDescription !== \"null\") {\n // Use the description from frontmatter\n instructionsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n // Fallback to the default approach - use last word of title for description, removing trailing 's' if present\n const topic = title.split(\" \").pop().replace(/s$/, \"\");\n instructionsContent += `| [${title}](${link}) | ${topic} specific coding standards and best practices | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.instructionsSection}\\n\\n${instructionsContent}\\n${TEMPLATES.instructionsUsage}`;\n}\n\n/**\n * Generate the prompts section with a table of all prompts\n */\nfunction generatePromptsSection(promptsDir) {\n // Get all prompt files\n const promptFiles = fs\n .readdirSync(promptsDir)\n .filter((file) => file.endsWith(\".prompt.md\"))\n .sort();\n\n console.log(`Found ${promptFiles.length} prompt files`);\n\n // Create table header\n let promptsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each prompt file\n for (const file of promptFiles) {\n const filePath = path.join(promptsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`prompts/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"prompt\");\n\n if (customDescription && customDescription !== \"null\") {\n promptsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n promptsContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.promptsSection}\\n\\n${promptsContent}\\n${TEMPLATES.promptsUsage}`;\n}\n\n/**\n * Generate the chat modes section with a table of all chat modes\n */\nfunction generateChatModesSection(chatmodesDir) {\n // Check if chatmodes directory exists\n if (!fs.existsSync(chatmodesDir)) {\n console.log(\"Chat modes directory does not exist\");\n return \"\";\n }\n\n // Get all chat mode files\n const chatmodeFiles = fs\n .readdirSync(chatmodesDir)\n .filter((file) => file.endsWith(\".chatmode.md\"))\n .sort();\n\n console.log(`Found ${chatmodeFiles.length} chat mode files`);\n\n // If no chat modes, return empty string\n if (chatmodeFiles.length === 0) {\n return \"\";\n }\n\n // Create table header\n let chatmodesContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each chat mode file\n for (const file of chatmodeFiles) {\n const filePath = path.join(chatmodesDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`chatmodes/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"chatmode\");\n\n if (customDescription && customDescription !== \"null\") {\n chatmodesContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n chatmodesContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.chatmodesSection}\\n\\n${chatmodesContent}\\n${TEMPLATES.chatmodesUsage}`;\n}\n\n/**\n * Generate the complete README.md content from scratch\n */\nfunction generateReadme() {\n const instructionsDir = path.join(__dirname, \"instructions\");\n const promptsDir = path.join(__dirname, \"prompts\");\n const chatmodesDir = path.join(__dirname, \"chatmodes\");\n\n // Generate each section\n const instructionsSection = generateInstructionsSection(instructionsDir);\n const promptsSection = generatePromptsSection(promptsDir);\n const chatmodesSection = generateChatModesSection(chatmodesDir);\n\n // Build the complete README content with template sections\n let readmeContent = [TEMPLATES.header, instructionsSection, promptsSection];\n\n // Only include chat modes section if we have any chat modes\n if (chatmodesSection) {\n readmeContent.push(chatmodesSection);\n }\n\n // Add footer\n readmeContent.push(TEMPLATES.footer);\n\n return readmeContent.join(\"\\n\\n\");\n}\n\n// Main execution\ntry {\n console.log(\"Generating README.md from scratch...\");\n\n const readmePath = path.join(__dirname, \"README.md\");\n const newReadmeContent = generateReadme();\n\n // Check if the README file already exists\n if (fs.existsSync(readmePath)) {\n const originalContent = fs.readFileSync(readmePath, \"utf8\");\n const hasChanges = originalContent !== newReadmeContent;\n\n if (hasChanges) {\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md updated successfully!\");\n } else {\n console.log(\"README.md is already up to date. No changes needed.\");\n }\n } else {\n // Create the README file if it doesn't exist\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md created successfully!\");\n }\n} catch (error) {\n console.error(`Error generating README.md: ${error.message}`);\n process.exit(1);\n}\n", "middle_code": "() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let isMultilineDescription = false;\n let multilineDescription = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n if (inFrontmatter) {\n const multilineMatch = line.match(/^description:\\s*\\|(\\s*)$/);\n if (multilineMatch) {\n isMultilineDescription = true;\n continue;\n }\n if (isMultilineDescription) {\n if (!line.startsWith(\" \") || line.match(/^[a-zA-Z0-9_-]+:/)) {\n return multilineDescription.join(\" \").trim();\n }\n multilineDescription.push(line.substring(2));\n } else {\n const descriptionMatch = line.match(\n /^description:\\s*['\"]?(.+?)['\"]?$/\n );\n if (descriptionMatch) {\n let description = descriptionMatch[1];\n const singleQuoteMatch = line.match(/^description:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n description = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n return description;\n }\n }\n }\n }\n if (multilineDescription.length > 0) {\n return multilineDescription.join(\" \").trim();\n }\n return null;\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [], "task_instance_info": {"created_time": "2025-08-20 23:54:57", "created_task_model": "DeepSeek-R1", "function_skeleton": "() => {}", "code_description": "This code segment functions to: Parse and extract structured metadata entries from document headers, handling both single-line and multi-line formatted property values while maintaining consistent processing across different file types."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\nfunction extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n\n // First check frontmatter for description\n let inFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (inFrontmatter) break; // End of frontmatter\n inFrontmatter = true;\n continue;\n }\n \n if (inFrontmatter && line.startsWith(\"description:\")) {\n const description = line\n .replace(/^description:\\s*/, '')\n .trim()\n .replace(/^['\"](.*)['\"]$/, '$1');\n return description;\n }\n }\n\n // If no frontmatter description, look for special comment\n for (const line of lines) {\n if (line.startsWith(\"// Description: \")) {\n return line.replace(\"// Description: \", \"\").trim();\n }\n }\n\n return null;\n },\n filePath,\n null\n );\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 23-55-14"}, "editdistance_info": {"edit_distance": 22.7545, "calculate_time": "2025-08-20 23:55:14", "true_code_clean": "() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let isMultilineDescription = false;\n let multilineDescription = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n if (inFrontmatter) {\n const multilineMatch = line.match(/^description:\\s*\\|(\\s*)$/);\n if (multilineMatch) {\n isMultilineDescription = true;\n continue;\n }\n if (isMultilineDescription) {\n if (!line.startsWith(\" \") || line.match(/^[a-zA-Z0-9_-]+:/)) {\n return multilineDescription.join(\" \").trim();\n }\n multilineDescription.push(line.substring(2));\n } else {\n const descriptionMatch = line.match(\n /^description:\\s*['\"]?(.+?)['\"]?$/\n );\n if (descriptionMatch) {\n let description = descriptionMatch[1];\n const singleQuoteMatch = line.match(/^description:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n description = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n return description;\n }\n }\n }\n }\n if (multilineDescription.length > 0) {\n return multilineDescription.join(\" \").trim();\n }\n return null;\n }", "predict_code_clean": "function extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (inFrontmatter) break; \n inFrontmatter = true;\n continue;\n }\n if (inFrontmatter && line.startsWith(\"description:\")) {\n const description = line\n .replace(/^description:\\s*/, '')\n .trim()\n .replace(/^['\"](.*)['\"]$/, '$1');\n return description;\n }\n }\n for (const line of lines) {\n if (line.startsWith(\"\n return line.replace(\"\n }\n }\n return null;\n },\n filePath,\n null\n );\n}"}}
{"repo_name": "awesome-copilot", "file_name": "/awesome-copilot/update-readme.js", "inference_info": {"prefix_code": "#!/usr/bin/env node\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\n// Template sections for the README\nconst TEMPLATES = {\n header: `# π€ Awesome GitHub Copilot Customizations\n\nEnhance your GitHub Copilot experience with community-contributed instructions, prompts, and configurations. Get consistent AI assistance that follows your team's coding standards and project requirements.\n\n## π― GitHub Copilot Customization Features\n\nGitHub Copilot provides three main ways to customize AI responses and tailor assistance to your specific workflows, team guidelines, and project requirements:\n\n| **π [Custom Instructions](#-custom-instructions)** | **π― [Reusable Prompts](#-reusable-prompts)** | **π§© [Custom Chat Modes](#-custom-chat-modes)** |\n| --- | --- | --- |\n| Define common guidelines for tasks like code generation, reviews, and commit messages. Describe *how* tasks should be performed<br><br>**Benefits:**<br>β’ Automatic inclusion in every chat request<br>β’ Repository-wide consistency<br>β’ Multiple implementation options | Create reusable, standalone prompts for specific tasks. Describe *what* should be done with optional task-specific guidelines<br><br>**Benefits:**<br>β’ Eliminate repetitive prompt writing<br>β’ Shareable across teams<br>β’ Support for variables and dependencies | Define chat behavior, available tools, and codebase interaction patterns within specific boundaries for each request<br><br>**Benefits:**<br>β’ Context-aware assistance<br>β’ Tool configuration<br>β’ Role-specific workflows |\n\n> **π‘ Pro Tip:** Custom instructions only affect Copilot Chat (not inline code completions). You can combine all three customization types - use custom instructions for general guidelines, prompt files for specific tasks, and chat modes to control the interaction context.\n\n\n## π Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details on how to submit new instructions and prompts.`,\n\n instructionsSection: `## π Custom Instructions\n\nTeam and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:`,\n\n instructionsUsage: `> π‘ **Usage**: Copy these instructions to your \\`.github/copilot-instructions.md\\` file or create task-specific \\`.github/.instructions.md\\` files in your workspace's \\`.github/instructions\\` folder.`,\n\n promptsSection: `## π― Reusable Prompts\n\nReady-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.`,\n\n promptsUsage: `> π‘ **Usage**: Use \\`/prompt-name\\` in VS Code chat, run \\`Chat: Run Prompt\\` command, or hit the run button while you have a prompt open.`,\n\n chatmodesSection: `## π§© 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.`,\n\n chatmodesUsage: `> π‘ **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.`,\n\n footer: `## π Additional Resources\n\n- [VS Code Copilot Customization Documentation](https://code.visualstudio.com/docs/copilot/copilot-customization) - Official Microsoft documentation\n- [GitHub Copilot Chat Documentation](https://code.visualstudio.com/docs/copilot/chat/copilot-chat) - Complete chat feature guide\n- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration\n- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide\n\n## π οΈ Development Configuration\n\nThis repository uses various configuration files to ensure consistent code style and avoid issues with line endings:\n\n- [\\`.editorconfig\\`](.editorconfig) - Defines coding styles across different editors and IDEs\n- [\\`.gitattributes\\`](.gitattributes) - Ensures consistent line endings in text files\n- [\\`.vscode/settings.json\\`](.vscode/settings.json) - VS Code-specific settings for this repository\n- [\\`.vscode/extensions.json\\`](.vscode/extensions.json) - Recommended VS Code extensions\n\n> π‘ **Note**: All markdown files in this repository use LF line endings (Unix-style) to avoid mixed line endings issues. The repository is configured to automatically handle line endings conversion.\n\n## π License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## π€ Code of Conduct\n\nPlease note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n\n## β’οΈ Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.`,\n};\n\n// Add error handling utility\nfunction safeFileOperation(operation, filePath, defaultValue = null) {\n try {\n return operation();\n } catch (error) {\n console.error(`Error processing file ${filePath}: ${error.message}`);\n return defaultValue;\n }\n}\n\n", "suffix_code": "\n\nfunction extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n\n // Parse frontmatter for description (for both prompts and instructions)\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n\n // For multi-line descriptions\n let isMultilineDescription = false;\n let multilineDescription = [];\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n\n if (inFrontmatter) {\n // Check for multi-line description with pipe syntax (|)\n const multilineMatch = line.match(/^description:\\s*\\|(\\s*)$/);\n if (multilineMatch) {\n isMultilineDescription = true;\n // Continue to next line to start collecting the multi-line content\n continue;\n }\n\n // If we're collecting a multi-line description\n if (isMultilineDescription) {\n // If the line has no indentation or has another frontmatter key, stop collecting\n if (!line.startsWith(\" \") || line.match(/^[a-zA-Z0-9_-]+:/)) {\n // Join the collected lines and return\n return multilineDescription.join(\" \").trim();\n }\n\n // Add the line to our multi-line collection (removing the 2-space indentation)\n multilineDescription.push(line.substring(2));\n } else {\n // Look for single-line description field in frontmatter\n const descriptionMatch = line.match(\n /^description:\\s*['\"]?(.+?)['\"]?$/\n );\n if (descriptionMatch) {\n let description = descriptionMatch[1];\n\n // Check if the description is wrapped in single quotes and handle escaped quotes\n const singleQuoteMatch = line.match(/^description:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n // Replace escaped single quotes ('') with single quotes (')\n description = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n\n return description;\n }\n }\n }\n }\n\n // If we've collected multi-line description but the frontmatter ended\n if (multilineDescription.length > 0) {\n return multilineDescription.join(\" \").trim();\n }\n\n return null;\n },\n filePath,\n null\n );\n}\n\n/**\n * Generate badges for installation links in VS Code and VS Code Insiders.\n * @param {string} link - The relative link to the instructions or prompts file.\n * @returns {string} - Markdown formatted badges for installation.\n */\nconst vscodeInstallImage =\n \"https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst vscodeInsidersInstallImage =\n \"https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst repoBaseUrl =\n \"https://raw.githubusercontent.com/github/awesome-copilot/main\";\nconst vscodeBaseUrl = \"https://vscode.dev/redirect?url=\";\nconst vscodeInsidersBaseUrl = \"https://insiders.vscode.dev/redirect?url=\";\nfunction makeBadges(link, type) {\n return `[](${vscodeBaseUrl}${encodeURIComponent(\n `vscode:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )} [](${vscodeInsidersBaseUrl}${encodeURIComponent(\n `vscode-insiders:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )}`;\n}\n\n/**\n * Generate the instructions section with a table of all instructions\n */\nfunction generateInstructionsSection(instructionsDir) {\n // Get all instruction files\n const instructionFiles = fs\n .readdirSync(instructionsDir)\n .filter((file) => file.endsWith(\".md\"))\n .sort();\n\n console.log(`Found ${instructionFiles.length} instruction files`);\n\n // Create table header\n let instructionsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each instruction file\n for (const file of instructionFiles) {\n const filePath = path.join(instructionsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`instructions/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"instructions\");\n\n if (customDescription && customDescription !== \"null\") {\n // Use the description from frontmatter\n instructionsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n // Fallback to the default approach - use last word of title for description, removing trailing 's' if present\n const topic = title.split(\" \").pop().replace(/s$/, \"\");\n instructionsContent += `| [${title}](${link}) | ${topic} specific coding standards and best practices | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.instructionsSection}\\n\\n${instructionsContent}\\n${TEMPLATES.instructionsUsage}`;\n}\n\n/**\n * Generate the prompts section with a table of all prompts\n */\nfunction generatePromptsSection(promptsDir) {\n // Get all prompt files\n const promptFiles = fs\n .readdirSync(promptsDir)\n .filter((file) => file.endsWith(\".prompt.md\"))\n .sort();\n\n console.log(`Found ${promptFiles.length} prompt files`);\n\n // Create table header\n let promptsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each prompt file\n for (const file of promptFiles) {\n const filePath = path.join(promptsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`prompts/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"prompt\");\n\n if (customDescription && customDescription !== \"null\") {\n promptsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n promptsContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.promptsSection}\\n\\n${promptsContent}\\n${TEMPLATES.promptsUsage}`;\n}\n\n/**\n * Generate the chat modes section with a table of all chat modes\n */\nfunction generateChatModesSection(chatmodesDir) {\n // Check if chatmodes directory exists\n if (!fs.existsSync(chatmodesDir)) {\n console.log(\"Chat modes directory does not exist\");\n return \"\";\n }\n\n // Get all chat mode files\n const chatmodeFiles = fs\n .readdirSync(chatmodesDir)\n .filter((file) => file.endsWith(\".chatmode.md\"))\n .sort();\n\n console.log(`Found ${chatmodeFiles.length} chat mode files`);\n\n // If no chat modes, return empty string\n if (chatmodeFiles.length === 0) {\n return \"\";\n }\n\n // Create table header\n let chatmodesContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each chat mode file\n for (const file of chatmodeFiles) {\n const filePath = path.join(chatmodesDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`chatmodes/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"chatmode\");\n\n if (customDescription && customDescription !== \"null\") {\n chatmodesContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n chatmodesContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.chatmodesSection}\\n\\n${chatmodesContent}\\n${TEMPLATES.chatmodesUsage}`;\n}\n\n/**\n * Generate the complete README.md content from scratch\n */\nfunction generateReadme() {\n const instructionsDir = path.join(__dirname, \"instructions\");\n const promptsDir = path.join(__dirname, \"prompts\");\n const chatmodesDir = path.join(__dirname, \"chatmodes\");\n\n // Generate each section\n const instructionsSection = generateInstructionsSection(instructionsDir);\n const promptsSection = generatePromptsSection(promptsDir);\n const chatmodesSection = generateChatModesSection(chatmodesDir);\n\n // Build the complete README content with template sections\n let readmeContent = [TEMPLATES.header, instructionsSection, promptsSection];\n\n // Only include chat modes section if we have any chat modes\n if (chatmodesSection) {\n readmeContent.push(chatmodesSection);\n }\n\n // Add footer\n readmeContent.push(TEMPLATES.footer);\n\n return readmeContent.join(\"\\n\\n\");\n}\n\n// Main execution\ntry {\n console.log(\"Generating README.md from scratch...\");\n\n const readmePath = path.join(__dirname, \"README.md\");\n const newReadmeContent = generateReadme();\n\n // Check if the README file already exists\n if (fs.existsSync(readmePath)) {\n const originalContent = fs.readFileSync(readmePath, \"utf8\");\n const hasChanges = originalContent !== newReadmeContent;\n\n if (hasChanges) {\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md updated successfully!\");\n } else {\n console.log(\"README.md is already up to date. No changes needed.\");\n }\n } else {\n // Create the README file if it doesn't exist\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md created successfully!\");\n }\n} catch (error) {\n console.error(`Error generating README.md: ${error.message}`);\n process.exit(1);\n}\n", "middle_code": "function extractTitle(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let frontmatterEnded = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (!frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (inFrontmatter && !frontmatterEnded) {\n if (line.includes(\"title:\")) {\n const afterTitle = line\n .substring(line.indexOf(\"title:\") + 6)\n .trim();\n const cleanTitle = afterTitle.replace(/^['\"]|['\"]$/g, \"\");\n return cleanTitle;\n }\n }\n }\n inFrontmatter = false;\n frontmatterEnded = false;\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".chatmode.md\") ||\n filePath.includes(\".instructions.md\")\n ) {\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (inFrontmatter && !frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (frontmatterEnded && line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(\n filePath,\n filePath.includes(\".prompt.md\")\n ? \".prompt.md\"\n : filePath.includes(\".chatmode.md\")\n ? \".chatmode.md\"\n : \".instructions.md\"\n );\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(filePath, path.extname(filePath));\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n },\n filePath,\n path\n .basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase())\n );\n}", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [], "task_instance_info": {"created_time": "2025-08-20 23:54:57", "created_task_model": "DeepSeek-R1", "function_skeleton": "function extractTitle (filePath) {}", "code_description": "This code segment functions to: Extract structured metadata from documentation files by parsing frontmatter sections and header formats while providing fallback title generation when explicit metadata is unavailable."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\nfunction extractTitle(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n \n // First check frontmatter for title\n let inFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n \n if (inFrontmatter) {\n const titleMatch = line.match(/^title:\\s*['\"]?(.+?)['\"]?$/);\n if (titleMatch) {\n let title = titleMatch[1];\n \n // Handle single-quoted titles with escaped quotes\n const singleQuoteMatch = line.match(/^title:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n title = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n \n return title;\n }\n }\n }\n\n // Fallback to filename if no frontmatter title\n const fileName = path.basename(filePath);\n return fileName\n .replace(/(\\.prompt|\\.chatmode)?\\.md$/, '')\n .replace(/[-_]/g, ' ')\n .replace(/\\b\\w/g, c => c.toUpperCase());\n },\n filePath,\n \"Untitled\"\n );\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 23-55-16"}, "editdistance_info": {"edit_distance": 30.5769, "calculate_time": "2025-08-20 23:55:16", "true_code_clean": "function extractTitle(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let frontmatterEnded = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (!frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (inFrontmatter && !frontmatterEnded) {\n if (line.includes(\"title:\")) {\n const afterTitle = line\n .substring(line.indexOf(\"title:\") + 6)\n .trim();\n const cleanTitle = afterTitle.replace(/^['\"]|['\"]$/g, \"\");\n return cleanTitle;\n }\n }\n }\n inFrontmatter = false;\n frontmatterEnded = false;\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".chatmode.md\") ||\n filePath.includes(\".instructions.md\")\n ) {\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (inFrontmatter && !frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (frontmatterEnded && line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(\n filePath,\n filePath.includes(\".prompt.md\")\n ? \".prompt.md\"\n : filePath.includes(\".chatmode.md\")\n ? \".chatmode.md\"\n : \".instructions.md\"\n );\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(filePath, path.extname(filePath));\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n },\n filePath,\n path\n .basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase())\n );\n}", "predict_code_clean": "function extractTitle(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n if (inFrontmatter) {\n const titleMatch = line.match(/^title:\\s*['\"]?(.+?)['\"]?$/);\n if (titleMatch) {\n let title = titleMatch[1];\n const singleQuoteMatch = line.match(/^title:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n title = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n return title;\n }\n }\n }\n const fileName = path.basename(filePath);\n return fileName\n .replace(/(\\.prompt|\\.chatmode)?\\.md$/, '')\n .replace(/[-_]/g, ' ')\n .replace(/\\b\\w/g, c => c.toUpperCase());\n },\n filePath,\n \"Untitled\"\n );\n}"}}
{"repo_name": "awesome-copilot", "file_name": "/awesome-copilot/update-readme.js", "inference_info": {"prefix_code": "#!/usr/bin/env node\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\n// Template sections for the README\nconst TEMPLATES = {\n header: `# π€ Awesome GitHub Copilot Customizations\n\nEnhance your GitHub Copilot experience with community-contributed instructions, prompts, and configurations. Get consistent AI assistance that follows your team's coding standards and project requirements.\n\n## π― GitHub Copilot Customization Features\n\nGitHub Copilot provides three main ways to customize AI responses and tailor assistance to your specific workflows, team guidelines, and project requirements:\n\n| **π [Custom Instructions](#-custom-instructions)** | **π― [Reusable Prompts](#-reusable-prompts)** | **π§© [Custom Chat Modes](#-custom-chat-modes)** |\n| --- | --- | --- |\n| Define common guidelines for tasks like code generation, reviews, and commit messages. Describe *how* tasks should be performed<br><br>**Benefits:**<br>β’ Automatic inclusion in every chat request<br>β’ Repository-wide consistency<br>β’ Multiple implementation options | Create reusable, standalone prompts for specific tasks. Describe *what* should be done with optional task-specific guidelines<br><br>**Benefits:**<br>β’ Eliminate repetitive prompt writing<br>β’ Shareable across teams<br>β’ Support for variables and dependencies | Define chat behavior, available tools, and codebase interaction patterns within specific boundaries for each request<br><br>**Benefits:**<br>β’ Context-aware assistance<br>β’ Tool configuration<br>β’ Role-specific workflows |\n\n> **π‘ Pro Tip:** Custom instructions only affect Copilot Chat (not inline code completions). You can combine all three customization types - use custom instructions for general guidelines, prompt files for specific tasks, and chat modes to control the interaction context.\n\n\n## π Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details on how to submit new instructions and prompts.`,\n\n instructionsSection: `## π Custom Instructions\n\nTeam and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:`,\n\n instructionsUsage: `> π‘ **Usage**: Copy these instructions to your \\`.github/copilot-instructions.md\\` file or create task-specific \\`.github/.instructions.md\\` files in your workspace's \\`.github/instructions\\` folder.`,\n\n promptsSection: `## π― Reusable Prompts\n\nReady-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.`,\n\n promptsUsage: `> π‘ **Usage**: Use \\`/prompt-name\\` in VS Code chat, run \\`Chat: Run Prompt\\` command, or hit the run button while you have a prompt open.`,\n\n chatmodesSection: `## π§© 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.`,\n\n chatmodesUsage: `> π‘ **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.`,\n\n footer: `## π Additional Resources\n\n- [VS Code Copilot Customization Documentation](https://code.visualstudio.com/docs/copilot/copilot-customization) - Official Microsoft documentation\n- [GitHub Copilot Chat Documentation](https://code.visualstudio.com/docs/copilot/chat/copilot-chat) - Complete chat feature guide\n- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration\n- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide\n\n## π οΈ Development Configuration\n\nThis repository uses various configuration files to ensure consistent code style and avoid issues with line endings:\n\n- [\\`.editorconfig\\`](.editorconfig) - Defines coding styles across different editors and IDEs\n- [\\`.gitattributes\\`](.gitattributes) - Ensures consistent line endings in text files\n- [\\`.vscode/settings.json\\`](.vscode/settings.json) - VS Code-specific settings for this repository\n- [\\`.vscode/extensions.json\\`](.vscode/extensions.json) - Recommended VS Code extensions\n\n> π‘ **Note**: All markdown files in this repository use LF line endings (Unix-style) to avoid mixed line endings issues. The repository is configured to automatically handle line endings conversion.\n\n## π License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## π€ Code of Conduct\n\nPlease note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n\n## β’οΈ Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.`,\n};\n\n// Add error handling utility\nfunction safeFileOperation(operation, filePath, defaultValue = null) {\n try {\n return operation();\n } catch (error) {\n console.error(`Error processing file ${filePath}: ${error.message}`);\n return defaultValue;\n }\n}\n\nfunction extractTitle(filePath) {\n return safeFileOperation(\n ", "suffix_code": ",\n filePath,\n path\n .basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase())\n );\n}\n\nfunction extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n\n // Parse frontmatter for description (for both prompts and instructions)\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n\n // For multi-line descriptions\n let isMultilineDescription = false;\n let multilineDescription = [];\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n\n if (inFrontmatter) {\n // Check for multi-line description with pipe syntax (|)\n const multilineMatch = line.match(/^description:\\s*\\|(\\s*)$/);\n if (multilineMatch) {\n isMultilineDescription = true;\n // Continue to next line to start collecting the multi-line content\n continue;\n }\n\n // If we're collecting a multi-line description\n if (isMultilineDescription) {\n // If the line has no indentation or has another frontmatter key, stop collecting\n if (!line.startsWith(\" \") || line.match(/^[a-zA-Z0-9_-]+:/)) {\n // Join the collected lines and return\n return multilineDescription.join(\" \").trim();\n }\n\n // Add the line to our multi-line collection (removing the 2-space indentation)\n multilineDescription.push(line.substring(2));\n } else {\n // Look for single-line description field in frontmatter\n const descriptionMatch = line.match(\n /^description:\\s*['\"]?(.+?)['\"]?$/\n );\n if (descriptionMatch) {\n let description = descriptionMatch[1];\n\n // Check if the description is wrapped in single quotes and handle escaped quotes\n const singleQuoteMatch = line.match(/^description:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n // Replace escaped single quotes ('') with single quotes (')\n description = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n\n return description;\n }\n }\n }\n }\n\n // If we've collected multi-line description but the frontmatter ended\n if (multilineDescription.length > 0) {\n return multilineDescription.join(\" \").trim();\n }\n\n return null;\n },\n filePath,\n null\n );\n}\n\n/**\n * Generate badges for installation links in VS Code and VS Code Insiders.\n * @param {string} link - The relative link to the instructions or prompts file.\n * @returns {string} - Markdown formatted badges for installation.\n */\nconst vscodeInstallImage =\n \"https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst vscodeInsidersInstallImage =\n \"https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst repoBaseUrl =\n \"https://raw.githubusercontent.com/github/awesome-copilot/main\";\nconst vscodeBaseUrl = \"https://vscode.dev/redirect?url=\";\nconst vscodeInsidersBaseUrl = \"https://insiders.vscode.dev/redirect?url=\";\nfunction makeBadges(link, type) {\n return `[](${vscodeBaseUrl}${encodeURIComponent(\n `vscode:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )} [](${vscodeInsidersBaseUrl}${encodeURIComponent(\n `vscode-insiders:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )}`;\n}\n\n/**\n * Generate the instructions section with a table of all instructions\n */\nfunction generateInstructionsSection(instructionsDir) {\n // Get all instruction files\n const instructionFiles = fs\n .readdirSync(instructionsDir)\n .filter((file) => file.endsWith(\".md\"))\n .sort();\n\n console.log(`Found ${instructionFiles.length} instruction files`);\n\n // Create table header\n let instructionsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each instruction file\n for (const file of instructionFiles) {\n const filePath = path.join(instructionsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`instructions/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"instructions\");\n\n if (customDescription && customDescription !== \"null\") {\n // Use the description from frontmatter\n instructionsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n // Fallback to the default approach - use last word of title for description, removing trailing 's' if present\n const topic = title.split(\" \").pop().replace(/s$/, \"\");\n instructionsContent += `| [${title}](${link}) | ${topic} specific coding standards and best practices | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.instructionsSection}\\n\\n${instructionsContent}\\n${TEMPLATES.instructionsUsage}`;\n}\n\n/**\n * Generate the prompts section with a table of all prompts\n */\nfunction generatePromptsSection(promptsDir) {\n // Get all prompt files\n const promptFiles = fs\n .readdirSync(promptsDir)\n .filter((file) => file.endsWith(\".prompt.md\"))\n .sort();\n\n console.log(`Found ${promptFiles.length} prompt files`);\n\n // Create table header\n let promptsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each prompt file\n for (const file of promptFiles) {\n const filePath = path.join(promptsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`prompts/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"prompt\");\n\n if (customDescription && customDescription !== \"null\") {\n promptsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n promptsContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.promptsSection}\\n\\n${promptsContent}\\n${TEMPLATES.promptsUsage}`;\n}\n\n/**\n * Generate the chat modes section with a table of all chat modes\n */\nfunction generateChatModesSection(chatmodesDir) {\n // Check if chatmodes directory exists\n if (!fs.existsSync(chatmodesDir)) {\n console.log(\"Chat modes directory does not exist\");\n return \"\";\n }\n\n // Get all chat mode files\n const chatmodeFiles = fs\n .readdirSync(chatmodesDir)\n .filter((file) => file.endsWith(\".chatmode.md\"))\n .sort();\n\n console.log(`Found ${chatmodeFiles.length} chat mode files`);\n\n // If no chat modes, return empty string\n if (chatmodeFiles.length === 0) {\n return \"\";\n }\n\n // Create table header\n let chatmodesContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each chat mode file\n for (const file of chatmodeFiles) {\n const filePath = path.join(chatmodesDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`chatmodes/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"chatmode\");\n\n if (customDescription && customDescription !== \"null\") {\n chatmodesContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n chatmodesContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.chatmodesSection}\\n\\n${chatmodesContent}\\n${TEMPLATES.chatmodesUsage}`;\n}\n\n/**\n * Generate the complete README.md content from scratch\n */\nfunction generateReadme() {\n const instructionsDir = path.join(__dirname, \"instructions\");\n const promptsDir = path.join(__dirname, \"prompts\");\n const chatmodesDir = path.join(__dirname, \"chatmodes\");\n\n // Generate each section\n const instructionsSection = generateInstructionsSection(instructionsDir);\n const promptsSection = generatePromptsSection(promptsDir);\n const chatmodesSection = generateChatModesSection(chatmodesDir);\n\n // Build the complete README content with template sections\n let readmeContent = [TEMPLATES.header, instructionsSection, promptsSection];\n\n // Only include chat modes section if we have any chat modes\n if (chatmodesSection) {\n readmeContent.push(chatmodesSection);\n }\n\n // Add footer\n readmeContent.push(TEMPLATES.footer);\n\n return readmeContent.join(\"\\n\\n\");\n}\n\n// Main execution\ntry {\n console.log(\"Generating README.md from scratch...\");\n\n const readmePath = path.join(__dirname, \"README.md\");\n const newReadmeContent = generateReadme();\n\n // Check if the README file already exists\n if (fs.existsSync(readmePath)) {\n const originalContent = fs.readFileSync(readmePath, \"utf8\");\n const hasChanges = originalContent !== newReadmeContent;\n\n if (hasChanges) {\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md updated successfully!\");\n } else {\n console.log(\"README.md is already up to date. No changes needed.\");\n }\n } else {\n // Create the README file if it doesn't exist\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md created successfully!\");\n }\n} catch (error) {\n console.error(`Error generating README.md: ${error.message}`);\n process.exit(1);\n}\n", "middle_code": "() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let frontmatterEnded = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (!frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (inFrontmatter && !frontmatterEnded) {\n if (line.includes(\"title:\")) {\n const afterTitle = line\n .substring(line.indexOf(\"title:\") + 6)\n .trim();\n const cleanTitle = afterTitle.replace(/^['\"]|['\"]$/g, \"\");\n return cleanTitle;\n }\n }\n }\n inFrontmatter = false;\n frontmatterEnded = false;\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".chatmode.md\") ||\n filePath.includes(\".instructions.md\")\n ) {\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (inFrontmatter && !frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (frontmatterEnded && line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(\n filePath,\n filePath.includes(\".prompt.md\")\n ? \".prompt.md\"\n : filePath.includes(\".chatmode.md\")\n ? \".chatmode.md\"\n : \".instructions.md\"\n );\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(filePath, path.extname(filePath));\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [], "task_instance_info": {"created_time": "2025-08-20 23:54:57", "created_task_model": "DeepSeek-R1", "function_skeleton": "() => {}", "code_description": "This code segment functions to: Extract and format document titles from file metadata or content by checking frontmatter sections, header markup patterns, and filename conventions while handling multiple potential input formats."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\n() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n \n // First try to get title from frontmatter\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n \n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n \n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n \n if (inFrontmatter) {\n const titleMatch = line.match(/^title:\\s*(.+)/);\n if (titleMatch) {\n return titleMatch[1].replace(/['\"]/g, '').trim();\n }\n }\n }\n\n // Fallback to filename processing\n return path.basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 23-55-17"}, "editdistance_info": {"edit_distance": 23.6443, "calculate_time": "2025-08-20 23:55:17", "true_code_clean": "() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let frontmatterEnded = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (!frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (inFrontmatter && !frontmatterEnded) {\n if (line.includes(\"title:\")) {\n const afterTitle = line\n .substring(line.indexOf(\"title:\") + 6)\n .trim();\n const cleanTitle = afterTitle.replace(/^['\"]|['\"]$/g, \"\");\n return cleanTitle;\n }\n }\n }\n inFrontmatter = false;\n frontmatterEnded = false;\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".chatmode.md\") ||\n filePath.includes(\".instructions.md\")\n ) {\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (inFrontmatter && !frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (frontmatterEnded && line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(\n filePath,\n filePath.includes(\".prompt.md\")\n ? \".prompt.md\"\n : filePath.includes(\".chatmode.md\")\n ? \".chatmode.md\"\n : \".instructions.md\"\n );\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(filePath, path.extname(filePath));\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }", "predict_code_clean": "() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n if (inFrontmatter) {\n const titleMatch = line.match(/^title:\\s*(.+)/);\n if (titleMatch) {\n return titleMatch[1].replace(/['\"]/g, '').trim();\n }\n }\n }\n return path.basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n}"}}
{"repo_name": "awesome-copilot", "file_name": "/awesome-copilot/update-readme.js", "inference_info": {"prefix_code": "#!/usr/bin/env node\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\n// Template sections for the README\nconst TEMPLATES = {\n header: `# π€ Awesome GitHub Copilot Customizations\n\nEnhance your GitHub Copilot experience with community-contributed instructions, prompts, and configurations. Get consistent AI assistance that follows your team's coding standards and project requirements.\n\n## π― GitHub Copilot Customization Features\n\nGitHub Copilot provides three main ways to customize AI responses and tailor assistance to your specific workflows, team guidelines, and project requirements:\n\n| **π [Custom Instructions](#-custom-instructions)** | **π― [Reusable Prompts](#-reusable-prompts)** | **π§© [Custom Chat Modes](#-custom-chat-modes)** |\n| --- | --- | --- |\n| Define common guidelines for tasks like code generation, reviews, and commit messages. Describe *how* tasks should be performed<br><br>**Benefits:**<br>β’ Automatic inclusion in every chat request<br>β’ Repository-wide consistency<br>β’ Multiple implementation options | Create reusable, standalone prompts for specific tasks. Describe *what* should be done with optional task-specific guidelines<br><br>**Benefits:**<br>β’ Eliminate repetitive prompt writing<br>β’ Shareable across teams<br>β’ Support for variables and dependencies | Define chat behavior, available tools, and codebase interaction patterns within specific boundaries for each request<br><br>**Benefits:**<br>β’ Context-aware assistance<br>β’ Tool configuration<br>β’ Role-specific workflows |\n\n> **π‘ Pro Tip:** Custom instructions only affect Copilot Chat (not inline code completions). You can combine all three customization types - use custom instructions for general guidelines, prompt files for specific tasks, and chat modes to control the interaction context.\n\n\n## π Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details on how to submit new instructions and prompts.`,\n\n instructionsSection: `## π Custom Instructions\n\nTeam and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:`,\n\n instructionsUsage: `> π‘ **Usage**: Copy these instructions to your \\`.github/copilot-instructions.md\\` file or create task-specific \\`.github/.instructions.md\\` files in your workspace's \\`.github/instructions\\` folder.`,\n\n promptsSection: `## π― Reusable Prompts\n\nReady-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.`,\n\n promptsUsage: `> π‘ **Usage**: Use \\`/prompt-name\\` in VS Code chat, run \\`Chat: Run Prompt\\` command, or hit the run button while you have a prompt open.`,\n\n chatmodesSection: `## π§© 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.`,\n\n chatmodesUsage: `> π‘ **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.`,\n\n footer: `## π Additional Resources\n\n- [VS Code Copilot Customization Documentation](https://code.visualstudio.com/docs/copilot/copilot-customization) - Official Microsoft documentation\n- [GitHub Copilot Chat Documentation](https://code.visualstudio.com/docs/copilot/chat/copilot-chat) - Complete chat feature guide\n- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration\n- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide\n\n## π οΈ Development Configuration\n\nThis repository uses various configuration files to ensure consistent code style and avoid issues with line endings:\n\n- [\\`.editorconfig\\`](.editorconfig) - Defines coding styles across different editors and IDEs\n- [\\`.gitattributes\\`](.gitattributes) - Ensures consistent line endings in text files\n- [\\`.vscode/settings.json\\`](.vscode/settings.json) - VS Code-specific settings for this repository\n- [\\`.vscode/extensions.json\\`](.vscode/extensions.json) - Recommended VS Code extensions\n\n> π‘ **Note**: All markdown files in this repository use LF line endings (Unix-style) to avoid mixed line endings issues. The repository is configured to automatically handle line endings conversion.\n\n## π License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## π€ Code of Conduct\n\nPlease note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n\n## β’οΈ Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.`,\n};\n\n// Add error handling utility\nfunction safeFileOperation(operation, filePath, defaultValue = null) {\n try {\n return operation();\n } catch (error) {\n console.error(`Error processing file ${filePath}: ${error.message}`);\n return defaultValue;\n }\n}\n\nfunction extractTitle(filePath) {\n return safeFileOperation(\n ", "suffix_code": ",\n filePath,\n path\n .basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase())\n );\n}\n\nfunction extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n\n // Parse frontmatter for description (for both prompts and instructions)\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n\n // For multi-line descriptions\n let isMultilineDescription = false;\n let multilineDescription = [];\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n\n if (inFrontmatter) {\n // Check for multi-line description with pipe syntax (|)\n const multilineMatch = line.match(/^description:\\s*\\|(\\s*)$/);\n if (multilineMatch) {\n isMultilineDescription = true;\n // Continue to next line to start collecting the multi-line content\n continue;\n }\n\n // If we're collecting a multi-line description\n if (isMultilineDescription) {\n // If the line has no indentation or has another frontmatter key, stop collecting\n if (!line.startsWith(\" \") || line.match(/^[a-zA-Z0-9_-]+:/)) {\n // Join the collected lines and return\n return multilineDescription.join(\" \").trim();\n }\n\n // Add the line to our multi-line collection (removing the 2-space indentation)\n multilineDescription.push(line.substring(2));\n } else {\n // Look for single-line description field in frontmatter\n const descriptionMatch = line.match(\n /^description:\\s*['\"]?(.+?)['\"]?$/\n );\n if (descriptionMatch) {\n let description = descriptionMatch[1];\n\n // Check if the description is wrapped in single quotes and handle escaped quotes\n const singleQuoteMatch = line.match(/^description:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n // Replace escaped single quotes ('') with single quotes (')\n description = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n\n return description;\n }\n }\n }\n }\n\n // If we've collected multi-line description but the frontmatter ended\n if (multilineDescription.length > 0) {\n return multilineDescription.join(\" \").trim();\n }\n\n return null;\n },\n filePath,\n null\n );\n}\n\n/**\n * Generate badges for installation links in VS Code and VS Code Insiders.\n * @param {string} link - The relative link to the instructions or prompts file.\n * @returns {string} - Markdown formatted badges for installation.\n */\nconst vscodeInstallImage =\n \"https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst vscodeInsidersInstallImage =\n \"https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst repoBaseUrl =\n \"https://raw.githubusercontent.com/github/awesome-copilot/main\";\nconst vscodeBaseUrl = \"https://vscode.dev/redirect?url=\";\nconst vscodeInsidersBaseUrl = \"https://insiders.vscode.dev/redirect?url=\";\nfunction makeBadges(link, type) {\n return `[](${vscodeBaseUrl}${encodeURIComponent(\n `vscode:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )} [](${vscodeInsidersBaseUrl}${encodeURIComponent(\n `vscode-insiders:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )}`;\n}\n\n/**\n * Generate the instructions section with a table of all instructions\n */\nfunction generateInstructionsSection(instructionsDir) {\n // Get all instruction files\n const instructionFiles = fs\n .readdirSync(instructionsDir)\n .filter((file) => file.endsWith(\".md\"))\n .sort();\n\n console.log(`Found ${instructionFiles.length} instruction files`);\n\n // Create table header\n let instructionsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each instruction file\n for (const file of instructionFiles) {\n const filePath = path.join(instructionsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`instructions/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"instructions\");\n\n if (customDescription && customDescription !== \"null\") {\n // Use the description from frontmatter\n instructionsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n // Fallback to the default approach - use last word of title for description, removing trailing 's' if present\n const topic = title.split(\" \").pop().replace(/s$/, \"\");\n instructionsContent += `| [${title}](${link}) | ${topic} specific coding standards and best practices | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.instructionsSection}\\n\\n${instructionsContent}\\n${TEMPLATES.instructionsUsage}`;\n}\n\n/**\n * Generate the prompts section with a table of all prompts\n */\nfunction generatePromptsSection(promptsDir) {\n // Get all prompt files\n const promptFiles = fs\n .readdirSync(promptsDir)\n .filter((file) => file.endsWith(\".prompt.md\"))\n .sort();\n\n console.log(`Found ${promptFiles.length} prompt files`);\n\n // Create table header\n let promptsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each prompt file\n for (const file of promptFiles) {\n const filePath = path.join(promptsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`prompts/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"prompt\");\n\n if (customDescription && customDescription !== \"null\") {\n promptsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n promptsContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.promptsSection}\\n\\n${promptsContent}\\n${TEMPLATES.promptsUsage}`;\n}\n\n/**\n * Generate the chat modes section with a table of all chat modes\n */\nfunction generateChatModesSection(chatmodesDir) {\n // Check if chatmodes directory exists\n if (!fs.existsSync(chatmodesDir)) {\n console.log(\"Chat modes directory does not exist\");\n return \"\";\n }\n\n // Get all chat mode files\n const chatmodeFiles = fs\n .readdirSync(chatmodesDir)\n .filter((file) => file.endsWith(\".chatmode.md\"))\n .sort();\n\n console.log(`Found ${chatmodeFiles.length} chat mode files`);\n\n // If no chat modes, return empty string\n if (chatmodeFiles.length === 0) {\n return \"\";\n }\n\n // Create table header\n let chatmodesContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each chat mode file\n for (const file of chatmodeFiles) {\n const filePath = path.join(chatmodesDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`chatmodes/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"chatmode\");\n\n if (customDescription && customDescription !== \"null\") {\n chatmodesContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n chatmodesContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.chatmodesSection}\\n\\n${chatmodesContent}\\n${TEMPLATES.chatmodesUsage}`;\n}\n\n/**\n * Generate the complete README.md content from scratch\n */\nfunction generateReadme() {\n const instructionsDir = path.join(__dirname, \"instructions\");\n const promptsDir = path.join(__dirname, \"prompts\");\n const chatmodesDir = path.join(__dirname, \"chatmodes\");\n\n // Generate each section\n const instructionsSection = generateInstructionsSection(instructionsDir);\n const promptsSection = generatePromptsSection(promptsDir);\n const chatmodesSection = generateChatModesSection(chatmodesDir);\n\n // Build the complete README content with template sections\n let readmeContent = [TEMPLATES.header, instructionsSection, promptsSection];\n\n // Only include chat modes section if we have any chat modes\n if (chatmodesSection) {\n readmeContent.push(chatmodesSection);\n }\n\n // Add footer\n readmeContent.push(TEMPLATES.footer);\n\n return readmeContent.join(\"\\n\\n\");\n}\n\n// Main execution\ntry {\n console.log(\"Generating README.md from scratch...\");\n\n const readmePath = path.join(__dirname, \"README.md\");\n const newReadmeContent = generateReadme();\n\n // Check if the README file already exists\n if (fs.existsSync(readmePath)) {\n const originalContent = fs.readFileSync(readmePath, \"utf8\");\n const hasChanges = originalContent !== newReadmeContent;\n\n if (hasChanges) {\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md updated successfully!\");\n } else {\n console.log(\"README.md is already up to date. No changes needed.\");\n }\n } else {\n // Create the README file if it doesn't exist\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md created successfully!\");\n }\n} catch (error) {\n console.error(`Error generating README.md: ${error.message}`);\n process.exit(1);\n}\n", "middle_code": "() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let frontmatterEnded = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (!frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (inFrontmatter && !frontmatterEnded) {\n if (line.includes(\"title:\")) {\n const afterTitle = line\n .substring(line.indexOf(\"title:\") + 6)\n .trim();\n const cleanTitle = afterTitle.replace(/^['\"]|['\"]$/g, \"\");\n return cleanTitle;\n }\n }\n }\n inFrontmatter = false;\n frontmatterEnded = false;\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".chatmode.md\") ||\n filePath.includes(\".instructions.md\")\n ) {\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (inFrontmatter && !frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (frontmatterEnded && line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(\n filePath,\n filePath.includes(\".prompt.md\")\n ? \".prompt.md\"\n : filePath.includes(\".chatmode.md\")\n ? \".chatmode.md\"\n : \".instructions.md\"\n );\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(filePath, path.extname(filePath));\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [], "task_instance_info": {"created_time": "2025-08-20 23:54:57", "created_task_model": "DeepSeek-R1", "function_skeleton": "() => {}", "code_description": "This code segment functions to: Extract structured metadata from document files by parsing frontmatter sections and header content while providing fallback naming conventions derived from filenames. It processes text content to locate specific information patterns and transforms naming formats through sequential text processing operations."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\n() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n \n // First try to get title from frontmatter\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n \n for (const line of lines) {\n if (line.trim() === \"---\") {\n inFrontmatter = !inFrontmatter;\n if (!inFrontmatter) break; // Stop after first frontmatter block\n continue;\n }\n \n if (inFrontmatter) {\n const titleMatch = line.match(/^title:\\s*(.+)/);\n if (titleMatch) {\n // Remove surrounding quotes if present\n return titleMatch[1].replace(/^['\"](.*)['\"]$/, '$1');\n }\n }\n }\n\n // Fallback to filename-based title if no frontmatter title found\n return path.basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 23-55-18"}, "editdistance_info": {"edit_distance": 24.5119, "calculate_time": "2025-08-20 23:55:18", "true_code_clean": "() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let frontmatterEnded = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (!frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (inFrontmatter && !frontmatterEnded) {\n if (line.includes(\"title:\")) {\n const afterTitle = line\n .substring(line.indexOf(\"title:\") + 6)\n .trim();\n const cleanTitle = afterTitle.replace(/^['\"]|['\"]$/g, \"\");\n return cleanTitle;\n }\n }\n }\n inFrontmatter = false;\n frontmatterEnded = false;\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".chatmode.md\") ||\n filePath.includes(\".instructions.md\")\n ) {\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (inFrontmatter && !frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n if (frontmatterEnded && line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(\n filePath,\n filePath.includes(\".prompt.md\")\n ? \".prompt.md\"\n : filePath.includes(\".chatmode.md\")\n ? \".chatmode.md\"\n : \".instructions.md\"\n );\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n const basename = path.basename(filePath, path.extname(filePath));\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }", "predict_code_clean": "() => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n inFrontmatter = !inFrontmatter;\n if (!inFrontmatter) break; \n continue;\n }\n if (inFrontmatter) {\n const titleMatch = line.match(/^title:\\s*(.+)/);\n if (titleMatch) {\n return titleMatch[1].replace(/^['\"](.*)['\"]$/, '$1');\n }\n }\n }\n return path.basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n}"}}
{"repo_name": "awesome-copilot", "file_name": "/awesome-copilot/update-readme.js", "inference_info": {"prefix_code": "#!/usr/bin/env node\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\n// Template sections for the README\nconst TEMPLATES = {\n header: `# π€ Awesome GitHub Copilot Customizations\n\nEnhance your GitHub Copilot experience with community-contributed instructions, prompts, and configurations. Get consistent AI assistance that follows your team's coding standards and project requirements.\n\n## π― GitHub Copilot Customization Features\n\nGitHub Copilot provides three main ways to customize AI responses and tailor assistance to your specific workflows, team guidelines, and project requirements:\n\n| **π [Custom Instructions](#-custom-instructions)** | **π― [Reusable Prompts](#-reusable-prompts)** | **π§© [Custom Chat Modes](#-custom-chat-modes)** |\n| --- | --- | --- |\n| Define common guidelines for tasks like code generation, reviews, and commit messages. Describe *how* tasks should be performed<br><br>**Benefits:**<br>β’ Automatic inclusion in every chat request<br>β’ Repository-wide consistency<br>β’ Multiple implementation options | Create reusable, standalone prompts for specific tasks. Describe *what* should be done with optional task-specific guidelines<br><br>**Benefits:**<br>β’ Eliminate repetitive prompt writing<br>β’ Shareable across teams<br>β’ Support for variables and dependencies | Define chat behavior, available tools, and codebase interaction patterns within specific boundaries for each request<br><br>**Benefits:**<br>β’ Context-aware assistance<br>β’ Tool configuration<br>β’ Role-specific workflows |\n\n> **π‘ Pro Tip:** Custom instructions only affect Copilot Chat (not inline code completions). You can combine all three customization types - use custom instructions for general guidelines, prompt files for specific tasks, and chat modes to control the interaction context.\n\n\n## π Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details on how to submit new instructions and prompts.`,\n\n instructionsSection: `## π Custom Instructions\n\nTeam and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:`,\n\n instructionsUsage: `> π‘ **Usage**: Copy these instructions to your \\`.github/copilot-instructions.md\\` file or create task-specific \\`.github/.instructions.md\\` files in your workspace's \\`.github/instructions\\` folder.`,\n\n promptsSection: `## π― Reusable Prompts\n\nReady-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.`,\n\n promptsUsage: `> π‘ **Usage**: Use \\`/prompt-name\\` in VS Code chat, run \\`Chat: Run Prompt\\` command, or hit the run button while you have a prompt open.`,\n\n chatmodesSection: `## π§© 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.`,\n\n chatmodesUsage: `> π‘ **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.`,\n\n footer: `## π Additional Resources\n\n- [VS Code Copilot Customization Documentation](https://code.visualstudio.com/docs/copilot/copilot-customization) - Official Microsoft documentation\n- [GitHub Copilot Chat Documentation](https://code.visualstudio.com/docs/copilot/chat/copilot-chat) - Complete chat feature guide\n- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration\n- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide\n\n## π οΈ Development Configuration\n\nThis repository uses various configuration files to ensure consistent code style and avoid issues with line endings:\n\n- [\\`.editorconfig\\`](.editorconfig) - Defines coding styles across different editors and IDEs\n- [\\`.gitattributes\\`](.gitattributes) - Ensures consistent line endings in text files\n- [\\`.vscode/settings.json\\`](.vscode/settings.json) - VS Code-specific settings for this repository\n- [\\`.vscode/extensions.json\\`](.vscode/extensions.json) - Recommended VS Code extensions\n\n> π‘ **Note**: All markdown files in this repository use LF line endings (Unix-style) to avoid mixed line endings issues. The repository is configured to automatically handle line endings conversion.\n\n## π License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## π€ Code of Conduct\n\nPlease note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n\n## β’οΈ Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.`,\n};\n\n// Add error handling utility\nfunction safeFileOperation(operation, filePath, defaultValue = null) {\n try {\n return operation();\n } catch (error) {\n console.error(`Error processing file ${filePath}: ${error.message}`);\n return defaultValue;\n }\n}\n\nfunction extractTitle(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n\n // Step 1: Look for title in frontmatter for all file types\n let inFrontmatter = false;\n let frontmatterEnded = false;\n\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (!frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n\n if (inFrontmatter && !frontmatterEnded) {\n // Look for title field in frontmatter\n if (line.includes(\"title:\")) {\n // Extract everything after 'title:'\n const afterTitle = line\n .substring(line.indexOf(\"title:\") + 6)\n .trim();\n // Remove quotes if present\n const cleanTitle = afterTitle.replace(/^['\"]|['\"]$/g, \"\");\n return cleanTitle;\n }\n }\n }\n\n // Reset for second pass\n inFrontmatter = false;\n frontmatterEnded = false;\n\n // Step 2: For prompt/chatmode/instructions files, look for heading after frontmatter\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".chatmode.md\") ||\n filePath.includes(\".instructions.md\")\n ) {\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else if (inFrontmatter && !frontmatterEnded) {\n frontmatterEnded = true;\n }\n continue;\n }\n\n if (frontmatterEnded && line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n\n // Step 3: Format filename for prompt/chatmode/instructions files if no heading found\n const basename = path.basename(\n filePath,\n filePath.includes(\".prompt.md\")\n ? \".prompt.md\"\n : filePath.includes(\".chatmode.md\")\n ? \".chatmode.md\"\n : \".instructions.md\"\n );\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n }\n\n // Step 4: For instruction files, look for the first heading\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n return line.substring(2).trim();\n }\n }\n\n // Step 5: Fallback to filename\n const basename = path.basename(filePath, path.extname(filePath));\n return basename\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase());\n },\n filePath,\n path\n .basename(filePath, path.extname(filePath))\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (l) => l.toUpperCase())\n );\n}\n\n", "suffix_code": "\n\n/**\n * Generate badges for installation links in VS Code and VS Code Insiders.\n * @param {string} link - The relative link to the instructions or prompts file.\n * @returns {string} - Markdown formatted badges for installation.\n */\nconst vscodeInstallImage =\n \"https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst vscodeInsidersInstallImage =\n \"https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white\";\nconst repoBaseUrl =\n \"https://raw.githubusercontent.com/github/awesome-copilot/main\";\nconst vscodeBaseUrl = \"https://vscode.dev/redirect?url=\";\nconst vscodeInsidersBaseUrl = \"https://insiders.vscode.dev/redirect?url=\";\nfunction makeBadges(link, type) {\n return `[](${vscodeBaseUrl}${encodeURIComponent(\n `vscode:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )} [](${vscodeInsidersBaseUrl}${encodeURIComponent(\n `vscode-insiders:chat-${type}/install?url=${repoBaseUrl}/${link})`\n )}`;\n}\n\n/**\n * Generate the instructions section with a table of all instructions\n */\nfunction generateInstructionsSection(instructionsDir) {\n // Get all instruction files\n const instructionFiles = fs\n .readdirSync(instructionsDir)\n .filter((file) => file.endsWith(\".md\"))\n .sort();\n\n console.log(`Found ${instructionFiles.length} instruction files`);\n\n // Create table header\n let instructionsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each instruction file\n for (const file of instructionFiles) {\n const filePath = path.join(instructionsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`instructions/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"instructions\");\n\n if (customDescription && customDescription !== \"null\") {\n // Use the description from frontmatter\n instructionsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n // Fallback to the default approach - use last word of title for description, removing trailing 's' if present\n const topic = title.split(\" \").pop().replace(/s$/, \"\");\n instructionsContent += `| [${title}](${link}) | ${topic} specific coding standards and best practices | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.instructionsSection}\\n\\n${instructionsContent}\\n${TEMPLATES.instructionsUsage}`;\n}\n\n/**\n * Generate the prompts section with a table of all prompts\n */\nfunction generatePromptsSection(promptsDir) {\n // Get all prompt files\n const promptFiles = fs\n .readdirSync(promptsDir)\n .filter((file) => file.endsWith(\".prompt.md\"))\n .sort();\n\n console.log(`Found ${promptFiles.length} prompt files`);\n\n // Create table header\n let promptsContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each prompt file\n for (const file of promptFiles) {\n const filePath = path.join(promptsDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`prompts/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"prompt\");\n\n if (customDescription && customDescription !== \"null\") {\n promptsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n promptsContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.promptsSection}\\n\\n${promptsContent}\\n${TEMPLATES.promptsUsage}`;\n}\n\n/**\n * Generate the chat modes section with a table of all chat modes\n */\nfunction generateChatModesSection(chatmodesDir) {\n // Check if chatmodes directory exists\n if (!fs.existsSync(chatmodesDir)) {\n console.log(\"Chat modes directory does not exist\");\n return \"\";\n }\n\n // Get all chat mode files\n const chatmodeFiles = fs\n .readdirSync(chatmodesDir)\n .filter((file) => file.endsWith(\".chatmode.md\"))\n .sort();\n\n console.log(`Found ${chatmodeFiles.length} chat mode files`);\n\n // If no chat modes, return empty string\n if (chatmodeFiles.length === 0) {\n return \"\";\n }\n\n // Create table header\n let chatmodesContent =\n \"| Title | Description | Install |\\n| ----- | ----------- | ------- |\\n\";\n\n // Generate table rows for each chat mode file\n for (const file of chatmodeFiles) {\n const filePath = path.join(chatmodesDir, file);\n const title = extractTitle(filePath);\n const link = encodeURI(`chatmodes/${file}`);\n\n // Check if there's a description in the frontmatter\n const customDescription = extractDescription(filePath);\n\n // Create badges for installation links\n const badges = makeBadges(link, \"chatmode\");\n\n if (customDescription && customDescription !== \"null\") {\n chatmodesContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\\n`;\n } else {\n chatmodesContent += `| [${title}](${link}) | | ${badges} |\\n`;\n }\n }\n\n return `${TEMPLATES.chatmodesSection}\\n\\n${chatmodesContent}\\n${TEMPLATES.chatmodesUsage}`;\n}\n\n/**\n * Generate the complete README.md content from scratch\n */\nfunction generateReadme() {\n const instructionsDir = path.join(__dirname, \"instructions\");\n const promptsDir = path.join(__dirname, \"prompts\");\n const chatmodesDir = path.join(__dirname, \"chatmodes\");\n\n // Generate each section\n const instructionsSection = generateInstructionsSection(instructionsDir);\n const promptsSection = generatePromptsSection(promptsDir);\n const chatmodesSection = generateChatModesSection(chatmodesDir);\n\n // Build the complete README content with template sections\n let readmeContent = [TEMPLATES.header, instructionsSection, promptsSection];\n\n // Only include chat modes section if we have any chat modes\n if (chatmodesSection) {\n readmeContent.push(chatmodesSection);\n }\n\n // Add footer\n readmeContent.push(TEMPLATES.footer);\n\n return readmeContent.join(\"\\n\\n\");\n}\n\n// Main execution\ntry {\n console.log(\"Generating README.md from scratch...\");\n\n const readmePath = path.join(__dirname, \"README.md\");\n const newReadmeContent = generateReadme();\n\n // Check if the README file already exists\n if (fs.existsSync(readmePath)) {\n const originalContent = fs.readFileSync(readmePath, \"utf8\");\n const hasChanges = originalContent !== newReadmeContent;\n\n if (hasChanges) {\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md updated successfully!\");\n } else {\n console.log(\"README.md is already up to date. No changes needed.\");\n }\n } else {\n // Create the README file if it doesn't exist\n fs.writeFileSync(readmePath, newReadmeContent);\n console.log(\"README.md created successfully!\");\n }\n} catch (error) {\n console.error(`Error generating README.md: ${error.message}`);\n process.exit(1);\n}\n", "middle_code": "function extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let isMultilineDescription = false;\n let multilineDescription = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n if (inFrontmatter) {\n const multilineMatch = line.match(/^description:\\s*\\|(\\s*)$/);\n if (multilineMatch) {\n isMultilineDescription = true;\n continue;\n }\n if (isMultilineDescription) {\n if (!line.startsWith(\" \") || line.match(/^[a-zA-Z0-9_-]+:/)) {\n return multilineDescription.join(\" \").trim();\n }\n multilineDescription.push(line.substring(2));\n } else {\n const descriptionMatch = line.match(\n /^description:\\s*['\"]?(.+?)['\"]?$/\n );\n if (descriptionMatch) {\n let description = descriptionMatch[1];\n const singleQuoteMatch = line.match(/^description:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n description = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n return description;\n }\n }\n }\n }\n if (multilineDescription.length > 0) {\n return multilineDescription.join(\" \").trim();\n }\n return null;\n },\n filePath,\n null\n );\n}", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [], "task_instance_info": {"created_time": "2025-08-20 23:54:57", "created_task_model": "DeepSeek-R1", "function_skeleton": "function extractDescription (filePath) {}", "code_description": "This code segment functions to: Extract structured metadata descriptions from text content by analyzing formatting patterns, handling both inline and multi-line values while implementing validation checks for consistent text structure identification."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\nfunction extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n\n // Step 1: Look for description in frontmatter\n let inFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (inFrontmatter) break; // End of frontmatter\n inFrontmatter = true;\n continue;\n }\n\n if (inFrontmatter && line.includes(\"description:\")) {\n const afterDesc = line.substring(line.indexOf(\"description:\") + 12).trim();\n return afterDesc.replace(/^['\"]|['\"]$/g, \"\");\n }\n }\n\n // Step 2: Look for first paragraph after frontmatter for prompt/instructions files\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".instructions.md\") ||\n filePath.includes(\".chatmode.md\")\n ) {\n let passedFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n passedFrontmatter = true;\n continue;\n }\n \n if (passedFrontmatter && line.startsWith(\"> \")) {\n return line.substring(2).trim().replace(/<\\/?em>/g, \"\");\n }\n }\n }\n\n // Step 3: Look for HTML comment description\n const commentMatch = content.match(/<!--\\s*Description:\\s*(.+?)\\s*-->/);\n if (commentMatch) {\n return commentMatch[1].trim();\n }\n\n return null;\n },\n filePath,\n null\n );\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 23-55-18"}, "editdistance_info": {"edit_distance": 32.3034, "calculate_time": "2025-08-20 23:55:18", "true_code_clean": "function extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let isMultilineDescription = false;\n let multilineDescription = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line.trim() === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n continue;\n }\n break;\n }\n if (inFrontmatter) {\n const multilineMatch = line.match(/^description:\\s*\\|(\\s*)$/);\n if (multilineMatch) {\n isMultilineDescription = true;\n continue;\n }\n if (isMultilineDescription) {\n if (!line.startsWith(\" \") || line.match(/^[a-zA-Z0-9_-]+:/)) {\n return multilineDescription.join(\" \").trim();\n }\n multilineDescription.push(line.substring(2));\n } else {\n const descriptionMatch = line.match(\n /^description:\\s*['\"]?(.+?)['\"]?$/\n );\n if (descriptionMatch) {\n let description = descriptionMatch[1];\n const singleQuoteMatch = line.match(/^description:\\s*'(.+)'$/);\n if (singleQuoteMatch) {\n description = singleQuoteMatch[1].replace(/''/g, \"'\");\n }\n return description;\n }\n }\n }\n }\n if (multilineDescription.length > 0) {\n return multilineDescription.join(\" \").trim();\n }\n return null;\n },\n filePath,\n null\n );\n}", "predict_code_clean": "function extractDescription(filePath) {\n return safeFileOperation(\n () => {\n const content = fs.readFileSync(filePath, \"utf8\");\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n if (inFrontmatter) break; \n inFrontmatter = true;\n continue;\n }\n if (inFrontmatter && line.includes(\"description:\")) {\n const afterDesc = line.substring(line.indexOf(\"description:\") + 12).trim();\n return afterDesc.replace(/^['\"]|['\"]$/g, \"\");\n }\n }\n if (\n filePath.includes(\".prompt.md\") ||\n filePath.includes(\".instructions.md\") ||\n filePath.includes(\".chatmode.md\")\n ) {\n let passedFrontmatter = false;\n for (const line of lines) {\n if (line.trim() === \"---\") {\n passedFrontmatter = true;\n continue;\n }\n if (passedFrontmatter && line.startsWith(\"> \")) {\n return line.substring(2).trim().replace(/<\\/?em>/g, \"\");\n }\n }\n }\n const commentMatch = content.match(/<!--\\s*Description:\\s*(.+?)\\s*-->/);\n if (commentMatch) {\n return commentMatch[1].trim();\n }\n return null;\n },\n filePath,\n null\n );\n}"}}
|