agent-gitv1 0.1.0__tar.gz → 0.1.2__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.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-gitv1
3
+ Version: 0.1.2
4
+ Summary: AI-powered Git CLI using MCP + OpenAI, Gemini, or Ollama for commit workflows
5
+ Author-email: Vijay <you@example.com>
6
+ License: MIT
7
+ Keywords: ai,automation,cli,gemini,git,mcp
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: click>=8.1
10
+ Requires-Dist: google-genai>=0.8.0
11
+ Requires-Dist: mcp[cli]>=1.0.0
12
+ Requires-Dist: openai>=1.14.0
13
+ Requires-Dist: requests>=2.31.0
14
+ Description-Content-Type: text/markdown
15
+
16
+ # agent-gitv1
17
+
18
+ AI-powered Git CLI that uses Model Context Protocol (MCP) plus your configured LLM provider to automate commit workflows.
19
+
20
+ Supported providers:
21
+ - Google Gemini
22
+ - OpenAI
23
+ - Ollama (local or same-network)
24
+
25
+ ## Features
26
+
27
+ - `agent config` to set provider and model
28
+ - `agent commit` to generate commit messages from git diff
29
+ - Multiple commit suggestions (`--suggestions`)
30
+ - History-aware commit message generation (uses recent commit subjects)
31
+ - Ollama model auto-detection on local network (`/24`, port `11434`)
32
+ - `agent push` to push to remote
33
+
34
+ ## Prerequisites
35
+
36
+ - Python 3.10+
37
+ - `uvx` (`pip install uv`)
38
+ - Git
39
+ - Provider credentials (Gemini/OpenAI) or running Ollama server
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ cd "d:\Vijay Projects\Agent_bhai"
45
+ pip install -e .
46
+ ```
47
+
48
+ After install, use command:
49
+
50
+ ```bash
51
+ agent --help
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ Start with:
57
+
58
+ ```bash
59
+ agent config
60
+ ```
61
+
62
+ Provider notes:
63
+ - Gemini: use `GEMINI_API_KEY` or save key in config
64
+ - OpenAI: use `OPENAI_API_KEY` or save key in config
65
+ - Ollama: can auto-detect servers like `http://192.168.1.35:11434`
66
+
67
+ ## Commands
68
+
69
+ ### `agent --help`
70
+ Shows all available commands and options.
71
+
72
+ ### `agent config`
73
+ Configure provider and model.
74
+
75
+ ### `agent commit`
76
+ Stage changes, generate suggestions, choose a message, and commit.
77
+
78
+ Examples:
79
+
80
+ ```bash
81
+ agent commit
82
+ agent commit --repo /path/to/repo
83
+ agent commit --suggestions 3
84
+ agent commit --verbose
85
+ ```
86
+
87
+ ### `agent push`
88
+ Push commits to remote.
89
+
90
+ Examples:
91
+
92
+ ```bash
93
+ agent push
94
+ agent push --remote origin --branch main
95
+ ```
96
+
97
+ ## Environment Variables
98
+
99
+ - `GEMINI_API_KEY` (Gemini)
100
+ - `OPENAI_API_KEY` (OpenAI)
101
+
102
+ ## Publish to PyPI
103
+
104
+ 1. Bump version in `pyproject.toml` and `agent.py`
105
+ 2. Build and validate:
106
+
107
+ ```bash
108
+ python -m pip install --upgrade build twine
109
+ python -m build
110
+ python -m twine check dist/*
111
+ ```
112
+
113
+ 3. Upload:
114
+
115
+ ```bash
116
+ python -m twine upload dist/*
117
+ ```
118
+
119
+ ## Project Structure
120
+
121
+ ```text
122
+ Agent_bhai/
123
+ |- agent.py
124
+ |- pyproject.toml
125
+ |- README.md
126
+ ```
127
+
128
+ ## License
129
+
130
+ MIT
@@ -0,0 +1,115 @@
1
+ # agent-gitv1
2
+
3
+ AI-powered Git CLI that uses Model Context Protocol (MCP) plus your configured LLM provider to automate commit workflows.
4
+
5
+ Supported providers:
6
+ - Google Gemini
7
+ - OpenAI
8
+ - Ollama (local or same-network)
9
+
10
+ ## Features
11
+
12
+ - `agent config` to set provider and model
13
+ - `agent commit` to generate commit messages from git diff
14
+ - Multiple commit suggestions (`--suggestions`)
15
+ - History-aware commit message generation (uses recent commit subjects)
16
+ - Ollama model auto-detection on local network (`/24`, port `11434`)
17
+ - `agent push` to push to remote
18
+
19
+ ## Prerequisites
20
+
21
+ - Python 3.10+
22
+ - `uvx` (`pip install uv`)
23
+ - Git
24
+ - Provider credentials (Gemini/OpenAI) or running Ollama server
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ cd "d:\Vijay Projects\Agent_bhai"
30
+ pip install -e .
31
+ ```
32
+
33
+ After install, use command:
34
+
35
+ ```bash
36
+ agent --help
37
+ ```
38
+
39
+ ## Configuration
40
+
41
+ Start with:
42
+
43
+ ```bash
44
+ agent config
45
+ ```
46
+
47
+ Provider notes:
48
+ - Gemini: use `GEMINI_API_KEY` or save key in config
49
+ - OpenAI: use `OPENAI_API_KEY` or save key in config
50
+ - Ollama: can auto-detect servers like `http://192.168.1.35:11434`
51
+
52
+ ## Commands
53
+
54
+ ### `agent --help`
55
+ Shows all available commands and options.
56
+
57
+ ### `agent config`
58
+ Configure provider and model.
59
+
60
+ ### `agent commit`
61
+ Stage changes, generate suggestions, choose a message, and commit.
62
+
63
+ Examples:
64
+
65
+ ```bash
66
+ agent commit
67
+ agent commit --repo /path/to/repo
68
+ agent commit --suggestions 3
69
+ agent commit --verbose
70
+ ```
71
+
72
+ ### `agent push`
73
+ Push commits to remote.
74
+
75
+ Examples:
76
+
77
+ ```bash
78
+ agent push
79
+ agent push --remote origin --branch main
80
+ ```
81
+
82
+ ## Environment Variables
83
+
84
+ - `GEMINI_API_KEY` (Gemini)
85
+ - `OPENAI_API_KEY` (OpenAI)
86
+
87
+ ## Publish to PyPI
88
+
89
+ 1. Bump version in `pyproject.toml` and `agent.py`
90
+ 2. Build and validate:
91
+
92
+ ```bash
93
+ python -m pip install --upgrade build twine
94
+ python -m build
95
+ python -m twine check dist/*
96
+ ```
97
+
98
+ 3. Upload:
99
+
100
+ ```bash
101
+ python -m twine upload dist/*
102
+ ```
103
+
104
+ ## Project Structure
105
+
106
+ ```text
107
+ Agent_bhai/
108
+ |- agent.py
109
+ |- pyproject.toml
110
+ |- README.md
111
+ ```
112
+
113
+ ## License
114
+
115
+ MIT
@@ -8,6 +8,8 @@ import os
8
8
  import json
