CodeSense AI - VS Code Extension
An intelligent AI-powered code reviewer and assistant built directly into VS Code.
Features
- 🤖 Multi-Provider AI Support - Works with Google Gemini and OpenAI
- 💬 Interactive Chat Interface - Beautiful chat UI with conversation history
- 🔒 Secure API Key Storage - Keys stored securely using VS Code Secrets
- 🛠️ Code Operations - Read, write, create, and delete files with AI assistance
- 📁 Directory Management - Create folders and manage project structure
- ⚡ Terminal Integration - Run commands directly from the AI assistant
- 📝 Conversation History - Save and reload past conversations
- 🎨 Dark Theme UI - Beautiful gradient design that matches VS Code
- 🔄 Diff Visualization - Side-by-side code comparison for AI-suggested changes
Installation
From Source
Clone this repository:
git clone https://github.com/KumarAyushh/CodeSense.git
cd CodeSense
Install dependencies:
npm install
Press F5 in VS Code to launch the Extension Development Host
From VSIX (Coming Soon)
Install directly from the Visual Studio Marketplace (when published).
Usage
Open the Extension
- Click on the CodeSense icon in the Activity Bar (left sidebar)
Configure API Key
- Select your AI provider (Google Gemini or OpenAI)
- Enter your API key (stored securely)
- Keys are encrypted and never leave your machine
Start Chatting
- Ask questions about your code
- Request code reviews
- Generate new features
- Get help with debugging
Supported AI Providers
- ✅ Google Gemini (fully implemented)
- ✅ OpenAI (GPT-4o and GPT-4o-mini)
- 🚧 Anthropic Claude (coming soon)
- 🚧 Groq (coming soon)
Get API Keys
Features in Detail
Code Analysis
- Read and analyze files in your workspace
- Understand project structure
- Review code quality and suggest improvements
File Operations
- Create new files with AI-generated content
- Modify existing files
- Delete files (with confirmation)
- Create directory structures
Terminal Commands
- Execute shell commands
- Install packages
- Run build scripts
- Manage git operations
Conversation Management
- Auto-save conversations
- Load previous chats
- Delete unwanted history
- Context-aware responses (20 message history)
Diff Visualization
- Automatic side-by-side comparison when AI modifies existing code
- Visual changes display with green additions and red deletions
- One-click review before accepting AI changes
- Native VS Code diff viewer - familiar interface
- Auto-cleanup of temporary diff files (1 hour expiration)
When you ask AI to fix or modify code, CodeSense automatically opens the diff view with the title "CodeSense: AI Suggested Changes" showing exactly what changed.
Configuration
The extension stores settings securely:
ai_provider - Selected AI provider
ai_api_key - Your API key (encrypted)
No manual configuration files needed!
Development
Project Structure
CodeSense/
├── src/
│ ├── extension.js # Extension entry point
│ ├── ChatViewProvider.js # Webview UI and logic
│ └── diffUtil.js # Diff visualization utility
├── media/
│ ├── icon.svg # Extension icon
│ ├── main.js # Webview frontend
│ └── style.css # Webview styles
├── index.js # Agent tool functions
├── MultiProviderAgent.js # AI provider abstraction
└── package.json # Extension manifest
Running Locally
Install dependencies:
npm install
Open in VS Code:
code .
Press F5 to launch Extension Development Host
Open any workspace and test the extension
Standalone CLI Mode
The agent can also run standalone (outside VS Code):
# Set your API key
echo "GEMINI_API_KEY=your_key_here" > .env
# Run the agent
node index.js
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
Security
- API keys are stored using VS Code's secure secret storage
- Keys are never transmitted except to the official AI provider APIs
- No telemetry or data collection
- All processing happens locally
License
MIT License - see LICENSE file for details
Troubleshooting
Extension not activating
- Ensure you're using VS Code 1.80.0 or later
- Check the Output panel (Help → Toggle Developer Tools → Console)
API key not saving
- Restart VS Code after entering the key
- Check VS Code's secret storage permissions
AI not responding
- Verify your API key is correct
- Check your internet connection
- Ensure you have API quota remaining
Roadmap
- [ ] Support for Anthropic Claude
- [ ] Support for Groq
- [ ] Multi-file refactoring
- [ ] Custom prompt templates
- [ ] Export conversations to markdown
- [ ] Settings UI for customization
Author
Created with ❤️ by [Kumar Ayush]
Acknowledgments
- Google Gemini API
- OpenAI API
- VS Code Extension API