sourcecode 0.45.0__py3-none-any.whl → 0.47.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 +18 -4
- sourcecode/prepare_context.py +38 -3
- sourcecode/serializer.py +91 -33
- sourcecode/workspace.py +35 -1
- {sourcecode-0.45.0.dist-info → sourcecode-0.47.0.dist-info}/METADATA +1 -1
- {sourcecode-0.45.0.dist-info → sourcecode-0.47.0.dist-info}/RECORD +10 -10
- {sourcecode-0.45.0.dist-info → sourcecode-0.47.0.dist-info}/WHEEL +0 -0
- {sourcecode-0.45.0.dist-info → sourcecode-0.47.0.dist-info}/entry_points.txt +0 -0
- {sourcecode-0.45.0.dist-info → sourcecode-0.47.0.dist-info}/licenses/LICENSE +0 -0
sourcecode/__init__.py
CHANGED
sourcecode/cli.py
CHANGED
|
@@ -731,8 +731,11 @@ def main(
|
|
|
731
731
|
# These flags produce standard_view-only output sections not in contract_view.
|
|
732
732
|
# Preserves backward compat: callers using any legacy flag get their previous format.
|
|
733
733
|
# New callers opt into contract mode via --mode contract (or bare invocation).
|
|
734
|
+
# Legacy flags that produce output sections incompatible with contract_view
|
|
735
|
+
# force mode to raw. --agent is excluded: it now runs the contract pipeline
|
|
736
|
+
# and enriches contract_view with auto-enabled analyzers (deps, env, notes).
|
|
734
737
|
_legacy_flags_active = (
|
|
735
|
-
compact or
|
|
738
|
+
compact or tree or format == "yaml" or trace_pipeline
|
|
736
739
|
or docs or semantics or graph_modules or full_metrics or architecture
|
|
737
740
|
)
|
|
738
741
|
if mode in ("contract", "standard") and _legacy_flags_active:
|
|
@@ -1429,11 +1432,9 @@ def main(
|
|
|
1429
1432
|
"Try --depth 8 or verify the symbol name.",
|
|
1430
1433
|
err=True,
|
|
1431
1434
|
)
|
|
1432
|
-
if agent:
|
|
1433
|
-
typer.echo(f"[contract] {len(_contracts)} files extracted ({_contract_summary.method_breakdown})", err=True)
|
|
1434
1435
|
|
|
1435
1436
|
# 4. Serialize
|
|
1436
|
-
if _is_contract_mode:
|
|
1437
|
+
if _is_contract_mode and not agent:
|
|
1437
1438
|
from sourcecode.serializer import contract_view as _contract_view
|
|
1438
1439
|
_depth = _CONTRACT_DEPTH.get(mode, "minimal")
|
|
1439
1440
|
data = _contract_view(sm, emit_graph=emit_graph, depth=_depth)
|
|
@@ -1442,6 +1443,19 @@ def main(
|
|
|
1442
1443
|
content = json.dumps(data, indent=2, ensure_ascii=False)
|
|
1443
1444
|
elif agent:
|
|
1444
1445
|
data = agent_view(sm)
|
|
1446
|
+
# When contract pipeline ran (mode=contract, no legacy flags), include
|
|
1447
|
+
# per-file contracts in agent output so agents get structural context.
|
|
1448
|
+
if _is_contract_mode and sm.file_contracts:
|
|
1449
|
+
from sourcecode.serializer import _serialize_contract_minimal
|
|
1450
|
+
data["contracts"] = [_serialize_contract_minimal(c) for c in sm.file_contracts]
|
|
1451
|
+
if sm.contract_summary is not None:
|
|
1452
|
+
cs = sm.contract_summary
|
|
1453
|
+
data["contract_summary"] = {
|
|
1454
|
+
"files": cs.extracted_files,
|
|
1455
|
+
"total": cs.total_files,
|
|
1456
|
+
}
|
|
1457
|
+
if cs.method_breakdown:
|
|
1458
|
+
data["contract_summary"]["methods"] = cs.method_breakdown
|
|
1445
1459
|
if not no_redact:
|
|
1446
1460
|
data = redact_dict(data)
|
|
1447
1461
|
content = json.dumps(data, indent=2, ensure_ascii=False)
|
sourcecode/prepare_context.py
CHANGED
|
@@ -349,21 +349,56 @@ class TaskContextBuilder:
|
|
|
349
349
|
spec = TASKS[task_name]
|
|
350
350
|
|
|
351
351
|
# ── 1. Scan ────────────────────────────────────────────────────────
|
|
352
|
-
from sourcecode.
|
|
352
|
+
from sourcecode.adaptive_scanner import AdaptiveScanner
|
|
353
|
+
from sourcecode.repo_classifier import RepoClassifier
|
|
353
354
|
from sourcecode.tree_utils import flatten_file_tree
|
|
354
355
|
|
|
355
|
-
|
|
356
|
+
_topology = RepoClassifier().classify(self.root)
|
|
357
|
+
scanner = AdaptiveScanner(self.root, topology=_topology, base_depth=6)
|
|
356
358
|
file_tree = scanner.scan_tree()
|
|
357
359
|
manifests = scanner.find_manifests()
|
|
358
360
|
all_paths = [p.replace("\\", "/") for p in flatten_file_tree(file_tree)]
|
|
359
361
|
|
|
360
362
|
# ── 2. Detect stacks + entry points ───────────────────────────────
|
|
363
|
+
from dataclasses import replace as _replace
|
|
361
364
|
from sourcecode.detectors import ProjectDetector, build_default_detectors
|
|
362
365
|
from sourcecode.workspace import WorkspaceAnalyzer
|
|
363
366
|
|
|
364
367
|
detector = ProjectDetector(build_default_detectors())
|
|
365
368
|
workspace_analysis = WorkspaceAnalyzer().analyze(self.root, manifests)
|
|
366
|
-
|
|
369
|
+
|
|
370
|
+
_root_manifests = [
|
|
371
|
+
m for m in manifests
|
|
372
|
+
if Path(m).resolve().parent == self.root
|
|
373
|
+
]
|
|
374
|
+
_detection_manifests = _root_manifests if workspace_analysis.workspaces else manifests
|
|
375
|
+
if workspace_analysis.is_monorepo and not _root_manifests:
|
|
376
|
+
from sourcecode.schema import EntryPoint, StackDetection
|
|
377
|
+
stacks: list[StackDetection] = []
|
|
378
|
+
entry_points: list[EntryPoint] = []
|
|
379
|
+
else:
|
|
380
|
+
stacks, entry_points, _ = detector.detect(self.root, file_tree, _detection_manifests)
|
|
381
|
+
|
|
382
|
+
# Iterate workspaces to collect per-workspace stacks and entry points —
|
|
383
|
+
# same approach as the main CLI (cli.py lines 971-1041).
|
|
384
|
+
for workspace in workspace_analysis.workspaces:
|
|
385
|
+
ws_root = self.root / workspace.path
|
|
386
|
+
if not ws_root.exists() or not ws_root.is_dir():
|
|
387
|
+
continue
|
|
388
|
+
_ws_topology = RepoClassifier().classify(ws_root)
|
|
389
|
+
_ws_scanner = AdaptiveScanner(ws_root, topology=_ws_topology, base_depth=6)
|
|
390
|
+
_ws_tree = _ws_scanner.scan_tree()
|
|
391
|
+
_ws_manifests = _ws_scanner.find_manifests()
|
|
392
|
+
_ws_stacks, _ws_eps, _ = detector.detect(ws_root, _ws_tree, _ws_manifests)
|
|
393
|
+
stacks.extend(
|
|
394
|
+
_replace(s, root=workspace.path, workspace=workspace.path, primary=False)
|
|
395
|
+
for s in _ws_stacks
|
|
396
|
+
)
|
|
397
|
+
entry_points.extend(
|
|
398
|
+
_replace(ep, path=f"{workspace.path}/{ep.path}")
|
|
399
|
+
for ep in _ws_eps
|
|
400
|
+
)
|
|
401
|
+
|
|
367
402
|
stacks, project_type = detector.classify_results(
|
|
368
403
|
file_tree, stacks, entry_points,
|
|
369
404
|
project_type_override="monorepo" if workspace_analysis.is_monorepo else None,
|
sourcecode/serializer.py
CHANGED
|
@@ -24,6 +24,21 @@ from sourcecode.schema import (
|
|
|
24
24
|
SourceMap,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
|
+
# ---------------------------------------------------------------------------
|
|
28
|
+
# Visibility caps — public output is intentionally small.
|
|
29
|
+
# Internal analysis stays broad; only high-signal results reach the output.
|
|
30
|
+
# ---------------------------------------------------------------------------
|
|
31
|
+
_EP_PRODUCTION_CAP = 5 # max production entry points in default output
|
|
32
|
+
_EP_DEV_CAP = 3 # max development entry points in default output
|
|
33
|
+
_FILE_RELEVANCE_LIMIT = 10 # max files in file_relevance section
|
|
34
|
+
_FILE_RELEVANCE_MIN_COMBINED = 0.20 # minimum combined score to appear (out of ~2.0 max)
|
|
35
|
+
_PROD_DEPS_CAP = 10 # max production dependencies shown
|
|
36
|
+
_SECONDARY_DEPS_CAP = 5 # max per dev/test/build dependency group
|
|
37
|
+
_MONOREPO_PKGS_CAP = 8 # max workspace/runtime packages shown
|
|
38
|
+
_KEY_DEPS_CAP = 10 # max key dependencies shown
|
|
39
|
+
_CODE_NOTES_CAP = 15 # max code notes in default output
|
|
40
|
+
_ENV_MAP_CAP = 15 # max env var entries in default output
|
|
41
|
+
|
|
27
42
|
|
|
28
43
|
def to_json(sm: SourceMap | dict[str, Any], indent: int = 2) -> str:
|
|
29
44
|
"""Serialize SourceMap or dict to canonical JSON.
|
|
@@ -176,7 +191,7 @@ def _dep_import_key(name: str) -> str:
|
|
|
176
191
|
return lowered.split("/")[0].replace("_", "-")
|
|
177
192
|
|
|
178
193
|
|
|
179
|
-
def _file_relevance(sm: SourceMap, *, limit: int =
|
|
194
|
+
def _file_relevance(sm: SourceMap, *, limit: int = _FILE_RELEVANCE_LIMIT) -> list[dict[str, Any]]:
|
|
180
195
|
from sourcecode.ranking_engine import RankingEngine
|
|
181
196
|
|
|
182
197
|
root = Path(sm.metadata.analyzed_path) if sm.metadata.analyzed_path else Path(".")
|
|
@@ -227,7 +242,20 @@ def _file_relevance(sm: SourceMap, *, limit: int = 15) -> list[dict[str, Any]]:
|
|
|
227
242
|
sem_hub = semantic_hub_scores.get(path, 0.0) * 0.30
|
|
228
243
|
combined = fs.score + content_rel + sem_hub
|
|
229
244
|
|
|
230
|
-
|
|
245
|
+
# Visibility threshold: require meaningful combined signal.
|
|
246
|
+
# Exception: high/medium-confidence files with strong content relevance
|
|
247
|
+
# can survive even if structural score is weak.
|
|
248
|
+
if combined < _FILE_RELEVANCE_MIN_COMBINED:
|
|
249
|
+
if not (file_class
|
|
250
|
+
and file_class.relevance > 0.45
|
|
251
|
+
and file_class.confidence in {"high", "medium"}):
|
|
252
|
+
continue
|
|
253
|
+
|
|
254
|
+
# Suppress low-confidence auxiliary/config files unless structurally prominent
|
|
255
|
+
if (file_class
|
|
256
|
+
and file_class.confidence == "low"
|
|
257
|
+
and file_class.category in {"config", "auxiliary"}
|
|
258
|
+
and combined < 0.45):
|
|
231
259
|
continue
|
|
232
260
|
|
|
233
261
|
item: dict[str, Any] = {
|
|
@@ -343,7 +371,7 @@ def compact_view(sm: SourceMap, *, no_tree: bool = False) -> dict[str, Any]:
|
|
|
343
371
|
key_deps = [
|
|
344
372
|
asdict(d) for d in sm.key_dependencies
|
|
345
373
|
if (d.role or "unknown") in _PRODUCTION_DEP_ROLES and d.scope not in {"dev"}
|
|
346
|
-
]
|
|
374
|
+
][:_KEY_DEPS_CAP]
|
|
347
375
|
elif sm.dependency_summary is None or not sm.dependency_summary.requested:
|
|
348
376
|
dep_summary_dict = None # "not analyzed" — agent should add --dependencies
|
|
349
377
|
|
|
@@ -358,7 +386,7 @@ def compact_view(sm: SourceMap, *, no_tree: bool = False) -> dict[str, Any]:
|
|
|
358
386
|
)
|
|
359
387
|
env_map_items = [
|
|
360
388
|
{k: v for k, v in asdict(e).items() if v is not None and v != "" and v != []}
|
|
361
|
-
for e in _sorted_env[:
|
|
389
|
+
for e in _sorted_env[:_ENV_MAP_CAP]
|
|
362
390
|
]
|
|
363
391
|
|
|
364
392
|
code_notes_summary_dict: Any = None
|
|
@@ -373,13 +401,13 @@ def compact_view(sm: SourceMap, *, no_tree: bool = False) -> dict[str, Any]:
|
|
|
373
401
|
)
|
|
374
402
|
code_notes_items = [
|
|
375
403
|
{k: v for k, v in asdict(n).items() if v is not None}
|
|
376
|
-
for n in _sorted_notes[:
|
|
404
|
+
for n in _sorted_notes[:_CODE_NOTES_CAP]
|
|
377
405
|
]
|
|
378
406
|
|
|
379
|
-
# Entry points: production runtime only.
|
|
380
|
-
#
|
|
407
|
+
# Entry points: production runtime only, capped.
|
|
408
|
+
# Development entries shown separately; auxiliary omitted from compact view.
|
|
381
409
|
ep_groups = _entry_point_groups(sm.entry_points)
|
|
382
|
-
entry_points_compact = ep_groups["production"]
|
|
410
|
+
entry_points_compact = ep_groups["production"][:_EP_PRODUCTION_CAP]
|
|
383
411
|
if not entry_points_compact:
|
|
384
412
|
entry_points_compact = [] # truth signal: no production runtime detected
|
|
385
413
|
|
|
@@ -408,8 +436,7 @@ def compact_view(sm: SourceMap, *, no_tree: bool = False) -> dict[str, Any]:
|
|
|
408
436
|
"context_summary": context_summary_dict,
|
|
409
437
|
"stacks": [asdict(stack) for stack in sm.stacks],
|
|
410
438
|
"entry_points": entry_points_compact,
|
|
411
|
-
"development_entry_points": ep_groups["development"] or None,
|
|
412
|
-
"auxiliary_entry_points": ep_groups["auxiliary"] or None,
|
|
439
|
+
"development_entry_points": (ep_groups["development"][:_EP_DEV_CAP] or None),
|
|
413
440
|
"dependency_summary": dep_summary_dict,
|
|
414
441
|
"key_dependencies": key_deps,
|
|
415
442
|
"env_summary": env_summary_dict,
|
|
@@ -742,25 +769,23 @@ def agent_view(sm: SourceMap) -> dict[str, Any]:
|
|
|
742
769
|
|
|
743
770
|
result: dict[str, Any] = {"project": project}
|
|
744
771
|
|
|
745
|
-
# ── 2. Entry points: production/runtime only
|
|
746
|
-
#
|
|
747
|
-
#
|
|
772
|
+
# ── 2. Entry points: production/runtime only, capped ─────────────────────
|
|
773
|
+
# Auxiliary entries are not actionable for agents — omitted entirely.
|
|
774
|
+
# Development entries shown in a separate channel, capped.
|
|
748
775
|
ep_groups = _entry_point_groups(sm.entry_points)
|
|
749
|
-
result["entry_points"] = ep_groups["production"]
|
|
776
|
+
result["entry_points"] = ep_groups["production"][:_EP_PRODUCTION_CAP]
|
|
750
777
|
if ep_groups["development"]:
|
|
751
|
-
result["development_entry_points"] = ep_groups["development"]
|
|
752
|
-
if ep_groups["auxiliary"]:
|
|
753
|
-
result["auxiliary_entry_points"] = ep_groups["auxiliary"]
|
|
778
|
+
result["development_entry_points"] = ep_groups["development"][:_EP_DEV_CAP]
|
|
754
779
|
|
|
755
780
|
# ── 3. Architecture ───────────────────────────────────────────────────────
|
|
756
781
|
result["architecture"] = _architecture_context(sm)
|
|
757
782
|
|
|
758
|
-
# ── 3a. File relevance: evidence-backed
|
|
783
|
+
# ── 3a. File relevance: evidence-backed, high-signal only ────────────────
|
|
759
784
|
relevant_files = _file_relevance(sm)
|
|
760
785
|
if relevant_files:
|
|
761
786
|
result["file_relevance"] = relevant_files
|
|
762
787
|
|
|
763
|
-
# ── 3b. Monorepo package roles (when available)
|
|
788
|
+
# ── 3b. Monorepo package roles (when available), capped ──────────────────
|
|
764
789
|
if sm.monorepo_packages:
|
|
765
790
|
_noise_roles = {"benchmark_layer", "tooling_layer", "docs_layer", "test_layer"}
|
|
766
791
|
operational_pkgs = [
|
|
@@ -769,15 +794,16 @@ def agent_view(sm: SourceMap) -> dict[str, Any]:
|
|
|
769
794
|
if p.architectural_role not in _noise_roles
|
|
770
795
|
]
|
|
771
796
|
if operational_pkgs:
|
|
772
|
-
result["runtime_packages"] = operational_pkgs
|
|
797
|
+
result["runtime_packages"] = operational_pkgs[:_MONOREPO_PKGS_CAP]
|
|
773
798
|
|
|
774
|
-
# ── 4. Dependencies: separated by operational role
|
|
799
|
+
# ── 4. Dependencies: separated by operational role, capped ───────────────
|
|
800
|
+
# noise_dependencies intentionally excluded — not actionable.
|
|
775
801
|
dep_groups = _dependency_groups(sm)
|
|
776
802
|
if dep_groups["production_dependencies"]:
|
|
777
|
-
result["production_dependencies"] = dep_groups["production_dependencies"][:
|
|
778
|
-
for dep_key in ("dev_tools", "test_utilities", "build_tooling", "
|
|
803
|
+
result["production_dependencies"] = dep_groups["production_dependencies"][:_PROD_DEPS_CAP]
|
|
804
|
+
for dep_key in ("dev_tools", "test_utilities", "build_tooling", "suspicious_dependencies"):
|
|
779
805
|
if dep_groups[dep_key]:
|
|
780
|
-
result[dep_key] = dep_groups[dep_key][:
|
|
806
|
+
result[dep_key] = dep_groups[dep_key][:_SECONDARY_DEPS_CAP]
|
|
781
807
|
|
|
782
808
|
# Backward-compatible compact list, now production-only.
|
|
783
809
|
production_key_deps = [
|
|
@@ -788,7 +814,7 @@ def agent_view(sm: SourceMap) -> dict[str, Any]:
|
|
|
788
814
|
_dep_skip = {"parent", "manifest_path", "workspace", "source", "ecosystem"}
|
|
789
815
|
result["key_dependencies"] = [
|
|
790
816
|
{k: v for k, v in asdict(d).items() if v is not None and k not in _dep_skip}
|
|
791
|
-
for d in production_key_deps[:
|
|
817
|
+
for d in production_key_deps[:_KEY_DEPS_CAP]
|
|
792
818
|
]
|
|
793
819
|
|
|
794
820
|
# ── 5. Signals — compact operational context ─────────────────────────────
|
|
@@ -961,12 +987,12 @@ def standard_view(sm: SourceMap, *, include_tree: bool = False) -> dict[str, Any
|
|
|
961
987
|
"project_summary": sm.project_summary,
|
|
962
988
|
"architecture_summary": sm.architecture_summary,
|
|
963
989
|
"stacks": [asdict(s) for s in sm.stacks],
|
|
964
|
-
"entry_points": ep_groups["production"],
|
|
990
|
+
"entry_points": ep_groups["production"][:_EP_PRODUCTION_CAP],
|
|
965
991
|
}
|
|
966
992
|
if ep_groups["development"]:
|
|
967
|
-
result["development_entry_points"] = ep_groups["development"]
|
|
993
|
+
result["development_entry_points"] = ep_groups["development"][:_EP_DEV_CAP]
|
|
968
994
|
if ep_groups["auxiliary"]:
|
|
969
|
-
result["auxiliary_entry_points"] = ep_groups["auxiliary"]
|
|
995
|
+
result["auxiliary_entry_points"] = ep_groups["auxiliary"][:_EP_DEV_CAP]
|
|
970
996
|
|
|
971
997
|
# Layer B — signals (only when the corresponding analyzer ran)
|
|
972
998
|
if sm.dependency_summary is not None and sm.dependency_summary.requested:
|
|
@@ -976,16 +1002,21 @@ def standard_view(sm: SourceMap, *, include_tree: bool = False) -> dict[str, Any
|
|
|
976
1002
|
result["key_dependencies"] = [
|
|
977
1003
|
asdict(d) for d in sm.key_dependencies
|
|
978
1004
|
if (d.role or "unknown") in _PRODUCTION_DEP_ROLES and d.scope not in {"dev"}
|
|
979
|
-
]
|
|
1005
|
+
][:_KEY_DEPS_CAP]
|
|
980
1006
|
|
|
981
1007
|
if sm.env_summary is not None and sm.env_summary.requested:
|
|
982
1008
|
result["env_summary"] = asdict(sm.env_summary)
|
|
983
|
-
result["env_map"] = [asdict(e) for e in sm.env_map]
|
|
1009
|
+
result["env_map"] = [asdict(e) for e in sm.env_map[:_ENV_MAP_CAP]]
|
|
984
1010
|
|
|
985
1011
|
if sm.code_notes_summary is not None and sm.code_notes_summary.requested:
|
|
986
1012
|
result["code_notes_summary"] = asdict(sm.code_notes_summary)
|
|
987
1013
|
if sm.code_notes:
|
|
988
|
-
|
|
1014
|
+
_SEVERITY_ORDER = {"BUG": 0, "FIXME": 1, "DEPRECATED": 2, "TODO": 3, "HACK": 4, "WARNING": 5}
|
|
1015
|
+
_sorted_notes = sorted(
|
|
1016
|
+
sm.code_notes,
|
|
1017
|
+
key=lambda n: (_SEVERITY_ORDER.get(getattr(n, "kind", "").upper(), 9), getattr(n, "path", "")),
|
|
1018
|
+
)
|
|
1019
|
+
result["code_notes"] = [asdict(n) for n in _sorted_notes[:_CODE_NOTES_CAP]]
|
|
989
1020
|
if sm.code_adrs:
|
|
990
1021
|
result["code_adrs"] = [asdict(a) for a in sm.code_adrs]
|
|
991
1022
|
|
|
@@ -1076,12 +1107,12 @@ def _contract_view_minimal(
|
|
|
1076
1107
|
"""Minimal contract: project header + stripped per-file contracts."""
|
|
1077
1108
|
primary = next((s for s in sm.stacks if s.primary), sm.stacks[0] if sm.stacks else None)
|
|
1078
1109
|
|
|
1079
|
-
# Entry point paths only (production)
|
|
1110
|
+
# Entry point paths only (production), capped
|
|
1080
1111
|
ep_paths = sorted({
|
|
1081
1112
|
ep.path.replace("\\", "/")
|
|
1082
1113
|
for ep in sm.entry_points
|
|
1083
1114
|
if is_production_entry_point(ep)
|
|
1084
|
-
})
|
|
1115
|
+
})[:_EP_PRODUCTION_CAP]
|
|
1085
1116
|
|
|
1086
1117
|
project: dict[str, Any] = {"type": sm.project_type}
|
|
1087
1118
|
if primary:
|
|
@@ -1174,6 +1205,33 @@ def _contract_view_minimal(
|
|
|
1174
1205
|
if cs.symbol_truncation:
|
|
1175
1206
|
result["symbol_query"] = cs.symbol_truncation
|
|
1176
1207
|
|
|
1208
|
+
# Monorepo package roles — helps agents understand workspace structure
|
|
1209
|
+
if sm.monorepo_packages:
|
|
1210
|
+
_noise_roles = {"benchmark_layer", "tooling_layer", "docs_layer", "test_layer"}
|
|
1211
|
+
operational_pkgs = [
|
|
1212
|
+
{"path": p.path, "role": p.architectural_role, "criticality": p.criticality}
|
|
1213
|
+
for p in sm.monorepo_packages
|
|
1214
|
+
if p.architectural_role not in _noise_roles
|
|
1215
|
+
]
|
|
1216
|
+
if operational_pkgs:
|
|
1217
|
+
result["workspace_packages"] = operational_pkgs[:_MONOREPO_PKGS_CAP]
|
|
1218
|
+
|
|
1219
|
+
# Confidence summary — detection quality signal
|
|
1220
|
+
if sm.confidence_summary is not None:
|
|
1221
|
+
cs_conf = sm.confidence_summary
|
|
1222
|
+
conf: dict[str, Any] = {
|
|
1223
|
+
"overall": cs_conf.overall,
|
|
1224
|
+
"stack": cs_conf.stack_confidence,
|
|
1225
|
+
"entry_points": cs_conf.entry_point_confidence,
|
|
1226
|
+
}
|
|
1227
|
+
if cs_conf.anomalies:
|
|
1228
|
+
conf["anomalies"] = cs_conf.anomalies
|
|
1229
|
+
result["confidence"] = conf
|
|
1230
|
+
|
|
1231
|
+
# Analysis gaps — explicit about what could not be analyzed
|
|
1232
|
+
if sm.analysis_gaps:
|
|
1233
|
+
result["analysis_gaps"] = [asdict(g) for g in sm.analysis_gaps]
|
|
1234
|
+
|
|
1177
1235
|
return result
|
|
1178
1236
|
|
|
1179
1237
|
|
sourcecode/workspace.py
CHANGED
|
@@ -45,7 +45,7 @@ class WorkspaceAnalyzer:
|
|
|
45
45
|
|
|
46
46
|
def _detect_markers(self, root: Path) -> list[str]:
|
|
47
47
|
markers: list[str] = []
|
|
48
|
-
for filename in ("pnpm-workspace.yaml", "go.work", "turbo.json", "lerna.json"):
|
|
48
|
+
for filename in ("pnpm-workspace.yaml", "go.work", "turbo.json", "lerna.json", "nx.json", "rush.json"):
|
|
49
49
|
if (root / filename).exists():
|
|
50
50
|
markers.append(filename)
|
|
51
51
|
|
|
@@ -54,6 +54,17 @@ class WorkspaceAnalyzer:
|
|
|
54
54
|
content = cargo.read_text(encoding="utf-8", errors="replace")
|
|
55
55
|
if "[workspace]" in content:
|
|
56
56
|
markers.append("Cargo.toml[workspace]")
|
|
57
|
+
|
|
58
|
+
pkg = root / "package.json"
|
|
59
|
+
if pkg.exists():
|
|
60
|
+
try:
|
|
61
|
+
import json as _json
|
|
62
|
+
data = _json.loads(pkg.read_text(encoding="utf-8", errors="replace"))
|
|
63
|
+
if isinstance(data, dict) and data.get("workspaces"):
|
|
64
|
+
markers.append("package.json[workspaces]")
|
|
65
|
+
except Exception:
|
|
66
|
+
pass
|
|
67
|
+
|
|
57
68
|
return markers
|
|
58
69
|
|
|
59
70
|
def _workspace_candidates_from_manifests(
|
|
@@ -84,6 +95,8 @@ class WorkspaceAnalyzer:
|
|
|
84
95
|
candidates.extend(self._from_go_work(root))
|
|
85
96
|
if "Cargo.toml[workspace]" in markers:
|
|
86
97
|
candidates.extend(self._from_cargo_workspace(root))
|
|
98
|
+
if "package.json[workspaces]" in markers:
|
|
99
|
+
candidates.extend(self._from_npm_workspaces(root))
|
|
87
100
|
return [candidate for candidate in candidates if self._is_allowed_workspace(candidate.path)]
|
|
88
101
|
|
|
89
102
|
def _from_pnpm_workspace(self, root: Path) -> list[WorkspaceCandidate]:
|
|
@@ -143,6 +156,27 @@ class WorkspaceAnalyzer:
|
|
|
143
156
|
in_members = False
|
|
144
157
|
return candidates
|
|
145
158
|
|
|
159
|
+
def _from_npm_workspaces(self, root: Path) -> list[WorkspaceCandidate]:
|
|
160
|
+
try:
|
|
161
|
+
import json as _json
|
|
162
|
+
data = _json.loads((root / "package.json").read_text(encoding="utf-8", errors="replace"))
|
|
163
|
+
except Exception:
|
|
164
|
+
return []
|
|
165
|
+
workspaces = data.get("workspaces", [])
|
|
166
|
+
if isinstance(workspaces, dict):
|
|
167
|
+
workspaces = workspaces.get("packages", [])
|
|
168
|
+
if not isinstance(workspaces, list):
|
|
169
|
+
return []
|
|
170
|
+
candidates: list[WorkspaceCandidate] = []
|
|
171
|
+
for pattern in workspaces:
|
|
172
|
+
if not isinstance(pattern, str):
|
|
173
|
+
continue
|
|
174
|
+
for path in self._resolve_pattern(root, pattern):
|
|
175
|
+
candidates.append(
|
|
176
|
+
WorkspaceCandidate(path=path, reason="marker:package.json[workspaces]", depth=len(Path(path).parts))
|
|
177
|
+
)
|
|
178
|
+
return candidates
|
|
179
|
+
|
|
146
180
|
def _resolve_pattern(self, root: Path, pattern: str) -> list[str]:
|
|
147
181
|
matches: list[str] = []
|
|
148
182
|
for candidate in root.glob(pattern):
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
sourcecode/__init__.py,sha256=
|
|
1
|
+
sourcecode/__init__.py,sha256=d1ZO7BWBwtFn6pK50mntp9_F0e-laNVU7vBBdeZXfU0,103
|
|
2
2
|
sourcecode/adaptive_scanner.py,sha256=6dh34C2qZXyRbw-8xBhbEwDdXanM6CRFRWayVoYITnA,10190
|
|
3
3
|
sourcecode/architecture_analyzer.py,sha256=O4AXc7l_WTzIXrcAzstqZy-TGKNaFa6p3MzpgVjaO8g,27749
|
|
4
4
|
sourcecode/architecture_summary.py,sha256=rSY5MRiaz4N1YdG0pqDTDuFjSN7PO_Zplx-dtNzv2Yo,19985
|
|
5
5
|
sourcecode/ast_extractor.py,sha256=0OHQwTUBBc9lmqPLryVeB1z8dGIC6NhLlar800CD9oI,41129
|
|
6
6
|
sourcecode/classifier.py,sha256=GKTMN8qKZX7ponSwDJfN08RrasI4CVpq1_gFBgEopps,7093
|
|
7
|
-
sourcecode/cli.py,sha256=
|
|
7
|
+
sourcecode/cli.py,sha256=BC83AWW3oSIWcQM8IPN0tU-1bSb2NyhkMS_Fyi3bRRc,71887
|
|
8
8
|
sourcecode/code_notes_analyzer.py,sha256=rRd8bFYV0krjlxxQV0wenwE9K7pVpUQSR7KvSvUQKw4,9226
|
|
9
9
|
sourcecode/confidence_analyzer.py,sha256=HxJMPLI5ulqtkncnv98W4iVO6yMbpQo87VuxiuNbDmY,12167
|
|
10
10
|
sourcecode/context_scorer.py,sha256=nhppAo80fblAqcB9Ns0iQd21TZUrl2mQMo_xzPgavRE,14679
|
|
@@ -20,7 +20,7 @@ sourcecode/file_classifier.py,sha256=_KfFIIolharaIxbSTrCkaWauQIqNHCyor_n47RGyDh8
|
|
|
20
20
|
sourcecode/git_analyzer.py,sha256=PD3eNWydznQ6KLNpxGzBqizIHoPIKevfwz9Xyf_pDt4,11600
|
|
21
21
|
sourcecode/graph_analyzer.py,sha256=hMOsLLz9B0UnQ4xwbHdgr3bFvqpw0bQ8kN-xmEn3Krk,64156
|
|
22
22
|
sourcecode/metrics_analyzer.py,sha256=e2cFwB9XubFq_dIVsP2PLjpr4wX0N6ulb3ol3sGDUeo,20777
|
|
23
|
-
sourcecode/prepare_context.py,sha256=
|
|
23
|
+
sourcecode/prepare_context.py,sha256=pSVti4gjfBQM24bBCnEW74uZ_c6XijX6z4f8Bt-DkSY,33943
|
|
24
24
|
sourcecode/ranking_engine.py,sha256=virVglafZufioHpZpwktjMvUiL0TZELWQCQnQNV8dFo,9360
|
|
25
25
|
sourcecode/redactor.py,sha256=xuGcadGEHaPw4qZXlMDvzMCsr4VOkdp3oBQptHyJk8c,2884
|
|
26
26
|
sourcecode/relevance_scorer.py,sha256=E74w7nlsNVobO3LqKHiMtBd84ONwGp8uDpwXJEjRtLA,8330
|
|
@@ -29,10 +29,10 @@ sourcecode/runtime_classifier.py,sha256=zWX3r3HCKHc-qtIobErOa8aKMmaoPYREtJKvPcBG
|
|
|
29
29
|
sourcecode/scanner.py,sha256=aM3h9-DCQ3xKpeHpHYdo2vX6T5P95HA_YwZbkAVNwmo,8288
|
|
30
30
|
sourcecode/schema.py,sha256=ofEge9hTWHOTjeWt7ceCDQWzP-uhhenrYX2usjW2KVU,22759
|
|
31
31
|
sourcecode/semantic_analyzer.py,sha256=16EFTgM7ooW0m5gNUKOlTSn7IEMLSzKmzQn-cWaSqjs,82604
|
|
32
|
-
sourcecode/serializer.py,sha256=
|
|
32
|
+
sourcecode/serializer.py,sha256=Bt7HLDu6qt6NllsYhoPEeA1Nrk8nDkwZByymwuF3NKs,62595
|
|
33
33
|
sourcecode/summarizer.py,sha256=ZuzIdm3t8A-d5MuQL0TSNLrd-L0IQIuguIxeNXMNJf8,16070
|
|
34
34
|
sourcecode/tree_utils.py,sha256=Fj9OIuUksBvgibNd3feog0sMDjVypJzPexp5lvMoYWI,1424
|
|
35
|
-
sourcecode/workspace.py,sha256=
|
|
35
|
+
sourcecode/workspace.py,sha256=X_6NmNnitvT3_38V-JDChydo_sR68s249hLFlrQskU0,8271
|
|
36
36
|
sourcecode/detectors/__init__.py,sha256=A0AACJFF6HWf_RgatNtWu3PUzstcKtIGM9f1PoFcJug,1987
|
|
37
37
|
sourcecode/detectors/base.py,sha256=C2EqfZudQ1ITK4DID4M70nPxqoh9bl1zn_ta6XRaGWs,1168
|
|
38
38
|
sourcecode/detectors/csproj_parser.py,sha256=2Vxfo6h_ucF1KPTTOYLzNnCGRfHWIATVMeaHY45PbQY,6756
|
|
@@ -60,8 +60,8 @@ sourcecode/telemetry/consent.py,sha256=wLMvGNJeSSyZoNkQXpoUioY6mMv4Qdvuw7S9jAEWn
|
|
|
60
60
|
sourcecode/telemetry/events.py,sha256=oEvvulfsv5GIDWG2174gSS6tNB95w38AIYiYeifGKlE,2294
|
|
61
61
|
sourcecode/telemetry/filters.py,sha256=Asa71oRl7q3Wt_FMwuufIZJFzSYdgRNKS8LHCIyFeYE,4805
|
|
62
62
|
sourcecode/telemetry/transport.py,sha256=KJeIPCPWMdmbCP3ySGs2iUlia34U6vWne2dZsUezesw,1560
|
|
63
|
-
sourcecode-0.
|
|
64
|
-
sourcecode-0.
|
|
65
|
-
sourcecode-0.
|
|
66
|
-
sourcecode-0.
|
|
67
|
-
sourcecode-0.
|
|
63
|
+
sourcecode-0.47.0.dist-info/METADATA,sha256=5jHdy2fsqrC8KEFvA7Z_ZcunHN_zUyDcYafe0X1tKWs,25209
|
|
64
|
+
sourcecode-0.47.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
65
|
+
sourcecode-0.47.0.dist-info/entry_points.txt,sha256=ex3F9rmbXeyDIoFQHtkEqTsKSaJow8F0LrVu8XfIktQ,57
|
|
66
|
+
sourcecode-0.47.0.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
|
|
67
|
+
sourcecode-0.47.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|