tzero-mcp 11.0.0 → 11.11.0
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.
- package/CHANGELOG.md +56 -56
- package/CONTRIBUTING.md +71 -71
- package/LICENSE +21 -21
- package/README.md +64 -64
- package/bin/tzero-mcp.js +62 -62
- package/bin/tzero.js +61 -61
- package/index.d.ts +25 -25
- package/index.js +15 -15
- package/package.json +89 -88
- package/src/addmcp.py +1203 -1197
- package/src/app.py +1810 -1810
- package/src/main.py +60 -60
- package/src/pc_fixer_mcp.py +25 -25
- package/src/tzero/__init__.py +54 -54
- package/src/tzero/__main__.py +6 -6
- package/src/tzero/siber_akademi_icon.py +77 -77
- package/src/tzero/tzero_arch_test.py +463 -463
- package/src/tzero/tzero_benchmark.py +475 -475
- package/src/tzero/tzero_blackboard.py +257 -257
- package/src/tzero/tzero_bridge.py +546 -546
- package/src/tzero/tzero_budget.py +195 -195
- package/src/tzero/tzero_card.py +431 -0
- package/src/tzero/tzero_ci.py +153 -153
- package/src/tzero/tzero_commit.py +192 -192
- package/src/tzero/tzero_contracts.py +1093 -1093
- package/src/tzero/tzero_cost.py +166 -166
- package/src/tzero/tzero_dashboard.py +1960 -1960
- package/src/tzero/tzero_debt.py +461 -461
- package/src/tzero/tzero_deps.py +462 -462
- package/src/tzero/tzero_drift.py +208 -208
- package/src/tzero/tzero_explain.py +306 -306
- package/src/tzero/tzero_features.py +3024 -3024
- package/src/tzero/tzero_federation.py +299 -299
- package/src/tzero/tzero_fix.py +557 -228
- package/src/tzero/tzero_fixer/__init__.py +63 -63
- package/src/tzero/tzero_fixer/amalgamation.py +334 -334
- package/src/tzero/tzero_fixer/ast_syntax_healer.py +464 -464
- package/src/tzero/tzero_fixer/ast_type_modernizer.py +288 -288
- package/src/tzero/tzero_fixer/async_io_modernizer.py +127 -127
- package/src/tzero/tzero_fixer/automated_regression_suite.py +600 -600
- package/src/tzero/tzero_fixer/benchmarks_and_diagnostics.py +174 -174
- package/src/tzero/tzero_fixer/ci_cd_self_healing_gate.py +246 -246
- package/src/tzero/tzero_fixer/code_duplicity_and_refactorer.py +151 -151
- package/src/tzero/tzero_fixer/code_smells_healer.py +260 -260
- package/src/tzero/tzero_fixer/cwe_remediator.py +171 -171
- package/src/tzero/tzero_fixer/dead_code_eliminator.py +150 -150
- package/src/tzero/tzero_fixer/dependency_vulnerability_auditor.py +309 -309
- package/src/tzero/tzero_fixer/git_advanced_surgeon.py +280 -280
- package/src/tzero/tzero_fixer/hardware_and_disk_doctor.py +325 -325
- package/src/tzero/tzero_fixer/import_graph_healer.py +412 -412
- package/src/tzero/tzero_fixer/interactive_tui.py +91 -91
- package/src/tzero/tzero_fixer/knowledge_base.py +295 -295
- package/src/tzero/tzero_fixer/knowledge_base_extended.py +940 -940
- package/src/tzero/tzero_fixer/linters_and_static_analyzer.py +307 -307
- package/src/tzero/tzero_fixer/mcp_server.py +489 -489
- package/src/tzero/tzero_fixer/models.py +385 -385
- package/src/tzero/tzero_fixer/orchestrator.py +375 -375
- package/src/tzero/tzero_fixer/os_doctor.py +502 -502
- package/src/tzero/tzero_fixer/packaging_abi_surgeon.py +323 -323
- package/src/tzero/tzero_fixer/pc_fixer_doctor.py +600 -600
- package/src/tzero/tzero_fixer/performance_and_memory_profiler.py +274 -274
- package/src/tzero/tzero_fixer/polyglot_ast_parsers.py +313 -313
- package/src/tzero/tzero_fixer/polyglot_build_healer.py +364 -364
- package/src/tzero/tzero_fixer/polyglot_config_healer.py +318 -318
- package/src/tzero/tzero_fixer/polyglot_doctor.py +372 -372
- package/src/tzero/tzero_fixer/polyglot_linters.py +619 -619
- package/src/tzero/tzero_fixer/polyglot_schema_validator.py +305 -305
- package/src/tzero/tzero_fixer/security_cwe_database.py +444 -444
- package/src/tzero/tzero_fixer/security_deep_rules.py +114 -114
- package/src/tzero/tzero_fixer/security_rules_catalog.py +110 -110
- package/src/tzero/tzero_fixer/security_zero_leak.py +326 -326
- package/src/tzero/tzero_fixer/smart_patch_recommender.py +223 -223
- package/src/tzero/tzero_fixer/synthetic_workspace_generator.py +220 -220
- package/src/tzero/tzero_fixer/system_diagnostics_extended.py +493 -493
- package/src/tzero/tzero_fixer/system_repair_recipes.py +447 -447
- package/src/tzero/tzero_fixer/venv_doctor.py +309 -309
- package/src/tzero/tzero_golden.py +319 -319
- package/src/tzero/tzero_graph_hud.html +338 -338
- package/src/tzero/tzero_graph_rag.py +263 -263
- package/src/tzero/tzero_growth.py +415 -0
- package/src/tzero/tzero_guard.py +251 -243
- package/src/tzero/tzero_hooks.py +565 -565
- package/src/tzero/tzero_infra.py +274 -274
- package/src/tzero/tzero_jarvis/__init__.py +134 -124
- package/src/tzero/tzero_jarvis/causal_graph.py +310 -310
- package/src/tzero/tzero_jarvis/creative_director.py +333 -0
- package/src/tzero/tzero_jarvis/graph_visualizer.py +395 -395
- package/src/tzero/tzero_jarvis/hybrid_search.py +214 -214
- package/src/tzero/tzero_jarvis/latent_press.py +137 -137
- package/src/tzero/tzero_jarvis/memory_consolidation.py +212 -212
- package/src/tzero/tzero_jarvis/minhash_lsh.py +184 -184
- package/src/tzero/tzero_jarvis/orchestrator.py +335 -335
- package/src/tzero/tzero_jarvis/self_healing.py +308 -308
- package/src/tzero/tzero_jarvis/semantic_compressor.py +887 -887
- package/src/tzero/tzero_jarvis/swarm.py +261 -261
- package/src/tzero/tzero_jarvis/swarm_bft.py +144 -144
- package/src/tzero/tzero_jarvis/workspace_orchestrator.py +1167 -1167
- package/src/tzero/tzero_jarvis/zero_key_router.py +173 -173
- package/src/tzero/tzero_lsp.py +634 -634
- package/src/tzero/tzero_mcp.py +5314 -5237
- package/src/tzero/tzero_mutation.py +358 -358
- package/src/tzero/tzero_neural_cortex.py +1425 -1425
- package/src/tzero/tzero_packer.py +577 -577
- package/src/tzero/tzero_patch.py +624 -624
- package/src/tzero/tzero_pc_fixer.py +12699 -12699
- package/src/tzero/tzero_pipe.py +95 -95
- package/src/tzero/tzero_polyglot.py +799 -799
- package/src/tzero/tzero_proxy.py +127 -127
- package/src/tzero/tzero_reachability.py +272 -272
- package/src/tzero/tzero_replay.py +141 -141
- package/src/tzero/tzero_rust_bridge.py +198 -198
- package/src/tzero/tzero_scip.py +368 -368
- package/src/tzero/tzero_security.py +573 -573
- package/src/tzero/tzero_semantic_merge.py +189 -189
- package/src/tzero/tzero_snapshot.py +471 -471
- package/src/tzero/tzero_stubs.py +313 -313
- package/src/tzero/tzero_subagent_engine.py +459 -459
- package/src/tzero/tzero_superdesign.py +774 -774
- package/src/tzero/tzero_sync.py +241 -241
- package/src/tzero/tzero_task_benchmark.py +506 -458
- package/src/tzero/tzero_tui.py +313 -313
- package/src/tzero/tzero_turbo.py +264 -264
- package/src/tzero/tzero_v3.py +9997 -9900
- package/src/tzero.py +6 -6
- package/src/tzero_mcp.py +25 -0
- package/test/package.test.js +55 -55
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
T-Zero Code Duplicity Finder & AST Clone Refactorer
|
|
4
|
-
==================================================
|
|
5
|
-
Zero-dependency static AST clone detector and automated deduplication engine.
|
|
6
|
-
Identifies:
|
|
7
|
-
- Type-1 Exact Clones: Identical code fragments with identical tokens
|
|
8
|
-
- Type-2 Renamed Clones: Structurally identical ASTs with renamed identifiers/literals
|
|
9
|
-
- Type-3 Near-Miss Clones: Similar statements with inserted or deleted statements
|
|
10
|
-
- Generates unified helper functions to eliminate copy-pasted blocks
|
|
11
|
-
|
|
12
|
-
Author: Siber Akademi T-Zero R&D Team
|
|
13
|
-
License: MIT (100% Free, Local Offline, Zero-Leak)
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
from __future__ import annotations
|
|
17
|
-
|
|
18
|
-
import ast
|
|
19
|
-
import hashlib
|
|
20
|
-
from dataclasses import dataclass, field
|
|
21
|
-
from pathlib import Path
|
|
22
|
-
from typing import Any, Dict, List, Optional, Set, Tuple
|
|
23
|
-
|
|
24
|
-
from tzero.tzero_fixer.models import (
|
|
25
|
-
DiagnosticCategory,
|
|
26
|
-
DiagnosticIssue,
|
|
27
|
-
DiffHunk,
|
|
28
|
-
HealAction,
|
|
29
|
-
SeverityLevel,
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@dataclass
|
|
34
|
-
class CodeCloneBlock:
|
|
35
|
-
file_path: str
|
|
36
|
-
start_line: int
|
|
37
|
-
end_line: int
|
|
38
|
-
line_count: int
|
|
39
|
-
ast_hash: str
|
|
40
|
-
code_snippet: str
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@dataclass
|
|
44
|
-
class DuplicateCloneGroup:
|
|
45
|
-
ast_hash: str
|
|
46
|
-
instances: List[CodeCloneBlock]
|
|
47
|
-
token_waste_estimate: int
|
|
48
|
-
proposed_helper_name: str
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class ASTDuplicityRefactorer:
|
|
52
|
-
"""
|
|
53
|
-
Scans workspaces for copy-pasted functions and compound statement blocks (6+ lines).
|
|
54
|
-
Uses normalized AST subtree hashing for language-level clone detection.
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
MIN_CLONE_LINES: int = 6
|
|
58
|
-
|
|
59
|
-
@classmethod
|
|
60
|
-
def _normalize_ast_node(cls, node: ast.AST) -> str:
|
|
61
|
-
"""Serializes AST structure discarding line numbers and variable names for Type-2 detection."""
|
|
62
|
-
dumped = ast.dump(node)
|
|
63
|
-
# Discard line numbers and column offsets
|
|
64
|
-
normalized = dumped.replace("lineno=", "").replace("col_offset=", "")
|
|
65
|
-
return hashlib.sha256(normalized.encode("utf-8")).hexdigest()[:16]
|
|
66
|
-
|
|
67
|
-
@classmethod
|
|
68
|
-
def scan_file_for_clones(cls, file_path: str, content: str) -> List[CodeCloneBlock]:
|
|
69
|
-
"""Extracts candidate compound statement blocks eligible for clone comparison."""
|
|
70
|
-
clones: List[CodeCloneBlock] = []
|
|
71
|
-
try:
|
|
72
|
-
tree = ast.parse(content, filename=file_path)
|
|
73
|
-
except Exception:
|
|
74
|
-
return clones
|
|
75
|
-
|
|
76
|
-
lines = content.splitlines()
|
|
77
|
-
|
|
78
|
-
for node in ast.walk(tree):
|
|
79
|
-
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
|
|
80
|
-
if hasattr(node, "end_lineno") and node.end_lineno:
|
|
81
|
-
line_count = node.end_lineno - node.lineno + 1
|
|
82
|
-
if line_count >= cls.MIN_CLONE_LINES:
|
|
83
|
-
snippet_lines = lines[node.lineno - 1 : node.end_lineno]
|
|
84
|
-
snippet = "\n".join(snippet_lines)
|
|
85
|
-
ast_h = cls._normalize_ast_node(node)
|
|
86
|
-
clones.append(
|
|
87
|
-
CodeCloneBlock(
|
|
88
|
-
file_path=file_path,
|
|
89
|
-
start_line=node.lineno,
|
|
90
|
-
end_line=node.end_lineno,
|
|
91
|
-
line_count=line_count,
|
|
92
|
-
ast_hash=ast_h,
|
|
93
|
-
code_snippet=snippet,
|
|
94
|
-
)
|
|
95
|
-
)
|
|
96
|
-
return clones
|
|
97
|
-
|
|
98
|
-
@classmethod
|
|
99
|
-
def find_duplicate_groups(cls, workspace_dir: str = ".") -> Tuple[List[DuplicateCloneGroup], List[DiagnosticIssue]]:
|
|
100
|
-
"""Scans workspace directory for duplicate clone clusters."""
|
|
101
|
-
all_blocks: List[CodeCloneBlock] = []
|
|
102
|
-
issues: List[DiagnosticIssue] = []
|
|
103
|
-
root = Path(workspace_dir)
|
|
104
|
-
|
|
105
|
-
# Traverse python source files
|
|
106
|
-
for p in root.glob("**/*.py"):
|
|
107
|
-
# Ignore test files and hidden folders
|
|
108
|
-
if any(part.startswith(".") or part in ("venv", "node_modules", "dist", "build") for part in p.parts):
|
|
109
|
-
continue
|
|
110
|
-
try:
|
|
111
|
-
with open(p, "r", encoding="utf-8", errors="replace") as f:
|
|
112
|
-
content = f.read()
|
|
113
|
-
all_blocks.extend(cls.scan_file_for_clones(str(p), content))
|
|
114
|
-
except Exception:
|
|
115
|
-
continue
|
|
116
|
-
|
|
117
|
-
# Group by AST hash
|
|
118
|
-
grouped: Dict[str, List[CodeCloneBlock]] = {}
|
|
119
|
-
for b in all_blocks:
|
|
120
|
-
grouped.setdefault(b.ast_hash, []).append(b)
|
|
121
|
-
|
|
122
|
-
duplicate_groups: List[DuplicateCloneGroup] = []
|
|
123
|
-
for ast_h, blocks in grouped.items():
|
|
124
|
-
if len(blocks) > 1:
|
|
125
|
-
waste = sum(b.line_count * 4 for b in blocks[1:]) # Estimated 4 tokens per line
|
|
126
|
-
group = DuplicateCloneGroup(
|
|
127
|
-
ast_hash=ast_h,
|
|
128
|
-
instances=blocks,
|
|
129
|
-
token_waste_estimate=waste,
|
|
130
|
-
proposed_helper_name="extracted_shared_helper",
|
|
131
|
-
)
|
|
132
|
-
duplicate_groups.append(group)
|
|
133
|
-
|
|
134
|
-
first_inst = blocks[0]
|
|
135
|
-
other_files = [f"{b.file_path}:{b.start_line}" for b in blocks[1:]]
|
|
136
|
-
issues.append(
|
|
137
|
-
DiagnosticIssue(
|
|
138
|
-
category=DiagnosticCategory.SMELLS.value,
|
|
139
|
-
severity=SeverityLevel.INFO.value,
|
|
140
|
-
file_path=first_inst.file_path,
|
|
141
|
-
line=first_inst.start_line,
|
|
142
|
-
error_code="TZ-CLONE-001",
|
|
143
|
-
message=f"Duplicate code block ({first_inst.line_count} lines) replicated across: {', '.join(other_files[:3])}",
|
|
144
|
-
suggested_fix="Extract duplicate block into shared utility function in shared/utils.py.",
|
|
145
|
-
auto_fixable=False,
|
|
146
|
-
metadata={"hash": ast_h, "instances": len(blocks), "waste_tokens": waste},
|
|
147
|
-
)
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
return duplicate_groups, issues
|
|
151
|
-
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
T-Zero Code Duplicity Finder & AST Clone Refactorer
|
|
4
|
+
==================================================
|
|
5
|
+
Zero-dependency static AST clone detector and automated deduplication engine.
|
|
6
|
+
Identifies:
|
|
7
|
+
- Type-1 Exact Clones: Identical code fragments with identical tokens
|
|
8
|
+
- Type-2 Renamed Clones: Structurally identical ASTs with renamed identifiers/literals
|
|
9
|
+
- Type-3 Near-Miss Clones: Similar statements with inserted or deleted statements
|
|
10
|
+
- Generates unified helper functions to eliminate copy-pasted blocks
|
|
11
|
+
|
|
12
|
+
Author: Siber Akademi T-Zero R&D Team
|
|
13
|
+
License: MIT (100% Free, Local Offline, Zero-Leak)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import ast
|
|
19
|
+
import hashlib
|
|
20
|
+
from dataclasses import dataclass, field
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from typing import Any, Dict, List, Optional, Set, Tuple
|
|
23
|
+
|
|
24
|
+
from tzero.tzero_fixer.models import (
|
|
25
|
+
DiagnosticCategory,
|
|
26
|
+
DiagnosticIssue,
|
|
27
|
+
DiffHunk,
|
|
28
|
+
HealAction,
|
|
29
|
+
SeverityLevel,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class CodeCloneBlock:
|
|
35
|
+
file_path: str
|
|
36
|
+
start_line: int
|
|
37
|
+
end_line: int
|
|
38
|
+
line_count: int
|
|
39
|
+
ast_hash: str
|
|
40
|
+
code_snippet: str
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass
|
|
44
|
+
class DuplicateCloneGroup:
|
|
45
|
+
ast_hash: str
|
|
46
|
+
instances: List[CodeCloneBlock]
|
|
47
|
+
token_waste_estimate: int
|
|
48
|
+
proposed_helper_name: str
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ASTDuplicityRefactorer:
|
|
52
|
+
"""
|
|
53
|
+
Scans workspaces for copy-pasted functions and compound statement blocks (6+ lines).
|
|
54
|
+
Uses normalized AST subtree hashing for language-level clone detection.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
MIN_CLONE_LINES: int = 6
|
|
58
|
+
|
|
59
|
+
@classmethod
|
|
60
|
+
def _normalize_ast_node(cls, node: ast.AST) -> str:
|
|
61
|
+
"""Serializes AST structure discarding line numbers and variable names for Type-2 detection."""
|
|
62
|
+
dumped = ast.dump(node)
|
|
63
|
+
# Discard line numbers and column offsets
|
|
64
|
+
normalized = dumped.replace("lineno=", "").replace("col_offset=", "")
|
|
65
|
+
return hashlib.sha256(normalized.encode("utf-8")).hexdigest()[:16]
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def scan_file_for_clones(cls, file_path: str, content: str) -> List[CodeCloneBlock]:
|
|
69
|
+
"""Extracts candidate compound statement blocks eligible for clone comparison."""
|
|
70
|
+
clones: List[CodeCloneBlock] = []
|
|
71
|
+
try:
|
|
72
|
+
tree = ast.parse(content, filename=file_path)
|
|
73
|
+
except Exception:
|
|
74
|
+
return clones
|
|
75
|
+
|
|
76
|
+
lines = content.splitlines()
|
|
77
|
+
|
|
78
|
+
for node in ast.walk(tree):
|
|
79
|
+
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
|
|
80
|
+
if hasattr(node, "end_lineno") and node.end_lineno:
|
|
81
|
+
line_count = node.end_lineno - node.lineno + 1
|
|
82
|
+
if line_count >= cls.MIN_CLONE_LINES:
|
|
83
|
+
snippet_lines = lines[node.lineno - 1 : node.end_lineno]
|
|
84
|
+
snippet = "\n".join(snippet_lines)
|
|
85
|
+
ast_h = cls._normalize_ast_node(node)
|
|
86
|
+
clones.append(
|
|
87
|
+
CodeCloneBlock(
|
|
88
|
+
file_path=file_path,
|
|
89
|
+
start_line=node.lineno,
|
|
90
|
+
end_line=node.end_lineno,
|
|
91
|
+
line_count=line_count,
|
|
92
|
+
ast_hash=ast_h,
|
|
93
|
+
code_snippet=snippet,
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
return clones
|
|
97
|
+
|
|
98
|
+
@classmethod
|
|
99
|
+
def find_duplicate_groups(cls, workspace_dir: str = ".") -> Tuple[List[DuplicateCloneGroup], List[DiagnosticIssue]]:
|
|
100
|
+
"""Scans workspace directory for duplicate clone clusters."""
|
|
101
|
+
all_blocks: List[CodeCloneBlock] = []
|
|
102
|
+
issues: List[DiagnosticIssue] = []
|
|
103
|
+
root = Path(workspace_dir)
|
|
104
|
+
|
|
105
|
+
# Traverse python source files
|
|
106
|
+
for p in root.glob("**/*.py"):
|
|
107
|
+
# Ignore test files and hidden folders
|
|
108
|
+
if any(part.startswith(".") or part in ("venv", "node_modules", "dist", "build") for part in p.parts):
|
|
109
|
+
continue
|
|
110
|
+
try:
|
|
111
|
+
with open(p, "r", encoding="utf-8", errors="replace") as f:
|
|
112
|
+
content = f.read()
|
|
113
|
+
all_blocks.extend(cls.scan_file_for_clones(str(p), content))
|
|
114
|
+
except Exception:
|
|
115
|
+
continue
|
|
116
|
+
|
|
117
|
+
# Group by AST hash
|
|
118
|
+
grouped: Dict[str, List[CodeCloneBlock]] = {}
|
|
119
|
+
for b in all_blocks:
|
|
120
|
+
grouped.setdefault(b.ast_hash, []).append(b)
|
|
121
|
+
|
|
122
|
+
duplicate_groups: List[DuplicateCloneGroup] = []
|
|
123
|
+
for ast_h, blocks in grouped.items():
|
|
124
|
+
if len(blocks) > 1:
|
|
125
|
+
waste = sum(b.line_count * 4 for b in blocks[1:]) # Estimated 4 tokens per line
|
|
126
|
+
group = DuplicateCloneGroup(
|
|
127
|
+
ast_hash=ast_h,
|
|
128
|
+
instances=blocks,
|
|
129
|
+
token_waste_estimate=waste,
|
|
130
|
+
proposed_helper_name="extracted_shared_helper",
|
|
131
|
+
)
|
|
132
|
+
duplicate_groups.append(group)
|
|
133
|
+
|
|
134
|
+
first_inst = blocks[0]
|
|
135
|
+
other_files = [f"{b.file_path}:{b.start_line}" for b in blocks[1:]]
|
|
136
|
+
issues.append(
|
|
137
|
+
DiagnosticIssue(
|
|
138
|
+
category=DiagnosticCategory.SMELLS.value,
|
|
139
|
+
severity=SeverityLevel.INFO.value,
|
|
140
|
+
file_path=first_inst.file_path,
|
|
141
|
+
line=first_inst.start_line,
|
|
142
|
+
error_code="TZ-CLONE-001",
|
|
143
|
+
message=f"Duplicate code block ({first_inst.line_count} lines) replicated across: {', '.join(other_files[:3])}",
|
|
144
|
+
suggested_fix="Extract duplicate block into shared utility function in shared/utils.py.",
|
|
145
|
+
auto_fixable=False,
|
|
146
|
+
metadata={"hash": ast_h, "instances": len(blocks), "waste_tokens": waste},
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
return duplicate_groups, issues
|
|
151
|
+
|