Skip to content
This repository was archived by the owner on Oct 20, 2026. It is now read-only.

feat: make CodeGuard provider-agnostic + fix review crash - #1

Merged
aimanmalib merged 5 commits into
mainfrom
feat/provider-agnostic-llm
Jun 5, 2026
Merged

aimanmalib merged 5 commits into
mainfrom
feat/provider-agnostic-llm

Conversation

@aimanmalib

Copy link
Copy Markdown
Owner

What

Makes CodeGuard provider-agnostic — it now runs on any OpenAI-compatible /chat/completions endpoint instead of being locked to one backend. Also fixes a crash in the review command.

Why

The pipeline already spoke the standard OpenAI protocol internally; only the config/client names and auth header were hardcoded. This change exposes that flexibility so users can run on OpenAI, OpenRouter, Ollama, llama.cpp, or Xiaomi MiMo with a single config line.

Changes

  • core/config.py — new generic LLMConfig with PROVIDER_PRESETS (openai/openrouter/ollama/mimo), bearer vs api-key auth styles, env-var resolution. MiMoConfig kept as a backward-compat subclass; CodeGuardConfig.mimo aliases .llm and legacy mimo: YAML blocks still load. Default temperature stays 0.3 for code-review accuracy.
  • core/llm_client.py — LLMClient (renamed from MiMoClient, now provider-agnostic). core/mimo_client.py is a thin re-export shim; MiMoClient remains an importable alias.
  • cli.py bug fix — the review command called _detect_language(), which was never defined, crashing single-file reviews with NameError. Added the helper with an extension→language map.
  • Tests — +17 multi-backend config tests, +5 CLI tests. 49 tests pass (was 27).
  • CI — new .github/workflows/ci.yml: ruff lint + format check + pytest with coverage on Python 3.10/3.11/3.12.
  • Docs — README rebranded with a Supported Providers table + Configuration section; added CONTRIBUTING.md and issue templates.
  • Cleanup — applied ruff format repo-wide.

Backward compatibility

No breaking changes. Existing MIMO_API_KEY / MiMoConfig / MiMoClient / mimo: config usage all continue to work.

Verification

ruff check src/ tests/      # All checks passed!
ruff format --check          # 25 files already formatted
pytest                       # 49 passed

Introduce generic LLMConfig + LLMClient supporting any OpenAI-compatible
endpoint (OpenAI, OpenRouter, Ollama, MiMo, llama.cpp) with bearer or
api-key auth. MiMoConfig/MiMoClient kept as backward-compat aliases.
Default temperature stays 0.3 for code-review accuracy. 27 tests pass.
Cover provider presets (openai/openrouter/ollama/mimo), bearer vs
api-key auth, env resolution, low code-review temperature, and MiMo
backward-compat paths. 44 tests pass.
Reposition from 'MiMo-exclusive' to 'any OpenAI-compatible LLM'.
Add Supported Providers table + Configuration section, update README
header/badges/diagram, CLI help text, pyproject metadata, and package
docstring. MiMo now listed as one provider among many.
The 'review' command called _detect_language() which was never defined,
crashing single-file reviews with NameError. Add the helper with an
extension->language map (+5 tests). Apply ruff format repo-wide so the
format gate passes. 49 tests green, ruff clean.
Add .github/workflows/ci.yml (ruff lint + format check + pytest with
coverage across Python 3.10/3.11/3.12), contributor guide, and bug/
feature issue templates with a chooser config.
@aimanmalib
aimanmalib merged commit e457e80 into main Jun 5, 2026
3 checks passed
@aimanmalib
aimanmalib deleted the feat/provider-agnostic-llm branch June 5, 2026 07:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant