lgit-cli 5.3.0__py3-none-any.whl → 5.5.0__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.
- lgit/__init__.py +1 -1
- lgit/api.py +52 -13
- lgit/changelog.py +612 -221
- lgit/cli.py +140 -27
- lgit/compose.py +367 -75
- lgit/config.py +63 -0
- lgit/diffing.py +42 -0
- lgit/git.py +25 -0
- lgit/judgment.py +330 -0
- lgit/mechanical.py +337 -0
- lgit/models.py +75 -0
- lgit/patch.py +50 -3
- lgit/resources/model_pricing.json +2 -1
- lgit/resources/prompts/analysis.md +2 -0
- lgit/resources/prompts/fast.md +2 -0
- lgit/resources/prompts/map.md +2 -0
- lgit/resources/prompts/synthesis.md +116 -0
- lgit/synthesis.py +285 -0
- lgit/templates.py +70 -5
- lgit/tokens.py +5 -1
- {lgit_cli-5.3.0.dist-info → lgit_cli-5.5.0.dist-info}/METADATA +30 -3
- {lgit_cli-5.3.0.dist-info → lgit_cli-5.5.0.dist-info}/RECORD +25 -21
- {lgit_cli-5.3.0.dist-info → lgit_cli-5.5.0.dist-info}/WHEEL +1 -1
- {lgit_cli-5.3.0.dist-info → lgit_cli-5.5.0.dist-info}/entry_points.txt +0 -0
- {lgit_cli-5.3.0.dist-info → lgit_cli-5.5.0.dist-info}/licenses/LICENSE +0 -0
lgit/__init__.py
CHANGED
lgit/api.py
CHANGED
|
@@ -18,7 +18,7 @@ import httpx
|
|
|
18
18
|
from jinja2 import Template
|
|
19
19
|
|
|
20
20
|
from . import cache as llm_cache
|
|
21
|
-
from . import pricing, profile
|
|
21
|
+
from . import pricing, profile, style
|
|
22
22
|
from .diffing import condense_stat
|
|
23
23
|
from .errors import ApiContextLengthExceeded, ApiError, LgitError
|
|
24
24
|
from .markdown_output import (
|
|
@@ -34,7 +34,14 @@ from .markdown_output import (
|
|
|
34
34
|
from .markdown_output import (
|
|
35
35
|
strip_type_prefix as strip_markdown_type_prefix,
|
|
36
36
|
)
|
|
37
|
-
from .models import
|
|
37
|
+
from .models import (
|
|
38
|
+
CommitSummary,
|
|
39
|
+
ConventionalAnalysis,
|
|
40
|
+
ConventionalCommit,
|
|
41
|
+
ResolvedApiMode,
|
|
42
|
+
resolve_model_chain,
|
|
43
|
+
resolve_model_name,
|
|
44
|
+
)
|
|
38
45
|
from .normalization import post_process_commit_message
|
|
39
46
|
from .validation import is_past_tense_first_word, repair_summary_tense, validate_summary_quality
|
|
40
47
|
|
|
@@ -200,19 +207,19 @@ def strip_type_prefix(summary: str, commit_type: str | None = None, scope: str |
|
|
|
200
207
|
|
|
201
208
|
|
|
202
209
|
def summary_from_holistic_analysis(analysis: ConventionalAnalysis, config: CommitConfig, stat: str = "") -> str | None:
|
|
203
|
-
"""
|
|
204
|
-
|
|
205
|
-
del stat
|
|
210
|
+
"""Reuse a compliant analysis summary, repairing tense; return None when a summary call is needed."""
|
|
206
211
|
if not analysis.summary or not str(analysis.summary).strip():
|
|
207
212
|
return None
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
commit_type = str(analysis.commit_type)
|
|
214
|
+
scope = None if analysis.scope is None else str(analysis.scope)
|
|
215
|
+
draft = strip_type_prefix(str(analysis.summary).strip(), commit_type, scope).rstrip(" .")
|
|
216
|
+
summary, _ = _accept_summary(draft, commit_type, stat)
|
|
217
|
+
if summary is None:
|
|
218
|
+
return None
|
|
219
|
+
prefix = f"{commit_type}({scope}): " if scope else f"{commit_type}: "
|
|
220
|
+
if len((prefix + summary).encode("utf-8")) > min(config.summary_soft_limit, config.summary_hard_limit):
|
|
214
221
|
return None
|
|
215
|
-
return
|
|
222
|
+
return summary
|
|
216
223
|
|
|
217
224
|
|
|
218
225
|
async def generate_summary_from_analysis(
|
|
@@ -287,7 +294,6 @@ async def generate_analysis_with_map_reduce(
|
|
|
287
294
|
and fires only when the map-reduce path is taken.
|
|
288
295
|
"""
|
|
289
296
|
|
|
290
|
-
from . import style
|
|
291
297
|
from .map_reduce import run_map_reduce, should_use_map_reduce
|
|
292
298
|
from .tokens import create_token_counter
|
|
293
299
|
|
|
@@ -498,6 +504,39 @@ def decode_cache_payload(tool_name: str, operation: str, stored: str) -> tuple[A
|
|
|
498
504
|
|
|
499
505
|
|
|
500
506
|
async def _run_oneshot_response(config: CommitConfig, spec: OneShotSpec) -> OneShotResponse:
|
|
507
|
+
"""Run one request, walking the model chain when a model fails outright.
|
|
508
|
+
|
|
509
|
+
Each candidate gets the full retry budget; a model that still fails — 5xx
|
|
510
|
+
stream stalls, refusals, or a context window that cannot hold the prompt —
|
|
511
|
+
hands off to the next entry of the ``;``-separated chain instead of failing
|
|
512
|
+
the whole run.
|
|
513
|
+
"""
|
|
514
|
+
|
|
515
|
+
candidates = resolve_model_chain(spec.model or "")
|
|
516
|
+
for idx, candidate in enumerate(candidates):
|
|
517
|
+
try:
|
|
518
|
+
return await _run_oneshot_attempt(config, replace(spec, model=candidate))
|
|
519
|
+
except (
|
|
520
|
+
LgitError,
|
|
521
|
+
httpx.TimeoutException,
|
|
522
|
+
httpx.TransportError,
|
|
523
|
+
json.JSONDecodeError,
|
|
524
|
+
ValueError,
|
|
525
|
+
TypeError,
|
|
526
|
+
) as exc:
|
|
527
|
+
if idx == len(candidates) - 1:
|
|
528
|
+
raise
|
|
529
|
+
fallback = candidates[idx + 1]
|
|
530
|
+
style.warn(f"{spec.operation}: {candidate} failed ({_fallback_reason(exc)}); falling back to {fallback}")
|
|
531
|
+
raise LgitError(f"No model candidates configured for {spec.operation}")
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
def _fallback_reason(exc: Exception) -> str:
|
|
535
|
+
text = str(exc).strip() or type(exc).__name__
|
|
536
|
+
return text if len(text) <= 160 else f"{text[:157]}..."
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
async def _run_oneshot_attempt(config: CommitConfig, spec: OneShotSpec) -> OneShotResponse:
|
|
501
540
|
mode = _resolved_mode(config, spec.model or "")
|
|
502
541
|
cache_entry = _build_cache_entry(config, spec)
|
|
503
542
|
if cache_entry is not None:
|