lgit-cli 5.0.0__py3-none-any.whl → 5.1.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/changelog.py +5 -7
- lgit/cli.py +9 -1
- lgit/compose.py +4 -2
- lgit/diffing.py +68 -1
- lgit/rewrite.py +2 -2
- {lgit_cli-5.0.0.dist-info → lgit_cli-5.1.0.dist-info}/METADATA +1 -1
- {lgit_cli-5.0.0.dist-info → lgit_cli-5.1.0.dist-info}/RECORD +10 -10
- {lgit_cli-5.0.0.dist-info → lgit_cli-5.1.0.dist-info}/WHEEL +0 -0
- {lgit_cli-5.0.0.dist-info → lgit_cli-5.1.0.dist-info}/entry_points.txt +0 -0
- {lgit_cli-5.0.0.dist-info → lgit_cli-5.1.0.dist-info}/licenses/LICENSE +0 -0
lgit/changelog.py
CHANGED
|
@@ -12,7 +12,7 @@ from pathlib import Path
|
|
|
12
12
|
from typing import TYPE_CHECKING, Any
|
|
13
13
|
|
|
14
14
|
from . import style
|
|
15
|
-
from .diffing import smart_truncate_diff
|
|
15
|
+
from .diffing import scrub_diff_for_prompt, smart_truncate_diff
|
|
16
16
|
from .errors import GitError, ValidationFailure
|
|
17
17
|
from .git import run_git
|
|
18
18
|
from .markdown_output import parse_changelog_response
|
|
@@ -98,7 +98,7 @@ def prepare_changelog_flow(args: Any, config: CommitConfig) -> PreparedChangelog
|
|
|
98
98
|
|
|
99
99
|
max_diff_length = config.max_diff_length
|
|
100
100
|
for boundary in detect_boundaries(candidate_files, changelogs, repo_dir):
|
|
101
|
-
diff = _diff_for_files(boundary.files, repo_dir, max_diff_length)
|
|
101
|
+
diff = scrub_diff_for_prompt(_diff_for_files(boundary.files, repo_dir, max_diff_length))
|
|
102
102
|
if not diff.strip():
|
|
103
103
|
continue
|
|
104
104
|
if len(diff) > max_diff_length:
|
|
@@ -398,11 +398,9 @@ class ChangelogWeaver:
|
|
|
398
398
|
repo_dir,
|
|
399
399
|
)
|
|
400
400
|
states = {state.changelog_path: state for state in self.boundaries}
|
|
401
|
-
group_diff = (
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
else diff
|
|
405
|
-
)
|
|
401
|
+
group_diff = scrub_diff_for_prompt(diff)
|
|
402
|
+
if len(group_diff) > self.config.max_diff_length:
|
|
403
|
+
group_diff = smart_truncate_diff(group_diff, self.config.max_diff_length, self.config)
|
|
406
404
|
for boundary in matched:
|
|
407
405
|
state = states[boundary.changelog_path]
|
|
408
406
|
try:
|
lgit/cli.py
CHANGED
|
@@ -29,7 +29,13 @@ from .changelog import (
|
|
|
29
29
|
run_changelog_flow,
|
|
30
30
|
)
|
|
31
31
|
from .config import CommitConfig
|
|
32
|
-
from .diffing import
|
|
32
|
+
from .diffing import (
|
|
33
|
+
classify_diff_whitespace,
|
|
34
|
+
scrub_diff_for_prompt,
|
|
35
|
+
smart_truncate_diff,
|
|
36
|
+
strip_whitespace_only_files,
|
|
37
|
+
truncate_diff_by_lines,
|
|
38
|
+
)
|
|
33
39
|
from .errors import LgitError, NoChanges, ValidationFailure
|
|
34
40
|
from .map_reduce import FileObservation, should_use_map_reduce
|
|
35
41
|
from .markdown_output import fallback_summary
|
|
@@ -532,6 +538,7 @@ async def _generate_fast_workflow(
|
|
|
532
538
|
) -> ConventionalCommit:
|
|
533
539
|
with profile.section("strip_whitespace_only", collector):
|
|
534
540
|
diff = strip_whitespace_only_files(diff) or diff
|
|
541
|
+
diff = scrub_diff_for_prompt(diff)
|
|
535
542
|
with profile.section("truncate_diff_by_lines", collector):
|
|
536
543
|
diff = truncate_diff_by_lines(diff, 10_000, config)
|
|
537
544
|
with profile.section("extract_scope_candidates", collector):
|
|
@@ -559,6 +566,7 @@ async def _generate_standard_workflow(
|
|
|
559
566
|
style.status(f"{style.info('›')} Analyzing {style.bold(mode.value)} changes...")
|
|
560
567
|
with profile.section("strip_whitespace_only", collector):
|
|
561
568
|
diff = strip_whitespace_only_files(diff) or diff
|
|
569
|
+
diff = scrub_diff_for_prompt(diff)
|
|
562
570
|
with profile.section("extract_scope_candidates", collector):
|
|
563
571
|
scope_candidates, _wide = (
|
|
564
572
|
extract_scope_candidates(numstat, args.target, args.dir, config) if numstat.strip() else ("(none)", False)
|
lgit/compose.py
CHANGED
|
@@ -350,8 +350,9 @@ async def run_compose_round(
|
|
|
350
350
|
|
|
351
351
|
token_counter = _create_token_counter(config)
|
|
352
352
|
observations = []
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
planning_diff = diffing.scrub_diff_for_prompt(snapshot.diff)
|
|
354
|
+
if not _is_large_compose_snapshot(snapshot) and _should_use_map_reduce(planning_diff, config, token_counter):
|
|
355
|
+
observations = await map_reduce.observe_diff_files(planning_diff, config.summary_model, config, token_counter)
|
|
355
356
|
if observations:
|
|
356
357
|
_save_debug_artifact(
|
|
357
358
|
args,
|
|
@@ -1731,6 +1732,7 @@ async def _message_parts_from_api(
|
|
|
1731
1732
|
counter: Any,
|
|
1732
1733
|
debug_prefix: str,
|
|
1733
1734
|
) -> tuple[list[str], str | None]:
|
|
1735
|
+
diff = diffing.scrub_diff_for_prompt(diff)
|
|
1734
1736
|
strategy = _compose_analysis_strategy(diff, config, counter)
|
|
1735
1737
|
if strategy is ComposeAnalysisStrategy.MAP_REDUCE:
|
|
1736
1738
|
analysis = await map_reduce.run_map_reduce(
|
lgit/diffing.py
CHANGED
|
@@ -116,7 +116,11 @@ class FileDiff:
|
|
|
116
116
|
keep_start = 15
|
|
117
117
|
keep_end = 10
|
|
118
118
|
omitted = len(lines) - keep_start - keep_end
|
|
119
|
-
|
|
119
|
+
content = "\n".join([*lines[:keep_start], f"... (truncated {omitted} lines) ...", *lines[-keep_end:]])
|
|
120
|
+
if _byte_len(content) <= available:
|
|
121
|
+
self.content = content
|
|
122
|
+
return
|
|
123
|
+
self.content = _truncate_utf8(content, available) + truncation_suffix
|
|
120
124
|
return
|
|
121
125
|
|
|
122
126
|
self.content = _truncate_utf8(self.content, available) + truncation_suffix
|
|
@@ -133,6 +137,43 @@ def _truncate_utf8(text: str, max_bytes: int) -> str:
|
|
|
133
137
|
return data[:max_bytes].decode("utf-8", errors="ignore")
|
|
134
138
|
|
|
135
139
|
|
|
140
|
+
# No human-authored diff line this long carries commit-analysis signal; anything
|
|
141
|
+
# beyond it is a machine-generated payload (hex/base64 blob, minified bundle,
|
|
142
|
+
# embedded asset) that only burns prompt tokens.
|
|
143
|
+
BLOB_LINE_THRESHOLD = 512
|
|
144
|
+
_BLOB_KEEP_HEAD = 120
|
|
145
|
+
_BLOB_KEEP_TAIL = 24
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def _format_omitted_size(count: int) -> str:
|
|
149
|
+
if count >= 1024 * 1024:
|
|
150
|
+
return f"{count / (1024 * 1024):.1f}MB"
|
|
151
|
+
if count >= 1024:
|
|
152
|
+
return f"{count / 1024:.0f}KB"
|
|
153
|
+
return f"{count}B"
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def collapse_blob_lines(diff: str, threshold: int = BLOB_LINE_THRESHOLD) -> str:
|
|
157
|
+
"""Collapse blob-like lines (hex/base64 payloads, minified bundles, long string literals) for LLM prompts.
|
|
158
|
+
|
|
159
|
+
Each line longer than ``threshold`` is reduced to its head, an ``[..omitted 14KB..]``
|
|
160
|
+
marker, and its tail. The result is no longer an applicable patch — use only on
|
|
161
|
+
diff text bound for prompts, never on diffs used for staging.
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
if len(diff) <= threshold:
|
|
165
|
+
return diff
|
|
166
|
+
lines = diff.split("\n")
|
|
167
|
+
changed = False
|
|
168
|
+
for idx, line in enumerate(lines):
|
|
169
|
+
if len(line) <= threshold:
|
|
170
|
+
continue
|
|
171
|
+
omitted = len(line) - _BLOB_KEEP_HEAD - _BLOB_KEEP_TAIL
|
|
172
|
+
lines[idx] = f"{line[:_BLOB_KEEP_HEAD]}[..omitted {_format_omitted_size(omitted)}..]{line[-_BLOB_KEEP_TAIL:]}"
|
|
173
|
+
changed = True
|
|
174
|
+
return "\n".join(lines) if changed else diff
|
|
175
|
+
|
|
176
|
+
|
|
136
177
|
@dataclass(slots=True)
|
|
137
178
|
class WhitespaceReport:
|
|
138
179
|
"""Classification of a diff by whitespace-only and substantive files."""
|
|
@@ -223,6 +264,32 @@ def reconstruct_diff(files: list[FileDiff] | tuple[FileDiff, ...]) -> str:
|
|
|
223
264
|
return "\n".join(sections)
|
|
224
265
|
|
|
225
266
|
|
|
267
|
+
# Per-file cap for prompt-bound diffs: a single file section still larger than
|
|
268
|
+
# this after blob-line collapse is generated or vendored content whose bulk
|
|
269
|
+
# carries no commit-analysis signal.
|
|
270
|
+
MAX_PROMPT_FILE_BYTES = 100_000
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def scrub_diff_for_prompt(diff: str, max_file_bytes: int = MAX_PROMPT_FILE_BYTES) -> str:
|
|
274
|
+
"""Prepare a diff for LLM prompts: collapse blob lines, then cap oversized file sections.
|
|
275
|
+
|
|
276
|
+
Oversized sections are collapsed to their headers plus edge lines via
|
|
277
|
+
:meth:`FileDiff.truncate`. Prompt-side only — the result is not an applicable
|
|
278
|
+
patch; never use it for staging.
|
|
279
|
+
"""
|
|
280
|
+
|
|
281
|
+
diff = collapse_blob_lines(diff)
|
|
282
|
+
if len(diff) <= max_file_bytes:
|
|
283
|
+
return diff
|
|
284
|
+
files = parse_diff(diff)
|
|
285
|
+
if not any(file.size > max_file_bytes for file in files):
|
|
286
|
+
return diff
|
|
287
|
+
for file in files:
|
|
288
|
+
if file.size > max_file_bytes:
|
|
289
|
+
file.truncate(max_file_bytes)
|
|
290
|
+
return reconstruct_diff(files)
|
|
291
|
+
|
|
292
|
+
|
|
226
293
|
def smart_truncate_diff(
|
|
227
294
|
diff: str,
|
|
228
295
|
max_length: int,
|
lgit/rewrite.py
CHANGED
|
@@ -14,7 +14,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
14
14
|
from . import style
|
|
15
15
|
from .analysis import extract_scope_candidates
|
|
16
16
|
from .api import generate_conventional_analysis, generate_summary_from_analysis
|
|
17
|
-
from .diffing import smart_truncate_diff
|
|
17
|
+
from .diffing import scrub_diff_for_prompt, smart_truncate_diff
|
|
18
18
|
from .errors import ValidationFailure
|
|
19
19
|
from .git import (
|
|
20
20
|
check_working_tree_clean,
|
|
@@ -168,7 +168,7 @@ async def generate_for_commit(commit: Any, config: CommitConfig, dir: str | os.P
|
|
|
168
168
|
"""Generate and validate one replacement conventional commit message."""
|
|
169
169
|
|
|
170
170
|
commit_hash = commit.hash
|
|
171
|
-
diff = get_git_diff("commit", commit_hash, dir, config)
|
|
171
|
+
diff = scrub_diff_for_prompt(get_git_diff("commit", commit_hash, dir, config))
|
|
172
172
|
stat = get_git_stat("commit", commit_hash, dir, config)
|
|
173
173
|
max_diff_length = config.max_diff_length
|
|
174
174
|
if len(diff) > max_diff_length:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lgit-cli
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.1.0
|
|
4
4
|
Summary: AI-powered git commit message generator using Claude and other LLMs via OpenAI-compatible APIs
|
|
5
5
|
Project-URL: Homepage, https://github.com/can1357/llm-git
|
|
6
6
|
Project-URL: Repository, https://github.com/can1357/llm-git
|
|
@@ -3,11 +3,11 @@ lgit/__main__.py,sha256=VbaRO8-0ehWv7zA27BpyHYWTQVvt5M-aG5HnWr7ws0U,165
|
|
|
3
3
|
lgit/analysis.py,sha256=j8bduuV6pqvMuza-r_RNJDe5SMQGKTtU6gwktaAeSS4,10671
|
|
4
4
|
lgit/api.py,sha256=34jBaT8X_qH62weNCSmpI4JtTqmmVmOpwxlEthPpxi4,35543
|
|
5
5
|
lgit/cache.py,sha256=mrF5g74HMP9FR9kCJgwBcT4l34DuAuBaAkC1pCV7x6M,12477
|
|
6
|
-
lgit/changelog.py,sha256=
|
|
7
|
-
lgit/cli.py,sha256=
|
|
8
|
-
lgit/compose.py,sha256=
|
|
6
|
+
lgit/changelog.py,sha256=UL48dCYLre4I1X-8HW1JRTy4NgU2TANyMOOEIoVPvT0,37305
|
|
7
|
+
lgit/cli.py,sha256=2svPdaTKspreB6gTv8dH_VGLeae34mOx4VI9YLRTWn4,52517
|
|
8
|
+
lgit/compose.py,sha256=S4cSJ5CtFjM7_U_jbqr22vmIJg1ZjYudqpmUPbzfoTM,76747
|
|
9
9
|
lgit/config.py,sha256=VI5zJtsr2WHRH6WbI-KKsaLUEtoyEZx-xayCbrTaMZ4,14215
|
|
10
|
-
lgit/diffing.py,sha256=
|
|
10
|
+
lgit/diffing.py,sha256=9z1gQdRYQg6Wsujt9tqgM7mfyXj2AkT0lfnaM6cKaj0,15819
|
|
11
11
|
lgit/errors.py,sha256=DkPJKA2ag5KbBoyuRk1d8zKgz9Mp1qRoLVBGRudlqkg,3457
|
|
12
12
|
lgit/git.py,sha256=_wavbMwewf0lP1fZrrhgW5yD36jwWUC87Y7jfIikIEk,31543
|
|
13
13
|
lgit/map_reduce.py,sha256=4I1kRlMCuK86_pbU1e_ZsnyfudCwscGDLS05GVNeH60,17840
|
|
@@ -19,7 +19,7 @@ lgit/pricing.py,sha256=uVBsXKOp7WLWswiHOQO_0HMsnZotOQUB53XgstRn8B8,6342
|
|
|
19
19
|
lgit/profile.py,sha256=QAR5jEuS6za6iNjDapRcSjlSuREZDlYAB1gpPQOq1G0,12977
|
|
20
20
|
lgit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
21
|
lgit/repo.py,sha256=eflCUY_XvTx8NY-KES5_BsyxpQczFEiT46eV2Fi4itQ,8926
|
|
22
|
-
lgit/rewrite.py,sha256=
|
|
22
|
+
lgit/rewrite.py,sha256=PX6Pf7fS9ySU5DFdsvR2apecX_A6tZ8u5jTbnOERm5U,8771
|
|
23
23
|
lgit/style.py,sha256=gfQYsUU-6nZFVhFkDBw6kWpsC3y7cGjOyUCJTV9ModY,7504
|
|
24
24
|
lgit/templates.py,sha256=T9J2k3Tk-uAriD43BzguSBR30GFEId1tiVg7Oo49__4,11789
|
|
25
25
|
lgit/tokens.py,sha256=BbAhjIUtCXVBStPXzq4ZeuZa8H5r9ZqZJUnA1XHD_MI,3123
|
|
@@ -41,8 +41,8 @@ lgit/testing/compare.py,sha256=jRY98uLclVPyQ7e1TMqFVz2cjUi6kwwn2dkQyR_xsgY,1834
|
|
|
41
41
|
lgit/testing/fixture.py,sha256=VXk02ZzFTBHHhYax6bsoGowdyz06nmrJm3ylenyfGbU,13654
|
|
42
42
|
lgit/testing/report.py,sha256=wb7YnP_lsYwsg5OIFtsIC1bMHtK42Mttul_zQcwRNpk,9036
|
|
43
43
|
lgit/testing/runner.py,sha256=5Sr4QvEOTdE7CAxB-CKcNJClEZARQGqB-t_6P6-UA2c,9514
|
|
44
|
-
lgit_cli-5.
|
|
45
|
-
lgit_cli-5.
|
|
46
|
-
lgit_cli-5.
|
|
47
|
-
lgit_cli-5.
|
|
48
|
-
lgit_cli-5.
|
|
44
|
+
lgit_cli-5.1.0.dist-info/METADATA,sha256=haooGGBss1jxE2HNOk9I50aFj3Tycg9OKgpOKPhJN1o,9565
|
|
45
|
+
lgit_cli-5.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
46
|
+
lgit_cli-5.1.0.dist-info/entry_points.txt,sha256=CUSsokc0V3oVHQ2Z1ocL09wV7Krhm0SSfLZpnRMBdA0,39
|
|
47
|
+
lgit_cli-5.1.0.dist-info/licenses/LICENSE,sha256=6dqVzjngLuIcUMd4wWLXPLpv-Pi8gySZAEE3hSN5iKw,1076
|
|
48
|
+
lgit_cli-5.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|