DevelopersPlugin DevelopmentOverview

Plugin System Overview

Lokus features a powerful, extensible plugin system that allows developers to extend and customize the application’s functionality. Built with security, performance, and developer experience in mind, the plugin system provides comprehensive APIs for editor extensions, UI customization, data integration, and more.

Version: 1.3.1 | Status: Production Ready | Plugin API: v2.0

What’s New in v1.3

The v1.3 “Quantum Leap” release brings VS Code-level extensibility to Lokus with major plugin system enhancements:

Major Features

Plugin Manifest v2.0 Advanced manifest format with contribution points, capabilities, activation events, and dependency management. Full VS Code extension manifest compatibility.

Native MCP Integration Built-in Model Context Protocol support with dedicated builders for resources, tools, and prompts. Create AI-powered plugins with zero configuration.

Performance Enhancements

  • Plugin code splitting and lazy loading
  • WebAssembly support for compute-intensive operations
  • Worker thread execution for background tasks
  • Sub-50ms plugin activation time

Testing Framework v2.0 Complete testing utilities with mock context, helper methods, and async test support. Jest and Vitest compatible out of the box.

Plugin Marketplace Official plugin registry at registry.lokus.dev with:

  • One-click installation
  • Automatic updates
  • Version management
  • User reviews and ratings
  • Download statistics

Enhanced Security

  • Stricter permission model with granular controls
  • Sandboxed WebWorker execution for untrusted code
  • Automatic security scanning
  • CSP (Content Security Policy) enforcement
  • Code signing support

UI Extension Points

  • Custom webview panels with React/Vue support
  • Status bar items
  • Context menus
  • Sidebar panels
  • Editor decorations
  • Tree views
  • Quick pick menus

Plugin Statistics

  • 500+ plugins in official marketplace
  • 14 specialized APIs covering all extension points
  • 95+ editor methods for deep TipTap integration
  • 50+ events for lifecycle hooks
  • 100+ contribution points for UI integration
  • <50ms average activation time
  • 128MB default memory limit per plugin
  • TypeScript-first with full type definitions

Plugin Types

Lokus supports multiple plugin types for different use cases:

1. Editor Plugins

Extend the TipTap-based rich text editor with custom nodes, marks, and extensions.

Use Cases:

  • Custom markdown syntax
  • Specialized content types
  • Editor behaviors and interactions
  • Syntax highlighting

Example: Math equation editor, Mermaid diagrams, custom task lists

2. UI Plugins

Add custom panels, toolbars, menus, and visualizations to the Lokus interface.

Use Cases:

  • Custom sidebars and panels
  • Toolbar buttons and context menus
  • Status bar items
  • Tree views and lists

Example: File explorer, outline view, minimap

3. Data Provider Plugins

Integrate external data sources and services into Lokus.

Use Cases:

  • External API integration
  • Database connections
  • Cloud service integration
  • Real-time data synchronization

Example: Jira integration, GitHub issues, Trello boards

4. Command Plugins

Register custom commands and keyboard shortcuts.

Use Cases:

  • Workflow automation
  • Batch operations
  • Custom tools
  • Quick actions

Example: Bulk rename, format on save, template generator

5. Theme Plugins

Create and distribute custom themes and visual styles.

Use Cases:

  • Color schemes
  • Typography customization
  • Icon packs
  • Visual effects

Example: Dracula theme, Material Design, high contrast themes

6. Language Support Plugins

Add syntax highlighting and language features for programming languages.

Use Cases:

  • Code syntax highlighting
  • Language-specific features
  • Code snippets
  • Linting and formatting

Example: Rust support, Python highlighting, JSON formatting

7. Tool Plugins

Integrate external tools and utilities.

Use Cases:

  • Build systems
  • Testing frameworks
  • Linters and formatters
  • Version control

Example: Git integration, ESLint, Prettier

8. Visualization Plugins

Create custom data visualizations and diagrams.

Use Cases:

  • Chart types
  • Graph layouts
  • Interactive visualizations
  • 3D renderings

Example: Gantt charts, mind maps, network diagrams

Quick Start

Get started with plugin development in minutes:

import { Plugin, PluginContext } from 'lokus-plugin-sdk'
 
export default class MyPlugin implements Plugin {
  async activate(context: PluginContext) {
    // Register a command
    context.api.commands.register({
      id: 'myPlugin.hello',
      title: 'Say Hello',
      handler: () => {
        context.api.ui.showNotification('Hello from my plugin!', 'info')
      }
    })
  }
 
