#!/usr/bin/env python3
import subprocess
import os
import re

files = [
    "workers/monitor_dashboard.py",
    "workers/monitor_dashboard2.0.py",
    "workers/ocr/robot_1_ocr_processor.py",
    "workers/py_to_database.py",
    "workers/service/service_robot_0_hunter.py",
    "workers/service/service_robot_1_scout_osm.py",
    "workers/service/service_robot_2_researcher.py",
    "workers/service/service_robot_3_enricher.py",
    "workers/service/service_robot_4_validator_google.py",
    "workers/service/service_robot_5_auditor.py",
    "workers/system/subscription_worker.py",
    "workers/system/system_robot_2_service_auditor.py",
    "workers/vehicle/R0_brand_hunter.py",
    "workers/vehicle/R1_model_scout.py",
    "workers/vehicle/R2_generation_scout.py",
    "workers/vehicle/R3_engine_scout.py",
    "workers/vehicle/R4_final_extractor.py",
    "workers/vehicle/bike/bike_R0_brand_hunter.py",
    "workers/vehicle/bike/bike_R1_model_scout.py",
    "workers/vehicle/bike/bike_R2_generation_scout.py",
    "workers/vehicle/bike/bike_R3_engine_scout.py",
    "workers/vehicle/bike/bike_R4_final_extractor.py",
    "workers/vehicle/bike/test_aprilia.py",
    "workers/vehicle/mapping_dictionary.py",
    "workers/vehicle/mapping_rules.py",
    "workers/vehicle/r5_test.py",
    "workers/vehicle/r5_ultimate_harvester.py",
    "workers/vehicle/robot_report.py",
    "workers/vehicle/ultimatespecs/vehicle_ultimate_r0_spider.py",
    "workers/vehicle/ultimatespecs/vehicle_ultimate_r1_scraper.py",
    "workers/vehicle/ultimatespecs/vehicle_ultimate_r2_enricher.py",
    "workers/vehicle/ultimatespecs/vehicle_ultimate_r3_finalizer.py",
    "workers/vehicle/vehicle_data_loader.py",
    "workers/vehicle/vehicle_robot_0_discovery_engine.py",
    "workers/vehicle/vehicle_robot_0_gb_discovery.py",
    "workers/vehicle/vehicle_robot_1_2_nhtsa_fetcher.py",
    "workers/vehicle/vehicle_robot_1_4_bike_hunter.py",
    "workers/vehicle/vehicle_robot_1_5_heavy_eu.py",
    "workers/vehicle/vehicle_robot_1_5_heavy_eu1.0.py",
    "workers/vehicle/vehicle_robot_1_catalog_hunter.py",
    "workers/vehicle/vehicle_robot_1_gb_hunter.py",
    "workers/vehicle/vehicle_robot_2_1_rdw_enricher.py",
    "workers/vehicle/vehicle_robot_2_1_ultima_scout.py",
    "workers/vehicle/vehicle_robot_2_1_ultima_scout_1.0.py",
    "workers/vehicle/vehicle_robot_2_auto_data_net.py",
    "workers/vehicle/vehicle_robot_2_researcher.py",
    "workers/vehicle/vehicle_robot_3_alchemist_pro.py",
    "workers/vehicle/vehicle_robot_4_validator.py",
    "workers/vehicle/vehicle_robot_4_vin_auditor.py"
]

# initial tags from previous script (simplified)
tags = {}
for f in files:
    tags[f] = ("[MEGTART]", "Modern code, part of active robot pipeline.")

# overrides based on analysis
overrides = {
    "workers/service/service_robot_4_validator_google.py": ("[REFAKTORÁL]", "Contains hardcoded 'ghost' status; should use ServiceStatus Enum."),
    "workers/vehicle/R3_engine_scout.py": ("[REFAKTORÁL]", "Uses BeautifulSoup for web scraping; consider modernizing to async HTTP client and structured data extraction."),
    "workers/vehicle/R4_final_extractor.py": ("[REFAKTORÁL]", "Uses BeautifulSoup for web scraping; consider modernizing to async HTTP client and structured data extraction."),
    "workers/vehicle/bike/bike_R3_engine_scout.py": ("[REFAKTORÁL]", "Uses BeautifulSoup for web scraping; consider modernizing to async HTTP client and structured data extraction."),
    "workers/vehicle/vehicle_robot_2_auto_data_net.py": ("[REFAKTORÁL]", "Uses BeautifulSoup for web scraping; consider modernizing to async HTTP client and structured data extraction."),
    "workers/vehicle/vehicle_robot_2_researcher.py": ("[REFAKTORÁL]", "Uses BeautifulSoup for web scraping; consider modernizing to async HTTP client and structured data extraction."),
    # duplicates
    "workers/vehicle/vehicle_robot_1_5_heavy_eu1.0.py": ("[TÖRÖLHETŐ]", "Duplicate of non-1.0 version; remove to avoid confusion."),
    "workers/vehicle/vehicle_robot_2_1_ultima_scout_1.0.py": ("[TÖRÖLHETŐ]", "Duplicate of non-1.0 version; remove to avoid confusion."),
    "workers/monitor_dashboard.py": ("[TÖRÖLHETŐ]", "Older version; monitor_dashboard2.0.py should be kept."),
    # small mapping files but used, keep
    "workers/vehicle/mapping_dictionary.py": ("[MEGTART]", "Mapping utility used by rdw_enricher; keep."),
    "workers/vehicle/mapping_rules.py": ("[MEGTART]", "Mapping utility used by rdw_enricher; keep."),
    # test files
    "workers/vehicle/r5_test.py": ("[TÖRÖLHETŐ]", "Test file; not needed in production."),
    "workers/vehicle/bike/test_aprilia.py": ("[TÖRÖLHETŐ]", "Test file; not needed in production."),
}

for f, (tag, reason) in overrides.items():
    tags[f] = (tag, reason)

# output new lines
for f in files:
    tag, reason = tags[f]
    print(f"- [ ] `{f}` - {tag} {reason}")

# statistics
counts = {"MEGTART":0, "REFAKTORÁL":0, "TÖRÖLHETŐ":0}
for tag, _ in tags.values():
    if tag == "[MEGTART]":
        counts["MEGTART"] += 1
    elif tag == "[REFAKTORÁL]":
        counts["REFAKTORÁL"] += 1
    elif tag == "[TÖRÖLHETŐ]":
        counts["TÖRÖLHETŐ"] += 1

print("\nStatistics:")
print(f"MEGTART: {counts['MEGTART']}")
print(f"REFAKTORÁL: {counts['REFAKTORÁL']}")
print(f"TÖRÖLHETŐ: {counts['TÖRÖLHETŐ']}")
print(f"Total: {sum(counts.values())}")