UNPKG

capsule-ai-cli

Version:

The AI Model Orchestrator - Intelligent multi-model workflows with device-locked licensing

56 lines 1.89 kB
import chalk from 'chalk'; import { EventEmitter } from 'events'; export class EditConfirmationService extends EventEmitter { autoApprove = false; pendingConfirmation = null; setAutoApprove(enabled) { this.autoApprove = enabled; } isAutoApprove() { return this.autoApprove; } async confirmEdit(preview) { if (this.autoApprove) { const message = chalk.dim(` ⎿ Auto-applying edit to ${preview.filePath}`); console.log(message); return true; } return new Promise((resolve) => { this.emit('showEditConfirmation', { ...preview, onConfirm: () => { resolve(true); }, onCancel: () => { resolve(false); } }); }); } async confirmMultipleEdits(previews) { if (this.autoApprove) { const message = chalk.dim(` ⎿ Auto-applying ${previews.length} edits`); console.log(message); return previews.map(() => true); } const message = chalk.yellow(`\n📝 ${previews.length} edits proposed`); console.log(message); return new Promise((resolve) => { const results = []; let currentIndex = 0; const processNext = async () => { if (currentIndex >= previews.length) { resolve(results); return; } const approved = await this.confirmEdit(previews[currentIndex]); results.push(approved); currentIndex++; processNext(); }; processNext(); }); } } export const editConfirmationService = new EditConfirmationService(); //# sourceMappingURL=edit-confirmation.js.map