@bettor-help/cli
v0.1.5
Published
Bettor Help CLI — Clerk auth + client-side contest reconciliation.
Readme
@bettor-help/cli
The bettor.help companion CLI: one-shot onboarding, Clerk sign-in, client-side contest reconciliation, DKEntries ingest, and environment self-checks. Your DraftKings cookie never leaves your machine — the cloud never contacts DK.
npm install -g @bettor-help/cli
bettor-help start # one-shot onboarding: home dir + plugins + sign-inLocal file convention
Daily working files live under ~/bettor-help/<YYYY-MM-DD>/:
~/bettor-help/2026-07-02/
builds/ lineups you export from a build
entries/ archived DKEntries.csv exports (see `entries`)
edit-entries/ CSVs uploaded via DK's "Edit Entries" flow (late-swap / rebuild)
results/ contest standings CSVs (see `fetch-standings` / `reconcile`)Override the home base with the BETTOR_HELP_HOME env var.
Commands
Onboarding & auth
| Command | What it does |
| ----------------------------------------- | ------------------------------------------------------------------------------- |
| bettor-help start [--dir <path>] | One-shot onboarding: create ~/bettor-help, enable the plugins there, sign in. |
| bettor-help login / logout / whoami | Clerk OAuth session management. |
Daily workflow
| Command | What it does |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| bettor-help day [--date YYYY-MM-DD] [--open] | Create the day's {builds,entries,edit-entries,results}/ tree and print the paths. --open opens the folder (macOS open, Windows start, Linux xdg-open). |
| bettor-help entries [--date <D>] [--file <path>] [--dg <id>] [--profile <name@ver>] | The "grab my entries" primitive. Scans ~/Downloads for DKEntries*.csv files newer than the last run (newest first; --file overrides), identifies each file's draft group from its contest IDs via DK's public contest API (--dg overrides), archives a copy to ~/bettor-help/<date>/entries/DKEntries-dg<dg>.csv, and records the entries in the cloud entry ledger (ingest_entries). Prints contests / entry count / players resolved per file; per-file failures are loud but don't stop the batch. |
| bettor-help cookie --login | Browser-assisted DraftKings cookie capture (the recommended flow). Opens your installed Google Chrome (via playwright-core, channel: 'chrome' — no bundled browser download) on a dedicated persistent profile at ~/.config/bettor-help/browser-profile/, waits up to 5 minutes for you to sign in to DraftKings, then saves all draftkings.com cookies as a Cookie: header line to ~/.config/bettor-help/dk_cookie_header.txt (single line, mode 600). Because the profile keeps your DK session, later reconcile/fetch-standings runs silently re-harvest a fresh cookie headless when the saved one is missing/stale or DK rejects it (one retry, never a loop). Requires Google Chrome installed. |
| bettor-help cookie [--check] | Manual fallback: paste your browser's Cookie header at the prompt; it is validated (must look like a DK cookie) and saved to ~/.config/bettor-help/dk_cookie_header.txt (single line, mode 600). --check reports presence + age + whether the browser profile (auto-refresh) is available, without contacting DK. |
| bettor-help doctor | Environment self-check — one line per check with a fix hint: Node ≥ 20, CLI version (+ npm latest), login state, DK cookie presence/freshness, MCP endpoint reachability, ~/bettor-help writable. Exits non-zero if any hard check fails. |
Contest reconciliation
| Command | What it does |
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| bettor-help reconcile --sport <s> [--date <D>] [--contest-id <id>]... | discover → fetch-standings → reduce → upload in one shot. |
| bettor-help discover --sport <s> | List DK contests for a sport (cookieless public API). |
| bettor-help fetch-standings --contest-id <id> [--date <D>] | Fetch a standings CSV (requires the DK cookie); lands in ~/bettor-help/<date>/results/. |
| bettor-help reduce / upload | Build and POST the upload_contest_field payload manually. |
Environment
| Variable | Effect |
| ----------------------- | ------------------------------------------------------ |
| BH_TOKEN | Bypass Clerk login with a Bearer token (CI use). |
| BETTOR_HELP_HOME | Override the ~/bettor-help home base. |
| BETTOR_HELP_DOWNLOADS | Override the ~/Downloads scan dir used by entries. |
Troubleshooting
Run bettor-help doctor first — it checks everything the other commands need
and prints a fix hint per failure. Cookie problems specifically:
bettor-help cookie --check; if the cookie keeps expiring, run
bettor-help cookie --login once so the CLI can auto-refresh it.
--login needs Google Chrome installed; without Chrome, use the manual
paste flow (bettor-help cookie).
Development
cd packages/cli
npm ci
npm run typecheck
npm test