[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77JT78SPZHZ58BJHEXEWTKM":3,"skill-same:01M77JT78SPZHZ58BJHEXEWTKM":46},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M77JT78SPZHZ58BJHEXEWTKM","iris-pro",null,"Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fi\u002Firis-pro\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: iris-pro\ndescription: \"Iris Pro — Inbox Intelligence. Reads your Gmail inbox, scores every email by urgency and sender importance, drafts full personalised replies for every actionable email (not just 5), generates weekly inbox analytics, and produces a priority action plan. The full-power version of Iris.\"\nversion: \"1.0.4\"\nmetadata:\n  openclaw:\n    requires:\n      env: [GMAIL_ADDRESS, GMAIL_APP_PASSWORD, LICENSE_KEY]\n      bins: [python3, pip3]\n    primaryEnv: GMAIL_ADDRESS\n    emoji: \"🌈⚡\"\n    homepage: https:\u002F\u002Fclawhub.ai\u002Foccupythemilkyway\u002Firis-pro\n    tags: [email, gmail, inbox, triage, productivity, pro, premium, iris, drafts]\n    envVars:\n      - name: LICENSE_KEY\n        required: true\n        description: \"Your Iris Pro license key. Get one at: ko-fi.com\u002Fs\u002Ff75940a0ce\"\n\n💰 **Bundle deal:** all 5 Pro skills for **$29** → **ko-fi.com\u002Fs\u002F7625accf3f** (save $16)\n      - name: GMAIL_ADDRESS\n        required: true\n        description: Your Gmail address\n      - name: GMAIL_APP_PASSWORD\n        required: true\n        description: \"Gmail app password from myaccount.google.com\u002Fapppasswords\"\n      - name: SCAN_COUNT\n        required: false\n        description: \"Emails to scan (up to 200 in Pro)\"\n        default: \"100\"\n      - name: VIP_SENDERS\n        required: false\n        description: \"Comma-separated VIP sender emails or domains\"\n        default: \"\"\n      - name: YOUR_NAME\n        required: false\n        description: \"Your name for personalised replies\"\n        default: \"\"\n      - name: YOUR_ROLE\n        required: false\n        description: \"Your role\u002Ftitle for context-aware replies\"\n        default: \"\"\n      - name: REPLY_TONE\n        required: false\n        description: \"Tone for draft replies: professional, friendly, brief\"\n        default: \"professional\"\n      - name: CATEGORIES\n        required: false\n        description: \"Comma-separated email categories to apply: sales,hr,legal,finance,support,general\"\n        default: \"general\"\n---\n\n# Iris Pro — Full Inbox Intelligence\n\nEverything in Iris, plus unlimited draft replies, email categorisation, weekly analytics, and custom reply tones.\n\n## Pro features vs free Iris\n\n| Feature | Iris (Free) | Iris Pro |\n|---------|-------------|----------|\n| Emails scanned | 50 | Up to 200 |\n| Draft replies | Top 5 only | Every actionable email |\n| Reply tones | Standard | Professional \u002F Friendly \u002F Brief |\n| Email categories | — | Sales, HR, Legal, Finance, Support |\n| Weekly analytics | — | ✅ Trend chart + avg response time |\n| Noise stats | Count only | Full sender breakdown |\n| Report format | Markdown | Markdown + structured JSON |\n\n## Setup\n\n1. Get your license key at **ko-fi.com\u002Fs\u002Ff75940a0ce**\n2. Set `LICENSE_KEY` to the key you receive\n3. Create a Gmail app password at myaccount.google.com\u002Fapppasswords\n\n## 🔒 Security\n\nGmail credentials stay local. No data transmitted to any server.\n\n---\n\n## Step 1 — Install\n\n```bash\npip3 install rich --break-system-packages --quiet\n```\n\n---\n\n## Step 2 — Triage your inbox (Pro)\n\n```python\nimport os, imaplib, email, re, json\nfrom email.header import decode_header\nfrom email.utils import parsedate_to_datetime\nfrom datetime import datetime, timezone, timedelta\nfrom collections import defaultdict\nfrom rich.console import Console\nfrom rich.table import Table\nfrom rich.panel import Panel\nfrom rich import box\n\nFENCE = chr(96) * 3\n\nconsole = Console()\n\nLICENSE_KEY = os.environ.get(\"LICENSE_KEY\", \"\").strip()\nif not LICENSE_KEY:\n    console.print(Panel(\n        \"[red bold]🔒 Iris Pro requires a license key.[\u002Fred bold]\\n\\n\"\n        \"Get your key at: [bold cyan]ko-fi.com\u002Fs\u002Ff75940a0ce[\u002Fbold cyan]\\n\\n\"\n        \"Or use the free version: [dim]openclaw skills install iris[\u002Fdim]\",\n        title=\"License Required\",\n        border_style=\"red\"\n    ))\n    raise SystemExit(1)\n\nGMAIL_ADDR  = os.environ.get(\"GMAIL_ADDRESS\", \"\").strip()\nGMAIL_PASS  = os.environ.get(\"GMAIL_APP_PASSWORD\", \"\").strip()\ntry:\n    SCAN_COUNT = min(int(os.environ.get(\"SCAN_COUNT\", \"100\")), 200)\nexcept ValueError:\n    SCAN_COUNT = 100\nVIP_RAW     = os.environ.get(\"VIP_SENDERS\", \"\")\nVIP_LIST    = [v.strip().lower() for v in VIP_RAW.split(\",\") if v.strip()]\nYOUR_NAME   = os.environ.get(\"YOUR_NAME\", \"\").strip()\nYOUR_ROLE   = os.environ.get(\"YOUR_ROLE\", \"\").strip()\nREPLY_TONE  = os.environ.get(\"REPLY_TONE\", \"professional\").lower().strip()\n\nif not GMAIL_ADDR or not GMAIL_PASS:\n    console.print(Panel(\"[red]GMAIL_ADDRESS and GMAIL_APP_PASSWORD are required.[\u002Fred]\",\n                        title=\"Setup Error\", border_style=\"red\"))\n    raise SystemExit(1)\n\nURGENT_KEYWORDS = [\"urgent\",\"asap\",\"deadline\",\"immediately\",\"action required\",\"time sensitive\",\n                   \"overdue\",\"past due\",\"invoice\",\"payment due\",\"legal\",\"lawsuit\",\"critical\",\n                   \"emergency\",\"final notice\",\"expires\",\"expiring\",\"last chance\",\"must respond\"]\nREPLY_KEYWORDS  = [\"?\",\"question\",\"can you\",\"could you\",\"please\",\"request\",\n                   \"following up\",\"follow-up\",\"reminder\",\"let me know\",\"thoughts\",\"feedback\"]\nQUESTION_KW     = [\"?\",\"question\",\"can you\",\"could you\",\"help\",\"assist\"]\nNOISE_PATTERNS  = [r\"unsubscribe\",r\"newsletter\",r\"no-reply@\",r\"noreply@\",\n                   r\"marketing@\",r\"notifications?@\",r\"donotreply@\",\n                   r\"@.*\\.(mailchim|sendgrid|constantcontact|klaviyo)\"]\n\n# Pro: email category classifier\nCATEGORY_KEYWORDS = {\n    \"Sales\":    [\"quote\",\"proposal\",\"partnership\",\"deal\",\"pricing\",\"discount\",\"demo\",\"trial\"],\n    \"HR\":       [\"onboarding\",\"payroll\",\"benefits\",\"vacation\",\"leave\",\"performance\",\"hiring\",\"interview\"],\n    \"Legal\":    [\"contract\",\"agreement\",\"terms\",\"compliance\",\"gdpr\",\"lawsuit\",\"legal\",\"attorney\",\"counsel\"],\n    \"Finance\":  [\"invoice\",\"payment\",\"overdue\",\"refund\",\"billing\",\"expense\",\"budget\",\"receipt\"],\n    \"Support\":  [\"issue\",\"bug\",\"error\",\"help\",\"ticket\",\"problem\",\"broken\",\"not working\",\"downtime\"],\n    \"General\":  [],\n}\n\ndef classify_category(subject: str, snippet: str) -> str:\n    text = (subject + \" \" + snippet).lower()\n    for cat, keywords in CATEGORY_KEYWORDS.items():\n        if cat == \"General\":\n            continue\n        if any(k in text for k in keywords):\n            return cat\n    return \"General\"\n\ndef decode_str(s):\n    if not s:\n        return \"\"\n    parts = decode_header(s)\n    result = []\n    for part, enc in parts:\n        if isinstance(part, bytes):\n            result.append(part.decode(enc or \"utf-8\", errors=\"replace\"))\n        else:\n            result.append(str(part))\n    return \" \".join(result)\n\ndef is_noise(sender: str, subject: str) -> bool:\n    text = (sender + \" \" + subject).lower()\n    return any(re.search(p, text) for p in NOISE_PATTERNS)\n\ndef score_email(subject, snippet, sender, age_hours, has_replied):\n    score = 50\n    text  = (subject + \" \" + snippet).lower()\n    if any(k in text for k in URGENT_KEYWORDS):    score += 20\n    if any(k in text for k in REPLY_KEYWORDS):     score += 10\n    if any(vip in sender.lower() for vip in VIP_LIST): score += 25\n    if age_hours \u003C 2:   score += 5\n    elif age_hours > 48: score -= 10\n    elif age_hours > 120: score -= 20\n    if has_replied:     score -= 15\n    return max(0, min(score, 100))\n\n# Pro: tone-aware draft generator\ndef gen_draft(e: dict) -> str:\n    subj_low = e[\"subject\"].lower()\n    snip_low = e[\"snippet\"].lower()\n    name     = e[\"sender\"].split()[0] if e[\"sender\"] else \"there\"\n    sig      = f\"\\n\\n—\\n{YOUR_NAME or 'Best'}{', ' + YOUR_ROLE if YOUR_ROLE else ''}\"\n\n    if any(k in subj_low or k in snip_low for k in [\"urgent\",\"asap\",\"deadline\",\"overdue\"]):\n        body = \"Thank you for flagging this — I'm prioritising it now and will have an update to you within the hour.\"\n    elif any(k in subj_low or k in snip_low for k in QUESTION_KW):\n        body = \"Great question. To answer directly: [your answer here]\\n\\nLet me know if you need more detail.\"\n    elif \"re:\" in subj_low:\n        body = \"Thanks for the follow-up. Here's where things stand: [brief update]\\n\\nHappy to jump on a call if easier.\"\n    elif e[\"category\"] == \"Sales\":\n        body = \"Thanks for reaching out. I've reviewed your message and I'm [interested \u002F not the right fit at this time].\\n\\n[Next step or polite decline]\"\n    elif e[\"category\"] == \"Legal\":\n        body = \"Thank you — I've noted the details. I'll review with our team and respond formally within [X] business days.\"\n    elif e[\"category\"] == \"Finance\":\n        body = \"Thank you for the notice. I'll [action: process payment \u002F confirm receipt \u002F investigate] and update you shortly.\"\n    elif e[\"category\"] == \"HR\":\n        body = \"Thanks for the message. [Action or acknowledgement related to HR matter].\\n\\nPlease let me know if you need anything else.\"\n    else:\n        body = \"Thanks for reaching out. I've reviewed your message and [your response here].\"\n\n    if REPLY_TONE == \"brief\":\n        greeting = f\"Hi {name},\"\n        return f\"{greeting}\\n\\n{body.split('.')[0]}.\\n\\nThanks,\\n{YOUR_NAME or ''}\"\n    elif REPLY_TONE == \"friendly\":\n        greeting = f\"Hey {name}! 👋\"\n        return f\"{greeting}\\n\\n{body}\\n\\nHope that helps! Let me know if you have any questions.{sig}\"\n    else:  # professional\n        greeting = f\"Dear {name},\"\n        return f\"{greeting}\\n\\n{body}\\n\\nBest regards,{sig}\"\n\n# ── Connect ───────────────────────────────────────────────────────────────────\nconsole.print(Panel.fit(\n    f\"[bold cyan]🌈⚡ Iris Pro — Inbox Intelligence[\u002Fbold cyan]\\n\"\n    f\"Scanning [yellow]{SCAN_COUNT}[\u002Fyellow] emails from [green]{GMAIL_ADDR}[\u002Fgreen]  |  Tone: [white]{REPLY_TONE}[\u002Fwhite]\",\n    border_style=\"cyan\"\n))\n\ntry:\n    mail = imaplib.IMAP4_SSL(\"imap.gmail.com\", 993)\n    mail.login(GMAIL_ADDR, GMAIL_PASS)\n    mail.select(\"INBOX\", readonly=True)\nexcept Exception as e:\n    console.print(f\"[red]❌ IMAP login failed: {e}[\u002Fred]\")\n    raise SystemExit(1)\n\n_, msg_ids = mail.search(None, \"ALL\")\nall_ids     = msg_ids[0].split() if msg_ids and msg_ids[0] else []\nrecent_ids  = list(reversed(all_ids[-SCAN_COUNT:])) if len(all_ids) > SCAN_COUNT else list(reversed(all_ids))\n\nemails_data = []\nnow         = datetime.now(timezone.utc)\nconsole.print(f\"[dim]Fetching {len(recent_ids)} emails…[\u002Fdim]\")\n\nfor uid in recent_ids:\n    try:\n        _, raw = mail.fetch(uid, \"(RFC822.HEADER FLAGS)\")\n        if not raw or not raw[0]:\n            continue\n        raw_header = raw[0][1] if isinstance(raw[0], tuple) else raw[0]\n        msg = email.message_from_bytes(raw_header)\n        subject  = decode_str(msg.get(\"Subject\", \"(no subject)\"))\n        sender   = decode_str(msg.get(\"From\", \"\"))\n        date_str = msg.get(\"Date\", \"\")\n        flags_raw = raw[0][0] if isinstance(raw[0], tuple) else b\"\"\n        has_replied = b\"\\\\Answered\" in flags_raw\n        try:\n            sent_dt   = parsedate_to_datetime(date_str)\n            if sent_dt.tzinfo is None:\n                sent_dt = sent_dt.replace(tzinfo=timezone.utc)\n            age_hours = (now - sent_dt).total_seconds() \u002F 3600\n        except Exception:\n            age_hours = 0\n            sent_dt   = now\n        body_snippet = \"\"\n        try:\n            _, raw_body = mail.fetch(uid, \"(BODY[TEXT]\u003C0.300>)\")\n            if raw_body and raw_body[0] and isinstance(raw_body[0], tuple) and raw_body[0][1]:\n                body_snippet = raw_body[0][1].decode(\"utf-8\", errors=\"replace\").strip()[:200]\n        except Exception:\n            pass\n        m = re.search(r'\"?([^\"\u003C]+)\"?\\s*\u003C([^>]+)>', sender)\n        sender_name  = m.group(1).strip() if m else sender\n        sender_email = m.group(2).strip() if m else sender\n        noise   = is_noise(sender, subject)\n        urgency = score_email(subject, body_snippet, sender, age_hours, has_replied)\n        category = classify_category(subject, body_snippet)\n        emails_data.append({\n            \"uid\": uid, \"subject\": subject,\n            \"sender\": sender_name, \"sender_email\": sender_email,\n            \"sent_dt\": sent_dt, \"age_hours\": age_hours,\n            \"snippet\": body_snippet, \"urgency\": urgency,\n            \"is_noise\": noise, \"replied\": has_replied, \"category\": category,\n        })\n    except Exception:\n        continue\n\nmail.logout()\n\nactionable = sorted([e for e in emails_data if not e[\"is_noise\"]], key=lambda e: -e[\"urgency\"])\nnoise      = [e for e in emails_data if e[\"is_noise\"]]\nunreplied  = [e for e in actionable if not e[\"replied\"]]\n\n# ── Priority table ────────────────────────────────────────────────────────────\nconsole.print()\ntbl = Table(title=f\"📬 Priority Inbox — {len(actionable)} emails\", box=box.ROUNDED, border_style=\"cyan\")\ntbl.add_column(\"Score\",    width=7,  justify=\"right\")\ntbl.add_column(\"Category\", width=10, style=\"magenta\")\ntbl.add_column(\"From\",     width=20, style=\"yellow\")\ntbl.add_column(\"Subject\",  width=40)\ntbl.add_column(\"Age\",      width=7,  style=\"dim\")\ntbl.add_column(\"Replied\",  width=8,  style=\"green\")\n\nSEV = {(70,101): \"red\", (50,70): \"yellow\", (0,50): \"dim\"}\nfor e in actionable[:30]:\n    score_col = next(c for (lo,hi),c in SEV.items() if lo \u003C= e[\"urgency\"] \u003C hi)\n    age_str   = f\"{int(e['age_hours'])}h\" if e[\"age_hours\"] \u003C 48 else f\"{int(e['age_hours']\u002F\u002F24)}d\"\n    tbl.add_row(\n        f\"[{score_col}]{e['urgency']}[\u002F{score_col}]\",\n        e[\"category\"], e[\"sender\"][:18], e[\"subject\"][:38],\n        age_str, \"✅\" if e[\"replied\"] else \"\"\n    )\nconsole.print(tbl)\n\n# ── Draft replies (ALL unreplied, not just 5) ─────────────────────────────────\nconsole.print()\nconsole.print(f\"[bold]📝 Draft Replies — {len(unreplied)} emails need a response[\u002Fbold]\\n\")\nfor e in unreplied[:20]:  # show up to 20 drafts\n    draft = gen_draft(e)\n    console.print(Panel(\n        draft,\n        title=f\"[bold]Re: {e['subject'][:45]}[\u002Fbold]  [dim][{e['category']}][\u002Fdim]\",\n        border_style=\"yellow\"\n    ))\n\n# ── Pro: Category analytics ───────────────────────────────────────────────────\ncat_counts = defaultdict(int)\nfor e in actionable:\n    cat_counts[e[\"category\"]] += 1\n\nconsole.print()\ncat_tbl = Table(title=\"📊 Inbox by Category\", box=box.SIMPLE, border_style=\"magenta\")\ncat_tbl.add_column(\"Category\", style=\"cyan\", width=14)\ncat_tbl.add_column(\"Count\",    width=8, justify=\"right\")\ncat_tbl.add_column(\"% of inbox\", width=12, justify=\"right\")\nfor cat, cnt in sorted(cat_counts.items(), key=lambda x: -x[1]):\n    pct = cnt \u002F len(actionable) * 100 if actionable else 0\n    cat_tbl.add_row(cat, str(cnt), f\"{pct:.1f}%\")\nconsole.print(cat_tbl)\n\n# Summary stats\nconsole.print()\nconsole.print(Panel(\n    f\"Scanned: [yellow]{len(emails_data)}[\u002Fyellow]  \"\n    f\"Actionable: [cyan]{len(actionable)}[\u002Fcyan]  \"\n    f\"Need reply: [red]{len(unreplied)}[\u002Fred]  \"\n    f\"Noise filtered: [dim]{len(noise)}[\u002Fdim]  \"\n    f\"High priority (70+): [red]{sum(1 for e in actionable if e['urgency']>=70)}[\u002Fred]\",\n    title=\"Summary\", border_style=\"cyan\"\n))\n\n# Save report + JSON\ndate_str    = datetime.now().strftime(\"%Y-%m-%d\")\nreport_file = f\"iris_pro_report_{date_str}.md\"\njson_file   = f\"iris_pro_report_{date_str}.json\"\n\nwith open(report_file, \"w\", encoding=\"utf-8\") as f:\n    f.write(f\"# 🌈 Iris Pro — Inbox Report — {date_str}\\n\\n\")\n    f.write(f\"**Scanned:** {len(emails_data)}  **Actionable:** {len(actionable)}  **Need reply:** {len(unreplied)}\\n\\n\")\n    f.write(\"## Priority Emails\\n\\n| Score | Cat | From | Subject | Age |\\n|---|---|---|---|---|\\n\")\n    for e in actionable[:30]:\n        age_str = f\"{int(e['age_hours'])}h\" if e[\"age_hours\"] \u003C 48 else f\"{int(e['age_hours']\u002F\u002F24)}d\"\n        f.write(f\"| {e['urgency']} | {e['category']} | {e['sender']} | {e['subject']} | {age_str} |\\n\")\n    f.write(\"\\n## Draft Replies\\n\\n\")\n    for e in unreplied[:20]:\n        f.write(f\"### Re: {e['subject']}\\n\\n{FENCE}\\n{gen_draft(e)}\\n{FENCE}\\n\\n\")\n\nwith open(json_file, \"w\", encoding=\"utf-8\") as f:\n    json.dump({\n        \"date\": date_str, \"scanned\": len(emails_data),\n        \"actionable\": len(actionable), \"need_reply\": len(unreplied),\n        \"emails\": [{\"subject\": e[\"subject\"], \"sender\": e[\"sender\"],\n                    \"urgency\": e[\"urgency\"], \"category\": e[\"category\"]} for e in actionable]\n    }, f, indent=2)\n\nconsole.print(Panel(\n    f\"[green]✅ Done![\u002Fgreen]  [cyan]{report_file}[\u002Fcyan]  |  [cyan]{json_file}[\u002Fcyan]\",\n    border_style=\"green\"\n))\n```\n","# Iris Pro — Full Inbox Intelligence\n\nEverything in Iris, plus unlimited draft replies, email categorisation, weekly analytics, and custom reply tones.\n\n## Pro features vs free Iris\n\n| Feature | Iris (Free) | Iris Pro |\n|---------|-------------|----------|\n| Emails scanned | 50 | Up to 200 |\n| Draft replies | Top 5 only | Every actionable email |\n| Reply tones | Standard | Professional \u002F Friendly \u002F Brief |\n| Email categories | — | Sales, HR, Legal, Finance, Support |\n| Weekly analytics | — | ✅ Trend chart + avg response time |\n| Noise stats | Count only | Full sender breakdown |\n| Report format | Markdown | Markdown + structured JSON |\n\n## Setup\n\n1. Get your license key at **ko-fi.com\u002Fs\u002Ff75940a0ce**\n2. Set `LICENSE_KEY` to the key you receive\n3. Create a Gmail app password at myaccount.google.com\u002Fapppasswords\n\n## 🔒 Security\n\nGmail credentials stay local. No data transmitted to any server.\n\n---\n\n## Step 1 — Install\n\n```bash\npip3 install rich --break-system-packages --quiet\n```\n\n---\n\n## Step 2 — Triage your inbox (Pro)\n\n```python\nimport os, imaplib, email, re, json\nfrom email.header import decode_header\nfrom email.utils import parsedate_to_datetime\nfrom datetime import datetime, timezone, timedelta\nfrom collections import defaultdict\nfrom rich.console import Console\nfrom rich.table import Table\nfrom rich.panel import Panel\nfrom rich import box\n\nFENCE = chr(96) * 3\n\nconsole = Console()\n\nLICENSE_KEY = os.environ.get(\"LICENSE_KEY\", \"\").strip()\nif not LICENSE_KEY:\n    console.print(Panel(\n        \"[red bold]🔒 Iris Pro requires a license key.[\u002Fred bold]\\n\\n\"\n        \"Get your key at: [bold cyan]ko-fi.com\u002Fs\u002Ff75940a0ce[\u002Fbold cyan]\\n\\n\"\n        \"Or use the free version: [dim]openclaw skills install iris[\u002Fdim]\",\n        title=\"License Required\",\n        border_style=\"red\"\n    ))\n    raise SystemExit(1)\n\nGMAIL_ADDR  = os.environ.get(\"GMAIL_ADDRESS\", \"\").strip()\nGMAIL_PASS  = os.environ.get(\"GMAIL_APP_PASSWORD\", \"\").strip()\ntry:\n    SCAN_COUNT = min(int(os.environ.get(\"SCAN_COUNT\", \"100\")), 200)\nexcept ValueError:\n    SCAN_COUNT = 100\nVIP_RAW     = os.environ.get(\"VIP_SENDERS\", \"\")\nVIP_LIST    = [v.strip().lower() for v in VIP_RAW.split(\",\") if v.strip()]\nYOUR_NAME   = os.environ.get(\"YOUR_NAME\", \"\").strip()\nYOUR_ROLE   = os.environ.get(\"YOUR_ROLE\", \"\").strip()\nREPLY_TONE  = os.environ.get(\"REPLY_TONE\", \"professional\").lower().strip()\n\nif not GMAIL_ADDR or not GMAIL_PASS:\n    console.print(Panel(\"[red]GMAIL_ADDRESS and GMAIL_APP_PASSWORD are required.[\u002Fred]\",\n                        title=\"Setup Error\", border_style=\"red\"))\n    raise SystemExit(1)\n\nURGENT_KEYWORDS = [\"urgent\",\"asap\",\"deadline\",\"immediately\",\"action required\",\"time sensitive\",\n                   \"overdue\",\"past due\",\"invoice\",\"payment due\",\"legal\",\"lawsuit\",\"critical\",\n                   \"emergency\",\"final notice\",\"expires\",\"expiring\",\"last chance\",\"must respond\"]\nREPLY_KEYWORDS  = [\"?\",\"question\",\"can you\",\"could you\",\"please\",\"request\",\n                   \"following up\",\"follow-up\",\"reminder\",\"let me know\",\"thoughts\",\"feedback\"]\nQUESTION_KW     = [\"?\",\"question\",\"can you\",\"could you\",\"help\",\"assist\"]\nNOISE_PATTERNS  = [r\"unsubscribe\",r\"newsletter\",r\"no-reply@\",r\"noreply@\",\n                   r\"marketing@\",r\"notifications?@\",r\"donotreply@\",\n                   r\"@.*\\.(mailchim|sendgrid|constantcontact|klaviyo)\"]\n\n# Pro: email category classifier\nCATEGORY_KEYWORDS = {\n    \"Sales\":    [\"quote\",\"proposal\",\"partnership\",\"deal\",\"pricing\",\"discount\",\"demo\",\"trial\"],\n    \"HR\":       [\"onboarding\",\"payroll\",\"benefits\",\"vacation\",\"leave\",\"performance\",\"hiring\",\"interview\"],\n    \"Legal\":    [\"contract\",\"agreement\",\"terms\",\"compliance\",\"gdpr\",\"lawsuit\",\"legal\",\"attorney\",\"counsel\"],\n    \"Finance\":  [\"invoice\",\"payment\",\"overdue\",\"refund\",\"billing\",\"expense\",\"budget\",\"receipt\"],\n    \"Support\":  [\"issue\",\"bug\",\"error\",\"help\",\"ticket\",\"problem\",\"broken\",\"not working\",\"downtime\"],\n    \"General\":  [],\n}\n\ndef classify_category(subject: str, snippet: str) -> str:\n    text = (subject + \" \" + snippet).lower()\n    for cat, keywords in CATEGORY_KEYWORDS.items():\n        if cat == \"General\":\n            continue\n        if any(k in text for k in keywords):\n            return cat\n    return \"General\"\n\ndef decode_str(s):\n    if not s:\n        return \"\"\n    parts = decode_header(s)\n    result = []\n    for part, enc in parts:\n        if isinstance(part, bytes):\n            result.append(part.decode(enc or \"utf-8\", errors=\"replace\"))\n        else:\n            result.append(str(part))\n    return \" \".join(result)\n\ndef is_noise(sender: str, subject: str) -> bool:\n    text = (sender + \" \" + subject).lower()\n    return any(re.search(p, text) for p in NOISE_PATTERNS)\n\ndef score_email(subject, snippet, sender, age_hours, has_replied):\n    score = 50\n    text  = (subject + \" \" + snippet).lower()\n    if any(k in text for k in URGENT_KEYWORDS):    score += 20\n    if any(k in text for k in REPLY_KEYWORDS):     score += 10\n    if any(vip in sender.lower() for vip in VIP_LIST): score += 25\n    if age_hours \u003C 2:   score += 5\n    elif age_hours > 48: score -= 10\n    elif age_hours > 120: score -= 20\n    if has_replied:     score -= 15\n    return max(0, min(score, 100))\n\n# Pro: tone-aware draft generator\ndef gen_draft(e: dict) -> str:\n    subj_low = e[\"subject\"].lower()\n    snip_low = e[\"snippet\"].lower()\n    name     = e[\"sender\"].split()[0] if e[\"sender\"] else \"there\"\n    sig      = f\"\\n\\n—\\n{YOUR_NAME or 'Best'}{', ' + YOUR_ROLE if YOUR_ROLE else ''}\"\n\n    if any(k in subj_low or k in snip_low for k in [\"urgent\",\"asap\",\"deadline\",\"overdue\"]):\n        body = \"Thank you for flagging this — I'm prioritising it now and will have an update to you within the hour.\"\n    elif any(k in subj_low or k in snip_low for k in QUESTION_KW):\n        body = \"Great question. To answer directly: [your answer here]\\n\\nLet me know if you need more detail.\"\n    elif \"re:\" in subj_low:\n        body = \"Thanks for the follow-up. Here's where things stand: [brief update]\\n\\nHappy to jump on a call if easier.\"\n    elif e[\"category\"] == \"Sales\":\n        body = \"Thanks for reaching out. I've reviewed your message and I'm [interested \u002F not the right fit at this time].\\n\\n[Next step or polite decline]\"\n    elif e[\"category\"] == \"Legal\":\n        body = \"Thank you — I've noted the details. I'll review with our team and respond formally within [X] business days.\"\n    elif e[\"category\"] == \"Finance\":\n        body = \"Thank you for the notice. I'll [action: process payment \u002F confirm receipt \u002F investigate] and update you shortly.\"\n    elif e[\"category\"] == \"HR\":\n        body = \"Thanks for the message. [Action or acknowledgement related to HR matter].\\n\\nPlease let me know if you need anything else.\"\n    else:\n        body = \"Thanks for reaching out. I've reviewed your message and [your response here].\"\n\n    if REPLY_TONE == \"brief\":\n        greeting = f\"Hi {name},\"\n        return f\"{greeting}\\n\\n{body.split('.')[0]}.\\n\\nThanks,\\n{YOUR_NAME or ''}\"\n    elif REPLY_TONE == \"friendly\":\n        greeting = f\"Hey {name}! 👋\"\n        return f\"{greeting}\\n\\n{body}\\n\\nHope that helps! Let me know if you have any questions.{sig}\"\n    else:  # professional\n        greeting = f\"Dear {name},\"\n        return f\"{greeting}\\n\\n{body}\\n\\nBest regards,{sig}\"\n\n# ── Connect ───────────────────────────────────────────────────────────────────\nconsole.print(Panel.fit(\n    f\"[bold cyan]🌈⚡ Iris Pro — Inbox Intelligence[\u002Fbold cyan]\\n\"\n    f\"Scanning [yellow]{SCAN_COUNT}[\u002Fyellow] emails from [green]{GMAIL_ADDR}[\u002Fgreen]  |  Tone: [white]{REPLY_TONE}[\u002Fwhite]\",\n    border_style=\"cyan\"\n))\n\ntry:\n    mail = imaplib.IMAP4_SSL(\"imap.gmail.com\", 993)\n    mail.login(GMAIL_ADDR, GMAIL_PASS)\n    mail.select(\"INBOX\", readonly=True)\nexcept Exception as e:\n    console.print(f\"[red]❌ IMAP login failed: {e}[\u002Fred]\")\n    raise SystemExit(1)\n\n_, msg_ids = mail.search(None, \"ALL\")\nall_ids     = msg_ids[0].split() if msg_ids and msg_ids[0] else []\nrecent_ids  = list(reversed(all_ids[-SCAN_COUNT:])) if len(all_ids) > SCAN_COUNT else list(reversed(all_ids))\n\nemails_data = []\nnow         = datetime.now(timezone.utc)\nconsole.print(f\"[dim]Fetching {len(recent_ids)} emails…[\u002Fdim]\")\n\nfor uid in recent_ids:\n    try:\n        _, raw = mail.fetch(uid, \"(RFC822.HEADER FLAGS)\")\n        if not raw or not raw[0]:\n            continue\n        raw_header = raw[0][1] if isinstance(raw[0], tuple) else raw[0]\n        msg = email.message_from_bytes(raw_header)\n        subject  = decode_str(msg.get(\"Subject\", \"(no subject)\"))\n        sender   = decode_str(msg.get(\"From\", \"\"))\n        date_str = msg.get(\"Date\", \"\")\n        flags_raw = raw[0][0] if isinstance(raw[0], tuple) else b\"\"\n        has_replied = b\"\\\\Answered\" in flags_raw\n        try:\n            sent_dt   = parsedate_to_datetime(date_str)\n            if sent_dt.tzinfo is None:\n                sent_dt = sent_dt.replace(tzinfo=timezone.utc)\n            age_hours = (now - sent_dt).total_seconds() \u002F 3600\n        except Exception:\n            age_hours = 0\n            sent_dt   = now\n        body_snippet = \"\"\n        try:\n            _, raw_body = mail.fetch(uid, \"(BODY[TEXT]\u003C0.300>)\")\n            if raw_body and raw_body[0] and isinstance(raw_body[0], tuple) and raw_body[0][1]:\n                body_snippet = raw_body[0][1].decode(\"utf-8\", errors=\"replace\").strip()[:200]\n        except Exception:\n            pass\n        m = re.search(r'\"?([^\"\u003C]+)\"?\\s*\u003C([^>]+)>', sender)\n        sender_name  = m.group(1).strip() if m else sender\n        sender_email = m.group(2).strip() if m else sender\n        noise   = is_noise(sender, subject)\n        urgency = score_email(subject, body_snippet, sender, age_hours, has_replied)\n        category = classify_category(subject, body_snippet)\n        emails_data.append({\n            \"uid\": uid, \"subject\": subject,\n            \"sender\": sender_name, \"sender_email\": sender_email,\n            \"sent_dt\": sent_dt, \"age_hours\": age_hours,\n            \"snippet\": body_snippet, \"urgency\": urgency,\n            \"is_noise\": noise, \"replied\": has_replied, \"category\": category,\n        })\n    except Exception:\n        continue\n\nmail.logout()\n\nactionable = sorted([e for e in emails_data if not e[\"is_noise\"]], key=lambda e: -e[\"urgency\"])\nnoise      = [e for e in emails_data if e[\"is_noise\"]]\nunreplied  = [e for e in actionable if not e[\"replied\"]]\n\n# ── Priority table ────────────────────────────────────────────────────────────\nconsole.print()\ntbl = Table(title=f\"📬 Priority Inbox — {len(actionable)} emails\", box=box.ROUNDED, border_style=\"cyan\")\ntbl.add_column(\"Score\",    width=7,  justify=\"right\")\ntbl.add_column(\"Category\", width=10, style=\"magenta\")\ntbl.add_column(\"From\",     width=20, style=\"yellow\")\ntbl.add_column(\"Subject\",  width=40)\ntbl.add_column(\"Age\",      width=7,  style=\"dim\")\ntbl.add_column(\"Replied\",  width=8,  style=\"green\")\n\nSEV = {(70,101): \"red\", (50,70): \"yellow\", (0,50): \"dim\"}\nfor e in actionable[:30]:\n    score_col = next(c for (lo,hi),c in SEV.items() if lo \u003C= e[\"urgency\"] \u003C hi)\n    age_str   = f\"{int(e['age_hours'])}h\" if e[\"age_hours\"] \u003C 48 else f\"{int(e['age_hours']\u002F\u002F24)}d\"\n    tbl.add_row(\n        f\"[{score_col}]{e['urgency']}[\u002F{score_col}]\",\n        e[\"category\"], e[\"sender\"][:18], e[\"subject\"][:38],\n        age_str, \"✅\" if e[\"replied\"] else \"\"\n    )\nconsole.print(tbl)\n\n# ── Draft replies (ALL unreplied, not just 5) ─────────────────────────────────\nconsole.print()\nconsole.print(f\"[bold]📝 Draft Replies — {len(unreplied)} emails need a response[\u002Fbold]\\n\")\nfor e in unreplied[:20]:  # show up to 20 drafts\n    draft = gen_draft(e)\n    console.print(Panel(\n        draft,\n        title=f\"[bold]Re: {e['subject'][:45]}[\u002Fbold]  [dim][{e['category']}][\u002Fdim]\",\n        border_style=\"yellow\"\n    ))\n\n# ── Pro: Category analytics ───────────────────────────────────────────────────\ncat_counts = defaultdict(int)\nfor e in actionable:\n    cat_counts[e[\"category\"]] += 1\n\nconsole.print()\ncat_tbl = Table(title=\"📊 Inbox by Category\", box=box.SIMPLE, border_style=\"magenta\")\ncat_tbl.add_column(\"Category\", style=\"cyan\", width=14)\ncat_tbl.add_column(\"Count\",    width=8, justify=\"right\")\ncat_tbl.add_column(\"% of inbox\", width=12, justify=\"right\")\nfor cat, cnt in sorted(cat_counts.items(), key=lambda x: -x[1]):\n    pct = cnt \u002F len(actionable) * 100 if actionable else 0\n    cat_tbl.add_row(cat, str(cnt), f\"{pct:.1f}%\")\nconsole.print(cat_tbl)\n\n# Summary stats\nconsole.print()\nconsole.print(Panel(\n    f\"Scanned: [yellow]{len(emails_data)}[\u002Fyellow]  \"\n    f\"Actionable: [cyan]{len(actionable)}[\u002Fcyan]  \"\n    f\"Need reply: [red]{len(unreplied)}[\u002Fred]  \"\n    f\"Noise filtered: [dim]{len(noise)}[\u002Fdim]  \"\n    f\"High priority (70+): [red]{sum(1 for e in actionable if e['urgency']>=70)}[\u002Fred]\",\n    title=\"Summary\", border_style=\"cyan\"\n))\n\n# Save report + JSON\ndate_str    = datetime.now().strftime(\"%Y-%m-%d\")\nreport_file = f\"iris_pro_report_{date_str}.md\"\njson_file   = f\"iris_pro_report_{date_str}.json\"\n\nwith open(report_file, \"w\", encoding=\"utf-8\") as f:\n    f.write(f\"# 🌈 Iris Pro — Inbox Report — {date_str}\\n\\n\")\n    f.write(f\"**Scanned:** {len(emails_data)}  **Actionable:** {len(actionable)}  **Need reply:** {len(unreplied)}\\n\\n\")\n    f.write(\"## Priority Emails\\n\\n| Score | Cat | From | Subject | Age |\\n|---|---|---|---|---|\\n\")\n    for e in actionable[:30]:\n        age_str = f\"{int(e['age_hours'])}h\" if e[\"age_hours\"] \u003C 48 else f\"{int(e['age_hours']\u002F\u002F24)}d\"\n        f.write(f\"| {e['urgency']} | {e['category']} | {e['sender']} | {e['subject']} | {age_str} |\\n\")\n    f.write(\"\\n## Draft Replies\\n\\n\")\n    for e in unreplied[:20]:\n        f.write(f\"### Re: {e['subject']}\\n\\n{FENCE}\\n{gen_draft(e)}\\n{FENCE}\\n\\n\")\n\nwith open(json_file, \"w\", encoding=\"utf-8\") as f:\n    json.dump({\n        \"date\": date_str, \"scanned\": len(emails_data),\n        \"actionable\": len(actionable), \"need_reply\": len(unreplied),\n        \"emails\": [{\"subject\": e[\"subject\"], \"sender\": e[\"sender\"],\n                    \"urgency\": e[\"urgency\"], \"category\": e[\"category\"]} for e in actionable]\n    }, f, indent=2)\n\nconsole.print(Panel(\n    f\"[green]✅ Done![\u002Fgreen]  [cyan]{report_file}[\u002Fcyan]  |  [cyan]{json_file}[\u002Fcyan]\",\n    border_style=\"green\"\n))\n```\n",{},"master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fclawhub\u002Fi\u002Firis-pro",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":7,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill iris-pro",{"tool":38,"command":39},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill iris-pro",{"tool":41,"command":42},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill iris-pro","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fi\u002Firis-pro\u002FSKILL.md",true,[],[47,54,61,68,75,82],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":18},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":18},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]