Plugin CLI Reference

The Lokus Plugin CLI (lokus-plugin-cli) is the official command-line tool for creating, building, testing, and publishing Lokus plugins.

Installation

# Install globally
npm install -g lokus-plugin-cli
 
# Or use with npx (no installation needed)
npx lokus-plugin <command>

Commands Overview

CommandDescription
createCreate a new plugin from a template
buildBuild plugin for production
devRun in development mode with hot reload
validateValidate plugin manifest
linkLink plugin for local development
packageCreate distributable package
publishPublish to the registry
loginAuthenticate with the registry
listList installed plugins
infoShow plugin information

create

Create a new plugin project from a template.

npx lokus-plugin create <plugin-name> [options]

Options

OptionDescription
-t, --template \<name\>Template to use (see below)
--skip-promptsSkip interactive prompts, use defaults
--author \<name\>Plugin author name
--description \<desc\>Plugin description
--display-name \<name\>Human-readable plugin name

Available Templates

TemplateDescription
basic-typescriptSimple TypeScript plugin with commands
basic-pluginMinimal plugin structure
react-ui-panelPlugin with React-based UI panel
ui-extension-pluginPlugin with toolbar and status bar items
language-support-pluginPlugin for language/syntax support

Examples

# Interactive mode (prompts for all options)
npx lokus-plugin create my-plugin
 
# Quick start with defaults
npx lokus-plugin create my-plugin --skip-prompts
 
# Specific template
npx lokus-plugin create my-plugin --template react-ui-panel
 
# With metadata
npx lokus-plugin create my-plugin \
  --template basic-typescript \
  --author "John Doe" \
  --description "My awesome plugin" \
  --display-name "My Plugin"

Generated Files

my-plugin/
├── src/
│   └── index.ts          # Plugin entry point
├── test/
│   ├── index.test.ts     # Unit tests
│   └── setup.ts          # Test setup
├── dist/                  # Build output (after npm run build)
├── package.json          # npm configuration
├── plugin.json           # Plugin manifest
├── tsconfig.json         # TypeScript config
├── esbuild.config.js     # Build configuration
└── README.md

build

Build the plugin for production.

npx lokus-plugin build [options]

Options

OptionDescription
-p, --path \<path\>Plugin directory (default: .)
--watchWatch mode for continuous building
--minifyMinify output
--sourcemapGenerate source maps

Examples

# Build current directory
npx lokus-plugin build
 
# Build with source maps
npx lokus-plugin build --sourcemap
 
# Watch mode
npx lokus-plugin build --watch
 
# Build specific directory
npx lokus-plugin build --path ./my-plugin

Note: Most projects use npm run build which is configured in package.json to use esbuild directly.


dev

Run the plugin in development mode with file watching.

npx lokus-plugin dev [options]

Options

OptionDescription
-p, --path \<path\>Plugin directory (default: .)
--verboseEnable verbose logging
--cleanClean build artifacts before starting

Examples

# Start dev mode
npx lokus-plugin dev
 
# With verbose output
npx lokus-plugin dev --verbose
 
# Clean start
npx lokus-plugin dev --clean

validate

Validate the plugin manifest (plugin.json).

npx lokus-plugin validate [options]

Options

OptionDescription
-p, --path \<path\>Plugin directory (default: .)

Output

On success:

✓ Plugin manifest is valid
  Name: my-plugin
  Version: 0.1.0
  Description: A Lokus plugin

On failure:

Error: Missing required fields: version, main

Examples

# Validate current directory
npx lokus-plugin validate
 
# Validate specific plugin
npx lokus-plugin validate --path ./my-plugin

Create a symbolic link in the Lokus plugins directory for local development.

npx lokus-plugin link [options]

Options

OptionDescription
-p, --path \<path\>Plugin directory (default: .)

What it does

  1. Reads the plugin ID from plugin.json
  2. Creates a symlink at ~/.lokus/plugins/\<plugin-id\> pointing to your plugin directory
  3. Lokus will now load your plugin on startup

Examples

# Link current plugin
npx lokus-plugin link
 
# Link specific plugin
npx lokus-plugin link --path ./my-plugin
ls -la ~/.lokus/plugins/
# Should show: my-plugin -> /path/to/your/plugin

Unlinking

To remove the link:

rm ~/.lokus/plugins/<plugin-id>

package

Create a distributable package (.zip file).

npx lokus-plugin package [options]

Options

OptionDescription
-p, --path \<path\>Plugin directory (default: .)
-o, --output \<dir\>Output directory

