# RickRunGood integration — Schwab R4 Showdown

RickRunGood is **members-only**. CourtEdge does **not** scrape Rick on Cloudflare or in CI. Use **local Mac cron + your subscription cookie** ([PGA-RICKRUNGOOD-SCHEDULE.md](./PGA-RICKRUNGOOD-SCHEDULE.md)) or **manual paste** below.

## Scheduled local fetch (optional)

```bash
source rick-session.env   # RICKRUNGOOD_SESSION_COOKIE — see rick-session.env.example
node scripts/rickrungood-fetch.mjs
# or 2hr loop every 15min: bash scripts/rickrungood-loop.sh
```

Writes `data/imports/rick-latest.json` and chains to `import-rickrungood-paste.mjs` when R4 slate is active. **You** must own the RickRunGood subscription; see schedule doc for ToS notes.

## Rick URLs (copy from browser while logged in)

| Layer | Rick page | CourtEdge use |
|-------|-----------|---------------|
| **Live showdown cheat sheet** | [rickrungood.com/pga-pro-tools/live-showdown-cheat-sheet/](https://rickrungood.com/pga-pro-tools/live-showdown-cheat-sheet/) | Salaries, flex/CPT own%, live SG momentum |
| **Holy Grail (Colonial TOT)** | Rick → PGA Pro Tools → **Holy Grail** → Charles Schwab / Colonial | `rick_tot`, `rick_win_pct`, course-history fades |
| **Last 48 rounds (trends)** | Rick → PGA Pro Tools → **Data Tools** → **Last 48 rounds** | `rick_trend_score`, form momentum hot/cold |
| **Course fit** | DataGolf (already in lab) | Unchanged — Rick is layer #2 + live sheet |

Bundled slate also records: `salary_reference_url` on `data/pga-dk-slate-showdown-r4-cpt.json`.

## What to copy tonight

### A — Live showdown cheat sheet (salaries / own%)

1. Open **Live Showdown Cheat Sheet** for Charles Schwab R4.
2. Select all rows (header + golfers) → copy.
3. Save paste:

```text
# RickRunGood live showdown — Schwab R4
# Source: https://rickrungood.com/pga-pro-tools/live-showdown-cheat-sheet/
Player	Salary	CPT Salary	Proj	Own%	CPT Own%
Russell Henley	10600	15900	41.1	27.1	12.4
...
```

4. Import:

```bash
node scripts/import-rickrungood-paste.mjs \
  --paste data/imports/rick-cheat-sheet-r4.txt \
  --mode cheat-sheet
```

Updates **flex + CPT ownership** (and salaries if present) on:

- `data/pga-dk-slate-showdown-r4-cpt.json`
- `data/pga-dk-slate-showdown-r4.json`

Then rebuilds play board + captain construction.

### B — Holy Grail (TOT, Win%, fades)

1. Open **Holy Grail** → Colonial / Charles Schwab.
2. Copy tab-separated table (include header).
3. Save to `data/imports/rick-holy-grail-schwab-2026.txt` (replace template rows under the comments).
4. Import:

```bash
node scripts/import-rickrungood-paste.mjs \
  --paste data/imports/rick-holy-grail-schwab-2026.txt \
  --mode holy-grail
```

Writes:

- `data/pga-schwab-holy-grail.json` — curated + pasted merge
- Merges `rick_tot`, `rick_win_pct`, … onto R4 slate players
- Rebuilds `data/pga-showdown-r4-play-board.json` with `rick_holy_grail_tier`
- Rebuilds `data/pga-r4-captain-construction.json`

### C — Last 48 rounds (form trends)

1. Open **Data Tools → Last 48 rounds** for Charles Schwab.
2. Copy tab-separated table (include header + trend arrow column if present).
3. Save to `data/imports/rick-trends-48r-schwab-2026.txt`.
4. Import:

```bash
node scripts/import-rickrungood-paste.mjs \
  --paste data/imports/rick-trends-48r-schwab-2026.txt \
  --mode trends-48r
```

Writes:

- `data/pga-rick-trends-48r.json` — hot top 10 + cold fades bottom 10
- Merges `rick_trend_score`, `rick_trend_trap` onto R4 slate players

See [PGA-RICK-TRENDS-48R.md](./PGA-RICK-TRENDS-48R.md).

### D — Auto-detect (either paste)

```bash
cat my-paste.txt | node scripts/import-rickrungood-paste.mjs --paste -
```

Detects Holy Grail when headers include `tot` / `win_pct`; **Last 48 rounds** when `trend_score` or `rounds` + SG columns; else treats as cheat sheet.

## Paste formats

### Cheat sheet (TSV preferred)

Required: **name** column. Strongly recommended: **salary**, **ownership** (or `own%`).

Optional: `captain_salary`, `cpt own%`, `projection`, `ceiling`, `floor`.

### Holy Grail (TSV)

Header example:

```text
player_name	tot	win_pct	top10_pct	starts	mc_pct
Russell Henley	1.12	7.69	45.0	13	7.7
```

Aliases: `name`, `tot`, `win%`, `top10%`, `mc%`.

### Last 48 rounds (TSV)

Header example:

```text
trend	player_name	rounds	salary	sg_ott	sg_app	sg_arg	sg_putt	sg_t2g	sg_bs	trend_score
↑	Christiaan Bezuidenhout	48	7900	0.180	0.220	0.080	0.120	0.200	0.190	0.61
```

Aliases: `trend_score`, `score`, `tot` (only when paired with `rounds` + SG cols).

## Repo wiring (after import)

| File | Role |
|------|------|
| `data/pga-schwab-holy-grail.json` | Holy Grail JSON + article curation (Henley, Bhatia, Echavarria core; Horschel fade) |
| `data/pga-showdown-r4-play-board.json` | GPP board with `rick_tot`, `rick_holy_grail_tier: core\|pivot\|fade` |
| `data/pga-r4-captain-construction.json` | Field chalk CPT vs Rick-boosted pivot CPTs |
| `data/pga-colonial-course-history.json` | CourtEdge narrative history (not Rick TOT) |
| `articles/pga-schwab-r4-2026-05-31.html` | Editorial Holy Grail copy (paywall) |
| `data/pga-rick-trends-48r.json` | Last 48-round trend scores + hot/cold lists |
| `docs/PGA-RICK-HOLY-GRAIL.md` | Holy Grail schema + checklist |
| `docs/PGA-RICK-TRENDS-48R.md` | Trends schema + paste guide |
| `docs/PGA-MOKLOVIN-PATTERN.md` | Moklovin pattern + Rick paste notes |

## Lab UI

On **★ Schwab R4 — Captain + 5 FLEX**:

- **Rick Run Good** strip — source links, paste instructions, `imported_at` when JSON exists
- **Rick Holy Grail · Colonial** — gold panel · course-fit + fades
- **Rick · Last 48 rounds** — cyan panel · hot trend top 10 + cold fades bottom 10
- **R4 Captain · field vs leverage** — chalk CPT table + Rick-boosted pivot CPTs
- Play board hint switches from “paste not loaded” → “Holy Grail loaded · N golfers”

Preset: [/pga-dk-lineup-lab?preset=showdown-r4-cpt](https://courtedge.net/pga-dk-lineup-lab?preset=showdown-r4-cpt)

## Deploy

```bash
cd ~/courtedge-deploy
node scripts/import-rick-holy-grail.mjs
node scripts/import-rick-trends-48r.mjs
node scripts/build-pga-schwab-holy-grail.mjs
node scripts/build-pga-showdown-r4-play-board.mjs
node scripts/build-pga-r4-captain-construction.mjs
bash scripts/quick-deploy-pga.sh
```

Or auto-detect paste:

```bash
node scripts/import-rickrungood-paste.mjs --paste data/imports/rick-holy-grail-schwab-2026.txt --mode holy-grail
bash scripts/quick-deploy-pga.sh
```

## Sunday R4 go-live checklist

Run **Terminal.app** on your Mac (wrangler auth often fails in Cursor agent).

### 1 — Paste Rick tables (members-only)

| Layer | Save paste to | Import |
|-------|---------------|--------|
| Holy Grail (Colonial TOT) | `data/imports/rick-holy-grail-schwab-2026.txt` | `node scripts/import-rick-holy-grail.mjs` |
| Last 48 rounds | `data/imports/rick-trends-48r-schwab-2026.txt` | `node scripts/import-rick-trends-48r.mjs` |
| Live showdown cheat sheet (optional own%) | `data/imports/rick-cheat-sheet-r4.txt` | `node scripts/import-rickrungood-paste.mjs --paste … --mode cheat-sheet` |

**Current repo seed (May 31):** ~26 Holy Grail + ~30 trend rows from paste, plus **article seeds** for Smalley, Bez, Ghim, Olesen, Coody, Cole, Spaun, etc. Full **75-man** field still needs a Rick copy-paste for complete TOT/trend coverage.

### 2 — Rebuild chain

```bash
cd ~/courtedge-deploy
node scripts/import-rick-holy-grail.mjs      # chains play board + captain JSON
node scripts/import-rick-trends-48r.mjs
node scripts/build-pga-schwab-holy-grail.mjs # article curation merge
```

Confirm outputs:

- `data/pga-schwab-holy-grail.json` — `ok: true`, `player_count` ≥ 26
- `data/pga-rick-trends-48r.json` — `ok: true`, hot/cold lists populated
- `data/pga-showdown-r4-play-board.json` — `rick_tot` + `rick_holy_grail_tier` on board rows
- `data/pga-r4-captain-construction.json` — `rick_loaded: true`, pivot CPTs with Rick notes

### 3 — Bump lab build version

In `pga-dk-lineup-lab.html`: update `BUILD_VERSION` comment + `LAB_BUILD_VERSION` + `?v=` on gate/engine scripts. Current ship tag: **`20260531.26-rick-r4-go-live`**.

### 4 — Deploy

```bash
cd ~/courtedge-deploy
bash scripts/quick-deploy-pga.sh
# or: npx wrangler pages deploy . --project-name courtedge --commit-dirty=true
```

### 5 — Live verify (hard refresh Cmd+Shift+R)

Lab preset: [courtedge.net/pga-dk-lineup-lab?preset=showdown-r4-cpt](https://courtedge.net/pga-dk-lineup-lab?preset=showdown-r4-cpt)

| Panel | Pass |
|-------|------|
| Rick Run Good strip | LOADED pill · Holy Grail + 48r status · `imported_at` |
| Rick Holy Grail · Colonial | Gold panel · course-fit top + fades |
| Rick · Last 48 rounds | Cyan panel · hot top 10 + cold fades |
| R4 Captain · field vs leverage | Chalk CPT table + Rick-boost pivot CPTs |
| Play board hint | “Holy Grail loaded · N golfers” (not “paste not loaded”) |

```bash
curl -sI https://courtedge.net/data/pga-schwab-holy-grail.json | head -3
curl -sI https://courtedge.net/data/pga-rick-trends-48r.json | head -3
curl -s https://courtedge.net/pga-dk-lineup-lab.html | grep LAB_BUILD_VERSION
```

Expect **HTTP 200** on JSON (not 404) and BUILD_VERSION matching repo.

## Privacy

- Never commit Rick login cookies or session tokens.
- Paste files may stay local; article-curated `pga-schwab-holy-grail.json` ships without members-only raw tables until you paste.
