-
-
Notifications
You must be signed in to change notification settings - Fork 1
Plugin Architecture
RenzMc edited this page Sep 6, 2025
·
1 revision
This guide provides a technical overview of the Acode AI CLI Assistant Plugin architecture, components, and design patterns.
The plugin is built using modern JavaScript with a modular architecture that integrates seamlessly with Acode's plugin system while providing advanced AI capabilities.
Acode-Plugin-AI-cli/
βββ src/
β βββ main.js # Main plugin entry point
β βββ constants.js # Configuration constants
β βββ api_key.js # API key encryption/management
β βββ utils.js # Utility functions
β βββ style.scss # Styling
βββ dist/
β βββ main.js # Bundled plugin code
β βββ assets/ # Plugin assets
βββ docs/ # Documentation files
βββ package.json # Project dependencies and metadata
βββ plugin.json # Acode plugin configuration
βββ build.mjs # Build process configuration
The main plugin class that handles:
- Initialization and setup
- UI rendering and management
- AI provider integration
- Message history handling
- File operations
Responsible for:
- Secure encryption of API keys using AES-GCM
- Passphrase-based key derivation with PBKDF2
- Storage and retrieval of encrypted keys
- Key validation and management
Handles:
- Code change detection
- Debounce timing management
- AI request optimization
- Error detection and suggestions
Manages:
- Multi-file operations
- Pattern-based renaming
- Directory organization
- File movement and deletion
The plugin integrates with multiple AI providers through dedicated classes:
-
OpenAI: Using
@langchain/openaipackage -
Google Gemini: Using
@langchain/google-genaipackage -
Ollama: Using
@langchain/communitypackage -
Groq: Using
@langchain/groqpackage -
Anthropic Claude: Using
@langchain/anthropicpackage - OpenRouter: Custom OpenAI-like integration
- Qwen: Custom OpenAI-like integration
- OpenAI-Like: Generic OpenAI-compatible API integration
All providers implement a common interface:
class AIProvider {
async getResponse(prompt) { /* Implementation */ }
async streamResponse(prompt) { /* Implementation */ }
validateApiKey(apiKey) { /* Implementation */ }
}All plugin styles are scoped to prevent conflicts:
#acode-ai-assistant {
// All styles contained within this scope
}UI elements are modular:
- Chat Interface: Message display, input area, action buttons
- Dialog Components: History browser, settings panel, file selector
- Widgets: Real-time suggestions, error markers, performance indicators
- CSS variables for consistent theming
- Media queries for device-specific layouts
- Flexible components that adapt to screen size
- AES-GCM: For encrypting sensitive data
- PBKDF2: For secure key derivation
- Random IVs: For unique encryption per entry
- API keys never stored in plain text
- Passphrases never stored or transmitted
- Local storage isolation from other plugins
- HTTPS-only API connections
- Secure header management
- Token usage monitoring
The plugin uses ESBuild for fast bundling:
// build.mjs
import * as esbuild from "esbuild";
import { sassPlugin } from "esbuild-sass-plugin";
let result = await esbuild.build({
entryPoints: ["src/main.js"],
bundle: true,
minify: true,
outdir: "dist",
plugins: [
sassPlugin({
type: "css-text",
}),
],
});- SVG icons for crisp rendering
- SCSS for maintainable styling
- JSON configuration files
- Automated ZIP packaging for distribution
- Asset copying and optimization
- Version management through package.json
- User triggers plugin through UI or keyboard shortcut
- Plugin initializes and renders interface
- User inputs query or selects code
- Plugin processes input and sends to AI provider
- AI response is received and formatted
- Response is displayed with markdown rendering
- User can interact with response (copy code, etc.)
- Editor content change detected
- Debounce timer initiated
- Content analyzed for context
- AI request prepared with context
- Response cached for future use
- UI updated with suggestions
- User selects operation type
- File selection interface presented
- Operation parameters configured
- AI analysis performed if needed
- Changes previewed
- User confirms operation
- Files processed in batch
- Component-level testing
- API integration testing
- Security validation testing
- Acode plugin system compatibility
- Cross-provider functionality
- UI responsiveness testing
- Response time monitoring
- Memory usage tracking
- Battery impact assessment
- Token usage tracking
- Response time measurement
- Error rate monitoring
- Feature usage statistics
- Console logging for development
- Error boundary implementations
- Performance profiling hooks
- Acode command registration
- Context menu integration
- Keyboard shortcut binding
- Theme adaptation
- Provider interface for adding new AI services
- Custom prompt templates
- Response formatting customization
- Cache strategy modification
- Custom component injection
- Theme variable overrides
- Layout modification hooks
- Animation customization
- Dependency resolution issues
- SCSS compilation errors
- Asset copying problems
- API provider initialization failures
- UI rendering issues
- Storage access problems
- Acode version compatibility
- Plugin conflict resolution
- Resource limitation handling
To verify architectural components are working:
- Check that main.js initializes properly
- Verify API key manager encrypts/decrypts correctly
- Test real-time analysis engine responsiveness
- Confirm bulk operations manager processes files
If you encounter architectural issues:
- Check the Common Issues documentation
- Visit our GitHub Issues page
- Join our Discussions community for support
- Home
- Getting Started
- Usage Guides
- Advanced Features
- Developer Docs
- Troubleshooting