Skip to main content

When to Add a Module

The runtime has 15 modules. Adding a 16th is a significant decision — do it when a new function doesn’t fit any existing region and is important enough to be a permanent part of the pipeline.
Before adding a module, consider whether the function belongs in an existing module. If it’s a new tool, it probably belongs in cerebellum as a capability. If it’s a new safety check, it belongs in amygdala. New modules are for genuinely new cognitive functions.

Step 1: Create the Folder

Follow the one-thing-per-folder convention:

Step 2: Define the Class

Every module follows the same constructor pattern:

Step 3: Define Corpus Events

Add your module’s events to the CorpusEvent enum in corpus.ts:
Name events as module-name.past-tense-verb. This makes the event log read like a story: “message received, context built, safety checked, response streamed.”

Step 4: Wire into Agent

Import and instantiate your module in agent.ts:
Where in the pipeline your module runs depends on what it does:

Step 5: Add Workspace Storage (if needed)

If your module needs persistent state, create a folder in the defaults:
Read and write markdown files for state:

Design Rules

All inter-module communication goes through corpus events. This keeps the dependency graph flat and makes modules independently testable.
Each module does exactly one thing. If you’re adding two unrelated functions, that’s two modules (or one of them belongs in an existing module).
Human-readable, git-versionable, LLM-parseable. Never use binary formats or JSON for workspace state. Markdown with YAML frontmatter is the standard.
Your module should be testable by mocking only the corpus. If you need to mock five other things, your module has too many dependencies.
If your module needs configuration, read it from config.json via the workspace helper. Don’t invent a new config mechanism.

Testing

Unit test your module in isolation by mocking the corpus:

Architecture Overview

Understand how all 15 modules fit together.

Project Structure

Where everything lives in the codebase.