gitpr-cli 0.0.21__tar.gz → 0.0.23__tar.gz

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.
Files changed (29) hide show
  1. {gitpr_cli-0.0.21/gitpr_cli.egg-info → gitpr_cli-0.0.23}/PKG-INFO +15 -1
  2. gitpr_cli-0.0.21/PKG-INFO → gitpr_cli-0.0.23/README.md +234 -238
  3. gitpr_cli-0.0.21/README.md → gitpr_cli-0.0.23/gitpr_cli.egg-info/PKG-INFO +252 -220
  4. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/pyproject.toml +1 -1
  5. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/ai_providers.py +1 -0
  6. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/cache.py +2 -0
  7. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/core.py +21 -3
  8. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/i18n.py +14 -4
  9. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/updater.py +6 -7
  10. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/LICENSE +0 -0
  11. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/gitpr_cli.egg-info/SOURCES.txt +0 -0
  12. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/gitpr_cli.egg-info/dependency_links.txt +0 -0
  13. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/gitpr_cli.egg-info/entry_points.txt +0 -0
  14. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/gitpr_cli.egg-info/requires.txt +0 -0
  15. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/gitpr_cli.egg-info/top_level.txt +0 -0
  16. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/setup.cfg +0 -0
  17. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/__init__.py +0 -0
  18. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/blame_engine.py +0 -0
  19. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/config.py +0 -0
  20. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/issue_engine.py +0 -0
  21. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/linter_engine.py +0 -0
  22. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/main.py +0 -0
  23. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/security.py +0 -0
  24. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/spinner.py +0 -0
  25. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/tui_issue.py +0 -0
  26. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/ui/__init__.py +0 -0
  27. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/ui/help_screen.py +0 -0
  28. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/src/ui/issue_app.py +0 -0
  29. {gitpr_cli-0.0.21 → gitpr_cli-0.0.23}/tests/test_core.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitpr-cli
3
- Version: 0.0.21
3
+ Version: 0.0.23
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
@@ -179,6 +179,20 @@ Instead of hiding AI instructions in the source code, GitPR uses local Markdown
179
179
  * `.gitpr.issue.md`: Defines the structure and level of detail required for generating standardized Issues (used with `--issue`).
180
180
  * `.gitpr.blame.md`: Defines the focus of archaeological analysis for legacy code tracing (used with `--blame`).
181
181
 
182
+ ## 🌐 Internationalization (i18n)
183
+
184
+ GitPR automatically detects your system language and displays messages in your native language. The i18n system is inspired by **Laravel's `__()` helper**:
185
+
186
+ * **Auto-detection:** On first run, GitPR detects your OS language and saves it to `~/.gitpr/.env` (`GITPR_LANG`).
187
+ * **Translation files:** Language packs are downloaded automatically from the official repository to `~/.gitpr/langs/`.
188
+ * **English fallback:** If a translation is missing, the English text is displayed directly.
189
+ * **Developer API:** Use `from src.i18n import __` and wrap all user-facing strings with `__("Your text here")`.
190
+ * **Placeholders:** Supports named parameters — `__("Downloading {file}...", file="template.md")`.
191
+
192
+ To force a specific language, set `GITPR_LANG=pt_br` or `GITPR_LANG=en` in `~/.gitpr/.env`.
193
+
194
+ > 📖 **Full developer guide:** [docs/i18n_explanation.md](docs/i18n_explanation.md) — architecture, usage patterns, circular import precautions, and how to add new languages.
195
+
182
196
  ## 📚 Technical Documentation and Advanced Guides
183
197
 
184
198
  To keep this README concise, we detail the most advanced **DevOps** and **Continuous Integration** focused implementations in separate documents.
