git-copilot-commit 0.5.1__py3-none-any.whl → 0.5.3__py3-none-any.whl
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.
- git_copilot_commit/cli.py +57 -5
- git_copilot_commit/github_copilot.py +17 -0
- git_copilot_commit/prompts/split-commit-planner-prompt.md +0 -1
- {git_copilot_commit-0.5.1.dist-info → git_copilot_commit-0.5.3.dist-info}/METADATA +1 -1
- {git_copilot_commit-0.5.1.dist-info → git_copilot_commit-0.5.3.dist-info}/RECORD +8 -8
- {git_copilot_commit-0.5.1.dist-info → git_copilot_commit-0.5.3.dist-info}/WHEEL +0 -0
- {git_copilot_commit-0.5.1.dist-info → git_copilot_commit-0.5.3.dist-info}/entry_points.txt +0 -0
- {git_copilot_commit-0.5.1.dist-info → git_copilot_commit-0.5.3.dist-info}/licenses/LICENSE +0 -0
git_copilot_commit/cli.py
CHANGED
|
@@ -268,7 +268,12 @@ def display_selected_model(model: github_copilot.CopilotModel) -> None:
|
|
|
268
268
|
console.print(f"[green]Using model:[/green] {model.id} ({', '.join(details)})")
|
|
269
269
|
|
|
270
270
|
|
|
271
|
-
def build_commit_message_prompt(
|
|
271
|
+
def build_commit_message_prompt(
|
|
272
|
+
status: GitStatus,
|
|
273
|
+
context: str = "",
|
|
274
|
+
*,
|
|
275
|
+
include_diff: bool = True,
|
|
276
|
+
) -> str:
|
|
272
277
|
"""Build the prompt used to generate a commit message."""
|
|
273
278
|
if not status.has_staged_changes:
|
|
274
279
|
console.print("[red]No staged changes to commit.[/red]")
|
|
@@ -277,10 +282,16 @@ def build_commit_message_prompt(status: GitStatus, context: str = "") -> str:
|
|
|
277
282
|
prompt_parts = [
|
|
278
283
|
"`git status`:\n",
|
|
279
284
|
f"```\n{status.get_porcelain_output()}\n```",
|
|
280
|
-
"\n\n`git diff --staged`:\n",
|
|
281
|
-
f"```\n{status.staged_diff}\n```",
|
|
282
285
|
]
|
|
283
286
|
|
|
287
|
+
if include_diff:
|
|
288
|
+
prompt_parts.extend(
|
|
289
|
+
[
|
|
290
|
+
"\n\n`git diff --staged`:\n",
|
|
291
|
+
f"```\n{status.staged_diff}\n```",
|
|
292
|
+
]
|
|
293
|
+
)
|
|
294
|
+
|
|
284
295
|
if context.strip():
|
|
285
296
|
prompt_parts.insert(0, f"User-provided context:\n\n{context.strip()}\n\n")
|
|
286
297
|
|
|
@@ -330,6 +341,29 @@ def generate_commit_message_for_prompt(
|
|
|
330
341
|
)
|
|
331
342
|
|
|
332
343
|
|
|
344
|
+
def should_fallback_to_status_only(exc: github_copilot.CopilotError) -> bool:
|
|
345
|
+
message_parts = [str(exc)]
|
|
346
|
+
if isinstance(exc, github_copilot.CopilotHttpError) and exc.detail:
|
|
347
|
+
message_parts.append(exc.detail)
|
|
348
|
+
|
|
349
|
+
haystack = " ".join(part.strip() for part in message_parts if part).lower()
|
|
350
|
+
indicators = (
|
|
351
|
+
"maximum context length",
|
|
352
|
+
"context_length_exceeded",
|
|
353
|
+
"context window",
|
|
354
|
+
"prompt is too long",
|
|
355
|
+
"input is too long",
|
|
356
|
+
"request is too large",
|
|
357
|
+
"too many tokens",
|
|
358
|
+
"token limit",
|
|
359
|
+
"max_prompt_tokens",
|
|
360
|
+
"max prompt tokens",
|
|
361
|
+
"input tokens",
|
|
362
|
+
"prompt tokens",
|
|
363
|
+
)
|
|
364
|
+
return any(indicator in haystack for indicator in indicators)
|
|
365
|
+
|
|
366
|
+
|
|
333
367
|
def generate_commit_message_for_status(
|
|
334
368
|
status: GitStatus,
|
|
335
369
|
model: str | None = None,
|
|
@@ -337,9 +371,27 @@ def generate_commit_message_for_status(
|
|
|
337
371
|
http_client_config: github_copilot.HttpClientConfig | None = None,
|
|
338
372
|
) -> str:
|
|
339
373
|
"""Generate a commit message for a staged status snapshot."""
|
|
340
|
-
|
|
374
|
+
full_prompt = build_commit_message_prompt(status, context=context)
|
|
375
|
+
try:
|
|
376
|
+
return generate_commit_message_for_prompt(
|
|
377
|
+
full_prompt,
|
|
378
|
+
model=model,
|
|
379
|
+
http_client_config=http_client_config,
|
|
380
|
+
)
|
|
381
|
+
except github_copilot.CopilotError as exc:
|
|
382
|
+
if not should_fallback_to_status_only(exc):
|
|
383
|
+
raise
|
|
384
|
+
|
|
385
|
+
console.print(
|
|
386
|
+
"[yellow]Staged diff exceeded the model context window; retrying with [bold]`git status`[/] only.[/yellow]"
|
|
387
|
+
)
|
|
388
|
+
fallback_prompt = build_commit_message_prompt(
|
|
389
|
+
status,
|
|
390
|
+
context=context,
|
|
391
|
+
include_diff=False,
|
|
392
|
+
)
|
|
341
393
|
return generate_commit_message_for_prompt(
|
|
342
|
-
|
|
394
|
+
fallback_prompt,
|
|
343
395
|
model=model,
|
|
344
396
|
http_client_config=http_client_config,
|
|
345
397
|
)
|
|
@@ -162,6 +162,7 @@ class CopilotModel:
|
|
|
162
162
|
name: str
|
|
163
163
|
vendor: str | None = None
|
|
164
164
|
family: str | None = None
|
|
165
|
+
max_context_window_tokens: int | None = None
|
|
165
166
|
supported_endpoints: tuple[str, ...] = ()
|
|
166
167
|
|
|
167
168
|
@classmethod
|
|
@@ -173,11 +174,18 @@ class CopilotModel:
|
|
|
173
174
|
supported_endpoints = payload.get("supported_endpoints")
|
|
174
175
|
|
|
175
176
|
family: str | None = None
|
|
177
|
+
max_context_window_tokens: int | None = None
|
|
176
178
|
if isinstance(capabilities, dict):
|
|
177
179
|
raw_family = capabilities.get("family")
|
|
178
180
|
if isinstance(raw_family, str) and raw_family:
|
|
179
181
|
family = raw_family
|
|
180
182
|
|
|
183
|
+
limits = capabilities.get("limits")
|
|
184
|
+
if isinstance(limits, dict):
|
|
185
|
+
raw_context_window = limits.get("max_context_window_tokens")
|
|
186
|
+
if isinstance(raw_context_window, int) and raw_context_window > 0:
|
|
187
|
+
max_context_window_tokens = raw_context_window
|
|
188
|
+
|
|
181
189
|
endpoints: list[str] = []
|
|
182
190
|
if isinstance(supported_endpoints, list):
|
|
183
191
|
for entry in supported_endpoints:
|
|
@@ -192,6 +200,7 @@ class CopilotModel:
|
|
|
192
200
|
name=name if isinstance(name, str) and name else model_id,
|
|
193
201
|
vendor=vendor if isinstance(vendor, str) and vendor else None,
|
|
194
202
|
family=family,
|
|
203
|
+
max_context_window_tokens=max_context_window_tokens,
|
|
195
204
|
supported_endpoints=tuple(endpoints),
|
|
196
205
|
)
|
|
197
206
|
|
|
@@ -891,6 +900,12 @@ def format_supported_endpoints(model: CopilotModel) -> str:
|
|
|
891
900
|
return "default"
|
|
892
901
|
|
|
893
902
|
|
|
903
|
+
def format_context_window(model: CopilotModel) -> str:
|
|
904
|
+
if model.max_context_window_tokens is None:
|
|
905
|
+
return "?"
|
|
906
|
+
return f"{model.max_context_window_tokens:,}"
|
|
907
|
+
|
|
908
|
+
|
|
894
909
|
def normalize_vendor_filter(value: str | None) -> str | None:
|
|
895
910
|
if value is None:
|
|
896
911
|
return None
|
|
@@ -1226,6 +1241,7 @@ def print_model_table(models: list[CopilotModel]) -> None:
|
|
|
1226
1241
|
table.add_column("#", justify="right", style="cyan")
|
|
1227
1242
|
table.add_column("Model", style="green")
|
|
1228
1243
|
table.add_column("Vendor", style="blue")
|
|
1244
|
+
table.add_column("Context", justify="right", style="bright_cyan")
|
|
1229
1245
|
table.add_column("Route", style="yellow")
|
|
1230
1246
|
table.add_column("Endpoints", style="magenta")
|
|
1231
1247
|
for index, model in enumerate(models, start=1):
|
|
@@ -1233,6 +1249,7 @@ def print_model_table(models: list[CopilotModel]) -> None:
|
|
|
1233
1249
|
str(index),
|
|
1234
1250
|
model.id,
|
|
1235
1251
|
model.vendor or "?",
|
|
1252
|
+
format_context_window(model),
|
|
1236
1253
|
infer_api_surface(model),
|
|
1237
1254
|
format_supported_endpoints(model),
|
|
1238
1255
|
)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
git_copilot_commit/__init__.py,sha256=v3x5oBkxwKJEZLv62QqSmP3iqNKLtZgrWZfH8eFzlQg,60
|
|
2
|
-
git_copilot_commit/cli.py,sha256=
|
|
2
|
+
git_copilot_commit/cli.py,sha256=CIwT5T-Y5j5DpDRi-tHMiB-bACntCWRjqxx8zQSY3AM,31373
|
|
3
3
|
git_copilot_commit/git.py,sha256=vNuh2j8TGmocLio4XgPpbXIktlgczNdEt2Fg1c40wuk,14962
|
|
4
|
-
git_copilot_commit/github_copilot.py,sha256=
|
|
4
|
+
git_copilot_commit/github_copilot.py,sha256=2SKVVFmQ2yETAySjSRYKQTujW-1vZEW4rFKSr--dtLs,50427
|
|
5
5
|
git_copilot_commit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
git_copilot_commit/settings.py,sha256=WrM10_J3F7QBfOVmPDWpNZrNHhmZSeN-9FqQZxgdWvQ,3730
|
|
7
7
|
git_copilot_commit/split_commits.py,sha256=sGk5xfAvTeRcnW4XQvvyNVgYGsAFNntkk-JuVXb8Y6Y,14851
|
|
8
8
|
git_copilot_commit/version.py,sha256=AieHOUX52g6N67HL0iLWtDKrgOYyulxwHWViu26Jrd4,105
|
|
9
9
|
git_copilot_commit/prompts/commit-message-generator-prompt.md,sha256=EHAS6w15vLQ-kgT1N7nPG2nWqdeTmlHje_kN9yZIoZQ,2378
|
|
10
|
-
git_copilot_commit/prompts/split-commit-planner-prompt.md,sha256=
|
|
11
|
-
git_copilot_commit-0.5.
|
|
12
|
-
git_copilot_commit-0.5.
|
|
13
|
-
git_copilot_commit-0.5.
|
|
14
|
-
git_copilot_commit-0.5.
|
|
15
|
-
git_copilot_commit-0.5.
|
|
10
|
+
git_copilot_commit/prompts/split-commit-planner-prompt.md,sha256=ABKuVVyrkHsb3QV6qyS--W5yvKBoZhtq8xJEb3OZQvI,1088
|
|
11
|
+
git_copilot_commit-0.5.3.dist-info/METADATA,sha256=8_PBEk8n1GS9xG8dpZnll5bNLB1PDVL5FZbSXzmCcqs,6649
|
|
12
|
+
git_copilot_commit-0.5.3.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
13
|
+
git_copilot_commit-0.5.3.dist-info/entry_points.txt,sha256=-D4bQqiuSPwQJG2zx--vJbZD1iqB5coUfoJ_gmC3rSg,66
|
|
14
|
+
git_copilot_commit-0.5.3.dist-info/licenses/LICENSE,sha256=14lNZAoKJPI1U7eGpletjN_PFm1JwP1vT_0jFKY6eWg,1065
|
|
15
|
+
git_copilot_commit-0.5.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|