repodna-engine 1.0.1__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.
Files changed (173) hide show
  1. repodna/__init__.py +3 -0
  2. repodna/__main__.py +10 -0
  3. repodna/advisor/__init__.py +17 -0
  4. repodna/advisor/engine.py +502 -0
  5. repodna/advisor/models.py +101 -0
  6. repodna/agent/__init__.py +87 -0
  7. repodna/agent/context.py +558 -0
  8. repodna/agent/deltas.py +198 -0
  9. repodna/agent/evidence.py +134 -0
  10. repodna/agent/expansion.py +447 -0
  11. repodna/agent/localization.py +518 -0
  12. repodna/agent/models.py +695 -0
  13. repodna/agent/patch.py +378 -0
  14. repodna/agent/postflight.py +278 -0
  15. repodna/agent/preflight.py +336 -0
  16. repodna/agent/ranking.py +318 -0
  17. repodna/agent/repo_map.py +392 -0
  18. repodna/agent/safety.py +111 -0
  19. repodna/agent/service.py +574 -0
  20. repodna/agent/sessions.py +264 -0
  21. repodna/agent/task.py +660 -0
  22. repodna/agent/telemetry.py +101 -0
  23. repodna/agent/token_budget.py +231 -0
  24. repodna/api/__init__.py +1 -0
  25. repodna/api/agent_routes.py +248 -0
  26. repodna/api/app.py +2904 -0
  27. repodna/benchmarks/__init__.py +29 -0
  28. repodna/benchmarks/baselines.py +126 -0
  29. repodna/benchmarks/budget_bench.py +162 -0
  30. repodna/benchmarks/engine.py +418 -0
  31. repodna/benchmarks/evaluator.py +310 -0
  32. repodna/benchmarks/metrics.py +206 -0
  33. repodna/benchmarks/models.py +194 -0
  34. repodna/benchmarks/scalability.py +166 -0
  35. repodna/brain/__init__.py +46 -0
  36. repodna/brain/evidence.py +276 -0
  37. repodna/brain/extractor.py +1207 -0
  38. repodna/brain/indexer.py +766 -0
  39. repodna/brain/models.py +275 -0
  40. repodna/brain/multilang_extractors.py +889 -0
  41. repodna/brain/retrieval.py +469 -0
  42. repodna/brain/tracer.py +203 -0
  43. repodna/cli/__init__.py +1 -0
  44. repodna/cli/__main__.py +10 -0
  45. repodna/cli/agent_cmd.py +228 -0
  46. repodna/cli/installer.py +590 -0
  47. repodna/cli/main.py +2173 -0
  48. repodna/cli/plugin_cmd.py +130 -0
  49. repodna/cli/workspace_cmd.py +211 -0
  50. repodna/context/__init__.py +9 -0
  51. repodna/context/builder.py +379 -0
  52. repodna/context/models.py +133 -0
  53. repodna/contract/__init__.py +39 -0
  54. repodna/contract/evaluator.py +318 -0
  55. repodna/contract/loader.py +260 -0
  56. repodna/contract/models.py +185 -0
  57. repodna/core/__init__.py +1 -0
  58. repodna/core/analyzer.py +1424 -0
  59. repodna/diff/__init__.py +35 -0
  60. repodna/diff/engine.py +332 -0
  61. repodna/diff/models.py +117 -0
  62. repodna/diff/snapshot.py +248 -0
  63. repodna/ecosystem/__init__.py +27 -0
  64. repodna/ecosystem/contracts.py +129 -0
  65. repodna/ecosystem/doctor.py +253 -0
  66. repodna/git_insights/__init__.py +1 -0
  67. repodna/git_insights/analyzer.py +273 -0
  68. repodna/graph/__init__.py +1 -0
  69. repodna/graph/engine.py +562 -0
  70. repodna/guardian/__init__.py +17 -0
  71. repodna/guardian/engine.py +369 -0
  72. repodna/guardian/models.py +104 -0
  73. repodna/history/__init__.py +40 -0
  74. repodna/history/cache.py +240 -0
  75. repodna/history/diff.py +394 -0
  76. repodna/history/engine.py +557 -0
  77. repodna/history/evidence.py +160 -0
  78. repodna/history/models.py +258 -0
  79. repodna/history/timeline.py +164 -0
  80. repodna/intelligence/__init__.py +33 -0
  81. repodna/intelligence/models.py +165 -0
  82. repodna/intelligence/service.py +570 -0
  83. repodna/live/__init__.py +94 -0
  84. repodna/live/alerts.py +443 -0
  85. repodna/live/coordinator.py +351 -0
  86. repodna/live/diff.py +444 -0
  87. repodna/live/events.py +471 -0
  88. repodna/live/filtering.py +329 -0
  89. repodna/live/history.py +637 -0
  90. repodna/live/models.py +505 -0
  91. repodna/live/observer.py +653 -0
  92. repodna/live/reconciliation.py +253 -0
  93. repodna/live/session.py +1547 -0
  94. repodna/mcp/__init__.py +5 -0
  95. repodna/mcp/__main__.py +6 -0
  96. repodna/mcp/agent_tools.py +258 -0
  97. repodna/mcp/server.py +3283 -0
  98. repodna/mcp/workspace_tools.py +200 -0
  99. repodna/parsers/__init__.py +13 -0
  100. repodna/parsers/base.py +126 -0
  101. repodna/parsers/capabilities.py +361 -0
  102. repodna/parsers/project_metadata.py +232 -0
  103. repodna/parsers/resolver.py +621 -0
  104. repodna/parsers/treesitter_parser.py +830 -0
  105. repodna/passport/__init__.py +64 -0
  106. repodna/passport/generator.py +546 -0
  107. repodna/passport/migrator.py +139 -0
  108. repodna/passport/models.py +224 -0
  109. repodna/passport/validator.py +143 -0
  110. repodna/performance/__init__.py +89 -0
  111. repodna/performance/cache.py +1584 -0
  112. repodna/performance/identity.py +341 -0
  113. repodna/performance/incremental.py +317 -0
  114. repodna/performance/models.py +157 -0
  115. repodna/performance/parallel.py +291 -0
  116. repodna/plugins/__init__.py +47 -0
  117. repodna/plugins/evaluator.py +334 -0
  118. repodna/plugins/models.py +113 -0
  119. repodna/plugins/validator.py +256 -0
  120. repodna/quality/__init__.py +91 -0
  121. repodna/quality/complexity.py +352 -0
  122. repodna/quality/config.py +159 -0
  123. repodna/quality/debt.py +73 -0
  124. repodna/quality/duplicates.py +330 -0
  125. repodna/quality/engine.py +282 -0
  126. repodna/quality/impact.py +198 -0
  127. repodna/quality/models.py +427 -0
  128. repodna/quality/rules.py +364 -0
  129. repodna/quality/sarif.py +107 -0
  130. repodna/quality/security_signals.py +278 -0
  131. repodna/quality/test_mapping.py +271 -0
  132. repodna/quality/unused.py +201 -0
  133. repodna/reports/__init__.py +1 -0
  134. repodna/reports/exporter.py +374 -0
  135. repodna/rules/__init__.py +1 -0
  136. repodna/rules/health.py +436 -0
  137. repodna/schemas/__init__.py +1 -0
  138. repodna/schemas/models.py +348 -0
  139. repodna/security/__init__.py +1 -0
  140. repodna/security/safe_yaml.py +81 -0
  141. repodna/security/validators.py +583 -0
  142. repodna/skills/__init__.py +0 -0
  143. repodna/skills/repodna/SKILL.md +59 -0
  144. repodna/skills/repodna/__init__.py +0 -0
  145. repodna/skills/repodna/examples/workflows.md +85 -0
  146. repodna/skills/repodna/references/architecture-rules.md +26 -0
  147. repodna/storage/__init__.py +1 -0
  148. repodna/storage/workspace.py +199 -0
  149. repodna/webui/__init__.py +1 -0
  150. repodna/webui/assets/DependencyGraph-km_Qo-nG.js +43 -0
  151. repodna/webui/assets/HealthReportView-WVL39aNO.js +1 -0
  152. repodna/webui/assets/index-ByZ5e5pe.js +506 -0
  153. repodna/webui/assets/index-CDj3e8hw.css +1 -0
  154. repodna/webui/index.html +21 -0
  155. repodna/workspace/__init__.py +131 -0
  156. repodna/workspace/compatibility.py +317 -0
  157. repodna/workspace/context.py +175 -0
  158. repodna/workspace/contracts.py +369 -0
  159. repodna/workspace/federation.py +411 -0
  160. repodna/workspace/identity.py +202 -0
  161. repodna/workspace/impact.py +111 -0
  162. repodna/workspace/manifest.py +266 -0
  163. repodna/workspace/models.py +461 -0
  164. repodna/workspace/packages.py +494 -0
  165. repodna/workspace/policies.py +142 -0
  166. repodna/workspace/services.py +238 -0
  167. repodna/workspace/topology.py +316 -0
  168. repodna_engine-1.0.1.dist-info/METADATA +129 -0
  169. repodna_engine-1.0.1.dist-info/RECORD +173 -0
  170. repodna_engine-1.0.1.dist-info/WHEEL +5 -0
  171. repodna_engine-1.0.1.dist-info/entry_points.txt +2 -0
  172. repodna_engine-1.0.1.dist-info/licenses/LICENSE +21 -0
  173. repodna_engine-1.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,5 @@
