feat: wire build/test infra, trips API, and enriched journey stops

- Add tsconfig.json (server) + client/tsconfig.{json,app.json,node.json}
  so typecheck and tsc -b actually work.
- Fix npm test to run Playwright (was running vitest on Playwright specs);
  typecheck now covers both server and client.
- Mount routes before app.listen, add error handler, mount optional
  @tonycodes/auth-express middleware when AUTH_SECRET is set.
- Add /api/trips (GET/POST/PATCH/DELETE) backed by an in-memory store
  that gracefully degrades when DATABASE_URL is unset.
- Add prisma/seed.ts skeleton and server/types/express.d.ts for req.auth.
- Rewrite Grok prompt for combo-aware planning: charge+eat,
  stay+destination-charging, eat+viewpoint, etc., with amenities,
  cuisine, priceLevel, duration, day titles and trip highlights.
- Extend Stop schema + normalization to preserve all enrichment fields.
- New StopCard component renders combo pill, description, meta row
  (charge / stop / battery / cuisine / £-level) and amenity icons;
  map popups show the same enriched detail; timeline gains day titles
  and a HIGHLIGHTS sidebar.
- Fix server TS errors (vehicle accepted as string | {name,rangeKm},
  JSON parse results typed).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 10:32:53 +01:00
parent d516e93323
commit 89b24d4c34
24 changed files with 1263 additions and 243 deletions
+45 -22
View File
@@ -2,6 +2,10 @@
# One-command development script for Tesla Roadtrip
# Usage: ./scripts/dev.sh
#
# This script now prefers your personal authenticated Grok CLI (~/.grok/bin/grok)
# for local development (free + full Heavy capabilities).
# The xAI API key is still used for production deploys and when FORCE_XAI_API=true.
set -e
@@ -14,31 +18,50 @@ if [ -f .env ]; then
set +a
fi
# Check for XAI_API_KEY
if [ -z "$XAI_API_KEY" ]; then
echo ""
echo "⚠️ XAI_API_KEY is not set."
echo " → Real Grok (via xAI API) will NOT work."
echo " → The app will fall back to very basic responses."
echo ""
echo " To fix this:"
echo " 1. Add this line to your .env file:"
echo " XAI_API_KEY=xai-YourKeyHere"
echo ""
echo " 2. Or export it before running:"
echo " export XAI_API_KEY=xai-YourKeyHere"
echo ""
read -p "Continue without real Grok? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Exiting..."
exit 1
fi
else
echo "✅ XAI_API_KEY found — real Grok API will be used"
# === Detect which Grok provider will be active ===
LOCAL_GROK_BIN="${GROK_BIN:-$HOME/.grok/bin/grok}"
HAS_LOCAL_GROK=false
HAS_AUTH=false
if [ -x "$LOCAL_GROK_BIN" ]; then
HAS_LOCAL_GROK=true
fi
if [ -f "$HOME/.grok/auth.json" ]; then
HAS_AUTH=true
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if [ "$FORCE_XAI_API" = "true" ]; then
echo "🔑 FORCE_XAI_API=true → Using xAI API (grok-4.3) for this session"
echo " (Good for testing the exact production path locally)"
elif [ "$HAS_LOCAL_GROK" = true ] && [ "$HAS_AUTH" = true ]; then
echo "✅ LOCAL PERSONAL GROK CLI (Heavy)"
echo " Binary : $LOCAL_GROK_BIN"
echo " Auth : ~/.grok/auth.json (your personal account)"
echo " Mode : web_search + high effort — free + powerful for iteration"
echo ""
echo " All local testing (dev.sh, iterate.sh, Playwright) will use YOUR Grok account."
elif [ "$HAS_LOCAL_GROK" = true ]; then
echo "⚠️ Local grok binary found but no ~/.grok/auth.json"
echo " → Run 'grok login' in your terminal first, then restart dev.sh"
echo " Falling back to xAI API (if key present)"
else
echo "️ No local grok binary at $LOCAL_GROK_BIN"
echo " Using xAI API instead (if XAI_API_KEY is set)"
fi
if [ -n "$XAI_API_KEY" ]; then
echo ""
echo " XAI_API_KEY is present (will be used for production + FORCE_XAI_API mode)"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Starting Backend + Frontend..."
echo " Backend: http://localhost:3000"
echo " Frontend: http://localhost:5173"