git-copilot-commit 0.1.18__tar.gz → 0.1.20__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.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-copilot-commit
3
- Version: 0.1.18
3
+ Version: 0.1.20
4
4
  Summary: Automatically generate and commit changes using copilot
5
5
  Author-email: Dheepak Krishnamurthy <1813121+kdheepak@users.noreply.github.com>
6
6
  License-File: LICENSE
7
7
  Requires-Python: >=3.12
8
8
  Requires-Dist: platformdirs>=4.0.0
9
- Requires-Dist: pycopilot>=0.1.6
9
+ Requires-Dist: pycopilot>=0.1.7
10
10
  Requires-Dist: rich>=14.0.0
11
11
  Requires-Dist: typer>=0.16.0
12
12
  Description-Content-Type: text/markdown
@@ -38,7 +38,14 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
38
38
  powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
39
39
  ```
40
40
 
41
- Then install and run `git-copilot-commit`:
41
+ You can install and run the latest version of tool directly every time by invoking this one command:
42
+
43
+ ```bash
44
+ # Install latest version into temporary environment and run --help
45
+ uvx git-copilot-commit --help
46
+ ```
47
+
48
+ Alternatively, you can install into a global isolated environment and run `git-copilot-commit`:
42
49
 
43
50
  ```bash
44
51
  # Install into global isolated environment
@@ -48,14 +55,6 @@ uv tool install git-copilot-commit
48
55
  git-copilot-commit --help
49
56
  ```
50
57
 
51
- Alternatively, you can install and run the latest version of tool directly every time by invoking
52
- this one command:
53
-
54
- ```bash
55
- # Install latest version into temporary environment and run --help
56
- uvx git-copilot-commit --help
57
- ```
58
-
59
58
  [`uv`]: https://github.com/astral-sh/uv
60
59
 
61
60
  ### Install with `pipx`
@@ -75,7 +74,7 @@ pipx install git-copilot-commit
75
74
  1. Authenticate with GitHub Copilot:
76
75
 
77
76
  ```bash
78
- git-copilot-commit authenticate
77
+ uvx git-copilot-commit authenticate
79
78
  ```
80
79
 
81
80
  2. Make changes in your repository.
@@ -83,9 +82,9 @@ pipx install git-copilot-commit
83
82
  3. Generate and commit:
84
83
 
85
84
  ```bash
86
- git-copilot-commit commit
85
+ uvx git-copilot-commit commit
87
86
  # Or, if you want to stage all files and accept the generated commit message, use:
88
- git-copilot-commit commit --all --yes
87
+ uvx git-copilot-commit commit --all --yes
89
88
  ```
90
89
 
91
90
  ## Usage
@@ -148,27 +147,27 @@ Options:
148
147
  Commit all changes:
149
148
 
150
149
  ```bash
151
- git-copilot-commit commit --all
150
+ uvx git-copilot-commit commit --all
152
151
  ```
153
152
 
154
153
  Accept the generated commit message without editing:
155
154
 
156
155
  ```bash
157
- git-copilot-commit commit --yes
156
+ uvx git-copilot-commit commit --yes
158
157
  ```
159
158
 
160
159
  Use a specific model:
161
160
 
162
161
  ```bash
163
- git-copilot-commit commit --model claude-3.5-sonnet
162
+ uvx git-copilot-commit commit --model claude-3.5-sonnet
164
163
  ```
165
164
 
166
165
  Set and use a default model:
167
166
 
168
167
  ```bash
169
- git-copilot-commit config --set-default-model gpt-4o
170
- git-copilot-commit commit
171
- git-copilot-commit commit --model claude-3.5-sonnet
168
+ uvx git-copilot-commit config --set-default-model gpt-4o
169
+ uvx git-copilot-commit commit
170
+ uvx git-copilot-commit commit --model claude-3.5-sonnet
172
171
  ```
173
172
 
174
173
  ## Commit Message Format
@@ -25,7 +25,14 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
25
25
  powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
26
26
  ```
27
27
 
