ai-sql-reviewer
CLI-инструмент для schema-aware ревью изменённых PostgreSQL-запросов в CI.
Возможности
- Извлекает изменённые statements из Git diff и сохраняет номера строк.
- Проверяет синтаксис через SQLGlot до любых модельных вызовов.
- Восстанавливает схему миграциями во временном PostgreSQL-контейнере.
- Запускает независимые performance, architecture и correctness reviews, critic и final reviewer.
- Валидирует все ответы Pydantic-моделями и показывает безопасные предложения как diff.
- Поддерживает console, Markdown и JSON; исходные SQL-файлы не изменяет.
Требования
Python 3.12+, uv, Docker и доступный из shell migration command.
Установка
uv tool install ai-sql-reviewer==0.1.0
Конфигурация
dialect: postgres
migrations:
command: ./scripts/migrate.sh
postgres_version: "17"
timeout_seconds: 120
llm:
model: openai/example-model
api_key_env: OPENAI_API_KEY
api_base: null
temperature: 0
timeout_seconds: 60
max_retries: 2
review:
agents: [performance, architecture, correctness]
minimum_confidence: 0.65
max_findings: 10
output:
format: markdown
Секрет хранится только в environment variable, имя которой задаёт api_key_env.
CLI
ai-sql-review review-diff --base origin/main --head HEAD --format markdown
ai-sql-review review-file path/to/query.sql --format console
ai-sql-review review-sql "SELECT * FROM users" --format json
--debug включает технические сообщения orchestration и parser без публикации внутренних model responses.
GitHub Actions
- uses: astral-sh/setup-uv@v9.0.0
- env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: uvx --from ai-sql-reviewer==0.1.0 ai-sql-review review-diff --base "${{ github.event.pull_request.base.sha }}" --head "${{ github.sha }}" --format markdown
Полный пример: examples/github-actions/sql-review.yml.
Ограничения MVP
- Поддерживается только PostgreSQL и миграции, запускаемые одной shell-командой.
- Нет GitHub App, публикации PR-комментариев, query-plan execution и автоматического применения fixes.
- Качество выводов зависит от выбранной через LiteLLM модели и предоставленной схемы.
Разработка
uv sync
uv run ruff check .
uv run mypy src
uv build
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_sql_reviewer-0.1.1.tar.gz.
File metadata
- Download URL: ai_sql_reviewer-0.1.1.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e1eb818c4a20ee0242f52b68cbbdb7f8d19b53e1215784dfb15d365b693f6ed
|
|
| MD5 |
353cb17e67533687a0f8a06942f596d2
|
|
| BLAKE2b-256 |
87fee0e61157fc36ac76051b884247a273f3970b287ddf029f14d15d92dc22e2
|
Provenance
The following attestation bundles were made for ai_sql_reviewer-0.1.1.tar.gz:
Publisher:
release.yml on not2exe/ai-sql-reviewer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_sql_reviewer-0.1.1.tar.gz -
Subject digest:
0e1eb818c4a20ee0242f52b68cbbdb7f8d19b53e1215784dfb15d365b693f6ed - Sigstore transparency entry: 2334790090
- Sigstore integration time:
-
Permalink:
not2exe/ai-sql-reviewer@638b8c8766fd77e75c2685fd6d4ba35ec1bb339b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/not2exe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@638b8c8766fd77e75c2685fd6d4ba35ec1bb339b -
Trigger Event:
push
-
Statement type:
File details
Details for the file ai_sql_reviewer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ai_sql_reviewer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e05bf84c1349d7122a543e33b399f091add055e5a7a50f92d45c706645b0752
|
|
| MD5 |
aca60b829b9f608f52838137c5571955
|
|
| BLAKE2b-256 |
79f85d74e979c594063a73163689c75f1013aed1e9f4ea75ae63512c93d4e584
|
Provenance
The following attestation bundles were made for ai_sql_reviewer-0.1.1-py3-none-any.whl:
Publisher:
release.yml on not2exe/ai-sql-reviewer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_sql_reviewer-0.1.1-py3-none-any.whl -
Subject digest:
4e05bf84c1349d7122a543e33b399f091add055e5a7a50f92d45c706645b0752 - Sigstore transparency entry: 2334790140
- Sigstore integration time:
-
Permalink:
not2exe/ai-sql-reviewer@638b8c8766fd77e75c2685fd6d4ba35ec1bb339b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/not2exe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@638b8c8766fd77e75c2685fd6d4ba35ec1bb339b -
Trigger Event:
push
-
Statement type: