35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# .agent/tools/files_stats.py
|
|
import os
|
|
import pathspec
|
|
|
|
def get_heavy_files(limit=10, start_path='.'):
|
|
"""Lista os arquivos maiores do projeto para priorizar refatoração."""
|
|
|
|
# Filtros padrão
|
|
patterns = ['.git', '.agent', 'node_modules', 'venv', '*.png', '*.jpg', '*.mp4', 'package-lock.json', 'yarn.lock']
|
|
spec = pathspec.PathSpec.from_lines('gitwildmatch', patterns)
|
|
|
|
files_data = []
|
|
|
|
for root, dirs, files in os.walk(start_path):
|
|
dirs[:] = [d for d in dirs if not spec.match_file(os.path.join(root, d))]
|
|
|
|
for f in files:
|
|
f_path = os.path.join(root, f)
|
|
if not spec.match_file(f_path):
|
|
try:
|
|
size_kb = os.path.getsize(f_path) / 1024
|
|
files_data.append((f_path, size_kb))
|
|
except: pass
|
|
|
|
# Ordena por tamanho (decrescente)
|
|
files_data.sort(key=lambda x: x[1], reverse=True)
|
|
|
|
output = [f"📊 TOP {limit} Arquivos mais pesados (Candidatos a Refatoração):"]
|
|
for path, size in files_data[:limit]:
|
|
output.append(f"{size:.2f} KB | {path}")
|
|
|
|
return "\n".join(output)
|
|
|
|
if __name__ == "__main__":
|
|
print(get_heavy_files()) |