28
- Then install and run `git-copilot-commit`:
28
+ You can install and run the latest version of tool directly every time by invoking this one command:
29
+
30
+ ```bash
31
+ # Install latest version into temporary environment and run --help
32
+ uvx git-copilot-commit --help
33
+ ```
34
+
35
+ Alternatively, you can install into a global isolated environment and run `git-copilot-commit`:
29
36
 
30
37
  ```bash
31
38
  # Install into global isolated environment
@@ -35,14 +42,6 @@ uv tool install git-copilot-commit
35
42
  git-copilot-commit --help
36
43
  ```
37
44
 
38
- Alternatively, you can install and run the latest version of tool directly every time by invoking
39
- this one command:
40
-
41
- ```bash
42
- # Install latest version into temporary environment and run --help
43
- uvx git-copilot-commit --help
44
- ```
45
-
46
45
  [`uv`]: https://github.com/astral-sh/uv
47
46
 
48
47
  ### Install with `pipx`
@@ -62,7 +61,7 @@ pipx install git-copilot-commit
62
61
  1. Authenticate with GitHub Copilot:
63
62
 
64
63
  ```bash
65
- git-copilot-commit authenticate
64
+ uvx git-copilot-commit authenticate
66
65
  ```
67
66
 
68
67
  2. Make changes in your repository.
@@ -70,9 +69,9 @@ pipx install git-copilot-commit
70
69
  3. Generate and commit:
71
70
 
72
71
  ```bash
73
- git-copilot-commit commit
72
+ uvx git-copilot-commit commit
74
73
  # Or, if you want to stage all files and accept the generated commit message, use:
75
- git-copilot-commit commit --all --yes
74
+ uvx git-copilot-commit commit --all --yes
76
75
  ```
77
76
 
78
77
  ## Usage
@@ -135,27 +134,27 @@ Options:
135
134
  Commit all changes:
136
135
 
137
136
  ```bash
138
- git-copilot-commit commit --all
137
+ uvx git-copilot-commit commit --all
139
138
  ```
140
139
 
141
140
  Accept the generated commit message without editing:
142
141
 
143
142
  ```bash
144
- git-copilot-commit commit --yes
143
+ uvx git-copilot-commit commit --yes
145
144
  ```
146
145
 
147
146
  Use a specific model:
148
147
 
149
148
  ```bash
150
- git-copilot-commit commit --model claude-3.5-sonnet
149
+ uvx git-copilot-commit commit --model claude-3.5-sonnet
151
150
  ```
152
151
 
153
152
  Set and use a default model:
154
153
 
155
154
  ```bash
156
- git-copilot-commit config --set-default-model gpt-4o
157
- git-copilot-commit commit
158
- git-copilot-commit commit --model claude-3.5-sonnet
155
+ uvx git-copilot-commit config --set-default-model gpt-4o
156
+ uvx git-copilot-commit commit
157
+ uvx git-copilot-commit commit --model claude-3.5-sonnet
159
158
  ```
160
159
 
161
160
  ## Commit Message Format
