sourcecode 1.9.0__py3-none-any.whl → 1.10.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.
sourcecode/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """sourcecode — Deterministic codebase context maps for AI coding agents."""
2
2
 
3
- __version__ = "1.9.0"
3
+ __version__ = "1.10.0"
sourcecode/serializer.py CHANGED
@@ -38,6 +38,19 @@ _MONOREPO_PKGS_CAP = 8 # max workspace/runtime packages shown
38
38
  _KEY_DEPS_CAP = 50 # max key dependencies shown
39
39
  _CODE_NOTES_CAP = 15 # max code notes in default output
40
40
  _ENV_MAP_CAP = 15 # max env var entries in default output
41
+ _MAX_DEFAULT_CONTRACTS = 20 # max contracts in default/standard contract output
42
+ _MAX_HARD_SIGNALS_DEFAULT = 20 # max hard_signals entries in default output
43
+
44
+
45
+ def _cap_contracts_for_output(
46
+ contracts: list[Any],
47
+ max_count: int = _MAX_DEFAULT_CONTRACTS,
48
+ ) -> tuple[list[Any], dict[str, Any]]:
49
+ """Sort contracts by relevance_score desc, cap to max_count, return (sampled, meta)."""
50
+ total = len(contracts)
51
+ sampled = sorted(contracts, key=lambda c: getattr(c, "relevance_score", 0.0), reverse=True)[:max_count]
52
+ meta: dict[str, Any] = {"total": total, "shown": len(sampled), "truncated": total > max_count}
53
+ return sampled, meta
41
54
 
42
55
 
43
56
  def to_json(sm: SourceMap | dict[str, Any], indent: int = 2) -> str:
@@ -1230,13 +1243,11 @@ def _contract_view_minimal(
1230
1243
  if getattr(sm, "app_server_hint", None):
1231
1244
  result["app_server_hint"] = sm.app_server_hint
1232
1245
 
1233
- # Per-file contracts
1246
+ # Per-file contracts — capped to avoid token bloat on large projects
1234
1247
  if contracts:
1235
- serialized: list[dict[str, Any]] = []
1236
- for c in contracts:
1237
- item = _serialize_contract_minimal(c)
1238
- serialized.append(item)
1239
- result["contracts"] = serialized
1248
+ _capped, _meta = _cap_contracts_for_output(contracts)
1249
+ result["contracts"] = [_serialize_contract_minimal(c) for c in _capped]
1250
+ result["contracts_meta"] = _meta
1240
1251
 
1241
1252
  # Optional analysis sections — included when the analyzer explicitly ran
1242
1253
  # (user passed --dependencies, --env-map, --code-notes, --git-context)
@@ -1587,10 +1598,11 @@ def _contract_view_standard(
1587
1598
  "stack": sm.confidence_summary.stack_confidence,
1588
1599
  }
1589
1600
 
1590
- # Per-file contracts (full detail)
1601
+ # Per-file contracts (full detail) — capped to avoid token bloat on large projects
1591
1602
  if contracts:
1603
+ _capped, _meta = _cap_contracts_for_output(contracts)
1592
1604
  serialized: list[dict[str, Any]] = []
1593
- for c in contracts:
1605
+ for c in _capped:
1594
1606
  if getattr(c, "language", None) == "mybatis-xml":
1595
1607
  item = _serialize_contract_mybatis_xml(c)
1596
1608
  item["relevance_score"] = round(c.relevance_score, 3)
@@ -1646,6 +1658,7 @@ def _contract_view_standard(
1646
1658
  item["method"] = c.extraction_method
1647
1659
  serialized.append(item)
1648
1660
  result["contracts"] = serialized
1661
+ result["contracts_meta"] = _meta
1649
1662
 
1650
1663
  # Optional analysis sections (deep mode or when analyzers ran)
1651
1664
  if include_optional:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sourcecode
3
- Version: 1.9.0
3
+ Version: 1.10.0
4
4
  Summary: Deterministic codebase context for AI coding agents
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -1,4 +1,4 @@
1
- sourcecode/__init__.py,sha256=7vT9zGHBIzJnrOurwpOa5S9QoTVH_lpybnxNKWeq4Kg,102
1
+ sourcecode/__init__.py,sha256=GIBn7xub4gRHF7c7fnnLnviXbqQHlPBBIqawhO-HQKQ,103
2
2
  sourcecode/adaptive_scanner.py,sha256=RTNExwWPXzjgLaRueT7UuxkPj5ZEToWjGbx1j0LSZ9E,10250
3
3
  sourcecode/architecture_analyzer.py,sha256=oPmGPf9_p6y8Z7SIGHEu57nVYwxycIovDzBvlHl-l5k,32557
4
4
  sourcecode/architecture_summary.py,sha256=J9yoLgh8wXwIRrT6q6JooB6PekivbOEYpJz4BUXdalk,20545
@@ -30,7 +30,7 @@ sourcecode/runtime_classifier.py,sha256=zWX3r3HCKHc-qtIobErOa8aKMmaoPYREtJKvPcBG
30
30
  sourcecode/scanner.py,sha256=aM3h9-DCQ3xKpeHpHYdo2vX6T5P95HA_YwZbkAVNwmo,8288
31
31
  sourcecode/schema.py,sha256=rNxpDUgOfvJDzz6DKitL-5_0UAh0YomNwTsSSe8PafY,24066
32
32
  sourcecode/semantic_analyzer.py,sha256=12TwXYkYbDcBdu0heX_EmfPM2EkO8a_r5osf0SaeQbs,88956
33
- sourcecode/serializer.py,sha256=LQuAb2YNkNhckuT9fYNCrRe3TV_BJkPlgbb85Cwsyoo,70001
33
+ sourcecode/serializer.py,sha256=ZcMh8p3XMmdSexHxR8AsmA8TjOFCKbXXxnJI8TCSFwY,70836
34
34
  sourcecode/summarizer.py,sha256=ZuzIdm3t8A-d5MuQL0TSNLrd-L0IQIuguIxeNXMNJf8,16070
35
35
  sourcecode/tree_utils.py,sha256=Fj9OIuUksBvgibNd3feog0sMDjVypJzPexp5lvMoYWI,1424
36
36
  sourcecode/workspace.py,sha256=X_6NmNnitvT3_38V-JDChydo_sR68s249hLFlrQskU0,8271
@@ -61,8 +61,8 @@ sourcecode/telemetry/consent.py,sha256=wLMvGNJeSSyZoNkQXpoUioY6mMv4Qdvuw7S9jAEWn
61
61
  sourcecode/telemetry/events.py,sha256=oEvvulfsv5GIDWG2174gSS6tNB95w38AIYiYeifGKlE,2294
62
62
  sourcecode/telemetry/filters.py,sha256=Asa71oRl7q3Wt_FMwuufIZJFzSYdgRNKS8LHCIyFeYE,4805
63
63
  sourcecode/telemetry/transport.py,sha256=KJeIPCPWMdmbCP3ySGs2iUlia34U6vWne2dZsUezesw,1560
64
- sourcecode-1.9.0.dist-info/METADATA,sha256=lyqhpfo9LG4IjfyXZ8QBhqfTncocJBA7_cKPKO3PEP4,20411
65
- sourcecode-1.9.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
66
- sourcecode-1.9.0.dist-info/entry_points.txt,sha256=ex3F9rmbXeyDIoFQHtkEqTsKSaJow8F0LrVu8XfIktQ,57
67
- sourcecode-1.9.0.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
68
- sourcecode-1.9.0.dist-info/RECORD,,
64
+ sourcecode-1.10.0.dist-info/METADATA,sha256=96dUJ1T_kbtCJS-5VGvdaUCvHlJNAJmTu7MFhmLkOVM,20412
65
+ sourcecode-1.10.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
66
+ sourcecode-1.10.0.dist-info/entry_points.txt,sha256=ex3F9rmbXeyDIoFQHtkEqTsKSaJow8F0LrVu8XfIktQ,57
67
+ sourcecode-1.10.0.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
68
+ sourcecode-1.10.0.dist-info/RECORD,,