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.8.0.tar.gz (52.3 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.8.0-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for airev-1.8.0.tar.gz
Algorithm Hash digest
SHA256 d92c70ac0bc4b517262e0c5416c9b5a4e79f0a6af326a93875bde64a5cc59b9d
MD5 4006ac4d2dc7b878da65e04a47fc0a44
BLAKE2b-256 7eed1ef1467d7e9387bb0f1775cd28a5005df4cc8ad0c0ffa0c260d1e08947fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: airev-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 45.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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d3dee2de91400d4e934670256f13d13ec2874ac045fc93b9a9a84aad7dc623a
MD5 6a747e44d4e2a2ec9a4170aa4f1eb7cc
BLAKE2b-256 019a7b1992c9b3ea24d64734e9be327fd30677a583f69bce03821b6d617c68f5

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