gitpr-cli 0.0.18__py3-none-any.whl → 0.0.20__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gitpr_cli-0.0.18.dist-info → gitpr_cli-0.0.20.dist-info}/METADATA +3 -1
- {gitpr_cli-0.0.18.dist-info → gitpr_cli-0.0.20.dist-info}/RECORD +11 -10
- src/ai_providers.py +59 -47
- src/cache.py +14 -12
- src/core.py +33 -11
- src/spinner.py +177 -0
- src/updater.py +1 -1
- {gitpr_cli-0.0.18.dist-info → gitpr_cli-0.0.20.dist-info}/WHEEL +0 -0
- {gitpr_cli-0.0.18.dist-info → gitpr_cli-0.0.20.dist-info}/entry_points.txt +0 -0
- {gitpr_cli-0.0.18.dist-info → gitpr_cli-0.0.20.dist-info}/licenses/LICENSE +0 -0
- {gitpr_cli-0.0.18.dist-info → gitpr_cli-0.0.20.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitpr-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.20
|
|
4
4
|
Summary: Automação de PRs, Commits e Code Review com IA (Gemini e DeepSeek)
|
|
5
5
|
Author-email: Natan Fiuza <contato@natanfiuza.dev.br>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -12,6 +12,8 @@ Requires-Dist: openai
|
|
|
12
12
|
Requires-Dist: python-dotenv
|
|
13
13
|
Requires-Dist: cryptography
|
|
14
14
|
Requires-Dist: pyyaml
|
|
15
|
+
Requires-Dist: textual
|
|
16
|
+
Requires-Dist: requests
|
|
15
17
|
Dynamic: license-file
|
|
16
18
|
|
|
17
19
|
# **GitPR CLI 🚀**
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
gitpr_cli-0.0.
|
|
1
|
+
gitpr_cli-0.0.20.dist-info/licenses/LICENSE,sha256=UQzLC6mwqb-ZNDkBBAqOxC-SMQcEID0gaM6oFcu6u48,27030
|
|
2
2
|
src/__init__.py,sha256=U6ksarernNcryHO20aj4rNG7w0thT7xdMs5KzBJyPvE,28
|
|
3
|
-
src/ai_providers.py,sha256=
|
|
3
|
+
src/ai_providers.py,sha256=xHRew0GT8sIznm8xJASF9jyPLCPYy4nBQ_QKJ4tuDwg,3227
|
|
4
4
|
src/blame_engine.py,sha256=lLPuuOZSPdJOhKrj00Wko0-i7wzKwngkpPkiSL0nMho,10321
|
|
5
|
-
src/cache.py,sha256=
|
|
5
|
+
src/cache.py,sha256=HguSjONhFbhL3ZanYgHiDL0tYgiax8MFYy0nT-7hzH8,3173
|
|
6
6
|
src/config.py,sha256=BXgHArYWuuaB2GL7NynOuKtEq4kOuTUwApOcy-ApsqM,6775
|
|
7
|
-
src/core.py,sha256=
|
|
7
|
+
src/core.py,sha256=njcO6io6Mu6cVxnBhgl-zzLSe1-8W-FGrldWqYbcRg0,16261
|
|
8
8
|
src/issue_engine.py,sha256=-cDkW7Dxo48kN_aWwGKSymVE-6nJ2bCHZW7GpM3wC00,3637
|
|
9
9
|
src/linter_engine.py,sha256=ppyMje4qQCf9fMRhWOTxsfKvUBcjNoniu7v20kZ0034,4494
|
|
10
10
|
src/main.py,sha256=7bTMdu27EIgq6WUBsC5H26dlejFqSjAz9cQJN7ngjfE,28718
|
|
11
11
|
src/security.py,sha256=_OKBz_R-3xM8-5XNl_dOUyPCQi6jWDeLoOykZvN1Cys,1355
|
|
12
|
+
src/spinner.py,sha256=aF2kforafGNdziud7Og-PRNe-1leE7tkRMXiUW1lxTI,6056
|
|
12
13
|
src/tui_issue.py,sha256=Aiy82hUdz8cs9lnKsxm_bT-GQ-8WDm0VtPdxOoKeOWk,1638
|
|
13
|
-
src/updater.py,sha256=
|
|
14
|
+
src/updater.py,sha256=t5vgevLyqd-8W4WSvwEV8CdU3CKvyQMzX-AO95wvdCk,7024
|
|
14
15
|
src/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
16
|
src/ui/help_screen.py,sha256=0pbCvagLoyzEaghv1xYyIDT2lopeLwcp2un5M7-03PY,1643
|
|
16
17
|
src/ui/issue_app.py,sha256=tZ0mug_kvJIkjrbabFeSsk0ihg64tncFrq78Mbivuuo,4589
|
|
17
|
-
gitpr_cli-0.0.
|
|
18
|
-
gitpr_cli-0.0.
|
|
19
|
-
gitpr_cli-0.0.
|
|
20
|
-
gitpr_cli-0.0.
|
|
21
|
-
gitpr_cli-0.0.
|
|
18
|
+
gitpr_cli-0.0.20.dist-info/METADATA,sha256=NoNZJolb46-np8k4kiIP9nXfUAKyl7Dt5KMyf8j5r34,15689
|
|
19
|
+
gitpr_cli-0.0.20.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
20
|
+
gitpr_cli-0.0.20.dist-info/entry_points.txt,sha256=mh_4F_idM4cj0XhfRGBDQb5Nnku93YJ-dyKh5SufwlE,39
|
|
21
|
+
gitpr_cli-0.0.20.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
|
|
22
|
+
gitpr_cli-0.0.20.dist-info/RECORD,,
|
src/ai_providers.py
CHANGED
|
@@ -3,63 +3,75 @@ import time
|
|
|
3
3
|
import click
|
|
4
4
|
from google import genai
|
|
5
5
|
from openai import OpenAI
|
|
6
|
+
from src.spinner import Spinner
|
|
6
7
|
|
|
7
|
-
def call_ai_model(provider, api_key, api_model, prompt, system_instruction):
|
|
8
|
+
def call_ai_model(provider, api_key, api_model, prompt, system_instruction, quiet=False):
|
|
8
9
|
"""
|
|
9
10
|
Motor unificado para chamadas de IA.
|
|
10
11
|
Suporta 'gemini' e 'deepseek'.
|
|
11
12
|
"""
|
|
12
13
|
max_retries = 3
|
|
13
14
|
retry_delay = 2
|
|
15
|
+
spinner = Spinner(quiet=quiet)
|
|
16
|
+
spinner.start()
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
try:
|
|
19
|
+
for attempt in range(1, max_retries + 1):
|
|
20
|
+
try:
|
|
21
|
+
if provider == "gemini":
|
|
22
|
+
client = genai.Client(api_key=api_key)
|
|
23
|
+
response = client.models.generate_content(
|
|
24
|
+
model=api_model,
|
|
25
|
+
contents=prompt,
|
|
26
|
+
config={
|
|
27
|
+
"system_instruction": system_instruction,
|
|
28
|
+
"response_mime_type": "application/json",
|
|
29
|
+
"temperature": 0.0,
|
|
30
|
+
"top_p": 0.1,
|
|
31
|
+
"top_k": 1
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
result_text = response.text
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
else:
|
|
47
|
-
click.secho(f"❌ Provedor de IA desconhecido: {provider}", fg="red")
|
|
48
|
-
return None
|
|
36
|
+
elif provider == "deepseek":
|
|
37
|
+
# O DeepSeek e 100% compativel com a biblioteca da OpenAI
|
|
38
|
+
client = OpenAI(api_key=api_key, base_url="https://api.deepseek.com")
|
|
39
|
+
response = client.chat.completions.create(
|
|
40
|
+
model=api_model, # Ex: "deepseek-chat"
|
|
41
|
+
messages=[
|
|
42
|
+
{"role": "system", "content": system_instruction},
|
|
43
|
+
{"role": "user", "content": prompt}
|
|
44
|
+
],
|
|
45
|
+
response_format={"type": "json_object"},
|
|
46
|
+
temperature=0.0
|
|
47
|
+
)
|
|
48
|
+
result_text = response.choices[0].message.content
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
else:
|
|
51
|
+
spinner.stop()
|
|
52
|
+
click.secho(f"❌ Provedor de IA desconhecido: {provider}", fg="red")
|
|
53
|
+
return None
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
result_json = result_json[0] if result_json else {}
|
|
55
|
+
# Tenta converter a resposta de texto para um dicionario JSON do Python
|
|
56
|
+
result_json = json.loads(result_text)
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
# 🛡️ ESCUDO: Se a IA retornar uma lista [ { ... } ] por engano
|
|
59
|
+
if isinstance(result_json, list):
|
|
60
|
+
result_json = result_json[0] if result_json else {}
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
spinner.stop()
|
|
63
|
+
return result_json
|
|
64
|
+
|
|
65
|
+
except Exception as e:
|
|
66
|
+
if attempt < max_retries:
|
|
67
|
+
spinner.stop()
|
|
68
|
+
click.secho(f"\r⚠️ Instabilidade na API ({provider.capitalize()}). A tentar novamente ({attempt}/{max_retries})...", fg="yellow", dim=True)
|
|
69
|
+
time.sleep(retry_delay)
|
|
70
|
+
spinner = Spinner(quiet=quiet)
|
|
71
|
+
spinner.start()
|
|
72
|
+
else:
|
|
73
|
+
spinner.stop()
|
|
74
|
+
click.secho(f"\r❌ Erro critico ao contactar a API do {provider.capitalize()} apos {max_retries} tentativas: {str(e)}", fg="red", bold=True)
|
|
75
|
+
return None
|
|
76
|
+
finally:
|
|
77
|
+
spinner.stop()
|
src/cache.py
CHANGED
|
@@ -33,11 +33,13 @@ def save_cached_response(action_folder, action_type, prompt_text, response_dict)
|
|
|
33
33
|
folder_path.mkdir(parents=True, exist_ok=True)
|
|
34
34
|
|
|
35
35
|
cache_file = folder_path / f"{md5_hash}.json"
|
|
36
|
-
from src.core import get_current_branch
|
|
36
|
+
from src.core import get_current_branch, get_repo_name
|
|
37
37
|
current_branch = get_current_branch()
|
|
38
|
-
|
|
38
|
+
repo_name = get_repo_name()
|
|
39
|
+
|
|
39
40
|
cache_data = {
|
|
40
41
|
"md5": md5_hash,
|
|
42
|
+
"repo": repo_name,
|
|
41
43
|
"branch": current_branch,
|
|
42
44
|
"datetime": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
|
43
45
|
"action_type": action_type,
|
|
@@ -51,21 +53,21 @@ def save_cached_response(action_folder, action_type, prompt_text, response_dict)
|
|
|
51
53
|
except IOError:
|
|
52
54
|
pass # Falha silenciosa no cache para não travar a ferramenta
|
|
53
55
|
|
|
54
|
-
def get_cached_pr_descriptions(branch_name):
|
|
55
|
-
"""Busca no cache todos os PRs gerados historicamente para
|
|
56
|
+
def get_cached_pr_descriptions(repo_name, branch_name):
|
|
57
|
+
"""Busca no cache todos os PRs gerados historicamente para este repositorio e branch."""
|
|
56
58
|
pr_cache_folder = get_cache_base_dir() / "pr_desc"
|
|
57
59
|
history_texts = []
|
|
58
|
-
|
|
60
|
+
|
|
59
61
|
if not pr_cache_folder.exists():
|
|
60
62
|
return ""
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
for cache_file in pr_cache_folder.glob("*.json"):
|
|
63
65
|
try:
|
|
64
66
|
with open(cache_file, "r", encoding="utf-8") as f:
|
|
65
67
|
data = json.load(f)
|
|
66
|
-
|
|
67
|
-
#
|
|
68
|
-
if data.get("branch") == branch_name:
|
|
68
|
+
|
|
69
|
+
# Filtra por repositorio E branch (evita misturar projetos diferentes)
|
|
70
|
+
if data.get("repo") == repo_name and data.get("branch") == branch_name:
|
|
69
71
|
response_dict = data.get("response", {})
|
|
70
72
|
pr_desc = response_dict.get("pr_description")
|
|
71
73
|
if pr_desc:
|
|
@@ -73,10 +75,10 @@ def get_cached_pr_descriptions(branch_name):
|
|
|
73
75
|
history_texts.append(f"[{date_str}]\n{pr_desc}\n")
|
|
74
76
|
except (json.JSONDecodeError, IOError):
|
|
75
77
|
continue
|
|
76
|
-
|
|
78
|
+
|
|
77
79
|
if history_texts:
|
|
78
|
-
# Ordena cronologicamente (usando a data
|
|
80
|
+
# Ordena cronologicamente (usando a data extraida no colchete)
|
|
79
81
|
history_texts.sort()
|
|
80
82
|
return "=== HISTÓRICO DE PRs DA IA ===\n" + "\n".join(history_texts)
|
|
81
|
-
|
|
83
|
+
|
|
82
84
|
return ""
|
src/core.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import re
|
|
2
3
|
import json
|
|
3
4
|
import stat
|
|
4
5
|
import click
|
|
@@ -56,9 +57,9 @@ def get_current_branch():
|
|
|
56
57
|
"""Retorna o nome da branch atual."""
|
|
57
58
|
try:
|
|
58
59
|
result = subprocess.run(
|
|
59
|
-
["git", "rev-parse", "--abbrev-ref", "HEAD"],
|
|
60
|
-
capture_output=True,
|
|
61
|
-
text=True,
|
|
60
|
+
["git", "rev-parse", "--abbrev-ref", "HEAD"],
|
|
61
|
+
capture_output=True,
|
|
62
|
+
text=True,
|
|
62
63
|
encoding="utf-8",
|
|
63
64
|
check=True
|
|
64
65
|
)
|
|
@@ -67,6 +68,26 @@ def get_current_branch():
|
|
|
67
68
|
return "main" # Fallback
|
|
68
69
|
|
|
69
70
|
|
|
71
|
+
def get_repo_name():
|
|
72
|
+
"""Extrai o nome owner/repo do git remote origin."""
|
|
73
|
+
try:
|
|
74
|
+
result = subprocess.run(
|
|
75
|
+
["git", "remote", "-v"],
|
|
76
|
+
capture_output=True,
|
|
77
|
+
text=True,
|
|
78
|
+
encoding="utf-8",
|
|
79
|
+
check=True
|
|
80
|
+
)
|
|
81
|
+
match = re.search(r'github\.com[:/](.+?)/(.+?)(\.git)?\s+\(push\)', result.stdout)
|
|
82
|
+
if match:
|
|
83
|
+
owner = match.group(1)
|
|
84
|
+
repo = match.group(2).replace('.git', '')
|
|
85
|
+
return f"{owner}/{repo}"
|
|
86
|
+
return "unknown/repo"
|
|
87
|
+
except subprocess.CalledProcessError:
|
|
88
|
+
return "unknown/repo"
|
|
89
|
+
|
|
90
|
+
|
|
70
91
|
def get_skill_context(action_type="pr"):
|
|
71
92
|
"""Lê o arquivo de contexto correto baseado na ação (PR/Commit ou Review)."""
|
|
72
93
|
|
|
@@ -316,14 +337,15 @@ def install_git_hooks():
|
|
|
316
337
|
return success_count == len(hooks_to_install)
|
|
317
338
|
|
|
318
339
|
def get_branch_history_text():
|
|
319
|
-
"""Compila o Git Log e o Cache de PRs da branch atual para gerar o contexto
|
|
340
|
+
"""Compila o Git Log e o Cache de PRs da branch atual para gerar o contexto epico."""
|
|
320
341
|
branch = get_current_branch()
|
|
321
342
|
base_branch = get_base_branch()
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
343
|
+
repo_name = get_repo_name()
|
|
344
|
+
|
|
345
|
+
click.secho(f"🔄 Compilando historico do repositorio '{repo_name}', branch '{branch}' contra '{base_branch}'...", fg="cyan")
|
|
346
|
+
|
|
347
|
+
hybrid_context = f"Repositorio: {repo_name}\nResumo Historico da Branch: {branch}\n\n"
|
|
348
|
+
|
|
327
349
|
# Pega os Commits reais do Git
|
|
328
350
|
try:
|
|
329
351
|
# Pega a linha do tempo desde o merge base
|
|
@@ -349,8 +371,8 @@ def get_branch_history_text():
|
|
|
349
371
|
except subprocess.CalledProcessError as e:
|
|
350
372
|
click.secho(f"⚠️ Aviso: Não foi possível obter o Git Log: {e.stderr}", fg="yellow")
|
|
351
373
|
|
|
352
|
-
# Pega a
|
|
353
|
-
cached_prs = get_cached_pr_descriptions(branch)
|
|
374
|
+
# Pega a memoria historica da IA (Cache de PRs antigos desse repo + branch)
|
|
375
|
+
cached_prs = get_cached_pr_descriptions(repo_name, branch)
|
|
354
376
|
if cached_prs:
|
|
355
377
|
hybrid_context += f"{cached_prs}\n"
|
|
356
378
|
else:
|
src/spinner.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Spinner animado com caracteres braille e palavras de pensamento.
|
|
3
|
+
Efeito visual: caracter braille girando (magenta) + palavra sendo "descoberta"
|
|
4
|
+
letra a letra com cores aleatorias.
|
|
5
|
+
"""
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
import time
|
|
9
|
+
import random
|
|
10
|
+
import string
|
|
11
|
+
import threading
|
|
12
|
+
import urllib.request
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from dotenv import load_dotenv, set_key
|
|
15
|
+
|
|
16
|
+
# ANSI color codes
|
|
17
|
+
MAGENTA = '\033[35m'
|
|
18
|
+
RESET = '\033[0m'
|
|
19
|
+
|
|
20
|
+
# Paleta de cores para as palavras
|
|
21
|
+
WORD_COLORS = [
|
|
22
|
+
'\033[36m', # cyan
|
|
23
|
+
'\033[33m', # yellow
|
|
24
|
+
'\033[32m', # green
|
|
25
|
+
'\033[34m', # blue
|
|
26
|
+
'\033[95m', # bright magenta
|
|
27
|
+
'\033[96m', # bright cyan
|
|
28
|
+
'\033[93m', # bright yellow
|
|
29
|
+
'\033[92m', # bright green
|
|
30
|
+
'\033[94m', # bright blue
|
|
31
|
+
'\033[91m', # red
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
# Caracteres braille unicode que simulam um giro
|
|
35
|
+
BRAILLE_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
|
|
36
|
+
|
|
37
|
+
# URL do template remoto com a lista de palavras
|
|
38
|
+
THINKING_WORDS_URL = (
|
|
39
|
+
"https://raw.githubusercontent.com/natanfiuza/gitpr/"
|
|
40
|
+
"refs/heads/main/templates/gitpr.thinking-words.md"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Fallback interno caso o download falhe
|
|
44
|
+
_FALLBACK_WORDS = [
|
|
45
|
+
"Fabuloso", "Pensando", "Analisando", "Raciocinando",
|
|
46
|
+
"Elaborando", "Processando", "Decifrando", "Calculando",
|
|
47
|
+
"Refletindo", "Maquinando",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
def _load_thinking_words():
|
|
51
|
+
"""Carrega a lista de palavras do .env ou faz download do template remoto."""
|
|
52
|
+
env_file = str(Path.home() / ".gitpr" / ".env")
|
|
53
|
+
|
|
54
|
+
# Garante que o .env foi carregado
|
|
55
|
+
load_dotenv(env_file)
|
|
56
|
+
|
|
57
|
+
raw = os.getenv("SPINNER_THINKING_WORDS", "").strip()
|
|
58
|
+
|
|
59
|
+
if raw:
|
|
60
|
+
# .env ja tem palavras: suporta separador | ou ,
|
|
61
|
+
sep = "|" if "|" in raw else ","
|
|
62
|
+
return [w.strip() for w in raw.split(sep) if w.strip()]
|
|
63
|
+
|
|
64
|
+
# .env nao tem palavras: baixa do GitHub
|
|
65
|
+
try:
|
|
66
|
+
with urllib.request.urlopen(THINKING_WORDS_URL, timeout=10) as resp:
|
|
67
|
+
content = resp.read().decode("utf-8")
|
|
68
|
+
|
|
69
|
+
# Parse: suporta palavras separadas por virgula OU uma por linha
|
|
70
|
+
words = []
|
|
71
|
+
for line in content.splitlines():
|
|
72
|
+
line = line.strip()
|
|
73
|
+
if not line or line.startswith("#"):
|
|
74
|
+
continue
|
|
75
|
+
# Cada linha pode ter varias palavras separadas por virgula
|
|
76
|
+
for word in line.split(","):
|
|
77
|
+
word = word.strip()
|
|
78
|
+
if word:
|
|
79
|
+
words.append(word)
|
|
80
|
+
|
|
81
|
+
if words:
|
|
82
|
+
# Salva no .env como pipe-separated
|
|
83
|
+
set_key(env_file, "SPINNER_THINKING_WORDS", "|".join(words))
|
|
84
|
+
return words
|
|
85
|
+
except Exception:
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
# Fallback: usa lista interna
|
|
89
|
+
return list(_FALLBACK_WORDS)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# Palavras que representam "pensamento" da IA (carregadas do .env ou template remoto)
|
|
93
|
+
THINKING_WORDS = _load_thinking_words()
|
|
94
|
+
|
|
95
|
+
class Spinner:
|
|
96
|
+
"""Spinner animado que roda em background enquanto a IA processa."""
|
|
97
|
+
|
|
98
|
+
def __init__(self, quiet=False):
|
|
99
|
+
self._thread = None
|
|
100
|
+
self._running = False
|
|
101
|
+
self._quiet = quiet
|
|
102
|
+
|
|
103
|
+
def _spin(self):
|
|
104
|
+
"""Loop principal da animacao, executado em thread separada."""
|
|
105
|
+
braille_idx = 0
|
|
106
|
+
word_idx = random.randrange(len(THINKING_WORDS))
|
|
107
|
+
word = THINKING_WORDS[word_idx]
|
|
108
|
+
word_color = random.choice(WORD_COLORS)
|
|
109
|
+
discovered = "" # Letras ja "descobertas" da palavra
|
|
110
|
+
dots_cycle = 0 # 0 = ".", 1 = "..", 2 = "..."
|
|
111
|
+
char_step = 0 # Contador de frames para revelar letras
|
|
112
|
+
chars_per_letter = 4 # Frames com caracteres aleatorios antes de revelar uma letra
|
|
113
|
+
|
|
114
|
+
while self._running:
|
|
115
|
+
braille_char = BRAILLE_FRAMES[braille_idx]
|
|
116
|
+
braille_idx = (braille_idx + 1) % len(BRAILLE_FRAMES)
|
|
117
|
+
|
|
118
|
+
# Animacao da palavra sendo "descoberta"
|
|
119
|
+
if len(discovered) < len(word):
|
|
120
|
+
char_step += 1
|
|
121
|
+
if char_step >= chars_per_letter:
|
|
122
|
+
# Revela mais uma letra da palavra
|
|
123
|
+
discovered = word[:len(discovered) + 1]
|
|
124
|
+
char_step = 0
|
|
125
|
+
else:
|
|
126
|
+
# Mostra um caractere aleatorio no lugar da proxima letra
|
|
127
|
+
fake_char = random.choice(string.ascii_uppercase + "0123456789!@#$")
|
|
128
|
+
discovered = word[:len(discovered)] + fake_char
|
|
129
|
+
|
|
130
|
+
display_word = discovered
|
|
131
|
+
else:
|
|
132
|
+
# Palavra completa: ciclo dos pontinhos
|
|
133
|
+
dots_cycle = (dots_cycle + 1) % 12
|
|
134
|
+
if dots_cycle < 4:
|
|
135
|
+
dots = "."
|
|
136
|
+
elif dots_cycle < 8:
|
|
137
|
+
dots = ".."
|
|
138
|
+
else:
|
|
139
|
+
dots = "..."
|
|
140
|
+
|
|
141
|
+
display_word = word + dots
|
|
142
|
+
|
|
143
|
+
# Troca de palavra e cor apos alguns ciclos de pontinhos
|
|
144
|
+
if dots_cycle == 0 and braille_idx == 0:
|
|
145
|
+
word_idx = (word_idx + 1) % len(THINKING_WORDS)
|
|
146
|
+
word = THINKING_WORDS[word_idx]
|
|
147
|
+
word_color = random.choice(WORD_COLORS)
|
|
148
|
+
discovered = ""
|
|
149
|
+
char_step = 0
|
|
150
|
+
|
|
151
|
+
# Monta e exibe a linha: braille magenta + palavra colorida
|
|
152
|
+
line = f"\r {MAGENTA}{braille_char}{RESET} {word_color}{display_word}{RESET}"
|
|
153
|
+
# Limpa o resto da linha com espacos
|
|
154
|
+
line = line.ljust(70 + len(MAGENTA) + len(RESET) * 2 + len(word_color))
|
|
155
|
+
|
|
156
|
+
if not self._quiet:
|
|
157
|
+
sys.stdout.write(line)
|
|
158
|
+
sys.stdout.flush()
|
|
159
|
+
|
|
160
|
+
time.sleep(0.08) # ~12 fps, suave
|
|
161
|
+
|
|
162
|
+
def start(self):
|
|
163
|
+
"""Inicia a animacao em background."""
|
|
164
|
+
if self._quiet:
|
|
165
|
+
return
|
|
166
|
+
self._running = True
|
|
167
|
+
self._thread = threading.Thread(target=self._spin, daemon=True)
|
|
168
|
+
self._thread.start()
|
|
169
|
+
|
|
170
|
+
def stop(self):
|
|
171
|
+
"""Para a animacao e limpa a linha."""
|
|
172
|
+
self._running = False
|
|
173
|
+
if self._thread:
|
|
174
|
+
self._thread.join(timeout=0.5)
|
|
175
|
+
if not self._quiet:
|
|
176
|
+
sys.stdout.write("\r" + " " * 70 + "\r")
|
|
177
|
+
sys.stdout.flush()
|
src/updater.py
CHANGED
|
@@ -7,7 +7,7 @@ import click
|
|
|
7
7
|
from datetime import datetime
|
|
8
8
|
|
|
9
9
|
# Versão atual do seu executável local (Atualize isso a cada novo build!)
|
|
10
|
-
__version__ = "0.0.
|
|
10
|
+
__version__ = "0.0.20"
|
|
11
11
|
GITHUB_API_URL = "https://api.github.com/repos/natanfiuza/gitpr/releases/latest"
|
|
12
12
|
PYPI_API_URL = "https://pypi.org/pypi/gitpr-cli/json"
|
|
13
13
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|