CodePlanr - AI-Powered VS Code Extension
CodePlanr is an intelligent VS Code extension that uses OpenAI GPT-4o to generate step-by-step coding plans from user tasks. It scans your workspace offline for relevant files and presents actionable plans in a beautiful, clickable Markdown format.
Features
🤖 AI-Powered Planning: Generate detailed coding plans using OpenAI GPT-4o
📁 Smart Workspace Analysis: Automatically scans and analyzes relevant files in your workspace
📝 Interactive Plans: Beautiful, clickable Markdown plans with file links and action buttons
⚡ Code Generation: Generate specific code changes for each step with AI assistance
✅ Safe Application: Apply changes with user confirmation and detailed review
🔧 Easy Configuration: Simple setup with OpenAI API key configuration
Getting Started
Prerequisites
- VS Code 1.104.0 or higher
- OpenAI API key (get one from OpenAI)
Installation
- Clone this repository
- Run
yarn install
to install dependencies
- Press
F5
to run the extension in a new Extension Development Host window
Configuration
- Open the Command Palette (
Ctrl+Shift+P
/ Cmd+Shift+P
)
- Run
CodePlanr: Configure API Key
- Enter your OpenAI API key when prompted
Usage
Generate a Coding Plan
- Open the Command Palette (
Ctrl+Shift+P
/ Cmd+Shift+P
)
- Run
CodePlanr: Generate AI Coding Plan
- Describe what you want to implement (e.g., "Add user authentication", "Create a new API endpoint")
- The extension will scan your workspace and generate a detailed plan
Apply Code Changes
- In the generated plan, click "🤖 Generate Code" for any step
- Review the suggested changes in the preview
- Click "✅ Apply Changes" to implement the changes
- Confirm the changes in the review dialog
Commands
CodePlanr: Generate AI Coding Plan
- Create a new coding plan from a task description
CodePlanr: Apply AI Suggested Changes
- Apply generated code changes
CodePlanr: Configure API Key
- Set up your OpenAI API key
Extension Settings
This extension contributes the following settings:
CodePlanr.openaiApiKey
: OpenAI API Key for CodePlanr AI features
CodePlanr.model
: OpenAI model to use for code generation (default: "gpt-4o")
How It Works
- Task Input: You describe what you want to implement
- Workspace Analysis: The extension scans your workspace for relevant files
- AI Planning: OpenAI analyzes your codebase and generates a detailed plan
- Interactive Display: The plan is shown in a beautiful webview with clickable elements
- Code Generation: For each step, you can generate specific code changes
- Safe Application: Changes are applied with your confirmation and detailed review
Architecture
The extension is built with a modular architecture:
- OpenAI Service: Handles AI interactions and code generation
- Workspace Scanner: Analyzes workspace files and determines relevance
- Plan Generator: Combines workspace analysis with AI planning
- Markdown Viewer: Displays plans in an interactive webview
- Code Applier: Safely applies changes with user confirmation
Development
Project Structure
src/
├── extension.ts # Main extension entry point
├── services/
│ ├── openaiService.ts # OpenAI API integration
│ ├── workspaceScanner.ts # Workspace file analysis
│ ├── planGenerator.ts # Plan generation logic
│ ├── markdownViewer.ts # Interactive plan display
│ └── codeApplier.ts # Code change application
└── test/
└── extension.test.ts # Extension tests
Building
# Install dependencies
yarn install
# Compile TypeScript
yarn compile
# Watch for changes
yarn watch
# Package for distribution
yarn package
Release Notes
0.0.1
Initial release of CodePlanr with:
- AI-powered coding plan generation
- Workspace analysis and file scanning
- Interactive plan viewer with clickable elements
- Code change generation and application
- OpenAI GPT-4o integration
Known Issues
- Large workspaces may take longer to scan
- API rate limits may apply based on your OpenAI plan
- Some complex codebases may require manual plan refinement
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
If you encounter any issues or have questions:
- Check the VS Code Developer Console for error messages
- Ensure your OpenAI API key is correctly configured
- Verify you have sufficient OpenAI API credits
- Open an issue on GitHub with detailed information
Built with ❤️ for the VS Code community