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.3.0.tar.gz (42.2 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.3.0-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for airev-1.3.0.tar.gz
Algorithm Hash digest
SHA256 3adb3096b1b346cf3f55d64814618581c76bb11fe68f7dc0553b7bd8127e1fd9
MD5 ded9b8ce4c7ec16039a3773794b27173
BLAKE2b-256 a85139feb3b21ef406a96c7f8688d965f755b31989d3f89b65ab3f493bd5311b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: airev-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 38.1 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 650e9c3ead84a9293ac80772f397070b58134fb955aaee085bc4f427165bb4fc
MD5 d07f324d0ce8be3014a709dd59f8c4ce
BLAKE2b-256 65f96b3c41f17dcc72b5e87eeb8b25886939625a078763b642fb0ae3414afeb4

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