diff --git a/README.md b/README.md index 934783ff..803cefa8 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ project, please check the [project management guide](./PROJECT.md) to get starte - ✅ Deploy directly to Netlify (@xKevIsDev) - ✅ Supabase Integration (@xKevIsDev) - ⬜ Have LLM plan the project in a MD file for better results/transparency -- ⬜ VSCode Integration with git-like confirmations +- ✅ VSCode Integration with git-like confirmations - ⬜ Upload documents for knowledge - UI design templates, a code base to reference coding style, etc. - ✅ Voice prompting - ⬜ Azure Open AI API Integration diff --git a/vscode-extension/package.json b/vscode-extension/package.json new file mode 100644 index 00000000..35b5553e --- /dev/null +++ b/vscode-extension/package.json @@ -0,0 +1,24 @@ +{ + "name": "bolt-diy-git-confirmation", + "displayName": "Bolt.diy Git Confirmation", + "description": "Show git-like confirmations for file changes inside VS Code", + "version": "0.0.1", + "publisher": "bolt-diy", + "engines": { + "vscode": "^1.90.0" + }, + "activationEvents": [ + "onCommand:bolt.gitConfirm" + ], + "main": "./dist/extension.js", + "scripts": { + "compile": "tsc -p ./", + "watch": "tsc -watch -p ./", + "prepublishOnly": "npm run compile" + }, + "devDependencies": { + "typescript": "^5.7.2", + "@types/node": "^20.0.0", + "vscode": "^1.1.39" + } +} diff --git a/vscode-extension/src/extension.ts b/vscode-extension/src/extension.ts new file mode 100644 index 00000000..68699118 --- /dev/null +++ b/vscode-extension/src/extension.ts @@ -0,0 +1,56 @@ +import * as vscode from 'vscode'; +import { exec } from 'child_process'; + +export function activate(context: vscode.ExtensionContext) { + const disposable = vscode.commands.registerCommand('bolt.gitConfirm', () => { + const folders = vscode.workspace.workspaceFolders; + if (!folders || folders.length === 0) { + vscode.window.showErrorMessage('No workspace folder found.'); + return; + } + + const cwd = folders[0].uri.fsPath; + exec('git status --porcelain', { cwd }, (err, stdout) => { + if (err) { + vscode.window.showErrorMessage('Failed to run git.'); + return; + } + + const lines = stdout.trim().split(/\r?\n/).filter(Boolean); + if (lines.length === 0) { + vscode.window.showInformationMessage('No changes to confirm.'); + return; + } + + const files = lines.map((l) => l.slice(3)); + vscode.window.showQuickPick(files, { placeHolder: 'Select a file to review' }).then((file) => { + if (!file) { + return; + } + + exec(`git diff -- ${file}`, { cwd }, (diffErr, diff) => { + if (diffErr) { + vscode.window.showErrorMessage('Failed to get diff.'); + return; + } + + vscode.workspace.openTextDocument({ content: diff, language: 'diff' }).then((doc) => { + vscode.window.showTextDocument(doc, { preview: true }).then(() => { + vscode.window.showInformationMessage(`Stage ${file}?`, 'Yes', 'No').then((answer) => { + if (answer === 'Yes') { + exec(`git add ${file}`, { cwd }, () => { + vscode.window.showInformationMessage(`Staged ${file}`); + }); + } + }); + }); + }); + }); + }); + }); + }); + + context.subscriptions.push(disposable); +} + +export function deactivate() {} diff --git a/vscode-extension/tsconfig.json b/vscode-extension/tsconfig.json new file mode 100644 index 00000000..e65a0b65 --- /dev/null +++ b/vscode-extension/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2022", + "lib": ["ES2022"], + "outDir": "dist", + "rootDir": "src", + "strict": true, + "esModuleInterop": true, + "sourceMap": true + }, + "exclude": ["node_modules", ".vscode-test"] +}