9
9
  import re
10
10
  import subprocess
11
+ import socket
12
+ from concurrent.futures import ThreadPoolExecutor, as_completed
11
13
  from pathlib import Path
12
14
  import click
13
15
  from mcp import ClientSession, StdioServerParameters
@@ -77,6 +79,56 @@ def get_ollama_models(base_url: str):
77
79
  except Exception:
78
80
  return []
79
81
 
82
+ def get_local_ipv4() -> str:
83
+ """
84
+ Best-effort local IPv4 detection for subnet discovery.
85
+ Uses UDP connect trick (no packet sent) to determine outbound interface IP.
86
+ """
87
+ try:
88
+ with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
89
+ s.connect(("8.8.8.8", 80))
90
+ return s.getsockname()[0]
91
+ except Exception:
92
+ return ""
93
+
94
+ def discover_ollama_servers(port: int = 11434, timeout: float = 0.6) -> list[tuple[str, list[str]]]:
95
+ """
96
+ Discover Ollama servers in the same /24 subnet plus localhost.
97
+ Returns list of (base_url, models) for reachable Ollama instances.
98
+ """
99
+ local_ip = get_local_ipv4()
100
+ candidate_urls = {
101
+ f"http://localhost:{port}",
102
+ f"http://127.0.0.1:{port}",
103
+ }
104
+
105
+ if local_ip and "." in local_ip:
106
+ subnet = ".".join(local_ip.split(".")[:3])
107
+ for i in range(1, 255):
108
+ candidate_urls.add(f"http://{subnet}.{i}:{port}")
109
+
110
+ found: list[tuple[str, list[str]]] = []
111
+
112
+ def probe(url: str):
113
+ models = get_ollama_models(url)
114
+ if models:
115
+ return (url, models)
116
+ return None
117
+
118
+ with ThreadPoolExecutor(max_workers=48) as pool:
119
+ futures = [pool.submit(probe, url) for url in sorted(candidate_urls)]
120
+ for future in as_completed(futures):
121
+ result = future.result()
122
+ if result:
123
+ found.append(result)
124
+
125
+ # Keep localhost entries first, then sort by URL.
126
+ localhost_first = sorted(
127
+ found,
128
+ key=lambda item: (0 if ("localhost" in item[0] or "127.0.0.1" in item[0]) else 1, item[0]),
129
+ )
130
+ return localhost_first
131
+
80
132
  def generate_with_gemini(diff: str, config: dict) -> str:
