An intelligent code completion and chat assistant plugin for IntelliJ-based IDEs, powered by capable AI models. Code4Me V2 enhances your development workflow with context-aware completions and conversational programming assistance through a sophisticated modular architecture.
Code4Me V2 is an AI-powered code completion platform developed for the AISE laboratory at TU Delft. The IntelliJ plugin serves as the primary interface for researchers and developers, providing real-time AI-assisted coding with comprehensive telemetry collection for academic research.
Note: All AI models, server configurations, and module settings are configurable through the plugin.conf file, allowing researchers to customize the system for different experiments and deployments.
- AI-Powered Suggestions: Get intelligent code completions based on your current context
- Multiple Display Modes: Choose between inline suggestions (default) or traditional dropdown completions
- Multi-Model Support: Choose from multiple AI models (configured in plugin.conf)
- Context-Aware: Leverages file content, cursor position, and project structure for relevant suggestions
- Real-time Generation: Fast completion suggestions with minimal latency
- Conversational Programming: Interactive chat interface for code discussion and assistance
- Multi-File Context: Understands your entire project context across selected files
- Code Analysis: Get explanations, refactoring suggestions, and debugging help
- Session Management: Persistent chat history with project-specific conversations
- Complete User Control: Enable/disable individual modules through intuitive settings interface
- Granular Data Collection: Choose exactly what data is collected and transmitted
- Privacy Controls: Comprehensive settings for data collection with transparent controls
- Limited Data Collection Mode: One-click configuration for minimal data sharing
- Module-Based Preferences: Individual control over telemetry, context, and behavioral modules
- Dependency Management: Automatic handling of module dependencies when enabling/disabling
- Download: Get the plugin from the JetBrains Plugin Repository (coming soon) or build from source
- Install: Install through IntelliJ IDEA's plugin manager or manually install the
.jarfile - Restart: Restart your IDE to activate the plugin
After installation, you'll need to create an account to use Code4Me's AI-powered features:
- Open Settings: Navigate to
Settings > Tools > Code4Me V2 Settings - Create Account:
- Toggle to "Sign Up Mode"
- Enter your full name, email, and password
- Review and accept the privacy policy and terms
- Click "Sign Up" to create your account
- Alternative - Login: If you already have an account, simply enter your email and password in Login Mode
Once authenticated, you can customize your experience:
-
Choose Your Privacy Level:
- Click "Use Limited Data Collection" for minimal data sharing
- Or configure individual modules for granular control
-
Select AI Models and Completion Mode:
- Access model preferences through the module tree
- Choose from available models (see plugin.conf for current model list)
- Toggle between inline completions (default) or dropdown completions
-
Configure Data Collection:
- Enable/disable completion data storage
- Control contextual and behavioral telemetry
- Customize individual module preferences
With setup complete, you can immediately begin using:
- Code Completions: Start typing in any supported language to receive AI-powered suggestions. Choose between inline suggestions (shown directly in your editor) or traditional dropdown completions through the settings
- Chat Assistant: Open the Code4Me chat panel (located on the right sidebar) to ask questions and get programming help
- Context-Aware Features: The plugin automatically gathers context from your project to provide relevant assistance
The plugin works out-of-the-box with minimal configuration, but offers extensive customization options through the comprehensive settings interface.
The Code4Me plugin is built around a sophisticated modular architecture that provides exceptional flexibility, extensibility, and user control over functionality and data collection.
Configuration Layer:
βββ plugin.conf (HOCON Configuration)
βββ ConfigService (Dynamic Module Loading)
β
βΌ
Core Interface:
βββ PluginModule Interface (Data Collection Contract)
βββ PreferenceCapable (Settings Management)
βββ Record System (Type-safe Data Storage)
β
βΌ
Module Categories:
βββ Behavioral Telemetry (Typing, Timing, Acceptance)
βββ Contextual Telemetry (Editor, File, Position)
βββ Context Retrieval (File, Multi-file, Project)
βββ Model Configuration (AI Models, Preferences)
βββ Aggregators (Data Coordination)
βββ After Insertion (Feedback, Ground Truth)
The module system follows a sophisticated lifecycle that ensures proper initialization, dependency resolution, and data collection:
1. Configuration Loading Phase
- Modules are defined in plugin.conf with hierarchical structure
- Each module specifies its class, dependencies, and submodules
- Configuration supports both hard and soft dependencies
- Enabled/disabled state is configurable per module
2. Dynamic Module Instantiation
- ConfigService uses reflection to instantiate module classes
- Modules are loaded based on their dependency order
- Failed module loading doesn't crash the entire system
- Module instances are cached for performance
3. Dependency Resolution
- System builds dependency chains and validates relationships
- Hard dependencies must be satisfied for module operation
- Soft dependencies are optional enhancements
- Circular dependencies are detected and prevented
Track user interaction patterns and typing behavior:
TimeSinceLastShownCompletion- Tracks intervals between completion requestsTimeSinceLastAcceptedCompletion- Measures acceptance timing patternsTypingSpeed- Calculates characters per second for adaptive debouncing
Gather environment and editor state information:
EditorContextRetrievalModule- Collects editor state, file language, cursor position
Collect code context from various sources:
FileContextRetrievalModule- Current file content and pathMultiFileContextRetrievalModule- Context from all open editor sessions and project-wide references and relationships
Coordinate data collection from multiple submodules:
BaseBehavioralTelemetryAggregator- Coordinates behavioral data collectionBaseContextualTelemetryAggregator- Manages contextual information gatheringBaseContextAggregator- Handles context retrieval coordinationBaseAfterInsertionAggregator- Manages post-completion actions
The plugin uses a type-safe record system for data collection and aggregation:
data class Record(
val type: Type,
internal val expanded: MutableMap<EntryKey, Any> = mutableMapOf()
) {
enum class Type {
CONTEXT,
BEHAVIORAL_TELEMETRY,
CONTEXTUAL_TELEMETRY,
MODEL
}
companion object {
inline fun <reified T : Any> key(name: String): EntryKey {
return EntryKey(name, T::class.java)
}
}
}
// Usage example - type-safe data storage
val record = Record(Record.Type.BEHAVIORAL_TELEMETRY)
record.put(Record.key<Long>("timing_data"), 1500L)
record.put(Record.key<String>("event_type"), "completion_shown")Data Aggregation Process:
fun aggregateByType(): Map<Record.Type, List<Record>> {
return this.groupBy { it.type }
}
fun toMap(): Map<String, Any> {
return this.expanded.entries.associate { (key, value) ->
key.name to value
}
}IntelliJ Plugin
β
βΌ User Login Request
Authentication Service
β
βΌ OAuth Flow (optional)
Google OAuth βββΊ JWT Token βββΊ Authentication Service
β β
βΌ βΌ
Code4Me Backend βββ POST /api/user/authenticate
β
βΌ Session Tokens
Authentication Service βββΊ Authentication Success βββΊ IntelliJ Plugin
Authenticated Communication Flow:
Plugin βββΊ API Requests with Session Cookies βββΊ Backend
βββ Responses with Token Refresh ββββββββββ Backend
The plugin communicates with the Code4Me backend through a comprehensive REST API with the following characteristics:
Base Configuration:
- Server settings loaded from plugin.conf (host, port, timeout)
- Specialized HTTP clients for different operations (chat, completion, authentication)
- Automatic retry logic with exponential backoff
- Connection pooling for improved performance
Completion Request Process:
- Data Collection Phase - ModuleManager collects data from all enabled modules
- Data Aggregation - Records are grouped by type and converted to maps
- API Request Construction - Request object built with context, telemetry, and user preferences
- Server Communication - HTTP request sent to completion API with authentication
- Response Processing - Completion results integrated back into IDE interface
Authentication Error Recovery:
- Automatic detection of invalid or expired tokens
- Graceful fallback to login prompt when authentication fails
- User data cleanup on authentication errors
- Clear notification system for token invalidation
API Communication Resilience:
- Automatic token refresh on 401 responses
- Connection retry logic with exponential backoff
- Graceful degradation when backend is unavailable
- Local caching of critical configuration data
- User notification system for connection issues
User Preference System: The plugin provides comprehensive privacy controls through the PrefSettings system:
- Code Context Storage - Enable/disable storage of file content and snippets
- Environment Telemetry - Control collection of editor state and file information
- User Behavior Analytics - Manage collection of typing patterns and interaction data
- Active Module List - Maintain list of enabled/disabled modules
- Module Preferences - Individual settings for each module's behavior
Limited Data Collection Mode:
- One-click button applies privacy-focused defaults across all modules
- Disables non-essential data collection while maintaining core functionality
- Provides transparent indication of what settings were changed
- Reversible - users can re-enable specific modules after applying limited mode
What Gets Sent to Server:
- Code Context: File content snippets, cursor position, selection (if enabled)
- Contextual Telemetry: File paths, language info, editor state (if enabled)
- Behavioral Telemetry: Typing patterns, completion acceptance rates (if enabled)
- Chat Data: Conversation history for context continuity
- Feedback Data: Completion acceptance/rejection for model improvement
Privacy Safeguards: The plugin implements comprehensive data filtering before transmission:
- Context data is filtered based on storeContext preference
- Telemetry data is filtered based on respective telemetry preferences
- Users have granular control over what data leaves their local environment
The plugin uses HOCON (Human-Optimized Config Object Notation) for configuration management. The configuration includes:
Server Configuration (customizable for different backend deployments):
- Backend server host and port settings
- Connection timeout and retry parameters
- Context path and SSL configuration
Authentication Settings (customizable OAuth configuration):
- Google OAuth client credentials
- Session timeout and renewal settings
- Multi-provider authentication support
AI Model Configuration (example models shown - researchers can configure any models):
- Available model definitions with IDs and names
- Chat vs completion model classification
- Default model selection and system prompts
- Custom model parameters and settings
Module Categories Definition (researchers can add custom categories):
- Behavioral telemetry modules for user interaction patterns
- Contextual telemetry modules for environment and editor state
- Context retrieval modules for code understanding
- Aggregator modules for data coordination
- Model modules for AI configuration
- After-insertion modules for post-completion actions
Note: The specific models and settings shown in plugin.conf are examples from the current configuration. Researchers can modify plugin.conf to use different models, change system prompts, and adjust all settings for their specific experiments.
Complete Module Definition Structure: Each module in plugin.conf includes:
- Identification - Unique ID, class name, and display name
- Type Classification - Module type (aggregator, telemetry, context, etc.)
- Description - Human-readable description of module function
- Enablement State - Whether module is active by default
- Submodules - Nested modules with their own configurations
- Dependencies - Hard and soft dependencies on other modules
Dependency Types:
- Soft Dependencies - Module works without them but with reduced capabilities
- Hard Dependencies - Required for basic module operation
- Dependency Validation - System prevents circular dependencies and ensures required modules are available
Dynamic Configuration Loading:
- HOCON format allows comments, includes, and variable substitution
- Configuration is parsed and validated during plugin startup
- Module configurations are processed hierarchically
Parallel Data Collection:
- Enabled modules process data collection requests in parallel streams
- Failed modules don't block other modules from completing
- Exception handling ensures individual module failures don't crash the system
- Stream-based processing provides efficient resource utilization
Asynchronous Processing:
- Non-blocking completion requests with configurable timeouts
- Cancellable operations that respect IDE responsiveness
- Background processing for non-critical operations
- Efficient thread pool management for concurrent requests
Connection Pooling:
- HTTP client reuse with connection pooling
- Persistent connections for chat operations
- Connection recovery and retry logic
Caching Strategies:
- Local caching of completion results
- Context data caching to avoid redundant collection
- Configuration caching to reduce startup time
- JDK 21 or higher
- IntelliJ IDEA 2024.2+
- Gradle 8.13+
# Clone the repository
git clone https://github.com/AISE-TUDelft/code4me2.git
cd code4me2
# Build the plugin
./gradlew build
# Run tests
./gradlew check
# Run in development IDE
./gradlew runIdeThe project maintains high code quality through:
- Kotlin Code Style: Enforced through ktlint
- Automated Testing: JUnit-based test suite
- Static Analysis: Gradle Qodana plugin for code quality analysis
- Documentation: Dokka for comprehensive API documentation
1. Implement PluginModule Interface: Create a new module class that implements the PluginModule interface with:
- Module name and identification
- Data collection logic in collectData method
- Preference class specification (BEHAVIORAL_TELEMETRY, CONTEXTUAL_TELEMETRY, etc.)
- Preference list definition with keys, types, and descriptions
2. Add to plugin.conf: Register your module in the configuration with:
- Unique module ID and class name
- Module type and description
- Enabled/disabled state
- Dependencies and submodules if applicable
- Register with an Aggregator
- Documentation: Comprehensive KDoc for all public APIs
- Error Handling: Graceful degradation and proper logging
- Performance: No blocking operations on UI thread
- Security: No sensitive data in logs or debug output
Key interface for module lifecycle management:
getAvailableModules()- Returns list of all available modulescollectData(request)- Triggers data collection from all enabled modulesinitializeModules()- Initializes modules and their dependenciesstoreModules(modules)- Stores module instances for runtime use
Configuration management and module instantiation:
getAvailableModules()- Gets module configurations from plugin.confgetServerConfig()- Returns server connection settingsgetModelsConfiguration()- Returns AI model configurationinstantiateModulesFromConfigs()- Creates module instances from configuration
The plugin integrates with the Code4Me backend through these endpoints:
Authentication:
POST /api/user/authenticate/- User loginPOST /api/user/create/- Account creationGET /api/user/get/- Current user info
Completion:
POST /api/completion/request/- Request code completionPOST /api/completion/feedback/- Submit completion feedbackPOST /api/completion/multi-file-context/update/- Update context
Chat:
POST /api/chat/request/- Chat completion request
- IntelliJ Platform SDK β Plugin development reference
- Gradle IntelliJ Plugin β Build & run IntelliJ plugins
- Kotlin Docs β Language and standard library
- HOCON Spec β Plugin configuration format
- ktlint β Kotlin linter
- OAuth 2.0 β Authentication standard
- TU Delft AISE Lab β Research group behind Code4Me
- TU Delft AISE Laboratory for research support and academic collaboration
- JetBrains for the IntelliJ Platform and development tools
- Hugging Face for AI model infrastructure and ecosystem
- Kotlin Community for the excellent programming language and ecosystem


