sourcecode 0.36.0__py3-none-any.whl → 0.37.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 +1 -1
- sourcecode/cli.py +66 -17
- sourcecode/git_analyzer.py +7 -0
- sourcecode/metrics_analyzer.py +10 -0
- sourcecode/serializer.py +20 -1
- {sourcecode-0.36.0.dist-info → sourcecode-0.37.0.dist-info}/METADATA +1 -1
- {sourcecode-0.36.0.dist-info → sourcecode-0.37.0.dist-info}/RECORD +10 -10
- {sourcecode-0.36.0.dist-info → sourcecode-0.37.0.dist-info}/WHEEL +0 -0
- {sourcecode-0.36.0.dist-info → sourcecode-0.37.0.dist-info}/entry_points.txt +0 -0
- {sourcecode-0.36.0.dist-info → sourcecode-0.37.0.dist-info}/licenses/LICENSE +0 -0
sourcecode/__init__.py
CHANGED
sourcecode/cli.py
CHANGED
|
@@ -384,7 +384,8 @@ def main(
|
|
|
384
384
|
no_tree: bool = typer.Option(
|
|
385
385
|
False,
|
|
386
386
|
"--no-tree",
|
|
387
|
-
|
|
387
|
+
hidden=True,
|
|
388
|
+
help="(Removed) No-op. File tree is excluded by default. Use --tree to include it.",
|
|
388
389
|
),
|
|
389
390
|
tree: bool = typer.Option(
|
|
390
391
|
False,
|
|
@@ -516,13 +517,13 @@ def main(
|
|
|
516
517
|
"contract",
|
|
517
518
|
"--mode",
|
|
518
519
|
help=(
|
|
519
|
-
"Output mode: contract
|
|
520
|
-
"contract
|
|
520
|
+
"Output mode: contract (default) | standard | raw. "
|
|
521
|
+
"contract: minimal per-file contracts — exports, signatures, deps. "
|
|
522
|
+
"Smallest output, recommended for AI agents. "
|
|
523
|
+
"minimal is accepted as an alias for contract. "
|
|
521
524
|
"standard: full per-file detail with imports, relevance scores, extraction method. "
|
|
522
|
-
"
|
|
523
|
-
"
|
|
524
|
-
"raw: legacy project-level analysis (stacks, entry points, dependencies). "
|
|
525
|
-
"contract/minimal is the recommended default for AI coding agents."
|
|
525
|
+
"raw: project-level analysis only (stacks, entry points, dependency summary). "
|
|
526
|
+
"No per-file contracts."
|
|
526
527
|
),
|
|
527
528
|
),
|
|
528
529
|
max_symbols: Optional[int] = typer.Option(
|
|
@@ -534,7 +535,8 @@ def main(
|
|
|
534
535
|
dependency_depth: int = typer.Option(
|
|
535
536
|
0,
|
|
536
537
|
"--dependency-depth",
|
|
537
|
-
|
|
538
|
+
hidden=True,
|
|
539
|
+
help="(Removed) Transitive resolution is not implemented. Pass 0 or omit.",
|
|
538
540
|
min=0,
|
|
539
541
|
max=5,
|
|
540
542
|
),
|
|
@@ -561,7 +563,8 @@ def main(
|
|
|
561
563
|
compress_types: bool = typer.Option(
|
|
562
564
|
False,
|
|
563
565
|
"--compress-types",
|
|
564
|
-
|
|
566
|
+
hidden=True,
|
|
567
|
+
help="(Removed) No observable effect when type signatures are not extracted. Omit.",
|
|
565
568
|
),
|
|
566
569
|
symbol: Optional[str] = typer.Option(
|
|
567
570
|
None,
|
|
@@ -589,8 +592,20 @@ def main(
|
|
|
589
592
|
_t0 = time.monotonic()
|
|
590
593
|
|
|
591
594
|
# Validate new flag choices
|
|
592
|
-
_MODE_CHOICES = ("contract", "minimal", "standard", "
|
|
593
|
-
|
|
595
|
+
_MODE_CHOICES = ("contract", "minimal", "standard", "raw")
|
|
596
|
+
_DEPRECATED_MODES: dict[str, str] = {
|
|
597
|
+
"hybrid": "contract",
|
|
598
|
+
"deep": "standard",
|
|
599
|
+
}
|
|
600
|
+
if mode in _DEPRECATED_MODES:
|
|
601
|
+
fallback = _DEPRECATED_MODES[mode]
|
|
602
|
+
typer.echo(
|
|
603
|
+
f"[deprecated] --mode {mode} is removed: produced identical output to --mode {fallback}. "
|
|
604
|
+
f"Using --mode {fallback}.",
|
|
605
|
+
err=True,
|
|
606
|
+
)
|
|
607
|
+
mode = fallback
|
|
608
|
+
elif mode not in _MODE_CHOICES:
|
|
594
609
|
typer.echo(
|
|
595
610
|
f"Error: invalid value '{mode}' for --mode. Valid options: {', '.join(_MODE_CHOICES)}",
|
|
596
611
|
err=True,
|
|
@@ -604,6 +619,22 @@ def main(
|
|
|
604
619
|
)
|
|
605
620
|
raise typer.Exit(code=1)
|
|
606
621
|
|
|
622
|
+
if dependency_depth > 0:
|
|
623
|
+
typer.echo(
|
|
624
|
+
f"[warning] --dependency-depth {dependency_depth} has no effect: "
|
|
625
|
+
"transitive import resolution is not implemented for npm/yarn/pip projects. "
|
|
626
|
+
"Using depth=0 (direct dependencies only).",
|
|
627
|
+
err=True,
|
|
628
|
+
)
|
|
629
|
+
dependency_depth = 0
|
|
630
|
+
|
|
631
|
+
if compress_types:
|
|
632
|
+
typer.echo(
|
|
633
|
+
"[deprecated] --compress-types is removed: type signatures are rarely extracted "
|
|
634
|
+
"at default depth. Flag ignored.",
|
|
635
|
+
err=True,
|
|
636
|
+
)
|
|
637
|
+
|
|
607
638
|
# Validate format choices
|
|
608
639
|
if format not in FORMAT_CHOICES:
|
|
609
640
|
typer.echo(
|
|
@@ -634,9 +665,9 @@ def main(
|
|
|
634
665
|
raise typer.Exit(code=1)
|
|
635
666
|
|
|
636
667
|
# Normalize mode aliases
|
|
637
|
-
_CONTRACT_MODES = frozenset({"contract", "minimal", "standard"
|
|
668
|
+
_CONTRACT_MODES = frozenset({"contract", "minimal", "standard"})
|
|
638
669
|
if mode == "minimal":
|
|
639
|
-
mode = "contract" # minimal is
|
|
670
|
+
mode = "contract" # minimal is a documented alias for contract
|
|
640
671
|
elif mode not in _CONTRACT_MODES and mode != "raw":
|
|
641
672
|
mode = "contract" # unknown → safe default
|
|
642
673
|
|
|
@@ -648,15 +679,13 @@ def main(
|
|
|
648
679
|
compact or agent or tree or format == "yaml" or trace_pipeline
|
|
649
680
|
or docs or semantics or graph_modules or full_metrics or architecture
|
|
650
681
|
)
|
|
651
|
-
if mode in ("contract", "standard"
|
|
682
|
+
if mode in ("contract", "standard") and _legacy_flags_active:
|
|
652
683
|
mode = "raw"
|
|
653
684
|
|
|
654
685
|
# Map mode to contract_view depth
|
|
655
686
|
_CONTRACT_DEPTH = {
|
|
656
687
|
"contract": "minimal",
|
|
657
688
|
"standard": "standard",
|
|
658
|
-
"deep": "deep",
|
|
659
|
-
"hybrid": "minimal", # hybrid adds bodies via pipeline, minimal header
|
|
660
689
|
}
|
|
661
690
|
|
|
662
691
|
# --- Import analysis modules ---
|
|
@@ -746,6 +775,19 @@ def main(
|
|
|
746
775
|
detector = ProjectDetector(build_default_detectors())
|
|
747
776
|
workspace_analysis = WorkspaceAnalyzer().analyze(target, manifests)
|
|
748
777
|
|
|
778
|
+
# Warn when scanning a monorepo at default depth — typical package sources
|
|
779
|
+
# (packages/*/src/) live at depth 5+, so default depth=4 silently misses them.
|
|
780
|
+
# Only emit to TTY to avoid contaminating piped/CI output; agents read analysis_gaps.
|
|
781
|
+
import sys as _sys
|
|
782
|
+
if workspace_analysis.is_monorepo and depth <= 4 and effective_depth <= 4:
|
|
783
|
+
if _sys.stderr.isatty():
|
|
784
|
+
typer.echo(
|
|
785
|
+
f"[warning] monorepo detected with --depth {depth}. "
|
|
786
|
+
"Source files in packages/*/src/ (depth 5+) may be invisible. "
|
|
787
|
+
"Use --depth 6 or higher for full coverage.",
|
|
788
|
+
err=True,
|
|
789
|
+
)
|
|
790
|
+
|
|
749
791
|
# --compact implicitly enables lightweight analysis passes so that
|
|
750
792
|
# dependency_summary, env_summary and code_notes_summary are never null.
|
|
751
793
|
if compact:
|
|
@@ -1244,7 +1286,7 @@ def main(
|
|
|
1244
1286
|
sm = _replace(sm, pipeline_trace=_trace.build_trace())
|
|
1245
1287
|
|
|
1246
1288
|
# Contract pipeline — runs for mode=contract|standard|deep|hybrid (skip for raw)
|
|
1247
|
-
_is_contract_mode = mode in ("contract", "standard"
|
|
1289
|
+
_is_contract_mode = mode in ("contract", "standard")
|
|
1248
1290
|
if _is_contract_mode:
|
|
1249
1291
|
from sourcecode.contract_pipeline import ContractPipeline
|
|
1250
1292
|
_cp = ContractPipeline()
|
|
@@ -1263,6 +1305,13 @@ def main(
|
|
|
1263
1305
|
compress_types=compress_types,
|
|
1264
1306
|
)
|
|
1265
1307
|
sm = _replace(sm, file_contracts=_contracts, contract_summary=_contract_summary)
|
|
1308
|
+
if symbol is not None and len(_contracts) == 0:
|
|
1309
|
+
typer.echo(
|
|
1310
|
+
f"[warning] --symbol '{symbol}' matched 0 files. "
|
|
1311
|
+
"The symbol may not exist at the current --depth, or the name may differ in case. "
|
|
1312
|
+
"Try --depth 8 or verify the symbol name.",
|
|
1313
|
+
err=True,
|
|
1314
|
+
)
|
|
1266
1315
|
if agent:
|
|
1267
1316
|
typer.echo(f"[contract] {len(_contracts)} files extracted ({_contract_summary.method_breakdown})", err=True)
|
|
1268
1317
|
|
sourcecode/git_analyzer.py
CHANGED
|
@@ -198,6 +198,13 @@ def _is_hotspot_admin(path: str) -> bool:
|
|
|
198
198
|
for suffix in _HOTSPOT_ADMIN_SUFFIXES:
|
|
199
199
|
if filename.endswith(suffix):
|
|
200
200
|
return True
|
|
201
|
+
# Localized changelogs: CHANGELOG.zh-CN.md, CHANGES.en-US.md, etc.
|
|
202
|
+
_lower = filename.lower()
|
|
203
|
+
if _lower.startswith("changelog.") or _lower.startswith("changes."):
|
|
204
|
+
return True
|
|
205
|
+
# lerna.json and root-level package.json are modified by version bumps, not dev work
|
|
206
|
+
if filename in ("lerna.json",):
|
|
207
|
+
return True
|
|
201
208
|
return False
|
|
202
209
|
|
|
203
210
|
|
sourcecode/metrics_analyzer.py
CHANGED
|
@@ -219,6 +219,16 @@ class MetricsAnalyzer:
|
|
|
219
219
|
if fm.language != "unknown":
|
|
220
220
|
languages.add(fm.language)
|
|
221
221
|
|
|
222
|
+
# Emit explicit limitation when JS/TS files are present but complexity is unavailable.
|
|
223
|
+
# This prevents agents from assuming null complexity means "no functions found".
|
|
224
|
+
_js_ts_count = sum(1 for r in records if r.language in ("javascript", "typescript") and r.complexity_availability == "unavailable")
|
|
225
|
+
if _js_ts_count > 0:
|
|
226
|
+
limitations.append(
|
|
227
|
+
f"cyclomatic_complexity_unavailable: {_js_ts_count} JS/TS file(s) — "
|
|
228
|
+
"complexity requires tree-sitter (pip install 'sourcecode[ast]'). "
|
|
229
|
+
"null complexity fields are expected, not an error."
|
|
230
|
+
)
|
|
231
|
+
|
|
222
232
|
summary = MetricsSummary(
|
|
223
233
|
requested=True,
|
|
224
234
|
file_count=len(records),
|
sourcecode/serializer.py
CHANGED
|
@@ -923,7 +923,7 @@ def _contract_view_minimal(
|
|
|
923
923
|
|
|
924
924
|
result: dict[str, Any] = {
|
|
925
925
|
"schema_version": sm.metadata.schema_version,
|
|
926
|
-
"mode": "
|
|
926
|
+
"mode": "contract",
|
|
927
927
|
"project": project,
|
|
928
928
|
}
|
|
929
929
|
|
|
@@ -949,9 +949,28 @@ def _contract_view_minimal(
|
|
|
949
949
|
|
|
950
950
|
if sm.env_summary is not None and sm.env_summary.requested:
|
|
951
951
|
result["env_summary"] = asdict(sm.env_summary)
|
|
952
|
+
if sm.env_map:
|
|
953
|
+
# Include top-20 env entries sorted by required first, then name.
|
|
954
|
+
# Agents read the summary count but need the actual keys to act on them.
|
|
955
|
+
_sorted_env = sorted(sm.env_map, key=lambda e: (not getattr(e, "required", False), getattr(e, "name", "")))
|
|
956
|
+
result["env_map"] = [
|
|
957
|
+
{k: v for k, v in asdict(e).items() if v is not None and v != ""}
|
|
958
|
+
for e in _sorted_env[:20]
|
|
959
|
+
]
|
|
952
960
|
|
|
953
961
|
if sm.code_notes_summary is not None and sm.code_notes_summary.requested:
|
|
954
962
|
result["code_notes_summary"] = asdict(sm.code_notes_summary)
|
|
963
|
+
if sm.code_notes:
|
|
964
|
+
# Include top-20 notes by severity: BUG > FIXME > DEPRECATED > TODO > others.
|
|
965
|
+
_SEVERITY_ORDER = {"BUG": 0, "FIXME": 1, "DEPRECATED": 2, "TODO": 3, "HACK": 4, "WARNING": 5}
|
|
966
|
+
_sorted_notes = sorted(
|
|
967
|
+
sm.code_notes,
|
|
968
|
+
key=lambda n: (_SEVERITY_ORDER.get(getattr(n, "kind", "").upper(), 9), getattr(n, "path", "")),
|
|
969
|
+
)
|
|
970
|
+
result["code_notes"] = [
|
|
971
|
+
{k: v for k, v in asdict(n).items() if v is not None and v != ""}
|
|
972
|
+
for n in _sorted_notes[:20]
|
|
973
|
+
]
|
|
955
974
|
|
|
956
975
|
if sm.git_context is not None and sm.git_context.requested:
|
|
957
976
|
result["git_context"] = asdict(sm.git_context)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
sourcecode/__init__.py,sha256=
|
|
1
|
+
sourcecode/__init__.py,sha256=Xha8jq1XWD5Ze_B5mEne-d5fOfBVVwnX-Ieg7spvalk,103
|
|
2
2
|
sourcecode/architecture_analyzer.py,sha256=H6noGgVArUJ25z1qC0fFA0KvJJeHZYyhKvKSkOyWHUk,23096
|
|
3
3
|
sourcecode/architecture_summary.py,sha256=rSY5MRiaz4N1YdG0pqDTDuFjSN7PO_Zplx-dtNzv2Yo,19985
|
|
4
4
|
sourcecode/ast_extractor.py,sha256=0OHQwTUBBc9lmqPLryVeB1z8dGIC6NhLlar800CD9oI,41129
|
|
5
5
|
sourcecode/classifier.py,sha256=GKTMN8qKZX7ponSwDJfN08RrasI4CVpq1_gFBgEopps,7093
|
|
6
|
-
sourcecode/cli.py,sha256=
|
|
6
|
+
sourcecode/cli.py,sha256=LSGytpRlyMFdmHugrP3USDhPb0hiigHn0PL9Ppac3R4,64852
|
|
7
7
|
sourcecode/code_notes_analyzer.py,sha256=rRd8bFYV0krjlxxQV0wenwE9K7pVpUQSR7KvSvUQKw4,9226
|
|
8
8
|
sourcecode/confidence_analyzer.py,sha256=HxJMPLI5ulqtkncnv98W4iVO6yMbpQo87VuxiuNbDmY,12167
|
|
9
9
|
sourcecode/context_summarizer.py,sha256=CiQrfBEzun949bWvmLabWoj2HhPn6Lw62ofqnsy0FlQ,6503
|
|
@@ -15,9 +15,9 @@ sourcecode/doc_analyzer.py,sha256=Ec3orx6vBKsh5cNM3-F4y2Got2KuKx8w3dErwtdtM-A,19
|
|
|
15
15
|
sourcecode/entrypoint_classifier.py,sha256=a69dMGyxCTd_LOm3oqj-EXWpRmbmeujN7T1mr2eJ1as,3877
|
|
16
16
|
sourcecode/env_analyzer.py,sha256=slvq-eT24RVMNczLNDlZbe0hU8JXIIPxybqubvrrnSQ,14409
|
|
17
17
|
sourcecode/file_classifier.py,sha256=_KfFIIolharaIxbSTrCkaWauQIqNHCyor_n47RGyDh8,8577
|
|
18
|
-
sourcecode/git_analyzer.py,sha256=
|
|
18
|
+
sourcecode/git_analyzer.py,sha256=s7tJTd_GAczhrH7j9JhBNp7ozhkW3lzBN0TMNwFqJwE,9977
|
|
19
19
|
sourcecode/graph_analyzer.py,sha256=hMOsLLz9B0UnQ4xwbHdgr3bFvqpw0bQ8kN-xmEn3Krk,64156
|
|
20
|
-
sourcecode/metrics_analyzer.py,sha256=
|
|
20
|
+
sourcecode/metrics_analyzer.py,sha256=e2cFwB9XubFq_dIVsP2PLjpr4wX0N6ulb3ol3sGDUeo,20777
|
|
21
21
|
sourcecode/prepare_context.py,sha256=vxEzr8czS3MFbdTx4hBJQlJLrl9cuvbHdL3ZokxFkvo,31384
|
|
22
22
|
sourcecode/redactor.py,sha256=xuGcadGEHaPw4qZXlMDvzMCsr4VOkdp3oBQptHyJk8c,2884
|
|
23
23
|
sourcecode/relevance_scorer.py,sha256=ea7_7AHVgahVEWK3ebKOpG67agzG_pGICu5f2KgzrIA,8133
|
|
@@ -25,7 +25,7 @@ sourcecode/runtime_classifier.py,sha256=zWX3r3HCKHc-qtIobErOa8aKMmaoPYREtJKvPcBG
|
|
|
25
25
|
sourcecode/scanner.py,sha256=aM3h9-DCQ3xKpeHpHYdo2vX6T5P95HA_YwZbkAVNwmo,8288
|
|
26
26
|
sourcecode/schema.py,sha256=AShu_bcP30TYaw4Dl1nYy8aFnBCKxrUli3LhU3MZTjs,20739
|
|
27
27
|
sourcecode/semantic_analyzer.py,sha256=asQfJf-EhzYaOTA-iMuZsrVXtbW7SV2WEKCxgsxa88Y,79413
|
|
28
|
-
sourcecode/serializer.py,sha256=
|
|
28
|
+
sourcecode/serializer.py,sha256=uQGcytdaaM3qzxXcZ2NMjXYvzdvT9PP45960t-Thgqk,51128
|
|
29
29
|
sourcecode/summarizer.py,sha256=ZuzIdm3t8A-d5MuQL0TSNLrd-L0IQIuguIxeNXMNJf8,16070
|
|
30
30
|
sourcecode/tree_utils.py,sha256=Fj9OIuUksBvgibNd3feog0sMDjVypJzPexp5lvMoYWI,1424
|
|
31
31
|
sourcecode/workspace.py,sha256=fQlVoNx8S-fSHpKoJ0JBvEHCFkxszH0KZVJed1i3TRk,6845
|
|
@@ -56,8 +56,8 @@ sourcecode/telemetry/consent.py,sha256=wLMvGNJeSSyZoNkQXpoUioY6mMv4Qdvuw7S9jAEWn
|
|
|
56
56
|
sourcecode/telemetry/events.py,sha256=oEvvulfsv5GIDWG2174gSS6tNB95w38AIYiYeifGKlE,2294
|
|
57
57
|
sourcecode/telemetry/filters.py,sha256=Asa71oRl7q3Wt_FMwuufIZJFzSYdgRNKS8LHCIyFeYE,4805
|
|
58
58
|
sourcecode/telemetry/transport.py,sha256=KJeIPCPWMdmbCP3ySGs2iUlia34U6vWne2dZsUezesw,1560
|
|
59
|
-
sourcecode-0.
|
|
60
|
-
sourcecode-0.
|
|
61
|
-
sourcecode-0.
|
|
62
|
-
sourcecode-0.
|
|
63
|
-
sourcecode-0.
|
|
59
|
+
sourcecode-0.37.0.dist-info/METADATA,sha256=75XE0yybH_O7U8rxcP6ZY2MdvibRaxALg4io5V9RsU4,25209
|
|
60
|
+
sourcecode-0.37.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
61
|
+
sourcecode-0.37.0.dist-info/entry_points.txt,sha256=ex3F9rmbXeyDIoFQHtkEqTsKSaJow8F0LrVu8XfIktQ,57
|
|
62
|
+
sourcecode-0.37.0.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
|
|
63
|
+
sourcecode-0.37.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|