Development
Repository layout, environment setup, and the test/lint/typecheck commands used across the Kazma monorepo.
1. Repository layout
Section titled “1. Repository layout”kazma/├── kazma-core/ # Agent runner, LLM provider, swarm, ConfigStore, safety, memory, skills, MCP, hub├── kazma-gateway/ # Telegram/Discord/Slack adapters, agent_handler package, slash commands├── kazma-ui/ # FastAPI app, SSE chat, swarm panel, settings, i18n, static assets├── kazma-tui/ # Textual TUI dashboard├── kazma-memory/ # Arabic tokenizer + SQLite/FTS5 search backend├── kazma-skills/ # Skill manifests (data)├── kazma-cli/ # The `kazma` command surface├── docs/ # Existing Docusaurus site (v3.4)├── docs-v2/ # This rewrite├── tests/ # Cross-cutting tests├── examples/ # Example skills (e.g. almuhalab_custom_skills)├── kubernetes/ # Hub API manifests (see Deployment §4)├── kazma.yaml # Main config├── kazma-permissions.yaml├── kazma-security.yaml├── services.yaml├── pyproject.toml # Single hatchling build for all 7 packages├── Dockerfile # Main agent image├── docker-compose.yml # Main agent compose├── setup.ps1 # Windows bootstrap└── run.sh # Minimal E2E reproduction2. Environment setup
Section titled “2. Environment setup”2.1 Install (editable, all extras)
Section titled “2.1 Install (editable, all extras)”git clone <repo> kazma && cd kazmapython -m venv .venvsource .venv/bin/activate # POSIX# or: .venv\Scripts\activate # Windows
pip install -e ".[rag,dev]"Extras (pyproject.toml:37-71):
| Extra | Contents |
|---|---|
rag | chromadb>=0.5.0, sentence-transformers>=3.0.0 |
dev | pytest, pytest-asyncio, pytest-cov, pytest-mock, ruff, mypy, locust |
test | pytest stack + fakeredis |
tracing | opentelemetry-* exporters/instrumentors |
tui | textual>=8.0.0, python-bidi |
2.2 Windows
Section titled “2.2 Windows”.\setup.ps1 # validates env, syncs venv, runs import check2.3 uv (used by run.sh)
Section titled “2.3 uv (used by run.sh)”uv sync --extra dev --extra cli --extra tui --extra rag3. Code style & conventions
Section titled “3. Code style & conventions”From AGENTS.md:
- Python: type hints, docstrings, logging.
logger = logging.getLogger(__name__)pattern.from __future__ import annotationsfor type hints.- One concern per file; keep modules focused.
- Compile-check Python before committing:
python -c "import py_compile; py_compile.compile(r'<file>', doraise=True); print('OK')" - Syntax-check JS before committing:
node --check "<file>" - PowerShell: never
&&/||; use;and$LASTEXITCODE.
4. Test / lint / typecheck
Section titled “4. Test / lint / typecheck”# Python compile check (fast smoke).venv/Scripts/python.exe -c "import py_compile; py_compile.compile(r'kazma-core/kazma_core/llm_provider.py', doraise=True); print('OK')"
# JS syntax checknode --check "kazma-ui/kazma_ui/static/js/chat.js"
# Run testspython -m pytest kazma-core/tests/ -vpython -m pytest tests/ -v # cross-cuttingpython -m pytest -k majlis -v # specific
# Lintpython -m ruff check kazma-core/kazma_core/python -m ruff check kazma-tui/kazma_tui/ # (per services.yaml)
# Type checkpython -m mypy kazma-tui/kazma_tui/ # (per services.yaml)Per-package commands are also declared in services.yaml:
commands: install: "pip install -e kazma-tui/ -e kazma-core/" test: "python -m pytest kazma-tui/tests/ -v" lint: "python -m ruff check kazma-tui/kazma_tui/" typecheck: "python -m mypy kazma-tui/kazma_tui/"5. The Docusaurus docs site (docs/)
Section titled “5. The Docusaurus docs site (docs/)”The existing docs site is Docusaurus 3.4 (docs/package.json):
kazma docs build # npm install && npm run buildkazma docs serve # npm run start (port 3000)This docs-v2/ tree is content intended to be folded into that site (see the integration note in the audit summary). The Docusaurus sidebars.js and docusaurus.config.js live in docs/.
6. Server lifecycle (development)
Section titled “6. Server lifecycle (development)”Restart the dev server (PowerShell, from AGENTS.md):
Get-Process -Name python -ErrorAction SilentlyContinue | Where-Object { (Get-CimInstance Win32_Process -Filter ('ProcessId=' + $_.Id)).CommandLine -like '*uvicorn*kazma*' } | ForEach-Object { Stop-Process -Id $_.Id -Force }
cd 'G:\GitHubRepos\kazma'& '.venv\Scripts\python.exe' -m uvicorn kazma_ui.app:create_app --factory --host 127.0.0.1 --port 80907. Contributing
Section titled “7. Contributing”See CONTRIBUTING.md (root) for the full guide. Quick rules:
- Branch off
mainfor PRs. - Keep public API signatures stable (the swarm refactor preserved them; do the same).
- Compile/syntax-check before committing.
- Run the relevant test suite.
- Document security implications of any new danger tool or config flag.
Documentation Audit Notes
Section titled “Documentation Audit Notes”- The repo root has many
.pytest_tmp_*directories from prior test runs — git-ignored clutter, safe to clean. services.yamlis scoped tokazma-tuicommands; treat it as an example, not the canonical task runner for all packages.run.shis a minimal end-to-end reproduction (installs, runs the full suite, exercises a live agent, writesEVAL.md) — useful for CI-like validation.