enhanced-git 1.0.5__tar.gz → 1.0.6__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. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/PKG-INFO +33 -3
  2. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/README.md +32 -2
  3. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/cli.py +66 -0
  4. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/config.py +27 -4
  5. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/pyproject.toml +1 -1
  6. enhanced_git-1.0.6/test.txt +1 -0
  7. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/.gitai.toml +0 -0
  8. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/.github/workflows/ci.yml +0 -0
  9. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/.github/workflows/release.yml +0 -0
  10. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/.gitignore +0 -0
  11. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/.pre-commit-config.yaml +0 -0
  12. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/CONTRIBUTING.md +0 -0
  13. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/LICENSE +0 -0
  14. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/Makefile +0 -0
  15. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/__init__.py +0 -0
  16. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/changelog.py +0 -0
  17. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/commit.py +0 -0
  18. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/constants.py +0 -0
  19. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/diff.py +0 -0
  20. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/hook.py +0 -0
  21. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/providers/__init__.py +0 -0
  22. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/providers/base.py +0 -0
  23. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/providers/ollama_provider.py +0 -0
  24. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/providers/openai_provider.py +0 -0
  25. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/gitai/util.py +0 -0
  26. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/tests/__init__.py +0 -0
  27. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/tests/test_changelog.py +0 -0
  28. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/tests/test_diff.py +0 -0
  29. {enhanced_git-1.0.5 → enhanced_git-1.0.6}/tests/test_hook_integration.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: enhanced-git
3
- Version: 1.0.5
3
+ Version: 1.0.6
4
4
  Summary: Generate Conventional Commit messages and changelog sections using AI
5
5
  Project-URL: Homepage, https://github.com/mxzahid/git-ai
6
6
  Project-URL: Repository, https://github.com/mxzahid/git-ai
