Skip to content

Developing Plugins

CortexPrism edited this page Jun 17, 2026 · 1 revision

Developing Plugins

Full guide at: docs/plugins/developing.md

Quick Reference

Project Structure

my-plugin/
├── manifest.json        # Plugin identity, capabilities, entry point
├── mod.ts               # Entry point — exports tools, hooks, providers
└── README.md

Manifest

{
  "name": "my-plugin",
  "version": "1.0.0",
  "description": "An example plugin",
  "kind": "esm",
  "entryPoint": "./mod.ts",
  "runtime": "deno",
  "capabilities": ["tools", "network:fetch"]
}

Entry Point

import type { Tool, PluginContext } from 'cortex/plugins';

const myTool: Tool = {
  definition: {
    name: 'my_tool',
    description: 'Does something useful',
    params: [{ name: 'input', type: 'string', description: 'Input', required: true }],
    capabilities: ['network:fetch'],
  },
  execute: async (args, ctx) => {
    return { toolName: 'my_tool', success: true, output: 'result', durationMs: 0 };
  },
};

export const tools = [myTool];

Lifecycle Hooks

export const onLoad = async (ctx: PluginContext) => { /* init */ };
export const onUnload = async (ctx: PluginContext) => { /* cleanup */ };
export const onActivate = async (ctx: PluginContext) => { /* tools live */ };
export const onDeactivate = async (ctx: PluginContext) => { /* tools removed */ };

Testing

cortex plugins install ./my-plugin
cortex plugins enable my-plugin
cortex plugins list
cortex chat  # test your tool

See Also

Clone this wiki locally