-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Adding Auto-Accept and Plan Mode to Nanocoder
Description
This document outlines the proposal for adding two new operational modes to Nanocoder: Auto-Accept Mode and Plan Mode. These modes aim to enhance user control over tool execution and improve the AI's reasoning capabilities by separating planning and action phases.
Auto-Accept Mode
Overview
Auto-accept mode allows Nanocoder to automatically accept and execute all tool calls without user intervention. This is useful for batch operations or when the user trusts the AI to perform a series of actions autonomously.
Features
- Automatic approval of all function calls
- Configurable confirmation for high-risk operations (optional)
- Logging of all actions taken for transparency
- Ability to pause or disable the mode at any time
Use Case
- Processing multiple files in bulk
- Automated data migration tasks
- When working in a trusted development environment
Plan Mode
Overview
Plan mode initiates a pure reasoning phase where Nanocoder cannot execute any tool calls. During this mode, the AI focuses exclusively on analysis, planning, and strategy without performing actions. This helps in creating detailed execution plans before actual implementation.
Features
- Complete suppression of tool calls
- Enhanced reasoning capabilities for complex problems
- Output structured plans in markdown format
- Transition to execution mode when plan is finalized
Use Case
- Complex refactoring tasks requiring detailed planning
- Multi-step feature implementations
- Strategic code review and analysis
Implementation Details
Code Changes Required
Core Modifications
- State Management: Add mode tracking to the Nanocoder state management system
- Tool Call Handling: Modify tool execution pipeline to respect mode restrictions
- UI/UX Updates: Add CLI commands to enable/disable modes and visual indicators
Files to Modify
src/core/agent.ts
- Add mode management logicsrc/cli/commands.ts
- Add mode switching commandssrc/tools/executor.ts
- Implement tool call gating based on mode
Step-by-Step Development Workflow
-
Create a feature branch:
git checkout -b feature/auto-accept-plan-modes
-
Implement mode state management:
- Define mode types (normal, auto-accept, plan)
- Add mode persistence/configuration
- Implement mode switching logic
-
Modify tool execution:
- Add pre-execution checks for plan mode
- Implement automatic approval for auto-accept mode
- Add logging for transparency
-
Update CLI interface:
- Implement Shift+Tab key binding for cycling through modes (Normal -> Auto-Accept -> Plan -> Normal)
- Display current mode in prompt
- Add mode status indicators
- Ensure key binding works at any time during interaction
-
Remove mode commands (deprecated):
- Instead of dedicated commands, rely on the key binding for seamless mode switching
Testing
Manual Testing Scenarios
-
Auto-Accept Mode Testing:
- Test batch file operations
- Verify logging of actions
- Test pause/disable functionality
- Confirm safety measures for risky operations
-
Plan Mode Testing:
- Verify no tool calls are allowed
- Test plan generation and output
- Check transition between modes
- Ensure reasoning quality improvements
-
Edge Cases:
- Mode conflicts
- Error handling during mode switches
- Recovery from interrupted operations
Integration Testing
- Test with different AI providers (Ollama, OpenRouter, OpenAI-compatible)
- MCP server integration with modes enabled
- Cross-platform compatibility
Coding Standards Compliance
- Follow existing TypeScript guidelines with strict typing
- Use conventional commit messages (
feat: add auto-accept mode
) - Maintain consistent code style and file organization
- Add comprehensive error handling
Pull Request Checklist
- Mode state management implemented
- Tool call gating working correctly
- CLI commands added and tested
- Manual testing completed for both modes
- Documentation updated (README, CLI help)
- No breaking changes introduced
- Existing tests pass
Benefits
- Enhanced Productivity: Auto-accept mode speeds up repetitive tasks
- Improved Planning: Plan mode enables better problem-solving before execution
- User Control: Users can choose the right mode for their workflow
- Safety: Modes prevent unintended actions while providing flexibility
Risk Assessment
- Low Risk: Both modes are additive features that don't affect default behavior
- Mitigation: Include safety nets, logging, and easy mode switching
- Backward Compatibility: Default mode remains "normal" operation
Future Enhancements
- Hybrid mode combining elements of both
- User-configurable exceptions in auto-accept mode
- Integration with debugging tools in plan mode
- API endpoints for mode management