git-copilot-commit 0.5.3__py3-none-any.whl → 0.5.4__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 +45 -10
- git_copilot_commit/split_commits.py +9 -3
- {git_copilot_commit-0.5.3.dist-info → git_copilot_commit-0.5.4.dist-info}/METADATA +1 -1
- {git_copilot_commit-0.5.3.dist-info → git_copilot_commit-0.5.4.dist-info}/RECORD +7 -7
- {git_copilot_commit-0.5.3.dist-info → git_copilot_commit-0.5.4.dist-info}/WHEEL +0 -0
- {git_copilot_commit-0.5.3.dist-info → git_copilot_commit-0.5.4.dist-info}/entry_points.txt +0 -0
- {git_copilot_commit-0.5.3.dist-info → git_copilot_commit-0.5.4.dist-info}/licenses/LICENSE +0 -0
git_copilot_commit/cli.py
CHANGED
|
@@ -341,7 +341,7 @@ def generate_commit_message_for_prompt(
|
|
|
341
341
|
)
|
|
342
342
|
|
|
343
343
|
|
|
344
|
-
def
|
|
344
|
+
def should_retry_with_compact_prompt(exc: github_copilot.CopilotError) -> bool:
|
|
345
345
|
message_parts = [str(exc)]
|
|
346
346
|
if isinstance(exc, github_copilot.CopilotHttpError) and exc.detail:
|
|
347
347
|
message_parts.append(exc.detail)
|
|
@@ -360,6 +360,7 @@ def should_fallback_to_status_only(exc: github_copilot.CopilotError) -> bool:
|
|
|
360
360
|
"max prompt tokens",
|
|
361
361
|
"input tokens",
|
|
362
362
|
"prompt tokens",
|
|
363
|
+
"prompt token count",
|
|
363
364
|
)
|
|
364
365
|
return any(indicator in haystack for indicator in indicators)
|
|
365
366
|
|
|
@@ -379,7 +380,7 @@ def generate_commit_message_for_status(
|
|
|
379
380
|
http_client_config=http_client_config,
|
|
380
381
|
)
|
|
381
382
|
except github_copilot.CopilotError as exc:
|
|
382
|
-
if not
|
|
383
|
+
if not should_retry_with_compact_prompt(exc):
|
|
383
384
|
raise
|
|
384
385
|
|
|
385
386
|
console.print(
|
|
@@ -507,31 +508,65 @@ def request_split_commit_plan(
|
|
|
507
508
|
http_client_config: github_copilot.HttpClientConfig | None = None,
|
|
508
509
|
) -> SplitCommitPlan:
|
|
509
510
|
"""Request and validate a split-commit plan for the staged patch units."""
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
511
|
+
planner_system_prompt = load_named_prompt(SPLIT_COMMIT_PLANNER_PROMPT_FILENAME)
|
|
512
|
+
planner_prompt = build_split_plan_prompt(
|
|
513
|
+
status,
|
|
514
|
+
patch_units,
|
|
515
|
+
preferred_commits=preferred_commits,
|
|
516
|
+
context=context,
|
|
517
|
+
)
|
|
517
518
|
|
|
519
|
+
try:
|
|
518
520
|
with console.status(
|
|
519
521
|
"[yellow]Planning split commits from [bold]staged hunks[/] ...[/yellow]"
|
|
520
522
|
):
|
|
521
523
|
response = ask_copilot_with_system_prompt(
|
|
522
|
-
|
|
524
|
+
planner_system_prompt,
|
|
523
525
|
planner_prompt,
|
|
524
526
|
model=model,
|
|
525
527
|
http_client_config=http_client_config,
|
|
526
528
|
)
|
|
529
|
+
except github_copilot.CopilotError as exc:
|
|
530
|
+
if not should_retry_with_compact_prompt(exc):
|
|
531
|
+
print_copilot_error("Could not generate a split commit plan", exc)
|
|
532
|
+
raise typer.Exit(1)
|
|
533
|
+
|
|
534
|
+
console.print(
|
|
535
|
+
"[yellow]Staged patch units exceeded the model context window; retrying split planning with summaries only.[/yellow]"
|
|
536
|
+
)
|
|
537
|
+
else:
|
|
527
538
|
return parse_split_plan_response(
|
|
528
539
|
response,
|
|
529
540
|
patch_units,
|
|
530
541
|
)
|
|
542
|
+
|
|
543
|
+
compact_planner_prompt = build_split_plan_prompt(
|
|
544
|
+
status,
|
|
545
|
+
patch_units,
|
|
546
|
+
preferred_commits=preferred_commits,
|
|
547
|
+
context=context,
|
|
548
|
+
include_patches=False,
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
try:
|
|
552
|
+
with console.status(
|
|
553
|
+
"[yellow]Planning split commits from [bold]patch summaries[/] ...[/yellow]"
|
|
554
|
+
):
|
|
555
|
+
response = ask_copilot_with_system_prompt(
|
|
556
|
+
planner_system_prompt,
|
|
557
|
+
compact_planner_prompt,
|
|
558
|
+
model=model,
|
|
559
|
+
http_client_config=http_client_config,
|
|
560
|
+
)
|
|
531
561
|
except github_copilot.CopilotError as exc:
|
|
532
562
|
print_copilot_error("Could not generate a split commit plan", exc)
|
|
533
563
|
raise typer.Exit(1)
|
|
534
564
|
|
|
565
|
+
return parse_split_plan_response(
|
|
566
|
+
response,
|
|
567
|
+
patch_units,
|
|
568
|
+
)
|
|
569
|
+
|
|
535
570
|
|
|
536
571
|
def request_split_commit_messages(
|
|
537
572
|
plan: SplitCommitPlan,
|
|
@@ -173,6 +173,7 @@ def build_split_plan_prompt(
|
|
|
173
173
|
*,
|
|
174
174
|
preferred_commits: int | None = None,
|
|
175
175
|
context: str = "",
|
|
176
|
+
include_patches: bool = True,
|
|
176
177
|
) -> str:
|
|
177
178
|
"""Build the user prompt used to request a split-commit plan."""
|
|
178
179
|
if not patch_units:
|
|
@@ -193,7 +194,7 @@ def build_split_plan_prompt(
|
|
|
193
194
|
"`git status`:",
|
|
194
195
|
f"```\n{status.get_porcelain_output()}\n```",
|
|
195
196
|
"",
|
|
196
|
-
"Patch units:",
|
|
197
|
+
"Patch units:" if include_patches else "Patch units (summaries only):",
|
|
197
198
|
]
|
|
198
199
|
)
|
|
199
200
|
|
|
@@ -204,10 +205,15 @@ def build_split_plan_prompt(
|
|
|
204
205
|
f"Path: {unit.path}",
|
|
205
206
|
f"Kind: {unit.kind}",
|
|
206
207
|
f"Summary: {unit.summary}",
|
|
207
|
-
"Patch:",
|
|
208
|
-
f"```diff\n{unit.patch}\n```",
|
|
209
208
|
]
|
|
210
209
|
)
|
|
210
|
+
if include_patches:
|
|
211
|
+
prompt_parts.extend(
|
|
212
|
+
[
|
|
213
|
+
"Patch:",
|
|
214
|
+
f"```diff\n{unit.patch}\n```",
|
|
215
|
+
]
|
|
216
|
+
)
|
|
211
217
|
|
|
212
218
|
return "\n".join(prompt_parts)
|
|
213
219
|
|
|
@@ -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=k-HCs6skTLysyyHUN-lS9NjrsURvXcq7E2MgdClRnxc,32472
|
|
3
3
|
git_copilot_commit/git.py,sha256=vNuh2j8TGmocLio4XgPpbXIktlgczNdEt2Fg1c40wuk,14962
|
|
4
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
|
-
git_copilot_commit/split_commits.py,sha256=
|
|
7
|
+
git_copilot_commit/split_commits.py,sha256=rHyuVJggjmYjbva7BVqsM3aZRxUgOKkuZtxxvFRcu6Q,15060
|
|
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
10
|
git_copilot_commit/prompts/split-commit-planner-prompt.md,sha256=ABKuVVyrkHsb3QV6qyS--W5yvKBoZhtq8xJEb3OZQvI,1088
|
|
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.
|
|
11
|
+
git_copilot_commit-0.5.4.dist-info/METADATA,sha256=gvVJMTP6Akuyws8U-z0O_ANqUAnq9fAJoEO982M25Q0,6649
|
|
12
|
+
git_copilot_commit-0.5.4.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
13
|
+
git_copilot_commit-0.5.4.dist-info/entry_points.txt,sha256=-D4bQqiuSPwQJG2zx--vJbZD1iqB5coUfoJ_gmC3rSg,66
|
|
14
|
+
git_copilot_commit-0.5.4.dist-info/licenses/LICENSE,sha256=14lNZAoKJPI1U7eGpletjN_PFm1JwP1vT_0jFKY6eWg,1065
|
|
15
|
+
git_copilot_commit-0.5.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|