Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/second-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Another Example Document

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
# Another Example Document
# Another Example Document

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
# Another Example Document
# Another Example Document


This document is written to show various issues that can be found by a linter.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
This document is written to show various issues that can be found by a linter.
This document is written to show various issues that can be found by a linter.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
This document is written to show various issues that can be found by a linter.
"You write this document to show various issues that can be found by a linter."


## Introduction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Introduction
## Introduction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Introduction
## Introduction

The system is designed to be used by all users. It is important that the instructions are followed carefully.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
The system is designed to be used by all users. It is important that the instructions are followed carefully.
The system is designed to be used by all users. It is important that the instructions are followed carefully.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
The system is designed to be used by all users. It is important that the instructions are followed carefully.
"You should design the system to be used by all users. It is important that you follow the instructions carefully."


## Setup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Setup
## Setup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Setup
## Setup

The configuration file is located in the root directory. It is necessary to open it and modify the settings. The server must be restarted after changes are made.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
The configuration file is located in the root directory. It is necessary to open it and modify the settings. The server must be restarted after changes are made.
The configuration file is located in the root directory. It is necessary to open it and modify the settings. The server must be restarted after changes are made.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
The configuration file is located in the root directory. It is necessary to open it and modify the settings. The server must be restarted after changes are made.
"You locate the configuration file in the root directory. You need to open it and modify the settings. You must restart the server after making changes."


### Steps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
### Steps
### Steps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
### Steps
### Steps

1. The repository is cloned.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
1. The repository is cloned.
1. The repository is cloned.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
1. The repository is cloned.
"You cloned the repository."

2. Dependencies are installed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
2. Dependencies are installed.
2. Dependencies are installed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
2. Dependencies are installed.
"You installed the dependencies."

3. The database is set up.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
3. The database is set up.
3. The database is set up.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
3. The database is set up.
"You set up the database."


> **Note:** The database should be backed up regularly.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
> **Note:** The database should be backed up regularly.
> **Note:** The database should be backed up regularly.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
> **Note:** The database should be backed up regularly.
> **Note:** The database should be backed up regularly.


## Troubleshooting

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Troubleshooting
## Troubleshooting

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Troubleshooting
## Troubleshooting

Errors are logged to `/var/log/app.log`. "Permission Denied" errors are often caused by incorrect file permissions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Errors are logged to `/var/log/app.log`. "Permission Denied" errors are often caused by incorrect file permissions.
Errors are logged to `/var/log/app.log`. "Permission Denied" errors are often caused by incorrect file permissions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Errors are logged to `/var/log/app.log`. "Permission Denied" errors are often caused by incorrect file permissions.
"You log errors to `/var/log/app.log`. You often cause "Permission Denied" errors by incorrect file permissions."


