@stambha/plugins
v0.3.5
Published
Stambha plugin lifecycle hooks and container (definePlugin, StambhaContainer)
Downloads
961
Maintainers
Readme
@stambha/plugins
Plugin lifecycle — definePlugin, DI container, and Sapphire-style hooks around client startup and interactions.
Part of the @stambha monorepo · GitHub
Install
npm install @stambha/plugins @stambha/coreRequires Node.js 20+.
Quick start
import { createStambhaBot } from "@stambha/core";
import { attachPlugins, definePlugin } from "@stambha/plugins";
const LoggingPlugin = definePlugin("logging", {
postStart: async () => {
console.log("[plugin:logging] client started");
},
});
const client = createStambhaBot({ /* … */ });
await attachPlugins(client, {
plugins: [LoggingPlugin],
});Plugins receive a PluginContext with client, logger, and the StambhaContainer for services.
Container & tokens
import { StambhaContainer, ContainerToken, LoggerToken } from "@stambha/plugins";
const container = new StambhaContainer();
container.register(LoggerToken, () => myLogger);Key exports
| Export | Purpose |
|--------|---------|
| definePlugin | Declare a plugin module |
| attachPlugins | Register plugins on a client |
| PluginManager, createPluginManager | Ordered load/unload |
| StambhaContainer | Lightweight service container |
| resolveSignal, resolveAutocompleteCommand | Interaction routing helpers |
Related packages
| Package | Role |
|---------|------|
| @stambha/core | Client events and lifecycle |
| @stambha/loader | Load local plugins from disk |
Development
pnpm --filter @stambha/plugins build
pnpm --filter @stambha/plugins test