Creating a Plugin
Scaffold one
aegis plugins create scraper --author "Your Name" --description "Web scraping for Aegis Stack"
cd aegis-stack-scraper
pip install -e .
aegis plugins list
The scaffold produces:
aegis-stack-scraper/ the distribution
pyproject.toml registers the plugin (see below)
src/aegis_stack_scraper/ the import package
plugin.py get_spec(): what the plugin is
templates/{{ project_slug }}/ files that land in a project
tests/test_plugin.py pins the spec and the registration
Makefile, .pre-commit-config.yaml,
.github/workflows/test.yml lint and test, locally and in CI
What plugin.py declares
get_spec() returns a PluginSpec, the same declaration the built-in
services and components use. It is a description, not code that runs in the
project: Aegis reads it to know what to render, wire and migrate when someone
runs aegis add scraper.
It declares:
- what the plugin owns: the files its templates produce, so
aegis removecan take exactly those out again; - how it wires in: routers, settings, health checks, dashboard cards and modals, CLI commands;
- what it needs: components and services it depends on;
- its own tables: migrations, written and applied on
aegis add, in a Postgres schema of its own when it declares one; - its own worker queues:
worker_queues=["crawler"]names a queue module the plugin ships atapp/components/worker/queues/crawler.py, and a stack with the worker component runs aworker-crawlercontainer for it, one process, bind-mounted in dev like the stack's own workers. Gate the module oninclude_workerand write one branch perworker_backend(arq, TaskIQ, Dramatiq); without the component the file renders empty and nothing reads it. A queue that needs numbers of its own declares them:worker_queues=[WorkerQueueWiring("media", concurrency=2, max_wait_seconds=900)]. Without that, the queue inheritsWORKER_QUEUE_DEFAULT(10 jobs) — wrong for work that pins a core, like anffmpegrun: ten of them on a two-vCPU box is an unresponsive machine. The numbers render intoapp/core/plugin_queue_defaults.pyand merge intoDEFAULT_QUEUES, so they are the project's own default from the moment the plugin lands; a project that wants something else still setsWORKER_QUEUESin its environment, which wins. A worker whose work needs more than the stack's 512M names it too,WorkerQueueWiring("media", concurrency=1, memory="1G"), as its compose default;<QUEUE>_WORKER_MEMORYin the environment still wins.
The reference plugin, aegis-stack-crawl4ai, exercises most of that surface
and is the best example to read.
What goes into the image
Four levers, in order of size. Pick the smallest that carries what you need:
| need | mechanism | ends up as |
|---|---|---|
| a Python library | pyproject_deps=["pillow>=11"] |
pyproject.toml, installed by uv sync |
| an apt package, tens of MB | docker_packages=["ffmpeg", "poppler-utils"] |
docker/apt-packages.txt, installed in its own layer |
| a non-apt download, ~100 MB | docker_steps=["fetch-model"] plus docker/build.d/fetch-model.sh in your templates |
run in name order by the build hook |
| 500 MB–1 GB (a model, a JVM, a GPU runtime) | docker_services=["inference"] and your own docker/inference/Dockerfile |
a service of its own, talked to over HTTP |
docker_packages and docker_steps reach the image through two fixed hook
blocks in Dockerfile.jinja, which copy docker/apt-packages.txt and run
docker/build.d/*.sh. The Dockerfile never mentions your plugin, which is
the point: that file is warn-if-diverged, so a project that has added its own
build steps keeps its copy, and anything written into it by a plugin would
never arrive. The hooks are data, and aegis add/aegis remove rewrite that
data when plugins come and go — the same package requested by two plugins is
installed once.
Step scripts are files rather than commands on purpose: a run this URL | sh
string cannot be read in review, and would be interpolated into a shell.
What a project finds by convention
Some of what a plugin contributes needs no wiring in plugin.py: the
project looks for a module of a known name in every service package, on
disk, and picks up a plugin's the same way as its own.
File in app/services/<your service>/ |
What it holds |
|---|---|
__init__.py |
CATEGORY = Category.DATA (from app.core.parts): where the service sits in Overseer's grouping; App when left out |
models.py (or a models/ package) |
the plugin's tables |
health.py |
HEALTH, its health check, registered at startup under the service's folder name; or the spec's health_checks, registered under its label (the name overseer_pages keys a page on). One or the other, not both |
change_types.py |
changes a model proposes and the user approves |
scheduled_jobs.py |
JOBS, the jobs that run on a schedule |
aggregates.py |
AGGREGATES, what the plugin's data says about itself (Aggregate from app.core.aggregates): counts and sums an agent reads with aggregate, never rows |
overseer.py |
OVERSEER, an OverseerPage (app.core.overseer_pages): a page of its own in Overseer, see Services (or the spec's overseer_pages) |
tools.py |
tools an agent or an MCP client can be granted (register_tool) — declaring one in the spec's agent_tools is what grants it |
A tool is only usable once it is declared, with the effect it has:
Registering it in tools.py and stopping there leaves it ungranted — the
default chat agent and the MCP_TOOLS list are built from these
declarations, and the generated project's tests/core/test_tools.py expects
every registered tool to carry a decided effect. The effect is a policy
call, never inferred: read for a lookup, writes for anything that
changes a row. A tool you deliberately keep away from the agent is simply
not declared.
A scheduled job is a ServiceJob from app.core.schedule: the job
function, a stable id, a display name and the trigger. In a project with a
worker it runs on the worker. Without a scheduler the list is simply never
read, so a plugin can ship its jobs whether or not the project has one.
# app/services/scraper/scheduled_jobs.py
from app.core.schedule import ServiceJob
from app.services.scraper.jobs import recrawl_sites_job
JOBS: tuple[ServiceJob, ...] = (
ServiceJob(
recrawl_sites_job,
"scraper_recrawl",
"Scraper: Recrawl Sites",
{"trigger": "cron", "hour": 3},
),
)
Ids and function names are shared with every other service: prefix them with the plugin's name.
Depending on a service variant
Dependencies can name a variant. required_services = ["auth[org]"] asks for
auth at org level: aegis add installs it at that level when the project has
no auth, upgrades it when the project is at basic or rbac, and does nothing
when org is already there. A request that would swap an unordered choice, such
as ai[langchain] on a pydantic-ai project, is refused with a message rather
than applied silently.
How the CLI finds it
pyproject.toml registers the spec under the aegis.plugins entry point
group:
Any aegis command run in an environment where the package is installed sees
it, whether it was installed from PyPI, a git URL or a local path. aegis
never installs packages itself.
When the plugin works locally, see Publishing a Plugin.