Plugin and Engine
$.plugin names the plugin.
plugin.register lets a mod refuse another module.
engine.create builds $ and lets a mod add a noun.
A plugin ships the types of its noun in the .d.ts file that types names in plugin.json.
Return { refuse } from plugin.register to keep a module out. The types file is named in plugin.json.
Official page: Mods Reference. Source: the program (types-2.1.304.d.ts).
Example
This hook keeps user mods out.
on('plugin.register', { tier: 'user' }, () => ({ refuse: 'managed only' }))
This engine.create hook adds a noun.
on('engine.create', async ($, e, next) => {
const built = await next(e)
return { ...built, voice: { say: async (text) => {} } }
})
Members of the Plugin Noun
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
$. | Documented | The name from plugin.. Debug-log and $. lines carry it. | Type string. | Anywhere in the module (a plain value). |
$. | Documented | The plugin's directory (the one holding plugin.), absolute. | Type string. | Anywhere in the module (a plain value). |
Events
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
plugin. | Documented | Fires once for each hooks module about to join the chain, at load and at reload. Core allows by default. | Input Plugin. Result Plugin: { allow: or { refuse }. A refused module never joins. A judge that fails is skipped and the module joins. | Hook via on('plugin.. |
engine. | Documented | Runs while $ is built, once per load or reload of this plugin, before any other hook of it. next(e) resolves to $ built so far. | Input Engine. Result Engine. A step may add nouns to $. Outside user it may also withhold nouns. It fails and the plugin unloads if it replaces another plugin's noun. | Hook via on('engine.. |
Types
| Item | Status | What it is for | Shape and limits |
|---|---|---|---|
Core | Documented | The plugin's identity (plugin) and the nouns core adds to $ as the innermost step of the engine. fold. | A finished $ has every core noun that no outer step withheld and every noun that plugins added. |
Engine | Documented | The input of engine.. | Field plugins: the modules this fold builds, first outermost (managed plugins first, so an organization plugin's withholding wins). At a first load it is all plugins. At a reload it is this plugin only. Write the hook after next: const built = await next(e). |
Engine | Documented | What an engine. hook returns: $ as built so far with this plugin's nouns added, less any it withheld. | Engine plus a record of nouns. Every declared noun is optional here. |
Engine | Documented | $, the first parameter of every hook. Frozen. | A plugin adds a noun by declaration merging: declare module "claude-. |
Engine | Documented | What next(e) resolves to at engine.: $ as the steps beneath built it. | Open to nouns no declaration names yet. A withheld noun is a stub on it. |
No | Documented | What an engine. hook gets as $: nothing. | Every property reads as never, so $. inside the hook is a compile error. |
INSTRUCTION_ | Documented | Every tier an instruction file can belong to. | ["managed", "user", "project", "local", "memory"] |
Instruction | Documented | One instruction file behind the claude block. | path (absolute), kind, content (comments and front matter already stripped), and parent? (the file whose @ import brought this one). |
Instruction | Documented | The tier of an instruction file. | One of the values of INSTRUCTION_. |
Plugin | Documented | A plugin's options as register(on, options) gets them: the values of its user fields, defaults filled in. | A read-only record of string, number, boolean, or string list. Stored in plugin of settings. |
Plugin | Documented | The input of plugin.: one hooks module about to load. Every field is pinned. | name, tier (never core), root, version?, provenance (<name>@<marketplace>, <name>@inline for --, <name>@builtin), and uses. |
Plugin | Documented | What a plugin. hook returns. | { allow: lets the module load. { refuse: stops it. The debug log names the plugin and the reason. |
Plugin | Documented | What a hooks module uses, as the host scanned its source. These are the lists claude plugin validate prints. | events (the patterns of the on calls), calls (noun.), env? (names in $. and $.), state? ({ plugin, key }). A module that spells on, $, $., or a $. reference in a non-literal way does not load. |
Plugin | Documented | Whose element: the plugin whose hook drew it, stamped by the runtime. | Field plugin. Two plugins under one hover. string never share a group. |
Plugin | Documented | The named values plugins keep in the session ($.), by plugin name and key. Empty by default. | A plugin declares its keys by declaration merging. Example: interface Plugin. |