@@ -1,238 +1,234 @@
1
- Metadata-Version: 2.4
2
- Name: gitpr-cli
3
- Version: 0.0.21
4
- Summary: Automação de PRs, Commits e Code Review com IA (Gemini e DeepSeek)
5
- Author-email: Natan Fiuza <contato@natanfiuza.dev.br>
6
- Requires-Python: >=3.10
7
- Description-Content-Type: text/markdown
8
- License-File: LICENSE
9
- Requires-Dist: click>=8.0.0
10
- Requires-Dist: google-genai
11
- Requires-Dist: openai
12
- Requires-Dist: python-dotenv
13
- Requires-Dist: cryptography
14
- Requires-Dist: pyyaml
15
- Requires-Dist: textual
16
- Requires-Dist: requests
17
- Dynamic: license-file
18
-
19
- # **GitPR CLI 🚀**
20
-
21
- 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.
22
-
23
- ## **🛠️ Technologies and Libraries Used**
24
-
25
- This project was developed in Python and uses the following main libraries:
26
-
27
- * [**Click**](https://click.palletsprojects.com/): To create a robust and user-friendly command-line interface (CLI).
28
- * [**Google GenAI**](https://pypi.org/project/google-genai/): Official SDK for direct integration with the Gemini API.
29
- * [**OpenAI**](https://pypi.org/project/openai/): Library used due to its full compatibility with the powerful **DeepSeek** API.
30
- * [**Python-dotenv**](https://pypi.org/project/python-dotenv/): For secure environment variable management.
31
- * [**Pytest**](https://docs.pytest.org/): For running unit tests in a simple, colorful, and readable way in the console.
32
- * [**Cryptography**](https://cryptography.io/): To ensure your `GEMINI_API_KEY` is stored encrypted and securely on disk.
33
- * [**PyYAML**](https://pyyaml.org/): Used to read and process the custom static analysis rules from the `.gitpr.linter.yml` file.
34
- * [**Textual**](https://textual.textualize.io/): Powerful library for creating Terminal Graphical Interfaces (TUI), used in the interactive issue generation and editing panel.
35
- * [**Requests**](https://pypi.org/project/requests/): Elegant and robust library for HTTP requests, used to communicate with the GitHub REST API.
36
-
37
- ----
38
-
39
- ## 📦 How to Compile the Executable Locally
40
-
41
- If you want to generate your own binary from the source code, we use **PyInstaller**. Make sure you are in the project root directory with the virtual environment configured.
42
-
43
- 1. Install development dependencies (if you haven't already):
44
- ```bash
45
- pipenv install --dev
46
- ```
47
-
48
- 2. Run the build command pointing to our entry point (`run.py`):
49
- ```bash
50
- pipenv run pyinstaller --noconfirm --onefile --icon=icon.ico --name gitpr run.py
51
- ```
52
- > **Technical note:** The `--onefile` flag ensures all Python, libraries, and dependencies are compressed into a single binary, while `--paths src` helps the compiler find our `core.py` and `config.py` files. 🛠️
53
-
54
- After running this command, PyInstaller will create some folders (`build` and `dist`).
55
- Your final ready-to-use file will be inside the **`dist/`** folder named `gitpr` (or `gitpr.exe` on Windows).
56
-
57
-
58
- ----
59
-
60
- ## 🧪 Running Tests
61
-
62
- To ensure the Git capture logic and AI integration are working correctly, we use unit tests.
63
-
64
- 1. Install test dependencies (if you haven't already):
65
- ```bash
66
- pipenv install --dev pytest
67
- ```
68
-
69
- 2. Run the tests with the command:
70
- ```bash
71
- pipenv run pytest -v
72
- ```
73
- Pytest will automatically detect files inside the `tests/` folder and display a detailed execution report.
74
-
75
- ----
76
- ## **⚙️ Installation and Configuration**
77
-
78
- ### **Using the Executable (Recommended)**
79
-
80
- 1. Download the gitpr executable file from the "Releases" tab on GitHub.
81
- 2. Move the executable to a folder that is in your PATH (e.g.: /usr/local/bin on Linux/Mac or your user folder on Windows).
82
- 3. On the first run, the wizard will guide you:
83
- ```bash
84
- $ gitpr
85
- ```
86
- ```bash
87
- 🚀 Intelligent PR Automation with AI
88
-
89
- 🔧 First run detected! Let's configure GitPR CLI.
90
-
91
- 🔑 Enter your GEMINI_API_KEY:
92
-
93
- 📄 Default output filename pattern [{branch}_{datetime}_PR_DESC.md]:
94
- ```
95
- *Note: Your configuration will be securely saved in the `~/.gitpr/.env` file.*
96
-
97
- > **🔒 Security Note:** GitPR CLI uses symmetric encryption (Fernet). Your API key is stored as a hash in the `.env` file, and the master key for decryption is automatically generated in `~/.gitpr/secret.key`. **Never share your secret.key file.**
98
-
99
- ### From Source Code
100
-
101
- 1. Clone the repository: `git clone https://github.com/natanfiuza/gitpr.git`
102
-
103
- 2. Enter the folder: `cd gitpr`
104
-
105
- 3. Set up the environment:
106
- ```bash
107
- pipenv install google-genai openai python-dotenv click cryptography
108
- ```
109
- 4. Run: pipenv run python src/main.py
110
-
111
- ## **💻 How to Use**
112
-
113
- GitPR has a powerful default behavior and several advanced options to assist you in your day-to-day as a developer.
114
-
115
- ### **Default Behavior (Pull Request)**
116
- Simply run the bare command in your terminal:
117
- ```bash
118
- gitpr
119
- ```
120
- The tool will sync with the remote (`git fetch`), compare your changes with the remote main branch (e.g.: `origin/main`), and generate a Markdown file (e.g.: `feature-login_20260421110134_PR_DESC.md`) at the root of your project with the complete suggestion for your Pull Request.
121
-
122
- ### **Advanced Options and Commands**
123
- You can pass the following *flags* for specific actions:
124
-
125
- * `-c` or `--commit`: Runs a local `git diff` and displays **only the suggested commit message**.
126
- * `-r` or `--review`: Performs a detailed **Code Review** of local changes.
127
- * `-f` or `--fullreview`: Performs a **Full Code Review** analyzing all changes since the remote branch.
128
- * `-i <file>` or `--input <file>`: **Full File Audit.** Must be used together with `-r` or `-f`; it ignores git history and does a Code Review of the entire file. Excellent for acting as a consultant on legacy code refactoring.
129
- * `--provider <gemini|deepseek>`: Forces the use of a specific AI only for this execution, ignoring your default saved in `.env`.
130
- * `-l` or `--linter`: Runs **only the local static linter** (no AI calls). Ideal for use in CI/CD pipelines to block non-compliant code.
131
- * `-ih` or `--installhooks`: Automatically installs **local Git Hooks** (`pre-commit` and `prepare-commit-msg`) in your repository.
132
- * `-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.
133
- * `-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:
134
- * **New Code Issue (`gitpr -is`):** Reads the current `git diff`. **Why use:** Ideal for quickly documenting the task you just finished programming, before committing.
135
- * **Epic/Release Issue (`gitpr -is -ht`):** Reads the full history of the current branch (Git Log + PR Cache). **Why use:** Ideal for generating consolidated documentation of an entire release or a large *feature* that took several days/commits to complete.
136
- * **Archaeological/Technical Debt Issue (`gitpr -is -b file:lines`):** Reads the timeline of a specific business rule. **Why use:** Ideal for documenting technical debt, explaining how a legacy code block evolved and why it needs to be refactored.
137
- * `-h` or `--help`: Shows the general help with all options. Use together with another flag for **contextual help** (e.g.: `gitpr -h --issue`, `gitpr -h --linter`) with a direct link to the detailed documentation of each feature.
138
- * `-u` or `--update`: Checks and installs the latest version of GitPR (Auto-Updater).
139
-
140
- > **⚙️ Technical Note (--hook):** GitPR has a hidden flag `--hook <file>` that is triggered exclusively by the Git Hooks system in the background. It allows the AI to inject the suggested message directly into Git's temporary file, without cluttering your terminal.
141
-
142
- ## 🛡️ Local Linter (Static Analysis)
143
-
144
- GitPR CLI allows you to define strict rules that will be validated instantly during `--review` or `--fullreview`, without depending on AI. This is ideal for preventing common errors (like `console.log` or test IPs) from reaching the repository.
145
-
146
- ### How to configure `.gitpr.linter.yml`:
147
- When running `gitpr --skill`, a template will be generated. You can configure rules using Regular Expressions (Regex):
148
-
149
- ```yaml
150
- rules:
151
- - name: "check-localhost"
152
- extensions: ["js", "php"] # Extensions to be validated
153
- regex: 'http(s)?://(localhost|127\.0\.0\.1)' # What to look for
154
- message: "🚨 Localhost usage detected in file {file_name}"
155
- ignore_comments: true # Ignores if the line is commented
156
- ignore_paths: # Folders or files ignored (accepts *)
157
- - "vendor/*"
158
- - "node_modules/*"
159
- ```
160
-
161
- The Linter analyzes only the **added lines** in your `git diff`, ensuring a focused and extremely fast execution. If there are violations, they will appear highlighted at the top of your review file.
162
-
163
- ## 🧠 Multi-Model Architecture (AI-Agnostic)
164
-
165
- GitPR is not tied to a single Artificial Intelligence. During initial setup, the user can choose their default engine. We currently support:
166
- * **Google Gemini** (Default: `gemini-2.5-flash`)
167
- * **DeepSeek** (Default: `deepseek-chat`)
168
-
169
- You can dynamically switch models by configuring the `GEMINI_API_MODEL` or `DEEPSEEK_API_MODEL` variables in your `~/.gitpr/.env` file, or switch in real-time using the `--provider` flag.
170
-
171
- ## 🎯 Customizable "Skills" System (Prompt Engineering)
172
-
173
- Instead of hiding AI instructions in the source code, GitPR uses local Markdown files that act as *System Instructions*. When running `gitpr -s`, the following files are generated at the root of your project to customize the AI's "persona" according to your company's business rules:
174
-
175
- * `.gitpr.commit.md`: Rules for generating short commit messages.
176
- * `.gitpr.pr.md`: Required topic structure for the Pull Request description.
177
- * `.gitpr.review.md`: Defines the architectural focus (e.g.: SOLID, Clean Code) for diff analysis.
178
- * `.gitpr.filereview.md`: Defines strict cohesion and coupling rules for full file auditing (used with `--input`).
179
- * `.gitpr.issue.md`: Defines the structure and level of detail required for generating standardized Issues (used with `--issue`).
180
- * `.gitpr.blame.md`: Defines the focus of archaeological analysis for legacy code tracing (used with `--blame`).
181
-
182
- ## 📚 Technical Documentation and Advanced Guides
183
-
184
- To keep this README concise, we detail the most advanced **DevOps** and **Continuous Integration** focused implementations in separate documents.
185
-
186
- If you want to implement GitPR as an automated quality barrier in your team, check out the guides below:
187
-
188
- * [**Local Git Hooks (Shift-Left)**](docs/git-hooks-locais.md): How to use `gitpr --installhooks` to create guardrails on the developer's machine and use AI to automatically write commit messages.
189
- * [**Customizable Static Linter**](docs/linter-regras-customizadas.md): How to create validation rules in `.gitpr.linter.yml` for CI/CD and pre-commit hooks.
190
- * [**Issue Generation and TUI Interface**](docs/issue-tui-help.md): How to use the terminal graphical interface (TUI) and the 3 context engines to manage structured Issues.
191
- * [**AI Code Review**](docs/code-review-ia.md): Guide to review modes (`--review`, `--fullreview`) and file auditing (`--input`).
192
- * [**AI Commit Messages**](docs/commit-message-ia.md): How to generate messages in the Conventional Commits standard and integrate with Git Hooks.
193
- * [**Code Archaeologist (Git Blame)**](docs/blame-arqueologo.md): How to trace the origin of business rules with `git blame` and AI.
194
- * [**Skills and Templates System**](docs/skill-template.md): How to customize AI behavior with `.gitpr.*.md` files.
195
- * [**Auto-Updater**](docs/auto-update.md): How GitPR's automatic update (hot-swap) works.
196
- * [**AI Providers**](docs/providers-ia.md): Configuration and selection between Google Gemini and DeepSeek.
197
- * [**Pull Request (Default Mode)**](docs/pr-descricao-padrao.md): Complete flow for generating PR descriptions without flags.
198
- * [**CI/CD Integration (GitHub Actions)**](docs/github-ci-linter.md): How to run GitPR in the pipeline to block "Merge" of PRs with violations.
199
- * [**GitHub Token (PAT) Integration and Security**](docs/github-pat-integration.md): Understand how GitPR creates issues directly in the repository with authentication.
200
-
201
- ## ⚡ Local Cache System (Quota Savings)
202
-
203
- GitPR has an intelligent **MD5**-based cache engine. Whenever you run a command (`--review`, `--commit`, etc.), the tool generates an exact hash of your current code (diff) and instructions.
204
- If you run the same command again without changing the code, GitPR intercepts the request and returns the result instantly (in milliseconds) from the `~/.gitpr/cache/prompts/` folder, saving you time and your Gemini API quotas!
205
-
206
- ## 🔄 Auto-Updater (Over-The-Air Update)
207
-
208
- Never worry about manually downloading new versions again. GitPR has a Connection Guardian and a built-in updater:
209
- * It checks network availability before starting so it doesn't block your offline workflow.
210
- * On each execution, it silently checks if there is a new official release on the GitHub API.
211
- * You can force the check and installation by running `gitpr --update` or `gitpr -u`.
212
- * The tool uses the *Hot-Swap* technique, downloading the new `.exe` and transparently replacing the old version.
213
-
214
- ## Publishing to PyPI
215
-
216
- ```bash
217
- pipenv run python -m build
218
- pipenv run twine upload dist/*
219
- ```
220
- ## **🤝 How to Contribute**
221
-
222
- Contributions are very welcome! To contribute:
223
-
224
- 1. Fork the project.
225
- 2. Create a branch for your *feature* (git checkout -b feature/NewFeature).
226
- 3. Commit your changes (git commit -m 'feat: add new feature'). Tip: Use GitPR itself to generate this message! 😄
227
- 4. Push to the branch (git push origin feature/NewFeature).
228
- 5. Open a Pull Request.
229
-
230
- ## **✨ Acknowledgments and Authorship**
231
-
232
- Project conceived and developed by:
233
-
234
- **Natan Fiuza** - [contato@natanfiuza.dev.br](mailto:contato@natanfiuza.dev.br)
235
-
236
- ## **📄 License**
237
-
238
- This project is licensed under the **GNU Lesser General Public License v2.1 (LGPL-2.1)**. See the LICENSE file for more details.
1
+ # **GitPR CLI 🚀**
2
+
3
+ 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.
4
+
5
+ ## **🛠️ Technologies and Libraries Used**
6
+
7
+ This project was developed in Python and uses the following main libraries:
8
+
9
+ * [**Click**](https://click.palletsprojects.com/): To create a robust and user-friendly command-line interface (CLI).
10
+ * [**Google GenAI**](https://pypi.org/project/google-genai/): Official SDK for direct integration with the Gemini API.
11
+ * [**OpenAI**](https://pypi.org/project/openai/): Library used due to its full compatibility with the powerful **DeepSeek** API.
12
+ * [**Python-dotenv**](https://pypi.org/project/python-dotenv/): For secure environment variable management.
13
+ * [**Pytest**](https://docs.pytest.org/): For running unit tests in a simple, colorful, and readable way in the console.
14
+ * [**Cryptography**](https://cryptography.io/): To ensure your `GEMINI_API_KEY` is stored encrypted and securely on disk.
15
+ * [**PyYAML**](https://pyyaml.org/): Used to read and process the custom static analysis rules from the `.gitpr.linter.yml` file.
16
+ * [**Textual**](https://textual.textualize.io/): Powerful library for creating Terminal Graphical Interfaces (TUI), used in the interactive issue generation and editing panel.
17
+ * [**Requests**](https://pypi.org/project/requests/): Elegant and robust library for HTTP requests, used to communicate with the GitHub REST API.
18
+
19
+ ----
20
+
21
+ ## 📦 How to Compile the Executable Locally
22
+
23
+ If you want to generate your own binary from the source code, we use **PyInstaller**. Make sure you are in the project root directory with the virtual environment configured.
24
+
25
+ 1. Install development dependencies (if you haven't already):
26
+ ```bash
27
+ pipenv install --dev
28
+ ```
29
+
30
+ 2. Run the build command pointing to our entry point (`run.py`):
31
+ ```bash
32
+ pipenv run pyinstaller --noconfirm --onefile --icon=icon.ico --name gitpr run.py
33
+ ```
34
+ > **Technical note:** The `--onefile` flag ensures all Python, libraries, and dependencies are compressed into a single binary, while `--paths src` helps the compiler find our `core.py` and `config.py` files. 🛠️
35
+
36
+ After running this command, PyInstaller will create some folders (`build` and `dist`).
37
+ Your final ready-to-use file will be inside the **`dist/`** folder named `gitpr` (or `gitpr.exe` on Windows).
38
+
39
+
40
+ ----
41
+
42
+ ## 🧪 Running Tests
43
+
44
+ To ensure the Git capture logic and AI integration are working correctly, we use unit tests.
45
+
46
+ 1. Install test dependencies (if you haven't already):
47
+ ```bash
48
+ pipenv install --dev pytest
49
+ ```
50
+
51
+ 2. Run the tests with the command:
52
+ ```bash
53
+ pipenv run pytest -v
54
+ ```
55
+ Pytest will automatically detect files inside the `tests/` folder and display a detailed execution report.
56
+
57
+ ----
58
+ ## **⚙️ Installation and Configuration**
59
+
60
+ ### **Using the Executable (Recommended)**
61
+
62
+ 1. Download the gitpr executable file from the "Releases" tab on GitHub.
63
+ 2. Move the executable to a folder that is in your PATH (e.g.: /usr/local/bin on Linux/Mac or your user folder on Windows).
64
+ 3. On the first run, the wizard will guide you:
65
+ ```bash
66
+ $ gitpr
67
+ ```
68
+ ```bash
69
+ 🚀 Intelligent PR Automation with AI
70
+
71
+ 🔧 First run detected! Let's configure GitPR CLI.
72
+
73
+ 🔑 Enter your GEMINI_API_KEY:
74
+
75
+ 📄 Default output filename pattern [{branch}_{datetime}_PR_DESC.md]:
76
+ ```
77
+ *Note: Your configuration will be securely saved in the `~/.gitpr/.env` file.*
78
+
79
+ > **🔒 Security Note:** GitPR CLI uses symmetric encryption (Fernet). Your API key is stored as a hash in the `.env` file, and the master key for decryption is automatically generated in `~/.gitpr/secret.key`. **Never share your secret.key file.**
80
+
81
+ ### From Source Code
82
+
83
+ 1. Clone the repository: `git clone https://github.com/natanfiuza/gitpr.git`
84
+
85
+ 2. Enter the folder: `cd gitpr`
86
+
87
+ 3. Set up the environment:
88
+ ```bash
89
+ pipenv install google-genai openai python-dotenv click cryptography
90
+ ```
91
+ 4. Run: pipenv run python src/main.py
92
+
93
+ ## **💻 How to Use**
94
+
95
+ GitPR has a powerful default behavior and several advanced options to assist you in your day-to-day as a developer.
96
+
97
+ ### **Default Behavior (Pull Request)**
98
+ Simply run the bare command in your terminal:
99
+ ```bash
100
+ gitpr
101
+ ```
102
+ The tool will sync with the remote (`git fetch`), compare your changes with the remote main branch (e.g.: `origin/main`), and generate a Markdown file (e.g.: `feature-login_20260421110134_PR_DESC.md`) at the root of your project with the complete suggestion for your Pull Request.
103
+
104
+ ### **Advanced Options and Commands**
105
+ You can pass the following *flags* for specific actions:
106
+
107
+ * `-c` or `--commit`: Runs a local `git diff` and displays **only the suggested commit message**.
108
+ * `-r` or `--review`: Performs a detailed **Code Review** of local changes.
109
+ * `-f` or `--fullreview`: Performs a **Full Code Review** analyzing all changes since the remote branch.
110
+ * `-i <file>` or `--input <file>`: **Full File Audit.** Must be used together with `-r` or `-f`; it ignores git history and does a Code Review of the entire file. Excellent for acting as a consultant on legacy code refactoring.
111
+ * `--provider <gemini|deepseek>`: Forces the use of a specific AI only for this execution, ignoring your default saved in `.env`.
112
+ * `-l` or `--linter`: Runs **only the local static linter** (no AI calls). Ideal for use in CI/CD pipelines to block non-compliant code.
113
+ * `-ih` or `--installhooks`: Automatically installs **local Git Hooks** (`pre-commit` and `prepare-commit-msg`) in your repository.
114
+ * `-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.
115
+ * `-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:
116
+ * **New Code Issue (`gitpr -is`):** Reads the current `git diff`. **Why use:** Ideal for quickly documenting the task you just finished programming, before committing.
117
+ * **Epic/Release Issue (`gitpr -is -ht`):** Reads the full history of the current branch (Git Log + PR Cache). **Why use:** Ideal for generating consolidated documentation of an entire release or a large *feature* that took several days/commits to complete.
118
+ * **Archaeological/Technical Debt Issue (`gitpr -is -b file:lines`):** Reads the timeline of a specific business rule. **Why use:** Ideal for documenting technical debt, explaining how a legacy code block evolved and why it needs to be refactored.
119
+ * `-h` or `--help`: Shows the general help with all options. Use together with another flag for **contextual help** (e.g.: `gitpr -h --issue`, `gitpr -h --linter`) with a direct link to the detailed documentation of each feature.
120
+ * `-u` or `--update`: Checks and installs the latest version of GitPR (Auto-Updater).
121
+
122
+ > **⚙️ Technical Note (--hook):** GitPR has a hidden flag `--hook <file>` that is triggered exclusively by the Git Hooks system in the background. It allows the AI to inject the suggested message directly into Git's temporary file, without cluttering your terminal.
123
+
124
+ ## 🛡️ Local Linter (Static Analysis)
125
+
126
+ GitPR CLI allows you to define strict rules that will be validated instantly during `--review` or `--fullreview`, without depending on AI. This is ideal for preventing common errors (like `console.log` or test IPs) from reaching the repository.
127
+
128
+ ### How to configure `.gitpr.linter.yml`:
129
+ When running `gitpr --skill`, a template will be generated. You can configure rules using Regular Expressions (Regex):
130
+
131
+ ```yaml
132
+ rules:
133
+ - name: "check-localhost"
134
+ extensions: ["js", "php"] # Extensions to be validated
135
+ regex: 'http(s)?://(localhost|127\.0\.0\.1)' # What to look for
136
+ message: "🚨 Localhost usage detected in file {file_name}"
137
+ ignore_comments: true # Ignores if the line is commented
138
+ ignore_paths: # Folders or files ignored (accepts *)
139
+ - "vendor/*"
140
+ - "node_modules/*"
141
+ ```
142
+
143
+ The Linter analyzes only the **added lines** in your `git diff`, ensuring a focused and extremely fast execution. If there are violations, they will appear highlighted at the top of your review file.
144
+
145
+ ## 🧠 Multi-Model Architecture (AI-Agnostic)
146
+
147
+ GitPR is not tied to a single Artificial Intelligence. During initial setup, the user can choose their default engine. We currently support:
148
+ * **Google Gemini** (Default: `gemini-2.5-flash`)
149
+ * **DeepSeek** (Default: `deepseek-chat`)
150
+
151
+ You can dynamically switch models by configuring the `GEMINI_API_MODEL` or `DEEPSEEK_API_MODEL` variables in your `~/.gitpr/.env` file, or switch in real-time using the `--provider` flag.
152
+
153
+ ## 🎯 Customizable "Skills" System (Prompt Engineering)
154
+
155
+ Instead of hiding AI instructions in the source code, GitPR uses local Markdown files that act as *System Instructions*. When running `gitpr -s`, the following files are generated at the root of your project to customize the AI's "persona" according to your company's business rules:
156
+
157
+ * `.gitpr.commit.md`: Rules for generating short commit messages.
158
+ * `.gitpr.pr.md`: Required topic structure for the Pull Request description.
159
+ * `.gitpr.review.md`: Defines the architectural focus (e.g.: SOLID, Clean Code) for diff analysis.
160
+ * `.gitpr.filereview.md`: Defines strict cohesion and coupling rules for full file auditing (used with `--input`).
161
+ * `.gitpr.issue.md`: Defines the structure and level of detail required for generating standardized Issues (used with `--issue`).
162
+ * `.gitpr.blame.md`: Defines the focus of archaeological analysis for legacy code tracing (used with `--blame`).
163
+
164
+ ## 🌐 Internationalization (i18n)
165
+
166
+ GitPR automatically detects your system language and displays messages in your native language. The i18n system is inspired by **Laravel's `__()` helper**:
167
+
168
+ * **Auto-detection:** On first run, GitPR detects your OS language and saves it to `~/.gitpr/.env` (`GITPR_LANG`).
169
+ * **Translation files:** Language packs are downloaded automatically from the official repository to `~/.gitpr/langs/`.
170
+ * **English fallback:** If a translation is missing, the English text is displayed directly.
171
+ * **Developer API:** Use `from src.i18n import __` and wrap all user-facing strings with `__("Your text here")`.
172
+ * **Placeholders:** Supports named parameters — `__("Downloading {file}...", file="template.md")`.
173
+
174
+ To force a specific language, set `GITPR_LANG=pt_br` or `GITPR_LANG=en` in `~/.gitpr/.env`.
175
+
176
+ > 📖 **Full developer guide:** [docs/i18n_explanation.md](docs/i18n_explanation.md) architecture, usage patterns, circular import precautions, and how to add new languages.
177
+
178
+ ## 📚 Technical Documentation and Advanced Guides
179
+
180
+ To keep this README concise, we detail the most advanced **DevOps** and **Continuous Integration** focused implementations in separate documents.
181
+
182
+ If you want to implement GitPR as an automated quality barrier in your team, check out the guides below:
183
+
184
+ * [**Local Git Hooks (Shift-Left)**](docs/git-hooks-locais.md): How to use `gitpr --installhooks` to create guardrails on the developer's machine and use AI to automatically write commit messages.
185
+ * [**Customizable Static Linter**](docs/linter-regras-customizadas.md): How to create validation rules in `.gitpr.linter.yml` for CI/CD and pre-commit hooks.
186
+ * [**Issue Generation and TUI Interface**](docs/issue-tui-help.md): How to use the terminal graphical interface (TUI) and the 3 context engines to manage structured Issues.
187
+ * [**AI Code Review**](docs/code-review-ia.md): Guide to review modes (`--review`, `--fullreview`) and file auditing (`--input`).
188
+ * [**AI Commit Messages**](docs/commit-message-ia.md): How to generate messages in the Conventional Commits standard and integrate with Git Hooks.
189
+ * [**Code Archaeologist (Git Blame)**](docs/blame-arqueologo.md): How to trace the origin of business rules with `git blame` and AI.
190
+ * [**Skills and Templates System**](docs/skill-template.md): How to customize AI behavior with `.gitpr.*.md` files.
191
+ * [**Auto-Updater**](docs/auto-update.md): How GitPR's automatic update (hot-swap) works.
192
+ * [**AI Providers**](docs/providers-ia.md): Configuration and selection between Google Gemini and DeepSeek.
193
+ * [**Pull Request (Default Mode)**](docs/pr-descricao-padrao.md): Complete flow for generating PR descriptions without flags.
194
+ * [**CI/CD Integration (GitHub Actions)**](docs/github-ci-linter.md): How to run GitPR in the pipeline to block "Merge" of PRs with violations.
195
+ * [**GitHub Token (PAT) Integration and Security**](docs/github-pat-integration.md): Understand how GitPR creates issues directly in the repository with authentication.
196
+
197
+ ## Local Cache System (Quota Savings)
198
+
199
+ GitPR has an intelligent **MD5**-based cache engine. Whenever you run a command (`--review`, `--commit`, etc.), the tool generates an exact hash of your current code (diff) and instructions.
200
+ If you run the same command again without changing the code, GitPR intercepts the request and returns the result instantly (in milliseconds) from the `~/.gitpr/cache/prompts/` folder, saving you time and your Gemini API quotas!
201
+
202
+ ## 🔄 Auto-Updater (Over-The-Air Update)
203
+
204
+ Never worry about manually downloading new versions again. GitPR has a Connection Guardian and a built-in updater:
205
+ * It checks network availability before starting so it doesn't block your offline workflow.
206
+ * On each execution, it silently checks if there is a new official release on the GitHub API.
207
+ * You can force the check and installation by running `gitpr --update` or `gitpr -u`.
208
+ * The tool uses the *Hot-Swap* technique, downloading the new `.exe` and transparently replacing the old version.
209
+
210
+ ## Publishing to PyPI
211
+
212
+ ```bash
213
+ pipenv run python -m build
214
+ pipenv run twine upload dist/*
215
+ ```
216
+ ## **🤝 How to Contribute**
217
+
218
+ Contributions are very welcome! To contribute:
219
+
220
+ 1. Fork the project.
221
+ 2. Create a branch for your *feature* (git checkout -b feature/NewFeature).
222
+ 3. Commit your changes (git commit -m 'feat: add new feature'). Tip: Use GitPR itself to generate this message! 😄
223
+ 4. Push to the branch (git push origin feature/NewFeature).
224
+ 5. Open a Pull Request.
225
+
226
+ ## **✨ Acknowledgments and Authorship**
227
+
228
+ Project conceived and developed by:
229
+
230
+ **Natan Fiuza** - [contato@natanfiuza.dev.br](mailto:contato@natanfiuza.dev.br)
231
+
232
+ ## **📄 License**
233
+
234
+ This project is licensed under the **GNU Lesser General Public License v2.1 (LGPL-2.1)**. See the LICENSE file for more details.