81
133
  from google import genai
82
134
  from google.genai import types
@@ -555,16 +607,20 @@ async def run_agent_commit(repo_path: str, verbose: bool, suggestion_count: int)
555
607
  # ─────────────────────────────────────────────
556
608
 
557
609
  @click.group()
558
- @click.version_option(version="0.1.0", prog_name="agent-gitv1")
610
+ @click.version_option(version="0.1.2", prog_name="agent-gitv1")
559
611
  def cli():
560
612
  """
561
- \b
562
- ╔════════════════════════════════════════════╗
563
- ║ agent-gitv1 🤖 MCP + Multi-LLM Commits ║
564
- ╚════════════════════════════════════════════╝
613
+ agent-gitv1: MCP + Multi-LLM Git Assistant
565
614
 
566
615
  Automate your Git workflow with AI-generated commit messages.
567
- Supports OpenAI, Gemini, and Local Ollama models!
616
+ Supports OpenAI, Gemini, and local Ollama models.
617
+
618
+ Available commands:
619
+ config Configure AI provider and model
620
+ commit Stage changes and create an AI-assisted commit
621
+ push Push committed changes to remote
622
+
623
+ Run `agent <command> --help` for command-specific options.
568
624
  """
569
625
  pass
570
626
 
@@ -590,7 +646,33 @@ def config_command():
590
646
  config["model"] = click.prompt("Model", default="gpt-4o-mini")
591
647
 
592
648
  elif provider == "ollama":
593
- base_url = click.prompt("Ollama Base URL", default="http://localhost:11434")
649
+ base_url = "http://localhost:11434"
650
+
651
+ if click.confirm("Auto-detect Ollama servers on your local network?", default=True):
652
+ click.echo("Scanning local network for Ollama servers (this can take a few seconds)...")
653
+ discovered = discover_ollama_servers()
654
+ if discovered:
655
+ click.echo(click.style("\nDetected Ollama Servers:", fg="green"))
656
+ for i, (url, models) in enumerate(discovered, start=1):
657
+ preview = ", ".join(models[:3])
658
+ more = f" (+{len(models)-3} more)" if len(models) > 3 else ""
659
+ click.echo(f" {i}. {url} -> {preview}{more}")
660
+
661
+ choice = click.prompt(
662
+ "\nSelect server by number or type custom base URL",
663
+ type=str,
664
+ default="1",
665
+ ).strip()
666
+ if choice.isdigit() and 1 <= int(choice) <= len(discovered):
667
+ base_url = discovered[int(choice) - 1][0]
668
+ elif choice:
669
+ base_url = choice
670
+ else:
671
+ click.echo(click.style("No Ollama servers auto-detected.", fg="yellow"))
672
+ base_url = click.prompt("Ollama Base URL", default="http://localhost:11434")
673
+ else:
674
+ base_url = click.prompt("Ollama Base URL", default="http://localhost:11434")
675
+
594
676
  config["base_url"] = base_url
595
677
 
