fix(imports): agent_runner MailService→Mail model, fix trace_hooks syntax, fix trace_api_contracts warnings
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
This commit is contained in:
@@ -3,16 +3,17 @@
|
||||
from __future__ import annotations
|
||||
import re, sys, json
|
||||
from pathlib import Path
|
||||
from collections import defaultdict
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
APP = ROOT / "app"
|
||||
|
||||
def find_hook_registrations() -> list[dict]:
|
||||
def find_hook_registrations():
|
||||
regs = []
|
||||
for py in APP.rglob("*.py"):
|
||||
try: content = py.read_text()
|
||||
except: continue
|
||||
try:
|
||||
content = py.read_text()
|
||||
except Exception:
|
||||
continue
|
||||
rel = str(py.relative_to(ROOT))
|
||||
for m in re.finditer(r'register_(?:action|filter)s?\s*\(\s*["\']([^"\']+)['"]', content):
|
||||
regs.append({"file": rel, "hook_type": "action_or_filter", "hook_name": m.group(1)})
|
||||
@@ -20,11 +21,13 @@ def find_hook_registrations() -> list[dict]:
|
||||
regs.append({"file": rel, "hook_type": "action_group", "hook_name": m.group(1)})
|
||||
return regs
|
||||
|
||||
def find_hook_triggers() -> list[dict]:
|
||||
def find_hook_triggers():
|
||||
triggers = []
|
||||
for py in APP.rglob("*.py"):
|
||||
try: content = py.read_text()
|
||||
except: continue
|
||||
try:
|
||||
content = py.read_text()
|
||||
except Exception:
|
||||
continue
|
||||
rel = str(py.relative_to(ROOT))
|
||||
for m in re.finditer(r'do_action\s*\(\s*["\']([^"\']+)['"]', content):
|
||||
triggers.append({"file": rel, "hook_name": m.group(1), "type": "action"})
|
||||
@@ -51,13 +54,16 @@ def main():
|
||||
print(f" Triggered but never received: {len(orphans_trig)}")
|
||||
if orphans_reg:
|
||||
print("\n--- Registered but never triggered ---")
|
||||
for o in orphans_reg[:20]: print(f" {o['hook_name']} (in {o['file']})")
|
||||
for o in orphans_reg[:20]:
|
||||
print(f" {o['hook_name']} (in {o['file']})")
|
||||
if orphans_trig:
|
||||
print("\n--- Triggered but never received ---")
|
||||
for o in orphans_trig[:20]: print(f" {o['hook_name']} (in {o['file']})")
|
||||
for o in orphans_trig[:20]:
|
||||
print(f" {o['hook_name']} (in {o['file']})")
|
||||
results = {"registrations": regs, "triggers": triggers, "orphan_registrations": orphans_reg, "orphan_triggers": orphans_trig}
|
||||
with open(ROOT / "scripts" / "test_suite" / "results_trace_hooks.json", "w") as f:
|
||||
json.dump(results, f, indent=2, default=str)
|
||||
return len(orphans_reg) + len(orphans_trig)
|
||||
|
||||
if __name__ == "__main__": sys.exit(main())
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user