- Source:
src/sqlsaber/cli/: CLI entry (saber,sqlsaber), REPL, prompts.agents/: agent implementations (pydantic‑ai).tools/: SQL, introspection, registry.database/: connection, resolver, schema utilities.memory/,conversation/: state and persistence.config/: settings, API keys, DB configs.
- Tests:
tests/mirror modules (test_cli/,test_tools/, …). - Docs & assets:
docs/,sqlsaber.gif,sqlsaber.svg.
- Install (editable):
uv sync - Lint:
uv run ruff check . - Type check (all):
uvx ty check src/ - Type check (targeted):
uvx ty check <file> - Format:
uv run ruff format . - Tests (all):
uv run pytest -q - Tests (targeted):
uv run pytest tests/test_tools -q - Run CLI (dev):
uv run saberoruv run python -m sqlsaber
Note: Prefer uv run ruff ... over uvx ruff ... to avoid hitting user-level uv caches that may be restricted in sandboxed environments.
- CLI startup must stay fast (<0.5s for
--help). Avoid eager imports of heavy modules (pydantic_ai,google.genai,openai, etc.) at module load time. - Use lazy
__getattr__imports in__init__.pyfiles for heavy exports (seesqlsaber/__init__.pyandsqlsaber/config/__init__.py). - CLI command modules should defer heavy imports to inside command functions, not at module top-level.
- Test with
time uv run saber --helpbefore merging changes that touch imports.
- Python 3.12+, 4‑space indent, strictly use modern (3.12+) type hints approach.
- Type check must pass without errors always.
- Ruff is the linter/formatter; code must be clean and formatted.
- Naming: modules/files
snake_case.py; classesPascalCase; functions/varssnake_case; constantsUPPER_SNAKE. - Keep public CLI surfaces in
cli/; factor reusable logic into modules undersqlsaber/.
- Framework:
pytestwithpytest-asyncio. - Place tests under
tests/, name filestest_*.pyand mirror package layout. - Include tests for new behavior and bug fixes; prefer async tests for async code.
- Use fixtures from
tests/conftest.pywhere possible. - Tests must pass without errors always.
- Cloud Agent VMs export
FORCE_COLOR=0, which Rich treats as "force terminal" and flips the display-detection tests (tests/test_tools/test_display.py, and table/markdown rendering assertions elsewhere) into the wrong branch. Run the suite the way CI does, without that variable:env -u FORCE_COLOR uv run python -m pytest. GitHub Actions does not setFORCE_COLOR, so CI is unaffected.