Implement CYA-WP-0008 llm-connect adapter integration.

Wire LLMConnectAdapter behind the existing LLMAdapter seam with config-driven
selection, graceful degradation, --offline mode, and bounded session context.
Add unit tests, integration docs, and update README/SCOPE/AGENTS.
This commit is contained in:
2026-06-22 10:36:10 +02:00
parent cd5db14fbf
commit 019f6e7dc7
17 changed files with 800 additions and 19 deletions

View File

@@ -16,7 +16,7 @@ usable after `pip install -e .`:
- `cya "your request in plain English"`
- `cya --explain-context "..."` — shows exactly what local context would be sent
- Automatic rule-based risk classification with mandatory confirmation for anything destructive, privileged, mass-edit, or network-affecting
- All LLM interaction flows through a documented `LLMAdapter` seam (currently a deterministic fake; ready for real `llm-connect`)
- All LLM interaction flows through a documented `LLMAdapter` seam (`FakeLLMAdapter` by default; real `llm-connect` when configured)
## Installation
@@ -58,6 +58,41 @@ git pull
make dev-install
```
## LLM backend (configured vs offline)
By default `cya` uses a deterministic **offline** adapter (no API keys, no network).
For real inference, configure llm-connect:
```bash
# 1. Install llm-connect (sibling checkout)
pip install -e ~/llm-connect
# 2. Route credentials — do not commit keys
warden route find "OpenRouter API key" --json
# 3. Export key and configure cya
export OPENROUTER_API_KEY="..." # from OpenBao / operator path
mkdir -p ~/.config/cya
cat > ~/.config/cya/config.toml <<'EOF'
[llm]
adapter = "connect"
backend = "openrouter"
model = "anthropic/claude-sonnet-4"
EOF
cya "show me the recent git history for this repo"
```
Force offline mode anytime (tests, CI, air-gapped):
```bash
cya --offline "your request"
# or: CYA_LLM_ADAPTER=fake cya "..."
```
See `docs/llm-connect-integration.md` for the full mapping, session context budget,
and optional `.cya.toml` project overrides.
## Usage examples
```bash
@@ -190,9 +225,11 @@ decisions, and integration guide.
```bash
# Recommended one-liner (see Installation section above)
make dev-install
pip install -e ~/llm-connect # optional, for live inference
pytest tests/ -q
cya "..." # manual verification
pytest tests/ -q # offline mocks only; no API keys
pytest -m llm_live # manual live check (requires OPENROUTER_API_KEY)
cya --offline "..." # manual verification without network
make version # show current dev version
```