Euxis Library Architecture (core/lib/)¶
Overview¶
Euxis v0.0.20 modularized the monolithic euxis.sh (~940 lines) into 6 focused library modules under core/lib/. The main script (euxis-bin/euxis.sh) retains only bootstrapping, routing, and top-level orchestration (~400 lines). Each library owns a single domain and can be sourced independently by other scripts.
Modules¶
Module |
Domain |
Key Functions |
|---|---|---|
|
Logging, UI & Perf |
|
|
Provider routing |
|
|
Agent discovery, lifecycle & plugins |
|
|
Tiered memory, pruning & drift |
|
|
Project/session |
|
|
Variable substitution |
|
|
Auto-detection |
|
|
Prompt assembly |
|
Code Metrics¶
The framework core consists of:
8 library modules in
core/lib/(~870 LOC)1 main entry point
euxis-bin/euxis.sh(~400 LOC)20+ CLI tools in
euxis-bin/(dispatch, loop, council, bench, lint, etc.)6 test files in
tests/(E2E, concurrency, integration)11 validation patterns in
config/patterns/35 agent prompts in
agents/prompts/core/andagents/prompts/fleet/11 protocol files in
agents/prompts/protocols/6 templates in
config/templates/6 ADRs in
docs/adr/
Note: .venv-voice/ contains a Python virtualenv for the voice interface feature. These ~17K files are third-party dependencies, not framework code. They are excluded via .euxisignore and should not be counted in framework metrics.
Include Guard Pattern¶
Every lib file uses a guard to prevent double-sourcing:
#!/usr/bin/env bash
[[ -n "${_EUXIS_LIB_<NAME>:-}" ]] && return; _EUXIS_LIB_<NAME>=1
EUXIS_HOME="${EUXIS_HOME:-${HOME}/.euxis}"
This ensures:
Safe to source the same lib multiple times (idempotent)
EUXIS_HOMEalways has a sane default regardless of load orderNo duplicate function definitions or variable resets
Dependency Graph¶
euxis.sh
├── lib/common.sh (no dependencies)
├── lib/providers.sh → lib/common.sh
├── lib/agents.sh (no dependencies)
├── lib/memory.sh (no dependencies)
├── lib/session.sh (no dependencies)
├── lib/template.sh (no dependencies)
├── lib/skill-detector.sh (no dependencies)
└── lib/prompt.sh → lib/agents.sh, lib/memory.sh, lib/template.sh
Internal dependencies are resolved via EUXIS_HOME:
source "${EUXIS_HOME}/euxis-bin/lib/common.sh"
How euxis.sh Sources Libraries¶
EUXIS_HOME="${HOME}/.euxis"
source "${EUXIS_HOME}/euxis-bin/lib/common.sh"
source "${EUXIS_HOME}/euxis-bin/lib/providers.sh"
# ... etc
All paths are anchored to EUXIS_HOME for portability. This works correctly whether euxis is invoked via ~/.euxis/euxis-bin/euxis.sh, a hardlink at ~/.euxis/euxis-bin/euxis, or any other location.
Extension Guidelines¶
Adding a New Library Module¶
Create
core/lib/<name>.shwith the guard pattern:#!/usr/bin/env bash [[ -n "${_EUXIS_LIB_<NAME>:-}" ]] && return; _EUXIS_LIB_<NAME>=1 EUXIS_HOME="${EUXIS_HOME:-${HOME}/.euxis}"
Source any dependencies at the top:
source "${EUXIS_HOME}/euxis-bin/lib/common.sh"
Add a
sourceline ineuxis-bin/euxis.sh(after existing sources).Set permissions:
chmod 755 core/lib/<name>.shRun
bash -n euxis-bin/euxis.shto verify syntax.
Rules¶
One domain per module. Don’t add provider logic to
memory.sh.No circular dependencies. If A sources B, B must not source A.
Always use the guard. Other scripts (dispatch, loop, combo) may source the same libs.
Keep the interface stable. Function signatures are the API — changing them breaks callers.
Export nothing. Libraries define functions, not exported variables. Callers set their own state.
Euxis v0.0.20 · Build something that matters.