# Kalasutra Astro AI v3 — Setup Notes

## 1. One file you must copy in yourself
Your Swiss Ephemeris WASM wrapper (`swisseph.js`, referenced by your v2 `background.js`
and `backtest.js`) wasn't part of what you uploaded. Put your existing copy at:

    src/swisseph.js

`background.js` now imports it from there (`./src/swisseph.js`), and if `backtest.js`
still dynamically imports `chrome.runtime.getURL('src/swisseph.js')`, both now point
at the same single copy — no more duplicate files.

## 2. New files (all local, no server calls, no API keys required)
- `src/kp-core.js` — shared constants + SgL/StL/SL/SSL + KP house lookup (single source
  of truth; consolidated out of the duplicated copies in your old background.js/backtest.js)
- `src/panchang-engine.js` — weekday, tithi, yoga, karana, sunrise/set, hora, sub-hora,
  choghadiya, rahu kalam. Same math as your v2 `computePanchang()`, just extracted from
  the DOM-writing code so `background.js` can run it silently every tick.
- `src/sbc-engine.js` — Vedha + Latta, ported from your **`sbc_engine.py`** (the more
  complete version with directional Sammukha/Vama/Dakshina classification and pada
  corner-diagonals) — this supersedes your older `sbc_vedha_engine.js`. Adds
  `getLiveVedhaAndLatta()`, which tells you which nakshatra each transiting planet is
  currently vedha-ing (and receiving vedha from), plus its Latta target.
- `src/dasha-engine.js` — 5-fold Vimshottari (Maha→Antar→Pratyantar→Sookshma→Prana),
  extracted from your `renderDashaTree()`. `findActiveDasha()` gives you just the
  currently-active lord at all 5 levels cheaply (for the 30s tick); `generateDashaTree()`
  builds the full 120-year tree on demand (side panel "Show Full Tree" button).
- `src/tarabala-engine.js` — birth star vs. transit Moon star, 9-fold Tara cycle.
- `src/ashtakavarga-engine.js` — **Phase 1**: classical Chandrashtakavarga (Moon's
  Bhinnashtakavarga) bindu table from BPHS/Phaladeepika — these are fixed classical
  constants used by essentially all KP/Vedic software, not something specific to your
  desktop engine, so there's no "your validated numbers vs. mine" ambiguity here.
  `getTransitMoonAshtakavargaPoints()` returns the 0–8 point value for whatever sign
  the transit Moon is currently in.

## 3. Rewired files
- `background.js` — now computes **12 planets** (9 Vedic + Uranus/Neptune/Pluto),
  Panchang, live SBC Vedha/Latta, and — once a birth profile is saved — active Dasha,
  Tara Bala, and Ashtakavarga, all bundled into the one `ks_latest_astro` payload it
  already pushed every 30s. Kept your license-verification message handler so
  `content.js`'s TradingView HUD keeps working unchanged.
- `popup.html` / `popup.js` — added a **Profile** tab (Name, Age, Birth Date/Time/Lat/Lon).
  Saving it tells `background.js` to build a natal cache (birth star, lagna,
  Chandrashtakavarga base, dasha start point) — recomputed only when you save changes,
  not on every tick.
- `sidepanel.html` / `sidepanel.js` (new) — the live dashboard: Panchang, SBC Vedha/Latta,
  KP Cusps (1–12), KP Planets (12), and — once your profile is saved — active Dasha,
  Tara Bala, and Ashtakavarga. All collapsible so it doesn't overwhelm the panel width.

## 4. What I deliberately left out of this pass
Your old `background.js` also had `generateLiveAITimelineReport()` — the minute-by-minute
OpenRouter/Gemini AI scanner that builds an HTML prediction report. That's unrelated to
the Panchang/KP/Dasha/Tara Bala/Ashtakavarga scope you described, so I didn't carry it
over to keep this pass focused and reviewable. Say the word and I'll wire it back in on
top of the new 12-planet payload.

## 5. Not touched
`content.js` (the TradingView overlay/signal HUD) — the new payload keeps every field
name it reads (`tithi`, `hora`, `choghadiya`, `lagnaName`, `lagnaSSL`, `lagnaABCD`,
`planets.Mo.sssl...`), so it should keep working as-is.
