Implement refined installation process with .awesome-copilot directory structure
Co-authored-by: AstroSteveo <34114851+AstroSteveo@users.noreply.github.com>
This commit is contained in:
parent
7d67aef601
commit
61e056c8e0
93
CONFIG.md
93
CONFIG.md
@ -1,20 +1,42 @@
|
||||
# Configuration File System
|
||||
|
||||
The Awesome Copilot repository now supports a configuration file system that allows you to easily manage which prompts, instructions, chat modes, and collections are included in your project.
|
||||
The Awesome Copilot repository supports a configuration file system that allows you to easily manage which prompts, instructions, chat modes, and collections are included in your project.
|
||||
|
||||
## Installation
|
||||
|
||||
### Via NPM (Recommended)
|
||||
```bash
|
||||
# Install globally
|
||||
npm install -g awesome-copilot
|
||||
|
||||
# Or run without installing
|
||||
npx awesome-copilot init
|
||||
```
|
||||
|
||||
### Via Git Clone
|
||||
```bash
|
||||
git clone https://github.com/AstroSteveo/awesome-copilot
|
||||
cd awesome-copilot
|
||||
npm install
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Generate a Configuration File
|
||||
### 1. Initialize Your Project
|
||||
|
||||
```bash
|
||||
# Generate default configuration file
|
||||
node awesome-copilot.js init
|
||||
# Initialize with default configuration
|
||||
awesome-copilot init
|
||||
|
||||
# Or generate with a specific name
|
||||
node awesome-copilot.js init my-project.config.yml
|
||||
# Or initialize with a specific name
|
||||
awesome-copilot init my-project.config.yml
|
||||
```
|
||||
|
||||
This creates a YAML configuration file with all available items set to `false` by default.
|
||||
This creates:
|
||||
- Configuration file (`awesome-copilot.config.yml`)
|
||||
- `.awesome-copilot/` directory structure
|
||||
- VS Code settings pointing to `.awesome-copilot/` directories
|
||||
- `.gitignore` entry to exclude generated files
|
||||
|
||||
### 2. Enable Desired Items
|
||||
|
||||
@ -25,7 +47,7 @@ version: "1.0"
|
||||
project:
|
||||
name: "My Project"
|
||||
description: "A project using awesome-copilot customizations"
|
||||
output_directory: ".github"
|
||||
output_directory: ".awesome-copilot"
|
||||
prompts:
|
||||
create-readme: true
|
||||
editorconfig: true
|
||||
@ -47,13 +69,13 @@ collections:
|
||||
|
||||
```bash
|
||||
# Apply default configuration file
|
||||
node awesome-copilot.js apply
|
||||
awesome-copilot apply
|
||||
|
||||
# Or apply specific configuration file
|
||||
node awesome-copilot.js apply my-project.config.yml
|
||||
awesome-copilot apply my-project.config.yml
|
||||
```
|
||||
|
||||
This will copy the enabled files to your project's `.github` directory (or the directory specified in the config).
|
||||
This will copy the enabled files to your project's `.awesome-copilot` directory (or the directory specified in the config).
|
||||
|
||||
## Configuration File Format
|
||||
|
||||
@ -95,29 +117,42 @@ collections:
|
||||
When you apply a configuration, files are organized as follows:
|
||||
|
||||
```
|
||||
.github/
|
||||
├── copilot/
|
||||
│ ├── *.prompt.md # Prompts for /awesome-copilot commands
|
||||
.awesome-copilot/
|
||||
├── prompts/
|
||||
│ └── *.prompt.md # Prompts for /awesome-copilot commands
|
||||
├── chatmodes/
|
||||
│ └── *.chatmode.md # Chat modes for VS Code
|
||||
└── instructions/
|
||||
└── *.instructions.md # Instructions that auto-apply to coding
|
||||
```
|
||||
|
||||
VS Code automatically detects these files through the generated `.vscode/settings.json` configuration.
|
||||
|
||||
## NPM Scripts
|
||||
|
||||
You can also use npm scripts instead of the CLI:
|
||||
If you've cloned the repository locally, you can also use npm scripts:
|
||||
|
||||
```bash
|
||||
# Generate configuration
|
||||
# Initialize configuration
|
||||
npm run config:init
|
||||
|
||||
# Apply configuration
|
||||
npm run config:apply
|
||||
|
||||
# Access CLI
|
||||
# Access CLI help
|
||||
npm run config help
|
||||
```
|
||||
|
||||
## VS Code Integration
|
||||
|
||||
The `awesome-copilot init` command automatically configures VS Code to detect your customizations:
|
||||
|
||||
- Creates `.vscode/settings.json` with proper file locations
|
||||
- Points to `.awesome-copilot/` directories instead of framework directories
|
||||
- Maintains separation between your project and the awesome-copilot framework
|
||||
|
||||
No manual VS Code configuration needed!
|
||||
|
||||
## Examples
|
||||
|
||||
### Frontend React Project
|
||||
@ -142,7 +177,7 @@ chatmodes:
|
||||
version: "1.0"
|
||||
project:
|
||||
name: ".NET API"
|
||||
output_directory: ".github"
|
||||
output_directory: ".awesome-copilot"
|
||||
collections:
|
||||
csharp-dotnet-development: true
|
||||
instructions:
|
||||
@ -157,7 +192,7 @@ prompts:
|
||||
version: "1.0"
|
||||
project:
|
||||
name: "Full Stack App"
|
||||
output_directory: ".github"
|
||||
output_directory: ".awesome-copilot"
|
||||
collections:
|
||||
frontend-web-dev: true
|
||||
csharp-dotnet-development: true
|
||||
@ -169,17 +204,23 @@ chatmodes:
|
||||
|
||||
## Migration from Manual Approach
|
||||
|
||||
If you were previously copying files manually:
|
||||
If you were previously copying files manually or using an older version:
|
||||
|
||||
1. Remove manually copied files from your `.github` directory
|
||||
2. Run `node awesome-copilot.js init` to create a config file
|
||||
3. Edit the config to enable the same items you were using manually
|
||||
4. Run `node awesome-copilot.js apply` to get a clean, managed setup
|
||||
2. Install awesome-copilot: `npm install -g awesome-copilot`
|
||||
3. Run `awesome-copilot init` to create a clean setup
|
||||
4. Edit the config to enable the same items you were using manually
|
||||
5. Run `awesome-copilot apply` to get a clean, managed setup
|
||||
|
||||
The new approach uses `.awesome-copilot/` directory instead of `.github/` for better separation.
|
||||
|
||||
## Benefits
|
||||
|
||||
- **Clean Installation**: Install via npm/npx, no need to clone the entire repository
|
||||
- **Centralized Management**: One file controls all your Copilot customizations
|
||||
- **Version Control Friendly**: Config file tracks what's enabled in your project
|
||||
- **Easy Updates**: Re-run apply command after pulling awesome-copilot updates
|
||||
- **VS Code Integration**: Automatic configuration, no manual setup required
|
||||
- **Clear Separation**: Framework files separated from your project files
|
||||
- **Version Control Friendly**: Config file tracks what's enabled, generated files are ignored
|
||||
- **Easy Updates**: Re-run apply command after awesome-copilot updates
|
||||
- **Collection Support**: Enable entire curated sets with one setting
|
||||
- **Clean Organization**: Files are organized in proper directory structure
|
||||
- **Minimal Footprint**: Only enabled files are copied to your project
|
||||
@ -78,12 +78,13 @@ async function applyConfig(configPath = "awesome-copilot.config.yml") {
|
||||
console.log("Applying awesome-copilot configuration...");
|
||||
|
||||
const rootDir = __dirname;
|
||||
const outputDir = config.project?.output_directory || ".github";
|
||||
const outputDir = config.project?.output_directory || ".awesome-copilot";
|
||||
|
||||
// Create output directory structure
|
||||
ensureDirectoryExists(outputDir);
|
||||
ensureDirectoryExists(path.join(outputDir, "copilot"));
|
||||
ensureDirectoryExists(path.join(outputDir, "prompts"));
|
||||
ensureDirectoryExists(path.join(outputDir, "instructions"));
|
||||
ensureDirectoryExists(path.join(outputDir, "chatmodes"));
|
||||
|
||||
let copiedCount = 0;
|
||||
const summary = {
|
||||
@ -119,7 +120,7 @@ async function applyConfig(configPath = "awesome-copilot.config.yml") {
|
||||
if (enabled) {
|
||||
const sourcePath = path.join(rootDir, "prompts", `${promptName}.prompt.md`);
|
||||
if (fs.existsSync(sourcePath)) {
|
||||
const destPath = path.join(outputDir, "copilot", `${promptName}.prompt.md`);
|
||||
const destPath = path.join(outputDir, "prompts", `${promptName}.prompt.md`);
|
||||
copyFile(sourcePath, destPath);
|
||||
copiedCount++;
|
||||
summary.prompts++;
|
||||
@ -149,7 +150,7 @@ async function applyConfig(configPath = "awesome-copilot.config.yml") {
|
||||
if (enabled) {
|
||||
const sourcePath = path.join(rootDir, "chatmodes", `${chatmodeName}.chatmode.md`);
|
||||
if (fs.existsSync(sourcePath)) {
|
||||
const destPath = path.join(outputDir, "copilot", `${chatmodeName}.chatmode.md`);
|
||||
const destPath = path.join(outputDir, "chatmodes", `${chatmodeName}.chatmode.md`);
|
||||
copyFile(sourcePath, destPath);
|
||||
copiedCount++;
|
||||
summary.chatmodes++;
|
||||
@ -165,8 +166,10 @@ async function applyConfig(configPath = "awesome-copilot.config.yml") {
|
||||
const fileName = path.basename(itemPath);
|
||||
let destPath;
|
||||
|
||||
if (fileName.endsWith('.prompt.md') || fileName.endsWith('.chatmode.md')) {
|
||||
destPath = path.join(outputDir, "copilot", fileName);
|
||||
if (fileName.endsWith('.prompt.md')) {
|
||||
destPath = path.join(outputDir, "prompts", fileName);
|
||||
} else if (fileName.endsWith('.chatmode.md')) {
|
||||
destPath = path.join(outputDir, "chatmodes", fileName);
|
||||
} else if (fileName.endsWith('.instructions.md')) {
|
||||
destPath = path.join(outputDir, "instructions", fileName);
|
||||
}
|
||||
|
||||
@ -5,11 +5,12 @@ const { applyConfig } = require("./apply-config");
|
||||
|
||||
const commands = {
|
||||
init: {
|
||||
description: "Generate a new configuration file",
|
||||
description: "Initialize a new project with awesome-copilot configuration",
|
||||
usage: "awesome-copilot init [config-file]",
|
||||
action: async (args) => {
|
||||
const configFile = args[0] || "awesome-copilot.config.yml";
|
||||
generateConfig(configFile);
|
||||
const { initializeProject } = require("./initialize-project");
|
||||
await initializeProject(configFile);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ function generateConfig(outputPath = "awesome-copilot.config.yml") {
|
||||
project: {
|
||||
name: "My Project",
|
||||
description: "A project using awesome-copilot customizations",
|
||||
output_directory: ".github"
|
||||
output_directory: ".awesome-copilot"
|
||||
},
|
||||
prompts: {},
|
||||
instructions: {},
|
||||
|
||||
171
initialize-project.js
Normal file
171
initialize-project.js
Normal file
@ -0,0 +1,171 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { generateConfig } = require("./generate-config");
|
||||
|
||||
/**
|
||||
* Initialize a new project with awesome-copilot configuration
|
||||
*/
|
||||
async function initializeProject(configFile = "awesome-copilot.config.yml") {
|
||||
console.log("🚀 Initializing awesome-copilot project...");
|
||||
console.log("=" .repeat(50));
|
||||
|
||||
// Generate the configuration file
|
||||
generateConfig(configFile);
|
||||
|
||||
// Create .vscode directory and settings if they don't exist
|
||||
createVSCodeSettings();
|
||||
|
||||
// Create .gitignore entry for awesome-copilot directory
|
||||
updateGitignore();
|
||||
|
||||
// Create awesome-copilot directory structure
|
||||
createProjectStructure();
|
||||
|
||||
console.log("\n" + "=" .repeat(50));
|
||||
console.log("✅ Project initialization complete!");
|
||||
console.log("=" .repeat(50));
|
||||
console.log("\nNext steps:");
|
||||
console.log(`1. Edit ${configFile} to enable desired prompts, instructions, and chat modes`);
|
||||
console.log("2. Run 'awesome-copilot apply' to copy enabled files to your project");
|
||||
console.log("3. Your VS Code is now configured to use .awesome-copilot/ directory");
|
||||
console.log("4. Files in .awesome-copilot/ are automatically ignored by git");
|
||||
console.log("\nWorkflow:");
|
||||
console.log("• Edit configuration → apply → VS Code automatically picks up changes");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create VS Code settings that point to .awesome-copilot directory
|
||||
*/
|
||||
function createVSCodeSettings() {
|
||||
const vscodeDir = ".vscode";
|
||||
const settingsFile = path.join(vscodeDir, "settings.json");
|
||||
|
||||
// Ensure .vscode directory exists
|
||||
if (!fs.existsSync(vscodeDir)) {
|
||||
fs.mkdirSync(vscodeDir, { recursive: true });
|
||||
console.log("📁 Created .vscode directory");
|
||||
}
|
||||
|
||||
// VS Code settings template for awesome-copilot
|
||||
const awesomeCopilotSettings = {
|
||||
"chat.modeFilesLocations": {
|
||||
".awesome-copilot/chatmodes": true
|
||||
},
|
||||
"chat.promptFilesLocations": {
|
||||
".awesome-copilot/prompts": true
|
||||
},
|
||||
"chat.instructionsFilesLocations": {
|
||||
".awesome-copilot/instructions": true
|
||||
}
|
||||
};
|
||||
|
||||
let settings = {};
|
||||
let settingsExisted = false;
|
||||
|
||||
// Read existing settings if they exist
|
||||
if (fs.existsSync(settingsFile)) {
|
||||
try {
|
||||
const existingContent = fs.readFileSync(settingsFile, 'utf8');
|
||||
settings = JSON.parse(existingContent);
|
||||
settingsExisted = true;
|
||||
} catch (error) {
|
||||
console.log("⚠️ Warning: Could not parse existing VS Code settings, creating new ones");
|
||||
}
|
||||
}
|
||||
|
||||
// Merge awesome-copilot settings
|
||||
Object.assign(settings, awesomeCopilotSettings);
|
||||
|
||||
// Write settings back
|
||||
fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2));
|
||||
|
||||
if (settingsExisted) {
|
||||
console.log("⚙️ Updated existing VS Code settings with awesome-copilot configuration");
|
||||
} else {
|
||||
console.log("⚙️ Created VS Code settings for awesome-copilot");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update .gitignore to exclude awesome-copilot directory
|
||||
*/
|
||||
function updateGitignore() {
|
||||
const gitignoreFile = ".gitignore";
|
||||
const gitignoreEntry = "\n# Awesome Copilot generated files\n.awesome-copilot/\n";
|
||||
|
||||
let shouldAdd = true;
|
||||
|
||||
if (fs.existsSync(gitignoreFile)) {
|
||||
const content = fs.readFileSync(gitignoreFile, 'utf8');
|
||||
if (content.includes('.awesome-copilot/')) {
|
||||
shouldAdd = false;
|
||||
console.log("📝 .gitignore already contains .awesome-copilot/ entry");
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldAdd) {
|
||||
fs.appendFileSync(gitignoreFile, gitignoreEntry);
|
||||
console.log("📝 Added .awesome-copilot/ to .gitignore");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create basic project structure
|
||||
*/
|
||||
function createProjectStructure() {
|
||||
const awesomeDir = ".awesome-copilot";
|
||||
|
||||
// Create main directory and subdirectories
|
||||
const dirs = [
|
||||
awesomeDir,
|
||||
path.join(awesomeDir, "prompts"),
|
||||
path.join(awesomeDir, "instructions"),
|
||||
path.join(awesomeDir, "chatmodes")
|
||||
];
|
||||
|
||||
dirs.forEach(dir => {
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
console.log(`📁 Created ${dir} directory`);
|
||||
}
|
||||
});
|
||||
|
||||
// Create a README in the awesome-copilot directory
|
||||
const readmeContent = `# Awesome Copilot Configuration
|
||||
|
||||
This directory contains your project's GitHub Copilot customizations.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
- \`prompts/\` - Custom prompts for /awesome-copilot commands
|
||||
- \`instructions/\` - Instructions that auto-apply to your coding
|
||||
- \`chatmodes/\` - Chat modes for enhanced conversations
|
||||
|
||||
## Usage
|
||||
|
||||
1. Edit \`awesome-copilot.config.yml\` in your project root
|
||||
2. Run \`awesome-copilot apply\` to update files
|
||||
3. VS Code automatically detects changes
|
||||
|
||||
Files in this directory are automatically ignored by git.
|
||||
`;
|
||||
|
||||
const readmePath = path.join(awesomeDir, "README.md");
|
||||
if (!fs.existsSync(readmePath)) {
|
||||
fs.writeFileSync(readmePath, readmeContent);
|
||||
console.log("📄 Created README.md in .awesome-copilot directory");
|
||||
}
|
||||
}
|
||||
|
||||
// CLI usage
|
||||
if (require.main === module) {
|
||||
const configFile = process.argv[2] || "awesome-copilot.config.yml";
|
||||
initializeProject(configFile).catch(error => {
|
||||
console.error("Error initializing project:", error.message);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { initializeProject };
|
||||
@ -2,7 +2,10 @@
|
||||
"name": "awesome-copilot",
|
||||
"version": "1.0.0",
|
||||
"description": "Enhance your GitHub Copilot experience with community-contributed instructions, prompts, and chat modes",
|
||||
"main": "update-readme.js",
|
||||
"main": "awesome-copilot.js",
|
||||
"bin": {
|
||||
"awesome-copilot": "./awesome-copilot.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node update-readme.js",
|
||||
"config:init": "node generate-config.js",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user