002ed92bea
This commit implements iOS/Android mobile app support using Capacitor and adds a comprehensive opening training feature with LLM-powered explanations. ## Mobile App Infrastructure - Add Capacitor configuration for iOS/Android builds - Create mobile build script that excludes API routes - Update Next.js config for conditional static export - Add layout components with generateStaticParams for static builds - Generate 500+ static pages for offline mobile use ## Chess Engine Abstraction - Create ChessEngine interface for pluggable implementations - Add LocalEngine (GPL - uses stockfish.js in browser) - Add RemoteEngine (proprietary - calls API server) - Factory pattern selects engine based on environment - Enables GPL compliance for web, proprietary for mobile ## Opening Training Feature - Interactive opening repertoire training - Move validation with engine-backed feedback - LLM explanations using Gemini API - Wikipedia integration for opening context - Opening family grouping (e4, d4, c4, etc.) - Session state management - Real-time move feedback with evaluation Components: - OpeningSelector: Browse and select openings by family - OpeningTrainer: Main training interface with chessboard - MoveFeedback: Display move quality and LLM explanations - WikipediaSummary: Show opening history and context - ErrorBoundary: Graceful error handling Services: - openingLoader: Load and filter opening database - engineService: Engine evaluation wrapper - moveValidator: Validate moves against repertoire - feedbackGenerator: Generate contextual feedback - wikipediaService: Fetch and cache Wikipedia data - sessionManager: Track training session state ## Wikipedia Integration - Automatic Wikipedia article fetching for openings - Client-side and server-side caching - Sanitized summaries with proper formatting - Link opening database to Wikipedia slugs - API endpoints for on-demand fetching ## Docker Improvements - Add entrypoint script for automatic data setup - Fetch Wikipedia data on first container startup - Generate opening move index automatically - Remove generated data from git (public/openings/*.json, public/wikipedia/*.json) - Add READMEs explaining data requirements - Update .gitignore for generated files ## Dual Licensing Strategy - Add LICENSING.md explaining dual licensing approach - GPL-3.0 for web builds (includes Stockfish) - Proprietary option for mobile builds (no GPL code) - Single codebase, multiple licensing models - Legal compliance documented ## API Endpoints - POST /api/v1/llm/opening-explanation - Get LLM move explanations - GET /api/v1/wikipedia/summary - Fetch Wikipedia summaries ## Type Updates - Add openingTraining types - Update Tutor component to use ChessEngine interface - Add Gemini error handling types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
31 lines
843 B
Bash
Executable File
31 lines
843 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Mobile build script
|
|
# Temporarily moves API folder outside src/, builds static export, then restores it
|
|
|
|
set -e
|
|
|
|
echo "🔧 Preparing mobile build..."
|
|
|
|
# Clean previous build (suppress errors for non-empty directories)
|
|
echo "🧹 Cleaning previous build..."
|
|
rm -rf .next out 2>/dev/null || true
|
|
|
|
# Backup API folder to temp location OUTSIDE src/
|
|
if [ -d "src/app/api" ]; then
|
|
echo "📦 Temporarily moving API routes outside src/..."
|
|
mv src/app/api .api_temp_mobile_build
|
|
fi
|
|
|
|
# Build with mobile configuration
|
|
echo "🏗️ Building static export for mobile..."
|
|
BUILD_TARGET=mobile NEXT_PUBLIC_USE_REMOTE_ENGINE=true next build
|
|
|
|
# Restore API folder
|
|
if [ -d ".api_temp_mobile_build" ]; then
|
|
echo "📦 Restoring API routes..."
|
|
mv .api_temp_mobile_build src/app/api
|
|
fi
|
|
|
|
echo "✅ Mobile build complete! Output in ./out"
|