  async deactivate() {
    // Cleanup resources
  }
}

Plugin Architecture

┌─────────────────────────────────────────────────────────┐
│                    Lokus Application                    │
├─────────────────────────────────────────────────────────┤
│                                                         │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐   │
│  │   Editor    │  │     UI      │  │  Workspace  │   │
│  │   (TipTap)  │  │  Components │  │   Manager   │   │
│  └──────┬──────┘  └──────┬──────┘  └──────┬──────┘   │
│         │                │                │           │
├─────────┼────────────────┼────────────────┼───────────┤
│         │   Plugin API Bridge            │           │
│         │   (LokusPluginAPI)             │           │
├─────────┼────────────────┼────────────────┼───────────┤
│         │                │                │           │
│  ┌──────▼──────┐  ┌──────▼──────┐  ┌──────▼──────┐   │
│  │  EditorAPI  │  │    UIAPI    │  │ WorkspaceAPI│   │
│  │   (95+)     │  │  (panels,   │  │  (files,    │   │
│  │   methods   │  │   dialogs)  │  │   editors)  │   │
│  └─────────────┘  └─────────────┘  └─────────────┘   │
│                                                         │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐   │
│  │ TerminalAPI │  │   TaskAPI   │  │  DebugAPI   │   │
│  │ (terminals) │  │   (tasks)   │  │  (debugger) │   │
│  └─────────────┘  └─────────────┘  └─────────────┘   │
│                                                         │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐   │
│  │ StorageAPI  │  │FilesystemAPI│  │ NetworkAPI  │   │
│  │   (K-V)     │  │   (safe)    │  │   (fetch)   │   │
│  └─────────────┘  └─────────────┘  └─────────────┘   │
│                                                         │
├─────────────────────────────────────────────────────────┤
│              Plugin Runtime Environment                 │
│              (Sandboxed, Permission-based)              │
├─────────────────────────────────────────────────────────┤
│                                                         │
│   ┌──────────┐  ┌──────────┐  ┌──────────┐           │
│   │ Plugin A │  │ Plugin B │  │ Plugin C │           │
│   │          │  │          │  │          │           │
│   │ context  │  │ context  │  │ context  │           │
│   │   .api   │  │   .api   │  │   .api   │           │
│   └──────────┘  └──────────┘  └──────────┘           │
│                                                         │
└─────────────────────────────────────────────────────────┘

Core Concepts

Plugin Lifecycle

Plugins follow a well-defined lifecycle:

  1. Installation - Plugin downloaded and validated
  2. Activation - Plugin loaded based on activation events
  3. Execution - Plugin APIs available for use
  4. Deactivation - Plugin cleanup and resource disposal
  5. Uninstallation - Plugin removed from system

See Plugin Lifecycle for detailed information on lifecycle hooks and resource management.

Security Model

All plugins run in sandboxed environments with:

  • Declared permissions enforced at runtime
  • Memory and CPU limits
  • No direct Node.js API access
  • Isolated storage per plugin

API Surface

Lokus provides 14 comprehensive APIs for complete extensibility:

Core APIs:

  • EditorAPI - 95+ methods for TipTap editor integration, custom nodes, marks, extensions, slash commands, and toolbar items
  • UIAPI - Notifications, dialogs, panels, tree views, status bars, webviews, and progress indicators
  • CommandsAPI - Register commands, keyboard shortcuts, and command palette integration
  • WorkspaceAPI - Access workspace files, folders, active editors, and file events
  • ConfigurationAPI - Read/write plugin settings with change notifications

Language & Editor Features:

  • LanguagesAPI - Completion providers, hover information, code actions, formatters, and linters

Terminal & Tasks:

  • TerminalAPI - Create terminals, send commands, listen for terminal events
  • TaskAPI - Task providers, task execution, and task events

Debugging & Themes:

  • DebugAPI - Debug adapters, debug configurations, and debugging sessions
  • ThemeAPI - Register themes, customize colors, theme change events

Storage & Files:

  • StorageAPI - Key-value storage with multiple databases
  • FilesystemAPI - Safe file operations within plugin directory

Network & System:

Next Steps

Learn the Basics

Explore the APIs

Dive Deeper

Advanced Topics

  • Architecture - Deep dive into plugin architecture and runtime
  • MCP Integration - Build AI-powered plugins with Model Context Protocol
  • Performance - Optimization techniques and best practices
  • Publishing - Share your plugin on the marketplace

Additional Resources