Skip to content

router-hub/codeit-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

codeIt πŸ€–

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.

codeIt Banner VS Code Perplexity AI

✨ Features

🎯 Dual Mode Operation

  • πŸ’¬ Chat Mode: Interactive conversations about your code with context awareness
  • πŸ€– Smart Agent Mode: Intelligent file operations and multi-file modifications

🧠 Intelligent Context Understanding

  • 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

πŸ”§ Advanced Code Operations

  • 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

πŸ’¬ Rich Chat Experience

  • 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

βš™οΈ Comprehensive Configuration

  • 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

πŸš€ Quick Start

1. Installation

# 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)

2. Setup Perplexity API

  1. Get API Key: Visit Perplexity AI and generate an API key
  2. Configure Extension:
    • Open Command Palette (Ctrl+Shift+P)
    • Run codeIt: Configure API Key
    • Enter your Perplexity API key
  3. Test Connection: Run codeIt: Test Connection to verify setup

3. Start Using

Quick Start Commands:

  • Ctrl+Shift+I - Open codeIt with mode selection
  • Ctrl+Shift+Q - Quick chat about selected code
  • Right-click menu - Context-aware code operations

🎯 Usage Examples

Chat Mode Examples

// 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"

Smart Agent Mode Examples

// 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"

πŸ› οΈ Commands Reference

Core Commands

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

Code Operations

Command Description
codeIt: Refactor Selection Refactor selected code
codeIt: Generate Code Generate new code
codeIt: Undo Last Change Undo last AI-generated change

Chat Management

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

Configuration

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

Debug & Development

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

βš™οΈ Configuration

AI Model Settings

{
  "codeit.defaultModel": "sonar",
  "codeit.defaultTemperature": 0.3,
  "codeit.maxTokens": 10000
}

Context Settings

{
  "codeit.maxContextLines": 50,
  "codeit.enableCodeContext": true,
  "codeit.includeGitInfo": true,
  "codeit.includeFileMetadata": true
}

Behavior Settings

{
  "codeit.autoApplyChanges": false,
  "codeit.showDiffPreview": true,
  "codeit.confidenceThreshold": 0.7,
  "codeit.validateSyntax": true
}

Performance Settings

{
  "codeit.requestTimeout": 30000,
  "codeit.retryAttempts": 3,
  "codeit.retryDelay": 1000,
  "codeit.enableTokenOptimization": true
}

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    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                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

  • 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

πŸ” Security & Privacy

Data Protection

  • 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

Privacy Features

  • 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

πŸ› οΈ Development

Prerequisites

  • Node.js 18+
  • VS Code 1.74+
  • TypeScript 4.9+

Development Setup

# 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 publish

Project Structure

codeIt/
β”œβ”€β”€ 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

Testing

  1. Press F5 to launch extension in debug mode
  2. Open a test workspace with code files
  3. Test various commands and scenarios
  4. Check the developer console for logs

API Testing (Development Only)

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.js

Option 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

⚠️ Security Note:

  • 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 .env file which is also gitignored

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Add comprehensive error handling
  • Include JSDoc comments for public APIs
  • Test thoroughly before submitting PRs
  • Update documentation for new features

πŸ“Š Performance

Optimization 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

Benchmarks

  • 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

πŸ› Troubleshooting

Common Issues

API Connection Problems

# Check API key configuration
codeIt: Configure API Key

# Test connection
codeIt: Test Connection

# Verify internet connectivity

Performance 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 Context

Debug Mode

Enable debug logging in settings:

{
  "codeit.enableLogging": true
}

πŸ“ˆ Roadmap

Upcoming Features

  • 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

Planned Improvements

  • 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

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Perplexity AI for providing the powerful AI models
  • VS Code Team for the excellent extension API
  • Open Source Community for inspiration and contributions

πŸ“ž Support

Getting Help

Community


Made with ❀️ by the codeIt team

GitHub stars GitHub forks GitHub issues

About

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.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors