lgit-cli 5.2.0__py3-none-any.whl → 5.3.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/cli.py +3 -6
- lgit/compose.py +166 -24
- lgit/config.py +7 -0
- lgit/diffing.py +3 -3
- lgit/map_reduce.py +20 -9
- lgit/resources/prompts/compose-intent.md +17 -10
- {lgit_cli-5.2.0.dist-info → lgit_cli-5.3.0.dist-info}/METADATA +1 -1
- {lgit_cli-5.2.0.dist-info → lgit_cli-5.3.0.dist-info}/RECORD +11 -11
- {lgit_cli-5.2.0.dist-info → lgit_cli-5.3.0.dist-info}/WHEEL +0 -0
- {lgit_cli-5.2.0.dist-info → lgit_cli-5.3.0.dist-info}/entry_points.txt +0 -0
- {lgit_cli-5.2.0.dist-info → lgit_cli-5.3.0.dist-info}/licenses/LICENSE +0 -0
lgit/cli.py
CHANGED
|
@@ -437,6 +437,7 @@ def _load_config(args: argparse.Namespace) -> CommitConfig:
|
|
|
437
437
|
config.analysis_model = resolved_model
|
|
438
438
|
config.summary_model = resolved_model
|
|
439
439
|
config.map_model = resolved_model
|
|
440
|
+
config.fast_model = resolved_model
|
|
440
441
|
if args.sign:
|
|
441
442
|
config.gpg_sign = True
|
|
442
443
|
if args.signoff:
|
|
@@ -546,7 +547,7 @@ async def _generate_fast_workflow(
|
|
|
546
547
|
scope_candidates, _wide = (
|
|
547
548
|
extract_scope_candidates(numstat, args.target, args.dir, config) if numstat.strip() else ("(none)", False)
|
|
548
549
|
)
|
|
549
|
-
style.status(f"{style.dim('›')} {style.dim('fast mode:')} {style.model(
|
|
550
|
+
style.status(f"{style.dim('›')} {style.dim('fast mode:')} {style.model(config.effective_fast_model)}")
|
|
550
551
|
style.status(f"{style.info('›')} Analyzing {style.bold(mode.value)} changes...")
|
|
551
552
|
if changelog_runner is not None:
|
|
552
553
|
changelog_runner.start_with_diff()
|
|
@@ -610,10 +611,6 @@ async def _generate_standard_workflow(
|
|
|
610
611
|
return await _message_from_analysis(analysis, config, stat, user_context, args, collector)
|
|
611
612
|
|
|
612
613
|
|
|
613
|
-
def _resolve_fast_mode_model(args: argparse.Namespace, config: CommitConfig) -> str:
|
|
614
|
-
return str(config.analysis_model if args.model or config.legacy_model else resolve_model_name("haiku"))
|
|
615
|
-
|
|
616
|
-
|
|
617
614
|
async def _generate_fast_message(
|
|
618
615
|
config: CommitConfig,
|
|
619
616
|
stat: str,
|
|
@@ -623,7 +620,7 @@ async def _generate_fast_message(
|
|
|
623
620
|
args: argparse.Namespace,
|
|
624
621
|
collector: profile.TimingCollector | None = None,
|
|
625
622
|
) -> ConventionalCommit:
|
|
626
|
-
fast_config = replace(config, analysis_model=
|
|
623
|
+
fast_config = replace(config, analysis_model=config.effective_fast_model)
|
|
627
624
|
try:
|
|
628
625
|
async with profile.section("generate_fast_commit", collector):
|
|
629
626
|
message = await generate_fast_commit(
|
lgit/compose.py
CHANGED
|
@@ -51,11 +51,13 @@ class _ComposeArgs(Protocol):
|
|
|
51
51
|
debug_output: str | None
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
COMPOSE_PLAN_SCHEMA_VERSION = "
|
|
54
|
+
COMPOSE_PLAN_SCHEMA_VERSION = "v4"
|
|
55
55
|
COMPOSE_MESSAGE_PARALLELISM = 8
|
|
56
56
|
# Compose planning intentionally switches representation as snapshots grow:
|
|
57
57
|
# small/medium snapshots preserve per-file detail, while large snapshots plan by
|
|
58
58
|
# path area to keep prompts bounded and avoid monolithic LLM output.
|
|
59
|
+
# Large snapshots stop subdividing once they expose enough workstream-level areas;
|
|
60
|
+
# repositories with only a few workstreams keep splitting for useful granularity.
|
|
59
61
|
MAX_OBSERVATIONS_PER_FILE = 3
|
|
60
62
|
COMPOSE_SUMMARY_MEDIUM_FILE_THRESHOLD = 60
|
|
61
63
|
COMPOSE_SUMMARY_MEDIUM_HUNK_THRESHOLD = 200
|
|
@@ -64,8 +66,11 @@ COMPOSE_SUMMARY_LARGE_HUNK_THRESHOLD = 500
|
|
|
64
66
|
COMPOSE_AREA_TARGET_MAX_FILES = 60
|
|
65
67
|
COMPOSE_AREA_TARGET_MAX_HUNKS = 140
|
|
66
68
|
COMPOSE_AREA_TARGET_MAX_DEPTH = 6
|
|
67
|
-
|
|
69
|
+
COMPOSE_AREA_TARGET_MAX_COUNT = 48
|
|
70
|
+
COMPOSE_AREA_TARGET_MIN_COUNT = 24
|
|
71
|
+
COMPOSE_MONOLITH_FALLBACK_TARGET_THRESHOLD = 3
|
|
68
72
|
COMPOSE_MONOLITH_FALLBACK_WORKSTREAM_THRESHOLD = 3
|
|
73
|
+
COMPOSE_GRAB_BAG_WORKSTREAM_THRESHOLD = 5
|
|
69
74
|
MAX_BIND_FILES_PER_REQUEST = 18
|
|
70
75
|
MAX_BIND_HUNKS_PER_REQUEST = 120
|
|
71
76
|
_DEPENDENCY_MANIFESTS = {
|
|
@@ -362,7 +367,7 @@ async def run_compose_round(
|
|
|
362
367
|
[_observation_to_jsonable(item) for item in observations],
|
|
363
368
|
)
|
|
364
369
|
|
|
365
|
-
max_commits = args.compose_max_commits or
|
|
370
|
+
max_commits = args.compose_max_commits or 32
|
|
366
371
|
model = config.analysis_model
|
|
367
372
|
plan = _load_cached_plan(repo_dir, snapshot, max_commits, model)
|
|
368
373
|
if plan is None:
|
|
@@ -466,7 +471,8 @@ def _analyze_compose_intent_from_mapping(
|
|
|
466
471
|
raw_groups = data.get("groups", ())
|
|
467
472
|
groups = [_intent_group_from_mapping(item, idx) for idx, item in enumerate(raw_groups, start=1)]
|
|
468
473
|
planning_index = _build_planning_index(snapshot)
|
|
469
|
-
|
|
474
|
+
normalized = _normalize_intent_plan(snapshot, planning_index, groups, config, max_commits)
|
|
475
|
+
return _split_grab_bag_groups(snapshot, normalized, max_commits)
|
|
470
476
|
|
|
471
477
|
|
|
472
478
|
async def _analyze_compose_intent(
|
|
@@ -745,6 +751,11 @@ def _build_planning_index(snapshot: ComposeSnapshot) -> PlanningIndex:
|
|
|
745
751
|
aliases[target.target_id] = target.target_id
|
|
746
752
|
aliases[target.target_id.upper()] = target.target_id
|
|
747
753
|
aliases[_normalize_file_reference(target.label)] = target.target_id
|
|
754
|
+
for file_id in target.file_ids:
|
|
755
|
+
file = snapshot.file_by_id(file_id)
|
|
756
|
+
if file is not None:
|
|
757
|
+
aliases[file.file_id] = target.target_id
|
|
758
|
+
aliases[_normalize_file_reference(file.path)] = target.target_id
|
|
748
759
|
return PlanningIndex(mode=mode, targets=targets, aliases=aliases)
|
|
749
760
|
|
|
750
761
|
|
|
@@ -777,24 +788,41 @@ def _build_area_planning_targets(snapshot: ComposeSnapshot) -> list[PlanningTarg
|
|
|
777
788
|
def _collect_planning_buckets(
|
|
778
789
|
snapshot: ComposeSnapshot, file_ids: Sequence[str], depth: int
|
|
779
790
|
) -> list[tuple[str, tuple[str, ...]]]:
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
791
|
+
buckets: list[tuple[int, tuple[str, ...]]] = [(depth, tuple(file_ids))]
|
|
792
|
+
while len(buckets) < COMPOSE_AREA_TARGET_MIN_COUNT:
|
|
793
|
+
chosen: tuple[tuple[int, int, int, int], int, int, list[list[str]]] | None = None
|
|
794
|
+
for idx, (bucket_depth, bucket_file_ids) in enumerate(buckets):
|
|
795
|
+
files = [file for file_id in bucket_file_ids for file in [snapshot.file_by_id(file_id)] if file is not None]
|
|
796
|
+
hunk_count = sum(len(file.hunk_ids) for file in files)
|
|
797
|
+
max_depth = max((len(file.path.split("/")) for file in files), default=bucket_depth)
|
|
798
|
+
if (
|
|
799
|
+
(len(files) <= COMPOSE_AREA_TARGET_MAX_FILES and hunk_count <= COMPOSE_AREA_TARGET_MAX_HUNKS)
|
|
800
|
+
or bucket_depth >= COMPOSE_AREA_TARGET_MAX_DEPTH
|
|
801
|
+
or bucket_depth >= max_depth
|
|
802
|
+
):
|
|
803
|
+
continue
|
|
804
|
+
|
|
805
|
+
groups: dict[str, list[str]] = defaultdict(list)
|
|
806
|
+
for file in files:
|
|
807
|
+
groups[_prefix_at_depth(file.path, bucket_depth + 1)].append(file.file_id)
|
|
808
|
+
children = list(groups.values())
|
|
809
|
+
if len(children) > 1 and len(buckets) - 1 + len(children) > COMPOSE_AREA_TARGET_MAX_COUNT:
|
|
810
|
+
continue
|
|
811
|
+
|
|
812
|
+
pressure = max(
|
|
813
|
+
-(-len(files) // COMPOSE_AREA_TARGET_MAX_FILES),
|
|
814
|
+
-(-hunk_count // COMPOSE_AREA_TARGET_MAX_HUNKS),
|
|
815
|
+
)
|
|
816
|
+
score = (pressure, hunk_count, len(files), -idx)
|
|
817
|
+
if chosen is None or score > chosen[0]:
|
|
818
|
+
chosen = (score, idx, bucket_depth, children)
|
|
819
|
+
|
|
820
|
+
if chosen is None:
|
|
821
|
+
break
|
|
822
|
+
_, idx, bucket_depth, children = chosen
|
|
823
|
+
buckets[idx : idx + 1] = [(bucket_depth + 1, tuple(child)) for child in children]
|
|
824
|
+
|
|
825
|
+
return [(_planning_bucket_label(snapshot, ids), ids) for _, ids in buckets]
|
|
798
826
|
|
|
799
827
|
|
|
800
828
|
def _prefix_at_depth(path: str, depth: int) -> str:
|
|
@@ -914,8 +942,8 @@ def _render_planning_notes(index: PlanningIndex) -> str:
|
|
|
914
942
|
|
|
915
943
|
def _render_split_bias(index: PlanningIndex) -> str:
|
|
916
944
|
if index.mode is PlanningMode.FILE:
|
|
917
|
-
return "Prefer fewer groups when the split is uncertain."
|
|
918
|
-
return "Prefer splitting unrelated areas into separate groups. Only return one broad group if nearly every area clearly belongs to the same atomic change."
|
|
945
|
+
return "Prefer fewer groups when the split is uncertain. Keep test files in the same group as the implementation they cover."
|
|
946
|
+
return "Prefer splitting unrelated areas into separate groups. Only return one broad group if nearly every area clearly belongs to the same atomic change. Keep a tests-only area in the same group as the implementation area it covers."
|
|
919
947
|
|
|
920
948
|
|
|
921
949
|
def _normalize_file_reference(raw_file_ref: str) -> str:
|
|
@@ -1110,6 +1138,118 @@ def _normalize_intent_plan(
|
|
|
1110
1138
|
return tuple(finalized)
|
|
1111
1139
|
|
|
1112
1140
|
|
|
1141
|
+
def _split_grab_bag_groups(
|
|
1142
|
+
snapshot: ComposeSnapshot,
|
|
1143
|
+
groups: Sequence[ComposeIntentGroup],
|
|
1144
|
+
max_commits: int,
|
|
1145
|
+
) -> tuple[ComposeIntentGroup, ...]:
|
|
1146
|
+
partitions_by_index: dict[int, list[tuple[str, tuple[str, ...]]]] = {}
|
|
1147
|
+
for idx, group in enumerate(groups):
|
|
1148
|
+
partition_files: dict[str, list[str]] = {}
|
|
1149
|
+
for file_id in group.file_ids:
|
|
1150
|
+
file = snapshot.file_by_id(file_id)
|
|
1151
|
+
if file is None:
|
|
1152
|
+
continue
|
|
1153
|
+
key = "repo" if "/" not in file.path else _workstream_key_for_label(file.path)
|
|
1154
|
+
partition_files.setdefault(key, []).append(file_id)
|
|
1155
|
+
if len(partition_files) >= COMPOSE_GRAB_BAG_WORKSTREAM_THRESHOLD:
|
|
1156
|
+
partitions_by_index[idx] = [(key, tuple(file_ids)) for key, file_ids in partition_files.items()]
|
|
1157
|
+
|
|
1158
|
+
available_slots = max(0, max_commits - len(groups))
|
|
1159
|
+
split_indices: set[int] = set()
|
|
1160
|
+
for idx, partitions in sorted(partitions_by_index.items(), key=lambda item: (-len(item[1]), item[0])):
|
|
1161
|
+
extra_groups = len(partitions) - 1
|
|
1162
|
+
if extra_groups <= available_slots:
|
|
1163
|
+
split_indices.add(idx)
|
|
1164
|
+
available_slots -= extra_groups
|
|
1165
|
+
if not split_indices:
|
|
1166
|
+
return tuple(groups)
|
|
1167
|
+
|
|
1168
|
+
used_group_ids = {group.group_id for group in groups}
|
|
1169
|
+
next_group_number = 1
|
|
1170
|
+
for group_id in used_group_ids:
|
|
1171
|
+
candidate = _extract_group_id_candidate(group_id)
|
|
1172
|
+
if candidate is not None:
|
|
1173
|
+
next_group_number = max(next_group_number, int(candidate[1:]) + 1)
|
|
1174
|
+
|
|
1175
|
+
def allocate_group_id() -> str:
|
|
1176
|
+
nonlocal next_group_number
|
|
1177
|
+
while f"G{next_group_number}" in used_group_ids:
|
|
1178
|
+
next_group_number += 1
|
|
1179
|
+
group_id = f"G{next_group_number}"
|
|
1180
|
+
used_group_ids.add(group_id)
|
|
1181
|
+
next_group_number += 1
|
|
1182
|
+
return group_id
|
|
1183
|
+
|
|
1184
|
+
split_ids: dict[str, tuple[str, ...]] = {}
|
|
1185
|
+
expanded_groups: list[ComposeIntentGroup] = []
|
|
1186
|
+
for idx, group in enumerate(groups):
|
|
1187
|
+
if idx not in split_indices:
|
|
1188
|
+
expanded_groups.append(group)
|
|
1189
|
+
continue
|
|
1190
|
+
|
|
1191
|
+
partitions = partitions_by_index[idx]
|
|
1192
|
+
group_text = " ".join(
|
|
1193
|
+
(
|
|
1194
|
+
group.rationale,
|
|
1195
|
+
group.scope.as_str() if group.scope is not None else "",
|
|
1196
|
+
)
|
|
1197
|
+
)
|
|
1198
|
+
group_tokens = set(_planning_text_tokens(group_text))
|
|
1199
|
+
ranked_partitions: list[tuple[int, int, int]] = []
|
|
1200
|
+
for position, (key, file_ids) in enumerate(partitions):
|
|
1201
|
+
paths = [file.path for file_id in file_ids for file in [snapshot.file_by_id(file_id)] if file is not None]
|
|
1202
|
+
tokens = set(_planning_text_tokens(" ".join((key, *paths))))
|
|
1203
|
+
ranked_partitions.append((len(group_tokens & tokens), len(file_ids), -position))
|
|
1204
|
+
_, _, negative_primary = max(ranked_partitions)
|
|
1205
|
+
primary = -negative_primary
|
|
1206
|
+
ordered_positions = [primary, *(position for position in range(len(partitions)) if position != primary)]
|
|
1207
|
+
generated: list[ComposeIntentGroup] = []
|
|
1208
|
+
for position in ordered_positions:
|
|
1209
|
+
key, file_ids = partitions[position]
|
|
1210
|
+
if position == primary:
|
|
1211
|
+
split_group = ComposeIntentGroup(
|
|
1212
|
+
group.group_id,
|
|
1213
|
+
group.commit_type,
|
|
1214
|
+
group.scope,
|
|
1215
|
+
file_ids,
|
|
1216
|
+
group.rationale,
|
|
1217
|
+
group.dependencies,
|
|
1218
|
+
)
|
|
1219
|
+
else:
|
|
1220
|
+
split_group = ComposeIntentGroup(
|
|
1221
|
+
allocate_group_id(),
|
|
1222
|
+
_fallback_commit_type_for_group(snapshot, (key,), file_ids),
|
|
1223
|
+
_fallback_scope_for_label(key),
|
|
1224
|
+
file_ids,
|
|
1225
|
+
_fallback_rationale_for_labels((key,)),
|
|
1226
|
+
group.dependencies,
|
|
1227
|
+
)
|
|
1228
|
+
generated.append(split_group)
|
|
1229
|
+
expanded_groups.extend(generated)
|
|
1230
|
+
split_ids[group.group_id] = tuple(item.group_id for item in generated)
|
|
1231
|
+
|
|
1232
|
+
rewritten: list[ComposeIntentGroup] = []
|
|
1233
|
+
for group in expanded_groups:
|
|
1234
|
+
dependencies: list[str] = []
|
|
1235
|
+
for dependency in group.dependencies:
|
|
1236
|
+
for expanded_dependency in split_ids.get(dependency, (dependency,)):
|
|
1237
|
+
if expanded_dependency != group.group_id and expanded_dependency not in dependencies:
|
|
1238
|
+
dependencies.append(expanded_dependency)
|
|
1239
|
+
rewritten.append(
|
|
1240
|
+
ComposeIntentGroup(
|
|
1241
|
+
group.group_id,
|
|
1242
|
+
group.commit_type,
|
|
1243
|
+
group.scope,
|
|
1244
|
+
group.file_ids,
|
|
1245
|
+
group.rationale,
|
|
1246
|
+
tuple(dependencies),
|
|
1247
|
+
)
|
|
1248
|
+
)
|
|
1249
|
+
compute_dependency_order(rewritten)
|
|
1250
|
+
return tuple(rewritten)
|
|
1251
|
+
|
|
1252
|
+
|
|
1113
1253
|
def _seed_group_target(group: ComposeIntentGroup, planning_index: PlanningIndex, claimed: set[str]) -> list[str]:
|
|
1114
1254
|
if not planning_index.targets:
|
|
1115
1255
|
return []
|
|
@@ -1309,6 +1449,8 @@ def _fallback_commit_type_for_group(
|
|
|
1309
1449
|
return CommitType.from_raw("build")
|
|
1310
1450
|
if files and all(_compose_file_category(file) in {"config", "dependency"} for file in files):
|
|
1311
1451
|
return CommitType.from_raw("chore")
|
|
1452
|
+
if files and all("new file mode" in file.patch_header for file in files):
|
|
1453
|
+
return CommitType.from_raw("feat")
|
|
1312
1454
|
return CommitType.from_raw("refactor")
|
|
1313
1455
|
|
|
1314
1456
|
|
lgit/config.py
CHANGED
|
@@ -94,6 +94,7 @@ class CommitConfig:
|
|
|
94
94
|
analysis_model: str = DEFAULT_ANALYSIS_MODEL
|
|
95
95
|
summary_model: str = DEFAULT_SUMMARY_MODEL
|
|
96
96
|
map_model: str = ""
|
|
97
|
+
fast_model: str = ""
|
|
97
98
|
legacy_model: str | None = None
|
|
98
99
|
excluded_files: list[str] = field(default_factory=lambda: list(DEFAULT_EXCLUDED_FILES))
|
|
99
100
|
low_priority_extensions: list[str] = field(default_factory=lambda: list(DEFAULT_LOW_PRIORITY_EXTENSIONS))
|
|
@@ -166,6 +167,11 @@ class CommitConfig:
|
|
|
166
167
|
"""Return the model for map-phase calls: ``map_model``, falling back to ``summary_model``."""
|
|
167
168
|
return self.map_model or self.summary_model
|
|
168
169
|
|
|
170
|
+
@property
|
|
171
|
+
def effective_fast_model(self) -> str:
|
|
172
|
+
"""Return the model for fast-mode single calls: ``fast_model``, falling back to ``summary_model``."""
|
|
173
|
+
return self.fast_model or self.summary_model
|
|
174
|
+
|
|
169
175
|
@property
|
|
170
176
|
def resolved_api_mode(self) -> ResolvedApiMode:
|
|
171
177
|
"""Return the concrete API protocol selected for this configuration."""
|
|
@@ -407,6 +413,7 @@ _FIELD_COERCERS = {
|
|
|
407
413
|
"analysis_model": _to_str,
|
|
408
414
|
"summary_model": _to_str,
|
|
409
415
|
"map_model": _to_str,
|
|
416
|
+
"fast_model": _to_str,
|
|
410
417
|
"legacy_model": _to_optional_str,
|
|
411
418
|
"excluded_files": _to_str_list,
|
|
412
419
|
"low_priority_extensions": _to_str_list,
|
lgit/diffing.py
CHANGED
|
@@ -257,7 +257,7 @@ def parse_diff(diff: str) -> list[FileDiff]:
|
|
|
257
257
|
if line.startswith("Binary files"):
|
|
258
258
|
current.is_binary = True
|
|
259
259
|
header_lines.append(line)
|
|
260
|
-
elif line.startswith(
|
|
260
|
+
elif in_diff_header and line.startswith(
|
|
261
261
|
(
|
|
262
262
|
"index ",
|
|
263
263
|
"new file",
|
|
@@ -281,7 +281,7 @@ def parse_diff(diff: str) -> list[FileDiff]:
|
|
|
281
281
|
current.status = "renamed"
|
|
282
282
|
elif line.startswith("@@"):
|
|
283
283
|
in_diff_header = False
|
|
284
|
-
|
|
284
|
+
content_lines.append(line)
|
|
285
285
|
elif not in_diff_header:
|
|
286
286
|
content_lines.append(line)
|
|
287
287
|
if line.startswith("+") and not line.startswith("+++"):
|
|
@@ -322,7 +322,7 @@ def scrub_diff_for_prompt(diff: str, max_file_bytes: int = MAX_PROMPT_FILE_BYTES
|
|
|
322
322
|
"""
|
|
323
323
|
|
|
324
324
|
diff = collapse_blob_lines(diff)
|
|
325
|
-
if
|
|
325
|
+
if _byte_len(diff) <= max_file_bytes:
|
|
326
326
|
return diff
|
|
327
327
|
files = parse_diff(diff)
|
|
328
328
|
if not any(file.size > max_file_bytes for file in files):
|
lgit/map_reduce.py
CHANGED
|
@@ -15,7 +15,7 @@ from .api import (
|
|
|
15
15
|
render_prompt,
|
|
16
16
|
run_oneshot,
|
|
17
17
|
)
|
|
18
|
-
from .diffing import FileDiff, condense_stat, parse_diff
|
|
18
|
+
from .diffing import FileDiff, condense_stat, parse_diff
|
|
19
19
|
from .markdown_output import analysis_from_mapping, fallback_summary, parse_conventional_analysis_markdown
|
|
20
20
|
from .models import AnalysisDetail, ConventionalAnalysis, resolve_model_name
|
|
21
21
|
from .tokens import create_token_counter
|
|
@@ -183,6 +183,7 @@ async def _map_phase(
|
|
|
183
183
|
config,
|
|
184
184
|
counter,
|
|
185
185
|
f"map batch {batch_idx + 1}/{len(batches)} ({len(batch_files)} files)",
|
|
186
|
+
budget,
|
|
186
187
|
)
|
|
187
188
|
return list(zip(batch_indices, observations, strict=True))
|
|
188
189
|
|
|
@@ -205,8 +206,9 @@ async def _map_file_batch(
|
|
|
205
206
|
config: CommitConfig,
|
|
206
207
|
counter: Any,
|
|
207
208
|
progress_label: str,
|
|
209
|
+
budget: int,
|
|
208
210
|
) -> list[FileObservation]:
|
|
209
|
-
rendered = [_render_file_diff_for_batch(file, counter) for file in files]
|
|
211
|
+
rendered = [_render_file_diff_for_batch(file, counter, budget) for file in files]
|
|
210
212
|
prompt_files = [{"path": file.filename, "diff": diff} for file, diff in zip(files, rendered, strict=True)]
|
|
211
213
|
system_prompt, user_prompt = _render_map_prompt(prompt_files, context_header)
|
|
212
214
|
response = await run_oneshot(
|
|
@@ -316,24 +318,31 @@ def _build_file_batches_for_indices(
|
|
|
316
318
|
files: Sequence[FileDiff], indices: Iterable[int], counter: Any, budget: int
|
|
317
319
|
) -> list[list[int]]:
|
|
318
320
|
token_budget = max(1, int(budget))
|
|
321
|
+
byte_budget = token_budget * 4
|
|
319
322
|
batches: list[list[int]] = []
|
|
320
323
|
current: list[int] = []
|
|
321
324
|
current_tokens = 0
|
|
325
|
+
current_bytes = 0
|
|
322
326
|
for idx in indices:
|
|
323
|
-
|
|
324
|
-
|
|
327
|
+
file = files[idx]
|
|
328
|
+
file_tokens = file.token_estimate(counter)
|
|
329
|
+
file_bytes = file.size + (1 if file.content else 0)
|
|
330
|
+
if file_tokens > token_budget or file_bytes > byte_budget:
|
|
325
331
|
if current:
|
|
326
332
|
batches.append(current)
|
|
327
333
|
current = []
|
|
328
334
|
current_tokens = 0
|
|
335
|
+
current_bytes = 0
|
|
329
336
|
batches.append([idx])
|
|
330
337
|
continue
|
|
331
|
-
if current and current_tokens + file_tokens > token_budget:
|
|
338
|
+
if current and (current_tokens + file_tokens > token_budget or current_bytes + file_bytes > byte_budget):
|
|
332
339
|
batches.append(current)
|
|
333
340
|
current = []
|
|
334
341
|
current_tokens = 0
|
|
342
|
+
current_bytes = 0
|
|
335
343
|
current.append(idx)
|
|
336
344
|
current_tokens += file_tokens
|
|
345
|
+
current_bytes += file_bytes
|
|
337
346
|
if current:
|
|
338
347
|
batches.append(current)
|
|
339
348
|
return batches
|
|
@@ -344,14 +353,16 @@ def _included_files(files: Sequence[FileDiff], config: CommitConfig) -> list[Fil
|
|
|
344
353
|
return [file for file in files if not any(file.filename.endswith(pattern) for pattern in excluded)]
|
|
345
354
|
|
|
346
355
|
|
|
347
|
-
def _render_file_diff_for_batch(file: FileDiff, counter: Any) -> str:
|
|
348
|
-
|
|
356
|
+
def _render_file_diff_for_batch(file: FileDiff, counter: Any, budget: int) -> str:
|
|
357
|
+
max_bytes = max(1, budget * 4)
|
|
358
|
+
rendered_bytes = file.size + (1 if file.content else 0)
|
|
359
|
+
if file.token_estimate(counter) <= budget and rendered_bytes <= max_bytes:
|
|
349
360
|
return _reconstruct_single_file_diff(file)
|
|
350
361
|
clone = FileDiff(
|
|
351
362
|
file.filename, file.header, file.content, file.additions, file.deletions, file.is_binary, file.status
|
|
352
363
|
)
|
|
353
|
-
clone.truncate(
|
|
354
|
-
return
|
|
364
|
+
clone.truncate(max(1, max_bytes - 1))
|
|
365
|
+
return _reconstruct_single_file_diff(clone)
|
|
355
366
|
|
|
356
367
|
|
|
357
368
|
def _reconstruct_single_file_diff(file: FileDiff) -> str:
|
|
@@ -8,30 +8,32 @@ Return your groups in a markdown-like format where each group defines a standalo
|
|
|
8
8
|
1. Each group is identified by a group ID (G1, G2, G3, etc.)
|
|
9
9
|
2. Each group has one commit type (from the `<commit_types>` list) and optional scope
|
|
10
10
|
3. Groups are independent when possible; use dependencies for strict ordering
|
|
11
|
-
4. Return
|
|
12
|
-
5.
|
|
11
|
+
4. Return no more than the requested maximum; use fewer only when the changes are genuinely atomic
|
|
12
|
+
5. Assign every provided file or area ID to exactly one group
|
|
13
|
+
7. Never split tests from the implementation they cover: put both in one group, and only emit a test-only group when the code under test is not part of this change
|
|
14
|
+
8. Keep documentation, generated artifacts, and dependency manifests with the implementation they belong to unless they are an independent change
|
|
15
|
+
9. Group by intent, not by file type, path adjacency, or broad labels such as "core", "tools", or "tests"
|
|
16
|
+
7. Keep tests, documentation, generated artifacts, and dependency manifests with the implementation they belong to unless they are an independent change
|
|
17
|
+
8. Group by intent, not by file type, path adjacency, or broad labels such as "core", "tools", or "tests"
|
|
13
18
|
|
|
14
19
|
Format rules:
|
|
15
20
|
- `G1 := type(scope): rationale` — group definition
|
|
16
21
|
- `G2 <- G1` — G2 depends on G1
|
|
17
|
-
- `Files:`
|
|
18
|
-
- `- GN:
|
|
22
|
+
- `Files:` must list only the provided `F...` or `A...` target IDs, never paths or hunk IDs
|
|
23
|
+
- `- GN: F001, F002, F003` — target IDs assigned to group GN
|
|
19
24
|
</instructions>
|
|
20
25
|
|
|
21
26
|
<output_format>
|
|
22
27
|
You MUST return the result in this format WITHOUT the fences:
|
|
23
28
|
```
|
|
24
29
|
G1 := feat(api): add authentication endpoints
|
|
25
|
-
G2 :=
|
|
26
|
-
G3 := docs(api): document new endpoints
|
|
30
|
+
G2 := feat(client): consume authentication endpoints
|
|
27
31
|
|
|
28
32
|
G2 <- G1
|
|
29
|
-
G3 <- G1
|
|
30
33
|
|
|
31
34
|
Files:
|
|
32
|
-
- G1:
|
|
33
|
-
- G2:
|
|
34
|
-
- G3: docs/API.md
|
|
35
|
+
- G1: F001, F002
|
|
36
|
+
- G2: F003, F004
|
|
35
37
|
```
|
|
36
38
|
</output_format>
|
|
37
39
|
|
|
@@ -44,6 +46,11 @@ max_commits: {{ max_commits }}
|
|
|
44
46
|
{{ planning_targets }}
|
|
45
47
|
</planning_targets>
|
|
46
48
|
|
|
49
|
+
<planning_guidance>
|
|
50
|
+
{{ planning_notes }}
|
|
51
|
+
{{ split_bias }}
|
|
52
|
+
</planning_guidance>
|
|
53
|
+
|
|
47
54
|
{% if types_description %}
|
|
48
55
|
<commit_types>
|
|
49
56
|
{{ types_description }}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: lgit-cli
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.3.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
|
|
@@ -4,13 +4,13 @@ lgit/analysis.py,sha256=j8bduuV6pqvMuza-r_RNJDe5SMQGKTtU6gwktaAeSS4,10671
|
|
|
4
4
|
lgit/api.py,sha256=Ypo6-6Y3fHKT_zJvzyZMClg5NUi6uCv6NK4paEYWrxo,38129
|
|
5
5
|
lgit/cache.py,sha256=mrF5g74HMP9FR9kCJgwBcT4l34DuAuBaAkC1pCV7x6M,12477
|
|
6
6
|
lgit/changelog.py,sha256=HGuz2qeM_2m8uV2x36X79OP5SL9Wn0JxFhfvk4oCG_o,37264
|
|
7
|
-
lgit/cli.py,sha256=
|
|
8
|
-
lgit/compose.py,sha256=
|
|
9
|
-
lgit/config.py,sha256=
|
|
10
|
-
lgit/diffing.py,sha256=
|
|
7
|
+
lgit/cli.py,sha256=nqvrJZfLxkYwjHSPNqaajZKe_PCPRcpDkfING3crhto,52778
|
|
8
|
+
lgit/compose.py,sha256=g4HW7NDNR9ynFtDk9TtPBuHvTnhHOUUrG3NAX7N4HC0,83243
|
|
9
|
+
lgit/config.py,sha256=GkldpfMAX8T7Vzkl5RVY3eTgNM8Dalqntf2IuUmFnrg,14749
|
|
10
|
+
lgit/diffing.py,sha256=USk8qws0kXEfTlphvf7-hMyBdqdOD9H7i7UOimm99SY,17595
|
|
11
11
|
lgit/errors.py,sha256=DkPJKA2ag5KbBoyuRk1d8zKgz9Mp1qRoLVBGRudlqkg,3457
|
|
12
12
|
lgit/git.py,sha256=_wavbMwewf0lP1fZrrhgW5yD36jwWUC87Y7jfIikIEk,31543
|
|
13
|
-
lgit/map_reduce.py,sha256=
|
|
13
|
+
lgit/map_reduce.py,sha256=Tk11z9FT9Ox2pFZEy7Ns-eruyWo62jZokQuUWWCFyqE,20188
|
|
14
14
|
lgit/markdown_output.py,sha256=mgRLhpa9TBr3AVCoFaMYktXPYfxh6NqM75xpcudYexA,26355
|
|
15
15
|
lgit/models.py,sha256=hc3AJ37YXoLBGgSbdLQN5EEnDNViXf-wywlkUW92_Z8,28942
|
|
16
16
|
lgit/normalization.py,sha256=Kj_xqLw_fLDkN7wTFtAbwlEAD8t_s8v8JEGcLWLG8DM,11889
|
|
@@ -31,7 +31,7 @@ lgit/resources/validation_data.json,sha256=PJ1Iocq2qPKvh-zC1V_WyPrlDFFsXyTdnIxa2
|
|
|
31
31
|
lgit/resources/prompts/analysis.md,sha256=0CTqrvoeSTac9DSGzpV1pRrtOoxYfdh5PqtN3glVdYI,3111
|
|
32
32
|
lgit/resources/prompts/changelog.md,sha256=6B7AsOMieF35VQvXRZaDBF4uNmXQzTFYGqUF4CnxZYA,5677
|
|
33
33
|
lgit/resources/prompts/compose-bind.md,sha256=PEEeq9J2dWgXF3tL7uT2mpuws-u1rw_5m4IOSta4Oi4,832
|
|
34
|
-
lgit/resources/prompts/compose-intent.md,sha256=
|
|
34
|
+
lgit/resources/prompts/compose-intent.md,sha256=1A3FXApZe_2ERiqodyzhNrJ12WddEydty-5Zb9FroaM,2273
|
|
35
35
|
lgit/resources/prompts/fast.md,sha256=hM0z84pc4f8kGbcLDz2ZJNTN8Nj45lHH1Nrggv3YSLg,1951
|
|
36
36
|
lgit/resources/prompts/map.md,sha256=f78-BUaEH1GPPBIB1rehkv012RcmPbD6mOHY9tWeyhM,2118
|
|
37
37
|
lgit/resources/prompts/reduce.md,sha256=emZwrBXr9QzrzgGa2iImwNIVCTKk607w41UzBjQp9D4,2922
|
|
@@ -42,8 +42,8 @@ lgit/testing/compare.py,sha256=jRY98uLclVPyQ7e1TMqFVz2cjUi6kwwn2dkQyR_xsgY,1834
|
|
|
42
42
|
lgit/testing/fixture.py,sha256=VXk02ZzFTBHHhYax6bsoGowdyz06nmrJm3ylenyfGbU,13654
|
|
43
43
|
lgit/testing/report.py,sha256=wb7YnP_lsYwsg5OIFtsIC1bMHtK42Mttul_zQcwRNpk,9036
|
|
44
44
|
lgit/testing/runner.py,sha256=5Sr4QvEOTdE7CAxB-CKcNJClEZARQGqB-t_6P6-UA2c,9514
|
|
45
|
-
lgit_cli-5.
|
|
46
|
-
lgit_cli-5.
|
|
47
|
-
lgit_cli-5.
|
|
48
|
-
lgit_cli-5.
|
|
49
|
-
lgit_cli-5.
|
|
45
|
+
lgit_cli-5.3.0.dist-info/METADATA,sha256=07djXpV_LJpdd8TU6Vz-RFYpBgGwiWAuAl4gqgJ6DQI,9565
|
|
46
|
+
lgit_cli-5.3.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
47
|
+
lgit_cli-5.3.0.dist-info/entry_points.txt,sha256=CUSsokc0V3oVHQ2Z1ocL09wV7Krhm0SSfLZpnRMBdA0,39
|
|
48
|
+
lgit_cli-5.3.0.dist-info/licenses/LICENSE,sha256=6dqVzjngLuIcUMd4wWLXPLpv-Pi8gySZAEE3hSN5iKw,1076
|
|
49
|
+
lgit_cli-5.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|