Skip to main content

CLI tool for AI-powered code review with context backtracking

Project description

airev

CLI para revisão de código automatizada com IA. Analisa diffs de branches Git e identifica problemas de segurança, performance, bugs e vazamentos de recursos.

Funcionalidades

  • Análise de diff inteligente: Compara sua branch com a branch base e analisa apenas o código modificado
  • Context backtracking: Identifica automaticamente funções que chamam ou são chamadas pelo código modificado
  • Múltiplos runners de IA: Suporte a Gemini CLI e GitHub Copilot CLI
  • Output estruturado: Resultados em terminal colorido ou JSON para integração com CI/CD
  • Internacionalização: Suporte a português (pt-br) e inglês (en)
  • Categorização de findings: Severidade (CRITICAL, WARNING, INFO) e categoria (security, performance, bug, resource-leak)

Instalação

Requisitos

Via pipx (Recomendado)

# Instala o pipx se ainda não tiver
pip install pipx
pipx ensurepath

# Instala o airev
pipx install airev

Via pip

pip install airev

Desenvolvimento local

# Clone o repositório
git clone https://github.com/tarcisiojr/airev.git
cd airev

# Instala em modo desenvolvimento
pip install -e ".[dev]"

Atualização

O airev verifica automaticamente por novas versões e notifica quando há atualizações disponíveis.

# Atualiza para a versão mais recente
airev upgrade

# Ou manualmente
pipx upgrade airev
# ou
pip install --upgrade airev

Para desabilitar a verificação automática:

export AIREV_NO_UPDATE_CHECK=1

Uso

Comando básico

# Analisa a branch atual contra main
airev review --base main

# Analisa contra develop usando Copilot
airev review --base develop --runner copilot

# Output em JSON para CI/CD
airev review --base main --json-output

# Modo silencioso (sem animações)
airev review --base main --no-progress

# Em inglês
airev review --base main --lang en

Opções do comando review

Opção Descrição
--base, -b Branch base para comparação (obrigatório)
--runner, -r Runner de IA: gemini (padrão) ou copilot
--json-output, -j Retorna resultado em JSON
--workdir, -w Diretório do repositório (padrão: atual)
--no-progress Desabilita animações (modo CI)
--progress Força animações mesmo em CI
--lang, -l Idioma: pt-br (padrão) ou en

Listar runners disponíveis

airev runners

Runners de IA

Gemini CLI (padrão)

Instale o Gemini CLI:

npm install -g @anthropic/gemini-cli
# ou
brew install gemini-cli

GitHub Copilot CLI

Instale o Copilot CLI standalone:

npm install -g @github/copilot-cli
# ou
brew install github/gh/copilot-cli
# ou
winget install GitHub.CopilotCLI

Output

Terminal

O output no terminal inclui:

  • Lista de arquivos modificados com estatísticas de linhas
  • Dependências identificadas (callers/callees)
  • Findings categorizados por severidade com cores
  • Resumo final com contagem por tipo

JSON

Com --json-output, o resultado segue a estrutura:

{
  "branch": "feature/x",
  "base": "main",
  "files_analyzed": 5,
  "findings": [
    {
      "file": "src/auth.py",
      "line": 42,
      "severity": "CRITICAL",
      "category": "security",
      "title": "SQL Injection",
      "description": "Query concatenada sem sanitização",
      "suggestion": "Use prepared statements"
    }
  ],
  "summary": {
    "total": 3,
    "critical": 1,
    "warning": 2,
    "info": 0
  }
}

Integração com CI/CD

GitHub Actions

- name: Code Review
  run: |
    pip install airev
    airev review --base main --no-progress --json-output > review.json

- name: Check Critical Findings
  run: |
    CRITICAL=$(jq '.summary.critical' review.json)
    if [ "$CRITICAL" -gt 0 ]; then
      echo "Found $CRITICAL critical issues!"
      exit 1
    fi

Desenvolvimento

Executar testes

pytest

Executar com cobertura

pytest --cov=code_reviewer

Verificar código

python -m py_compile src/code_reviewer/*.py

Arquitetura

src/code_reviewer/
├── cli.py              # Entry point e comandos Click
├── diff_parser.py      # Parser de git diff
├── context_builder.py  # Backtracking de dependências
├── prompt_builder.py   # Construção do prompt para IA
├── response_parser.py  # Parser da resposta da IA
├── models.py           # Modelos Pydantic
├── formatters/
│   ├── terminal.py     # Formatação colorida com rich
│   └── progress.py     # Reporter de progresso
├── runners/
│   ├── base.py         # Interface AIRunner
│   ├── gemini.py       # Runner Gemini CLI
│   └── copilot.py      # Runner Copilot CLI
├── i18n/               # Sistema de internacionalização
├── locales/            # Arquivos de tradução (YAML)
└── prompts/            # Templates de prompt

Licença

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airev-1.9.0.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

airev-1.9.0-py3-none-any.whl (45.4 kB view details)

Uploaded Python 3

File details

Details for the file airev-1.9.0.tar.gz.

File metadata

  • Download URL: airev-1.9.0.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for airev-1.9.0.tar.gz
Algorithm Hash digest
SHA256 1b127400da860a4c87aaabd68b23bdeeedd844a81ee2275995bd9d952d8f1f05
MD5 5834415bca359a8a5acec3fd7318c722
BLAKE2b-256 8e07c5642acfb775a46eb8fb9676252d97f4c0d200728f1c93e79076291d292d

See more details on using hashes here.

File details

Details for the file airev-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: airev-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 45.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for airev-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4758fd6af0bbd3b23ef1272a452f8afbdcc94e9e7f78561c6db4e0a1c4b6f94e
MD5 5ab2639622d90487e7b117facdba996a
BLAKE2b-256 29cfc3385584863a92d1cfd970ac3de3e1d47499dcae834857feac28f9f0fad9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page