--- allowed-tools: - Read - Write - Edit - Bash - Task argument-hint: "[--step-by-step] [--auto-pause] [--verbose]" description: "Modalitร  interattiva con esecuzione step-by-step e controllo utente" --- # Toduba Interactive Mode - Esecuzione Interattiva ๐ŸŽฎ ## Obiettivo Fornire un'esecuzione controllata step-by-step con possibilitร  di pause, resume, undo e controllo completo del flusso. ## Argomenti - `--step-by-step`: Richiede conferma ad ogni step - `--auto-pause`: Pausa automatica su warning/error - `--verbose`: Output dettagliato per ogni operazione - `--checkpoint`: Crea checkpoint ad ogni step major Argomenti ricevuti: $ARGUMENTS ## Interactive Session Manager ```typescript class InteractiveSession { private steps: Step[] = []; private currentStep: number = 0; private paused: boolean = false; private history: StepResult[] = []; private checkpoints: Checkpoint[] = []; async start(task: Task) { console.log('๐ŸŽฎ TODUBA INTERACTIVE MODE'); console.log('โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”'); console.log(''); console.log('Controls:'); console.log(' [Enter] - Continue'); console.log(' [p] - Pause'); console.log(' [s] - Skip step'); console.log(' [u] - Undo last'); console.log(' [r] - Resume all'); console.log(' [q] - Quit'); console.log(''); this.initializeSteps(task); await this.executeInteractive(); } } ``` ## Step-by-Step Execution Flow ### Visual Progress Display ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ ๐ŸŽฎ INTERACTIVE EXECUTION โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”‚ โ”‚ Task: Create user authentication API โ”‚ โ”‚ Mode: Step-by-step โ”‚ โ”‚ Progress: [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘] 40% (4/10 steps) โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€ Current Step โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Step 4: Creating user model โ”‚ โ”‚ โ”‚ โ”‚ Agent: toduba-backend-engineer โ”‚ โ”‚ โ”‚ โ”‚ Action: Write file models/User.js โ”‚ โ”‚ โ”‚ โ”‚ Status: โธ๏ธ Awaiting confirmation โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ Previous: โœ… Database connection setup โ”‚ โ”‚ Next: Create authentication middleware โ”‚ โ”‚ โ”‚ โ”‚ [Enter] Continue | [p] Pause | [u] Undo | [q] Quit โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### Step Structure ```typescript interface Step { id: string; name: string; description: string; agent: string; action: Action; dependencies: string[]; canUndo: boolean; critical: boolean; estimatedTime: number; } interface Action { type: 'create' | 'modify' | 'delete' | 'execute'; target: string; details: any; } ``` ## Interactive Controls Implementation ### Pause/Resume System ```javascript const handleUserInput = async (input) => { switch(input.toLowerCase()) { case 'p': case 'pause': await pauseExecution(); break; case 'r': case 'resume': await resumeExecution(); break; case 's': case 'skip': await skipCurrentStep(); break; case 'u': case 'undo': await undoLastStep(); break; case 'q': case 'quit': await quitInteractive(); break; case '': case 'enter': await continueExecution(); break; case 'h': case 'help': showInteractiveHelp(); break; default: console.log('Unknown command. Press [h] for help.'); } }; ``` ### Undo Mechanism ```javascript async undoLastStep() { if (this.history.length === 0) { console.log('โŒ No steps to undo'); return; } const lastStep = this.history.pop(); console.log(`โ†ฉ๏ธ Undoing: ${lastStep.step.name}`); // Show what will be undone console.log(''); console.log('This will revert:'); lastStep.changes.forEach(change => { console.log(` โ€ข ${change.type}: ${change.file}`); }); const confirm = await promptUser('Confirm undo? (y/n): '); if (confirm === 'y') { // Revert changes await this.revertStep(lastStep); this.currentStep--; console.log('โœ… Step undone successfully'); } else { this.history.push(lastStep); console.log('โŒ Undo cancelled'); } } ``` ## Checkpoint System ```javascript class CheckpointManager { async createCheckpoint(name: string, metadata: any) { const checkpoint = { id: `checkpoint-${Date.now()}`, name, timestamp: new Date(), step: this.currentStep, files: await this.captureFileState(), metadata }; // Save current state await this.saveCheckpoint(checkpoint); console.log(`๐Ÿ’พ Checkpoint created: ${checkpoint.name}`); return checkpoint.id; } async restoreCheckpoint(checkpointId: string) { console.log(`๐Ÿ”„ Restoring checkpoint: ${checkpointId}`); const checkpoint = await this.loadCheckpoint(checkpointId); // Show changes console.log(''); console.log('This will restore to:'); console.log(` Step: ${checkpoint.step}`); console.log(` Time: ${checkpoint.timestamp}`); console.log(` Files: ${checkpoint.files.length}`); const confirm = await promptUser('Proceed? (y/n): '); if (confirm === 'y') { await this.applyCheckpoint(checkpoint); console.log('โœ… Checkpoint restored'); } } } ``` ## Step Details Preview ```javascript async previewStep(step: Step) { console.clear(); console.log('โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”'); console.log('โ”‚ ๐Ÿ“‹ STEP PREVIEW โ”‚'); console.log('โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค'); console.log(`โ”‚ Step ${step.id}: ${step.name}`); console.log('โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค'); console.log('โ”‚'); console.log(`โ”‚ Description:`); console.log(`โ”‚ ${step.description}`); console.log('โ”‚'); console.log(`โ”‚ Will be executed by:`); console.log(`โ”‚ ๐Ÿค– ${step.agent}`); console.log('โ”‚'); console.log(`โ”‚ Actions to perform:`); step.actions.forEach(action => { console.log(`โ”‚ โ€ข ${action.type}: ${action.target}`); }); console.log('โ”‚'); console.log(`โ”‚ Estimated time: ${step.estimatedTime}s`); console.log('โ”‚'); if (step.critical) { console.log('โ”‚ โš ๏ธ CRITICAL STEP - Cannot be skipped'); } console.log('โ”‚'); console.log('โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜'); console.log(''); return await promptUser('[Enter] Execute | [s] Skip | [m] Modify: '); } ``` ## Breakpoint System ```javascript class BreakpointManager { private breakpoints: Breakpoint[] = []; addBreakpoint(condition: string | Function) { this.breakpoints.push({ id: `bp-${Date.now()}`, condition, hits: 0 }); } async checkBreakpoints(context: ExecutionContext) { for (const bp of this.breakpoints) { if (await this.evaluateBreakpoint(bp, context)) { console.log(`๐Ÿ”ด Breakpoint hit: ${bp.id}`); await this.handleBreakpoint(bp, context); } } } async handleBreakpoint(bp: Breakpoint, context: ExecutionContext) { console.log(''); console.log('โ”โ”โ” BREAKPOINT โ”โ”โ”'); console.log(`Location: ${context.step.name}`); console.log(`Condition: ${bp.condition}`); console.log(`Hits: ${++bp.hits}`); console.log(''); // Show context console.log('Context:'); console.log(JSON.stringify(context.variables, null, 2)); // Interactive debugger let debugging = true; while (debugging) { const cmd = await promptUser('debug> '); switch(cmd) { case 'c': case 'continue': debugging = false; break; case 'i': case 'inspect': await this.inspectContext(context); break; case 'n': case 'next': await this.stepOver(); debugging = false; break; case 'q': case 'quit': process.exit(0); } } } } ``` ## Modification Mode ```javascript async modifyStep(step: Step) { console.log('โœ๏ธ MODIFY STEP'); console.log('โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”'); console.log(''); console.log('Current configuration:'); console.log(JSON.stringify(step, null, 2)); console.log(''); console.log('What would you like to modify?'); console.log('1. Change target files'); console.log('2. Modify parameters'); console.log('3. Change agent assignment'); console.log('4. Skip this step'); console.log('5. Cancel modification'); const choice = await promptUser('Choice (1-5): '); switch(choice) { case '1': step.action.target = await promptUser('New target: '); break; case '2': await this.modifyParameters(step); break; case '3': step.agent = await this.selectAgent(); break; case '4': step.skip = true; break; } console.log('โœ… Step modified'); return step; } ``` ## Watch Mode Integration ```javascript class WatchModeIntegration { async enableWatchMode() { console.log('๐Ÿ‘๏ธ Watch mode enabled'); console.log('Files will be monitored for changes'); const watcher = chokidar.watch('.', { ignored: /node_modules|\.git/, persistent: true }); watcher.on('change', async (path) => { if (this.isPaused) return; console.log(`\n๐Ÿ“ File changed: ${path}`); console.log('Options:'); console.log('[r] Re-run current step'); console.log('[c] Continue anyway'); console.log('[p] Pause to investigate'); const action = await promptUser('Action: '); await this.handleFileChange(action, path); }); } } ``` ## Summary Report ```markdown ## ๐Ÿ“Š Interactive Session Summary **Session ID**: interactive-20241031-145632 **Duration**: 15 minutes 23 seconds **Mode**: Step-by-step with checkpoints ### Execution Statistics | Metric | Value | |--------|-------| | Total Steps | 10 | | Completed | 8 | | Skipped | 1 | | Undone | 1 | | Breakpoints Hit | 3 | | Checkpoints | 4 | ### Step Timeline ``` 1. โœ… Initialize project structure (0:23) 2. โœ… Setup database connection (1:45) 3. โœ… Create user model (2:12) 4. โ†ฉ๏ธ UNDONE: Create auth middleware 5. โœ… Create auth middleware v2 (4:33) 6. โญ๏ธ SKIPPED: Add logging 7. โœ… Create API endpoints (6:21) 8. โœ… Add validation (8:45) 9. โœ… Write tests (10:12) 10. โœ… Update documentation (11:54) ``` ### User Interactions - Pauses: 2 - Modifications: 3 - Undo operations: 1 - Breakpoint inspections: 3 ### Files Modified - Created: 12 files - Modified: 8 files - Deleted: 0 files ### Checkpoints Available 1. `checkpoint-1698765392000` - After database setup 2. `checkpoint-1698765512000` - After auth implementation 3. `checkpoint-1698765634000` - After API creation 4. `checkpoint-1698765756000` - Final state ### Recommendations - Consider automating step 6 (skipped frequently) - Breakpoint at auth middleware hit multiple times - Average pause duration: 45 seconds ``` ## Quick Commands During interactive execution: ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โŒจ๏ธ QUICK COMMANDS โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Enter - Continue โ”‚ โ”‚ p - Pause โ”‚ โ”‚ r - Resume โ”‚ โ”‚ s - Skip step โ”‚ โ”‚ u - Undo last โ”‚ โ”‚ m - Modify step โ”‚ โ”‚ b - Set breakpoint โ”‚ โ”‚ c - Create checkpoint โ”‚ โ”‚ l - List checkpoints โ”‚ โ”‚ i - Inspect context โ”‚ โ”‚ h - Help โ”‚ โ”‚ q - Quit โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ```