gitsage-local 0.1.3__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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mathys Dupont
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: gitsage-local
3
+ Version: 0.1.3
4
+ Summary: Local LLM powered Git commit generator
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: requests
9
+ Requires-Dist: pyperclip
10
+ Requires-Dist: toml
11
+ Dynamic: license-file
12
+
13
+ # GitSage
14
+ ![logo](ressources/logo.png)
15
+
16
+ Local AI powered commit generator based on ur repository local change.
17
+
18
+ ## Installation
19
+
20
+ ### Prerequirements
21
+
22
+ - Python>=3.10
23
+ - Python3-pip or Python3-pipx
24
+ - Python3-venv (optional if using pipx)
25
+ - Ollama
26
+
27
+ #### Start Ollama
28
+
29
+ ```bash
30
+ $> ollama pull qwen3:8b (or the model of your choice)
31
+ ```
32
+
33
+ #### Create your virtual environnent (if using pip)
34
+
35
+ ```bash
36
+ $> python3 -m venv .venv
37
+ ```
38
+
39
+ ##### Use your virtual environnement
40
+
41
+ ```bash
42
+ $> source .venv/bin/activate
43
+ ```
44
+
45
+ ### Install GitSage
46
+
47
+ #### with pip :
48
+
49
+ ```bash
50
+ (.venv) $> pip install gitsage
51
+ ```
52
+
53
+ #### with pipx :
54
+
55
+ ```bash
56
+ $> pipx install gitsage
57
+ ```
58
+
59
+ ## Usage
60
+
61
+ ```bash
62
+ $> gitsage <command> <options>
63
+ ```
64
+
65
+ ### Commands
66
+
67
+ help Show this help message
68
+ commit Generate a commit message based on the staged changes
69
+ version/-v/--version Show the version of GitSage
70
+
71
+ ### Options
72
+
73
+ --copy Copy the output to the clipboard
74
+
75
+ ## Configuration
76
+
77
+ The default configuration file is located at `~/.config/gitsage/config.toml`. If the file does not exist, it will be created with default values when you run the tool for the first time.
78
+
79
+ ### Default Configuration :
80
+
81
+ ```toml
82
+ model = "qwen3:8b"
83
+ prompt = """You generate Git commit messages.
84
+
85
+ Analyze the following staged git diff.
86
+
87
+ Return ONLY a single Conventional Commit message.
88
+ Format:
89
+ type(scope): description
90
+
91
+ Rules:
92
+ - Use feat, fix, refactor, docs, test, chore, or perf
93
+ - Keep the description concise
94
+ - Use imperative mood
95
+ - Do not invent changes
96
+ - Do not include markdown
97
+
98
+ """
99
+ ollama_url = "http://localhost:11434"
100
+ ```
101
+
102
+ You can modify the `model`, `prompt`, and `ollama_url` values in the configuration file to customize the behavior of GitSage according to your needs.
@@ -0,0 +1,90 @@
1
+ # GitSage
2
+ ![logo](ressources/logo.png)
3
+
4
+ Local AI powered commit generator based on ur repository local change.
5
+
6
+ ## Installation
7
+
8
+ ### Prerequirements
9
+
10
+ - Python>=3.10
11
+ - Python3-pip or Python3-pipx
12
+ - Python3-venv (optional if using pipx)
13
+ - Ollama
14
+
15
+ #### Start Ollama
16
+
17
+ ```bash
18
+ $> ollama pull qwen3:8b (or the model of your choice)
19
+ ```
20
+
21
+ #### Create your virtual environnent (if using pip)
22
+
23
+ ```bash
24
+ $> python3 -m venv .venv
25
+ ```
26
+
27
+ ##### Use your virtual environnement
28
+
29
+ ```bash
30
+ $> source .venv/bin/activate
31
+ ```
32
+
33
+ ### Install GitSage
34
+
35
+ #### with pip :
36
+
37
+ ```bash
38
+ (.venv) $> pip install gitsage
39
+ ```
40
+
41
+ #### with pipx :
42
+
43
+ ```bash
44
+ $> pipx install gitsage
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ```bash
50
+ $> gitsage <command> <options>
51
+ ```
52
+
53
+ ### Commands
54
+
55
+ help Show this help message
56
+ commit Generate a commit message based on the staged changes
57
+ version/-v/--version Show the version of GitSage
58
+
59
+ ### Options
60
+
61
+ --copy Copy the output to the clipboard
62
+
63
+ ## Configuration
64
+
65
+ The default configuration file is located at `~/.config/gitsage/config.toml`. If the file does not exist, it will be created with default values when you run the tool for the first time.
66
+
67
+ ### Default Configuration :
68
+
69
+ ```toml
70
+ model = "qwen3:8b"
71
+ prompt = """You generate Git commit messages.
72
+
73
+ Analyze the following staged git diff.
74
+
75
+ Return ONLY a single Conventional Commit message.
76
+ Format:
77
+ type(scope): description
78
+
79
+ Rules:
80
+ - Use feat, fix, refactor, docs, test, chore, or perf
81
+ - Keep the description concise
82
+ - Use imperative mood
83
+ - Do not invent changes
84
+ - Do not include markdown
85
+
86
+ """
87
+ ollama_url = "http://localhost:11434"
88
+ ```
89
+
90
+ You can modify the `model`, `prompt`, and `ollama_url` values in the configuration file to customize the behavior of GitSage according to your needs.
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "gitsage-local"
7
+ version = "0.1.3"
8
+ description = "Local LLM powered Git commit generator"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "requests",
13
+ "pyperclip",
14
+ "toml",
15
+ ]
16
+
17
+ [project.scripts]
18
+ gitsage = "gitsage.cli:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,37 @@
1
+ import gitsage.utils as utils
2
+ import sys
3
+
4
+ def commit(copy=False):
5
+ if not utils.check_ollama():
6
+ utils.print_error("Ollama is not running.\nTry:\n\t> ollama pull 'your model'")
7
+ sys.exit(1)
8
+ config = utils.load_config()
9
+ diff = utils.get_diff()
10
+ commit = utils.generate_commit_message(diff, config)
11
+ if copy:
12
+ utils.copy_to_clipboard(commit)
13
+
14
+ def main():
15
+ if len(sys.argv) < 2:
16
+ utils.draw_logo()
17
+ utils.print_help()
18
+ return 1
19
+
20
+ if sys.argv[1] in ["help", "-h", "--help"]:
21
+ utils.draw_logo()
22
+ utils.print_help()
23
+ return 0
24
+
25
+ if sys.argv[1] in ["version", "-v", "--version"]:
26
+ utils.print_version()
27
+ return 0
28
+
29
+ command = sys.argv[1]
30
+ copy = sys.argv[2] == "--copy" if len(sys.argv) > 2 else False
31
+
32
+ if command == "commit":
33
+ commit(copy=copy)
34
+ else:
35
+ utils.print_error(f"Unknown command: {command}\n")
36
+ print("Usage: gitsage <command> <options>")
37
+ return 1
@@ -0,0 +1,135 @@
1
+ import requests
2
+ import sys
3
+ import subprocess
4
+ import json
5
+ import pyperclip
6
+ from pathlib import Path
7
+ import toml
8
+ import os
9
+ from importlib.metadata import version
10
+
11
+ def load_config():
12
+ DEFAULT_CONFIG = '''\
13
+ model = "qwen3:8b"
14
+ prompt = """You generate Git commit messages.\n\nAnalyze the following staged git diff.\n\nReturn ONLY a single Conventional Commit message.\nFormat:\ntype(scope): description\n\nRules:\n- Use feat, fix, refactor, docs, test, chore, or perf\n- Keep the description concise\n- Use imperative mood\n- Do not invent changes\n- Do not include markdown\n\n"""
15
+ ollama_url = "http://localhost:11434"
16
+ '''
17
+
18
+ config_path = Path.home() / ".config/gitsage/config.toml"
19
+ if not os.path.exists(config_path):
20
+ config_path.parent.mkdir(parents=True, exist_ok=True)
21
+ with open(config_path, "w") as f:
22
+ f.write(DEFAULT_CONFIG)
23
+ try:
24
+ with open(config_path, "r") as f:
25
+ return toml.load(f)
26
+ except FileNotFoundError:
27
+ print_error(f"Config file not found at {config_path}.")
28
+ sys.exit(1)
29
+ except toml.TomlDecodeError:
30
+ print_error("Invalid TOML in config.toml.")
31
+ sys.exit(1)
32
+
33
+ def check_ollama():
34
+ try:
35
+ response = requests.get(
36
+ "http://localhost:11434/api/tags",
37
+ timeout=2
38
+ )
39
+ response.raise_for_status()
40
+ return True
41
+ except requests.RequestException:
42
+ return False
43
+
44
+ def get_diff():
45
+ try:
46
+ result = subprocess.run(
47
+ ["git", "diff", "--cached"],
48
+ capture_output=True,
49
+ text=True,
50
+ check=True,
51
+ )
52
+ return result.stdout
53
+ except subprocess.CalledProcessError as e:
54
+ print_error(f"Failed to get git diff: {e}")
55
+ sys.exit(1)
56
+
57
+ def generate_commit_message(diff, config):
58
+ response = requests.post(
59
+ config["ollama_url"] + "/api/generate",
60
+ json={
61
+ "model": config["model"],
62
+ "system": config["prompt"],
63
+ "prompt": f"Analyze this staged git diff:\n\n{diff}",
64
+ "stream": True,
65
+ "think": False,
66
+ },
67
+ stream=True,
68
+ )
69
+ output = ""
70
+ for line in response.iter_lines():
71
+ if not line:
72
+ continue
73
+ data = json.loads(line)
74
+ if data.get("response") != "":
75
+ output += data["response"]
76
+ print(data["response"], end="", flush=True)
77
+ print()
78
+ return output
79
+
80
+ def draw_logo():
81
+ GREEN = "\033[38;5;71m"
82
+ RESET = "\033[0m"
83
+
84
+ print(f"""{GREEN}
85
+ ████████
86
+ ██ ██
87
+ ████ ██ ██
88
+ ███ ████████
89
+ ███ █
90
+ ███ █ ████████
91
+ ████ ████████ ██
92
+ ███ █ ██ ██
93
+ ███ █ ████████
94
+ ███ ███████
95
+ ███ ██ ██
96
+ ██ ██
97
+ ████████████ ███████{RESET}
98
+ """)
99
+
100
+ def copy_to_clipboard(text):
101
+ try:
102
+ pyperclip.copy(text)
103
+ print()
104
+ print_info("Output copied to clipboard.")
105
+ except pyperclip.PyperclipException:
106
+ print_error(f"Failed to copy to clipboard.\n")
107
+ print_warning("Ensure you have a clipboard utility installed !")
108
+
109
+ def print_help():
110
+ print("Usage: gitsage <command> <options>\n")
111
+ print("Commands:\n")
112
+ print(" help Show this help message")
113
+ print(" commit Generate a commit message based on the staged changes")
114
+ print(" version/-v/--version Show the version of GitSage\n")
115
+ print("Options:\n")
116
+ print(" --copy Copy the output to the clipboard")
117
+
118
+
119
+ def print_version():
120
+ print(f"GitSage v{version('gitsage')}")
121
+
122
+ def print_error(message):
123
+ RED = "\033[31m"
124
+ RESET = "\033[0m"
125
+ print(f"{RED}[ERROR]: {message}{RESET}")
126
+
127
+ def print_warning(message):
128
+ YELLOW = "\033[33m"
129
+ RESET = "\033[0m"
130
+ print(f"{YELLOW}[WARNING]: {message}{RESET}")
131
+
132
+ def print_info(message):
133
+ BLUE = "\033[34m"
134
+ RESET = "\033[0m"
135
+ print(f"{BLUE}[INFO]: {message}{RESET}")
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: gitsage-local
3
+ Version: 0.1.3
4
+ Summary: Local LLM powered Git commit generator
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: requests
9
+ Requires-Dist: pyperclip
10
+ Requires-Dist: toml
11
+ Dynamic: license-file
12
+
13
+ # GitSage
14
+ ![logo](ressources/logo.png)
15
+
16
+ Local AI powered commit generator based on ur repository local change.
17
+
18
+ ## Installation
19
+
20
+ ### Prerequirements
21
+
22
+ - Python>=3.10
23
+ - Python3-pip or Python3-pipx
24
+ - Python3-venv (optional if using pipx)
25
+ - Ollama
26
+
27
+ #### Start Ollama
28
+
29
+ ```bash
30
+ $> ollama pull qwen3:8b (or the model of your choice)
31
+ ```
32
+
33
+ #### Create your virtual environnent (if using pip)
34
+
35
+ ```bash
36
+ $> python3 -m venv .venv
37
+ ```
38
+
39
+ ##### Use your virtual environnement
40
+
41
+ ```bash
42
+ $> source .venv/bin/activate
43
+ ```
44
+
45
+ ### Install GitSage
46
+
47
+ #### with pip :
48
+
49
+ ```bash
50
+ (.venv) $> pip install gitsage
51
+ ```
52
+
53
+ #### with pipx :
54
+
55
+ ```bash
56
+ $> pipx install gitsage
57
+ ```
58
+
59
+ ## Usage
60
+
61
+ ```bash
62
+ $> gitsage <command> <options>
63
+ ```
64
+
65
+ ### Commands
66
+
67
+ help Show this help message
68
+ commit Generate a commit message based on the staged changes
69
+ version/-v/--version Show the version of GitSage
70
+
71
+ ### Options
72
+
73
+ --copy Copy the output to the clipboard
74
+
75
+ ## Configuration
76
+
77
+ The default configuration file is located at `~/.config/gitsage/config.toml`. If the file does not exist, it will be created with default values when you run the tool for the first time.
78
+
79
+ ### Default Configuration :
80
+
81
+ ```toml
82
+ model = "qwen3:8b"
83
+ prompt = """You generate Git commit messages.
84
+
85
+ Analyze the following staged git diff.
86
+
87
+ Return ONLY a single Conventional Commit message.
88
+ Format:
89
+ type(scope): description
90
+
91
+ Rules:
92
+ - Use feat, fix, refactor, docs, test, chore, or perf
93
+ - Keep the description concise
94
+ - Use imperative mood
95
+ - Do not invent changes
96
+ - Do not include markdown
97
+
98
+ """
99
+ ollama_url = "http://localhost:11434"
100
+ ```
101
+
102
+ You can modify the `model`, `prompt`, and `ollama_url` values in the configuration file to customize the behavior of GitSage according to your needs.
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/gitsage/__init__.py
5
+ src/gitsage/cli.py
6
+ src/gitsage/utils.py
7
+ src/gitsage_local.egg-info/PKG-INFO
8
+ src/gitsage_local.egg-info/SOURCES.txt
9
+ src/gitsage_local.egg-info/dependency_links.txt
10
+ src/gitsage_local.egg-info/entry_points.txt
11
+ src/gitsage_local.egg-info/requires.txt
12
+ src/gitsage_local.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ gitsage = gitsage.cli:main
@@ -0,0 +1,3 @@
1
+ requests
2
+ pyperclip
3
+ toml