You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduces Plan Mode, a new approval workflow that allows users to review and approve implementation plans before any code changes are made. This feature enhances safety and control by ensuring users can see exactly what the AI intends to do before execution begins.
🚀 Key Features
Plan Mode Workflow
Read-only Planning Phase: When in plan mode, the AI can only perform read-only operations (file reading, searching, analysis)
Plan Presentation: AI presents a comprehensive implementation plan using the new exit_plan_mode tool
User Approval: Users can approve, reject, or modify the plan before any code changes occur
Seamless Transition: Upon approval, the system transitions to normal execution mode
New Configuration Options
approvalMode: New setting with values plan, default, auto-edit, yolo
Plan Mode UI: New PlanSummaryDisplay component for presenting plans in the terminal
Enhanced Tool Confirmation: Updated confirmation dialogs to handle plan approval workflow
New Slash Command: /approval-mode
Interactive Mode Management: New /approval-mode slash command for runtime approval mode switching, available options: plan, default, auto-edit and yolo.
Flexible Scope Control: Set approval mode for current session, user profile, or project with --session, --user, --project flags
Real-time Switching: Change approval behavior mid-conversation without restarting the CLI
🔧 Technical Implementation
Core Components
ExitPlanModeTool: New tool for transitioning from planning to execution
Plan Mode System Prompts: Enforces read-only behavior during planning phase
Enhanced Tool Scheduler: Blocks non-read-only tools when in plan mode
Shell Read-only Detection: New utilities to identify safe vs. destructive shell commands
UI Enhancements
PlanSummaryDisplay: React component for rendering markdown plans
Updated Tool Confirmation: Enhanced dialogs with plan-specific approval options
Auto-accept Indicator: Updated to reflect plan mode status
Command System Integration
ApprovalModeCommand: New built-in slash command with comprehensive argument parsing
Command Registration: Integrated into the BuiltinCommandLoader for automatic availability
Subcommand Support: Each approval mode available as a subcommand (e.g., /approval-mode plan)
Settings Integration: Seamless integration with user, project, and session-level configuration
🧪 Testing
Unit Tests: Comprehensive test coverage for all new components
Integration Tests: Updated existing tests to handle plan mode scenarios
Configuration Tests: Validation of new approval mode settings
Command Tests: Full test coverage for the new /approval-mode slash command functionality
📚 Documentation Updates
Updated CLI configuration documentation
Enhanced keyboard shortcuts documentation
Added plan mode workflow explanations
New Command Documentation: Complete documentation for /approval-mode command usage and options
🔒 Safety & Security
Read-only Enforcement: Plan mode strictly prevents any system modifications
Shell Command Analysis: New utilities to classify shell commands as safe/destructive
User Control: Users maintain full control over when and what gets executed
Runtime Safety: /approval-mode command allows users to increase or decrease safety levels as needed
🎨 User Experience
Clear Plan Presentation: Markdown-formatted plans with syntax highlighting
Optional Feature: Plan mode is opt-in via configuration
Graceful Fallbacks: Robust error handling and mode transitions
Command Compatibility: New slash command follows existing CLI patterns and conventions
This feature significantly enhances the safety and predictability of AI-assisted coding by giving users full visibility and control over implementation plans before any changes are made to their codebase. The new /approval-mode slash command provides users with immediate, interactive control over their safety preferences without needing to restart or reconfigure the CLI.
This PR introduces a significant new feature called "Plan Mode" which allows users to review and approve implementation plans before any code changes are made. The implementation is comprehensive, covering configuration, core logic, UI components, and proper testing. Overall, this is a valuable addition that enhances safety and user control.
🔍 General Feedback
The implementation is well-structured with clear separation of concerns
Good test coverage for the new functionality
Proper documentation updates for the new configuration options
The UI components are well-designed and integrate smoothly with existing components
The plan mode enforcement logic is robust and handles various edge cases
🎯 Specific Feedback
🟡 High
File: packages/core/src/utils/shellReadOnlyChecker.ts - The containsWriteRedirection function has a potential issue with escaped quotes. The function checks for quotes to determine if it's inside a quoted string, but it doesn't properly handle escaped quotes (e.g., "This is a \\\"quoted\\\" string"). This could lead to false positives in detecting write redirections.
🟢 Medium
File: packages/core/src/core/prompts.ts - In the getPlanModeSystemReminder function, the reference to ${ToolNames.EXIT_PLAN_MODE} might be clearer if it used the actual string literal for consistency with other parts of the prompt, or ensure that the ToolNames import is clearly visible.
File: packages/core/src/tools/exitPlanMode.ts - In the ExitPlanModeToolInvocation.execute method, the error handling could be improved by using a more specific error type instead of the generic Error type for better type safety.
🔵 Low
File: packages/core/src/core/client.ts - Consider adding a comment to explain why the order of tool registration was changed (ExitPlanModeTool before WebFetchTool) for better maintainability.
File: packages/core/src/utils/shellReadOnlyChecker.ts - The file is missing a newline at the end, which is a minor style issue.
✅ Highlights
Excellent implementation of the plan mode workflow with proper read-only enforcement
Well-designed UI components for displaying plans with markdown support
Comprehensive test coverage for all new functionality
Good handling of edge cases like untrusted folders
Clear documentation updates for the new features
Proper integration with existing approval mode cycling functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Summary
This PR introduces Plan Mode, a new approval workflow that allows users to review and approve implementation plans before any code changes are made. This feature enhances safety and control by ensuring users can see exactly what the AI intends to do before execution begins.
🚀 Key Features
Plan Mode Workflow
exit_plan_modetoolNew Configuration Options
approvalMode: New setting with valuesplan,default,auto-edit,yoloPlanSummaryDisplaycomponent for presenting plans in the terminalNew Slash Command:
/approval-mode/approval-modeslash command for runtime approval mode switching, available options:plan,default,auto-editandyolo.--session,--user,--projectflags🔧 Technical Implementation
Core Components
ExitPlanModeTool: New tool for transitioning from planning to executionUI Enhancements
PlanSummaryDisplay: React component for rendering markdown plansCommand System Integration
ApprovalModeCommand: New built-in slash command with comprehensive argument parsingBuiltinCommandLoaderfor automatic availability/approval-mode plan)🧪 Testing
/approval-modeslash command functionality📚 Documentation Updates
/approval-modecommand usage and options🔒 Safety & Security
/approval-modecommand allows users to increase or decrease safety levels as needed🎨 User Experience
/approval-modecommand🔄 Migration & Compatibility
This feature significantly enhances the safety and predictability of AI-assisted coding by giving users full visibility and control over implementation plans before any changes are made to their codebase. The new
/approval-modeslash command provides users with immediate, interactive control over their safety preferences without needing to restart or reconfigure the CLI.