1
+ """RepoDNA Model Context Protocol (MCP) Integration."""
2
+
3
+ from repodna.mcp.server import RepoDNAMCPServer, main
4
+
5
+ __all__ = ["RepoDNAMCPServer", "main"]
@@ -0,0 +1,6 @@
1
+ """Executable module entrypoint for `python -m repodna.mcp`."""
2
+
3
+ from repodna.mcp.server import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())
@@ -0,0 +1,258 @@
1
+ """Agent Intelligence MCP tool schemas, opt-in tool profiles, and read-only annotations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ # Advisory MCP ToolAnnotations (read-only, non-destructive, idempotent, closed local world)
8
+ # Note: Per MCP spec, annotations are advisory hints, NOT a security enforcement boundary.
9
+ READ_ONLY_TOOL_ANNOTATIONS: dict[str, Any] = {
10
+ "readOnlyHint": True,
11
+ "destructiveHint": False,
12
+ "idempotentHint": True,
13
+ "openWorldHint": False,
14
+ }
15
+
16
+ VALID_TOOL_PROFILES: frozenset[str] = frozenset(
17
+ {"full", "minimal", "architecture", "code-intelligence"}
18
+ )
19
+
20
+ # Opt-in profiles for reducing tools/list metadata token overhead
21
+ PROFILE_ALLOWLISTS: dict[str, frozenset[str] | None] = {
22
+ "full": None, # Default: preserves all 34 legacy tools + 8 v0.11.0 agent tools = 42 tools
23
+ "minimal": frozenset(
24
+ {
25
+ "repodna_repository_overview",
26
+ "repodna_task_context",
27
+ "repodna_repository_map",
28
+ "repodna_expand_context",
29
+ "repodna_change_preflight",
30
+ "repodna_inspect_patch",
31
+ "repodna_change_postflight",
32
+ "repodna_verify_evidence",
33
+ "repodna_agent_capabilities",
34
+ }
35
+ ),
36
+ "architecture": frozenset(
37
+ {
38
+ "repodna_repository_overview",
39
+ "repodna_architecture_map",
40
+ "repodna_get_passport",
41
+ "repodna_module_dependencies",
42
+ "repodna_module_findings",
43
+ "repodna_get_contract",
44
+ "repodna_check_contract",
45
+ "repodna_pr_guardian",
46
+ "repodna_refactoring_advisor",
47
+ "repodna_architecture_diff",
48
+ "repodna_change_impact",
49
+ "repodna_analysis_coverage",
50
+ "repodna_live_status",
51
+ "repodna_live_context",
52
+ "repodna_repository_map",
53
+ "repodna_change_preflight",
54
+ "repodna_change_postflight",
55
+ "repodna_agent_capabilities",
56
+ }
57
+ ),
58
+ "code-intelligence": frozenset(
59
+ {
60
+ "repodna_repository_overview",
61
+ "repodna_search_code",
62
+ "repodna_find_symbol",
63
+ "repodna_trace_symbol",
64
+ "repodna_get_evidence",
65
+ "repodna_code_quality",
66
+ "repodna_get_quality_findings",
67
+ "repodna_symbol_complexity",
68
+ "repodna_find_duplicates",
69
+ "repodna_unused_candidates",
70
+ "repodna_test_relationships",
71
+ "repodna_symbol_change_impact",
72
+ "repodna_task_context",
73
+ "repodna_repository_map",
74
+ "repodna_expand_context",
75
+ "repodna_inspect_patch",
76
+ "repodna_verify_evidence",
77
+ "repodna_agent_capabilities",
78
+ }
79
+ ),
80
+ }
81
+
82
+
83
+ def get_agent_mcp_tool_schemas() -> list[dict[str, Any]]:
84
+ """Returns deterministic JSON schemas for the 8 v0.11.0 AI Agent Intelligence MCP tools."""
85
+ return [
86
+ {
87
+ "name": "repodna_task_context",
88
+ "description": "Compile a token-budgeted, evidence-grounded context pack (or acknowledged delta pack) for a developer task.",
89
+ "annotations": dict(READ_ONLY_TOOL_ANNOTATIONS),
90
+ "inputSchema": {
91
+ "type": "object",
92
+ "properties": {
93
+ "target": {"type": "string", "default": "."},
94
+ "task": {"type": "string", "description": "Natural-language task description (EN/TR)."},
95
+ "token_budget": {"type": "integer", "default": 2048, "minimum": 64, "maximum": 65536},
96
+ "target_model": {"type": "string", "default": "generic"},
97
+ "tokenizer": {"type": "string", "default": "auto"},
98
+ "profile": {"type": "string", "default": "balanced"},
99
+ "offset": {"type": "integer", "default": 0, "minimum": 0},
100
+ "known_block_ids": {"type": "array", "items": {"type": "string"}},
101
+ "known_block_hashes": {"type": "object"},
102
+ "previous_snapshot_id": {"type": "string"},
103
+ "format": {"type": "string", "enum": ["json", "markdown"], "default": "json"},
104
+ },
105
+ "required": ["target", "task"],
106
+ },
107
+ },
108
+ {
109
+ "name": "repodna_repository_map",
110
+ "description": "Compile a deterministic, token-aware repository map with exported signatures, boundaries, and coverage limits.",
111
+ "annotations": dict(READ_ONLY_TOOL_ANNOTATIONS),
112
+ "inputSchema": {
113
+ "type": "object",
114
+ "properties": {
115
+ "target": {"type": "string", "default": "."},
116
+ "mode": {
117
+ "type": "string",
118
+ "enum": [
119
+ "overview",
120
+ "task-focused",
121
+ "symbol-focused",
122
+ "architecture-focused",
123
+ "test-focused",
124
+ "change-focused",
125
+ ],
126
+ "default": "overview",
127
+ },
128
+ "task": {"type": "string"},
129
+ "focus_symbol": {"type": "string"},
130
+ "token_budget": {"type": "integer", "default": 2048, "minimum": 64, "maximum": 65536},
131
+ "max_modules": {"type": "integer", "default": 25, "minimum": 1, "maximum": 100},
132
+ },
133
+ "required": ["target"],
134
+ },
135
+ },
136
+ {
137
+ "name": "repodna_expand_context",
138
+ "description": "Progressively expand a bounded file, symbol, evidence, dependency path, finding, test, rule, or live change.",
139
+ "annotations": dict(READ_ONLY_TOOL_ANNOTATIONS),
140
+ "inputSchema": {
141
+ "type": "object",
142
+ "properties": {
143
+ "target": {"type": "string", "default": "."},
144
+ "target_type": {
145
+ "type": "string",
146
+ "enum": [
147
+ "file",
148
+ "symbol",
149
+ "evidence",
150
+ "dependency_path",
151
+ "finding",
152
+ "test_relationship",
153
+ "architecture_rule",
154
+ "live_change",
155
+ ],
156
+ },
157
+ "target_id": {"type": "string"},
158
+ "snapshot_id": {"type": "string"},
159
+ "cursor": {"type": "string"},
160
+ "token_budget": {"type": "integer", "default": 1024, "minimum": 64, "maximum": 65536},
161
+ "max_lines": {"type": "integer", "default": 80, "minimum": 1, "maximum": 200},
162
+ },
163
+ "required": ["target", "target_type", "target_id"],
164
+ },
165
+ },
166
+ {
167
+ "name": "repodna_change_preflight",
168
+ "description": "Read-only pre-edit impact plan separating verified structural impact from explicitly labeled hypothetical risks.",
169
+ "annotations": dict(READ_ONLY_TOOL_ANNOTATIONS),
170
+ "inputSchema": {
171
+ "type": "object",
172
+ "properties": {
173
+ "target": {"type": "string", "default": "."},
174
+ "intended_files": {"type": "array", "items": {"type": "string"}},
175
+ "intended_symbols": {"type": "array", "items": {"type": "string"}},
176
+ "operation_type": {
177
+ "type": "string",
178
+ "enum": ["modify", "add", "delete", "rename", "refactor", "dependency_update"],
179
+ "default": "modify",
180
+ },
181
+ "proposed_dependency_edges": {
182
+ "type": "array",
183
+ "items": {"type": "array", "items": {"type": "string"}, "minItems": 2, "maxItems": 2},
184
+ },
185
+ "expected_behavior": {"type": "string", "default": ""},
186
+ },
187
+ "required": ["target"],
188
+ },
189
+ },
190
+ {
191
+ "name": "repodna_inspect_patch",
192
+ "description": "Bounded read-only unified diff inspection with path validation and fail-closed in-memory projection.",
193
+ "annotations": dict(READ_ONLY_TOOL_ANNOTATIONS),
194
+ "inputSchema": {
195
+ "type": "object",
196
+ "properties": {
197
+ "target": {"type": "string", "default": "."},
198
+ "patch_text": {"type": "string", "description": "Unified diff text (read-only, never applied to disk)."},
199
+ },
200
+ "required": ["target", "patch_text"],
201
+ },
202
+ },
203
+ {
204
+ "name": "repodna_change_postflight",
205
+ "description": "Static snapshot-backed postflight verification comparing before/after snapshots (does not run repository tests).",
206
+ "annotations": dict(READ_ONLY_TOOL_ANNOTATIONS),
207
+ "inputSchema": {
208
+ "type": "object",
209
+ "properties": {
210
+ "target": {"type": "string", "default": "."},
211
+ "intended_files": {"type": "array", "items": {"type": "string"}},
212
+ "stale_evidence_ids": {"type": "array", "items": {"type": "string"}},
213
+ },
214
+ "required": ["target"],
215
+ },
216
+ },
217
+ {
218
+ "name": "repodna_verify_evidence",
219
+ "description": "Verify an evidence ID against current repository snapshot and disk state (VERIFIED/STALE/UNAVAILABLE/PARTIAL/INVALID).",
220
+ "annotations": dict(READ_ONLY_TOOL_ANNOTATIONS),
221
+ "inputSchema": {
222
+ "type": "object",
223
+ "properties": {
224
+ "target": {"type": "string", "default": "."},
225
+ "evidence_id": {"type": "string"},
226
+ "expected_snapshot_id": {"type": "string"},
227
+ },
228
+ "required": ["target", "evidence_id"],
229
+ },
230
+ },
231
+ {
232
+ "name": "repodna_agent_capabilities",
233
+ "description": "Discover RepoDNA read-only capabilities, supported languages, tokenizer mode, tool profiles, and resource bounds.",
234
+ "annotations": dict(READ_ONLY_TOOL_ANNOTATIONS),
235
+ "inputSchema": {
236
+ "type": "object",
237
+ "properties": {},
238
+ },
239
+ },
240
+ ]
241
+
242
+
243
+ def filter_tools_by_profile(
244
+ tools: list[dict[str, Any]],
245
+ profile: str,
246
+ ) -> list[dict[str, Any]]:
247
+ """Filters tools list by profile while preserving deterministic ordering and adding read-only annotations."""
248
+ norm_profile = (profile or "full").strip().lower()
249
+ allowlist = PROFILE_ALLOWLISTS.get(norm_profile)
250
+ filtered: list[dict[str, Any]] = []
251
+ for tool in tools:
252
+ if allowlist is not None and tool.get("name") not in allowlist:
253
+ continue
254
+ item = dict(tool)
255
+ if "annotations" not in item:
256
+ item["annotations"] = dict(READ_ONLY_TOOL_ANNOTATIONS)
257
+ filtered.append(item)
258
+ return filtered