AI-powered coding assistant with Perplexity integration for VS Code
codeIt is a sophisticated VS Code extension that transforms your coding experience with intelligent AI assistance. It combines the power of Perplexity AI with context-aware code understanding to help you write, refactor, and improve your code faster than ever before.
- π¬ Chat Mode: Interactive conversations about your code with context awareness
- π€ Smart Agent Mode: Intelligent file operations and multi-file modifications
- Project Indexing: Automatically builds a comprehensive index of your project structure
- Smart File Resolution: Finds relevant files based on your instructions
- Context-Aware Prompts: Includes surrounding code, file metadata, and project structure
- Git Integration: Incorporates branch information and diff context
- Smart Refactoring: Select code and describe desired changes
- Multi-file Operations: Apply changes across multiple files intelligently
- Code Generation: Generate new code with full context understanding
- Syntax Validation: Ensures generated code is syntactically correct
- Diff Preview: Review changes before applying them
- Persistent Chat History: Save and manage your conversations
- Export Capabilities: Export chat history for documentation
- Quick Chat: Context-aware quick questions about selected code
- Chat View: Dedicated sidebar for managing conversations
- Multiple AI Models: Choose from Perplexity's latest models (sonar, sonar-pro, sonar-large-32k-online)
- Customizable Settings: Fine-tune behavior with 20+ configuration options
- Token Optimization: Intelligent prompt optimization for cost efficiency
- Retry Logic: Robust error handling with configurable retry attempts
# Clone the repository
git clone https://github.com/router-hub/codeit-extension.git
cd codeit-extension
# Install dependencies
npm install
# Build the extension
npm run compile
# Launch in VS Code (F5)- Get API Key: Visit Perplexity AI and generate an API key
- Configure Extension:
- Open Command Palette (
Ctrl+Shift+P) - Run
codeIt: Configure API Key - Enter your Perplexity API key
- Open Command Palette (
- Test Connection: Run
codeIt: Test Connectionto verify setup
Quick Start Commands:
Ctrl+Shift+I- Open codeIt with mode selectionCtrl+Shift+Q- Quick chat about selected code- Right-click menu - Context-aware code operations
// Ask about your code
"What's wrong with this function?"
"How can I optimize this algorithm?"
"Explain this React component"
// Get suggestions
"Suggest improvements for error handling"
"What design patterns could I use here?"
"Help me understand this async code"// File operations
"Update UserService to add logging"
"Fix all TypeScript errors in the project"
"Add error handling to all API calls"
// Multi-file changes
"Update all components to use the new theme"
"Add JSDoc comments to all functions"
"Refactor authentication logic across the app"| Command | Shortcut | Description |
|---|---|---|
codeIt: Ask codeIt |
Ctrl+Shift+I |
Main entry point with mode selection |
codeIt: Quick Chat |
Ctrl+Shift+Q |
Quick chat about selected code |
codeIt: Chat Mode |
- | Direct access to chat mode |
codeIt: Smart Agent Mode |
- | Direct access to smart agent mode |
| Command | Description |
|---|---|
codeIt: Refactor Selection |
Refactor selected code |
codeIt: Generate Code |
Generate new code |
codeIt: Undo Last Change |
Undo last AI-generated change |
| Command | Description |
|---|---|
codeIt: Start Chat |
Start a new chat session |
codeIt: Show History |
View chat history |
codeIt: Clear History |
Clear chat history |
codeIt: Export History |
Export chat conversations |
| Command | Description |
|---|---|
codeIt: Configure API Key |
Set up Perplexity API key |
codeIt: Test Connection |
Test API connectivity |
codeIt: Set API Key |
Alternative API key setup |
| Command | Description |
|---|---|
codeIt: Show Smart Agent Debug |
Debug smart agent operations |
codeIt: Debug Context |
Debug context building |
codeIt: Test Chat |
Test chat functionality |
codeIt: Refresh Project Index |
Rebuild project index |
{
"codeit.defaultModel": "sonar",
"codeit.defaultTemperature": 0.3,
"codeit.maxTokens": 10000
}{
"codeit.maxContextLines": 50,
"codeit.enableCodeContext": true,
"codeit.includeGitInfo": true,
"codeit.includeFileMetadata": true
}{
"codeit.autoApplyChanges": false,
"codeit.showDiffPreview": true,
"codeit.confidenceThreshold": 0.7,
"codeit.validateSyntax": true
}{
"codeit.requestTimeout": 30000,
"codeit.retryAttempts": 3,
"codeit.retryDelay": 1000,
"codeit.enableTokenOptimization": true
}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β VS Code Extension β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β User Interface Layer β
β βββ Command Handlers β
β βββ Chat Provider β
β βββ Chat View Provider β
β βββ Webview Interface β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Core Engine Layer β
β βββ Smart Agent β
β βββ Project Indexer β
β βββ Smart File Resolver β
β βββ Prompt Context Composer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β AI Integration Layer β
β βββ Perplexity API Client β
β βββ Prompt Builder β
β βββ Output Parser β
β βββ Patch Engine β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Configuration & Utilities β
β βββ Config Manager β
β βββ Format Utils β
β βββ Security Layer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- SmartAgent: Orchestrates intelligent file operations and multi-file changes
- ProjectIndexer: Builds and maintains project structure understanding
- ChatProvider: Manages interactive chat sessions with context
- PerplexityAPI: Handles secure communication with Perplexity AI
- PatchEngine: Safely applies AI-generated changes to files
- PromptBuilder: Constructs context-aware prompts for optimal AI responses
- Local Processing: All code analysis happens locally
- Secure Storage: API keys stored using VS Code's secrets API
- HTTPS Only: All external communications use secure connections
- No Code Upload: Code is never uploaded to external servers
- Context Control: Only selected code and specified files are processed
- Configurable Limits: Control how much context is included
- Session Management: Clear chat history and export capabilities
- Audit Trail: Track all AI-generated changes for review
- Node.js 18+
- VS Code 1.74+
- TypeScript 4.9+
# Install dependencies
npm install
# Build extension
npm run compile
# Watch mode for development
npm run watch
# Package for distribution
npm run package
# Publish to VS Code marketplace
npm run publishcodeIt/
βββ src/ # TypeScript source code
β βββ extension.ts # Main extension entry point
β βββ api.ts # Perplexity API client
β βββ smartAgent.ts # Smart agent implementation
β βββ chatProvider.ts # Chat functionality
β βββ chatViewProvider.ts # Chat UI management
β βββ projectIndexer.ts # Project indexing
β βββ smartFileResolver.ts # File resolution logic
β βββ promptBuilder.ts # AI prompt construction
β βββ promptContextComposer.ts # Context composition
β βββ patchEngine.ts # Code change application
β βββ outputParser.ts # AI response parsing
β βββ formatUtils.ts # Code formatting utilities
β βββ config.ts # Configuration management
βββ media/ # Extension assets
β βββ webview.html # Chat interface
β βββ styles.css # UI styling
β βββ script.js # Webview scripts
βββ package.json # Extension manifest
βββ tsconfig.json # TypeScript configuration
βββ README.md # This file
- Press
F5to launch extension in debug mode - Open a test workspace with code files
- Test various commands and scenarios
- Check the developer console for logs
For development and testing purposes, you can use the test-perplexity.js file to test the Perplexity API directly:
Option 1: Quick Setup (Recommended)
# Run the setup script
node setup-test-env.js
# Then run the test
node test-perplexity.jsOption 2: Manual Setup
# Set your API key as an environment variable
export PERPLEXITY_API_KEY="your-api-key-here"
# or
export PPLX_API_KEY="your-api-key-here"
# Run the test
node test-perplexity.js- The test file is excluded from version control (
.gitignore) to prevent accidental API key exposure - Never commit API keys to the repository
- The setup script creates a
.envfile which is also gitignored
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Add comprehensive error handling
- Include JSDoc comments for public APIs
- Test thoroughly before submitting PRs
- Update documentation for new features
- Token Optimization: Intelligent prompt truncation to reduce costs
- Caching: Project index caching for faster operations
- Lazy Loading: Load components only when needed
- Progress Tracking: Real-time feedback for long operations
- Batch Processing: Efficient multi-file operations
- Project Indexing: < 5 seconds for typical projects
- API Response: < 10 seconds for most operations
- File Resolution: < 1 second for smart file finding
- Context Building: < 2 seconds for comprehensive context
API Connection Problems
# Check API key configuration
codeIt: Configure API Key
# Test connection
codeIt: Test Connection
# Verify internet connectivityPerformance Issues
{
"codeit.maxContextLines": 25,
"codeit.maxTokens": 5000,
"codeit.enableTokenOptimization": true
}Chat Not Working
# Refresh project index
codeIt: Refresh Project Index
# Clear chat history
codeIt: Clear History
# Check debug logs
codeIt: Debug ContextEnable debug logging in settings:
{
"codeit.enableLogging": true
}- Multi-language Support: Enhanced support for Python, Java, Go
- Git Integration: Automatic commit messages and branch management
- Team Collaboration: Shared chat sessions and code reviews
- Custom Prompts: User-defined prompt templates
- Performance Profiling: Code performance analysis and suggestions
- Testing Integration: Automatic test generation and coverage analysis
- Offline Mode: Local AI model support
- Voice Commands: Voice-to-code functionality
- Visual Code Editor: Inline code editing interface
- Plugin System: Extensible architecture for custom integrations
This project is licensed under the MIT License - see the LICENSE file for details.
- Perplexity AI for providing the powerful AI models
- VS Code Team for the excellent extension API
- Open Source Community for inspiration and contributions
- Documentation: Check this README and inline help
- Issues: Report bugs on GitHub Issues
- Discussions: Join conversations on GitHub Discussions
- Discord: Join our Discord server
- Twitter: Follow @codeItExtension
- Blog: Read updates on our blog