Files
Jyotisha/scripts/generate_birth_sky_golden.py
T
Jesse_ChenandClaude Opus 5.5 d277cbd8ad feat(chart): 「那一刻的天空」封面 — engine, BFF, canvas painter, chart header entry
T1 scripts/birth_sky.py: real alt/az of the seven visible grahas (swe.calc_ut +
swe.azalt, geometric altitude, azimuth converted from swe's south origin to
north-east) and Yale BSC5 stars V<=4.0 (IAU 1976 precession); phase
day / twilight_morning / twilight_evening / night. Thin POST /api/birth_sky
registration in do_POST (no new handler method, no __new__).

T2 GET /api/birth-sky?subject=: birth truth read server side through
loadSubjectBirth + prepareChartViewProfile; zod contract; no billing, no
writes, no birth data in the response.

T3/T4 lib/birth-sky: sentence table, pure Canvas 2D drawBirthSky (night /
paper palettes from DESIGN tokens, east on the left, serif headline with
1.5 s font wait), PNG export via navigator.share or Blob + a.download.
Chart page prefetches and paints the cover once the chart is ok; the header
button appears only when the PNG is ready. Dialog is a lazy chunk.

T7 DESIGN §17, VOICE, CONTEXT glossary, CHANGELOG, real-device checklist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199rbQDTsUbCVw84wc8BTFe
2026-09-28 20:27:40 +08:00

39 lines
1.4 KiB
Python

"""Rebuild frontend/tests/fixtures/birth-sky-golden.json from the real engine.
Fictional sample from TASK-birth-sky-cover-20260928: 1994-05-18, UTC+8,
30.27N 120.15E, at four local times (one per sky phase). The frontend tests
read these engine responses as-is; the test suite never writes this file.
python3 -m scripts.generate_birth_sky_golden
"""
from __future__ import annotations
import json
from pathlib import Path
from scripts.birth_sky import compute_birth_sky
ROOT = Path(__file__).resolve().parents[1]
GOLDEN = ROOT / "frontend" / "tests" / "fixtures" / "birth-sky-golden.json"
SAMPLE = {"date": "1994-05-18", "tz": 8, "lat": 30.27, "lon": 120.15}
TIMES = {"day": "07:40", "twilight_morning": "04:50", "twilight_evening": "19:10", "night": "00:00"}
def main() -> None:
payload = {
"source": "scripts/generate_birth_sky_golden.py -> scripts/birth_sky.compute_birth_sky (POST /api/birth_sky)",
"note": "Fictional sample 1994-05-18 UTC+8 30.27N 120.15E; key = phase at that local time.",
"times": TIMES,
"responses": {
key: compute_birth_sky(SAMPLE["date"], time, SAMPLE["tz"], SAMPLE["lat"], SAMPLE["lon"])
for key, time in TIMES.items()
},
}
GOLDEN.write_text(json.dumps(payload, ensure_ascii=False, separators=(",", ":")) + "\n", encoding="utf-8")
print(f"wrote {GOLDEN}")
if __name__ == "__main__":
main()