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.2.0.tar.gz (40.6 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.2.0-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for airev-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f98c8f1de11e928eff5155f7ce7382a4faa35cff0f3c352af43b5a93fa5583eb
MD5 d6b9c2fdefa159ec035f7a8b7bf27b9a
BLAKE2b-256 a7aa8f15e5c4b21a4253b6e441b6cdc6e7f2b8010bdc93c5333f03bbd4b2b2be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: airev-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 36.8 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 187e2a7fafbe81f95b99f8498cdda6be719e7dee119c82575986ae9bb9de9f54
MD5 45093badca4e222ea12b0dfe1c00f399
BLAKE2b-256 aeecfab08cebf7eda3639e184d55368524c46b5c6c20503c4d3a383408582035

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