UNPKG

erosolar-cli

Version:

Unified AI agent framework for the command line - Multi-provider support with schema-driven tools, code intelligence, and transparent reasoning

143 lines (119 loc) • 4.32 kB
#!/usr/bin/env node /** * Task Completion Verification Script * * This script should be called AFTER an assistant indicates task completion * to perform comprehensive human-centered verification. */ import { HumanVerification } from './human-verification.mjs'; import { readFileSync, existsSync } from 'fs'; class TaskCompletionVerifier { constructor() { this.verifier = new HumanVerification(); } /** * Main verification workflow */ async verify(taskDescription, changes = {}) { console.log('šŸš€ TASK COMPLETION VERIFICATION'); console.log('================================'); // Auto-detect changes if not provided const detectedChanges = Object.keys(changes).length > 0 ? changes : await this.detectRecentChanges(); // Get user context from environment or defaults const userContext = this.getUserContext(); // Run human verification const report = await this.verifier.verifyTaskCompletion( taskDescription, detectedChanges, userContext ); // Generate actionable summary this.generateActionableSummary(report); return report; } /** * Auto-detect recent changes in the workspace */ async detectRecentChanges() { const changes = {}; // Check for recently modified files const recentFiles = [ 'scripts/human-verification.mjs', 'scripts/verify-task-completion.mjs', 'package.json' ]; for (const file of recentFiles) { if (existsSync(file)) { try { const content = readFileSync(file, 'utf8'); changes[file] = content.substring(0, 500) + '...'; // Truncate for display } catch (error) { changes[file] = `[Error reading file: ${error.message}]`; } } } return changes; } /** * Get user context for better verification */ getUserContext() { return { // Default context - in real usage, this would come from user profile technicalLevel: 'intermediate', projectType: 'cli-tool', urgency: 'standard', learningPreference: 'balanced' }; } /** * Generate actionable summary for the user */ generateActionableSummary(report) { console.log('\nšŸŽÆ ACTIONABLE SUMMARY'); console.log('===================='); if (report.overallStatus === 'āœ… SUCCESS') { console.log('āœ… Task completed successfully!'); console.log(' The solution appears to meet your needs.'); console.log(' Consider these next steps:'); console.log(' 1. Test the implementation in your environment'); console.log(' 2. Provide feedback on any adjustments needed'); console.log(' 3. Document any learnings for future reference'); } else { console.log('āš ļø Task needs attention'); console.log(' Please review these areas:'); report.recommendations.forEach((rec, index) => { console.log(` ${index + 1}. ${rec}`); }); console.log('\nšŸ’” Suggested actions:'); console.log(' 1. Review the specific areas flagged above'); console.log(' 2. Test edge cases and error conditions'); console.log(' 3. Consider if the solution truly solves your problem'); } console.log('\nšŸ¤ HUMAN VERIFICATION COMPLETE'); console.log('=============================='); console.log('Remember: This verification complements technical validation.'); console.log('Always trust your own judgment about whether the solution'); console.log('actually meets your needs in practice.'); } } // Export for use in other scripts export { TaskCompletionVerifier }; // CLI interface if (import.meta.url === `file://${process.argv[1]}`) { const verifier = new TaskCompletionVerifier(); // Get task description from command line or use default const taskDescription = process.argv[2] || 'Create human verification framework'; console.log(`Verifying task: "${taskDescription}"`); verifier.verify(taskDescription) .then(report => { console.log('\nšŸŽ‰ Verification process complete!'); process.exit(report.overallStatus === 'āœ… SUCCESS' ? 0 : 1); }) .catch(error => { console.error('Verification failed:', error); process.exit(1); }); }