gitai-tool


Namegitai-tool JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryGenerate summaries and code reviews for GitLab Merge Requests or GitHub Pull Requests using LLM
upload_time2025-08-10 19:47:59
maintainerNone
docs_urlNone
authorAleksandar Farkov
requires_python>=3.8
licenseMIT
keywords git gitlab github merge-requests pull-requests cli llm ai summaries code-review
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GitLab Merge Request Summary Generator

This command-line tool generates a "What's New" summary for a GitLab Merge Request. It uses the GitLab API to fetch technical details (like commit messages and code changes) and then leverages the Google Gemini API to translate them into a clear, benefit-oriented summary suitable for non-technical clients.

## Features

-   Fetches Merge Request details, commit history, and code diffs from GitLab.
-   Uses the Gemini API to generate an intelligent, human-readable summary.
-   Formats the output in Markdown with "New Features" and "Bug Fixes" sections.
-   Creates client-friendly language by focusing on benefits, not technical jargon.
-   Includes a debug mode to inspect the exact prompt sent to the AI.

## Prerequisites

Before you begin, ensure you have the following:

-   Python 3.8+
-   A GitLab account with access to the target project.
-   A [GitLab Personal Access Token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) with `api` scope.
-   A [Google Gemini API Key](https://ai.google.dev/gemini-api/docs/api-key).

## Installation

### Install with pipx (recommended)

Install from PyPI and get the global command `gitai-tool`:

```bash
pipx install gitai-tool
gitai-tool --help
```

To upgrade later:

```bash
pipx upgrade gitai-tool
```

### Install with pip (alternative)

```bash
pip install gitai-tool
gitai-tool --help
```

### Persisting configuration (TOML)

When required values are missing, the tool will prompt you interactively and then persist them to `~/.gitai-tool/config.toml` automatically. Subsequent runs will load values from the config file. Precedence matches AWS CLI: command-line flags > environment variables > config file. Example `config.toml`:

```toml
GITLAB_URL = "https://gitlab.com"
GITLAB_PRIVATE_TOKEN = "<your_token>"
GITLAB_PROJECT_ID = "<project_id>"
GEMINI_API_KEY = "<gemini_api_key>"
```

## Usage

After installation with `pipx` or `pip`, use the global command `gitai-tool`. The tool provides two main commands: `summarize` and `code-review`.

Common flags available to all commands:

-   `--gitlab-url`, `--gitlab-private-token`, `--gitlab-project-id`, `--gemini-api-key`
-   `--model`: Gemini model identifier. Defaults to `gemini-2.5-flash`.

### Summarize a Merge Request

Generates a "What's New" summary for a GitLab Merge Request, tailored to different audiences.

```bash
gitai-tool summarize <mr_id> [--style <style1> <style2>...] [--model <full-gemini-model>] [--debug]
```

-   `<mr_id>`: The IID (Internal ID) of the Merge Request to analyze (e.g., `42`).
-   `--style`: One or more summary styles. Choices: `clients`, `devops`, `developers`. You can also use `all` to generate all of them. If omitted, it defaults to generating all styles.
-   `--model`: Full Gemini model name to use. Defaults to `gemini-2.5-flash`.
-   `--debug`: Save the full prompt to a debug file for inspection.

#### Examples

```bash
# Generate summaries for all styles (default behavior)
gitai-tool summarize 42

# Generate a client-focused summary
gitai-tool summarize 42 --style clients

# Generate summaries for both developers and devops
gitai-tool summarize 42 --style developers devops
```

This command will:
1.  Fetch data for the specified Merge Request from the configured GitLab project.
2.  Generate a summary for each specified style using Gemini.
3.  Print the summaries to the console.
4.  Save each summary to a file named `release_summary_mr_<iid>.<style>.md` (e.g., `release_summary_mr_42.clients.md`).

### Review a Merge Request's Code

Generates a comprehensive, structured code review from the Merge Request's diffs.

```bash
gitai-tool code-review <mr_id> [--model <full-gemini-model>] [--debug]
```

-   `<mr_id>`: The IID of the Merge Request to review.
-   `--model`: Full Gemini model name to use. Defaults to `gemini-2.5-flash`.
-   `--debug`: Save the full prompt to a debug file.

This command outputs a `code_review_mr_<iid>.md` file containing a detailed review with structured findings on security, correctness, performance, readability, and more, along with an actionable checklist.

### Debug Mode

For both `summarize` and `code-review`, you can use the `--debug` flag to inspect the exact prompt being sent to the Gemini API.

This will create an additional file named `debug_prompt_mr_<iid>.<style>.md` (for summaries) or `debug_code_review_prompt_mr_<iid>.md` (for code reviews).

## Styles

Choose one or more `--style` options for the `summarize` command to match your target audience. If you don't provide a style, summaries for **all** audiences will be generated by default.

-   **clients**: Benefit-oriented, non-technical “What’s New” for customers. Uses friendly tone and focuses on outcomes. Sections: New Features, Bug Fixes.
-   **devops**: Operational brief for DevOps/SRE. Highlights environment variables, database migrations, seeds, infrastructure/IaC, CI/CD, logging/monitoring, security, dependencies, operational tasks/runbook, and breaking changes.
-   **developers**: Technical synopsis for implementers. Sections may include: Features/Enhancements, Bug Fixes, Refactors, API Changes, Configuration (incl. env vars), Database, Dependencies/Tooling, Tests, Known Issues, Deployment Checklist.

## Output Example

The tool will generate a Markdown file with a summary similar to this:

> We've been working hard to improve your experience! This update brings some exciting new capabilities and resolves a few pesky issues. Here’s a look at what’s new.
>
> ### ✨ New Features
>
> -   **Faster & More Secure Logins:** We've completely overhauled our authentication system, making the login process quicker and more secure for your peace of mind.
> -   **New User Profile Page:** You can now view and manage your account details on a redesigned, easy-to-use profile page.
>
> ### 🐛 Bug Fixes
>
> -   Fixed an issue where the application would occasionally crash when uploading a new profile picture.
> -   Resolved a bug that caused incorrect data to be displayed on the dashboard for some users. 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gitai-tool",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "git, gitlab, github, merge-requests, pull-requests, cli, llm, ai, summaries, code-review",
    "author": "Aleksandar Farkov",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/94/e6/c2a713c567f4e0f1c7397aed8d1f3e7c28faed3ead3151ed799dd271b0fc/gitai_tool-0.3.0.tar.gz",
    "platform": null,
    "description": "# GitLab Merge Request Summary Generator\n\nThis command-line tool generates a \"What's New\" summary for a GitLab Merge Request. It uses the GitLab API to fetch technical details (like commit messages and code changes) and then leverages the Google Gemini API to translate them into a clear, benefit-oriented summary suitable for non-technical clients.\n\n## Features\n\n-   Fetches Merge Request details, commit history, and code diffs from GitLab.\n-   Uses the Gemini API to generate an intelligent, human-readable summary.\n-   Formats the output in Markdown with \"New Features\" and \"Bug Fixes\" sections.\n-   Creates client-friendly language by focusing on benefits, not technical jargon.\n-   Includes a debug mode to inspect the exact prompt sent to the AI.\n\n## Prerequisites\n\nBefore you begin, ensure you have the following:\n\n-   Python 3.8+\n-   A GitLab account with access to the target project.\n-   A [GitLab Personal Access Token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) with `api` scope.\n-   A [Google Gemini API Key](https://ai.google.dev/gemini-api/docs/api-key).\n\n## Installation\n\n### Install with pipx (recommended)\n\nInstall from PyPI and get the global command `gitai-tool`:\n\n```bash\npipx install gitai-tool\ngitai-tool --help\n```\n\nTo upgrade later:\n\n```bash\npipx upgrade gitai-tool\n```\n\n### Install with pip (alternative)\n\n```bash\npip install gitai-tool\ngitai-tool --help\n```\n\n### Persisting configuration (TOML)\n\nWhen required values are missing, the tool will prompt you interactively and then persist them to `~/.gitai-tool/config.toml` automatically. Subsequent runs will load values from the config file. Precedence matches AWS CLI: command-line flags > environment variables > config file. Example `config.toml`:\n\n```toml\nGITLAB_URL = \"https://gitlab.com\"\nGITLAB_PRIVATE_TOKEN = \"<your_token>\"\nGITLAB_PROJECT_ID = \"<project_id>\"\nGEMINI_API_KEY = \"<gemini_api_key>\"\n```\n\n## Usage\n\nAfter installation with `pipx` or `pip`, use the global command `gitai-tool`. The tool provides two main commands: `summarize` and `code-review`.\n\nCommon flags available to all commands:\n\n-   `--gitlab-url`, `--gitlab-private-token`, `--gitlab-project-id`, `--gemini-api-key`\n-   `--model`: Gemini model identifier. Defaults to `gemini-2.5-flash`.\n\n### Summarize a Merge Request\n\nGenerates a \"What's New\" summary for a GitLab Merge Request, tailored to different audiences.\n\n```bash\ngitai-tool summarize <mr_id> [--style <style1> <style2>...] [--model <full-gemini-model>] [--debug]\n```\n\n-   `<mr_id>`: The IID (Internal ID) of the Merge Request to analyze (e.g., `42`).\n-   `--style`: One or more summary styles. Choices: `clients`, `devops`, `developers`. You can also use `all` to generate all of them. If omitted, it defaults to generating all styles.\n-   `--model`: Full Gemini model name to use. Defaults to `gemini-2.5-flash`.\n-   `--debug`: Save the full prompt to a debug file for inspection.\n\n#### Examples\n\n```bash\n# Generate summaries for all styles (default behavior)\ngitai-tool summarize 42\n\n# Generate a client-focused summary\ngitai-tool summarize 42 --style clients\n\n# Generate summaries for both developers and devops\ngitai-tool summarize 42 --style developers devops\n```\n\nThis command will:\n1.  Fetch data for the specified Merge Request from the configured GitLab project.\n2.  Generate a summary for each specified style using Gemini.\n3.  Print the summaries to the console.\n4.  Save each summary to a file named `release_summary_mr_<iid>.<style>.md` (e.g., `release_summary_mr_42.clients.md`).\n\n### Review a Merge Request's Code\n\nGenerates a comprehensive, structured code review from the Merge Request's diffs.\n\n```bash\ngitai-tool code-review <mr_id> [--model <full-gemini-model>] [--debug]\n```\n\n-   `<mr_id>`: The IID of the Merge Request to review.\n-   `--model`: Full Gemini model name to use. Defaults to `gemini-2.5-flash`.\n-   `--debug`: Save the full prompt to a debug file.\n\nThis command outputs a `code_review_mr_<iid>.md` file containing a detailed review with structured findings on security, correctness, performance, readability, and more, along with an actionable checklist.\n\n### Debug Mode\n\nFor both `summarize` and `code-review`, you can use the `--debug` flag to inspect the exact prompt being sent to the Gemini API.\n\nThis will create an additional file named `debug_prompt_mr_<iid>.<style>.md` (for summaries) or `debug_code_review_prompt_mr_<iid>.md` (for code reviews).\n\n## Styles\n\nChoose one or more `--style` options for the `summarize` command to match your target audience. If you don't provide a style, summaries for **all** audiences will be generated by default.\n\n-   **clients**: Benefit-oriented, non-technical \u201cWhat\u2019s New\u201d for customers. Uses friendly tone and focuses on outcomes. Sections: New Features, Bug Fixes.\n-   **devops**: Operational brief for DevOps/SRE. Highlights environment variables, database migrations, seeds, infrastructure/IaC, CI/CD, logging/monitoring, security, dependencies, operational tasks/runbook, and breaking changes.\n-   **developers**: Technical synopsis for implementers. Sections may include: Features/Enhancements, Bug Fixes, Refactors, API Changes, Configuration (incl. env vars), Database, Dependencies/Tooling, Tests, Known Issues, Deployment Checklist.\n\n## Output Example\n\nThe tool will generate a Markdown file with a summary similar to this:\n\n> We've been working hard to improve your experience! This update brings some exciting new capabilities and resolves a few pesky issues. Here\u2019s a look at what\u2019s new.\n>\n> ### \u2728 New Features\n>\n> -   **Faster & More Secure Logins:** We've completely overhauled our authentication system, making the login process quicker and more secure for your peace of mind.\n> -   **New User Profile Page:** You can now view and manage your account details on a redesigned, easy-to-use profile page.\n>\n> ### \ud83d\udc1b Bug Fixes\n>\n> -   Fixed an issue where the application would occasionally crash when uploading a new profile picture.\n> -   Resolved a bug that caused incorrect data to be displayed on the dashboard for some users. \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate summaries and code reviews for GitLab Merge Requests or GitHub Pull Requests using LLM",
    "version": "0.3.0",
    "project_urls": null,
    "split_keywords": [
        "git",
        " gitlab",
        " github",
        " merge-requests",
        " pull-requests",
        " cli",
        " llm",
        " ai",
        " summaries",
        " code-review"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b9349c9fe03d51b51d663f3050e09ebe5620daf30797b1067448ae4716f0c14d",
                "md5": "638c72a577b4022f32f2ca28d621cae5",
                "sha256": "6cee35c6042c1c0d8bb4e9a72b1093ae3ead31a6e462b0073e46cf25f279fe31"
            },
            "downloads": -1,
            "filename": "gitai_tool-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "638c72a577b4022f32f2ca28d621cae5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11001,
            "upload_time": "2025-08-10T19:47:58",
            "upload_time_iso_8601": "2025-08-10T19:47:58.591580Z",
            "url": "https://files.pythonhosted.org/packages/b9/34/9c9fe03d51b51d663f3050e09ebe5620daf30797b1067448ae4716f0c14d/gitai_tool-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "94e6c2a713c567f4e0f1c7397aed8d1f3e7c28faed3ead3151ed799dd271b0fc",
                "md5": "2cb87c5690032778d5ac7a2814f5e2e2",
                "sha256": "a7a27e933800283e8f4f0c35931c2990e27ed4802dff5e5aec385fe44085c534"
            },
            "downloads": -1,
            "filename": "gitai_tool-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2cb87c5690032778d5ac7a2814f5e2e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10686,
            "upload_time": "2025-08-10T19:47:59",
            "upload_time_iso_8601": "2025-08-10T19:47:59.478552Z",
            "url": "https://files.pythonhosted.org/packages/94/e6/c2a713c567f4e0f1c7397aed8d1f3e7c28faed3ead3151ed799dd271b0fc/gitai_tool-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-10 19:47:59",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gitai-tool"
}
        
Elapsed time: 2.53503s