"""Droplet.ai's Agentic Widget library: each entry is a job an agent runs on the user's phone,
not a picture. The widget is a sample; the guide is how the agent runs it for real.
Run: python3 library/build.py  -> library/library.json and library/README.md"""
import json, os
HERE = os.path.dirname(os.path.abspath(__file__))

def btn(id, label, symbol, url=None):
    b = {"id": id, "label": label, "symbol": symbol}
    if url: b["url"] = url
    return b

L = []
def add(**t): L.append(t)

def todo_blocks(items):
    return [
        {"type": "gauge", "label": "Done", "count": "checked"},
        {"type": "checklist", "items": items},
        {"type": "buttons", "items": [btn("tell", "Tell me more", "text.bubble.fill"), btn("handle", "Do one for me", "sparkles")]},
    ]

add(id="smart-todo", title="Smart to-do", category="Daily",
    tagline="A to-do list that knows where you are, what time it is, and what you meant to do.",
    does=["Shows only what you can do here and now: work things at work, errands when you're out, home things in the evening",
          "Learns from you: tell it more and the list gets better; your daily routines come back by themselves",
          "Does the ones it can (book, order, reply) after your OK, and asks you the one question that matters"],
    uses=["location", "calendar", "reminders"], agents="Any agent; it does more with email, calendar and a browser",
    widget={"slug": "smart-todo", "title": "To do", "subtitle": "By deadline", "symbol": "checklist", "accent": "#5E5CE6",
            "blocks": todo_blocks(["Pay rent (due Fri)", "Sign Sam's contract", "Send Q4 plan", "Reply to the landlord", "Renew passport"]),
            "variants": [
                {"when": {"from": "06:00", "to": "09:30"}, "title": "This morning", "subtitle": "Before you leave",
                 "blocks": todo_blocks(["Sign Sam's contract", "Bring the charger", "Reply to the landlord", "Leave by 8:40"])},
                {"when": {"place": "work"}, "title": "At work", "subtitle": "3 only you can do",
                 "blocks": todo_blocks(["Send Q4 plan to Maya", "Review Sam's deck", "Book 1:1 with Sam", "Expense the Uber"])},
                {"when": {"place": "away"}, "title": "Out and about", "subtitle": "Near you",
                 "blocks": todo_blocks(["Pharmacy: refill ready", "Post the signed forms", "Pick up the keys", "Buy a gift for Maya"])},
                {"when": {"from": "18:00", "to": "23:00", "place": "home"}, "title": "Tonight", "subtitle": "At home",
                 "blocks": todo_blocks(["Pay rent (due Fri)", "Call Mom", "Read Sam's deck", "Approve tomorrow's plan"])},
            ],
            "sizes": {"small": [0], "medium": [0, 1], "large": [0, 1, 2]},
            "lock": {"inline": "To do: 5 things", "circular": 0}},
    guide={"goal": "A to-do list the user never has to manage: the right things at the right place and time, getting smarter every time they tell it something, with the agent doing what it can.",
           "data": [
               "Everything you know about the user: what they asked you to remember, recent conversations, their projects, people and habits.",
               "Phone context (droplet_get_phone_context): place (home, work, away), local time, today's calendar, due reminders, health. Read it before every rewrite.",
               "Deadlines and commitments from email and calendar (bills, renewals, replies owed, events to prepare for).",
               "Daily routines: things the user does every day or week (vitamins, plants, gym bag, recycling night). Keep them in your memory and bring them back each day.",
               "Every item belongs to a context: anywhere, morning, work, away (errands, with the nearest first) or evening at home. Put it in that version, at most 5 per version, most important first.",
           ],
           "refresh": "Rewrite all versions at the first session of each day (reset_checklists: true, carry over what's not done, add today's routines), whenever the user tells you something new, and after each tick (move the next item up, add what follows from it). The phone switches versions by place and time on its own, with no agent running, so the list stays right between your sessions. Don't install anything on the user's computer to run at 6:00.",
           "taps": {"tell": "droplet_ask kind input: \"What else is on your mind?\" Turn the answer into items (split it, give each a context and a deadline), ask one follow-up only if the answer is ambiguous, then update the widget and say what you added.",
                    "handle": "Pick the top unticked item you can do yourself (book, order, reply, schedule, research). droplet_ask decision naming exactly what you'll do (\"Book the dentist for Tue 10:00?\"). On yes do it, tick it on the widget, and show the result in the note line."},
           "ask": "Before acting on any item (booking, buying, messaging). And ask the right questions (see below), one at a time.",
           "questions": [
               "Ask only when the answer changes what you do, one question at a time, on the widget (droplet_ask), never a form.",
               "No deadline on something that has one in real life (rent, passport, tax): \"When is the rent due?\" (choice: this Fri / 1st of the month / other).",
               "Not sure where an item belongs: \"Do this at work or at home?\" (choice).",
               "An item you could do yourself: \"Want me to book the dentist?\" (decision). Ask once per item, remember a no.",
               "Something repeats: after the user ticks the same item three days in a row, ask \"Add 'Take vitamins' every morning?\" (decision).",
               "Vague items (\"sort out car\"): \"What does the car need?\" (choice: service / insurance / MOT or inspection / other).",
               "An item has sat for a week: \"Still want 'Renew passport'?\" (choice: keep / move to next week / drop).",
               "Never ask what you can find out (calendar, email, phone context) and never ask more than one question per hour unless the user is answering.",
           ],
           "phone": "reminder for items with a time (droplet_phone_action reminder) when the user wants one; alarm for wake-ups only if asked.",
           "never": "Never more than 5 items in a version. Never untick what the user ticked. Never act on an item without a yes."})

add(id="leave-by", title="Leave by", category="Daily",
    tagline="Your next place, when to leave, and a ride one tap away.",
    does=["Shows your next event with a place, on a map, and when to leave", "Books the ride or tells people you're late when you tap", "Changes on its own as the day goes on"],
    uses=["calendar", "location"], agents="Any agent; booking needs one with a ride app or browser",
    widget={"slug": "leave-by", "title": "Next", "subtitle": "Dr. Lee · 3:00", "symbol": "car.fill", "accent": "#FF9F0A",
            "blocks": [
                {"type": "metric", "label": "Dr. Lee", "value": "3:00"},
                {"type": "countdown", "label": "Leave in", "to": "2030-01-01T08:40:00+00:00", "style": "relative"},
                {"type": "map", "lat": 40.6865, "lon": -73.9937, "label": "210 Court St", "span": 900},
                {"type": "buttons", "items": [btn("ride", "Book a ride", "car.fill"), btn("late", "Running late", "clock.badge.exclamationmark")]}],
            "sizes": {"small": [1], "medium": [0, 1, 3], "large": [1, 2, 3]},
            "lock": {"inline": "Leave 2:35 for Dr. Lee"}},
    guide={"goal": "The user never has to work out when to leave or how to get there.",
           "data": ["Next calendar event that has a location (droplet_get_phone_context: calendar).", "Travel time from the phone's place/city to that address (your maps tool, or 20 min in a city as a fallback). Leave-by = start minus travel minus 5 min.", "map block: geocode the address; never show raw coordinates."],
           "refresh": "When the next event changes, after it starts, and every 30 min on travel days (droplet_schedule or your own loop). The countdown ticks on the phone by itself.",
           "taps": {"ride": "Get a price and ETA from the user's ride app or browser, then droplet_ask 'Book an Uber XL, $24, pickup 2:32?' (decision). Only book on yes. Put the driver and ETA on the widget.",
                    "late": "Draft 'Running 10 min late' to the event's organiser, droplet_ask to send it (decision, name the recipient). Send only on yes, then show 'Told Dr. Lee's office' on the widget."},
           "ask": "Every booking and every message: approval first, naming the price or the recipient.",
           "phone": "None needed. Optional: a 'Leave now' notification only if the user asked for one.",
           "never": "Never book or message without the user's yes. Never show an event without a location here."})

