sourcecode 1.35.6__py3-none-any.whl → 1.35.8__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/mcp/registry.py +608 -28
- sourcecode/mcp/server.py +23 -4
- {sourcecode-1.35.6.dist-info → sourcecode-1.35.8.dist-info}/METADATA +1 -1
- {sourcecode-1.35.6.dist-info → sourcecode-1.35.8.dist-info}/RECORD +8 -8
- {sourcecode-1.35.6.dist-info → sourcecode-1.35.8.dist-info}/WHEEL +0 -0
- {sourcecode-1.35.6.dist-info → sourcecode-1.35.8.dist-info}/entry_points.txt +0 -0
- {sourcecode-1.35.6.dist-info → sourcecode-1.35.8.dist-info}/licenses/LICENSE +0 -0
sourcecode/__init__.py
CHANGED
sourcecode/mcp/registry.py
CHANGED
|
@@ -10,7 +10,7 @@ Internal helpers remain explicitly marked and are not exported to MCP.
|
|
|
10
10
|
"""
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
|
-
from dataclasses import dataclass, field
|
|
13
|
+
from dataclasses import dataclass, field, replace
|
|
14
14
|
import inspect
|
|
15
15
|
from functools import lru_cache
|
|
16
16
|
from typing import Any, Callable, Mapping
|
|
@@ -69,6 +69,7 @@ class ToolSpec:
|
|
|
69
69
|
aliases: tuple[str, ...] = ()
|
|
70
70
|
internal: bool = False
|
|
71
71
|
not_exposed_to_cli: bool = False
|
|
72
|
+
mcp_hidden: bool = False
|
|
72
73
|
docstring: str = ""
|
|
73
74
|
runtime_command: str = ""
|
|
74
75
|
_argv_builder: Callable[[Mapping[str, Any]], list[str]] | None = field(
|
|
@@ -82,6 +83,10 @@ class ToolSpec:
|
|
|
82
83
|
def public(self) -> bool:
|
|
83
84
|
return not self.internal and not self.not_exposed_to_cli
|
|
84
85
|
|
|
86
|
+
@property
|
|
87
|
+
def mcp_visible(self) -> bool:
|
|
88
|
+
return self.public and not self.mcp_hidden
|
|
89
|
+
|
|
85
90
|
def build_argv(self, inputs: Mapping[str, Any]) -> list[str]:
|
|
86
91
|
if self._argv_builder is None:
|
|
87
92
|
raise RuntimeError(f"ToolSpec '{self.name}' has no argv builder")
|
|
@@ -488,8 +493,11 @@ def _alias_spec(
|
|
|
488
493
|
aliases: tuple[str, ...] = (),
|
|
489
494
|
internal: bool = False,
|
|
490
495
|
not_exposed_to_cli: bool = False,
|
|
496
|
+
mcp_hidden: bool = False,
|
|
497
|
+
docstring_override: str | None = None,
|
|
491
498
|
validator: Callable[[Mapping[str, Any]], str | None] | None = None,
|
|
492
499
|
) -> ToolSpec:
|
|
500
|
+
doc = docstring_override or _build_contract_doc(description, params, cli_path, supported_targets, unsupported_targets)
|
|
493
501
|
return ToolSpec(
|
|
494
502
|
name=name,
|
|
495
503
|
description=description,
|
|
@@ -500,7 +508,8 @@ def _alias_spec(
|
|
|
500
508
|
aliases=aliases,
|
|
501
509
|
internal=internal,
|
|
502
510
|
not_exposed_to_cli=not_exposed_to_cli,
|
|
503
|
-
|
|
511
|
+
mcp_hidden=mcp_hidden,
|
|
512
|
+
docstring=doc,
|
|
504
513
|
runtime_command=" ".join(cli_path) if cli_path else "sourcecode",
|
|
505
514
|
_argv_builder=argv_builder,
|
|
506
515
|
validator=validator,
|
|
@@ -535,41 +544,86 @@ def _root_aliases() -> list[ToolSpec]:
|
|
|
535
544
|
module = str(inputs["module"]).strip("/")
|
|
536
545
|
return [f"{repo_path}/{module}", "--compact"]
|
|
537
546
|
|
|
547
|
+
_GET_COMPACT_DOC = """\
|
|
548
|
+
Compact human/LLM summary of a repository (~1000-3000 tokens). USE THIS FIRST.
|
|
549
|
+
|
|
550
|
+
Best for: quick project orientation, first-time context, token-budget constrained tasks.
|
|
551
|
+
Returns: stacks, entry points, dependency summary, architecture summary, confidence, gaps.
|
|
552
|
+
Includes security_surface, mybatis, and transactional_boundaries for Java/Spring projects.
|
|
553
|
+
For richer machine-oriented detail (deeper signals, more sections), use get_agent_context.
|
|
554
|
+
|
|
555
|
+
Maps to: sourcecode <repo_path> --compact [--git-context]
|
|
556
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
557
|
+
git_context: include git log and branch context in the analysis.
|
|
558
|
+
"""
|
|
559
|
+
|
|
560
|
+
_GET_AGENT_DOC = """\
|
|
561
|
+
Full structured agent context with extended machine-oriented signals (~5000-15000 tokens).
|
|
562
|
+
|
|
563
|
+
Best for: deep analysis, bug investigation, code review, or when get_compact_context
|
|
564
|
+
lacks sufficient detail. Includes all compact fields plus: env_map, code_notes,
|
|
565
|
+
architecture layers, security surface, transactional boundaries, module graph summary.
|
|
566
|
+
Prefer get_compact_context for quick orientation or token-constrained workflows.
|
|
567
|
+
|
|
568
|
+
Maps to: sourcecode <repo_path> --agent [--git-context]
|
|
569
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
570
|
+
git_context: include git log and branch context in the analysis.
|
|
571
|
+
"""
|
|
572
|
+
|
|
573
|
+
_GET_MODULE_DOC = """\
|
|
574
|
+
Compact analysis of a specific module or subdirectory within a repository.
|
|
575
|
+
|
|
576
|
+
Maps to: sourcecode <repo_path>/<module> --compact
|
|
577
|
+
repo_path: absolute path to the repository root.
|
|
578
|
+
module: subdirectory name relative to repo_path (e.g. 'src/auth', 'api', 'core').
|
|
579
|
+
Returns: same fields as get_compact_context but scoped to the module subtree.
|
|
580
|
+
"""
|
|
581
|
+
|
|
582
|
+
_TELEMETRY_DOC = """\
|
|
583
|
+
Manage telemetry settings.
|
|
584
|
+
|
|
585
|
+
Maps to: sourcecode telemetry <action>
|
|
586
|
+
action: one of "status" (show current state), "enable" (opt in), "disable" (opt out).
|
|
587
|
+
Valid values: "status" | "enable" | "disable"
|
|
588
|
+
"""
|
|
589
|
+
|
|
538
590
|
return [
|
|
539
591
|
_alias_spec(
|
|
540
592
|
"get_compact_context",
|
|
541
|
-
"Compact
|
|
542
|
-
"Use get_agent_context for richer detail.",
|
|
593
|
+
"Compact human/LLM summary of a repository (~1000-3000 tokens). USE THIS FIRST.",
|
|
543
594
|
("sourcecode",),
|
|
544
595
|
params_compact,
|
|
545
596
|
compact_argv,
|
|
546
597
|
supported_targets=("repo_path",),
|
|
547
598
|
unsupported_targets=("file_path",),
|
|
548
599
|
validator=validate_repo_path,
|
|
600
|
+
docstring_override=_GET_COMPACT_DOC,
|
|
549
601
|
),
|
|
550
602
|
_alias_spec(
|
|
551
603
|
"get_agent_context",
|
|
552
|
-
"
|
|
604
|
+
"Full structured agent context with extended machine-oriented signals (~5000-15000 tokens).",
|
|
553
605
|
("sourcecode",),
|
|
554
606
|
params_compact,
|
|
555
607
|
agent_argv,
|
|
556
608
|
supported_targets=("repo_path",),
|
|
557
609
|
unsupported_targets=("file_path",),
|
|
558
610
|
validator=validate_repo_path,
|
|
611
|
+
docstring_override=_GET_AGENT_DOC,
|
|
559
612
|
),
|
|
560
613
|
_alias_spec(
|
|
561
614
|
"get_module_context",
|
|
562
|
-
"Compact
|
|
615
|
+
"Compact analysis of a specific module or subdirectory within a repository.",
|
|
563
616
|
("sourcecode",),
|
|
564
617
|
params_module,
|
|
565
618
|
module_argv,
|
|
566
619
|
supported_targets=("repo_path", "module_path"),
|
|
567
620
|
unsupported_targets=("file_path",),
|
|
568
621
|
validator=validate_repo_path,
|
|
622
|
+
docstring_override=_GET_MODULE_DOC,
|
|
569
623
|
),
|
|
570
624
|
_alias_spec(
|
|
571
625
|
"telemetry",
|
|
572
|
-
"
|
|
626
|
+
"Manage telemetry settings: status | enable | disable.",
|
|
573
627
|
("telemetry",),
|
|
574
628
|
(
|
|
575
629
|
ToolParamSpec(
|
|
@@ -582,6 +636,7 @@ def _root_aliases() -> list[ToolSpec]:
|
|
|
582
636
|
),
|
|
583
637
|
lambda inputs: ["telemetry", str(inputs["action"])],
|
|
584
638
|
supported_targets=("action",),
|
|
639
|
+
docstring_override=_TELEMETRY_DOC,
|
|
585
640
|
),
|
|
586
641
|
]
|
|
587
642
|
|
|
@@ -589,10 +644,20 @@ def _root_aliases() -> list[ToolSpec]:
|
|
|
589
644
|
def _prepare_context_aliases() -> list[ToolSpec]:
|
|
590
645
|
validate_repo_path = _repo_path_validator()
|
|
591
646
|
|
|
592
|
-
|
|
647
|
+
# Only used for prepare-context tasks that genuinely accept --since (delta, review-pr).
|
|
648
|
+
def _since_task_alias(
|
|
649
|
+
name: str,
|
|
650
|
+
task: str,
|
|
651
|
+
description: str,
|
|
652
|
+
*,
|
|
653
|
+
supported_targets: tuple[str, ...],
|
|
654
|
+
docstring_override: str | None = None,
|
|
655
|
+
) -> ToolSpec:
|
|
593
656
|
params = (
|
|
594
657
|
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
595
|
-
ToolParamSpec("since", "
|
|
658
|
+
ToolParamSpec("since", "option", str, required=False, default="",
|
|
659
|
+
option_names=("--since",),
|
|
660
|
+
help="Git ref to diff against (e.g. HEAD~3, origin/main)."),
|
|
596
661
|
)
|
|
597
662
|
|
|
598
663
|
def argv_builder(inputs: Mapping[str, Any]) -> list[str]:
|
|
@@ -602,7 +667,6 @@ def _prepare_context_aliases() -> list[ToolSpec]:
|
|
|
602
667
|
if not value and name == "get_delta":
|
|
603
668
|
try:
|
|
604
669
|
from sourcecode.mcp.server import _auto_since as _resolve_since
|
|
605
|
-
|
|
606
670
|
value = _resolve_since(repo_path)
|
|
607
671
|
except Exception:
|
|
608
672
|
value = "HEAD~1"
|
|
@@ -619,31 +683,310 @@ def _prepare_context_aliases() -> list[ToolSpec]:
|
|
|
619
683
|
supported_targets=supported_targets,
|
|
620
684
|
unsupported_targets=("file_path",),
|
|
621
685
|
validator=validate_repo_path,
|
|
686
|
+
docstring_override=docstring_override,
|
|
622
687
|
)
|
|
623
688
|
|
|
689
|
+
_GET_DELTA_DOC = """\
|
|
690
|
+
Incremental context: git-changed files since a reference commit.
|
|
691
|
+
|
|
692
|
+
Maps to: sourcecode prepare-context delta <repo_path> --since <since>
|
|
693
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
694
|
+
since: git ref to diff against (e.g. HEAD~3, main, origin/main).
|
|
695
|
+
If empty or omitted, auto-detects merge-base with origin/main (or
|
|
696
|
+
origin/master). Falls back to HEAD~1 if no remote branch found.
|
|
697
|
+
Pass "HEAD~1" explicitly to force single-commit diff.
|
|
698
|
+
"""
|
|
699
|
+
|
|
700
|
+
_REVIEW_PR_DOC = """\
|
|
701
|
+
Execution paths and risk analysis for changed files in a pull request.
|
|
702
|
+
|
|
703
|
+
Maps to: sourcecode prepare-context review-pr <repo_path> [--since <since>]
|
|
704
|
+
Returns: compact_base + execution_paths (diff-scoped) + hotspots for changed files.
|
|
705
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
706
|
+
since: git ref to diff against (e.g. HEAD~3, main, origin/main).
|
|
707
|
+
If omitted, diffs against uncommitted changes or HEAD~1 fallback.
|
|
708
|
+
"""
|
|
709
|
+
|
|
710
|
+
_FIX_BUG_DOC = """\
|
|
711
|
+
Risk-ranked files for bug investigation, optionally focused by symptom.
|
|
712
|
+
|
|
713
|
+
Maps to: sourcecode prepare-context fix-bug <repo_path> [--symptom <symptom>]
|
|
714
|
+
Includes compact_base: security_surface, transactional_boundaries, spring_profiles.
|
|
715
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
716
|
+
symptom: optional error message or class name to focus the file ranking
|
|
717
|
+
(e.g. "NullPointerException in UserService.findById").
|
|
718
|
+
Without symptom, ranking is generic (by churn/complexity). With symptom,
|
|
719
|
+
the matching class and its callers are ranked first.
|
|
720
|
+
"""
|
|
721
|
+
|
|
722
|
+
_ONBOARD_DOC = """\
|
|
723
|
+
Onboarding context: structured overview for new contributors.
|
|
724
|
+
|
|
725
|
+
Maps to: sourcecode prepare-context onboard <repo_path>
|
|
726
|
+
Returns: project structure, key entry points, architectural patterns, getting-started guide.
|
|
727
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
728
|
+
"""
|
|
729
|
+
|
|
730
|
+
_EXPLAIN_DOC = """\
|
|
731
|
+
Architecture and entry-point explanation for a repository.
|
|
732
|
+
|
|
733
|
+
Maps to: sourcecode prepare-context explain <repo_path>
|
|
734
|
+
Returns: project summary, architecture overview, entry points, key dependencies.
|
|
735
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
736
|
+
"""
|
|
737
|
+
|
|
738
|
+
_REFACTOR_DOC = """\
|
|
739
|
+
Structural issues and refactor opportunities for a repository.
|
|
740
|
+
|
|
741
|
+
Maps to: sourcecode prepare-context refactor <repo_path>
|
|
742
|
+
Returns: structural issues, coupling hotspots, high-churn files, improvement opportunities.
|
|
743
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
744
|
+
"""
|
|
745
|
+
|
|
746
|
+
_GENERATE_TESTS_DOC = """\
|
|
747
|
+
Untested source files and test gap analysis for a repository.
|
|
748
|
+
|
|
749
|
+
Maps to: sourcecode prepare-context generate-tests <repo_path> [--all]
|
|
750
|
+
Returns: test_gaps list of untested files ranked by risk.
|
|
751
|
+
On large repos (>2000 classes) analysis is bounded by SOURCECODE_TESTS_TIMEOUT_MS
|
|
752
|
+
(default: 15000 ms). If timeout elapses, returns truncated=true with partial results.
|
|
753
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
754
|
+
include_all: return full test_gaps list without truncating to top 20.
|
|
755
|
+
"""
|
|
756
|
+
|
|
757
|
+
_IR_SUMMARY_DOC = """\
|
|
758
|
+
Deterministic symbol-level IR summary for Java repositories. Java only.
|
|
759
|
+
|
|
760
|
+
Maps to: sourcecode repo-ir <repo_path> --summary-only
|
|
761
|
+
Returns: reverse_graph (top 10 hubs), route_surface (top 50 endpoints),
|
|
762
|
+
subsystems (top 15), impact, analysis. Full graph nodes/edges omitted.
|
|
763
|
+
|
|
764
|
+
Output is bounded to ~100 KB for LLM safety. For full IR (can exceed 10 MB
|
|
765
|
+
on large repos), use the CLI: sourcecode repo-ir <path> --output ir.json
|
|
766
|
+
Use get_compact_context or get_agent_context for non-Java repos.
|
|
767
|
+
|
|
768
|
+
repo_path: absolute path to the Java repository (default: current working directory).
|
|
769
|
+
"""
|
|
770
|
+
|
|
771
|
+
_IMPACT_CONTEXT_DOC = """\
|
|
772
|
+
Blast-radius analysis: who calls a class and what breaks if it changes? Java only.
|
|
773
|
+
|
|
774
|
+
Maps to: sourcecode impact <target> <repo_path> [--depth <depth>]
|
|
775
|
+
Returns: direct_callers, indirect_callers, endpoints_affected,
|
|
776
|
+
transactional_boundaries_touched, risk_score, risk_level, stats.
|
|
777
|
+
|
|
778
|
+
Use this when:
|
|
779
|
+
- Planning a refactor: understand the full call chain before changing a class
|
|
780
|
+
- PR review: assess blast radius of a changed service or utility class
|
|
781
|
+
- Incident triage: find all paths that reach a faulty component
|
|
782
|
+
|
|
783
|
+
target: class name (simple or FQN) or Java file path. Examples:
|
|
784
|
+
"UserService", "org.example.UserService", "UserService.java"
|
|
785
|
+
repo_path: absolute path to the Java repository (default: current working directory).
|
|
786
|
+
depth: BFS depth for indirect caller traversal (1–8, default: 4).
|
|
787
|
+
"""
|
|
788
|
+
|
|
789
|
+
_MODERNIZE_DOC = """\
|
|
790
|
+
Analyzes codebase for modernization opportunities: dead zones, hotspot scores, upgrade candidates.
|
|
791
|
+
|
|
792
|
+
Maps to: sourcecode modernize <repo_path>
|
|
793
|
+
Returns: hotspot_candidates (high fan-in + git churn), dead_zone_candidates (isolated classes),
|
|
794
|
+
high_coupling_nodes, subsystem_summary, cross_module_tangles, recommendation.
|
|
795
|
+
|
|
796
|
+
Best for: refactor planning, identifying where to start, finding safe removal candidates.
|
|
797
|
+
Use get_compact_context or get_agent_context first for project orientation.
|
|
798
|
+
|
|
799
|
+
repo_path: absolute path to the Java repository (default: current working directory).
|
|
800
|
+
"""
|
|
801
|
+
|
|
802
|
+
_CHECK_FRESHNESS_DOC = """\
|
|
803
|
+
Report RIS freshness relative to the current git HEAD.
|
|
804
|
+
|
|
805
|
+
Answers instantly: is the cached snapshot current? How many commits behind?
|
|
806
|
+
Use before deciding whether to call get_compact_context for a refresh.
|
|
807
|
+
|
|
808
|
+
Returns:
|
|
809
|
+
fresh (bool) — True when RIS HEAD == current HEAD and no uncommitted changes
|
|
810
|
+
current_git_head (str) — Current repo HEAD (short SHA)
|
|
811
|
+
ris_git_head (str|null) — HEAD stored in RIS at last build
|
|
812
|
+
delta_commits (int|null) — Commits between ris_git_head and HEAD (0 = in sync)
|
|
813
|
+
has_uncommitted_changes — Working tree has staged or unstaged changes
|
|
814
|
+
ris_exists (bool) — False when no RIS built yet
|
|
815
|
+
ris_last_updated_at (str)— ISO-8601 timestamp of last RIS write
|
|
816
|
+
|
|
817
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
818
|
+
"""
|
|
819
|
+
|
|
820
|
+
_COLD_START_DOC = """\
|
|
821
|
+
Instant session bootstrap from persisted Repository Intelligence Snapshot (RIS).
|
|
822
|
+
|
|
823
|
+
PREFER start_session over this tool — it provides orchestration guidance on top
|
|
824
|
+
of the same RIS data. Use get_cold_start_context when you only need the raw
|
|
825
|
+
RIS bootstrap object without tool sequencing recommendations.
|
|
826
|
+
|
|
827
|
+
Returns cached structural context built from prior analysis runs — zero re-analysis cost.
|
|
828
|
+
|
|
829
|
+
status values:
|
|
830
|
+
"cold_start_ready" — RIS exists and matches the current git HEAD.
|
|
831
|
+
"cold_start_stale" — RIS exists but HEAD has changed since last analysis.
|
|
832
|
+
Data is still useful; run get_compact_context to refresh.
|
|
833
|
+
"no_ris" — No RIS yet for this repo; run get_compact_context first.
|
|
834
|
+
|
|
835
|
+
Returns: status, repo_id, git_head, stale (bool), last_updated_at,
|
|
836
|
+
summary (compact snapshot), entrypoints, endpoints, hotspots.
|
|
837
|
+
|
|
838
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
839
|
+
"""
|
|
840
|
+
|
|
841
|
+
_GET_ENDPOINTS_DOC = """\
|
|
842
|
+
REST API endpoint surface extraction from Java source files. JAVA ONLY.
|
|
843
|
+
|
|
844
|
+
Do NOT call this on non-Java repositories — it will return empty results.
|
|
845
|
+
Use get_compact_context or get_agent_context for non-Java repos.
|
|
846
|
+
|
|
847
|
+
Maps to: sourcecode endpoints <repo_path>
|
|
848
|
+
Returns: endpoints list with method, path, controller, handler fields;
|
|
849
|
+
security dict always present (policy: roles_allowed|permit_all|deny_all|
|
|
850
|
+
authenticated|...|none_detected); none_detected = no auth annotation found.
|
|
851
|
+
total (int), no_security_signal (int), and security_model (str) fields.
|
|
852
|
+
no_security_signal counts endpoints where security.policy == "none_detected".
|
|
853
|
+
security_model values: "filter_based" (centralized Spring Security config —
|
|
854
|
+
high no_security_signal is expected and does NOT mean endpoints are unprotected),
|
|
855
|
+
"annotation_based" (per-endpoint annotations only), "mixed" (both),
|
|
856
|
+
"unknown" (no security signals detected).
|
|
857
|
+
Supports Spring MVC (@GetMapping etc.) and JAX-RS (@GET/@POST etc.).
|
|
858
|
+
repo_path: absolute path to the Java repository (default: current working directory).
|
|
859
|
+
"""
|
|
860
|
+
|
|
861
|
+
_CACHE_STATUS_DOC = """\
|
|
862
|
+
Report cache metadata for a repository.
|
|
863
|
+
|
|
864
|
+
Maps to: sourcecode cache status <repo_path> --json
|
|
865
|
+
Returns: cache entries with git_head, timestamps, size info.
|
|
866
|
+
Use check_freshness for RIS-specific freshness checking (faster, richer).
|
|
867
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
868
|
+
"""
|
|
869
|
+
|
|
870
|
+
_CACHE_WARM_DOC = """\
|
|
871
|
+
Warm the cache for a repository (builds compact and agent analysis snapshots).
|
|
872
|
+
|
|
873
|
+
Maps to: sourcecode cache warm <repo_path>
|
|
874
|
+
Builds or refreshes the Repository Intelligence Snapshot (RIS).
|
|
875
|
+
Use before analytical workflows to ensure fast subsequent tool calls (~8s first run,
|
|
876
|
+
instant after).
|
|
877
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
878
|
+
"""
|
|
879
|
+
|
|
880
|
+
_CACHE_CLEAR_DOC = """\
|
|
881
|
+
Clear cached analysis for a repository.
|
|
882
|
+
|
|
883
|
+
Maps to: sourcecode cache clear <repo_path> [--include-ris]
|
|
884
|
+
Removes cached context files. After clearing, run get_compact_context or cache_warm to rebuild.
|
|
885
|
+
include_ris: also remove the RIS snapshot in addition to analysis cache (default: False).
|
|
886
|
+
repo_path: absolute path to the repository (default: current working directory).
|
|
887
|
+
"""
|
|
888
|
+
|
|
624
889
|
return [
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
890
|
+
# --- get_delta / review_pr_context: both genuinely use --since ---
|
|
891
|
+
_since_task_alias(
|
|
892
|
+
"get_delta", "delta",
|
|
893
|
+
"Incremental context: git-changed files since a reference commit.",
|
|
894
|
+
supported_targets=("repo_path", "git_ref"),
|
|
895
|
+
docstring_override=_GET_DELTA_DOC,
|
|
896
|
+
),
|
|
897
|
+
_since_task_alias(
|
|
898
|
+
"review_pr_context", "review-pr",
|
|
899
|
+
"Execution paths and risk analysis for changed files in a pull request.",
|
|
900
|
+
supported_targets=("repo_path", "git_ref"),
|
|
901
|
+
docstring_override=_REVIEW_PR_DOC,
|
|
902
|
+
),
|
|
903
|
+
|
|
904
|
+
# --- fix_bug_context: --symptom (not --since) ---
|
|
905
|
+
_alias_spec(
|
|
906
|
+
"fix_bug_context",
|
|
907
|
+
"Risk-ranked files for bug investigation, optionally focused by symptom.",
|
|
908
|
+
("prepare-context",),
|
|
909
|
+
(
|
|
910
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
911
|
+
ToolParamSpec("symptom", "option", str, required=False, default=None,
|
|
912
|
+
option_names=("--symptom",),
|
|
913
|
+
help="Error message or class name to focus file ranking."),
|
|
914
|
+
),
|
|
915
|
+
lambda inputs: (
|
|
916
|
+
["prepare-context", "fix-bug", str(inputs.get("repo_path", "."))]
|
|
917
|
+
+ (["--symptom", str(inputs["symptom"])] if inputs.get("symptom") else [])
|
|
918
|
+
),
|
|
919
|
+
supported_targets=("repo_path", "symptom"),
|
|
920
|
+
unsupported_targets=("file_path",),
|
|
921
|
+
validator=validate_repo_path,
|
|
922
|
+
docstring_override=_FIX_BUG_DOC,
|
|
923
|
+
),
|
|
924
|
+
|
|
925
|
+
# --- onboard / explain / refactor: no --since ---
|
|
926
|
+
_alias_spec(
|
|
927
|
+
"onboard_context",
|
|
928
|
+
"Onboarding context: structured overview for new contributors.",
|
|
929
|
+
("prepare-context",),
|
|
930
|
+
(
|
|
931
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
932
|
+
),
|
|
933
|
+
lambda inputs: ["prepare-context", "onboard", str(inputs.get("repo_path", "."))],
|
|
934
|
+
supported_targets=("repo_path",),
|
|
935
|
+
unsupported_targets=("file_path",),
|
|
936
|
+
validator=validate_repo_path,
|
|
937
|
+
docstring_override=_ONBOARD_DOC,
|
|
938
|
+
),
|
|
939
|
+
_alias_spec(
|
|
940
|
+
"explain_context",
|
|
941
|
+
"Architecture and entry-point explanation for a repository.",
|
|
942
|
+
("prepare-context",),
|
|
943
|
+
(
|
|
944
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
945
|
+
),
|
|
946
|
+
lambda inputs: ["prepare-context", "explain", str(inputs.get("repo_path", "."))],
|
|
947
|
+
supported_targets=("repo_path",),
|
|
948
|
+
unsupported_targets=("file_path",),
|
|
949
|
+
validator=validate_repo_path,
|
|
950
|
+
docstring_override=_EXPLAIN_DOC,
|
|
951
|
+
),
|
|
952
|
+
_alias_spec(
|
|
953
|
+
"refactor_context",
|
|
954
|
+
"Structural issues and refactor opportunities for a repository.",
|
|
955
|
+
("prepare-context",),
|
|
956
|
+
(
|
|
957
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
958
|
+
),
|
|
959
|
+
lambda inputs: ["prepare-context", "refactor", str(inputs.get("repo_path", "."))],
|
|
960
|
+
supported_targets=("repo_path",),
|
|
961
|
+
unsupported_targets=("file_path",),
|
|
962
|
+
validator=validate_repo_path,
|
|
963
|
+
docstring_override=_REFACTOR_DOC,
|
|
964
|
+
),
|
|
965
|
+
|
|
966
|
+
# --- other prepare-context aliases ---
|
|
631
967
|
_alias_spec(
|
|
632
968
|
"generate_tests_context",
|
|
633
|
-
"
|
|
969
|
+
"Untested source files and test gap analysis for a repository.",
|
|
634
970
|
("prepare-context",),
|
|
635
971
|
(
|
|
636
972
|
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
637
|
-
ToolParamSpec("include_all", "
|
|
973
|
+
ToolParamSpec("include_all", "option", bool, required=False, default=False,
|
|
974
|
+
option_names=("--all",), is_flag=True),
|
|
975
|
+
),
|
|
976
|
+
lambda inputs: (
|
|
977
|
+
["prepare-context", "generate-tests", str(inputs.get("repo_path", "."))]
|
|
978
|
+
+ (["--all"] if bool(inputs.get("include_all")) else [])
|
|
638
979
|
),
|
|
639
|
-
lambda inputs: ["prepare-context", "generate-tests", str(inputs.get("repo_path", "."))] + (["--all"] if bool(inputs.get("include_all")) else []),
|
|
640
980
|
supported_targets=("repo_path",),
|
|
641
981
|
unsupported_targets=("file_path",),
|
|
642
982
|
validator=validate_repo_path,
|
|
983
|
+
docstring_override=_GENERATE_TESTS_DOC,
|
|
643
984
|
),
|
|
985
|
+
|
|
986
|
+
# --- Java analysis aliases ---
|
|
644
987
|
_alias_spec(
|
|
645
988
|
"get_ir_summary",
|
|
646
|
-
"
|
|
989
|
+
"Deterministic symbol-level IR summary for Java repositories. Java only.",
|
|
647
990
|
("repo-ir",),
|
|
648
991
|
(
|
|
649
992
|
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
@@ -652,10 +995,11 @@ def _prepare_context_aliases() -> list[ToolSpec]:
|
|
|
652
995
|
supported_targets=("repo_path",),
|
|
653
996
|
unsupported_targets=("file_path",),
|
|
654
997
|
validator=validate_repo_path,
|
|
998
|
+
docstring_override=_IR_SUMMARY_DOC,
|
|
655
999
|
),
|
|
656
1000
|
_alias_spec(
|
|
657
1001
|
"get_impact_context",
|
|
658
|
-
"Blast-radius analysis
|
|
1002
|
+
"Blast-radius analysis: who calls a class and what breaks if it changes? Java only.",
|
|
659
1003
|
("impact",),
|
|
660
1004
|
(
|
|
661
1005
|
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
@@ -672,10 +1016,11 @@ def _prepare_context_aliases() -> list[ToolSpec]:
|
|
|
672
1016
|
supported_targets=("repo_path", "class_name"),
|
|
673
1017
|
unsupported_targets=("file_path",),
|
|
674
1018
|
validator=validate_repo_path,
|
|
1019
|
+
docstring_override=_IMPACT_CONTEXT_DOC,
|
|
675
1020
|
),
|
|
676
1021
|
_alias_spec(
|
|
677
1022
|
"modernize_context",
|
|
678
|
-
"Modernization analysis
|
|
1023
|
+
"Modernization analysis: dead zones, hotspot scores, upgrade candidates.",
|
|
679
1024
|
("modernize",),
|
|
680
1025
|
(
|
|
681
1026
|
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
@@ -684,10 +1029,13 @@ def _prepare_context_aliases() -> list[ToolSpec]:
|
|
|
684
1029
|
supported_targets=("repo_path",),
|
|
685
1030
|
unsupported_targets=("file_path",),
|
|
686
1031
|
validator=validate_repo_path,
|
|
1032
|
+
docstring_override=_MODERNIZE_DOC,
|
|
687
1033
|
),
|
|
1034
|
+
|
|
1035
|
+
# --- cache / freshness aliases ---
|
|
688
1036
|
_alias_spec(
|
|
689
1037
|
"check_freshness",
|
|
690
|
-
"
|
|
1038
|
+
"Report RIS freshness relative to the current git HEAD.",
|
|
691
1039
|
("cache", "freshness"),
|
|
692
1040
|
(
|
|
693
1041
|
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
@@ -696,10 +1044,11 @@ def _prepare_context_aliases() -> list[ToolSpec]:
|
|
|
696
1044
|
supported_targets=("repo_path",),
|
|
697
1045
|
unsupported_targets=("file_path",),
|
|
698
1046
|
validator=validate_repo_path,
|
|
1047
|
+
docstring_override=_CHECK_FRESHNESS_DOC,
|
|
699
1048
|
),
|
|
700
1049
|
_alias_spec(
|
|
701
1050
|
"get_cold_start_context",
|
|
702
|
-
"
|
|
1051
|
+
"Instant session bootstrap from persisted Repository Intelligence Snapshot (RIS).",
|
|
703
1052
|
("cold-start",),
|
|
704
1053
|
(
|
|
705
1054
|
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
@@ -708,6 +1057,69 @@ def _prepare_context_aliases() -> list[ToolSpec]:
|
|
|
708
1057
|
supported_targets=("repo_path",),
|
|
709
1058
|
unsupported_targets=("file_path",),
|
|
710
1059
|
validator=validate_repo_path,
|
|
1060
|
+
docstring_override=_COLD_START_DOC,
|
|
1061
|
+
),
|
|
1062
|
+
|
|
1063
|
+
# --- get_endpoints: clean alias replacing raw canonical with 7 CLI params ---
|
|
1064
|
+
_alias_spec(
|
|
1065
|
+
"get_endpoints",
|
|
1066
|
+
"REST API endpoint surface extraction from Java source files. JAVA ONLY.",
|
|
1067
|
+
("endpoints",),
|
|
1068
|
+
(
|
|
1069
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
1070
|
+
),
|
|
1071
|
+
lambda inputs: ["endpoints", str(inputs.get("repo_path", "."))],
|
|
1072
|
+
supported_targets=("repo_path",),
|
|
1073
|
+
unsupported_targets=("file_path",),
|
|
1074
|
+
validator=validate_repo_path,
|
|
1075
|
+
docstring_override=_GET_ENDPOINTS_DOC,
|
|
1076
|
+
),
|
|
1077
|
+
|
|
1078
|
+
# --- cache management: curated aliases stripping CLI noise params ---
|
|
1079
|
+
_alias_spec(
|
|
1080
|
+
"cache_status",
|
|
1081
|
+
"Report cache metadata for a repository.",
|
|
1082
|
+
("cache", "status"),
|
|
1083
|
+
(
|
|
1084
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
1085
|
+
),
|
|
1086
|
+
lambda inputs: ["cache", "status", str(inputs.get("repo_path", ".")), "--json"],
|
|
1087
|
+
supported_targets=("repo_path",),
|
|
1088
|
+
unsupported_targets=("file_path",),
|
|
1089
|
+
validator=validate_repo_path,
|
|
1090
|
+
docstring_override=_CACHE_STATUS_DOC,
|
|
1091
|
+
),
|
|
1092
|
+
_alias_spec(
|
|
1093
|
+
"cache_warm",
|
|
1094
|
+
"Warm the cache for a repository (builds compact and agent analysis snapshots).",
|
|
1095
|
+
("cache", "warm"),
|
|
1096
|
+
(
|
|
1097
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
1098
|
+
),
|
|
1099
|
+
lambda inputs: ["cache", "warm", str(inputs.get("repo_path", "."))],
|
|
1100
|
+
supported_targets=("repo_path",),
|
|
1101
|
+
unsupported_targets=("file_path",),
|
|
1102
|
+
validator=validate_repo_path,
|
|
1103
|
+
docstring_override=_CACHE_WARM_DOC,
|
|
1104
|
+
),
|
|
1105
|
+
_alias_spec(
|
|
1106
|
+
"cache_clear",
|
|
1107
|
+
"Clear cached analysis for a repository.",
|
|
1108
|
+
("cache", "clear"),
|
|
1109
|
+
(
|
|
1110
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True),
|
|
1111
|
+
ToolParamSpec("include_ris", "option", bool, required=False, default=False,
|
|
1112
|
+
option_names=("--include-ris",), is_flag=True,
|
|
1113
|
+
help="Also remove RIS snapshot (default: False)."),
|
|
1114
|
+
),
|
|
1115
|
+
lambda inputs: (
|
|
1116
|
+
["cache", "clear", str(inputs.get("repo_path", ".")), "--yes"]
|
|
1117
|
+
+ (["--include-ris"] if bool(inputs.get("include_ris")) else [])
|
|
1118
|
+
),
|
|
1119
|
+
supported_targets=("repo_path",),
|
|
1120
|
+
unsupported_targets=("file_path",),
|
|
1121
|
+
validator=validate_repo_path,
|
|
1122
|
+
docstring_override=_CACHE_CLEAR_DOC,
|
|
711
1123
|
),
|
|
712
1124
|
]
|
|
713
1125
|
|
|
@@ -788,17 +1200,174 @@ def _internal_specs() -> list[ToolSpec]:
|
|
|
788
1200
|
]
|
|
789
1201
|
|
|
790
1202
|
|
|
1203
|
+
# Canonical CLI tools that are MCP-noise: raw passthroughs, meta-commands, and duplicates
|
|
1204
|
+
# superseded by cleaner alias variants. Still tracked by validate_registry(); just not served.
|
|
1205
|
+
_MCP_HIDDEN_CANONICAL_TOOLS: frozenset[str] = frozenset({
|
|
1206
|
+
# Raw CLI passthroughs (clean alias exists)
|
|
1207
|
+
"sourcecode_root", # 40+ flags, no agent guidance; use get_compact_context / get_agent_context
|
|
1208
|
+
"prepare_context", # requires knowing subtask string; use task-specific aliases
|
|
1209
|
+
"repo_ir", # raw IR dump; use get_ir_summary
|
|
1210
|
+
"fix_bug", # raw Pro command; use fix_bug_context for MCP
|
|
1211
|
+
"review_pr", # raw Pro command; use review_pr_context for MCP
|
|
1212
|
+
"onboard", # raw with llm_prompt/copy flags; use onboard_context
|
|
1213
|
+
# Duplicates (inferior params — cleaner alias exists)
|
|
1214
|
+
"impact", # path/target order reversed vs get_impact_context; use get_impact_context
|
|
1215
|
+
"cold_start", # duplicate of get_cold_start_context
|
|
1216
|
+
"cache_freshness", # duplicate of check_freshness
|
|
1217
|
+
"modernize", # duplicate of modernize_context
|
|
1218
|
+
# Raw CLI tools with output-format/noise params — clean alias with only repo_path exists
|
|
1219
|
+
"endpoints", # 7 CLI params (output_path/format/copy/etc.); use get_endpoints
|
|
1220
|
+
"cache_status", # path + json_output flag; curated alias strips json_output, renames path→repo_path
|
|
1221
|
+
"cache_warm", # path + compact/agent output flags; curated alias keeps only repo_path
|
|
1222
|
+
"cache_clear", # path + yes/all_ destructive flags; curated alias keeps repo_path + include_ris only
|
|
1223
|
+
# Curated overrides — canonical CLI spec replaced by cleaner alias with same name.
|
|
1224
|
+
# Listed here so validate_registry() skips CLI param-drift checks on the alias.
|
|
1225
|
+
"spring_audit", # curated: repo_path + scope + min_severity only (strips output_path/format/copy)
|
|
1226
|
+
"impact_chain", # curated: repo_path + symbol + depth + query_type with choices
|
|
1227
|
+
# MCP self-management (an agent is not the MCP client admin)
|
|
1228
|
+
"mcp_init",
|
|
1229
|
+
"mcp_serve",
|
|
1230
|
+
"mcp_status",
|
|
1231
|
+
"mcp_remove",
|
|
1232
|
+
"mcp_list_tools",
|
|
1233
|
+
# Telemetry sub-commands (consolidated into telemetry(action=))
|
|
1234
|
+
"telemetry_status",
|
|
1235
|
+
"telemetry_enable",
|
|
1236
|
+
"telemetry_disable",
|
|
1237
|
+
})
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
def _java_spring_aliases() -> list[ToolSpec]:
|
|
1241
|
+
"""Curated MCP overrides for Java/Spring tools.
|
|
1242
|
+
|
|
1243
|
+
These replace the auto-generated canonical specs with cleaner param surfaces:
|
|
1244
|
+
- repo_path (not raw `path`) for consistency with all other MCP tools
|
|
1245
|
+
- MCP-irrelevant CLI flags (output_path, format, copy) stripped
|
|
1246
|
+
- query_type choices documented so agents discover event topology
|
|
1247
|
+
- Rich docstrings instead of contract-format stubs
|
|
1248
|
+
"""
|
|
1249
|
+
validate_repo_path = _repo_path_validator()
|
|
1250
|
+
|
|
1251
|
+
_SPRING_AUDIT_DOC = """\
|
|
1252
|
+
Spring semantic audit: TX anomalies + security surface. JAVA/SPRING ONLY.
|
|
1253
|
+
|
|
1254
|
+
Do NOT call on non-Java repositories — returns spring_detected=false with no findings.
|
|
1255
|
+
|
|
1256
|
+
Patterns detected:
|
|
1257
|
+
TX-001: @Transactional missing rollbackFor for checked exceptions
|
|
1258
|
+
TX-002: propagation=NEVER/NOT_SUPPORTED inside @Transactional scope
|
|
1259
|
+
TX-003: readOnly=true method calling write operations
|
|
1260
|
+
TX-004: REQUIRES_NEW nested inside REQUIRED (TX isolation breach risk)
|
|
1261
|
+
TX-005: @Async method called within @Transactional context (TX context lost)
|
|
1262
|
+
SEC-001: public endpoint with no security annotation (none_detected policy)
|
|
1263
|
+
SEC-002: security annotation on non-endpoint method (misplaced)
|
|
1264
|
+
SEC-003: missing auth on admin-pattern operations
|
|
1265
|
+
|
|
1266
|
+
Returns: schema_version, spring_detected, scope, summary, findings[], limitations, metadata.
|
|
1267
|
+
findings fields: id, pattern_id, category, severity, confidence, title, symbol,
|
|
1268
|
+
source_file, evidence, explanation, fix_hint.
|
|
1269
|
+
|
|
1270
|
+
repo_path: absolute path to the Java repository (default: current working directory).
|
|
1271
|
+
scope: "all" (default) | "tx" (TX-001..005 only) | "security" (SEC-001..003 only)
|
|
1272
|
+
min_severity: "low" (default) | "medium" | "high" | "critical"
|
|
1273
|
+
"""
|
|
1274
|
+
|
|
1275
|
+
_IMPACT_CHAIN_DOC = """\
|
|
1276
|
+
Spring impact-chain: blast radius of a symbol with TX/SEC semantic enrichment. JAVA/SPRING ONLY.
|
|
1277
|
+
|
|
1278
|
+
Do NOT call on non-Java repositories — returns resolution=not_found.
|
|
1279
|
+
|
|
1280
|
+
Two query modes via query_type:
|
|
1281
|
+
"impact" (default) — BFS call graph: direct_callers, indirect_callers, endpoints_affected,
|
|
1282
|
+
transaction_boundary, security_surfaces, impact_findings (TX/SEC patterns in call chain).
|
|
1283
|
+
"events" — event topology: publishers, consumers, propagation graph for an event class
|
|
1284
|
+
or event publisher. Use when symbol is an event class (e.g. OrderPlacedEvent).
|
|
1285
|
+
|
|
1286
|
+
Returns: schema_version, symbol, resolution, direct_callers, indirect_callers,
|
|
1287
|
+
endpoints_affected, transaction_boundary, security_surfaces, impact_findings,
|
|
1288
|
+
analysis_warnings, risk_level, confidence, metadata.
|
|
1289
|
+
|
|
1290
|
+
symbol: FQN, class name, or Class#method.
|
|
1291
|
+
Examples: "OrderService", "com.example.OrderService#placeOrder",
|
|
1292
|
+
"OrderPlacedEvent" (with query_type="events" for event topology)
|
|
1293
|
+
repo_path: absolute path to the Java repository (default: current working directory).
|
|
1294
|
+
depth: BFS traversal depth 1–8 (default 4).
|
|
1295
|
+
query_type: "impact" (default) | "events"
|
|
1296
|
+
"""
|
|
1297
|
+
|
|
1298
|
+
spring_audit = _alias_spec(
|
|
1299
|
+
"spring_audit",
|
|
1300
|
+
"Spring semantic audit: TX anomalies + security surface. JAVA/SPRING ONLY.",
|
|
1301
|
+
("spring-audit",),
|
|
1302
|
+
(
|
|
1303
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True,
|
|
1304
|
+
help="Absolute path to the Java repository."),
|
|
1305
|
+
ToolParamSpec("scope", "option", str, required=False, default="all",
|
|
1306
|
+
option_names=("--scope",), choices=("all", "tx", "security"),
|
|
1307
|
+
help="all (default) | tx | security"),
|
|
1308
|
+
ToolParamSpec("min_severity", "option", str, required=False, default="low",
|
|
1309
|
+
option_names=("--min-severity",), choices=("low", "medium", "high", "critical"),
|
|
1310
|
+
help="low (default) | medium | high | critical"),
|
|
1311
|
+
),
|
|
1312
|
+
lambda inputs: [
|
|
1313
|
+
"spring-audit",
|
|
1314
|
+
str(inputs.get("repo_path", ".")),
|
|
1315
|
+
"--scope", str(inputs.get("scope", "all")),
|
|
1316
|
+
"--min-severity", str(inputs.get("min_severity", "low")),
|
|
1317
|
+
],
|
|
1318
|
+
supported_targets=("repo_path",),
|
|
1319
|
+
unsupported_targets=("file_path",),
|
|
1320
|
+
validator=validate_repo_path,
|
|
1321
|
+
docstring_override=_SPRING_AUDIT_DOC,
|
|
1322
|
+
)
|
|
1323
|
+
|
|
1324
|
+
impact_chain = _alias_spec(
|
|
1325
|
+
"impact_chain",
|
|
1326
|
+
"Spring impact-chain: blast radius + TX/SEC enrichment. JAVA/SPRING ONLY.",
|
|
1327
|
+
("impact-chain",),
|
|
1328
|
+
(
|
|
1329
|
+
ToolParamSpec("symbol", "argument", str, required=True, default=None,
|
|
1330
|
+
help="FQN, class name, or Class#method."),
|
|
1331
|
+
ToolParamSpec("repo_path", "argument", str, required=False, default=".", is_path=True,
|
|
1332
|
+
help="Absolute path to the Java repository."),
|
|
1333
|
+
ToolParamSpec("depth", "option", int, required=False, default=4,
|
|
1334
|
+
option_names=("--depth",), help="BFS depth 1–8 (default 4)."),
|
|
1335
|
+
ToolParamSpec("query_type", "option", str, required=False, default="impact",
|
|
1336
|
+
option_names=("--type",), choices=("impact", "events"),
|
|
1337
|
+
help="impact (default) = call-chain blast radius; events = event topology"),
|
|
1338
|
+
),
|
|
1339
|
+
lambda inputs: [
|
|
1340
|
+
"impact-chain",
|
|
1341
|
+
str(inputs["symbol"]),
|
|
1342
|
+
str(inputs.get("repo_path", ".")),
|
|
1343
|
+
"--depth", str(inputs.get("depth", 4)),
|
|
1344
|
+
"--type", str(inputs.get("query_type", "impact")),
|
|
1345
|
+
],
|
|
1346
|
+
supported_targets=("repo_path", "class_name"),
|
|
1347
|
+
unsupported_targets=("file_path",),
|
|
1348
|
+
validator=validate_repo_path,
|
|
1349
|
+
docstring_override=_IMPACT_CHAIN_DOC,
|
|
1350
|
+
)
|
|
1351
|
+
|
|
1352
|
+
return [spring_audit, impact_chain]
|
|
1353
|
+
|
|
1354
|
+
|
|
791
1355
|
@lru_cache(maxsize=1)
|
|
792
1356
|
def build_tool_specs() -> tuple[ToolSpec, ...]:
|
|
793
1357
|
"""Build the full MCP registry from the live CLI runtime."""
|
|
794
|
-
|
|
1358
|
+
canonical_raw = [
|
|
795
1359
|
_canonical_spec_for_runtime_command(runtime)
|
|
796
1360
|
for runtime in discover_runtime_commands()
|
|
797
1361
|
if (runtime.callback is not None or runtime.path == ())
|
|
798
1362
|
and (not runtime.hidden or runtime.path == ("analyze",))
|
|
799
1363
|
]
|
|
1364
|
+
# Mark canonical tools that should not be served via MCP (validate_registry still checks them)
|
|
1365
|
+
canonical = [
|
|
1366
|
+
replace(spec, mcp_hidden=True) if spec.name in _MCP_HIDDEN_CANONICAL_TOOLS else spec
|
|
1367
|
+
for spec in canonical_raw
|
|
1368
|
+
]
|
|
800
1369
|
|
|
801
|
-
aliases = _root_aliases() + _prepare_context_aliases()
|
|
1370
|
+
aliases = _root_aliases() + _prepare_context_aliases() + _java_spring_aliases()
|
|
802
1371
|
internals = _internal_specs()
|
|
803
1372
|
|
|
804
1373
|
merged: dict[str, ToolSpec] = {}
|
|
@@ -842,6 +1411,11 @@ def validate_registry() -> list[str]:
|
|
|
842
1411
|
spec = registry_by_path.get(path)
|
|
843
1412
|
if spec is None:
|
|
844
1413
|
continue
|
|
1414
|
+
# Skip docstring/param drift for mcp_hidden tools and intentional curated overrides.
|
|
1415
|
+
# Curated aliases (e.g. spring_audit, impact_chain) replace canonical CLI specs with
|
|
1416
|
+
# cleaner MCP surfaces — their params diverge from the raw CLI by design.
|
|
1417
|
+
if spec.name in _MCP_HIDDEN_CANONICAL_TOOLS or spec.mcp_hidden:
|
|
1418
|
+
continue
|
|
845
1419
|
expected_doc = _first_doc_line(runtime.docstring or runtime.help or "")
|
|
846
1420
|
if expected_doc and expected_doc not in spec.description:
|
|
847
1421
|
issues.append(f"docstring_mismatch:{spec.name}")
|
|
@@ -853,9 +1427,15 @@ def validate_registry() -> list[str]:
|
|
|
853
1427
|
return issues
|
|
854
1428
|
|
|
855
1429
|
|
|
1430
|
+
@lru_cache(maxsize=1)
|
|
1431
|
+
def build_mcp_tool_specs() -> tuple[ToolSpec, ...]:
|
|
1432
|
+
"""Tool specs actually served via MCP: public and not mcp_hidden."""
|
|
1433
|
+
return tuple(spec for spec in build_tool_specs() if spec.mcp_visible)
|
|
1434
|
+
|
|
1435
|
+
|
|
856
1436
|
def mcp_tool_specs() -> tuple[ToolSpec, ...]:
|
|
857
|
-
"""
|
|
858
|
-
return
|
|
1437
|
+
"""Tool specs served via MCP (public, not mcp_hidden)."""
|
|
1438
|
+
return build_mcp_tool_specs()
|
|
859
1439
|
|
|
860
1440
|
|
|
861
1441
|
def mcp_internal_tool_specs() -> tuple[ToolSpec, ...]:
|
sourcecode/mcp/server.py
CHANGED
|
@@ -1179,17 +1179,36 @@ def telemetry(action: str) -> dict:
|
|
|
1179
1179
|
return _execute(["telemetry", action])
|
|
1180
1180
|
|
|
1181
1181
|
|
|
1182
|
+
_NATIVE_MCP_TOOLS: frozenset[str] = frozenset({
|
|
1183
|
+
"start_session",
|
|
1184
|
+
"analyze_task",
|
|
1185
|
+
"run_pr_review_flow",
|
|
1186
|
+
"run_bug_investigation_flow",
|
|
1187
|
+
"run_feature_flow",
|
|
1188
|
+
})
|
|
1189
|
+
|
|
1190
|
+
|
|
1182
1191
|
def _finalize_mcp_registry() -> None:
|
|
1183
|
-
"""
|
|
1184
|
-
|
|
1192
|
+
"""Sync the MCP server with the runtime-generated registry.
|
|
1193
|
+
|
|
1194
|
+
Removes every tool except the 5 native orchestration tools (start_session,
|
|
1195
|
+
analyze_task, flow runners) which are registered via @mcp.tool() in this
|
|
1196
|
+
module and have no backing CLI command. All other tools are rebuilt from the
|
|
1197
|
+
runtime-derived registry (build_mcp_tool_specs).
|
|
1198
|
+
"""
|
|
1199
|
+
from sourcecode.mcp.registry import build_mcp_tool_specs, make_tool_callable, validate_registry
|
|
1200
|
+
|
|
1201
|
+
mcp_specs = build_mcp_tool_specs()
|
|
1185
1202
|
|
|
1203
|
+
# Remove everything except the native orchestration tools
|
|
1186
1204
|
try:
|
|
1187
1205
|
for tool in list(mcp._tool_manager.list_tools()): # type: ignore[attr-defined]
|
|
1188
|
-
|
|
1206
|
+
if tool.name not in _NATIVE_MCP_TOOLS:
|
|
1207
|
+
mcp.remove_tool(tool.name)
|
|
1189
1208
|
except Exception:
|
|
1190
1209
|
pass
|
|
1191
1210
|
|
|
1192
|
-
for spec in
|
|
1211
|
+
for spec in mcp_specs:
|
|
1193
1212
|
tool_fn = make_tool_callable(spec)
|
|
1194
1213
|
tool_fn.__doc__ = spec.docstring
|
|
1195
1214
|
globals()[spec.name] = tool_fn
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
sourcecode/__init__.py,sha256=
|
|
1
|
+
sourcecode/__init__.py,sha256=4pSX2tiJdyiu03u0G_n4-Ww2ajE_E7piY8T-20n_IDM,103
|
|
2
2
|
sourcecode/adaptive_scanner.py,sha256=XffluXKzJUXrMtjEiAOnSNPZnztdIcts17T9ouHeID0,10521
|
|
3
3
|
sourcecode/architecture_analyzer.py,sha256=qh749a7ykPtGmQI1MR9y6j8TtL_jBdVYFx9YRsLqOMw,44121
|
|
4
4
|
sourcecode/architecture_summary.py,sha256=z34_6v7cSwy98cof2UVciGho7SCrZ93tiqMmq5WNzRQ,20405
|
|
@@ -76,9 +76,9 @@ sourcecode/detectors/terraform.py,sha256=cxORPR_zVLOJpHlh4e9JnFpkQsn_UnqMMom5yG6
|
|
|
76
76
|
sourcecode/detectors/tooling.py,sha256=8CKbtxwQoABP-WyBRNmdAmHDOvAH57AR1cF4UKuWEdQ,2074
|
|
77
77
|
sourcecode/mcp/__init__.py,sha256=XU4HfRGbdid8wdUA0x_4f7uKZD1z3mv_XUY_WU_T9Mw,179
|
|
78
78
|
sourcecode/mcp/orchestrator.py,sha256=BMi1D6liJHI3DXiaC8yeBLLP0wXajpCP3-vnRGqrvnw,26850
|
|
79
|
-
sourcecode/mcp/registry.py,sha256=
|
|
79
|
+
sourcecode/mcp/registry.py,sha256=r6YBd9OZoQ4nwg2roQkt6dAAO__e8REtPn--WKLUYIY,60206
|
|
80
80
|
sourcecode/mcp/runner.py,sha256=-Dp2qPGRkfNTVen6bKh7WtzQqpcEtsrXoiuajvshlKk,2866
|
|
81
|
-
sourcecode/mcp/server.py,sha256=
|
|
81
|
+
sourcecode/mcp/server.py,sha256=lBSQCw3yFe8rZHp2GGVcfua0EJUYZmsIUbvA4GIJv9s,52210
|
|
82
82
|
sourcecode/mcp/onboarding/__init__.py,sha256=sj2PWqEBmMc4zBNkomg89WtL0M6S7A9yb7_wAuSWNP4,66
|
|
83
83
|
sourcecode/mcp/onboarding/applier.py,sha256=B9CneieWTpaDSDIyW3S5nrlRlBpvfqUcgi93-mm_ApQ,2135
|
|
84
84
|
sourcecode/mcp/onboarding/backup.py,sha256=ihqGOR8QTX8HASRSEDyfFyXr5bkXrygPHamv4p9KTmk,1452
|
|
@@ -90,8 +90,8 @@ sourcecode/telemetry/consent.py,sha256=wLMvGNJeSSyZoNkQXpoUioY6mMv4Qdvuw7S9jAEWn
|
|
|
90
90
|
sourcecode/telemetry/events.py,sha256=oEvvulfsv5GIDWG2174gSS6tNB95w38AIYiYeifGKlE,2294
|
|
91
91
|
sourcecode/telemetry/filters.py,sha256=Asa71oRl7q3Wt_FMwuufIZJFzSYdgRNKS8LHCIyFeYE,4805
|
|
92
92
|
sourcecode/telemetry/transport.py,sha256=KJeIPCPWMdmbCP3ySGs2iUlia34U6vWne2dZsUezesw,1560
|
|
93
|
-
sourcecode-1.35.
|
|
94
|
-
sourcecode-1.35.
|
|
95
|
-
sourcecode-1.35.
|
|
96
|
-
sourcecode-1.35.
|
|
97
|
-
sourcecode-1.35.
|
|
93
|
+
sourcecode-1.35.8.dist-info/METADATA,sha256=LJSPDerXZXrHOmZrrgWCeQJme4iEyM7ePFxC4t3gDh4,21263
|
|
94
|
+
sourcecode-1.35.8.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
95
|
+
sourcecode-1.35.8.dist-info/entry_points.txt,sha256=ex3F9rmbXeyDIoFQHtkEqTsKSaJow8F0LrVu8XfIktQ,57
|
|
96
|
+
sourcecode-1.35.8.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
|
|
97
|
+
sourcecode-1.35.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|