systemprompt-loader
File loading infrastructure for systemprompt.io - separates I/O from shared models.
Overview
Part of the Infra layer in the systemprompt.io architecture.
This crate provides pure I/O operations for loading configuration files, profiles, secrets, extensions, and module definitions without any domain logic.
Architecture
The loader crate sits in the infrastructure layer and depends only on systemprompt-models (shared layer). It separates file I/O concerns from business logic, enabling:
- Testable file operations with clear boundaries
- Reusable loaders across different entry points (API, TUI, CLI)
- Consistent configuration parsing and validation
File Structure
src/
├── lib.rs # Public API exports
├── config_loader.rs # Basic services configuration loader
├── config_writer.rs # Agent configuration file writer
├── enhanced_config_loader.rs # Extended config loader with includes
├── extension_loader.rs # Extension manifest discovery and loading
├── extension_registry.rs # Runtime extension binary registry
├── include_resolver.rs # YAML !include directive resolver
├── module_loader.rs # Module definition aggregator
├── profile_loader.rs # Profile YAML loader with validation
├── secrets_loader.rs # Secrets file loader with path resolution
└── modules/
├── mod.rs # Module collection aggregator
├── agent.rs # Agent module definition
├── ai.rs # AI service module definition
├── analytics.rs # Analytics module definition
├── api.rs # API gateway module definition
├── content.rs # Content management module definition
├── database.rs # Database module definition
├── files.rs # File management module definition
├── log.rs # Logging module definition
├── mcp.rs # MCP service module definition
├── oauth.rs # OAuth module definition
├── scheduler.rs # Scheduler module definition
└── users.rs # Users module definition
Module Overview
Core Loaders
| Module | Purpose |
|---|---|
ProfileLoader |
Loads and validates profile YAML files from the profiles directory |
SecretsLoader |
Loads secrets files with support for ~/ home directory expansion |
ConfigLoader |
Loads services configuration with include file merging |
EnhancedConfigLoader |
Extended config loader with agent discovery and include resolution |
ModuleLoader |
Aggregates all module definitions for database schema management |
Extension Support
| Module | Purpose |
|---|---|
ExtensionLoader |
Discovers extensions by scanning for manifest.yaml files |
ExtensionRegistry |
Runtime registry mapping binary names to extension metadata |
IncludeResolver |
Resolves !include directives in YAML configuration |
ConfigWriter |
Creates, updates, and deletes agent configuration files |
Module Definitions
The modules/ directory contains definitions for each systemprompt.io module. Each definition specifies:
- Module metadata (name, version, description)
- Database schemas with required columns
- Seed data for initial setup
- API configuration
- Module dependencies and load order (weight)
Usage
use ;
let config = load?;
let profile = load_and_validate?;
let secrets = resolve_and_load?;
let modules = all;
let extensions = discover;
Dependencies
anyhow- Error handlingthiserror- Error type definitionsserde/serde_yaml/serde_json- Serializationtokio- Async runtimetracing- Loggingsystemprompt-models- Shared model types
Installation
Add to your Cargo.toml:
[]
= "0.0.1"
License
FSL-1.1-ALv2 - See LICENSE for details.