تخطَّ إلى المحتوى

Plugin Author Quickstart

هذا المحتوى غير متوفر بلغتك بعد.

ɳSelf plugins are microservices that run alongside the main stack. The CLI installs, starts, stops, and monitors them. Each plugin exposes a REST API and declares a schema (Postgres tables in the np_<name> schema).

Four SDKs are available. Pick the one that matches your stack.

LanguageInstallRuntime
Go (recommended)go get github.com/nself-org/cli/sdk/gonative binary
TypeScriptpnpm add @nself/plugin-sdkBun
Pythonpip install nself-plugin-sdkPython 3.10+
Flutter/Dartflutter pub add nself_sdkDart 3+

Install the ɳSelf CLI and verify it is running:

Terminal window
nself version
nself start --check

Go is the default language for ɳSelf plugins. Use Go unless you have a specific reason to use TypeScript (existing TS codebase, Deno edge runtime).

Terminal window
go get github.com/nself-org/cli/sdk/go@latest

The SDK gives you: lifecycle management, structured logging, config loading, HTTP server with /healthz and /metrics, Postgres pool helpers, license gating, and a test harness. No boilerplate.

Terminal window
mkdir my-plugin && cd my-plugin
go mod init github.com/yourname/my-plugin
cat > plugin.go << 'GOEOF'
package main
import (
"net/http"
sdkplugin "github.com/nself-org/cli/sdk/go/plugin"
sdkserver "github.com/nself-org/cli/sdk/go/server"
sdklogger "github.com/nself-org/cli/sdk/go/logger"
)
func main() {
log := sdklogger.New("my-plugin", "0.1.0")
srv := sdkserver.New(sdkserver.Config{Port: 3900})
srv.Handle("/my-plugin/hello", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"ok": true}`))
}))
sdkplugin.Run(srv, sdkplugin.Info{
Name: "my-plugin",
Version: "0.1.0",
Logger: log,
})
}
GOEOF

The manifest declares your plugin to the ɳSelf registry.

name: my-plugin
version: 0.1.0
tier: free # or: pro
license: MIT
description: One sentence summary.
author: yourname
port: 3900
schema: np_my_plugin # Postgres schema (created automatically on install)
health: /my-plugin/healthz
endpoints:
- GET /my-plugin/hello
systemDependencies: [] # postgres, redis, minio, etc.
depends: [] # other plugin names
env:
MY_PLUGIN_SECRET:
required: false
description: Optional secret token
default: ""
Terminal window
go run plugin.go
curl http://localhost:3900/my-plugin/hello
Terminal window
nself plugin install ./my-plugin
nself build && nself start

Use nself for TypeScript plugins (Bun runtime).

Terminal window
pnpm add @nself/plugin-sdk
index.ts
import { createPlugin } from '@nself/plugin-sdk'
const app = createPlugin({
name: 'my-plugin',
version: '0.1.0',
port: 3900,
})
app.get('/my-plugin/hello', (c) => c.json({ ok: true }))
app.start()

Minimal plugin.yaml is identical to the Go version above. Change runtime: bun at top level.


Use Python 3.10+ for data-heavy plugins, ML inference, or when your team already has a Python codebase.

Terminal window
pip install nself-plugin-sdk
main.py
from nself_sdk import create_plugin, JSONResponse
app = create_plugin(name="my-plugin", version="0.1.0", port=3900)
@app.get("/my-plugin/hello")
async def hello():
return JSONResponse({"ok": True})
if __name__ == "__main__":
app.run()

Minimal plugin.yaml is identical to the Go version above. Change runtime: python at top level.


Use Dart for plugins that ship as companion widgets alongside a Flutter app (e.g., a plugin that renders UI inside the ɳClaw or nChat app).

Terminal window
flutter pub add nself_sdk

Or add directly to pubspec.yaml:

dependencies:
nself_sdk: ^1.0.0
lib/main.dart
import 'package:nself_sdk/nself_sdk.dart';
void main() async {
final app = NselfPlugin(name: 'my-plugin', version: '0.1.0', port: 3900);
app.get('/my-plugin/hello', (req) async {
return Response.json({'ok': true});
});
await app.run();
}

Minimal plugin.yaml is identical to the Go version above. Change runtime: dart at top level.


FieldRequiredNotes
nameyesLowercase, hyphens only
versionyesSemver
tieryesfree or pro
licenseyesMIT for free, nself for pro
portyesUnique port (see Port Registry)
schemayesPostgres schema. Convention: np_<name>
healthyesHealth endpoint path
endpointsyesDocumented REST surface
dependsnoPlugins that must install first
systemDependenciesnopostgres, redis, minio, mail, search
envnoEnv vars the plugin reads

Full spec: Plugin System Spec


Once you ship a plugin, post it in the #showcase channel on community chat at chat.nself.org to get the plugin-author role. Plugin authors get:

  • Early access to SDK pre-releases
  • #plugin-authors channel for SDK questions
  • Listed in the community plugin registry

Two ready-to-clone templates are available:

Terminal window
# REST API plugin template
git clone https://github.com/nself-org/plugin-template-rest-api
# Webhook dispatcher template
git clone https://github.com/nself-org/plugin-template-webhook-dispatcher

Each template includes: plugin.yaml, Go source, Dockerfile, tests, and a GitHub Actions CI workflow.


Free plugins go to nself-org/plugins. Open a PR with:

  • free/<your-plugin>/plugin.yaml
  • free/<your-plugin>/README.md
  • At least one passing test

Pro plugins are published through the ɳSelf Pro Plugin Program.