@@ -8,7 +8,7 @@ authors = [
8
8
  ]
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [
11
- "pycopilot>=0.1.6",
11
+ "pycopilot>=0.1.7",
12
12
  "rich>=14.0.0",
13
13
  "typer>=0.16.0",
14
14
  "platformdirs>=4.0.0",
@@ -2,6 +2,8 @@
2
2
  git-copilot-commit - AI-powered Git commit assistant
3
3
  """
4
4
 
5
+ import rich.terminal_theme
6
+ import sys
5
7
  import typer
6
8
  from rich.console import Console
7
9
  from rich.prompt import Confirm
@@ -10,7 +12,7 @@ from rich.table import Table
10
12
  import rich
11
13
  from pathlib import Path
12
14
 
13
- from pycopilot.copilot import Copilot # type: ignore
15
+ from pycopilot.copilot import Copilot, CopilotAPIError # type: ignore
14
16
  from pycopilot.auth import Authentication
15
17
  from .git import GitRepository, GitError, NotAGitRepositoryError, GitStatus
16
18
  from .settings import Settings
@@ -38,19 +40,27 @@ def main(
38
40
  """
39
41
  if ctx.invoked_subcommand is None:
40
42
  # Show help when no command is provided
41
- print(ctx.get_help())
43
+ console.print(ctx.get_help())
42
44
  raise typer.Exit()
45
+ else:
46
+ # Don't show version for print command to avoid interfering with pipes
47
+ if ctx.invoked_subcommand != "echo":
48
+ console.print(
49
+ f"[bold]{(__package__ or 'git_copilot_commit').replace('_', '-')}[/] - [bold blue]v{__version__}[/]\n"
50
+ )
43
51
 
44
52
 
45
53
  def get_prompt_locations():
46
54
  """Get potential prompt file locations in order of preference."""
47
55
  import importlib.resources
48
-
56
+
49
57
  filename = "commit-message-generator-prompt.md"
50
-
58
+
51
59
  return [
52
60
  Path(Settings().data_dir) / "prompts" / filename, # User customizable
53
- importlib.resources.files("git_copilot_commit") / "prompts" / filename # Packaged version
61
+ importlib.resources.files("git_copilot_commit")
62
+ / "prompts"
63
+ / filename, # Packaged version
54
64
  ]
55
65
 
56
66
 
@@ -72,7 +82,7 @@ def load_system_prompt() -> str:
72
82
  return path.read_text(encoding="utf-8")
73
83
  except (FileNotFoundError, AttributeError):
74
84
  continue
75
-
85
+
76
86
  console.print("[red]Error: Prompt file not found in any location[/red]")
77
87
  raise typer.Exit(1)
78
88
 
@@ -82,21 +92,10 @@ def generate_commit_message(
82
92
  ) -> str:
83
93
  """Generate a conventional commit message using Copilot API."""
84
94
 
85
- # Get recent commits for context (handle empty repositories)
86
- try:
87
- recent_commits = repo.get_recent_commits(limit=5)
88
- recent_commits_text = "\n".join([f"- {msg}" for _, msg in recent_commits])
89
- except GitError:
90
- # No commits yet in this repository
91
- recent_commits_text = "No previous commits (initial commit)"
92
-
93
95
  system_prompt = load_system_prompt()
94
96
  client = Copilot(system_prompt=system_prompt)
95
97
 
96
- prompt = f"""Recent commits:
97
-
98
- {recent_commits_text}
99
-
98
+ prompt = f"""
100
99
  `git status`:
101
100
 
102
101
  ```
@@ -111,8 +110,25 @@ def generate_commit_message(
111
110
 
112
111
  Generate a conventional commit message:"""
113
112
 
114
- response = client.ask(prompt, model=model) if model else client.ask(prompt)
115
- return response.content
113
+ try:
114
+ response = client.ask(prompt, model=model) if model else client.ask(prompt)
115
+ return response.content
116
+ except CopilotAPIError:
117
+ # Fallback to git status only when diff is too large
118
+ fallback_prompt = f"""`git status`:
119
+
120
+ ```
121
+ {status.get_porcelain_output()}
122
+ ```
123
+
124
+ Generate a conventional commit message based on the git status above:"""
125
+
126
+ response = (
127
+ client.ask(fallback_prompt, model=model)
128
+ if model
129
+ else client.ask(fallback_prompt)
130
+ )
131
+ return response.content
116
132
 
117
133
 
118
134
  @app.command()
@@ -306,5 +322,51 @@ def config(
306
322
  console.print(f"Config file: [dim]{settings.config_file}[/dim]")
307
323
 
308
324
 
325
+ @app.command()
326
+ def echo(
327
+ model: str | None = typer.Option(
328
+ None, "--model", "-m", help="Model to use for generating commit message"
329
+ ),
330
+ ):
331
+ """
332
+ Generate commit message from stdin input (useful for pipes).
333
+ """
334
+ # Read from stdin
335
+ input_text = sys.stdin.read()
336
+
337
+ if not input_text.strip():
338
+ console.print("[red]Error: No input provided via stdin[/red]")
339
+ raise typer.Exit(1)
340
+
341
+ # Load settings and use default model if none provided
342
+ settings = Settings()
343
+ if model is None:
344
+ model = settings.default_model
345
+
346
+ # Load system prompt and create client
347
+ system_prompt = load_system_prompt()
348
+ client = Copilot(system_prompt=system_prompt)
349
+
350
+ # Generate commit message from the input
351
+ prompt = f"""
352
+ git diff:
353
+
354
+ ```
355
+ {input_text.strip()}
356
+ ```
357
+
358
+ Generate a conventional commit message based on the input above:"""
359
+
360
+ try:
361
+ response = client.ask(prompt, model=model) if model else client.ask(prompt)
362
+ # Print the commit message directly to stdout (no rich formatting for pipes)
363
+ import builtins
364
+
365
+ builtins.print(response.content)
366
+ except CopilotAPIError as e:
367
+ console.print(f"[red]Error generating commit message: {e}[/red]")
368
+ raise typer.Exit(1)
369
+
370
+
309
371
  if __name__ == "__main__":
310
372
  app()
@@ -68,7 +68,7 @@ dependencies = [
68
68
  [package.metadata]
69
69
  requires-dist = [
70
70
  { name = "platformdirs", specifier = ">=4.0.0" },
71
- { name = "pycopilot", specifier = ">=0.1.6" },
71
+ { name = "pycopilot", specifier = ">=0.1.7" },
72
72
  { name = "rich", specifier = ">=14.0.0" },
73
73
  { name = "typer", specifier = ">=0.16.0" },
74
74
  ]
@@ -163,7 +163,7 @@ wheels = [
163
163
 
164
164
  [[package]]
165
165
  name = "pycopilot"
166
- version = "0.1.6"
166
+ version = "0.1.7"
167
167
  source = { registry = "https://pypi.org/simple" }
168
168
  dependencies = [
169
169
  { name = "httpx" },
@@ -174,9 +174,9 @@ dependencies = [
174
174
  { name = "rich" },
175
175
  { name = "typer" },
176
176
  ]
177
- sdist = { url = "https://files.pythonhosted.org/packages/45/ae/9d540cfe9411ad9f5ab58080aab86a5a7902ab668ad16fb637f287c88ba7/pycopilot-0.1.6.tar.gz", hash = "sha256:84425265e0d587d964e7b5dd93de9d9175b849b7d718107a48efb749e5b88e8e", size = 31667, upload-time = "2025-07-17T15:39:42.473Z" }
177
+ sdist = { url = "https://files.pythonhosted.org/packages/41/c9/666fe6cefc806e363674b619c3d79575f3966474a77b828af2f9a725d7c8/pycopilot-0.1.7.tar.gz", hash = "sha256:82e295ef7fa6e9d626d12183adc8786ee6baa30f77e582d6a2f712cd88b69193", size = 31866, upload-time = "2025-07-22T12:25:14.553Z" }
178
178
  wheels = [
179
- { url = "https://files.pythonhosted.org/packages/3e/5f/56cd35579f5d400b2ef9f0c62b41f6024936fbfc8f69e302036588052531/pycopilot-0.1.6-py3-none-any.whl", hash = "sha256:88f39535a87d1efdc2358357d956bbe0d9e6b5a6fd60d572d46c813fe23af2d0", size = 10811, upload-time = "2025-07-17T15:39:41.608Z" },
179
+ { url = "https://files.pythonhosted.org/packages/1a/fb/401f2395f2051c2e1d0b997a5ad355310ecdfdc68b06718554971280b18d/pycopilot-0.1.7-py3-none-any.whl", hash = "sha256:9fced5efcfab9d0b91d2d542e4949e17f32f395f27b529882af0200908cfb9cc", size = 10930, upload-time = "2025-07-22T12:25:13.513Z" },
180
180
  ]
181
181
 
182
182
  [[package]]