gitpr-cli 0.0.27__py3-none-any.whl → 0.0.29__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.27.dist-info → gitpr_cli-0.0.29.dist-info}/METADATA +73 -4
- {gitpr_cli-0.0.27.dist-info → gitpr_cli-0.0.29.dist-info}/RECORD +11 -10
- {gitpr_cli-0.0.27.dist-info → gitpr_cli-0.0.29.dist-info}/entry_points.txt +1 -0
- src/core.py +91 -8
- src/main.py +23 -3
- src/mcp_server.py +1217 -0
- src/spinner.py +32 -7
- src/updater.py +2 -2
- {gitpr_cli-0.0.27.dist-info → gitpr_cli-0.0.29.dist-info}/WHEEL +0 -0
- {gitpr_cli-0.0.27.dist-info → gitpr_cli-0.0.29.dist-info}/licenses/LICENSE +0 -0
- {gitpr_cli-0.0.27.dist-info → gitpr_cli-0.0.29.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.29
|
|
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
|
|
@@ -14,17 +14,20 @@ Requires-Dist: cryptography
|
|
|
14
14
|
Requires-Dist: pyyaml
|
|
15
15
|
Requires-Dist: textual
|
|
16
16
|
Requires-Dist: requests
|
|
17
|
+
Requires-Dist: mcp>=1.0.0
|
|
17
18
|
Dynamic: license-file
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
# **GitPR CLI 🚀**
|
|
21
22
|
|
|
22
23
|
<p align="center">
|
|
23
|
-
<img src="docs/logo.png" alt="GitPR Logo" width="
|
|
24
|
+
<img src="https://raw.githubusercontent.com/natanfiuza/gitpr/main/docs/logo.png" alt="GitPR Logo" width="150">
|
|
24
25
|
</p>
|
|
25
26
|
|
|
26
27
|
GitPR CLI is a command-line automation tool that uses **Google Gemini** and **DeepSeek** artificial intelligence to analyze your code changes (git diff) or entire files. The tool automatically generates commit messages in the *Conventional Commits* standard, detailed Pull Request descriptions, and deep Code Reviews aimed at reducing technical debt.
|
|
27
28
|
|
|
29
|
+
🌐 **Website:** [gitpr.natanfiuza.dev.br](https://gitpr.natanfiuza.dev.br/) · 📂 **Repository:** [github.com/natanfiuza/gitpr](https://github.com/natanfiuza/gitpr)
|
|
30
|
+
|
|
28
31
|
## **🛠️ Technologies and Libraries Used**
|
|
29
32
|
|
|
30
33
|
This project was developed in Python and uses the following main libraries:
|
|
@@ -38,6 +41,7 @@ This project was developed in Python and uses the following main libraries:
|
|
|
38
41
|
* [**PyYAML**](https://pyyaml.org/): Used to read and process the custom static analysis rules from the `.gitpr.linter.yml` file.
|
|
39
42
|
* [**Textual**](https://textual.textualize.io/): Powerful library for creating Terminal Graphical Interfaces (TUI), used in the interactive issue generation and editing panel.
|
|
40
43
|
* [**Requests**](https://pypi.org/project/requests/): Elegant and robust library for HTTP requests, used to communicate with the GitHub REST API.
|
|
44
|
+
* [**MCP**](https://pypi.org/project/mcp/): Official Python SDK for the Model Context Protocol, enabling GitPR to integrate directly with AI-powered editors and IDEs.
|
|
41
45
|
|
|
42
46
|
----
|
|
43
47
|
|
|
@@ -135,6 +139,8 @@ You can pass the following *flags* for specific actions:
|
|
|
135
139
|
* `--lang <code>`: Forces the interface language for this execution (e.g.: `en_us`, `pt_br`). Overrides `GITPR_LANG` in `.env` without persisting the change.
|
|
136
140
|
* `-ch` or `--chat`: Opens the **Interactive Pair Programming Chat** — a TUI terminal where the AI sees your current diff and maintains a contextual conversation. Features memory per branch, slash commands (`/explain`, `/tests`, `/optimize`, `/clear`), auto-patching (F5), diff refresh (F2), and session export (F6).
|
|
137
141
|
* `-l` or `--linter`: Runs **only the local static linter** (no AI calls). Ideal for use in CI/CD pipelines to block non-compliant code.
|
|
142
|
+
* `--mcp`: Starts GitPR as an **MCP server** (Model Context Protocol) on stdio transport. Enables integration with VS Code, Cursor, Claude Desktop, and other MCP-compatible editors — exposing all GitPR AI capabilities as 10 annotated tools, 15 resources, and 7 pre-built prompts directly inside your IDE. Also available as the standalone `gitpr-mcp` command.
|
|
143
|
+
* `--install`: **Interactive Setup Wizard.** Runs a guided 4-step setup: downloads skill templates, installs Git hooks, configures MCP for detected editors, and checks/requests your AI provider API key. Each step asks for confirmation before proceeding.
|
|
138
144
|
* `-ih` or `--installhooks`: Automatically installs **local Git Hooks** (`pre-commit` and `prepare-commit-msg`) in your repository.
|
|
139
145
|
* `-s` or `--skill`: Creates the AI context template files (`.gitpr.commit.md`, `.gitpr.pr.md`, `.gitpr.review.md`, `.gitpr.filereview.md`, `.gitpr.issue.md`, `.gitpr.blame.md`) and the Linter (`.gitpr.linter.yml`) at the project root.
|
|
140
146
|
* `-is` or `--issue`: Automatically generates a draft of a **standardized Issue** and opens an interactive interface (TUI) for editing or direct submission via REST API. This feature has **3 context engines** depending on the command combination:
|
|
@@ -152,7 +158,7 @@ You can pass the following *flags* for specific actions:
|
|
|
152
158
|
|
|
153
159
|
When your diff is too large for a single AI call (over ~90k estimated tokens), GitPR automatically splits it into batches by file, asks the AI for a technical summary of each part (Map), and unifies everything into the final commit message, review, or PR description (Reduce). No flags needed — it activates on demand and shows the progress in the console.
|
|
154
160
|
|
|
155
|
-
📚 Full documentation: [docs/map-reduce-diff.md](docs/map-reduce-diff.md)
|
|
161
|
+
📚 Full documentation: [docs/map-reduce-diff.md](https://github.com/natanfiuza/gitpr/blob/main/docs/map-reduce-diff.md)
|
|
156
162
|
|
|
157
163
|
## 🛡️ Local Linter (Static Analysis)
|
|
158
164
|
|
|
@@ -207,7 +213,66 @@ GitPR automatically detects your system language and displays messages in your n
|
|
|
207
213
|
|
|
208
214
|
To force a specific language, set `GITPR_LANG=pt_br` or `GITPR_LANG=en` in `~/.gitpr/.env`.
|
|
209
215
|
|
|
210
|
-
> 📖 **Full developer guide:** [docs/i18n_explanation.md](docs/i18n_explanation.md) — architecture, usage patterns, circular import precautions, and how to add new languages.
|
|
216
|
+
> 📖 **Full developer guide:** [docs/i18n_explanation.md](https://github.com/natanfiuza/gitpr/blob/main/docs/i18n_explanation.md) — architecture, usage patterns, circular import precautions, and how to add new languages.
|
|
217
|
+
|
|
218
|
+
## 🔌 MCP Integration (Model Context Protocol)
|
|
219
|
+
|
|
220
|
+
GitPR can run as an **MCP server**, exposing its AI-powered capabilities as tools that your editor's AI assistant can invoke directly — no terminal needed. This enables a fully integrated workflow where you can generate commit messages, review code, run linters, trace code origins, and create issues without leaving your IDE.
|
|
221
|
+
|
|
222
|
+
### Supported Editors
|
|
223
|
+
|
|
224
|
+
| Editor | Config File |
|
|
225
|
+
| ------ | ----------- |
|
|
226
|
+
| **VS Code** | `.vscode/mcp.json` |
|
|
227
|
+
| **Cursor** | `.cursor/mcp.json` |
|
|
228
|
+
| **Claude Code** | `.mcp.json` |
|
|
229
|
+
| **Claude Desktop** | `claude_desktop_config.json` |
|
|
230
|
+
| **Zed** | `settings.json` |
|
|
231
|
+
|
|
232
|
+
### Quick Setup
|
|
233
|
+
|
|
234
|
+
Use the built-in installer to configure your editor automatically:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
gitpr-mcp --install vscode # Creates .vscode/mcp.json
|
|
238
|
+
gitpr-mcp --install cursor # Creates .cursor/mcp.json
|
|
239
|
+
gitpr-mcp --install claude-code # Creates .mcp.json
|
|
240
|
+
gitpr-mcp --install claude # Updates Claude Desktop config
|
|
241
|
+
gitpr-mcp --install zed # Updates Zed settings
|
|
242
|
+
gitpr-mcp --install auto # Auto-detect and install for all found
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The installer creates the config directory if needed, merges with any existing
|
|
246
|
+
config (never overwrites other servers), and is safe to run multiple times.
|
|
247
|
+
|
|
248
|
+
> Manual setup is also supported — see [docs/mcp-integration.md](https://github.com/natanfiuza/gitpr/blob/main/docs/mcp-integration.md)
|
|
249
|
+
> for the JSON config format for each editor.
|
|
250
|
+
|
|
251
|
+
Once configured, use natural language in your editor's AI chat:
|
|
252
|
+
|
|
253
|
+
* *"Review my current changes"* → calls `review_code`
|
|
254
|
+
* *"Generate a commit message"* → calls `generate_commit_message`
|
|
255
|
+
* *"Create a PR description"* → calls `generate_pr_description`
|
|
256
|
+
* *"Run the linter on my diff"* → calls `run_linter`
|
|
257
|
+
|
|
258
|
+
### Available MCP Tools
|
|
259
|
+
|
|
260
|
+
| Tool | Description |
|
|
261
|
+
| ---- | ----------- |
|
|
262
|
+
| `get_git_context` | Current branch, repository name, and remote URL |
|
|
263
|
+
| `analyze_diff` | Git diff of uncommitted changes |
|
|
264
|
+
| `get_full_diff` | Full diff against origin/main |
|
|
265
|
+
| `generate_commit_message` | AI-generated Conventional Commits message |
|
|
266
|
+
| `review_code` | AI code review of local changes |
|
|
267
|
+
| `full_review` | AI code review of all changes since origin/main |
|
|
268
|
+
| `generate_pr_description` | Complete PR description (title + body) |
|
|
269
|
+
| `run_linter` | Static linter against `.gitpr.linter.yml` |
|
|
270
|
+
| `analyze_blame` | Git blame + AI classification |
|
|
271
|
+
| `generate_issue` | Structured issue from diff, history, or blame |
|
|
272
|
+
|
|
273
|
+
📖 **Full documentation:** [docs/mcp-integration.md](https://github.com/natanfiuza/gitpr/blob/main/docs/mcp-integration.md) — available in 5 languages (EN, PT-BR, PT-PT, ES, FR).
|
|
274
|
+
|
|
275
|
+
> 💬 **MCP Prompts** — GitPR also exposes 7 pre-defined message templates (prompts) for common flows like "Review PR", "Generate Commit Message", and "Create Issue from Diff". See the [MCP Prompts guide](https://github.com/natanfiuza/gitpr/blob/main/docs/mcp-prompts.md) for the full list.
|
|
211
276
|
|
|
212
277
|
## 📚 Technical Documentation and Advanced Guides
|
|
213
278
|
|
|
@@ -238,10 +303,14 @@ If you want to implement GitPR as an automated quality barrier in your team, che
|
|
|
238
303
|
|
|
239
304
|
### Configuration & Infrastructure
|
|
240
305
|
|
|
306
|
+
* [**Install Wizard**](https://github.com/natanfiuza/gitpr/blob/main/docs/install-wizard.md) — Step-by-step guided setup for configuring GitPR in a new project.
|
|
241
307
|
* [**AI Providers**](https://github.com/natanfiuza/gitpr/blob/main/docs/providers-ia.md) — Configuration and selection between Google Gemini, DeepSeek, and Ollama.
|
|
242
308
|
* [**Auto-Updater**](https://github.com/natanfiuza/gitpr/blob/main/docs/auto-update.md) — How GitPR's automatic update (hot-swap) works.
|
|
243
309
|
* [**GitHub Token (PAT) Integration and Security**](https://github.com/natanfiuza/gitpr/blob/main/docs/github-pat-integration.md) — Understand how GitPR creates issues directly in the repository with authentication.
|
|
244
310
|
* [**Internationalization (i18n)**](https://github.com/natanfiuza/gitpr/blob/main/docs/i18n_explanation.md) — Architecture, usage patterns, and how to add new languages.
|
|
311
|
+
* [**MCP Integration**](https://github.com/natanfiuza/gitpr/blob/main/docs/mcp-integration.md) — Connect GitPR to VS Code, Cursor, and Claude Desktop via Model Context Protocol.
|
|
312
|
+
* [**MCP Prompts**](https://github.com/natanfiuza/gitpr/blob/main/docs/mcp-prompts.md) — Pre-built message templates (7 prompts, 35 language variants) for common GitPR workflows in your editor's AI chat.
|
|
313
|
+
* [**MCP Tool Annotations**](https://github.com/natanfiuza/gitpr/blob/main/docs/mcp-annotations.md) — IDE integration hints (`readOnlyHint`, `destructiveHint`) for smarter UI behavior and safer tool execution.
|
|
245
314
|
|
|
246
315
|
## ⚡ Local Cache System (Quota Savings)
|
|
247
316
|
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
gitpr_cli-0.0.
|
|
1
|
+
gitpr_cli-0.0.29.dist-info/licenses/LICENSE,sha256=UQzLC6mwqb-ZNDkBBAqOxC-SMQcEID0gaM6oFcu6u48,27030
|
|
2
2
|
src/__init__.py,sha256=U6ksarernNcryHO20aj4rNG7w0thT7xdMs5KzBJyPvE,28
|
|
3
3
|
src/ai_providers.py,sha256=cxPuytZ9LfvhQbWFPBJ4dud3lHLpAQpa3cbY8bKESk8,10954
|
|
4
4
|
src/blame_engine.py,sha256=z-uh8mHOF--JxY_nnbp5r_9y_a_IO4Zn42P0AeLBpto,10436
|
|
5
5
|
src/cache.py,sha256=XggMTy00GlZfeF1VoLEYCdxL5h0eTg11TJfPIRPx7fs,3201
|
|
6
6
|
src/chat_memory.py,sha256=vdYuElIQb6-flFm4SfzapnQZGRIwgbLECzIcsAc0Oo8,8724
|
|
7
7
|
src/config.py,sha256=VJ9ekDlTVG5ETWDuO1kZWlgrncXbrvduxa5Zg7wN_ZY,9064
|
|
8
|
-
src/core.py,sha256=
|
|
8
|
+
src/core.py,sha256=PqwqWHA5h_EplQ6mURxriS5Ql9_QPq73S2R9zJ11-78,28580
|
|
9
9
|
src/i18n.py,sha256=QED7hTSdWCC1lSNJ-l6VuOba18OrWgFTMQcZ7cQmXbY,3599
|
|
10
10
|
src/issue_engine.py,sha256=XJ7WNLoeg3wct079wS7OQqU62f_avn3A8LmMuPWchzE,3642
|
|
11
11
|
src/linter_engine.py,sha256=D04wvOgRa-vZEYknm-z-Cg7V_3gnoQz_64PMorWnISo,4414
|
|
12
|
-
src/main.py,sha256=
|
|
12
|
+
src/main.py,sha256=BoI2aN3l1fS4UzoWL67Yw2QtkeRxh9ITuVIQEc9JOPA,32724
|
|
13
|
+
src/mcp_server.py,sha256=rT5ACAb0MUpvt8qfO0jIt3g4y6BKWW5YY2qRrs6hKsQ,40227
|
|
13
14
|
src/security.py,sha256=Li0zM8ZURTK2nKRHIt49TWLO4DIddBEHzXPrVycv0Rs,1343
|
|
14
|
-
src/spinner.py,sha256=
|
|
15
|
+
src/spinner.py,sha256=fnl_jVOPjlC1DmINbnJ_IKW-uujpyJNTv51jwhAMvlc,8466
|
|
15
16
|
src/tui_issue.py,sha256=gcAJCIfMcdeMjrFJUWQQvdgBv7fnOBtxQxwdBk2Sk40,1789
|
|
16
|
-
src/updater.py,sha256=
|
|
17
|
+
src/updater.py,sha256=kHzP-SyprrNQSLeOhiplFjPuswkh4enVc9TM_7LQnpU,5886
|
|
17
18
|
src/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
19
|
src/ui/chat_app.py,sha256=y-py5UpisQbPLqqDON8AIkyA7X1IM5LAn1GbeYr2p_U,25598
|
|
19
20
|
src/ui/help_screen.py,sha256=tjbokXhwyzLnkOC0S56NbpX-78hcFQnvsQMpNU1wt0c,1862
|
|
20
21
|
src/ui/issue_app.py,sha256=8MdBcOVdCHPFx6EUhs80CiZ2G-29KulskkCz9qMZ_Lg,4737
|
|
21
|
-
gitpr_cli-0.0.
|
|
22
|
-
gitpr_cli-0.0.
|
|
23
|
-
gitpr_cli-0.0.
|
|
24
|
-
gitpr_cli-0.0.
|
|
25
|
-
gitpr_cli-0.0.
|
|
22
|
+
gitpr_cli-0.0.29.dist-info/METADATA,sha256=Q77hoxR0vAluySUVwFCFuJPb3-7zozYTPFNm-y2Y1jY,23425
|
|
23
|
+
gitpr_cli-0.0.29.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
24
|
+
gitpr_cli-0.0.29.dist-info/entry_points.txt,sha256=TstGnMUzdOI5qNmpM97EPDBPuMqOZxoo6EoLxHSOMSQ,71
|
|
25
|
+
gitpr_cli-0.0.29.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
|
|
26
|
+
gitpr_cli-0.0.29.dist-info/RECORD,,
|
src/core.py
CHANGED
|
@@ -12,7 +12,7 @@ from google import genai
|
|
|
12
12
|
from dotenv import load_dotenv, set_key
|
|
13
13
|
from src.security import decrypt_data
|
|
14
14
|
from src.cache import get_cached_response, save_cached_response, get_cached_pr_descriptions
|
|
15
|
-
from src.config import get_api_key, get_api_model, get_skill_dir, resolve_skill_path
|
|
15
|
+
from src.config import get_api_key, get_api_model, get_skill_dir, resolve_skill_path, get_ai_provider, setup_environment
|
|
16
16
|
from src.ai_providers import call_ai_model
|
|
17
17
|
from src.i18n import __, CURRENT_LANG
|
|
18
18
|
from src.updater import __lang_version__
|
|
@@ -96,13 +96,20 @@ SMART_EXCLUDES = _load_smart_excludes()
|
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
def get_doc_url(filename):
|
|
99
|
-
"""Returns the complete URL for
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
"""Returns the complete URL for the official GitPR documentation website.
|
|
100
|
+
|
|
101
|
+
Transforms a docs/ filename like 'commit-message-ia.md' into a clean website
|
|
102
|
+
URL with language query parameter. English is the site default (no ?lang=).
|
|
103
|
+
|
|
104
|
+
Examples:
|
|
105
|
+
get_doc_url("untracked-files.md") -> "https://gitpr.natanfiuza.dev.br/docs/untracked-files"
|
|
106
|
+
get_doc_url("untracked-files.md") -> "https://gitpr.natanfiuza.dev.br/docs/untracked-files?lang=pt_br" (when CURRENT_LANG is pt_br)
|
|
107
|
+
"""
|
|
108
|
+
base, _ = filename.rsplit(".", 1)
|
|
109
|
+
url = f"https://gitpr.natanfiuza.dev.br/docs/{base}"
|
|
110
|
+
if not CURRENT_LANG.startswith("en"):
|
|
111
|
+
url += f"?lang={CURRENT_LANG}"
|
|
112
|
+
return url
|
|
106
113
|
|
|
107
114
|
|
|
108
115
|
def get_git_diff(quiet=False):
|
|
@@ -509,6 +516,82 @@ def install_git_hooks():
|
|
|
509
516
|
|
|
510
517
|
return success_count == len(hooks_to_install)
|
|
511
518
|
|
|
519
|
+
|
|
520
|
+
def run_install_wizard():
|
|
521
|
+
"""
|
|
522
|
+
Interactive setup wizard combining --skill, --installhooks, MCP install, and API key check.
|
|
523
|
+
|
|
524
|
+
Asks for confirmation before each step and prints a documentation URL at the end.
|
|
525
|
+
"""
|
|
526
|
+
click.secho(__("\n🔧 Starting GitPR Interactive Setup Wizard..."), fg="cyan", bold=True)
|
|
527
|
+
click.echo(__("This wizard will guide you through the essential GitPR setup steps.\n"))
|
|
528
|
+
|
|
529
|
+
# ------------------------------------------------------------------
|
|
530
|
+
# Step 1: Skill Templates (equivalent to --skill)
|
|
531
|
+
# ------------------------------------------------------------------
|
|
532
|
+
click.secho(__("Step 1 of 4: Skill Templates"), fg="yellow", bold=True)
|
|
533
|
+
click.echo(__("Downloads template files (.gitpr.*.md, .gitpr.linter.yml) into the .gitpr/skill/ folder."))
|
|
534
|
+
click.echo(__("These files allow customizing AI behavior for your team's conventions."))
|
|
535
|
+
if click.confirm(__("Proceed with downloading skill templates?"), default=True):
|
|
536
|
+
generate_skill_template()
|
|
537
|
+
else:
|
|
538
|
+
click.echo(__("Skipped.\n"))
|
|
539
|
+
|
|
540
|
+
# ------------------------------------------------------------------
|
|
541
|
+
# Step 2: Git Hooks (equivalent to --installhooks)
|
|
542
|
+
# ------------------------------------------------------------------
|
|
543
|
+
click.secho(__("\nStep 2 of 4: Git Hooks"), fg="yellow", bold=True)
|
|
544
|
+
click.echo(__("Installs pre-commit (static linter) and prepare-commit-msg (AI commit messages) hooks."))
|
|
545
|
+
click.echo(__("This enables automatic validation and AI assistance before every commit."))
|
|
546
|
+
if click.confirm(__("Proceed with installing Git hooks?"), default=True):
|
|
547
|
+
if install_git_hooks():
|
|
548
|
+
click.secho(__("✅ Git Hooks successfully installed!"), fg="green", bold=True)
|
|
549
|
+
else:
|
|
550
|
+
click.secho(__("⚠️ Some hooks could not be installed."), fg="yellow")
|
|
551
|
+
else:
|
|
552
|
+
click.echo(__("Skipped.\n"))
|
|
553
|
+
|
|
554
|
+
# ------------------------------------------------------------------
|
|
555
|
+
# Step 3: MCP Configuration (equivalent to gitpr-mcp --install auto)
|
|
556
|
+
# ------------------------------------------------------------------
|
|
557
|
+
click.secho(__("\nStep 3 of 4: MCP Configuration"), fg="yellow", bold=True)
|
|
558
|
+
click.echo(__("Auto-detects and configures GitPR for VS Code, Cursor, Claude Desktop, and Zed."))
|
|
559
|
+
click.echo(__("This lets AI-powered editors use GitPR tools directly without the terminal."))
|
|
560
|
+
if click.confirm(__("Proceed with MCP configuration?"), default=True):
|
|
561
|
+
# Lazy import to avoid circular dependency at module level
|
|
562
|
+
from src.mcp_server import _run_install
|
|
563
|
+
_run_install("auto")
|
|
564
|
+
else:
|
|
565
|
+
click.echo(__("Skipped.\n"))
|
|
566
|
+
|
|
567
|
+
# ------------------------------------------------------------------
|
|
568
|
+
# Step 4: API Key Check
|
|
569
|
+
# ------------------------------------------------------------------
|
|
570
|
+
click.secho(__("\nStep 4 of 4: API Key Configuration"), fg="yellow", bold=True)
|
|
571
|
+
provider = get_ai_provider()
|
|
572
|
+
existing_key = get_api_key(provider)
|
|
573
|
+
if existing_key:
|
|
574
|
+
click.secho(
|
|
575
|
+
__("✅ API key for {provider} is already configured.", provider=provider.capitalize()),
|
|
576
|
+
fg="green",
|
|
577
|
+
)
|
|
578
|
+
else:
|
|
579
|
+
click.echo(__("No API key found for {provider}.", provider=provider.capitalize()))
|
|
580
|
+
if click.confirm(__("Would you like to configure it now?"), default=True):
|
|
581
|
+
setup_environment()
|
|
582
|
+
else:
|
|
583
|
+
click.echo(__("You can configure it later by running 'gitpr' or editing ~/.gitpr/.env manually."))
|
|
584
|
+
|
|
585
|
+
# ------------------------------------------------------------------
|
|
586
|
+
# Final: documentation URL
|
|
587
|
+
# ------------------------------------------------------------------
|
|
588
|
+
click.echo("")
|
|
589
|
+
click.secho(__("\n✅ Setup wizard complete!"), fg="green", bold=True)
|
|
590
|
+
click.echo(__("For more details, see the full documentation:"))
|
|
591
|
+
click.secho(f" {get_doc_url('install-wizard.md')}", fg="blue", underline=True)
|
|
592
|
+
click.echo("")
|
|
593
|
+
|
|
594
|
+
|
|
512
595
|
def get_branch_history_text():
|
|
513
596
|
"""Compiles the Git Log and PR Cache of the current branch to generate the epic context."""
|
|
514
597
|
branch = get_current_branch()
|
src/main.py
CHANGED
|
@@ -14,7 +14,8 @@ from src.core import (
|
|
|
14
14
|
generate_skill_template,
|
|
15
15
|
install_git_hooks,
|
|
16
16
|
get_branch_history_text,
|
|
17
|
-
get_doc_url
|
|
17
|
+
get_doc_url,
|
|
18
|
+
run_install_wizard,
|
|
18
19
|
)
|
|
19
20
|
from src.linter_engine import parse_diff_and_lint
|
|
20
21
|
from src.i18n import __
|
|
@@ -34,7 +35,7 @@ def print_banner():
|
|
|
34
35
|
"""
|
|
35
36
|
click.secho(banner, fg="cyan", bold=True)
|
|
36
37
|
click.secho(__(" 🚀 Intelligent PR Automation with AI (v{version})", version=__version__), fg="yellow", bold=True)
|
|
37
|
-
click.secho(__(" Options: -c,--commit | -r,--review | -f,--fullreview | -l,--linter | -s,--skill | -u,--update | -ih,--installhooks | -is,--issue | -h,--help (use -h --flag for contextual help)\n"), fg="white", dim=True)
|
|
38
|
+
click.secho(__(" Options: -c,--commit | -r,--review | -f,--fullreview | -l,--linter | -s,--skill | -u,--update | -ih,--installhooks | --install | -is,--issue | -h,--help (use -h --flag for contextual help)\n"), fg="white", dim=True)
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
# ============================================================
|
|
@@ -81,6 +82,11 @@ HELP_MAP: dict[str, dict[str, str]] = {
|
|
|
81
82
|
'title': __('Install Local Git Hooks'),
|
|
82
83
|
'description': __('Installs pre-commit (automatic static linter) and prepare-commit-msg (AI message generation) hooks in the local repository. Adopts the Shift Left practice for pre-push validation.'),
|
|
83
84
|
},
|
|
85
|
+
'install': {
|
|
86
|
+
'url': get_doc_url('install-wizard.md'),
|
|
87
|
+
'title': __('Interactive Setup Wizard (--install)'),
|
|
88
|
+
'description': __('Guided setup that downloads skill templates, installs Git hooks, configures MCP for your editors, and verifies your AI provider API key.'),
|
|
89
|
+
},
|
|
84
90
|
'blame': {
|
|
85
91
|
'url': get_doc_url('blame-arqueologo.md'),
|
|
86
92
|
'title': __('Code Archeologist (AI Git Blame)'),
|
|
@@ -120,6 +126,7 @@ HELP_PRIORITY: dict[str, int] = {
|
|
|
120
126
|
'skill': 2,
|
|
121
127
|
'update': 3,
|
|
122
128
|
'installhooks': 4,
|
|
129
|
+
'install': 14,
|
|
123
130
|
'issue': 5,
|
|
124
131
|
'blame': 6,
|
|
125
132
|
'commit': 7,
|
|
@@ -141,6 +148,7 @@ HELP_PRIORITY: dict[str, int] = {
|
|
|
141
148
|
@click.option('-s', '--skill', is_flag=True, help=__("Downloads the skill template files into the .gitpr/skill/ folder."))
|
|
142
149
|
@click.option('-u', '--update', is_flag=True, help=__("Checks and installs the latest version of GitPR."))
|
|
143
150
|
@click.option('-ih', '--installhooks', is_flag=True, help=__("Automatically installs validation Git Hooks in the project."))
|
|
151
|
+
@click.option('--install', is_flag=True, help=__("Interactive setup wizard: downloads templates, installs hooks, configures MCP, and checks API key."))
|
|
144
152
|
@click.option('--hook', type=click.Path(), hidden=True, help=__("Commit file path (internal hook use)."))
|
|
145
153
|
@click.option('-q', '--quiet', is_flag=True, hidden=True, help=__("Hides banner and non-essential logs (internal use)."))
|
|
146
154
|
@click.option('--pre-save', is_flag=True, hidden=True, help=__("Saves the full AI payload (system + prompt) to a JSON file before each AI call (debug)."))
|
|
@@ -151,8 +159,9 @@ HELP_PRIORITY: dict[str, int] = {
|
|
|
151
159
|
@click.option('-ch', '--chat', is_flag=True, help=__("Opens the interactive Pair Programming chat with AI."))
|
|
152
160
|
@click.option('-p', '--provider', type=click.Choice(['gemini', 'deepseek', 'ollama']), help=__("Forces the use of a specific AI provider for this execution."))
|
|
153
161
|
@click.option('--lang', type=str, help=__("Forces the interface language for this execution (e.g.: en_us, pt_br)."))
|
|
162
|
+
@click.option('--mcp', is_flag=True, hidden=True, help=__("Start the MCP server for integration with VS Code, Cursor, Claude Desktop, etc."))
|
|
154
163
|
@click.option('-h', '--help', 'help_flag', is_flag=True, help=__("Shows this message and exits. Use with another flag for contextual help (e.g., -h --issue)."))
|
|
155
|
-
def cli(commit, review, fullreview, linter, skill, update, installhooks, hook, quiet, pre_save, provider, input, blame, history, issue, chat, help_flag, lang):
|
|
164
|
+
def cli(commit, review, fullreview, linter, skill, update, installhooks, install, hook, quiet, pre_save, provider, input, blame, history, issue, chat, help_flag, lang, mcp):
|
|
156
165
|
"""
|
|
157
166
|
GitPR CLI - Intelligent PR Automation and AI Code Review.
|
|
158
167
|
|
|
@@ -221,6 +230,12 @@ def cli(commit, review, fullreview, linter, skill, update, installhooks, hook, q
|
|
|
221
230
|
set_lang(lang)
|
|
222
231
|
reload_thinking_words(lang)
|
|
223
232
|
|
|
233
|
+
# MCP Server Mode — start stdio MCP server (handled before any interactive setup)
|
|
234
|
+
if mcp:
|
|
235
|
+
from src.mcp_server import main as mcp_main
|
|
236
|
+
mcp_main()
|
|
237
|
+
return
|
|
238
|
+
|
|
224
239
|
# Silencia o banner se estiver no modo quiet ou via hook
|
|
225
240
|
if not quiet and not hook:
|
|
226
241
|
print_banner()
|
|
@@ -287,6 +302,11 @@ def cli(commit, review, fullreview, linter, skill, update, installhooks, hook, q
|
|
|
287
302
|
check_and_update()
|
|
288
303
|
return
|
|
289
304
|
|
|
305
|
+
# --install option: Interactive setup wizard
|
|
306
|
+
if install:
|
|
307
|
+
run_install_wizard()
|
|
308
|
+
return
|
|
309
|
+
|
|
290
310
|
# --skill option: Generate template and exit
|
|
291
311
|
if skill:
|
|
292
312
|
generate_skill_template()
|