|
#!/usr/bin/env node |
|
// VS Code Plan Prompts Installer |
|
// Usage: |
|
// > curl -fsSL https://gist.githubusercontent.com/digitarald/4b0060196821243dd9431669a25dfff7/raw/91333a55681977d5baf23ee6b88a7b08484db524/install-vscode-plan-prompts.js | node |
|
|
|
const https = require('https'); |
|
const fs = require('fs'); |
|
const path = require('path'); |
|
const readline = require('readline'); |
|
|
|
const GIST_BASE = 'https://gist.githubusercontent.com/digitarald/4b0060196821243dd9431669a25dfff7/raw'; |
|
|
|
const files = [ |
|
{ url: `${GIST_BASE}/plan-deep.prompt.md`, dest: '.github/prompts/plan-deep.prompt.md' }, |
|
{ url: `${GIST_BASE}/plan-fast.prompt.md`, dest: '.github/prompts/plan-fast.prompt.md' }, |
|
{ url: `${GIST_BASE}/Plan.chatmode.md`, dest: '.github/chatmodes/Plan.chatmode.md' } |
|
]; |
|
|
|
const newSettings = { |
|
"chat.promptFilesRecommendations": { |
|
"plan-fast": true, |
|
"plan-deep": true |
|
}, |
|
"github.copilot.chat.executePrompt.enabled": true |
|
}; |
|
|
|
const rl = readline.createInterface({ |
|
input: process.stdin, |
|
output: process.stdout |
|
}); |
|
|
|
function prompt(question) { |
|
return new Promise(resolve => rl.question(question, resolve)); |
|
} |
|
|
|
function download(url) { |
|
return new Promise((resolve, reject) => { |
|
https.get(url, res => { |
|
let data = ''; |
|
res.on('data', chunk => data += chunk); |
|
res.on('end', () => resolve(data)); |
|
}).on('error', reject); |
|
}); |
|
} |
|
|
|
async function downloadFile(url, dest) { |
|
if (fs.existsSync(dest)) { |
|
const answer = await prompt(`File '${dest}' already exists. Override? [y/N] `); |
|
if (!answer.match(/^y(es)?$/i)) { |
|
console.log(`Skipping ${dest}`); |
|
return; |
|
} |
|
} |
|
|
|
console.log(`Downloading ${dest}...`); |
|
const data = await download(url); |
|
fs.mkdirSync(path.dirname(dest), { recursive: true }); |
|
fs.writeFileSync(dest, data); |
|
} |
|
|
|
async function updateSettings() { |
|
const settingsFile = '.vscode/settings.json'; |
|
fs.mkdirSync('.vscode', { recursive: true }); |
|
|
|
let settings = {}; |
|
if (fs.existsSync(settingsFile)) { |
|
console.log('Updating settings.json...'); |
|
const content = fs.readFileSync(settingsFile, 'utf8'); |
|
settings = JSON.parse(content); |
|
} else { |
|
console.log('Creating settings.json...'); |
|
} |
|
|
|
Object.assign(settings, newSettings); |
|
fs.writeFileSync(settingsFile, JSON.stringify(settings, null, '\t') + '\n'); |
|
} |
|
|
|
async function main() { |
|
console.log('Installing VS Code Plan Prompts...\n'); |
|
|
|
for (const file of files) { |
|
await downloadFile(file.url, file.dest); |
|
} |
|
|
|
await updateSettings(); |
|
|
|
console.log('\n✓ Installation complete!\n'); |
|
console.log('Files installed:'); |
|
files.forEach(f => console.log(` - ${f.dest}`)); |
|
console.log(' - .vscode/settings.json (updated)'); |
|
|
|
rl.close(); |
|
} |
|
|
|
main().catch(err => { |
|
console.error('Error:', err.message); |
|
process.exit(1); |
|
}); |