add(id="approvals", title="Approvals", category="Work",
    tagline="Your agent asks before it ships. You approve from the Home Screen.",
    does=["Shows what your agent wants to do next, with the exact change", "Approve or hold with one tap", "Keeps a short log of what went out"],
    uses=[], agents="Coding agents (Claude Code, Codex, Cursor) and any agent that deploys, sends or spends",
    widget={"slug": "approvals", "title": "Ship v2.4?", "symbol": "checkmark.shield.fill", "accent": "#30D158",
            "blocks": [
                {"type": "metric", "label": "Tests", "value": "412/412", "trend": "up"},
                {"type": "text", "text": "6 commits: checkout fix, pricing", "style": "body"},
                {"type": "buttons", "items": [btn("approve", "Deploy", "paperplane.fill"), btn("hold", "Hold", "pause.fill")]},
                {"type": "list", "title": "Recently", "items": [{"title": "v2.3 deployed", "detail": "Tue"}, {"title": "Migration 042 run", "detail": "Mon"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]}},
    guide={"goal": "Nothing consequential happens without a tap, and the user never has to watch a terminal.",
           "data": ["The exact action you're about to take: what, where, how big (commits, files, amount, recipients).", "Evidence that it's safe: tests, build status, a diff summary."],
           "refresh": "Each time you reach a consequential step. Between steps show the last result.",
           "taps": {"approve": "Do exactly the action shown, nothing more. Update the widget to 'Deploying…' then the result ('v2.4 is live') with a link button to it.",
                    "hold": "Don't act. Show 'Held. I'll wait for you' and ask in chat or with droplet_ask what to change."},
           "ask": "For money use two steps (a button, then droplet_ask with risk high naming the amount). For anything irreversible name the target exactly.",
           "phone": "None.",
           "never": "Never act on an old approval after the action changed; ask again."})

add(id="ship-status", title="Ship status", category="Work",
    tagline="Builds, failing tests and the fix, all one tap from your agent.",
    does=["Shows if main is green, what broke and who it affects", "Tap to have your agent fix, re-run or revert", "Turns green again on its own when it's fixed"],
    uses=[], agents="Coding agents with repo and CI access",
    widget={"slug": "ship-status", "title": "main", "symbol": "hammer.fill", "accent": "#FF453A",
            "blocks": [
                {"type": "metric", "label": "Build", "value": "Failing", "trend": "down"},
                {"type": "text", "text": "Tax off by 1¢ on EUR carts", "style": "body"},
                {"type": "buttons", "items": [btn("fix", "Fix it", "wrench.and.screwdriver.fill"), btn("rerun", "Re-run", "arrow.clockwise"), btn("revert", "Revert", "arrow.uturn.backward")]},
                {"type": "list", "title": "Last runs", "items": [{"title": "a41c9 checkout rounding", "detail": "failed"}, {"title": "9f02e pricing page", "detail": "passed"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]}},
    guide={"goal": "The user knows the state of their code at a glance and can unblock it without opening a laptop.",
           "data": ["CI status of the default branch (gh run list, your CI API).", "The first failing test and a one-line cause you found by reading the log.", "Recent runs with their commit message."],
           "refresh": "On every CI run finishing (webhook or poll every 5 min while red), and when your fix lands.",
           "taps": {"fix": "Investigate and fix on a branch, run the tests, then show 'Fix ready: PR #212' with a 'Merge' button. Merging is consequential: approval first.",
                    "rerun": "Re-run the failed job, show 'Re-running…', then the result.",
                    "revert": "Prepare the revert of the culprit commit, then droplet_ask 'Revert a41c9 on main?' before pushing."},
           "ask": "Before merging, pushing to main or reverting.",
           "phone": "None.",
           "never": "Never push to the default branch without a yes."})

add(id="inbox-zero", title="Needs a reply", category="Work",
    tagline="Your agent drafts the replies. You tap send.",
    does=["Shows the few emails that really need you", "Each one has a reply already drafted", "Send, edit later or snooze with one tap"],
    uses=[], agents="Agents with email access (Gmail, Outlook)",
    widget={"slug": "inbox-zero", "title": "Needs a reply", "symbol": "envelope.badge.fill", "accent": "#0A84FF",
            "blocks": [
                {"type": "metric", "label": "Waiting", "value": "3"},
                {"type": "text", "text": "Maya: move Thursday? Reply ready.", "style": "body"},
                {"type": "buttons", "items": [btn("send", "Send draft", "paperplane.fill"), btn("next", "Next", "chevron.right"), btn("snooze", "Tomorrow", "moon.fill")]},
                {"type": "list", "title": "Also waiting", "items": [{"title": "Landlord: lease renewal", "detail": "2d"}, {"title": "Sam: deck feedback", "detail": "5h"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]}},
    guide={"goal": "Inbox triage happens on the Home Screen in seconds.",
           "data": ["Unread or flagged threads from real people that ask the user something (skip newsletters and receipts).", "A short draft reply in the user's voice for the top one."],
           "refresh": "Every 15 min during the user's working hours, and after each tap.",
           "taps": {"send": "Sending is outward facing. The user tapped a button that names it, so send exactly the draft shown, then show the next email.",
                    "next": "Show the next waiting email with its draft.",
                    "snooze": "Hide that thread until tomorrow 9:00 (keep a note), show the next one."},
           "ask": "If the draft would commit to money, dates far out or anything legal, droplet_ask with the full draft in details instead of the one-tap send.",
           "phone": "None.",
           "never": "Never send anything that isn't exactly what the widget showed."})

add(id="meeting-prep", title="Meeting prep", category="Work",
    tagline="Before every meeting: who, why, and your notes ready.",
    does=["Your next meeting with a countdown", "Prep notes your agent wrote from email and docs", "Join, or tell them you're late, in one tap"],
    uses=["calendar"], agents="Agents with calendar and email or docs access",
    widget={"slug": "meeting-prep", "title": "Next meeting", "symbol": "person.2.fill", "accent": "#5E5CE6",
            "blocks": [
                {"type": "metric", "label": "Design review", "value": "3:00"},
                {"type": "text", "text": "Decide: ship onboarding Nov 12?", "style": "body"},
                {"type": "buttons", "items": [btn("join", "Join", "video.fill", "https://meet.google.com/"), btn("late", "5 min late", "clock.fill")]},
                {"type": "list", "title": "Notes", "items": [{"title": "Step 3 drop-off: 38%"}, {"title": "Sam's deck v4 (link)"}, {"title": "Decide: ship Nov 12?"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 3, 2]}},
    guide={"goal": "The user walks into every meeting prepared, with no prep time.",
           "data": ["Next meeting from the calendar (attendees, video link).", "Two lines of context from recent email, docs and your notes.", "The decision they need to make."],
           "refresh": "30 min before each meeting, and when it ends (switch to the next one).",
           "taps": {"late": "Draft 'Running 5 min late' to the attendees and droplet_ask to send it (name them). Send on yes."},
           "ask": "Before messaging attendees.",
           "phone": "None.",
           "never": "Put the real video link in the Join button url (https)."})

add(id="agent-at-work", title="Agent at work", category="Work",
    tagline="What your agent is doing right now, and the result when it's done.",
    does=["Live progress of a long task: research, a refactor, a report", "The result the moment it's done", "Go deeper or stop with one tap"],
    uses=[], agents="Any agent running long tasks",
    widget={"slug": "agent-at-work", "title": "Competitor scan", "symbol": "sparkles", "accent": "#5E5CE6",
            "blocks": [
                {"type": "metric", "label": "Sites checked", "value": "7/12"},
                {"type": "text", "text": "2 rivals cut prices 20%", "style": "body"},
                {"type": "buttons", "items": [btn("summary", "Summary", "doc.text.fill"), btn("deeper", "Dig deeper", "magnifyingglass"), btn("stop", "Stop", "stop.fill")]},
                {"type": "progress", "label": "Scan", "value": 0.58},
                {"type": "list", "title": "Found so far", "items": [{"title": "Acme: Pro plan now $39", "detail": "-20%"}, {"title": "Bolt: free tier added"}, {"title": "Kite: new AI add-on, $10"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 3, 4, 2]}},
    guide={"goal": "The user can leave the computer while you work, and see the outcome on their phone.",
           "data": ["Your own progress: steps done / total, the most important finding so far."],
           "refresh": "At start, at each milestone, at the end (the result with a link or the key numbers), and when blocked (what you need).",
           "taps": {"summary": "Put the summary where they can read it (a doc link as the button url next time) and show the top three findings on the widget.",
                    "deeper": "droplet_ask choice with 2-3 directions to dig into, then continue.",
                    "stop": "Stop the task, show what you had so far."},
           "ask": "When you're blocked, the question goes here (droplet_ask), not in a chat they're not watching.",
           "phone": "None.",
           "never": "Never leave it on a stale 'Working…'; show the last real state."})

add(id="schedule-clash", title="Calendar clash", category="Right now",
    tagline="Two things landed at the same time. Your agent found the fix; you tap it.",
    does=["Spots overlaps as soon as a new invite lands", "Checks who can move and offers the one fix that works", "Moves the meeting and tells people after your tap"],
    uses=["calendar"], agents="Agents with calendar and email access",
    widget={"slug": "schedule-clash", "title": "Clash at 3:00", "symbol": "calendar.badge.exclamationmark", "accent": "#FF9F0A",
            "blocks": [
                {"type": "metric", "label": "Overlap", "value": "30 min"},
                {"type": "text", "text": "Design review and Sam's 1:1. Sam is free at 4.", "style": "body"},
                {"type": "buttons", "items": [btn("move", "Move Sam", "arrow.right.circle.fill"), btn("decline", "Decline", "xmark"), btn("keep", "Keep", "checkmark")]},
                {"type": "list", "title": "The two meetings", "items": [{"title": "Design review", "detail": "3:00, 6 people"}, {"title": "1:1 with Sam", "detail": "3:00, moves to 4:00"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]}},
    guide={"goal": "A clash gets fixed in one tap, before anyone has to ask about it.",
           "data": ["Today's and tomorrow's events (calendar connector, or Phone access).", "Each attendee's free time, if your calendar tool has it.", "Which meeting is easier to move: fewer people, recurring, or you own it."],
           "refresh": "When a new invite lands, and each morning. Go back to your last widget when it's solved.",
           "taps": {"move": "Move the meeting to the time shown, tell the other person, then show 'Moved. Sam's fine with 4:00'.", "decline": "Decline the meeting named, with a short note, and show the result.", "keep": "Do nothing. Don't bring this clash up again."},
           "ask": "Before writing to more than one or two people.",
           "phone": "Add the new time with a phone action only if you have no calendar connector.",
           "never": "Never move a meeting you don't own without telling the owner."})

add(id="early-start", title="Early tomorrow", category="Right now",
    tagline="An early start tomorrow? Your agent worked out the alarm. One tap sets it.",
    does=["Reads tomorrow's first commitment and how long you need to get there", "Works out the alarm time for you", "Sets a real iPhone alarm when you tap"],
    uses=["calendar"], agents="Any agent, with Calendar and Alarms on in Phone access",
    widget={"slug": "early-start", "title": "Early tomorrow", "symbol": "alarm.fill", "accent": "#BF5AF2",
            "blocks": [
                {"type": "metric", "label": "First thing", "value": "8:00"},
                {"type": "text", "text": "Board prep. I'd wake you at 6:45.", "style": "body"},
                {"type": "buttons", "items": [btn("set", "Set 6:45", "alarm.fill"), btn("later", "No alarm", "xmark")]},
                {"type": "list", "title": "Tomorrow", "items": [{"title": "Board prep", "detail": "8:00"}, {"title": "Notes are ready", "detail": "in your inbox"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]}},
    guide={"goal": "The user never has to work out tomorrow's alarm.",
           "data": ["Tomorrow's first event (Phone access calendar, or your calendar connector).", "Travel time if it's somewhere else, and how long they usually need in the morning (ask once)."],
           "refresh": "In the evening, only on days with an earlier start than usual. Otherwise this moment doesn't show.",
           "taps": {"set": "Set the alarm with droplet_phone_action, then show 'Alarm set for 6:45'.", "later": "Do nothing, and show the next thing that matters."},
           "ask": "Nothing: the tap is the approval, because an alarm is easy to undo.",
           "phone": "kind alarm, once, at the time shown.",
           "never": "Never set an alarm the user didn't tap for."})

add(id="only-you", title="Only you can do", category="Coding approvals",
    tagline="Your agent hit something it can't do. It lists exactly what it needs and carries on when you tick it.",
    does=["Lists only the steps an agent can't do itself: sign-ins, agreements, payment details", "Keeps going on everything else while it waits", "Picks the work back up the moment you tick"],
    uses=[], agents="Coding and browser agents on long tasks",
    widget={"slug": "only-you", "title": "Only you can do", "subtitle": "Release v2.4", "symbol": "person.fill.checkmark", "accent": "#5E5CE6",
            "blocks": [
                {"type": "gauge", "label": "Done", "count": "checked"},
                {"type": "checklist", "items": ["Accept Apple agreement", "Sign in to Google Cloud", "Add the card for Stripe"]},
                {"type": "buttons", "items": [btn("resume", "Carry on", "play.fill"), btn("later", "Tomorrow", "moon.fill")]}],
            "sizes": {"small": [0], "medium": [0, 1], "large": [0, 1, 2]},
            "lock": {"inline": "3 things only you can do", "circular": 0}},
    guide={"goal": "A blocked agent never sits silent: the user sees exactly what's needed and the work resumes on its own.",
           "data": ["The human-only steps you actually hit: logins, one-time codes, agreements, captchas, payment details, physical things.", "A link for each step where you have one (put it on the matching list row or in chat)."],
           "refresh": "As soon as you get blocked, and whenever a step clears. Tell the user what's still running in the subtitle.",
           "taps": {"resume": "Check each ticked step really worked, then carry on and switch the widget back to progress.", "later": "Stop asking, keep doing what doesn't need these, and bring it back tomorrow morning."},
           "ask": "Nothing extra: these are things the user does themselves.",
           "phone": "Send one notification when you first get blocked, if Notifications is on.",
           "never": "Never ask the user to send you a password, code or card number. They do the step themselves."})

add(id="your-call", title="Your call", category="Coding approvals",
    tagline="Your agent reached a fork. It did the thinking, and you pick the direction from your phone.",
    does=["Stops only at decisions that change the outcome", "Lays out two or three real options with the cost of each", "Carries on the moment you pick"],
    uses=[], agents="Coding agents and any agent on long tasks",
    widget={"slug": "your-call", "title": "Your call", "subtitle": "Login bug", "symbol": "arrow.triangle.branch", "accent": "#0A84FF",
            "blocks": [
                {"type": "metric", "label": "My pick", "value": "Patch"},
                {"type": "text", "text": "A 12-line patch ships today. A rewrite takes 2 days.", "style": "body"},
                {"type": "buttons", "items": [{"id": "a", "label": "Patch"}, {"id": "b", "label": "Rewrite"}, {"id": "c", "label": "Both"}]},
                {"type": "list", "title": "The options", "items": [{"title": "Patch: fixes this bug only", "detail": "today"}, {"title": "Rewrite: fixes the cause", "detail": "2 days"}, {"title": "Both: patch, then rewrite", "detail": "this week"}]}],
            "sizes": {"small": [0], "medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Your call: patch or rewrite", "circular": 0}},
    guide={"goal": "The agent keeps moving without guessing on the decisions that are the user's to make.",
           "data": ["The options you really considered, with what each one costs.", "Your recommendation, first."],
           "refresh": "When you reach the fork. Switch back to progress as soon as they pick.",
           "taps": {"a": "Do option A and show progress.", "b": "Do option B and show progress.", "c": "Do option C and show progress."},
           "ask": "Nothing extra unless the option itself is consequential (a deploy, money, deleting): then approval as well.",
           "phone": "None.",
           "never": "Never stop here for choices you could safely make yourself. Too many forks and the user stops looking."})

add(id="pr-review", title="PR review", category="Coding approvals",
    tagline="Your agent read the pull request. You get the verdict and merge with a tap.",
    does=["Reads each PR, the diff and the tests before you see it", "Gives you the risk and what changed in one line", "Merges or asks for changes after your tap"],
    uses=[], agents="Coding agents with repo access",
    widget={"slug": "pr-review", "title": "PR #212", "symbol": "arrow.triangle.pull", "accent": "#30D158",
            "blocks": [
                {"type": "metric", "label": "Risk", "value": "Low"},
                {"type": "text", "text": "Adds webhook retries. Tests pass. Looks right to me.", "style": "body"},
                {"type": "buttons", "items": [btn("merge", "Merge", "arrow.triangle.merge"), btn("changes", "Changes", "text.bubble.fill"), btn("next", "Next", "chevron.right")]},
                {"type": "list", "title": "Also waiting", "items": [{"title": "#218 Billing page copy", "detail": "low"}, {"title": "#220 Auth session change", "detail": "read this"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "3 PRs need you", "circular": 0}},
    guide={"goal": "Review stops being what holds the team up, without anything risky slipping through.",
           "data": ["Open PRs waiting on the user (gh pr list, your Git host's API).", "Your own read of the diff, the tests and CI.", "A real risk call: anything touching auth, money or data is never Low."],
           "refresh": "When a PR is opened or updated, or every hour in working hours.",
           "taps": {"merge": "Merge exactly this PR if nothing changed since you read it, then show the next one.", "changes": "Ask what to change with droplet_ask (input), post the review, then show the next one.", "next": "Show the next PR. Keep this one in the list."},
           "ask": "If the PR changed after your read, ask again rather than merging.",
           "phone": "None.",
           "never": "Never merge a High risk PR from a single tap: use droplet_ask with risk high and name it."})

add(id="incident", title="Production issue", category="Coding approvals",
    tagline="Something broke in production. Your agent already looked, and offers the fix.",
    does=["Notices the spike from your error tracker or logs", "Works out what changed and how many people it hits", "Rolls back or digs in after your tap"],
    uses=[], agents="Agents with access to your error tracker, logs and deploys",
    widget={"slug": "incident", "title": "Errors up 6x", "symbol": "exclamationmark.triangle.fill", "accent": "#FF453A",
            "blocks": [
                {"type": "metric", "label": "Errors a minute", "value": "84", "trend": "up"},
                {"type": "text", "text": "Checkout only, since the 14:02 deploy. Rollback is safe.", "style": "body"},
                {"type": "buttons", "items": [btn("rollback", "Roll back", "arrow.uturn.backward"), btn("dig", "Look into it", "magnifyingglass"), btn("ignore", "Ignore", "bell.slash.fill")]},
                {"type": "list", "title": "What I found", "items": [{"title": "TypeError in cart total", "detail": "1,204 times"}, {"title": "Deploy a41c9 at 14:02", "detail": "likely cause"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Errors up 6x on checkout", "circular": 0}},
    guide={"goal": "When production breaks, the user makes one good call from wherever they are.",
           "data": ["Error rate and top error (Sentry, Datadog, your logs).", "The last deploys and which one lines up.", "Whether rollback is safe, such as no migration since."],
           "refresh": "As soon as the alert fires, then on every real change. Show 'Back to normal' when it clears.",
           "taps": {"rollback": "Roll back to the version named, watch the error rate, then show the result with the numbers.", "dig": "Investigate, show progress, then come back with a fix or a clearer choice.", "ignore": "Don't act, and don't alert again for this error today."},
           "ask": "If a rollback would undo a migration or lose data, use droplet_ask with risk high.",
           "phone": "Send a notification: this one is worth interrupting for.",
           "never": "Never alert on noise. If this fires often, the user stops trusting it."})

add(id="overnight", title="While you slept", category="Coding approvals",
    tagline="What your agents finished overnight, and the one thing that needs you.",
    does=["Sums up what your scheduled agents did", "Leads with the one thing that needs a decision", "Stays quiet when everything went fine"],
    uses=[], agents="Agents running on a schedule (routines, cron, CI bots)",
    widget={"slug": "overnight", "title": "While you slept", "symbol": "moon.stars.fill", "accent": "#5E5CE6",
            "blocks": [
                {"type": "metric", "label": "Finished", "value": "4"},
                {"type": "text", "text": "Nightly tests green. 1 needs you: PR #218.", "style": "body"},
                {"type": "buttons", "items": [btn("show", "Show me", "arrow.right.circle.fill"), btn("clear", "All good", "checkmark")]},
                {"type": "list", "title": "Last night", "items": [{"title": "Dependency updates merged", "detail": "3"}, {"title": "Nightly tests", "detail": "passed"}, {"title": "PR #218 needs a decision", "detail": "open"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "4 done, 1 needs you", "circular": 0}},
    guide={"goal": "The user starts the day knowing what their agents did, without reading any logs.",
           "data": ["The runs of your scheduled jobs since last night, with their real results.", "Anything that failed or is waiting on the user."],
           "refresh": "Once each morning, from your scheduled run. Clear it when they tap.",
           "taps": {"show": "Turn the widget into the moment that needs them (PR review, Your call, Approvals).", "clear": "Go back to the widget's normal state."},
           "ask": "Nothing here: this moment only reports.",
           "phone": "None. The morning is not worth a buzz unless something is broken.",
           "never": "Never report work you didn't verify finished."})

add(id="pick-a-time", title="Pick a time", category="Inbox",
    tagline="Someone wants to meet. Your agent found the times that work. Tap one and it's sent.",
    does=["Catches scheduling requests in your email", "Checks your calendar for times that really work", "Replies and sends the invite when you tap"],
    uses=["calendar"], agents="Agents with email and calendar access",
    widget={"slug": "pick-a-time", "title": "Time with Sam?", "subtitle": "30 min this week", "symbol": "calendar", "accent": "#0A84FF",
            "blocks": [
                {"type": "metric", "label": "Free slots", "value": "3"},
                {"type": "text", "text": "Sam asked for 30 min about the contract.", "style": "body"},
                {"type": "buttons", "items": [{"id": "t1", "label": "Tue 2:00"}, {"id": "t2", "label": "Wed 10:30"}, {"id": "t3", "label": "Thu 4:00"}]},
                {"type": "list", "title": "Why these", "items": [{"title": "Tue 2:00", "detail": "after lunch"}, {"title": "Wed 10:30", "detail": "no back-to-back"}, {"title": "Thu 4:00", "detail": "end of day"}]}],
            "sizes": {"small": [0], "medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Pick a time with Sam", "circular": 0}},
    guide={"goal": "Scheduling takes one tap instead of five emails.",
           "data": ["The scheduling email (email connector).", "Free times on the user's calendar that respect their hours and focus time."],
           "refresh": "When a scheduling request arrives. Clear it after the invite goes out.",
           "taps": {"t1": "Reply with this time and send the invite, then show 'Sent. Sam has the invite'.", "t2": "Same for the second time.", "t3": "Same for the third time."},
           "ask": "The tap is the approval, because the widget names who and when. Ask first if it's someone the user has never written to.",
           "phone": "Add the event with a phone action only if you have no calendar connector.",
           "never": "Never offer a time you haven't checked against the calendar."})

add(id="follow-up", title="Follow up", category="Inbox",
    tagline="Someone never replied. Your agent noticed and wrote the nudge.",
    does=["Tracks what you're waiting on from other people", "Writes a short, polite nudge in your voice", "Sends it when you tap, or drops it"],
    uses=[], agents="Agents with email or Slack access",
    widget={"slug": "follow-up", "title": "No reply from Sam", "symbol": "arrowshape.turn.up.right.fill", "accent": "#FF9F0A",
            "blocks": [
                {"type": "metric", "label": "Waiting", "value": "5 days"},
                {"type": "text", "text": "You asked for the signed contract. Nudge is written.", "style": "body"},
                {"type": "buttons", "items": [btn("send", "Send", "paperplane.fill"), btn("wait", "Wait", "clock.fill"), btn("drop", "Drop", "xmark")]},
                {"type": "list", "title": "The nudge", "items": [{"title": "Hi Sam, any news on the contract? Happy to help if something's stuck."}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Sam hasn't replied: 5 days", "circular": 0}},
    guide={"goal": "Nothing the user is waiting on quietly dies.",
           "data": ["Sent emails or messages with a question or request and no reply (email or Slack connector).", "How long it's been, and what they usually allow for this person."],
           "refresh": "Once a day. Show one at a time, the most important first.",
           "taps": {"send": "Send exactly the nudge shown, then show the next one or 'All followed up'.", "wait": "Bring it back in 3 days.", "drop": "Stop tracking this one."},
           "ask": "The tap is the approval, because the text is on the widget (large) or in the app. If the small size hid it, ask first.",
           "phone": "None.",
           "never": "Never nudge the same person twice in a week without asking."})

add(id="spend-ok", title="OK to spend?", category="Money",
    tagline="Your agent needs to pay for something to keep going. It asks first, with the exact amount.",
    does=["Stops before any purchase, top-up or paid API", "Says what it costs and what happens if you say no", "Carries on when you approve"],
    uses=[], agents="Any agent that can spend: API credits, tools, ads, purchases",
    widget={"slug": "spend-ok", "title": "OK to spend $20?", "symbol": "creditcard.fill", "accent": "#30D158",
            "blocks": [
                {"type": "metric", "label": "Top-up", "value": "$20"},
                {"type": "text", "text": "API credit is out. Tonight's run stops at 2:00.", "style": "body"},
                {"type": "buttons", "items": [btn("pay", "Pay $20", "creditcard.fill"), btn("no", "Not now", "xmark")]},
                {"type": "list", "title": "This month", "items": [{"title": "API credit", "detail": "$40"}, {"title": "Hosting", "detail": "$20"}, {"title": "Left of your $100 limit", "detail": "$40"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "OK to spend $20?", "circular": 0}},
    guide={"goal": "Agents can keep working on paid things without ever spending behind the user's back.",
           "data": ["The exact amount, the seller and what it's for.", "What stops if the answer is no.", "What you've spent so far, if you've kept track."],
           "refresh": "When you reach the point of paying. Show the receipt after.",
           "taps": {"pay": "Ask droplet_ask with risk high naming the amount and seller. On yes, pay exactly that, then show the receipt.", "no": "Don't pay. Say what you'll do instead, and carry on without it."},
           "ask": "Always two steps for money: this button, then droplet_ask with risk high.",
           "phone": "None.",
           "never": "Never spend more than the amount shown, and never enter card details the user hasn't already saved."})

add(id="bill-guard", title="Renewal coming", category="Money",
    tagline="Something renews soon that you barely use. Your agent caught it in time.",
    does=["Finds renewals in your receipts and emails", "Checks whether you actually use it", "Cancels it or sets a reminder after your tap"],
    uses=[], agents="Agents with email access, and a browser to cancel",
    widget={"slug": "bill-guard", "title": "Figma renews Friday", "symbol": "creditcard.trianglebadge.exclamationmark", "accent": "#FF9F0A",
            "blocks": [
                {"type": "metric", "label": "Yearly", "value": "$144"},
                {"type": "text", "text": "No Figma emails from you since June. Cancel?", "style": "body"},
                {"type": "buttons", "items": [btn("cancel", "Cancel it", "xmark.circle.fill"), btn("keep", "Keep", "checkmark")]},
                {"type": "list", "title": "How to cancel", "items": [{"title": "Their settings page", "detail": "I'll open it"}, {"title": "Refund window", "detail": "14 days"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Figma renews Friday", "circular": 0}},
    guide={"goal": "The user never pays again for something they meant to cancel.",
           "data": ["Renewal notices and past receipts in email.", "Signs of use you can really see. If you can't tell, say so instead of guessing."],
           "refresh": "A few days before each renewal.",
           "taps": {"cancel": "Cancel with your browser tools if you can. If it needs their sign-in, send the cancel link and turn this into Only you can do.", "keep": "Do nothing, and don't ask again until next time it renews."},
           "ask": "Before anything that can't be undone, such as closing an account. Name it.",
           "phone": "None.",
           "never": "Never say it's cancelled until you've seen the confirmation."})

add(id="usage-spike", title="Usage spike", category="Money",
    tagline="A bill is about to jump. Your agent found out why and how to stop it.",
    does=["Watches usage on your cloud and API accounts", "Finds what's causing a jump", "Offers the fix before the invoice arrives"],
    uses=[], agents="Agents with access to your cloud or API billing",
    widget={"slug": "usage-spike", "title": "Usage up 4x", "symbol": "chart.line.uptrend.xyaxis", "accent": "#FF453A",
            "blocks": [
                {"type": "metric", "label": "Today so far", "value": "$38", "trend": "up"},
                {"type": "text", "text": "Bots on /api/search since 9:00. A rate limit stops it.", "style": "body"},
                {"type": "buttons", "items": [btn("limit", "Add limit", "hand.raised.fill"), btn("dig", "Look into it", "magnifyingglass"), btn("ignore", "It's fine", "checkmark")]},
                {"type": "list", "title": "Where it's going", "items": [{"title": "/api/search", "detail": "$31"}, {"title": "Everything else", "detail": "$7"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Usage up 4x today", "circular": 0}},
    guide={"goal": "Bills don't surprise the user: the jump gets caught the same day, with the cause.",
           "data": ["Usage and cost from your hosting, cloud or API dashboard.", "What's normal for this account.", "The cause you found in logs or traffic."],
           "refresh": "A scheduled check once or twice a day. Only show this when it's really out of line.",
           "taps": {"limit": "Prepare the change and deploy it after approval, then show the new rate.", "dig": "Investigate and report back with what you found.", "ignore": "Don't flag this cause again this week."},
           "ask": "Before deploying the fix, or anything that could affect real users.",
           "phone": "None unless it's costing real money fast.",
           "never": "Never turn a service off to save money without asking."})

add(id="news-brief", title="Worth your time", category="News & social",
    tagline="One story that matters to your work, why it matters, and what to do about it.",
    does=["Reads your feeds so you don't have to", "Only shows what touches your work, and says why", "Summarises it or tells you what to do next on a tap"],
    uses=[], agents="Any agent with a web or feed tool",
    widget={"slug": "news-brief", "title": "Worth your time", "subtitle": "1 of 3", "symbol": "newspaper.fill", "accent": "#FF375F",
            "blocks": [
                {"type": "metric", "label": "Affects", "value": "Your app"},
                {"type": "text", "text": "iOS 27 changed widget limits. Nothing's broken yet.", "style": "body"},
                {"type": "buttons", "items": [btn("todo", "What to do", "sparkles"), btn("summary", "Summary", "text.alignleft"), btn("next", "Next", "chevron.right")]},
                {"type": "list", "title": "Also today", "items": [{"title": "A competitor launched on iPad", "detail": "The Verge"}, {"title": "New MCP spec draft", "detail": "GitHub"}]}],
            "sizes": {"small": [0], "medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "1 story worth your time", "circular": 0}},
    guide={"goal": "The user sees only what changes something for them, and knows what to do about it.",
           "data": ["Feeds, sites and accounts the user follows, or what matters to their work.", "Your own judgement on why each one matters to them. If it doesn't, leave it out."],
           "refresh": "A few times a day. Showing nothing is fine.",
           "taps": {"todo": "Work out what it means for them and offer the next step as a new moment.", "summary": "Put a two-line summary on the widget, with a link to the source.", "next": "Show the next story."},
           "ask": "Before posting or sending anything about it.",
           "phone": "None.",
           "never": "Never pad it with headlines. This isn't a news feed."})

add(id="mention-reply", title="Reply drafted", category="News & social",
    tagline="Someone asked you something in public. Your agent wrote the reply. You tap post.",
    does=["Watches for real questions and mentions, not likes", "Writes the reply in your voice", "Posts it only after your tap"],
    uses=[], agents="Agents with social or community access",
    widget={"slug": "mention-reply", "title": "Reply to Priya?", "subtitle": "On X", "symbol": "bubble.left.and.bubble.right.fill", "accent": "#0A84FF",
            "blocks": [
                {"type": "metric", "label": "Her followers", "value": "12k"},
                {"type": "text", "text": "Does it work with Codex? Draft: Yes, connects in a minute.", "style": "body"},
                {"type": "buttons", "items": [btn("post", "Post", "paperplane.fill"), btn("skip", "Skip", "xmark")]},
                {"type": "list", "title": "Also waiting", "items": [{"title": "Question on Discord", "detail": "2h"}, {"title": "Reply on GitHub", "detail": "5h"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "1 reply ready to post", "circular": 0}},
    guide={"goal": "Real questions get answered fast, without the user living in their feeds.",
           "data": ["Mentions and replies from the accounts you're connected to.", "The user's past replies, to match their voice."],
           "refresh": "A few times a day. Only real questions and people worth replying to.",
           "taps": {"post": "Post exactly the text shown, then show the link to it.", "skip": "Drop it and show the next one."},
           "ask": "The tap is the approval, because the draft is on the widget. Ask first for anything sensitive or angry.",
           "phone": "None.",
           "never": "Never post text the user didn't see."})

add(id="gym-session", title="Gym session", category="Health",
    tagline="Your workout, a live set counter and the rest timer.",
    does=["Today's plan, built from your last sessions", "Tick sets, the ring counts them", "Rest timer and logging in one tap"],
    uses=["location", "health"], agents="Any agent",
    widget={"slug": "gym-session", "title": "Push day", "symbol": "dumbbell.fill", "accent": "#FF9F0A",
            "blocks": [
                {"type": "gauge", "label": "Sets", "count": "checked"},
                {"type": "checklist", "items": ["Bench 4×8 @ 70 kg", "Incline DB 3×10", "Dips 3×12", "Cable fly 3×15"]},
                {"type": "buttons", "items": [btn("rest", "Rest 90s", "timer"), btn("log", "Log it", "square.and.arrow.down.fill")]}],
            "sizes": {"small": [0], "medium": [0, 1], "large": [0, 1, 2]}},
    guide={"goal": "The user trains without a notebook or an app to open.",
           "data": ["The plan from their program and last session (progress the weight when they hit all reps).", "Version by place: show this when place is 'gym', a summary elsewhere."],
           "refresh": "Before each session; versions handle place on the phone.",
           "taps": {"rest": "droplet_phone_action timer 90 seconds (label 'Rest'). Show 'Resting…'.",
                    "log": "Save the ticked sets to their training log, show 'Logged. Next: Pull day Thu' and reset with reset_checklists: true next time."},
           "ask": "Ask once which days they train.",
           "phone": "timer for rest.",
           "never": "None."})

add(id="grocery-run", title="Grocery run", category="Home",
    tagline="A list that fills itself and counts down while you shop.",
    does=["Your agent adds what you're out of from recipes, messages and habits", "Tick as you shop; the ring counts with you", "Order the rest for delivery with one tap"],
    uses=["location"], agents="Any agent; ordering needs one with a grocery app or browser",
    widget={"slug": "grocery-run", "title": "Groceries", "symbol": "cart.fill", "accent": "#30D158",
            "blocks": [
                {"type": "gauge", "label": "In the cart", "count": "checked"},
                {"type": "checklist", "items": [{"title": "Oat milk", "done": False}, {"title": "Eggs (12)", "done": False}, {"title": "Coffee beans", "done": False}, {"title": "Spinach", "done": False}, {"title": "Lemons", "done": False}, {"title": "Pasta", "done": False}]},
                {"type": "buttons", "items": [btn("order", "Order the rest", "shippingbox.fill"), btn("add", "Add usuals", "plus")]}],
            "sizes": {"small": [0], "medium": [0, 1], "large": [0, 1, 2]}},
    guide={"goal": "The user never forgets an item and never writes a list.",
           "data": ["Items from the user's messages ('we're out of eggs'), recipes they plan, and what they buy every week.", "count ring: leave it as count 'checked'; it counts ticks on the phone."],
           "refresh": "When you learn of a new item; ticks are saved by Droplet.ai and stay ticked when you resend the list. Start a fresh list with reset_checklists: true after a shop.",
           "taps": {"order": "Build a cart with the unticked items in the user's grocery app, then droplet_ask with the total 'Order 4 items, $31.40, delivery 6-7 PM?'. Only on yes.",
                    "add": "Add the user's weekly usuals that aren't on the list yet."},
           "ask": "Before ordering (money).",
           "phone": "None. Optional versions: show it at the top when the phone is 'away' near a store.",
           "never": "Never untick what the user ticked."})

add(id="travel-day", title="Travel day", category="Travel",
    tagline="Flight, gate, when to leave and the ride, as one live widget.",
    does=["Flight status, gate and boarding time", "When to leave for the airport, with the ride", "Changes on its own when the flight does"],
    uses=["location", "calendar"], agents="Agents with email access (to find the booking)",
    widget={"slug": "travel-day", "title": "UA 1557 to SFO", "symbol": "airplane", "accent": "#0A84FF",
            "blocks": [
                {"type": "metric", "label": "Gate", "value": "C12"},
                {"type": "text", "text": "Boards 7:40 · on time", "style": "body"},
                {"type": "buttons", "items": [btn("checkin", "Check in", "checkmark.seal.fill", "https://www.united.com/"), btn("ride", "Ride at 5:45", "car.fill")]},
                {"type": "list", "title": "Plan", "items": [{"title": "Leave home 5:45 AM"}, {"title": "Alarm set for 5:00 AM"}, {"title": "Seat 14C · bag checked"}]}],
            "sizes": {"medium": [0, 1, 2], "large": [0, 1, 3, 2]}},
    guide={"goal": "Travel day runs itself.",
           "data": ["The booking from email; live status, gate and delays from the airline or a flight API.", "Leave time from travel time to the airport plus 2 h domestic / 3 h international."],
           "refresh": "Every 30 min on travel day (droplet_schedule with the flight API), immediately on a delay or gate change.",
           "taps": {"ride": "Price the ride, droplet_ask 'Book Uber to JFK, $58, pickup 5:45?' and book on yes."},
           "ask": "Before booking anything.",
           "phone": "Offer an alarm (droplet_phone_action alarm) for the wake-up time; tell them it's set.",
           "never": "Delay = update the widget, notify only if they asked for alerts."})

add(id="day-brief", title="Your day", category="Informative",
    tagline="What you need to know, changing through the day: how you slept, what's first, what's left.",
    does=["Your agent reads your calendar, health and reminders and picks what matters now", "Changes by itself morning, afternoon and evening", "No app to open and nothing to set up per day"],
    uses=["calendar", "health", "reminders"], agents="Any agent, with Phone access on",
    widget={"slug": "day-brief", "title": "This morning", "symbol": "sun.max.fill", "accent": "#FF9F0A",
            "blocks": [
                {"type": "metric", "label": "First thing", "value": "9:30"},
                {"type": "text", "text": "Standup, then clear until 2. You slept 5h, so nothing heavy is booked early.", "style": "body"},
                {"type": "list", "title": "Today", "items": [{"title": "Standup", "detail": "9:30"}, {"title": "Design review", "detail": "2:00"}, {"title": "Pay rent", "detail": "due today"}]}],
            "variants": [
                {"when": {"from": "12:00", "to": "17:00"}, "title": "This afternoon",
                 "blocks": [{"type": "metric", "label": "Next", "value": "2:00"}, {"type": "text", "text": "Design review with 6 people. Your notes are ready.", "style": "body"}, {"type": "list", "title": "Still today", "items": [{"title": "Reply to Sam", "detail": "drafted"}, {"title": "Pay rent", "detail": "due today"}]}]},
                {"when": {"from": "17:00", "to": "23:30"}, "title": "Tomorrow",
                 "blocks": [{"type": "metric", "label": "First thing", "value": "8:00"}, {"type": "text", "text": "Board prep, so an earlier start. You have 2 things left today.", "style": "body"}, {"type": "list", "title": "Left today", "items": [{"title": "Pay rent", "detail": "due today"}, {"title": "Call Mom", "detail": "her birthday"}]}]}],
            "sizes": {"small": [0], "medium": [0, 1], "large": [0, 1, 2]},
            "lock": {"inline": "First thing: 9:30 standup", "circular": 0}},
    guide={"goal": "One look tells the user what matters now. They never open a calendar to find out.",
           "data": ["Phone access: calendar, reminders, health totals, time zone.", "Anything else you know from your connectors: email, tasks, what they told you."],
           "refresh": "Write all the versions each morning; the phone switches between them with no agent running. Update when the day changes.",
           "taps": {}, "ask": "Nothing: this only informs.", "phone": "Reads calendar, reminders and health if they're on.",
           "never": "Never just copy the calendar. Choose what matters and say why."})

add(id="here-now", title="Here and now", category="Informative",
    tagline="What's useful where you are: your meetings at work, what's nearby when you're out, tomorrow when you're home.",
    does=["Shows something different at each place you've saved", "Your agent decides what's useful in each one", "Switches on the phone by itself as you move"],
    uses=["location", "calendar", "reminders"], agents="Any agent, with places saved in Droplet.ai",
    widget={"slug": "here-now", "title": "Out and about", "symbol": "location.fill", "accent": "#30D158",
            "blocks": [
                {"type": "metric", "label": "Near you", "value": "2"},
                {"type": "text", "text": "The pharmacy has your refill, and the post office is open until 6.", "style": "body"},
                {"type": "list", "title": "While you're out", "items": [{"title": "Pharmacy: refill ready", "detail": "5 min"}, {"title": "Post the signed forms", "detail": "until 6:00"}]}],
            "variants": [
                {"when": {"place": "work"}, "title": "At work",
                 "blocks": [{"type": "metric", "label": "Next", "value": "2:00"}, {"type": "text", "text": "Design review in room 4. Sam's deck is what they'll ask about.", "style": "body"}, {"type": "list", "title": "Today", "items": [{"title": "Design review", "detail": "2:00"}, {"title": "1:1 with Sam", "detail": "4:00"}]}]},
                {"when": {"place": "home"}, "title": "At home",
                 "blocks": [{"type": "metric", "label": "Tomorrow", "value": "8:00"}, {"type": "text", "text": "Board prep first. Bins go out tonight.", "style": "body"}, {"type": "list", "title": "Tonight", "items": [{"title": "Bins out", "detail": "by 7 AM"}, {"title": "Call Mom", "detail": "her birthday"}]}]}],
            "sizes": {"small": [0], "medium": [0, 1], "large": [0, 1, 2]},
            "lock": {"inline": "2 things near you", "circular": 0}},
    guide={"goal": "The widget feels like it knows where the user is, without them ever telling it.",
           "data": ["Saved places and the current place (Phone access).", "Calendar and reminders, and what you know is near each place."],
           "refresh": "Write the versions each morning, and when something changes. The phone switches by place on its own.",
           "taps": {}, "ask": "Ask once which places matter, if none are saved.", "phone": "Reads place, calendar and reminders if they're on.",
           "never": "Never show exact addresses or location details the user didn't turn on."})

add(id="smart-buttons", title="Smart buttons", category="Controls",
    tagline="The buttons you need right now. Your agent changes them by time, place and what's next.",
    does=["At work: join the next call, say you're late, start a timer", "At home at night: run your bedtime Shortcut, set tomorrow's alarm", "When you're out: head home, tell them you're on your way"],
    uses=["location", "calendar"], agents="Any agent; it needs a listener for buttons that ask it to do things",
    widget={"slug": "smart-buttons", "title": "Next up", "symbol": "square.grid.2x2.fill", "accent": "#0A84FF",
            "blocks": [
                {"type": "metric", "label": "Starts in", "value": "8 min"},
                {"type": "text", "text": "Design review, room 4.", "style": "body"},
                {"type": "buttons", "items": [btn("join", "Join", "video.fill", "https://meet.google.com/"), btn("late", "I'm late", "clock.fill"), btn("notes", "Notes", "doc.text.fill")]},
                {"type": "list", "title": "Why these", "items": [{"title": "Your next meeting is close", "detail": "2:00"}, {"title": "6 people are waiting on it", "detail": ""}]}],
            "variants": [
                {"when": {"place": "home", "from": "20:00", "to": "23:59"}, "title": "Tonight",
                 "blocks": [{"type": "metric", "label": "Tomorrow", "value": "8:00"}, {"type": "text", "text": "Early start: board prep.", "style": "body"}, {"type": "buttons", "items": [btn("bedtime", "Bedtime", "moon.fill", "shortcuts://run-shortcut?name=Bedtime"), btn("alarm", "Alarm 6:45", "alarm.fill"), btn("tomorrow", "Tomorrow", "calendar")]}, {"type": "list", "title": "Why these", "items": [{"title": "You're home and it's late", "detail": ""}, {"title": "Tomorrow starts early", "detail": "8:00"}]}]},
                {"when": {"place": "away"}, "title": "Out",
                 "blocks": [{"type": "metric", "label": "From home", "value": "25 min"}, {"type": "text", "text": "Dinner at home at 7.", "style": "body"}, {"type": "buttons", "items": [btn("home", "Go home", "house.fill", "https://maps.apple.com/?daddr=Home"), btn("omw", "On my way", "paperplane.fill"), btn("later", "Running late", "clock.fill")]}, {"type": "list", "title": "Why these", "items": [{"title": "You're out", "detail": ""}, {"title": "Dinner's on your calendar", "detail": "7:00"}]}]}],
            "sizes": {"small": [0], "medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Design review at 2:00", "circular": 0}},
    guide={"goal": "The user never hunts for the right app or shortcut. The action they need is already on the screen.",
           "data": ["Next event and its join link (calendar).", "Current place and time, and what they do at each.", "Their Shortcuts, phone contacts or home scenes, if they tell you the names."],
           "refresh": "Write the versions each morning; the phone switches them. Update when the next event changes.",
           "taps": {"late": "Tell the organiser, with their OK the first time, and show who you told.", "notes": "Fetch or prepare the notes, and put them on the widget.", "alarm": "Set the alarm with droplet_phone_action.", "omw": "Send the message you agreed with them.", "later": "Tell them you're running late, as agreed.", "tomorrow": "Show tomorrow on the widget."},
           "ask": "Before sending anything to someone for the first time.",
           "phone": "Alarms, timers and reminders through droplet_phone_action. Buttons with a url open directly, with no agent running.",
           "never": "Never add a button you can't follow through on. No dead controls."})

add(id="meeting-controls", title="Meeting controls", category="Controls",
    tagline="Only around a meeting: join it, say you're late, then send the recap when it ends.",
    does=["Shows up just before the meeting and leaves after", "Changes from Join and I'm late to Send recap", "Writes the recap and sends it after your tap"],
    uses=["calendar"], agents="Agents with calendar and email access",
    widget={"slug": "meeting-controls", "title": "Design review", "symbol": "video.fill", "accent": "#5E5CE6",
            "blocks": [
                {"type": "metric", "label": "Starts at", "value": "2:00"},
                {"type": "text", "text": "Room 4 or the video link.", "style": "body"},
                {"type": "buttons", "items": [btn("join", "Join", "video.fill", "https://meet.google.com/"), btn("late", "I'm late", "clock.fill"), btn("agenda", "Agenda", "list.bullet")]},
                {"type": "list", "title": "After it ends, these become", "items": [{"title": "Send recap", "detail": "I'll write it"}, {"title": "Add the tasks", "detail": "to your list"}]}],
            "sizes": {"small": [0], "medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Design review at 2:00", "circular": 0}},
    guide={"goal": "Everything about a meeting is one tap away at exactly the moment it's needed.",
           "data": ["The event, its link, its people and its room (calendar).", "Notes or a transcript afterwards, if you can read them."],
           "refresh": "Set it 10 minutes before. Change the buttons when it ends. Remove it when the recap is sent.",
           "taps": {"late": "Tell the organiser how late, and show it's done.", "agenda": "Put the agenda on the widget.", "recap": "Show the recap and send it after approval."},
           "ask": "Before sending a recap to the group.", "phone": "None.",
           "never": "Never keep it on the screen after the meeting is finished and handled."})

add(id="home-scenes", title="Home controls", category="Controls",
    tagline="At home, the controls for this moment: leaving, evening or bedtime.",
    does=["Only shows at home", "Changes with the time of day", "Runs your own Shortcuts in one tap, with no agent running"],
    uses=["location"], agents="Any agent; the user tells it their Shortcut names",
    widget={"slug": "home-scenes", "title": "Evening", "symbol": "house.fill", "accent": "#FF9F0A",
            "blocks": [
                {"type": "metric", "label": "Bedtime in", "value": "2h"},
                {"type": "text", "text": "Early start tomorrow.", "style": "body"},
                {"type": "buttons", "items": [btn("dim", "Dim", "lightbulb.fill", "shortcuts://run-shortcut?name=Dim%20lights"), btn("movie", "Movie", "tv.fill", "shortcuts://run-shortcut?name=Movie"), btn("bed", "Bedtime", "moon.fill", "shortcuts://run-shortcut?name=Bedtime")]},
                {"type": "list", "title": "Tomorrow", "items": [{"title": "Board prep", "detail": "8:00"}, {"title": "Leave by", "detail": "7:20"}]}],
            "variants": [
                {"when": {"place": "home", "from": "06:00", "to": "10:00"}, "title": "Morning",
                 "blocks": [{"type": "metric", "label": "Leave by", "value": "8:40"}, {"type": "text", "text": "Rain later, take a coat.", "style": "body"}, {"type": "buttons", "items": [btn("heat", "Heating off", "thermometer.low", "shortcuts://run-shortcut?name=Heating%20off"), btn("leave", "Leaving", "door.left.hand.open", "shortcuts://run-shortcut?name=Leaving")]}, {"type": "list", "title": "Today", "items": [{"title": "Standup", "detail": "9:30"}, {"title": "Home by", "detail": "6:30"}]}]}],
            "sizes": {"small": [0], "medium": [0, 1, 2], "large": [0, 1, 2, 3]},
            "lock": {"inline": "Home: evening", "circular": 0}},
    guide={"goal": "The user's home responds to one button that's already the right one.",
           "data": ["The names of their Shortcuts, which they tell you.", "Their usual times, and tomorrow's calendar for the leave-by time."],
           "refresh": "Rarely: when they add a Shortcut or their routine changes. The phone switches versions.",
           "taps": {}, "ask": "Ask once for the names of their Shortcuts.", "phone": "None: Shortcut links run on the phone.",
           "never": "Never invent a Shortcut name. A wrong name is a broken button."})

add(id="release-room", title="Release room", category="GUI",
    tagline="A small app for one job: everything about a release, with the controls, built by your agent.",
    does=["Status, numbers, the steps left and the controls, all in one widget", "Your agent builds it for this release and changes it as things move", "Goes away when the job is done"],
    uses=[], agents="Coding agents, and any agent running a big job",
    widget={"slug": "release-room", "title": "Release v2.4", "subtitle": "Canary at 10%", "symbol": "shippingbox.fill", "accent": "#30D158",
            "blocks": [
                {"type": "metric", "label": "Rollout", "value": "10%"},
                {"type": "text", "text": "Errors normal, 0.02%. Next: 50%.", "style": "body"},
                {"type": "buttons", "items": [btn("next", "Go to 50%", "arrow.up.circle.fill"), btn("hold", "Hold", "pause.fill"), btn("back", "Roll back", "arrow.uturn.backward")]},
                {"type": "chart", "kind": "line", "label": "Errors, last hour", "values": [0.02, 0.03, 0.02, 0.02, 0.03, 0.02, 0.02, 0.02]},
                {"type": "list", "title": "Steps left", "items": [{"title": "50% of users", "detail": "next"}, {"title": "100% of users", "detail": "then"}, {"title": "Announce it", "detail": "drafted"}]}],
            "sizes": {"small": [0], "medium": [0, 1, 2], "large": [0, 1, 3, 4, 2]},
            "lock": {"inline": "v2.4 at 10%, all normal", "circular": 0}},
    guide={"goal": "The user runs a whole job from one widget, as if the agent had built them an app for it.",
           "data": ["Rollout state, error rates and logs, from your deploy and monitoring tools.", "The plan you're following."],
           "refresh": "On every real change while it's running. Then show the result, and remove it.",
           "taps": {"next": "Go to the next step in the plan, watch the numbers, then show the result.", "hold": "Stop here, and show why it's held.", "back": "Roll back after approval, then show the numbers."},
           "ask": "Before anything that reaches all users, or can't be undone.",
           "phone": "A notification if the numbers go wrong.",
           "never": "Never go further than the step named on the button."})

LOCK = {
 "grocery-run": {"inline": "Groceries: 6 to get", "circular": 0},
 "gym-session": {"inline": "Push day: 4 exercises", "circular": 0},
 "travel-day": {"inline": "UA 1557 boards 7:40", "circular": 0},
  "approvals": {"inline": "Ship v2.4? Tap to approve", "circular": 0},
 "ship-status": {"inline": "main is failing", "circular": 0},
 "inbox-zero": {"inline": "3 emails need you", "circular": 0},
 "meeting-prep": {"inline": "Design review at 3:00", "circular": 0},
 "agent-at-work": {"inline": "Scan: 7 of 12 sites", "circular": 0},
}
from docs_extra import EXTRA as _X
for t in L:
    if t["id"] in LOCK and "lock" not in t["widget"]: t["widget"]["lock"] = LOCK[t["id"]]
    t["tags"] = _X[t["id"]].get("tags", [])
    t["when"] = _X[t["id"]]["when"]
    t["customize"] = _X[t["id"]].get("knobs", [])
for t in L: t["doc"] = f"https://droplet.ai/kit/library/{t['id']}.md"
from widget_types import TYPES, EXAMPLE_TYPE, AGENTIC
for t in L: t["type"] = EXAMPLE_TYPE[t["id"]]
types_out = [dict(ty, examples=[t["id"] for t in L if t["type"] == ty["id"]], doc=f"https://droplet.ai/kit/library/types/{ty['id']}.md") for ty in TYPES]
from widget_types import AGENTIC
# Group the moments under the Agentic Widget they belong to, Right now first. Builds before 40 show
# templates by "category" in this order, so they read as Agentic Widgets too.
order = {}
for a_ in AGENTIC:
    for m in a_["moments"]:
        order.setdefault(m, (AGENTIC.index(a_), a_["moments"].index(m), a_["name"]))
L[:] = [t for t in L if t["id"] in order]  # every moment belongs to an Agentic Widget
for t in L:
    t["category"] = order[t["id"]][2]
L.sort(key=lambda t: order.get(t["id"], (99, 0, ""))[:2])
agentic_out = [dict(a, doc=f"https://droplet.ai/kit/library/agentic/{a['id']}.md") for a in AGENTIC]
os.makedirs(os.path.join(HERE, "agentic"), exist_ok=True)
for a in AGENTIC:
    ms = [t for t in L if t["id"] in a["moments"]]
    ad = [f"# {a['name']}", "", f"*{a['oneliner']}*", "",
          "An Agentic Widget: ONE widget your agent keeps on the user's Home Screen, showing the right moment at the right time. Keep the slug; change what it shows as the day goes (versions by time and place let the phone switch on its own).", "",
          "## What it shows, and when", ""] + [f"- {h}" for h in a["how"]] + ["",
          "## Moments to build from", ""] + [f"- [{t['title']}](../{t['id']}.md): {t['tagline']}" for t in ms] + ["",
          "Each moment's guide has its data sources, refresh, what each button does and when to ask first. Build the moment that matters now; switch when another matters more.", ""]
    open(os.path.join(HERE, "agentic", f"{a['id']}.md"), "w").write("\n".join(ad))
out = {"version": "2026-11-01", "about": "Agentic Widgets: your agent decides what each one shows and offers, from the time, your place, your events and your data. Some inform, some give you the right controls, some are full GUIs built for the job, and some ask you or report work. Examples are good moments to import and adapt with the user's real data.", "agentic": agentic_out, "types": types_out, "templates": L}
json.dump(out, open(os.path.join(HERE, "library.json"), "w"), indent=1, ensure_ascii=False)

from docs_extra import EXTRA
from widget_types import TYPES, EXAMPLE_TYPE

USE_NAMES = {"calendar": "Calendar", "location": "Location", "health": "Health", "reminders": "Reminders"}
SIZE_NAMES = [("small", "Small"), ("medium", "Medium"), ("large", "Large")]

def describe(b):
    t = b["type"]
    if t == "metric": return f"metric: {b.get('label')} = {b.get('value')}"
    if t == "text": return f"text ({b.get('style', 'body')}): \"{b['text']}\""
    if t == "countdown": return f"countdown ({b.get('style', 'relative')}): {b.get('label')}"
    if t == "gauge": return "ring counting ticked items" if b.get("count") == "checked" else f"gauge: {b.get('label')}"
    if t == "progress": return f"progress bar: {b.get('label')}"
    if t == "checklist": return f"checklist of {len(b['items'])} items"
    if t == "list": return f"list: {b.get('title') or ''} ({len(b['items'])} rows)"
    if t == "map": return f"map: {b.get('label')}"
    if t == "buttons": return "buttons: " + ", ".join(f"{i['label']} (`{i['id']}`)" for i in b["items"])
    return t

def pretty(w):
    """The widget as JSON with one block per line, so it reads like a layout."""
    lines = ["{"]
    keys = list(w.keys())
    for n, k in enumerate(keys):
        end = "," if n < len(keys) - 1 else ""
        if k == "blocks":
            lines.append('  "blocks": [')
            for m, b in enumerate(w["blocks"]):
                lines.append("    " + json.dumps(b, ensure_ascii=False) + ("," if m < len(w["blocks"]) - 1 else ""))
            lines.append("  ]" + end)
        else:
            lines.append(f"  {json.dumps(k)}: {json.dumps(w[k], ensure_ascii=False)}{end}")
    return "\n".join(lines + ["}"])

def shown(widget, key):
    blocks, sizes = widget["blocks"], widget.get("sizes") or {}
    if key in sizes: return sizes[key]
    if key == "small": return [0]
    return list(range(len(blocks)))

index = ["# Droplet.ai library: Agentic Widgets", "",
         "Each widget here is a **job**, not a picture: a tested design plus how to run it. Agents can browse it with `droplet_library` (HTTP `library`), and users send them one from the Library tab in the Droplet.ai app (it arrives as a `request` event, SKILL.md Process H).", "",
         "How to use a template: get it, keep the design (blocks, sizes, symbol, button ids), replace every sample value with the user's real data, then run it the way its guide says. Build it on your existing widget unless the user asked for a separate one.", "",
         "| Widget | Category | What it does | Uses |", "|---|---|---|---|"]
for t in L:
    g, x, w = t["guide"], EXTRA[t["id"]], t["widget"]
    index.append(f"| [{t['title']}]({t['id']}.md) | {t['category']} | {t['tagline']} | {', '.join(USE_NAMES.get(u, u) for u in t['uses']) or '-'} |")
    ty = next(x for x in TYPES if x["id"] == EXAMPLE_TYPE[t["id"]])
    siblings = [o for o in L if EXAMPLE_TYPE[o["id"]] == ty["id"] and o["id"] != t["id"]]
    d = [f"# {t['title']}", "", f"*{t['tagline']}*", "",
         f"**Type: [{ty['name']}](types/{ty['id']}.md).** {ty['oneliner']} This is one good use of it; the same widget serves {', '.join(g.lower() for g in ty['good_for'][:4])} and more. Switch the subject when something else matters more.", "",
         f"Template id `{t['id']}` · {t['category']} · uses {', '.join(USE_NAMES.get(u, u) for u in t['uses']) or 'nothing on the phone'} · for: {t['agents']}.", "",
         "## Goal", "", g["goal"], "",
         "## When to offer it", "", x["when"], "",
         "## What the user gets", ""] + [f"- {line}" for line in t["does"]] + ["",
         "## What each size shows", ""]
    for key, name in SIZE_NAMES:
        idx = [i for i in shown(w, key) if i < len(w["blocks"])]
        d.append(f"- **{name}**: " + "; ".join(describe(w["blocks"][i]) for i in idx) + ".")
    if w.get("lock"): d.append(f"- **Lock Screen**: inline \"{w['lock'].get('inline', '')}\".")
    accent_name = {"#0A84FF":"blue","#5E5CE6":"indigo","#BF5AF2":"purple","#FF375F":"pink","#FF453A":"red","#FF9F0A":"orange","#30D158":"green","#0FA3B1":"teal","#636366":"graphite"}.get(w.get("accent"), "indigo")
    d += ["", "## Make it theirs", "",
          "**Look.** Send `look` instead of `theme` and `accent`; every combination is designed to read well:", "",
          "- `style`: `glass` (default: see-through, adapts to dark mode), `soft` (a calm pale tint) or `bold` (a vivid gradient with dark buttons).",
          "- `accent`: blue, indigo, purple, pink, red, orange, green, teal, graphite, or a hex.",
          "- `font`: default, rounded, serif or mono.", "",
          f"This template's own accent is **{accent_name}**. To restyle a widget you already saved, send only the look:", "",
          "```json", json.dumps({"slug": w["slug"], "look": {"style": "bold", "accent": accent_name, "font": "rounded"}}), "```", "",
          "Preview a look without saving: `droplet_preview_widget` with the slug and `look`. When the user says \"make it greener\", \"calmer\" or \"bolder\", change the look; keep the content.", ""]
    if t.get("customize"):
        d += ["**Their choices.** Ask once (droplet_ask) or use what you know:", ""] + [f"- {k}" for k in t["customize"]] + [""]
    d += [f"**Search words:** {', '.join(t.get('tags', []))}.", ""]
    d += ["", "## Before you build", ""]
    if t["uses"]:
        d.append(f"- Check `droplet_get_phone_context`: the phone must share {', '.join(USE_NAMES.get(u, u).lower() for u in t['uses'])}. If something is off, ask the user to turn it on in Droplet.ai, Settings, Phone access.")
    d += [f"- You need: {t['agents']}.", f"- Ask once: {g['ask']}", "",
          "## Fill it with real data", "", "Start from the template (`droplet_library` with `id: \"" + t["id"] + "\"`), keep the design, and replace each sample value:", "",
          "| Block | Real value |", "|---|---|"]
    for i, b in enumerate(w["blocks"]):
        d.append(f"| {i} · {b['type']} | {x['fields'].get(i, 'Keep as is.')} |")
    d += ["", "Sources:"] + [f"- {s_}" for s_ in g["data"]] + ["",
          "## The widget", "", "Sample values; send it with `droplet_set_widget` on your widget's slug (or a new slug with `new_widget: true` if the user asked for a separate widget). Preview it and fix every warning first.", "",
          "```json", pretty(w), "```", "",
          "## Keep it fresh", "", g["refresh"], ""]
    buttons = [it for b in w["blocks"] if b["type"] == "buttons" for it in b["items"]]
    if buttons:
        d += ["## Handle the taps", "", "Each tap reaches you once on `droplet_get_events` (keep a waker running, SKILL.md Process C). Answer within seconds by updating the widget.", ""]
        for it in buttons:
            if it.get("url"):
                d += [f"**{it['label']}** opens `{it['url']}` directly; no event. Put the user's real link there.", ""]
                continue
            ev = {"widget": w["slug"], "kind": "button", "target": it["id"], "value": {"label": it["label"]}}
            d += [f"**{it['label']}** (`{it['id']}`)", "", "```json", json.dumps(ev, ensure_ascii=False), "```", "", g["taps"].get(it["id"], "Do what the label says, then show the result on the widget."), ""]
    if g.get("questions"):
        d += ["## Ask the right questions", ""] + [f"- {q}" for q in g["questions"]] + [""]
    d += ["## Ask first", "", g["ask"], "", "For example:", "", "```json", json.dumps(x["ask_json"], ensure_ascii=False), "```", ""]
    d += ["## Phone actions", "", g["phone"], ""]
    if x["phone_json"]:
        d += ["```json", json.dumps(x["phone_json"], ensure_ascii=False), "```", "", "Send it with `droplet_phone_action` and tell the user what you set.", ""]
    d += ["## Edge cases", ""] + [f"- {e}" for e in x["edge"]] + ["",
          "## Never", "", g["never"], "",
          "## Done when", "",
          "- [ ] Every sample value is replaced with real data (no \"Dr. Lee\" on a real widget).",
          "- [ ] `droplet_preview_widget` shows no warnings at the sizes the user placed (`placed` in `droplet_whoami`).",
          "- [ ] Every button has a handler and a waker is running." if buttons else "- [ ] Nothing needs a handler (no event buttons).",
          "- [ ] Refresh is set up as above.",
          "- [ ] You told the user in one line what it does on its own and what it asks first.", ""]
    if siblings:
        d += ["## Same widget, other uses", ""] + [f"- [{o['title']}]({o['id']}.md): {o['tagline']}" for o in siblings] + [""]
    open(os.path.join(HERE, f"{t['id']}.md"), "w").write("\n".join(d))
os.makedirs(os.path.join(HERE, "types"), exist_ok=True)
index = ["# Droplet.ai library: widget types and examples", "",
         "**One adaptive widget, the right thing at the right time.** By default you keep one widget and change what it shows as the user's day goes: a Decide when you need their OK, a Timer when it's time to leave, a Checklist at the store, a Glance for a status. Add a second widget only to keep streams apart (news and social updates in one, coding approvals in another), and only when the user wants that.", "",
         "## Agentic Widgets (what users add)", "",
         "Each is a job you run as one adaptive widget. The user adds one from the Library tab (a `request` event with `value.agentic`: its job, how it adapts and its moments).", ""]
for a_ in AGENTIC:
    index += [f"- **[{a_['name']}](agentic/{a_['id']}.md)**: {a_['oneliner']}"]
index += ["",
         "## Widget types and their moments", "",
         "The **8 types** below are what your widget can become; the **examples** are good moments for each, tested at every size and in every look. Start from one and fill it with the user's real data.", "",
         "Browse with `droplet_library` (HTTP `library`): `query` in plain words, or `id` for a type or an example. Users send examples from the Library tab in the app (a `request` event, SKILL.md Process H). Style any widget with `look` (glass, soft or bold; an accent; a font).", ""]
for ty in TYPES:
    ex = [t for t in L if EXAMPLE_TYPE[t["id"]] == ty["id"]]
    index += [f"## [{ty['name']}](types/{ty['id']}.md)", "", ty["oneliner"], ""] + [f"- [{t['title']}]({t['id']}.md): {t['tagline']}" for t in ex] + [""]
    td = [f"# {ty['name']} widgets", "", f"*{ty['oneliner']}*", "",
          "## Shape", "", ty["shape"], "",
          "## How to drive it", ""] + [f"- {x}" for x in ty["drive"]] + ["",
          "## Good for", "", ", ".join(ty["good_for"]) + ".", "",
          "One widget, many uses: keep the slug, change the content as the user's day changes, and use versions (by time or place) so the phone switches by itself.", "",
          "## Examples to start from", ""] + [f"- [{t['title']}](../{t['id']}.md): {t['tagline']}" for t in ex] + ["",
          "## Looks", "", "Any look works on this type: `{\"look\": {\"style\": \"glass\" | \"soft\" | \"bold\", \"accent\": \"green\", \"font\": \"rounded\"}}`.", ""]
    open(os.path.join(HERE, "types", f"{ty['id']}.md"), "w").write("\n".join(td))
open(os.path.join(HERE, "README.md"), "w").write("\n".join(index) + "\n")
print(len(L), "templates")