@@ -168,9 +168,39 @@ git-ai changelog --since v1.0.0 --to main
168
168
  - `OLLAMA_BASE_URL`: Ollama server URL (default: http://localhost:11434)
169
169
  - `OLLAMA_MODEL`: Ollama model name (default: qwen2.5-coder:3b)
170
170
 
171
- ### Configuration File
171
+ **Important for pipx users**: pipx creates isolated environments that don't inherit shell environment variables. Use one of these solutions:
172
172
 
173
- GitAI supports optional configuration via a `.gitai.toml` file in your git repository root. This allows you to customize behavior beyond environment variables.
173
+ ```bash
174
+ # Solution 1: Use the setup command (easiest)
175
+ git-ai setup --provider ollama --model qwen2.5-coder:3b
176
+ # This creates ~/.config/gitai/config.toml for global configuration
177
+
178
+ # Solution 2: Use .gitai.toml config file (per-project)
179
+ # Create .gitai.toml in your project root with:
180
+ [llm]
181
+ provider = "ollama"
182
+ model = "qwen2.5-coder:3b"
183
+
184
+ # Solution 3: Set variables in your shell profile (.bashrc, .zshrc, etc.)
185
+ export OLLAMA_BASE_URL="http://localhost:11434"
186
+ export OLLAMA_MODEL="qwen2.5-coder:3b"
187
+ # Then restart your terminal
188
+
189
+ # Solution 4: Use environment variables inline
190
+ OLLAMA_BASE_URL="http://localhost:11434" OLLAMA_MODEL="qwen2.5-coder:3b" git-ai commit
191
+ ```
192
+
193
+ ### Configuration Files
194
+
195
+ GitAI supports configuration at multiple levels:
196
+
197
+ 1. **Global config**: `~/.config/gitai/config.toml` (applies to all repositories)
198
+ 2. **Project config**: `.gitai.toml` in git repository root (overrides global config)
199
+
200
+ Create a global configuration easily with:
201
+ ```bash
202
+ git-ai setup --provider ollama --model qwen2.5-coder:3b
203
+ ```
174
204
 
175
205
  **Auto-detection**: GitAI automatically detects your LLM provider based on environment variables (no config file needed!):
176
206
  - If `OPENAI_API_KEY` is set → uses OpenAI
@@ -127,9 +127,39 @@ git-ai changelog --since v1.0.0 --to main
127
127
  - `OLLAMA_BASE_URL`: Ollama server URL (default: http://localhost:11434)
128
128
  - `OLLAMA_MODEL`: Ollama model name (default: qwen2.5-coder:3b)
129
129
 
130
- ### Configuration File
130
+ **Important for pipx users**: pipx creates isolated environments that don't inherit shell environment variables. Use one of these solutions:
131
131
 
132
- GitAI supports optional configuration via a `.gitai.toml` file in your git repository root. This allows you to customize behavior beyond environment variables.
132
+ ```bash
133
+ # Solution 1: Use the setup command (easiest)
134
+ git-ai setup --provider ollama --model qwen2.5-coder:3b
135
+ # This creates ~/.config/gitai/config.toml for global configuration
136
+
137
+ # Solution 2: Use .gitai.toml config file (per-project)
138
+ # Create .gitai.toml in your project root with:
139
+ [llm]
140
+ provider = "ollama"
141
+ model = "qwen2.5-coder:3b"
142
+
143
+ # Solution 3: Set variables in your shell profile (.bashrc, .zshrc, etc.)
144
+ export OLLAMA_BASE_URL="http://localhost:11434"
145
+ export OLLAMA_MODEL="qwen2.5-coder:3b"
146
+ # Then restart your terminal
147
+
148
+ # Solution 4: Use environment variables inline
149
+ OLLAMA_BASE_URL="http://localhost:11434" OLLAMA_MODEL="qwen2.5-coder:3b" git-ai commit
150
+ ```
151
+
152
+ ### Configuration Files
153
+
154
+ GitAI supports configuration at multiple levels:
155
+
156
+ 1. **Global config**: `~/.config/gitai/config.toml` (applies to all repositories)
157
+ 2. **Project config**: `.gitai.toml` in git repository root (overrides global config)
158
+
159
+ Create a global configuration easily with:
160
+ ```bash
161
+ git-ai setup --provider ollama --model qwen2.5-coder:3b
162
+ ```
133
163
 
134
164
  **Auto-detection**: GitAI automatically detects your LLM provider based on environment variables (no config file needed!):
135
165
  - If `OPENAI_API_KEY` is set → uses OpenAI
@@ -156,6 +156,72 @@ def changelog(
156
156
  exit_with_error(f"Error generating changelog: {e}")
157
157
 
158
158
 
159
+ @app.command()
160
+ def debug() -> None:
161
+ """Debug configuration and environment."""
162
+ import os
163
+ from .config import Config
164
+
165
+ print("=== GitAI Debug Information ===")
166
+ print(f"OPENAI_API_KEY: {'SET' if os.getenv('OPENAI_API_KEY') else 'NOT SET'}")
167
+ print(f"OLLAMA_BASE_URL: {os.getenv('OLLAMA_BASE_URL', 'NOT SET')}")
168
+ print(f"OLLAMA_MODEL: {os.getenv('OLLAMA_MODEL', 'NOT SET')}")
169
+
170
+ try:
171
+ config = Config.load()
172
+ print(f"\nDetected provider: {config.llm.provider}")
173
+ print(f"Model: {config.llm.model}")
174
+ print(f"Base URL: {config.llm.base_url}")
175
+ print(f"API Key: {'SET' if config.llm.api_key else 'NOT SET'}")
176
+ print(f"LLM Available: {config.is_llm_available()}")
177
+ except Exception as e:
178
+ print(f"Error loading config: {e}")
179
+
180
+
181
+ @app.command()
182
+ def setup(
183
+ provider: Annotated[
184
+ str,
185
+ typer.Option("--provider", help="LLM provider: openai or ollama"),
186
+ ] = "ollama",
187
+ model: Annotated[
188
+ str,
189
+ typer.Option("--model", help="Model name"),
190
+ ] = "qwen2.5-coder:3b",
191
+ ) -> None:
192
+ """Set up user-level GitAI configuration."""
193
+ from pathlib import Path
194
+
195
+ config_dir = Path.home() / ".config" / "gitai"
196
+ config_file = config_dir / "config.toml"
197
+
198
+ # Create config directory if it doesn't exist
199
+ config_dir.mkdir(parents=True, exist_ok=True)
200
+
201
+ # Create config content
202
+ config_content = f"""# GitAI User Configuration
203
+ # This file is automatically created by 'git-ai setup'
204
+
205
+ [llm]
206
+ provider = "{provider}"
207
+ model = "{model}"
208
+ use_ollama = true
209
+
210
+ [commit]
211
+ style = "conventional"
212
+ include_body = true
213
+ """
214
+
215
+ # Write config file
216
+ config_file.write_text(config_content)
217
+
218
+ print_success(f"Created user configuration at {config_file}")
219
+ print_info("GitAI will now automatically use Ollama for all repositories")
220
+ print_info(
221
+ "You can override this by creating a .gitai.toml file in specific projects"
222
+ )
223
+
224
+
159
225
  @app.callback()
160
226
  def main() -> None:
161
227
  """GitAI - Generate Conventional Commit messages and changelog sections using AI."""
@@ -1,6 +1,7 @@
1
1
  """Configuration management for GitAI."""
2
2
 
3
3
  import os
4
+ from typing import Any
4
5
  from dataclasses import dataclass
5
6
  from pathlib import Path
6
7
 
@@ -70,12 +71,22 @@ class Config:
70
71
  # auto-detect provider based on available environment variables
71
72
  configured_provider = llm_data.get("provider")
72
73
  if configured_provider is None:
73
- if os.getenv("OPENAI_API_KEY"):
74
- configured_provider = "openai"
75
- elif os.getenv("OLLAMA_BASE_URL") or os.getenv("OLLAMA_MODEL"):
74
+ # Check environment variables for auto-detection
75
+ openai_key = os.getenv("OPENAI_API_KEY")
76
+ ollama_url = os.getenv("OLLAMA_BASE_URL")
77
+ ollama_model = os.getenv("OLLAMA_MODEL")
78
+
79
+ # Also check for user-level config directory
80
+ home_config = cls._load_user_config()
81
+
82
+ if ollama_url or ollama_model or home_config.get("use_ollama"):
76
83
  configured_provider = "ollama"
84
+ elif openai_key:
85
+ configured_provider = "openai"
77
86
  else:
78
- configured_provider = None # fallback
87
+ configured_provider = (
88
+ "openai" # fallback to openai (will use non-AI mode if no key)
89
+ )
79
90
 
80
91
  llm_config = LLMConfig(
81
92
  provider=configured_provider,
@@ -126,6 +137,18 @@ class Config:
126
137
  git_root=git_root,
127
138
  )
128
139
 
140
+ @classmethod
141
+ def _load_user_config(cls) -> dict[str, Any]:
142
+ """Load user-level configuration from ~/.config/gitai/config.toml"""
143
+ from pathlib import Path
144
+
145
+ config_dir = Path.home() / ".config" / "gitai"
146
+ config_file = config_dir / "config.toml"
147
+
148
+ if config_file.exists():
149
+ return load_toml_config(config_file)
150
+ return {}
151
+
129
152
  def is_llm_available(self) -> bool:
130
153
  """Check if LLM provider is available."""
131
154
  if self.llm.provider == "openai":
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "enhanced-git"
7
- version = "1.0.5"
7
+ version = "1.0.6"
8
8
  description = "Generate Conventional Commit messages and changelog sections using AI"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -0,0 +1 @@
1
+ sdaflkjsdlkfjkl
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes