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.1.1.tar.gz (39.1 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.1.1-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for airev-1.1.1.tar.gz
Algorithm Hash digest
SHA256 6844447167eb2f4b90b012a941b897b68e3cb9c8c96532ceb2f883368e186456
MD5 34e686cfaefd6d26d77238ab5c267720
BLAKE2b-256 1fb7af831aa296b364eb3003222441a68f315a48c004f946c3cca5954bbd1efd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: airev-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 35.9 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7bbc9a99770c05bca64808321f10a6df9898dcf45c8d9631589cf4970dbb300
MD5 4b435e4548ed984bdc8bbbb8ab266a76
BLAKE2b-256 090dee59761de3e0280f6df507b51bcd2c83483d203853f4eca76800109400f6

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