What it includes

  • dist/ directory (compiled code)
  • plugin.json manifest
  • README.md (if exists)
  • LICENSE (if exists)
  • Assets defined in manifest

Examples

# Package current plugin
npx lokus-plugin package
 
# Custom output directory
npx lokus-plugin package --output ./releases

Output: my-plugin-1.0.0.zip


publish

Publish the plugin to the Lokus registry.

npx lokus-plugin publish [options]

Options

OptionDescription
-p, --path \<path\>Plugin directory (default: .)
-r, --registry \<url\>Registry URL (default: https://lokusmd.com)
--dry-runSimulate without publishing
--tag \<tag\>Version tag (e.g., beta, latest)

Prerequisites

  1. Login first: Run npx lokus-plugin login
  2. Build: Ensure plugin is built (npm run build)
  3. Validate: Run npx lokus-plugin validate
  4. Version: Update version in plugin.json and package.json

Examples

# Publish to production
npx lokus-plugin publish
 
# Dry run (test without publishing)
npx lokus-plugin publish --dry-run
 
# Publish as beta
npx lokus-plugin publish --tag beta

Publish Flow

  1. Validates manifest
  2. Packages the plugin
  3. Uploads to registry at lokusmd.com/api/v1/registry/publish
  4. Returns the published package URL

login

Authenticate with the plugin registry.

npx lokus-plugin login [options]

Options

OptionDescription
--token \<token\>API token (or set via prompt)

Getting a Token

  1. Go to lokusmd.com/marketplace
  2. Sign in to your account
  3. Navigate to Developer Settings
  4. Generate an API token

Examples

# Interactive login
npx lokus-plugin login
 
# With token
npx lokus-plugin login --token lok_xxxxxxxxxxxxxxxx
 
# Using environment variable
export LOKUS_REGISTRY_TOKEN=lok_xxxxxxxxxxxxxxxx
npx lokus-plugin publish

Token Storage

Tokens are stored in ~/.lokus/config.json:

{
  "registryToken": "lok_xxxxxxxxxxxxxxxx"
}

list

List installed plugins.

npx lokus-plugin list [options]

Options

OptionDescription
--jsonOutput as JSON

Example Output

Installed Plugins:
  my-plugin (0.1.0) - linked
  other-plugin (1.2.3) - installed

info

Show detailed information about a plugin.

npx lokus-plugin info [plugin-id] [options]

Options

OptionDescription
-p, --path \<path\>Plugin directory (default: .)

Examples

# Info for current plugin
npx lokus-plugin info
 
# Info for specific plugin
npx lokus-plugin info my-plugin

Environment Variables

VariableDescription
LOKUS_REGISTRY_URLRegistry URL (default: https://lokusmd.com)
LOKUS_REGISTRY_TOKENAuthentication token
LOKUS_PLUGIN_TOKENAlternative token variable

Configuration

You can configure defaults in package.json:

{
  "lokus": {
    "manifest": "./plugin.json",
    "entry": "./src/index.ts",
    "outDir": "./dist"
  }
}

Or in .lokuspluginrc.json:

{
  "registry": "https://lokusmd.com",
  "manifest": "./plugin.json"
}

Common Workflows

Creating and Testing a New Plugin

# 1. Create plugin
npx lokus-plugin create my-plugin --template basic-typescript
cd my-plugin
 
# 2. Install dependencies
npm install
 
# 3. Build
npm run build
 
# 4. Validate
npx lokus-plugin validate
 
# 5. Link for development
npx lokus-plugin link
 
# 6. Start Lokus and test your plugin

Publishing a Plugin

# 1. Ensure tests pass
npm test
 
# 2. Build production
npm run build
 
# 3. Validate
npx lokus-plugin validate
 
# 4. Update version
npm version patch  # or minor/major
 
# 5. Login (if not already)
npx lokus-plugin login
 
# 6. Publish
npx lokus-plugin publish

Updating a Published Plugin

# 1. Make changes
# 2. Update version
npm version patch
 
# 3. Build and validate
npm run build
npx lokus-plugin validate
 
# 4. Publish update
npx lokus-plugin publish

Troubleshooting

”Command not found"

# Use npx instead of global install
npx lokus-plugin <command>

"Plugin manifest not found”

Ensure you’re in the plugin directory and plugin.json exists:

ls plugin.json

“Authentication failed"

# Re-login
npx lokus-plugin login
 
# Check token
cat ~/.lokus/config.json

"Version already exists”

Update the version in both plugin.json and package.json:

npm version patch

Next Steps