Adding a Module to Kirak
This guide explains how to add a built-in module to the Kirak runtime itself. To build custom modules within your own application, see Building Custom Modules; to add a new provider to an existing module, see Adding a Provider.
Kirak describes each module declaratively in a catalog specification. The catalog CLI (kirak modules, kirak providers, kirak catalog), kirak env, kirak validate, generated .env.example templates, and documentation reference tables are all generated from these specs and JSON Schemas. Tests verify that catalog specifications and runtime code stay strictly in sync.
Files to Change
Section titled “Files to Change”| Component | Target File | Required Modifications |
|---|---|---|
| Module Implementation | kirak/<module>/ |
Core module class (inheriting from BaseModule), router, and register_module() call |
| Catalog Specification | kirak/catalog/specs/<module>.py |
Define ModuleSpec: summary, pip extras, kirak.json section name, operations, hook events, bundled models, provider kinds, and environment variables |
| Catalog Index | kirak/catalog/specs/__init__.py |
Add new ModuleSpec to MODULES |
| Provider Registry | kirak/<module>/registry.py |
(If provider-based) Build registry table with builtin_table(provider_kind(...)) |
| JSON Schema | kirak/schemas/manifest.schema.json |
Declare the module’s kirak.json configuration section; provide description for every key |
| Dataclass | kirak/core/manifest.py |
Add the configuration dataclass representation |
| Validation Rules | kirak/validation/manifest.py |
Custom validation rules; register new problem codes in kirak/core/problem_codes.py |
| Packaging | pyproject.toml |
Define optional pip extra and register package data under [tool.setuptools.package-data] |
| Documentation | docs/modules/<module>.md |
Architecture, usage guides, and configuration references |
| Configuration Reference | docs/reference/configuration.md |
A <details> block for the module with <!-- TABLE START: <module>-settings --> and <!-- TABLE END: <module>-settings --> markers (and -providers) |
| Global Docs & Docstrings | docs/index.md, README.md, kirak/kirak_instance.py |
Add module summary to high-level tables and docstrings |
| Changelog | CHANGELOG.md |
Add release entry |
After updating the catalog spec, regenerate documentation tables:
python scripts/gen_reference.pyThe settings, provider, environment variable, error code, module and social provider tables are generated into the pages themselves. A page marks where a table goes with a pair of HTML comments, and the script writes the table between them, so the Markdown file holds the table and reads the same in an editor, on GitHub and on the website:
<!-- TABLE START: storage-providers (generated by scripts/gen_reference.py; do not edit) -->| Name | Where | Required / default | Description || ... |<!-- TABLE END: storage-providers -->To place a table, write the two marker lines with nothing between them and run the script. Edit the prose around the
markers, never the lines between them: the next run replaces those. tests/test_catalog/test_generated_docs.py fails
when a table is out of date, a marker names no table, or a table is placed on no page.
Automated Verification Tests
Section titled “Automated Verification Tests”The test suite catches any missed catalog registration steps:
tests/test_catalog/test_specs_match_code.py– Verifies every registered module has a spec matching its operations, hooks, manifest section, and pip extras.tests/test_core/test_schema_files.py– Verifies schema keys have descriptions and match dataclasses.tests/test_catalog/test_env.py– Confirms all read environment variables are declared in specs.tests/test_catalog/test_generated_docs.py– Confirms documentation tables match catalog specs.tests/test_validation/test_validate.py– Verifies all problem codes are registered.tests/test_core/test_package_data.py– Verifies all package data files are included in the build wheel.