[Click here for more help](#support)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
[Click here for more help](#support)
[Click here for more help](#support)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
[Click here for more help](#support)
`[You can click here for more help](#support)`

28 changes: 28 additions & 0 deletions docs/third-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Deployment Guidelines

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
# Deployment Guidelines
# Deployment Guidelines

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
# Deployment Guidelines
# Deployment Guidelines


This document outlines how the application is deployed to production.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
This document outlines how the application is deployed to production.
This document outlines how the application is deployed to production.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
This document outlines how the application is deployed to production.
"You deploy the application to production as outlined in this document."


## Prerequisites

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Prerequisites
## Prerequisites

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Prerequisites
## Prerequisites


Before the installation is started, the following requirements must be met:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Before the installation is started, the following requirements must be met:
Before the installation is started, the following requirements must be met:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Before the installation is started, the following requirements must be met:
"Before you start the installation, you must meet the following requirements:"


Node.js: It is required that Node.js v18 is installed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Node.js: It is required that Node.js v18 is installed.
Node.js: It is required that Node.js v18 is installed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Node.js: It is required that Node.js v18 is installed.
"You must install Node.js v18."


Database: A PostgreSQL instance must be provisioned by the infrastructure team.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Database: A PostgreSQL instance must be provisioned by the infrastructure team.
Database: A PostgreSQL instance must be provisioned by the infrastructure team.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Database: A PostgreSQL instance must be provisioned by the infrastructure team.
"You must provision a PostgreSQL instance by the infrastructure team."


Permissions: Root access is needed for the initial setup.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Permissions: Root access is needed for the initial setup.
Permissions: Root access is needed for the initial setup.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Permissions: Root access is needed for the initial setup.
"You need root access for the initial setup."


## Installation Steps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Installation Steps
## Installation Steps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Installation Steps
## Installation Steps


The repository can be cloned using the standard Git command.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
The repository can be cloned using the standard Git command.
The repository can be cloned using the standard Git command.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
The repository can be cloned using the standard Git command.
You can clone the repository using the standard Git command.

Once the files are downloaded, the dependencies are installed by running npm install.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Once the files are downloaded, the dependencies are installed by running npm install.
Once the files are downloaded, the dependencies are installed by running npm install.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Once the files are downloaded, the dependencies are installed by running npm install.
"Once you download the files, you install the dependencies by running npm install."


. Note: The environment variables must be configured before the application is started.
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line begins with a period followed by a space, which appears to be a typo. Should start with 'Note:' instead of '. Note:'.

Suggested change
. Note: The environment variables must be configured before the application is started.
Note: The environment variables must be configured before the application is started.

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
. Note: The environment variables must be configured before the application is started.
. Note: The environment variables must be configured before the application is started.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
. Note: The environment variables must be configured before the application is started.
"You must configure the environment variables before starting the application."


## Configuration

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Configuration
## Configuration

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
## Configuration
## Configuration


The configuration file config.yaml is found in the root directory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
The configuration file config.yaml is found in the root directory.
The configuration file config.yaml is found in the root directory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
The configuration file config.yaml is found in the root directory.
You find the configuration file config.yaml in the root directory.

Changes can be made to this file to adjust the port settings.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Changes can be made to this file to adjust the port settings.
Changes can be made to this file to adjust the port settings.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
Changes can be made to this file to adjust the port settings.
"You can make changes to this file to adjust the port settings."

If an error is encountered, the logs should be checked immediately.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
If an error is encountered, the logs should be checked immediately.
If an error is encountered, the logs should be checked immediately.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
If an error is encountered, the logs should be checked immediately.
"If an error is encountered, you should check the logs immediately."


[Click here for more details]()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestão de Voz Ativa (AI) 🤖

Suggested change
[Click here for more details]()
`Click here for more details`

84 changes: 38 additions & 46 deletions scripts/revisor_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,134 +2,126 @@
import sys
import anthropic
from github import Github
from github import Auth

def corrigir_frase(texto_original, client_anthropic):
"""
Envia a frase para o Claude para verificar voz passiva.
Retorna o texto corrigido ou o original se não houver mudança.
Envia a frase para o Claude. Retorna o texto original se der erro ou se não houver mudança.
"""
# Ignora linhas muito curtas, títulos, blocos de código ou itens de lista simples
if len(texto_original.strip()) < 10 or texto_original.strip().startswith(('#', '```', '![', '<')):
# Ignora linhas curtas, títulos, ou linhas que parecem código/comentários
if len(texto_original.strip()) < 10 or texto_original.strip().startswith(('#', '```', '![', '<', '>', '-')):
return texto_original

prompt = f"""
Atue como um Editor Técnico (Technical Writer).
Analise a frase abaixo. Se ela estiver na VOZ PASSIVA, reescreva para VOZ ATIVA.
Assuma que o sujeito é "you" (o usuário/leitor) se estiver oculto.
Atue como um Editor Técnico. Analise a frase abaixo.
Se estiver na VOZ PASSIVA, reescreva para VOZ ATIVA (assuma "you" como sujeito).

Regras CRÍTICAS:
1. Se a frase já estiver na voz ativa, retorne EXATAMENTE o texto original, sem mudar nada.
2. Se mudar, retorne APENAS o novo texto corrigido.
3. Mantenha a formatação Markdown (negrito, itálico, links) INTACTA.
Regras:
1. Se já estiver na voz ativa, retorne EXATAMENTE o texto original.
2. Mantenha formatação Markdown.
3. NÃO explique, apenas retorne o texto.

Frase: "{texto_original.strip()}"
"""

try:
# MUDANÇA: Usando Claude 3 Haiku (versão estável e universalmente disponível)
message = client_anthropic.messages.create(
model="claude-3-5-sonnet-latest",
model="claude-3-haiku-20240307",
max_tokens=300,
temperature=0,
messages=[{"role": "user", "content": prompt}]
)
texto_novo = message.content[0].text.strip()

# Validação extra: se o texto for igual, retorna original
# Se a IA devolver o mesmo texto (ou vazio), ignoramos
if texto_novo == texto_original.strip():
return texto_original

return texto_novo
except Exception as e:
print(f"⚠️ Erro ao consultar Claude: {e}")
# Se der erro na API, apenas logamos e seguimos sem quebrar o script
print(f"⚠️ [Claude API Error] Linha ignorada: {e}")
return texto_original

def main():
# 1. Validar Variáveis de Ambiente
github_token = os.getenv("GITHUB_TOKEN")
anthropic_key = os.getenv("ANTHROPIC_API_KEY")
repo_name = os.getenv("GITHUB_REPOSITORY")
pr_number = os.getenv("PR_NUMBER")

# O arquivo vem como argumento do comando python
if len(sys.argv) < 2:
print("❌ Erro: Caminho do arquivo não fornecido.")
sys.exit(1)

arquivo_path = sys.argv[1]

if not (github_token and anthropic_key and repo_name and pr_number):
print("❌ Erro: Variáveis de ambiente faltando (GITHUB_TOKEN, ANTHROPIC_API_KEY, PR_NUMBER).")
print("❌ Erro: Variáveis de ambiente faltando.")
sys.exit(1)

print(f"🔍 Iniciando análise de: {arquivo_path}")

# 2. Inicializar Clientes
# Autenticação robusta
auth = Auth.Token(github_token)
gh = Github(auth=auth)

try:
gh = Github(github_token)
repo = gh.get_repo(repo_name)
pr = repo.get_pull(int(pr_number))
claude = anthropic.Anthropic(api_key=anthropic_key)

# Pega o último commit para atrelar o comentário a ele
# Isso garante que o comentário apareça na versão atual do PR
# Pega o último commit para comentar na versão correta do PR
commits = list(pr.get_commits())
last_commit = commits[-1]
except Exception as e:
print(f"❌ Erro ao conectar com GitHub: {e}")
print(f"❌ Erro ao conectar GitHub: {e}")
sys.exit(1)

# 3. Ler o arquivo
try:
with open(arquivo_path, 'r', encoding='utf-8') as f:
linhas = f.readlines()
except FileNotFoundError:
print(f"❌ Arquivo não encontrado no disco: {arquivo_path}")
print(f"❌ Arquivo local não encontrado: {arquivo_path}")
sys.exit(1)

# 4. Processar Linha a Linha
sugestoes_feitas = 0
sugestoes = 0

for i, linha in enumerate(linhas):
linha_limpa = linha.strip()

# Pula linhas vazias
if not linha_limpa:
if not linha_limpa:
continue

novo_texto = corrigir_frase(linha, claude)

# Se houve correção
# Só comentamos se houver diferença REAL
if novo_texto != linha_limpa:
print(f"💡 Sugestão na linha {i+1}:")
print(f"💡 Sugestão Linha {i+1}:")
print(f" 🔴 {linha_limpa}")
print(f" 🟢 {novo_texto}")

body_suggestion = f"""
body = f"""
**Sugestão de Voz Ativa (AI)** 🤖

```suggestion
{novo_texto}
```
"""
try:
# Tenta postar o comentário na linha específica
# create_review_comment exige commit_id, path e line (ou position)
# Usa 'commit' em vez de 'commit_id'
pr.create_review_comment(
body=body_suggestion,
commit_id=last_commit,
body=body,
commit=last_commit,
path=arquivo_path,
line=i + 1 # GitHub lines são 1-based
line=i + 1
)
sugestoes_feitas += 1
sugestoes += 1
print(" ✅ Comentário postado.")
except Exception as e:
# O GitHub só permite comentar em linhas que foram alteradas no PR (no diff).
# Se a linha não faz parte do diff, ele retorna erro. Isso é normal.
print(f"⚠️ Pulei a linha {i+1} (provavelmente não foi alterada neste PR): {e}")
print(f" ⚠️ Não postado (Linha não alterada no PR ou erro API): {e}")

if sugestoes_feitas == 0:
print("✅ Nenhuma correção aplicável encontrada nas linhas alteradas.")
if sugestoes == 0:
print("✅ Nenhuma sugestão necessária.")
else:
print(f"🚀 {sugestoes_feitas} comentários postados com sucesso!")
print(f"🚀 {sugestoes} sugestões enviadas para o PR!")

if __name__ == "__main__":
main()