"""Print what the saved scan found: which Shopify stores register WebMCP tools, and which tools are marked consequential."""
import json, re

rows = [l.rstrip("\n").split("\t") for l in open("scan/index.tsv")]
with_tools = [url for i, url in rows if re.findall(r"^\w+ \[", open(f"scan/list-{i}.txt").read(), re.M)]
print(f"Shopify product pages checked:   {len(rows)}")
print(f"pages that register WebMCP tools: {len(with_tools)}\n")

store = json.load(open("tools/allbirds_tools.json"))["data"]["tools"]
checkout = json.load(open("tools/allbirds_checkout_tools.json"))["data"]["tools"]
print(f"{'page':<11}{'tool':<31}consequential")
for page, tools in (("storefront", store), ("checkout", checkout)):
    for t in tools:
        print(f"{page:<11}{t['name']:<31}{str(t['annotations']['consequential']).lower()}")