596
678
  click.echo("Fetching available models from Ollama...")
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "agent-gitv1"
7
- version = "0.1.0"
8
- description = "AI-powered Git CLI using MCP + Gemini to auto-generate commit messages"
7
+ version = "0.1.2"
8
+ description = "AI-powered Git CLI using MCP + OpenAI, Gemini, or Ollama for commit workflows"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = { text = "MIT" }
@@ -1,174 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: agent-gitv1
3
- Version: 0.1.0
4
- Summary: AI-powered Git CLI using MCP + Gemini to auto-generate commit messages
5
- Author-email: Vijay <you@example.com>
6
- License: MIT
7
- Keywords: ai,automation,cli,gemini,git,mcp
8
- Requires-Python: >=3.10
9
- Requires-Dist: click>=8.1
10
- Requires-Dist: google-genai>=0.8.0
11
- Requires-Dist: mcp[cli]>=1.0.0
12
- Requires-Dist: openai>=1.14.0
13
- Requires-Dist: requests>=2.31.0
14
- Description-Content-Type: text/markdown
15
-
16
- # agent-gitv1 🤖
17
-
18
- > **AI-powered Git CLI** — Uses [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) + Google Gemini to automatically generate professional commit messages from your diff.
19
-
20
- ---
21
-
22
- ## How It Works
23
-
24
- ```
25
- Your Code Changes
26
-
27
-
28
- [MCP Client] ──stdio──► [mcp-server-git]
29
- │ │
30
- │◄── git diff ───────────┘
31
-
32
-
33
- [Gemini AI] ──► Generate commit message
34
-
35
-
36
- [MCP Client] ──► git add . ──► git commit
37
- ```
38
-
39
- ---
40
-
41
- ## Prerequisites
42
-
43
- | Tool | Install |
44
- |------|---------|
45
- | Python ≥ 3.10 | [python.org](https://python.org) |
46
- | `uvx` (uv tool runner) | `pip install uv` |
47
- | `mcp-server-git` | Auto-fetched by `uvx` |
48
- | Gemini API Key | [aistudio.google.com](https://aistudio.google.com) |
49
-
50
- ---
51
-
52
- ## Installation
53
-
54
- ```bash
55
- # 1. Clone / navigate to the project
56
- cd "d:\Vijay Projects\Agent_bhai"
57
-
58
- # 2. Install in editable mode (creates the `agent` command globally)
59
- pip install -e .
60
-
61
- # 3. Set your Gemini API key
62
- set GEMINI_API_KEY=your_gemini_api_key_here # Windows CMD
63
- $env:GEMINI_API_KEY="your_key" # Windows PowerShell
64
- export GEMINI_API_KEY=your_gemini_api_key_here # Linux / Mac
65
- ```
66
-
67
- ---
68
-
69
- ## Usage
70
-
71
- ### `agent config` — Configure LLM Provider (Start Here!)
72
-
73
- Run this to configure OpenAI, Google Gemini, or Ollama.
74
-
75
- ```bash
76
- agent config
77
- ```
78
-
79
- What you can configure:
80
- - **Google Gemini**: Uses your API key and a model like `gemini-2.0-flash`.
81
- - **OpenAI (ChatGPT)**: Uses your API key and a model like `gpt-4o-mini`.
82
- - **Ollama (Local/Network)**: Provide the base URL (e.g. `http://localhost:11434` or `http://192.168.1.50:11434`). The CLI will automatically fetch your downloaded models and let you choose one!
83
-
84
- ---
85
-
86
- ### `agent commit` — Stage + AI commit message + commit
87
-
88
- ```bash
89
- # In any git repo:
90
- agent commit
91
-
92
- # Specify a repo path:
93
- agent commit --repo /path/to/repo
94
-
95
- # Generate multiple suggestions (pick one or type your own):
96
- agent commit --suggestions 3
97
-
98
- # Verbose mode (shows diff preview + available MCP tools):
99
- agent commit --verbose
100
- agent commit -v
101
- ```
102
-
103
- `agent commit` is now history-aware:
104
- - It uses recent commit messages from your repo to align tone/style.
105
- - It includes changed file names in the LLM prompt for better scoped messages.
106
-
107
- ### `agent push` — Push to remote
108
-
109
- ```bash
110
- agent push
111
- agent push --remote origin --branch main
112
- ```
113
-
114
- ### Help
115
-
116
- ```bash
117
- agent --help
118
- agent config --help
119
- agent commit --help
120
- agent push --help
121
- ```
122
-
123
- ---
124
-
125
- ## Example Session
126
-
127
- ```
128
- 🗂 Repository: D:\my-project
129
-
130
- 🔌 Connecting to mcp-server-git...
131
- ✅ MCP session initialized.
132
-
133
- 📂 Fetching git diff (unstaged changes)...
134
- Diff captured (1240 chars).
135
-
136
- 🤖 Generating commit message with Gemini...
137
-
138
- 💬 Commit Message: feat(auth): add JWT token refresh endpoint
139
-
140
- Proceed with git add + commit? [Y/n]: y
141
-
142
- 📦 Staging all changes (git add .)...
143
- Files staged.
144
-
145
- ✍️ Committing...
146
- [main a3f12bc] feat(auth): add JWT token refresh endpoint
147
-
148
- 🚀 Done! Changes committed successfully.
149
- ```
150
-
151
- ---
152
-
153
- ## Environment Variables
154
-
155
- | Variable | Required | Description |
156
- |----------|----------|-------------|
157
- | `GEMINI_API_KEY` | ✅ Yes | Your Google Gemini API key |
158
-
159
- ---
160
-
161
- ## Project Structure
162
-
163
- ```
164
- Agent_bhai/
165
- ├── agent.py # Main CLI + MCP client logic
166
- ├── pyproject.toml # Packaging + entry point config
167
- └── README.md # This file
168
- ```
169
-
170
- ---
171
-
172
- ## License
173
-
174
- MIT
@@ -1,159 +0,0 @@
1
- # agent-gitv1 🤖
2
-
3
- > **AI-powered Git CLI** — Uses [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) + Google Gemini to automatically generate professional commit messages from your diff.
4
-
5
- ---
6
-
7
- ## How It Works
8
-
9
- ```
10
- Your Code Changes
11
-
12
-
13
- [MCP Client] ──stdio──► [mcp-server-git]
14
- │ │
15
- │◄── git diff ───────────┘
16
-
17
-
18
- [Gemini AI] ──► Generate commit message
19
-
20
-
21
- [MCP Client] ──► git add . ──► git commit
22
- ```
23
-
24
- ---
25
-
26
- ## Prerequisites
27
-
28
- | Tool | Install |
29
- |------|---------|
30
- | Python ≥ 3.10 | [python.org](https://python.org) |
31
- | `uvx` (uv tool runner) | `pip install uv` |
32
- | `mcp-server-git` | Auto-fetched by `uvx` |
33
- | Gemini API Key | [aistudio.google.com](https://aistudio.google.com) |
34
-
35
- ---
36
-
37
- ## Installation
38
-
39
- ```bash
40
- # 1. Clone / navigate to the project
41
- cd "d:\Vijay Projects\Agent_bhai"
42
-
43
- # 2. Install in editable mode (creates the `agent` command globally)
44
- pip install -e .
45
-
46
- # 3. Set your Gemini API key
47
- set GEMINI_API_KEY=your_gemini_api_key_here # Windows CMD
48
- $env:GEMINI_API_KEY="your_key" # Windows PowerShell
49
- export GEMINI_API_KEY=your_gemini_api_key_here # Linux / Mac
50
- ```
51
-
52
- ---
53
-
54
- ## Usage
55
-
56
- ### `agent config` — Configure LLM Provider (Start Here!)
57
-
58
- Run this to configure OpenAI, Google Gemini, or Ollama.
59
-
60
- ```bash
61
- agent config
62
- ```
63
-
64
- What you can configure:
65
- - **Google Gemini**: Uses your API key and a model like `gemini-2.0-flash`.
66
- - **OpenAI (ChatGPT)**: Uses your API key and a model like `gpt-4o-mini`.
67
- - **Ollama (Local/Network)**: Provide the base URL (e.g. `http://localhost:11434` or `http://192.168.1.50:11434`). The CLI will automatically fetch your downloaded models and let you choose one!
68
-
69
- ---
70
-
71
- ### `agent commit` — Stage + AI commit message + commit
72
-
73
- ```bash
74
- # In any git repo:
75
- agent commit
76
-
77
- # Specify a repo path:
78
- agent commit --repo /path/to/repo
79
-
80
- # Generate multiple suggestions (pick one or type your own):
81
- agent commit --suggestions 3
82
-
83
- # Verbose mode (shows diff preview + available MCP tools):
84
- agent commit --verbose
85
- agent commit -v
86
- ```
87
-
88
- `agent commit` is now history-aware:
89
- - It uses recent commit messages from your repo to align tone/style.
90
- - It includes changed file names in the LLM prompt for better scoped messages.
91
-
92
- ### `agent push` — Push to remote
93
-
94
- ```bash
95
- agent push
96
- agent push --remote origin --branch main
97
- ```
98
-
99
- ### Help
100
-
101
- ```bash
102
- agent --help
103
- agent config --help
104
- agent commit --help
105
- agent push --help
106
- ```
107
-
108
- ---
109
-
110
- ## Example Session
111
-
112
- ```
113
- 🗂 Repository: D:\my-project
114
-
115
- 🔌 Connecting to mcp-server-git...
116
- ✅ MCP session initialized.
117
-
118
- 📂 Fetching git diff (unstaged changes)...
119
- Diff captured (1240 chars).
120
-
121
- 🤖 Generating commit message with Gemini...
122
-
123
- 💬 Commit Message: feat(auth): add JWT token refresh endpoint
124
-
125
- Proceed with git add + commit? [Y/n]: y
126
-
127
- 📦 Staging all changes (git add .)...
128
- Files staged.
129
-
130
- ✍️ Committing...
131
- [main a3f12bc] feat(auth): add JWT token refresh endpoint
132
-
133
- 🚀 Done! Changes committed successfully.
134
- ```
135
-
136
- ---
137
-
138
- ## Environment Variables
139
-
140
- | Variable | Required | Description |
141
- |----------|----------|-------------|
142
- | `GEMINI_API_KEY` | ✅ Yes | Your Google Gemini API key |
143
-
144
- ---
145
-
146
- ## Project Structure
147
-
148
- ```
149
- Agent_bhai/
150
- ├── agent.py # Main CLI + MCP client logic
151
- ├── pyproject.toml # Packaging + entry point config
152
- └── README.md # This file
153
- ```
154
-
155
- ---
156
-
157
- ## License
158
-
159
- MIT