interface IPlugin
Since 0.1.0

The plugin contract. Every framework capability implements this interface (AI_GUIDELINES ยง3.2).

Examples

Example 1

export function MyPlugin(options: MyPluginOptions): IPlugin {
  return {
    name: 'my-plugin',
    version: '1.0.0',
    dependencies: [CAPABILITIES.LOGGER],
    provides: ['my-capability'],
    register(ctx) {
      ctx.services.register('my-capability', new MyService(options));
    },
  };
}

Properties

readonly
name: string

Unique plugin name, lowercase kebab-case.

readonly
version: string

Plugin semver, matching its deno.json version.

readonly
optional
dependencies: readonly CapabilityToken[]

Capability tokens that must be provided before this plugin registers.

readonly
optional
optionalDependencies: readonly CapabilityToken[]

Capability tokens used when present, tolerated when absent.

readonly
optional
provides: readonly CapabilityToken[]

Capability tokens this plugin registers.

readonly
optional
consumes: readonly CapabilityToken[]

Capability tokens this plugin resolves lazily at runtime via ctx.services.get. Unlike IPlugin.dependencies, these are not required before this plugin registers and impose no ordering; but if no registered plugin provides one, the kernel emits a soft warn-level startup diagnostic (through the logger capability when one is registered), because the deferred lookups would otherwise fail only later, at request time.

readonly
optional
priority: number

Registration priority within the same dependency level; lower first.

Methods

register(ctx: IPluginContext): void | Promise<void>

Registers the plugin's services, middleware, routes, and hooks.

Usage

import { type IPlugin } from "common/src/index.ts";