#!/usr/bin/env python3
"""Build client-ready Boojee intake packets for each productized offer.

Local-only generator: writes Markdown files under product/intake-packets/ by default.
It does not send messages, request secrets, alter cron, or touch client systems.
"""

from __future__ import annotations

import argparse
from datetime import date
from pathlib import Path

OFFERS = {
    "cleanup": {
        "name": "$297 Business Cleanup Sprint",
        "slug": "business-cleanup-sprint",
        "promise": "credential-free public-surface cleanup audit, prioritized action list, draft copy, approval queue, evidence manifest, and proof packet",
        "turnaround": "24–48 hours after usable intake/source links are supplied",
        "required": [
            "Business name and service area",
            "Website URL and public profile/social URLs to review",
            "Primary lead/contact path customers should use",
            "Top 3 services or offers to emphasize",
            "Known wrong/outdated information the client wants checked",
        ],
        "questions": [
            "What should a good lead do first: call, text, form, email, booking link, or quote request?",
            "Which services are highest margin or easiest to fulfill right now?",
            "What customer objections or trust issues come up most often?",
            "Are there seasonal offers, emergency services, service radius limits, or excluded jobs?",
            "Which public profiles should not be changed without explicit approval?",
        ],
        "deliverables": [
            "00-scope-and-intake.md",
            "02-findings-and-actions.md with up to 10 prioritized cleanup items",
            "03-copy-and-reply-drafts.md for bios, CTAs, captions, and follow-ups",
            "04-approval-queue.csv for any external/account-changing action",
            "05-proof-packet.md and 08-before-after-report.md",
        ],
    },
    "admin": {
        "name": "$500/mo AI Admin Retainer",
        "slug": "ai-admin-retainer",
        "promise": "weekly admin organization, draft replies/actions, lead/task tracking, approval queues, and monthly value reporting",
        "turnaround": "first weekly report within 5 business days of receiving the initial task/source list",
        "required": [
            "Business name, owner/operator contact, and weekly reporting preference",
            "Current admin sources to summarize (exports/screenshots/forwarded notes only; no passwords)",
            "Lead/task categories and what counts as urgent",
            "Approval rules for replies, scheduling, purchases, vendor/client contact, and account changes",
            "Business hours, service area, and escalation rules",
        ],
        "questions": [
            "What recurring admin work currently gets missed, delayed, or scattered?",
            "What should be drafted only, and what can be marked ready for approval?",
            "Which types of messages are high risk and must always be reviewed by the owner?",
            "What weekly metrics matter: leads triaged, drafts prepared, tasks closed, blockers removed, follow-ups queued?",
            "Which documents/notes should be mapped into the working document index?",
        ],
        "deliverables": [
            "Lead/task tracker populated from supplied/sample rows",
            "Approval queue for every outbound or account-changing action",
            "Weekly admin report and optional monthly value report",
            "Draft reply/action bank clearly labeled as draft-only",
            "Evidence manifest tying counts to rows, exports, or client-provided notes",
        ],
    },
    "website": {
        "name": "$750 Website Quick-Win Fix",
        "slug": "website-quick-win",
        "promise": "mobile lead-path audit, homepage/contact/CTA/trust fixes, proposed copy, implementation instructions, and proof packet",
        "turnaround": "2–4 business days for credential-free audit/proposed fixes after source links are supplied",
        "required": [
            "Website URL and highest-priority landing/service pages",
            "Desired primary conversion action (call, text, form, booking, quote)",
            "Current services, service area, and proof/trust details that can be used",
            "Known technical constraints or platform/CMS if implementation is later approved",
            "Competitor or reference sites the client likes, if any",
        ],
        "questions": [
            "What page or contact path should receive the first quick-win review?",
            "Where do customers currently get confused or drop off?",
            "Which trust details are true and allowed to publish: years, insurance, reviews, certifications, photos?",
            "Should Boojee produce implementation instructions only, or queue live edits for separate approval?",
            "What claims must not be made publicly?",
        ],
        "deliverables": [
            "Mobile/contact/CTA/trust findings and recommended fixes",
            "Homepage/service/contact copy drafts",
            "Before/proposed-after report with evidence references",
            "Approval queue for live edits if implementation is requested",
            "Generated client handoff and manifest after QA",
        ],
    },
}

BOUNDARIES = [
    "Do not include passwords, private keys, payment details, or unrelated customer personal data.",
    "Boojee can review public links and client-supplied screenshots/exports without credentials.",
    "Messages, posts, client contact, purchases, bids, dispatches, account changes, and live website edits require a specific approval queue item before execution.",
    "Drafts and proposed-after copy are not represented as implemented unless an approval record and completion evidence exist.",
]


def render_packet(key: str, updated: str) -> str:
    offer = OFFERS[key]
    required = "\n".join(f"- [ ] {item}" for item in offer["required"])
    questions = "\n".join(f"{idx}. {item}" for idx, item in enumerate(offer["questions"], 1))
    deliverables = "\n".join(f"- {item}" for item in offer["deliverables"])
    boundaries = "\n".join(f"- {item}" for item in BOUNDARIES)
    return f"""# Client Intake Packet — {offer['name']}

Updated: {updated}
Status: ready-to-use intake asset; delivery-only; no outreach action implied.

## What Boojee delivers

A {offer['promise']}.

Expected first-delivery timing: {offer['turnaround']}.

## Minimum intake required before work starts

{required}

## Client questions

{questions}

## Delivery outputs the client should expect

{deliverables}

## Approval and safety boundaries

{boundaries}

## Handoff acceptance checklist

- [ ] Client name, public links/source material, and preferred contact path are captured.
- [ ] Offer scope is confirmed and out-of-scope items are listed.
- [ ] Every recommendation is tied to a source note, screenshot/export, or client-supplied fact.
- [ ] Every draft is labeled draft/proposed until approved.
- [ ] Every external or account-changing action has a pending/approved approval queue row.
- [ ] Proof packet and before/proposed-after report pass `qa_client_workspace.py` before handoff.
"""


def main() -> int:
    parser = argparse.ArgumentParser(description="Generate Boojee offer-specific intake packets.")
    parser.add_argument("--offer", choices=sorted([*OFFERS, "all"]), default="all")
    parser.add_argument("--out-dir", default="product/intake-packets")
    parser.add_argument("--updated", default=date.today().isoformat())
    args = parser.parse_args()

    out_dir = Path(args.out_dir)
    out_dir.mkdir(parents=True, exist_ok=True)
    selected = OFFERS if args.offer == "all" else {args.offer: OFFERS[args.offer]}
    written: list[Path] = []
    for key, meta in selected.items():
        path = out_dir / f"{meta['slug']}-client-intake-packet.md"
        path.write_text(render_packet(key, args.updated), encoding="utf-8")
        written.append(path)
    for path in written:
        print(path)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
