File size: 2,325 Bytes
a31f556
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"""

modules/deep_diagnostics.py - Phase 8 deep diagnostic report



Aggregates high-signal outputs from:

  - system_advisor

  - analytics

  - thermal trends

  - RAM patterns

  - disk health

  - driver anomalies

  - file intelligence

  - clipboard intelligence

"""

from __future__ import annotations

import json
import os
from datetime import datetime

from config import DATA_DIR

REPORT_PATH = os.path.join(DATA_DIR, "deep_diagnostic_report.json")


def generate_report() -> dict:
    report = {"generated": datetime.now().isoformat()}

    try:
        from modules.system_advisor import get_full_report
        report["system"] = get_full_report()
    except Exception:
        report["system"] = ""

    try:
        from engines.analytics_engine import generate_daily_briefing
        report["analytics"] = generate_daily_briefing()
    except Exception:
        report["analytics"] = ""

    for key, fn in [
        ("thermal", ("modules.thermal_trends", "trend_report", 180)),
        ("ram", ("modules.ram_trends", "pattern_report", 240)),
        ("disk", ("modules.disk_health", "health_report", 180)),
        ("drivers", ("modules.driver_anomaly", "report", 48)),
    ]:
        try:
            mod_name, attr, arg = fn
            mod = __import__(mod_name, fromlist=[attr])
            report[key] = getattr(mod, attr)(arg)
        except Exception:
            report[key] = ""

    try:
        from modules.file_intelligence import advisory
        report["files"] = advisory()
    except Exception:
        report["files"] = ""

    try:
        from modules.clipboard_intelligence import summary
        report["clipboard"] = summary()
    except Exception:
        report["clipboard"] = ""

    os.makedirs(os.path.dirname(REPORT_PATH), exist_ok=True)
    try:
        with open(REPORT_PATH, "w", encoding="utf-8") as f:
            json.dump(report, f, indent=2)
    except Exception:
        pass
    return report


def summary() -> str:
    r = generate_report()
    parts = [r.get("system", ""), r.get("thermal", ""), r.get("ram", ""), r.get("disk", ""), r.get("drivers", "")]
    parts = [p for p in parts if p]
    if not parts:
        return "Deep diagnostics unavailable."
    return " ".join(parts[:5])[:800]