Skip to content

Getting Started with Alma Plugin Development

This guide will walk you through creating your first Alma plugin from scratch.

Prerequisites

  • Node.js 18 or later
  • TypeScript knowledge (recommended)
  • Alma installed on your system

Quick Start

1. Create Plugin Directory

Create a new directory for your plugin:

bash
mkdir my-first-plugin
cd my-first-plugin

2. Initialize the Project

bash
npm init -y
npm install -D typescript zod
npm install alma-plugin-api

Create a tsconfig.json:

json
{
    "compilerOptions": {
        "target": "ES2022",
        "module": "ESNext",
        "moduleResolution": "bundler",
        "esModuleInterop": true,
        "strict": true,
        "outDir": "./dist",
        "declaration": true,
        "skipLibCheck": true
    },
    "include": ["*.ts"],
    "exclude": ["node_modules"]
}

3. Create the Manifest

Create manifest.json:

json
{
    "id": "my-first-plugin",
    "name": "My First Plugin",
    "version": "1.0.0",
    "description": "My first Alma plugin",
    "author": {
        "name": "Your Name"
    },
    "main": "main.js",
    "engines": {
        "alma": "^0.1.0"
    },
    "type": "tool",
    "activationEvents": ["onStartup"]
}

4. Write the Plugin Code

Create main.ts:

typescript
import type { PluginContext, PluginActivation } from 'alma-plugin-api';

export async function activate(context: PluginContext): Promise<PluginActivation> {
    const { logger, ui } = context;

    logger.info('My first plugin activated!');

    // Show a notification when the plugin loads
    ui.showNotification('Hello from my plugin!', { type: 'success' });

    return {
        dispose: () => {
            logger.info('My first plugin deactivated');
        },
    };
}

5. Build and Install

bash
npx tsc

Copy the compiled files to Alma's plugins directory:

  • macOS: ~/Library/Application Support/Alma/plugins/my-first-plugin/
  • Windows: %APPDATA%/Alma/plugins/my-first-plugin/
  • Linux: ~/.config/Alma/plugins/my-first-plugin/

Required files:

  • manifest.json
  • main.js

6. Enable the Plugin

  1. Open Alma
  2. Go to Settings > Plugins
  3. Find "My First Plugin" and enable it

Plugin Structure

A typical Alma plugin has the following structure:

my-plugin/
├── manifest.json       # Plugin metadata (required)
├── main.ts             # Source code
├── main.js             # Compiled entry point (required)
├── package.json        # npm package file
├── tsconfig.json       # TypeScript configuration
└── README.md           # Plugin documentation

Manifest Reference

The manifest.json file defines your plugin's metadata and capabilities:

json
{
    "id": "unique-plugin-id",
    "name": "Human Readable Name",
    "version": "1.0.0",
    "description": "What your plugin does",
    "author": {
        "name": "Author Name",
        "email": "author@example.com",
        "url": "https://example.com"
    },
    "main": "main.js",
    "engines": {
        "alma": "^0.1.0"
    },
    "type": "tool",
    "permissions": [
        "notifications"
    ],
    "activationEvents": [
        "onStartup"
    ],
    "contributes": {
        "tools": [],
        "commands": [],
        "configuration": {
            "title": "My Plugin Settings",
            "properties": {
                "myPlugin.enabled": {
                    "type": "boolean",
                    "default": true,
                    "description": "Enable the plugin feature"
                }
            }
        }
    }
}

Manifest Fields

FieldRequiredDescription
idYesUnique identifier (lowercase, hyphens allowed)
nameYesDisplay name
versionYesSemantic version (e.g., "1.0.0")
descriptionYesShort description
authorYesAuthor information
mainYesEntry point file
engines.almaYesRequired Alma version
typeNoPlugin type (tool, ui, theme, provider, transform)
permissionsNoRequired permissions
activationEventsNoWhen to activate the plugin
contributesNoPlugin contributions

Activation Events

EventDescription
onStartupActivate when Alma starts
onCommand:commandIdActivate when a specific command is invoked
onLanguage:languageIdActivate for specific file types
*Activate immediately (not recommended)

Plugin Types

TypeDescriptionUse Case
toolRegisters AI toolsAdd capabilities the AI can use
uiAdds UI componentsStatus bar items, sidebars
themeProvides themesCustom color schemes
providerAdds AI providersNew AI model backends
transformTransforms dataModify messages/prompts
compositeMultiple typesComplex plugins

Next Steps