A Codex skill that finds evidence-backed potential first customers from recent public signals.
Add report JSON schema, example fixture, tests, and CSV/JSON export with clipboard
Abhishek Sharma9f3ffd39c9fc
diff --git a/README.md b/README.mdindex 6080256..d57725e 100644--- a/README.md+++ b/README.md@@ -13,6 +13,7 @@ It defines the ideal customer profile, researches public sources, links the evid- Links every primary prospect to the original public source- Drafts respectful, source-based outreach openers- Creates a responsive standalone HTML report+- Exports prospects to CSV and JSON straight from the report- Keeps all outreach manual by default- Avoids private contact enrichment and sensitive personal data@@ -67,6 +68,28 @@ The report includes:Prospects are hypotheses based on public signals, not confirmed customers or guaranteed buyers.+## Export++Every generated report embeds the full report JSON as `<script type="application/json" id="prospect-data">`, so external tooling can read it without re-running research. Three buttons in the report header work entirely client-side, with no network calls:++- **Export CSV** — one row per prospect with name, stage, score, source URL, opener, and the five dimension scores. Drop straight into a spreadsheet or CRM.+- **Export JSON** — the full report as a pretty-printed JSON file.+- **Copy summary** — a plain-text block (product, verdict, top three prospects by score with source URL and opener, and the limits) for pasting into Slack or a doc.++Outreach is never sent automatically. The buttons only move data that is already in the report.++## Tests++The generator and the report JSON contract have a self-contained test suite using only the Python standard library:++```bash+python3 first-customer-finder/scripts/test_generate_report.py+```++It validates the example fixture at `first-customer-finder/examples/analysis.example.json` against the JSON schema at `first-customer-finder/references/report.schema.json`, checks that every prospect score matches the scoring formula in `research-framework.md`, and confirms the generator output matches the golden HTML snapshot at `first-customer-finder/examples/first-customer-finder-report.golden.html`. Run it after any change to the generator or schema.++If the optional `jsonschema` package is installed, the schema validation check runs; otherwise it self-skips.+## Modes- `quick`: up to five strong prospectsdiff --git a/first-customer-finder/examples/analysis.example.json b/first-customer-finder/examples/analysis.example.jsonnew file mode 100644index 0000000..5cd0852--- /dev/null+++ b/first-customer-finder/examples/analysis.example.json@@ -0,0 +1,106 @@+{+ "title": "First Customer Finder",+ "product": "Example Studio",+ "product_url": "https://example.com",+ "target_customer": "Independent gym owners",+ "search_scope": "Public English-language sources, last 12 months",+ "generated_at": "2026-07-12",+ "verdict": "The strongest early demand comes from owners manually chasing failed membership payments and asking peers how to handle them.",+ "prospects": [+ {+ "name": "Riverside Fitness (example)",+ "type": "Company",+ "stage": "High intent",+ "score": 90,+ "pain_signal": "The owner publicly described manually following up on overdue memberships and asked how other owners handle the same workflow.",+ "evidence": "A recent public forum thread shows the owner describing the manual reminder cadence, the time cost, and asking for alternatives.",+ "why_fit": "The product automates the exact reminder and payment step the owner is doing by hand.",+ "why_now": "The thread is recent and the owner is actively asking for a better approach.",+ "source_title": "How do you handle failed payments? (example)",+ "source_url": "https://example.com/forum/thread-1",+ "source_type": "Public forum",+ "signal_date": "2026-07-01",+ "suggested_channel": "Reply to the public discussion",+ "opener": "Saw your question about failed-payment follow-up. The manual chase is exactly what we automated for a couple of small gyms. Mind if I share the one-line version?",+ "caution": "Confirm the workflow is still active before pitching.",+ "dimensions": {+ "pain_strength": 5,+ "product_fit": 5,+ "timing": 4,+ "reachability": 4,+ "evidence_quality": 4+ }+ },+ {+ "name": "Corner Gym (example)",+ "type": "Company",+ "stage": "Problem aware",+ "score": 73,+ "pain_signal": "The owner posted about spending hours each month reconciling failed card retries against a spreadsheet.",+ "evidence": "A public post describes the spreadsheet workaround and the monthly time cost without naming a tool.",+ "why_fit": "The product replaces the spreadsheet reconciliation step with automatic retry and reporting.",+ "why_now": "The post is a few months old, so freshness is lower, but the workaround is ongoing.",+ "source_title": "Monthly failed-payment reconciliation (example)",+ "source_url": "https://example.com/forum/thread-2",+ "source_type": "Public forum",+ "signal_date": "2026-04-18",+ "suggested_channel": "Reply to the public discussion",+ "opener": "Your spreadsheet-reconciliation process sounded familiar. We replaced that exact step for two gyms. Worth a quick look?",+ "caution": "Verify the owner is still at the same gym before outreach.",+ "dimensions": {+ "pain_strength": 4,+ "product_fit": 4,+ "timing": 3,+ "reachability": 4,+ "evidence_quality": 3+ }+ },+ {+ "name": "Northgate Fitness (example)",+ "type": "Company",+ "stage": "Trigger present",+ "score": 65,+ "pain_signal": "The gym publicly announced a billing-system migration and asked members for patience during the transition.",+ "evidence": "A public announcement describes an in-progress billing migration and asks for patience, implying a current gap.",+ "why_fit": "The product can run alongside the migration as a fallback for failed payments during the cutover.",+ "why_now": "The migration is in progress, so the timing trigger is live but the buyer is busy.",+ "source_title": "Billing migration update (example)",+ "source_url": "https://example.com/news/billing-migration",+ "source_type": "Company page",+ "signal_date": "2026-06-20",+ "suggested_channel": "Public contact form or reply on the announcement",+ "opener": "Noticed your billing migration note. During cutovers, failed retries usually spike. We built a fallback that catches them. Useful as a safety net for the next few weeks?",+ "caution": "Approach as a safety net, not a replacement, during their migration.",+ "dimensions": {+ "pain_strength": 3,+ "product_fit": 4,+ "timing": 3,+ "reachability": 3,+ "evidence_quality": 3+ }+ }+ ],+ "patterns": [+ {+ "title": "Manual follow-up",+ "count": 2,+ "insight": "Owners rely on spreadsheets and messaging apps after payments fail."+ },+ {+ "title": "Cutover vulnerability",+ "count": 1,+ "insight": "Billing migrations create a temporary window where failed retries go unhandled."+ }+ ],+ "outreach_plan": {+ "angle": "Offer a manual concierge test before asking for software adoption.",+ "first_step": "Contact the three highest-scoring prospects with one source-based question.",+ "follow_up": "Share a two-minute mockup only after they confirm the pain.",+ "success": "Three conversations and one design-partner commitment within seven days."+ },+ "limits": [+ "These are potential customers inferred from public signals, not confirmed buyers.",+ "Verify current relevance before any outreach and keep contact manual.",+ "Source URLs are example placeholders in this fixture."+ ]+}diff --git a/first-customer-finder/examples/first-customer-finder-report.golden.html b/first-customer-finder/examples/first-customer-finder-report.golden.htmlnew file mode 100644index 0000000..f2676c7--- /dev/null+++ b/first-customer-finder/examples/first-customer-finder-report.golden.html@@ -0,0 +1,206 @@+<!doctype html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width,initial-scale=1">+ <meta name="color-scheme" content="dark">+ <title>First Customer Finder</title>+ <style>+ :root{--bg:#090b0f;--panel:#12161d;--panel2:#191f28;--ink:#f5f2ea;--muted:#9ca6b5;--line:#2b3340;--acid:#d9ff63;--blue:#69b7ff;--orange:#ff8f5a;--cyan:#5ee8d0;--radius:18px;--shadow:0 24px 80px rgba(0,0,0,.38)}+ *{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--bg);color:var(--ink);font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;line-height:1.55}body:before{content:"";position:fixed;inset:0;pointer-events:none;opacity:.3;background:repeating-linear-gradient(135deg,rgba(255,255,255,.018) 0 1px,transparent 1px 12px);mask-image:linear-gradient(#000,transparent 82%)}a{color:inherit}.skip{position:absolute;left:-9999px}.skip:focus{left:16px;top:16px;z-index:9;background:var(--acid);color:#111;padding:10px}+ .shell{width:min(1180px,calc(100% - 40px));margin:auto;position:relative}.top{display:flex;justify-content:space-between;align-items:center;padding:22px 0;border-bottom:1px solid var(--line)}.brand{font-weight:850;display:flex;align-items:center;gap:10px}.brand i{width:12px;height:12px;border-radius:50%;background:var(--acid);box-shadow:0 0 22px var(--acid)}.meta{display:flex;gap:8px;align-items:center}.chip,.stage{border:1px solid var(--line);border-radius:999px;padding:7px 10px;color:var(--muted);font:750 11px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.07em}button{background:var(--ink);color:#111;border:0;border-radius:999px;padding:9px 14px;font:800 13px inherit;cursor:pointer}button:focus-visible,summary:focus-visible,a:focus-visible{outline:3px solid var(--blue);outline-offset:3px}+ .hero{display:grid;grid-template-columns:1.45fr .55fr;gap:36px;align-items:end;padding:72px 0 42px}.eyebrow{color:var(--acid);font:750 11px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.11em}h1{font-size:clamp(48px,7vw,92px);line-height:.92;letter-spacing:-.065em;margin:13px 0 24px}.verdict{font-size:clamp(18px,2.1vw,25px);color:#dce1e9;max-width:820px;margin:0}.hero-card{background:var(--acid);color:#10120d;padding:26px;border-radius:var(--radius);box-shadow:var(--shadow);transform:rotate(1deg)}.hero-card span{font:800 11px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.08em}.hero-card strong{display:block;font-size:64px;line-height:1;letter-spacing:-.08em;margin:15px 0 6px}.hero-card p{margin:0;font-weight:700;font-size:13px}+ .stats{display:grid;grid-template-columns:repeat(4,1fr);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;margin-bottom:28px}.stats>div{padding:18px;background:var(--panel)}.stats>div+div{border-left:1px solid var(--line)}.stats span,.prospect-grid span,.signal span,.evidence span,blockquote span{display:block;color:var(--muted);font:700 10px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.08em;margin-bottom:6px}.stats strong{font-size:17px}+ .best{display:grid;grid-template-columns:180px 1fr auto;gap:24px;align-items:center;padding:25px;background:var(--orange);color:#1b0f09;border-radius:var(--radius);box-shadow:var(--shadow);margin:0 0 72px}.best-label{font:800 11px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.1em}.best h2{font-size:clamp(28px,4vw,46px);letter-spacing:-.045em;line-height:1;margin:0 0 8px}.best p{margin:0}.best strong{font-size:44px}+ .section-head{display:flex;justify-content:space-between;align-items:end;gap:24px;padding-bottom:18px;border-bottom:1px solid var(--line);margin-bottom:18px}.section-head h2{font-size:clamp(34px,5vw,62px);line-height:.98;letter-spacing:-.055em;margin:0}.section-head p{color:var(--muted);max-width:470px;margin:0}+ .prospects{display:grid;gap:16px;margin-bottom:76px}.prospect{background:linear-gradient(135deg,var(--panel),#0f1319);border:1px solid var(--line);border-radius:var(--radius);padding:25px;box-shadow:0 12px 38px rgba(0,0,0,.18)}.prospect-head{display:grid;grid-template-columns:54px 1fr 92px;gap:17px;align-items:start}.rank{font:850 24px ui-monospace,monospace;color:var(--acid);padding-top:8px}.identity h3{font-size:29px;letter-spacing:-.04em;margin:6px 0 10px}.stage{display:inline-block}.stage.hot{color:var(--orange);border-color:rgba(255,143,90,.5)}.stage.warm{color:var(--cyan);border-color:rgba(94,232,208,.45)}.score{--score:0;width:88px;height:88px;border-radius:50%;display:grid;place-content:center;text-align:center;background:radial-gradient(circle,var(--panel) 58%,transparent 60%),conic-gradient(var(--acid) calc(var(--score)*1%),var(--line) 0)}.score strong{font-size:26px;line-height:1}.score small{color:var(--muted)}+ .signal{margin:21px 0 12px;padding:16px;background:var(--panel2);border-left:4px solid var(--acid)}.signal p{font-size:17px;margin:0}.prospect-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}.prospect-grid>div,.evidence>div{border:1px solid var(--line);border-radius:12px;padding:15px;background:rgba(255,255,255,.018)}.prospect-grid p,.evidence p{margin:0}blockquote{margin:12px 0 0;padding:16px;border:1px dashed rgba(217,255,99,.55);border-radius:12px;color:#eaf6c6}details{margin-top:10px}summary{cursor:pointer;color:var(--acid);font-weight:800;padding:10px 0}.evidence{display:grid;grid-template-columns:1fr 1fr;gap:9px}.evidence a{display:inline-block;color:var(--blue);margin-top:8px;word-break:break-word}.metrics{display:grid;gap:8px;margin-top:14px}.metric{display:grid;grid-template-columns:145px 1fr 40px;gap:12px;align-items:center;font-size:13px}.track{height:8px;background:var(--line);border-radius:8px;overflow:hidden}.track i{display:block;height:100%;background:linear-gradient(90deg,var(--blue),var(--acid))}+ .patterns{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;margin-bottom:76px}.pattern{display:grid;grid-template-columns:42px 1fr auto;gap:15px;align-items:start;padding:20px;border:1px solid var(--line);border-radius:14px;background:var(--panel)}.pattern-num{color:var(--acid);font:800 13px ui-monospace,monospace}.pattern h3{margin:0 0 5px}.pattern p{margin:0;color:var(--muted)}.pattern>strong{font-size:30px;color:var(--acid)}+ .plan{display:grid;grid-template-columns:.8fr 1.2fr;gap:28px;background:var(--acid);color:#111;padding:29px;border-radius:var(--radius);margin-bottom:30px}.plan h2{font-size:38px;line-height:1;letter-spacing:-.045em;margin:10px 0}.plan-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}.plan-grid>div{border:1px solid rgba(0,0,0,.24);border-radius:11px;padding:13px}.plan-grid span{display:block;font:750 10px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.07em;margin-bottom:5px}.plan-grid p{margin:0}.limits{border:1px solid var(--line);border-radius:var(--radius);padding:24px;color:var(--muted);margin-bottom:60px}.limits h2{color:var(--ink);margin-top:0}footer{display:flex;justify-content:space-between;gap:20px;border-top:1px solid var(--line);padding:22px 0 40px;color:var(--muted);font-size:12px}.reveal{animation:rise .4s ease both}@keyframes rise{from{opacity:0;transform:translateY(12px)}}+ @media(max-width:820px){.shell{width:min(100% - 24px,1180px)}.hero,.plan{grid-template-columns:1fr}.hero{padding-top:44px}.hero-card{transform:none}.stats{grid-template-columns:1fr 1fr}.stats>div+div{border-left:0;border-top:1px solid var(--line)}.best{grid-template-columns:1fr}.prospect-head{grid-template-columns:38px 1fr}.score{grid-column:1/-1}.prospect-grid,.evidence,.patterns,.plan-grid{grid-template-columns:1fr}.meta .chip{display:none}}+ @media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important;scroll-behavior:auto!important}}@media print{body{background:#fff;color:#111}body:before,.top button{display:none}.shell{width:100%}.prospect,.pattern,.limits{background:#fff;color:#111;break-inside:avoid}.prospect-grid span,.signal span,.evidence span,blockquote span{color:#444}}+ .toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%) translateY(20px);background:var(--acid);color:#111;padding:11px 18px;border-radius:999px;font:800 13px inherit;box-shadow:var(--shadow);opacity:0;pointer-events:none;transition:opacity .25s,transform .25s;z-index:99}.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}.meta button[data-action]{background:var(--panel2);color:var(--ink);border:1px solid var(--line)}+ </style>+</head>+<body>+ <a class="skip" href="#main">Skip to report</a>+ <div class="shell">+ <header class="top"><div class="brand"><i></i> First Customer Finder</div><div class="meta"><span class="chip">Public signals only</span><button type="button" data-action="export-csv">Export CSV</button><button type="button" data-action="export-json">Export JSON</button><button type="button" data-action="copy-summary">Copy summary</button><button type="button" onclick="window.print()">Print / Save PDF</button></div></header>+ <main id="main">+ <section class="hero"><div><span class="eyebrow">Early-customer report · 2026-07-12</span><h1>First Customer Finder</h1><p class="verdict">The strongest early demand comes from owners manually chasing failed membership payments and asking peers how to handle them.</p></div><aside class="hero-card"><span>Qualified prospects</span><strong>3</strong><p>Potential customers based on public signals.</p></aside></section>+ <section class="stats"><div><span>Product</span><strong><a href="https://example.com" target="_blank" rel="noreferrer">Example Studio</a></strong></div><div><span>Target customer</span><strong>Independent gym owners</strong></div><div><span>High intent</span><strong>1</strong></div><div><span>Average fit score</span><strong>76/100</strong></div></section>+ <section class="best"><div class="best-label">Highest-confidence prospect</div><div><h2>Riverside Fitness (example)</h2><p>The thread is recent and the owner is actively asking for a better approach.</p></div><strong>90</strong></section>+ <section><header class="section-head"><h2>People with a reason<br>to care now.</h2><p>Every primary prospect is tied to a public pain, demand, or timing signal. Open the evidence before considering outreach.</p></header><div class="prospects">+ <article class="prospect reveal">+ <header class="prospect-head">+ <div class="rank">01</div>+ <div class="identity">+ <span class="eyebrow">Company</span>+ <h3>Riverside Fitness (example)</h3>+ <span class="stage hot">High intent</span>+ </div>+ <div class="score" style="--score:90" aria-label="Fit score 90 out of 100"><strong>90</strong><small>/100</small></div>+ </header>+ <div class="signal"><span>Public signal</span><p>The owner publicly described manually following up on overdue memberships and asked how other owners handle the same workflow.</p></div>+ <div class="prospect-grid">+ <div><span>Why it fits</span><p>The product automates the exact reminder and payment step the owner is doing by hand.</p></div>+ <div><span>Why now</span><p>The thread is recent and the owner is actively asking for a better approach.</p></div>+ <div><span>Suggested channel</span><p>Reply to the public discussion</p></div>+ <div><span>Caution</span><p>Confirm the workflow is still active before pitching.</p></div>+ </div>+ <blockquote><span>Suggested opener</span>Saw your question about failed-payment follow-up. The manual chase is exactly what we automated for a couple of small gyms. Mind if I share the one-line version?</blockquote>+ <details>+ <summary>Evidence and score breakdown</summary>+ <div class="evidence"><div><span>Evidence</span><p>A recent public forum thread shows the owner describing the manual reminder cadence, the time cost, and asking for alternatives.</p></div><div><span>Source</span><p>Public forum · 2026-07-01</p><a href="https://example.com/forum/thread-1" target="_blank" rel="noreferrer">How do you handle failed payments? (example) ↗</a></div></div>+ <div class="metrics"><div class="metric"><span>Pain strength</span><div class="track"><i style="width:100%"></i></div><b>5/5</b></div><div class="metric"><span>Product fit</span><div class="track"><i style="width:100%"></i></div><b>5/5</b></div><div class="metric"><span>Timing</span><div class="track"><i style="width:80%"></i></div><b>4/5</b></div><div class="metric"><span>Reachability</span><div class="track"><i style="width:80%"></i></div><b>4/5</b></div><div class="metric"><span>Evidence quality</span><div class="track"><i style="width:80%"></i></div><b>4/5</b></div></div>+ </details>+ </article>+ <article class="prospect reveal">+ <header class="prospect-head">+ <div class="rank">02</div>+ <div class="identity">+ <span class="eyebrow">Company</span>+ <h3>Corner Gym (example)</h3>+ <span class="stage warm">Problem aware</span>+ </div>+ <div class="score" style="--score:73" aria-label="Fit score 73 out of 100"><strong>73</strong><small>/100</small></div>+ </header>+ <div class="signal"><span>Public signal</span><p>The owner posted about spending hours each month reconciling failed card retries against a spreadsheet.</p></div>+ <div class="prospect-grid">+ <div><span>Why it fits</span><p>The product replaces the spreadsheet reconciliation step with automatic retry and reporting.</p></div>+ <div><span>Why now</span><p>The post is a few months old, so freshness is lower, but the workaround is ongoing.</p></div>+ <div><span>Suggested channel</span><p>Reply to the public discussion</p></div>+ <div><span>Caution</span><p>Verify the owner is still at the same gym before outreach.</p></div>+ </div>+ <blockquote><span>Suggested opener</span>Your spreadsheet-reconciliation process sounded familiar. We replaced that exact step for two gyms. Worth a quick look?</blockquote>+ <details>+ <summary>Evidence and score breakdown</summary>+ <div class="evidence"><div><span>Evidence</span><p>A public post describes the spreadsheet workaround and the monthly time cost without naming a tool.</p></div><div><span>Source</span><p>Public forum · 2026-04-18</p><a href="https://example.com/forum/thread-2" target="_blank" rel="noreferrer">Monthly failed-payment reconciliation (example) ↗</a></div></div>+ <div class="metrics"><div class="metric"><span>Pain strength</span><div class="track"><i style="width:80%"></i></div><b>4/5</b></div><div class="metric"><span>Product fit</span><div class="track"><i style="width:80%"></i></div><b>4/5</b></div><div class="metric"><span>Timing</span><div class="track"><i style="width:60%"></i></div><b>3/5</b></div><div class="metric"><span>Reachability</span><div class="track"><i style="width:80%"></i></div><b>4/5</b></div><div class="metric"><span>Evidence quality</span><div class="track"><i style="width:60%"></i></div><b>3/5</b></div></div>+ </details>+ </article>+ <article class="prospect reveal">+ <header class="prospect-head">+ <div class="rank">03</div>+ <div class="identity">+ <span class="eyebrow">Company</span>+ <h3>Northgate Fitness (example)</h3>+ <span class="stage warm">Trigger present</span>+ </div>+ <div class="score" style="--score:65" aria-label="Fit score 65 out of 100"><strong>65</strong><small>/100</small></div>+ </header>+ <div class="signal"><span>Public signal</span><p>The gym publicly announced a billing-system migration and asked members for patience during the transition.</p></div>+ <div class="prospect-grid">+ <div><span>Why it fits</span><p>The product can run alongside the migration as a fallback for failed payments during the cutover.</p></div>+ <div><span>Why now</span><p>The migration is in progress, so the timing trigger is live but the buyer is busy.</p></div>+ <div><span>Suggested channel</span><p>Public contact form or reply on the announcement</p></div>+ <div><span>Caution</span><p>Approach as a safety net, not a replacement, during their migration.</p></div>+ </div>+ <blockquote><span>Suggested opener</span>Noticed your billing migration note. During cutovers, failed retries usually spike. We built a fallback that catches them. Useful as a safety net for the next few weeks?</blockquote>+ <details>+ <summary>Evidence and score breakdown</summary>+ <div class="evidence"><div><span>Evidence</span><p>A public announcement describes an in-progress billing migration and asks for patience, implying a current gap.</p></div><div><span>Source</span><p>Company page · 2026-06-20</p><a href="https://example.com/news/billing-migration" target="_blank" rel="noreferrer">Billing migration update (example) ↗</a></div></div>+ <div class="metrics"><div class="metric"><span>Pain strength</span><div class="track"><i style="width:60%"></i></div><b>3/5</b></div><div class="metric"><span>Product fit</span><div class="track"><i style="width:80%"></i></div><b>4/5</b></div><div class="metric"><span>Timing</span><div class="track"><i style="width:60%"></i></div><b>3/5</b></div><div class="metric"><span>Reachability</span><div class="track"><i style="width:60%"></i></div><b>3/5</b></div><div class="metric"><span>Evidence quality</span><div class="track"><i style="width:60%"></i></div><b>3/5</b></div></div>+ </details>+ </article></div></section>+ <section><header class="section-head"><h2>Signals that repeat.</h2><p>Patterns across prospects reveal the strongest positioning, workflow, and outreach angles.</p></header><div class="patterns">+ <article class="pattern reveal"><span class="pattern-num">01</span><div><h3>Manual follow-up</h3><p>Owners rely on spreadsheets and messaging apps after payments fail.</p></div><strong>2×</strong></article>+ <article class="pattern reveal"><span class="pattern-num">02</span><div><h3>Cutover vulnerability</h3><p>Billing migrations create a temporary window where failed retries go unhandled.</p></div><strong>1×</strong></article></div></section>+ <section class="plan"><div><span class="eyebrow" style="color:#111">Seven-day manual plan</span><h2>Offer a manual concierge test before asking for software adoption.</h2></div><div class="plan-grid"><div><span>First step</span><p>Contact the three highest-scoring prospects with one source-based question.</p></div><div><span>Follow-up</span><p>Share a two-minute mockup only after they confirm the pain.</p></div><div><span>Success signal</span><p>Three conversations and one design-partner commitment within seven days.</p></div><div><span>Research scope</span><p>Public English-language sources, last 12 months</p></div></div></section>+ <section class="limits"><h2>Use this shortlist responsibly</h2><ul><li>These are potential customers inferred from public signals, not confirmed buyers.</li><li>Verify current relevance before any outreach and keep contact manual.</li><li>Source URLs are example placeholders in this fixture.</li></ul></section>+ </main>+ <footer><span>Generated by $first-customer-finder</span><span>Outreach is never sent automatically.</span></footer>+ </div>+ <div class="toast" id="toast" role="status" aria-live="polite"></div>+ <script type="application/json" id="prospect-data">{"title": "First Customer Finder", "product": "Example Studio", "product_url": "https://example.com", "target_customer": "Independent gym owners", "search_scope": "Public English-language sources, last 12 months", "generated_at": "2026-07-12", "verdict": "The strongest early demand comes from owners manually chasing failed membership payments and asking peers how to handle them.", "prospects": [{"name": "Riverside Fitness (example)", "type": "Company", "stage": "High intent", "score": 90, "pain_signal": "The owner publicly described manually following up on overdue memberships and asked how other owners handle the same workflow.", "evidence": "A recent public forum thread shows the owner describing the manual reminder cadence, the time cost, and asking for alternatives.", "why_fit": "The product automates the exact reminder and payment step the owner is doing by hand.", "why_now": "The thread is recent and the owner is actively asking for a better approach.", "source_title": "How do you handle failed payments? (example)", "source_url": "https://example.com/forum/thread-1", "source_type": "Public forum", "signal_date": "2026-07-01", "suggested_channel": "Reply to the public discussion", "opener": "Saw your question about failed-payment follow-up. The manual chase is exactly what we automated for a couple of small gyms. Mind if I share the one-line version?", "caution": "Confirm the workflow is still active before pitching.", "dimensions": {"pain_strength": 5, "product_fit": 5, "timing": 4, "reachability": 4, "evidence_quality": 4}}, {"name": "Corner Gym (example)", "type": "Company", "stage": "Problem aware", "score": 73, "pain_signal": "The owner posted about spending hours each month reconciling failed card retries against a spreadsheet.", "evidence": "A public post describes the spreadsheet workaround and the monthly time cost without naming a tool.", "why_fit": "The product replaces the spreadsheet reconciliation step with automatic retry and reporting.", "why_now": "The post is a few months old, so freshness is lower, but the workaround is ongoing.", "source_title": "Monthly failed-payment reconciliation (example)", "source_url": "https://example.com/forum/thread-2", "source_type": "Public forum", "signal_date": "2026-04-18", "suggested_channel": "Reply to the public discussion", "opener": "Your spreadsheet-reconciliation process sounded familiar. We replaced that exact step for two gyms. Worth a quick look?", "caution": "Verify the owner is still at the same gym before outreach.", "dimensions": {"pain_strength": 4, "product_fit": 4, "timing": 3, "reachability": 4, "evidence_quality": 3}}, {"name": "Northgate Fitness (example)", "type": "Company", "stage": "Trigger present", "score": 65, "pain_signal": "The gym publicly announced a billing-system migration and asked members for patience during the transition.", "evidence": "A public announcement describes an in-progress billing migration and asks for patience, implying a current gap.", "why_fit": "The product can run alongside the migration as a fallback for failed payments during the cutover.", "why_now": "The migration is in progress, so the timing trigger is live but the buyer is busy.", "source_title": "Billing migration update (example)", "source_url": "https://example.com/news/billing-migration", "source_type": "Company page", "signal_date": "2026-06-20", "suggested_channel": "Public contact form or reply on the announcement", "opener": "Noticed your billing migration note. During cutovers, failed retries usually spike. We built a fallback that catches them. Useful as a safety net for the next few weeks?", "caution": "Approach as a safety net, not a replacement, during their migration.", "dimensions": {"pain_strength": 3, "product_fit": 4, "timing": 3, "reachability": 3, "evidence_quality": 3}}], "patterns": [{"title": "Manual follow-up", "count": 2, "insight": "Owners rely on spreadsheets and messaging apps after payments fail."}, {"title": "Cutover vulnerability", "count": 1, "insight": "Billing migrations create a temporary window where failed retries go unhandled."}], "outreach_plan": {"angle": "Offer a manual concierge test before asking for software adoption.", "first_step": "Contact the three highest-scoring prospects with one source-based question.", "follow_up": "Share a two-minute mockup only after they confirm the pain.", "success": "Three conversations and one design-partner commitment within seven days."}, "limits": ["These are potential customers inferred from public signals, not confirmed buyers.", "Verify current relevance before any outreach and keep contact manual.", "Source URLs are example placeholders in this fixture."]}</script>+ <script>+ (function () {+ var el = document.getElementById('prospect-data');+ if (!el) return;+ var data;+ try { data = JSON.parse(el.textContent); } catch (e) { return; }+ function toast(msg) {+ var t = document.getElementById('toast');+ if (!t) return;+ t.textContent = msg;+ t.classList.add('show');+ setTimeout(function () { t.classList.remove('show'); }, 2200);+ }+ function download(name, text, mime) {+ var blob = new Blob([text], { type: mime || 'text/plain;charset=utf-8' });+ var url = URL.createObjectURL(blob);+ var a = document.createElement('a');+ a.href = url;+ a.download = name;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ setTimeout(function () { URL.revokeObjectURL(url); }, 1000);+ }+ function csvField(v) {+ v = v == null ? '' : String(v);+ v = v.replace(/"/g, '""').replace(/\r?\n/g, ' ');+ return '"' + v + '"';+ }+ function exportCSV() {+ var cols = ['Name','Type','Stage','Score','Pain signal','Why fit','Why now','Source title','Source URL','Source type','Signal date','Suggested channel','Opener','Caution','Pain strength','Product fit','Timing','Reachability','Evidence quality'];+ var rows = [cols.map(csvField).join(',')];+ (data.prospects || []).forEach(function (p) {+ var d = p.dimensions || {};+ rows.push([p.name, p.type, p.stage, p.score, p.pain_signal, p.why_fit, p.why_now, p.source_title, p.source_url, p.source_type, p.signal_date, p.suggested_channel, p.opener, p.caution, d.pain_strength, d.product_fit, d.timing, d.reachability, d.evidence_quality].map(csvField).join(','));+ });+ download('first-customer-finder-prospects.csv', rows.join('\n'), 'text/csv;charset=utf-8');+ toast('CSV downloaded');+ }+ function exportJSON() {+ download('first-customer-finder-report.json', JSON.stringify(data, null, 2), 'application/json;charset=utf-8');+ toast('JSON downloaded');+ }+ function copySummary() {+ var lines = [];+ lines.push(data.title || 'First Customer Finder');+ lines.push('Product: ' + (data.product || '') + (data.product_url ? ' (' + data.product_url + ')' : ''));+ lines.push('Target customer: ' + (data.target_customer || ''));+ lines.push('Verdict: ' + (data.verdict || ''));+ lines.push('');+ var top = (data.prospects || []).slice().sort(function (a, b) { return (b.score || 0) - (a.score || 0); }).slice(0, 3);+ lines.push('Top prospects:');+ top.forEach(function (p, i) {+ lines.push((i + 1) + '. ' + (p.name || '') + ' — score ' + (p.score || 0) + '/100');+ if (p.source_url) lines.push(' Source: ' + p.source_url);+ if (p.opener) lines.push(' Opener: ' + p.opener);+ });+ if (data.limits && data.limits.length) {+ lines.push('');+ lines.push('Limits:');+ data.limits.forEach(function (l) { lines.push('- ' + l); });+ }+ var text = lines.join('\n');+ function done() { toast('Summary copied to clipboard'); }+ if (navigator.clipboard && navigator.clipboard.writeText) {+ navigator.clipboard.writeText(text).then(done, function () { fallbackCopy(text); done(); });+ } else { fallbackCopy(text); done(); }+ }+ function fallbackCopy(text) {+ var ta = document.createElement('textarea');+ ta.value = text;+ ta.style.position = 'fixed';+ ta.style.left = '-9999px';+ document.body.appendChild(ta);+ ta.focus();+ ta.select();+ try { document.execCommand('copy'); } catch (e) {}+ document.body.removeChild(ta);+ }+ document.querySelectorAll('[data-action]').forEach(function (btn) {+ btn.addEventListener('click', function () {+ var a = btn.getAttribute('data-action');+ if (a === 'export-csv') exportCSV();+ else if (a === 'export-json') exportJSON();+ else if (a === 'copy-summary') copySummary();+ });+ });+ })();+ </script>+</body>+</html>\ No newline at end of filediff --git a/first-customer-finder/references/report-artifact.md b/first-customer-finder/references/report-artifact.mdindex 14e6ba5..ed42da7 100644--- a/first-customer-finder/references/report-artifact.md+++ b/first-customer-finder/references/report-artifact.md@@ -10,6 +10,20 @@ python3 scripts/generate_report.py analysis.json outputs/first-customer-finder-rReturn a clickable absolute file link in Codex. Keep the JSON in a work or temporary directory unless the user asks for raw data.+The JSON shape is formally defined in `references/report.schema.json` (JSON Schema draft-07). A complete worked example lives at `examples/analysis.example.json`, and a rendered snapshot at `examples/first-customer-finder-report.golden.html`. Run `python3 scripts/test_generate_report.py` to verify the generator still matches that snapshot.++## Export++The generated report is self-contained and portable. The full report JSON is also embedded in the HTML as `<script type="application/json" id="prospect-data">`, so external tooling can read it without re-running research.++Three buttons in the report header work entirely client-side, with no network calls:++- **Export CSV** — downloads `first-customer-finder-prospects.csv` with one row per prospect (name, type, stage, score, pain signal, why fit, why now, source title, source URL, source type, signal date, suggested channel, opener, caution, and the five dimension scores).+- **Export JSON** — downloads the full report as `first-customer-finder-report.json` (pretty-printed).+- **Copy summary** — copies a plain-text block to the clipboard: product, verdict, the top three prospects by score with their source URL and opener, and the limits. Useful for pasting into a Slack thread or doc.++Outreach is never sent automatically. The buttons only move data that is already in the report.+## JSON schema```jsondiff --git a/first-customer-finder/references/report.schema.json b/first-customer-finder/references/report.schema.jsonnew file mode 100644index 0000000..0ccd331--- /dev/null+++ b/first-customer-finder/references/report.schema.json@@ -0,0 +1,166 @@+{+ "$schema": "http://json-schema.org/draft-07/schema#",+ "$id": "https://github.com/Kappaemme-git/codex-first-customer-finder-skill/first-customer-finder/references/report.schema.json",+ "title": "First Customer Finder report",+ "description": "JSON contract for the analysis file consumed by scripts/generate_report.py. Derived from references/report-artifact.md and references/research-framework.md.",+ "type": "object",+ "additionalProperties": false,+ "required": ["title", "product", "product_url", "target_customer", "generated_at", "verdict", "prospects"],+ "properties": {+ "title": {+ "type": "string",+ "description": "Report title shown in the hero."+ },+ "product": {+ "type": "string",+ "description": "Product or startup name."+ },+ "product_url": {+ "type": "string",+ "format": "uri",+ "description": "Public URL of the product or landing page."+ },+ "target_customer": {+ "type": "string",+ "description": "Primary ideal customer profile label."+ },+ "search_scope": {+ "type": "string",+ "description": "Time, language, and source scope used for research."+ },+ "generated_at": {+ "type": "string",+ "format": "date",+ "description": "Date the report was generated (YYYY-MM-DD)."+ },+ "verdict": {+ "type": "string",+ "description": "One-sentence read on whether reachable early-customer signals exist."+ },+ "prospects": {+ "type": "array",+ "description": "Qualified prospects. Normal mode: up to ten. Every primary prospect must include a valid public source URL and a score from 0 to 100.",+ "items": { "$ref": "#/definitions/prospect" }+ },+ "patterns": {+ "type": "array",+ "description": "Repeated pain or trigger patterns observed across prospects.",+ "items": { "$ref": "#/definitions/pattern" }+ },+ "outreach_plan": { "$ref": "#/definitions/outreachPlan" },+ "limits": {+ "type": "array",+ "description": "Caveats shown in the responsible-use section.",+ "items": { "type": "string" }+ }+ },+ "definitions": {+ "prospect": {+ "type": "object",+ "additionalProperties": false,+ "required": ["name", "type", "stage", "score", "pain_signal", "why_fit", "why_now", "source_url", "dimensions"],+ "properties": {+ "name": {+ "type": "string",+ "description": "Displayed company, project, or public professional name."+ },+ "type": {+ "type": "string",+ "description": "Prospect category, e.g. Company, Person, Project."+ },+ "stage": {+ "type": "string",+ "enum": ["High intent", "Problem aware", "Trigger present", "Potential fit"],+ "description": "Qualification stage from the research framework."+ },+ "score": {+ "type": "integer",+ "minimum": 0,+ "maximum": 100,+ "description": "Composite fit score from 0 to 100, computed from the five weighted dimensions."+ },+ "pain_signal": {+ "type": "string",+ "description": "Concise public pain, demand, or timing signal."+ },+ "evidence": {+ "type": "string",+ "description": "What the public source shows."+ },+ "why_fit": {+ "type": "string",+ "description": "Why the product fits the evidenced job."+ },+ "why_now": {+ "type": "string",+ "description": "Why this is relevant now, including freshness and any current trigger."+ },+ "source_title": {+ "type": "string",+ "description": "Title of the public source."+ },+ "source_url": {+ "type": "string",+ "format": "uri",+ "description": "Public URL of the original source."+ },+ "source_type": {+ "type": "string",+ "description": "Source category, e.g. Public forum, Review, GitHub issue, Company page."+ },+ "signal_date": {+ "type": "string",+ "format": "date",+ "description": "Visible publication date of the signal (YYYY-MM-DD)."+ },+ "suggested_channel": {+ "type": "string",+ "description": "Natural, relevant public or professional contact path."+ },+ "opener": {+ "type": "string",+ "description": "Source-based outreach opener, under 90 words by default."+ },+ "caution": {+ "type": "string",+ "description": "What must be confirmed before outreach."+ },+ "dimensions": { "$ref": "#/definitions/dimensions" }+ }+ },+ "dimensions": {+ "type": "object",+ "additionalProperties": false,+ "required": ["pain_strength", "product_fit", "timing", "reachability", "evidence_quality"],+ "description": "Per-dimension scores from 0 to 5. Composite score = pain/5*25 + fit/5*25 + timing/5*20 + reachability/5*15 + evidence/5*15.",+ "properties": {+ "pain_strength": { "type": "integer", "minimum": 0, "maximum": 5 },+ "product_fit": { "type": "integer", "minimum": 0, "maximum": 5 },+ "timing": { "type": "integer", "minimum": 0, "maximum": 5 },+ "reachability": { "type": "integer", "minimum": 0, "maximum": 5 },+ "evidence_quality": { "type": "integer", "minimum": 0, "maximum": 5 }+ }+ },+ "pattern": {+ "type": "object",+ "additionalProperties": false,+ "required": ["title", "count", "insight"],+ "properties": {+ "title": { "type": "string" },+ "count": { "type": "integer", "minimum": 0 },+ "insight": { "type": "string" }+ }+ },+ "outreachPlan": {+ "type": "object",+ "additionalProperties": false,+ "required": ["angle", "first_step", "follow_up", "success"],+ "properties": {+ "angle": { "type": "string" },+ "first_step": { "type": "string" },+ "follow_up": { "type": "string" },+ "success": { "type": "string" }+ }+ }+ }+}diff --git a/first-customer-finder/scripts/generate_report.py b/first-customer-finder/scripts/generate_report.pyindex 16373f7..a58ea57 100755--- a/first-customer-finder/scripts/generate_report.py+++ b/first-customer-finder/scripts/generate_report.py@@ -110,6 +110,7 @@ def build_html(data: dict[str, Any]) -> str:prospect_html = "".join(render_prospect(x, i) for i, x in enumerate(prospects, 1))pattern_html = "".join(render_pattern(x, i) for i, x in enumerate(patterns, 1))product_url = safe_url(data.get("product_url"))+ embedded_json = json.dumps(data, ensure_ascii=False).replace("<", "\\u003c").replace(">", "\\u003e")return f"""<!doctype html><html lang="en">@@ -132,12 +133,13 @@ def build_html(data: dict[str, Any]) -> str:.plan{{display:grid;grid-template-columns:.8fr 1.2fr;gap:28px;background:var(--acid);color:#111;padding:29px;border-radius:var(--radius);margin-bottom:30px}}.plan h2{{font-size:38px;line-height:1;letter-spacing:-.045em;margin:10px 0}}.plan-grid{{display:grid;grid-template-columns:1fr 1fr;gap:9px}}.plan-grid>div{{border:1px solid rgba(0,0,0,.24);border-radius:11px;padding:13px}}.plan-grid span{{display:block;font:750 10px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.07em;margin-bottom:5px}}.plan-grid p{{margin:0}}.limits{{border:1px solid var(--line);border-radius:var(--radius);padding:24px;color:var(--muted);margin-bottom:60px}}.limits h2{{color:var(--ink);margin-top:0}}footer{{display:flex;justify-content:space-between;gap:20px;border-top:1px solid var(--line);padding:22px 0 40px;color:var(--muted);font-size:12px}}.reveal{{animation:rise .4s ease both}}@keyframes rise{{from{{opacity:0;transform:translateY(12px)}}}}@media(max-width:820px){{.shell{{width:min(100% - 24px,1180px)}}.hero,.plan{{grid-template-columns:1fr}}.hero{{padding-top:44px}}.hero-card{{transform:none}}.stats{{grid-template-columns:1fr 1fr}}.stats>div+div{{border-left:0;border-top:1px solid var(--line)}}.best{{grid-template-columns:1fr}}.prospect-head{{grid-template-columns:38px 1fr}}.score{{grid-column:1/-1}}.prospect-grid,.evidence,.patterns,.plan-grid{{grid-template-columns:1fr}}.meta .chip{{display:none}}}}@media(prefers-reduced-motion:reduce){{*{{animation:none!important;transition:none!important;scroll-behavior:auto!important}}}}@media print{{body{{background:#fff;color:#111}}body:before,.top button{{display:none}}.shell{{width:100%}}.prospect,.pattern,.limits{{background:#fff;color:#111;break-inside:avoid}}.prospect-grid span,.signal span,.evidence span,blockquote span{{color:#444}}}}+ .toast{{position:fixed;left:50%;bottom:28px;transform:translateX(-50%) translateY(20px);background:var(--acid);color:#111;padding:11px 18px;border-radius:999px;font:800 13px inherit;box-shadow:var(--shadow);opacity:0;pointer-events:none;transition:opacity .25s,transform .25s;z-index:99}}.toast.show{{opacity:1;transform:translateX(-50%) translateY(0)}}.meta button[data-action]{{background:var(--panel2);color:var(--ink);border:1px solid var(--line)}}</style></head><body><a class="skip" href="#main">Skip to report</a><div class="shell">- <header class="top"><div class="brand"><i></i> First Customer Finder</div><div class="meta"><span class="chip">Public signals only</span><button type="button" onclick="window.print()">Print / Save PDF</button></div></header>+ <header class="top"><div class="brand"><i></i> First Customer Finder</div><div class="meta"><span class="chip">Public signals only</span><button type="button" data-action="export-csv">Export CSV</button><button type="button" data-action="export-json">Export JSON</button><button type="button" data-action="copy-summary">Copy summary</button><button type="button" onclick="window.print()">Print / Save PDF</button></div></header><main id="main"><section class="hero"><div><span class="eyebrow">Early-customer report · {esc(data.get('generated_at', ''))}</span><h1>{esc(data.get('title', 'First Customer Finder'))}</h1><p class="verdict">{esc(data.get('verdict', 'No verdict supplied.'))}</p></div><aside class="hero-card"><span>Qualified prospects</span><strong>{len(prospects)}</strong><p>Potential customers based on public signals.</p></aside></section><section class="stats"><div><span>Product</span><strong><a href="{product_url}" target="_blank" rel="noreferrer">{esc(data.get('product', 'Not specified'))}</a></strong></div><div><span>Target customer</span><strong>{esc(data.get('target_customer', 'Not specified'))}</strong></div><div><span>High intent</span><strong>{high_intent}</strong></div><div><span>Average fit score</span><strong>{average}/100</strong></div></section>@@ -149,6 +151,97 @@ def build_html(data: dict[str, Any]) -> str:</main><footer><span>Generated by $first-customer-finder</span><span>Outreach is never sent automatically.</span></footer></div>+ <div class="toast" id="toast" role="status" aria-live="polite"></div>+ <script type="application/json" id="prospect-data">{embedded_json}</script>+ <script>+ (function () {{+ var el = document.getElementById('prospect-data');+ if (!el) return;+ var data;+ try {{ data = JSON.parse(el.textContent); }} catch (e) {{ return; }}+ function toast(msg) {{+ var t = document.getElementById('toast');+ if (!t) return;+ t.textContent = msg;+ t.classList.add('show');+ setTimeout(function () {{ t.classList.remove('show'); }}, 2200);+ }}+ function download(name, text, mime) {{+ var blob = new Blob([text], {{ type: mime || 'text/plain;charset=utf-8' }});+ var url = URL.createObjectURL(blob);+ var a = document.createElement('a');+ a.href = url;+ a.download = name;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ setTimeout(function () {{ URL.revokeObjectURL(url); }}, 1000);+ }}+ function csvField(v) {{+ v = v == null ? '' : String(v);+ v = v.replace(/"/g, '""').replace(/\\r?\\n/g, ' ');+ return '"' + v + '"';+ }}+ function exportCSV() {{+ var cols = ['Name','Type','Stage','Score','Pain signal','Why fit','Why now','Source title','Source URL','Source type','Signal date','Suggested channel','Opener','Caution','Pain strength','Product fit','Timing','Reachability','Evidence quality'];+ var rows = [cols.map(csvField).join(',')];+ (data.prospects || []).forEach(function (p) {{+ var d = p.dimensions || {{}};+ rows.push([p.name, p.type, p.stage, p.score, p.pain_signal, p.why_fit, p.why_now, p.source_title, p.source_url, p.source_type, p.signal_date, p.suggested_channel, p.opener, p.caution, d.pain_strength, d.product_fit, d.timing, d.reachability, d.evidence_quality].map(csvField).join(','));+ }});+ download('first-customer-finder-prospects.csv', rows.join('\\n'), 'text/csv;charset=utf-8');+ toast('CSV downloaded');+ }}+ function exportJSON() {{+ download('first-customer-finder-report.json', JSON.stringify(data, null, 2), 'application/json;charset=utf-8');+ toast('JSON downloaded');+ }}+ function copySummary() {{+ var lines = [];+ lines.push(data.title || 'First Customer Finder');+ lines.push('Product: ' + (data.product || '') + (data.product_url ? ' (' + data.product_url + ')' : ''));+ lines.push('Target customer: ' + (data.target_customer || ''));+ lines.push('Verdict: ' + (data.verdict || ''));+ lines.push('');+ var top = (data.prospects || []).slice().sort(function (a, b) {{ return (b.score || 0) - (a.score || 0); }}).slice(0, 3);+ lines.push('Top prospects:');+ top.forEach(function (p, i) {{+ lines.push((i + 1) + '. ' + (p.name || '') + ' — score ' + (p.score || 0) + '/100');+ if (p.source_url) lines.push(' Source: ' + p.source_url);+ if (p.opener) lines.push(' Opener: ' + p.opener);+ }});+ if (data.limits && data.limits.length) {{+ lines.push('');+ lines.push('Limits:');+ data.limits.forEach(function (l) {{ lines.push('- ' + l); }});+ }}+ var text = lines.join('\\n');+ function done() {{ toast('Summary copied to clipboard'); }}+ if (navigator.clipboard && navigator.clipboard.writeText) {{+ navigator.clipboard.writeText(text).then(done, function () {{ fallbackCopy(text); done(); }});+ }} else {{ fallbackCopy(text); done(); }}+ }}+ function fallbackCopy(text) {{+ var ta = document.createElement('textarea');+ ta.value = text;+ ta.style.position = 'fixed';+ ta.style.left = '-9999px';+ document.body.appendChild(ta);+ ta.focus();+ ta.select();+ try {{ document.execCommand('copy'); }} catch (e) {{}}+ document.body.removeChild(ta);+ }}+ document.querySelectorAll('[data-action]').forEach(function (btn) {{+ btn.addEventListener('click', function () {{+ var a = btn.getAttribute('data-action');+ if (a === 'export-csv') exportCSV();+ else if (a === 'export-json') exportJSON();+ else if (a === 'copy-summary') copySummary();+ }});+ }});+ }})();+ </script></body></html>"""diff --git a/first-customer-finder/scripts/test_generate_report.py b/first-customer-finder/scripts/test_generate_report.pynew file mode 100755index 0000000..de62fcb--- /dev/null+++ b/first-customer-finder/scripts/test_generate_report.py@@ -0,0 +1,183 @@+#!/usr/bin/env python3+"""Tests for generate_report.py and the report JSON contract.++Runs as a standalone script:++ python3 scripts/test_generate_report.py++Or with pytest:++ pytest scripts/test_generate_report.py++Uses only the Python standard library. If the optional `jsonschema` package is+installed, the example fixture is also validated against+references/report.schema.json; otherwise that check self-skips.+"""++from __future__ import annotations++import json+import os+import sys+import tempfile+import unittest+from pathlib import Path++SCRIPT_DIR = Path(__file__).resolve().parent+SKILL_DIR = SCRIPT_DIR.parent+EXAMPLES_DIR = SKILL_DIR / "examples"+REFERENCES_DIR = SKILL_DIR / "references"++sys.path.insert(0, str(SCRIPT_DIR))+import generate_report as gen # noqa: E402+++def load_example() -> dict:+ with (EXAMPLES_DIR / "analysis.example.json").open("r", encoding="utf-8") as h:+ return json.load(h)+++def score_from_dimensions(d: dict) -> int:+ return round(+ d["pain_strength"] / 5 * 25+ + d["product_fit"] / 5 * 25+ + d["timing"] / 5 * 20+ + d["reachability"] / 5 * 15+ + d["evidence_quality"] / 5 * 15+ )+++class FixtureContractTests(unittest.TestCase):+ def test_example_has_required_top_level_keys(self):+ data = load_example()+ for key in ("title", "product", "product_url", "target_customer",+ "generated_at", "verdict", "prospects"):+ self.assertIn(key, data, f"missing top-level key: {key}")++ def test_example_has_three_prospects(self):+ data = load_example()+ self.assertEqual(len(data["prospects"]), 3)++ def test_example_prospects_have_required_keys(self):+ data = load_example()+ required = ("name", "type", "stage", "score", "pain_signal",+ "why_fit", "why_now", "source_url", "dimensions")+ for p in data["prospects"]:+ for key in required:+ self.assertIn(key, p, f"prospect missing key: {key}")++ def test_example_scores_match_formula(self):+ data = load_example()+ for p in data["prospects"]:+ self.assertEqual(p["score"], score_from_dimensions(p["dimensions"]),+ f"score mismatch for {p['name']}")++ def test_example_scores_in_valid_bands(self):+ data = load_example()+ for p in data["prospects"]:+ self.assertGreaterEqual(p["score"], 0)+ self.assertLessEqual(p["score"], 100)++ def test_example_source_urls_are_http(self):+ data = load_example()+ for p in data["prospects"]:+ self.assertTrue(p["source_url"].startswith(("http://", "https://")),+ f"non-http source_url: {p['source_url']}")++ def test_example_dimensions_in_range(self):+ data = load_example()+ for p in data["prospects"]:+ for key, value in p["dimensions"].items():+ self.assertIsInstance(value, int)+ self.assertGreaterEqual(value, 0)+ self.assertLessEqual(value, 5, f"{key}={value} out of 0-5")++ def test_example_stages_are_valid(self):+ data = load_example()+ valid = {"High intent", "Problem aware", "Trigger present", "Potential fit"}+ for p in data["prospects"]:+ self.assertIn(p["stage"], valid, f"invalid stage: {p['stage']}")+++class GeneratorTests(unittest.TestCase):+ def test_build_html_returns_non_empty(self):+ html = gen.build_html(load_example())+ self.assertGreater(len(html), 1000)++ def test_build_html_contains_prospect_names(self):+ html = gen.build_html(load_example())+ for p in load_example()["prospects"]:+ self.assertIn(p["name"], html)++ def test_build_html_contains_scores(self):+ data = load_example()+ html = gen.build_html(data)+ for p in data["prospects"]:+ self.assertIn(str(p["score"]), html)++ def test_build_html_embeds_export_buttons(self):+ html = gen.build_html(load_example())+ self.assertIn('data-action="export-csv"', html)+ self.assertIn('data-action="export-json"', html)+ self.assertIn('data-action="copy-summary"', html)++ def test_build_html_embeds_report_json(self):+ html = gen.build_html(load_example())+ self.assertIn('id="prospect-data"', html)++ def test_embedded_json_is_parseable_and_matches(self):+ import re+ html = gen.build_html(load_example())+ m = re.search(r'<script type="application/json" id="prospect-data">(.*?)</script>', html, re.S)+ self.assertIsNotNone(m, "prospect-data script not found")+ embedded = json.loads(m.group(1))+ self.assertEqual(embedded["prospects"], load_example()["prospects"])++ def test_golden_html_matches_generator_output(self):+ html = gen.build_html(load_example())+ golden = (EXAMPLES_DIR / "first-customer-finder-report.golden.html").read_text(encoding="utf-8")+ self.assertEqual(html, golden)++ def test_clamps_out_of_range_scores(self):+ data = load_example()+ data["prospects"][0]["score"] = 999+ html = gen.build_html(data)+ self.assertIn(">100<", html)++ def test_handles_empty_prospects(self):+ data = load_example()+ data["prospects"] = []+ html = gen.build_html(data)+ self.assertIn("No qualified prospects supplied", html)++ def test_handles_missing_dimensions(self):+ data = load_example()+ del data["prospects"][0]["dimensions"]+ html = gen.build_html(data)+ self.assertIn("/5</b>", html)++ def test_main_writes_output_file(self):+ with tempfile.TemporaryDirectory() as tmp:+ out = Path(tmp) / "out" / "report.html"+ input_path = EXAMPLES_DIR / "analysis.example.json"+ sys.argv = ["generate_report.py", str(input_path), str(out)]+ try:+ gen.main()+ finally:+ sys.argv = ["generate_report.py"]+ self.assertTrue(out.exists())+ self.assertGreater(out.stat().st_size, 1000)+++class SchemaTests(unittest.TestCase):+ def test_fixture_validates_against_schema(self):+ try:+ import jsonschema # type: ignore+ except ImportError:+ self.skipTest("jsonschema not installed; schema check skipped")+ schema = json.loads((REFERENCES_DIR / "report.schema.json").read_text(encoding="utf-8"))+ jsonschema.validate(load_example(), schema)+++if __name__ == "__main__":+ unittest.main(verbosity=2)