Commit Graph

40 Commits

Author SHA1 Message Date
Claude e08cd3e4d6 fix: undo wrong move instead of resetting puzzle to start position
When a user makes an incorrect move in a puzzle, now only that move
is undone (like chess.com) instead of resetting the entire puzzle.
This improves usability by letting users retry from the same position
rather than having to redo all previous correct moves.
2026-01-03 21:45:22 +00:00
Stefan b36b91cddd download script 2025-12-15 12:21:34 +01:00
Stefan 4ef4e2e4f4 imprint 2025-12-14 13:04:56 +01:00
Stefan 25666e7359 imprint 2025-12-14 12:48:55 +01:00
Stefan 38f2cb0f3b imprint 2025-12-14 12:45:33 +01:00
Stefan 1bee218cce translations 2025-12-14 11:52:39 +01:00
Claude 47c37487b3 refactor: code review improvements
- Add 30s timeout to Stockfish evaluation to prevent hanging promises
- Add FEN validation and depth cap (max 30) to Stockfish API route
- Create ErrorBoundary component with specialized fallbacks for chess game and tutor
- Extract useChessSounds hook for better audio management
- Add React.memo to EvaluationBar and CapturedPieces for performance
- Add useMemo to CapturedPieces for sorted pieces calculation
- Improve tacticDetection to return empty array instead of "none" type
- Add filterMeaningfulTactics and hasTactics helper functions
- Translate hardcoded UI strings (stockfishLevel, download, evalChange)
- Update translations for EN, DE, FR, IT, PL
- Add uuid to Jest transformIgnorePatterns for ESM compatibility
- Update tests to use new filterMeaningfulTactics function
2025-12-10 21:30:28 +00:00
Stefan 8ed402bbe0 feat: improve opening trainer flow and add deviation dialog
- Add tutor message guardrail to prevent rapid-fire messages
  - Track last message by move index
  - Wait for both player and opponent moves before speaking
  - Speak immediately when player deviates from theory

- Add deviation dialog with three options:
  - Continue Playing (Start Game) - transitions to game mode
  - Undo & Return to Opening - returns to theory
  - Explore This Variation - continues off-book practice

- Implement smooth game mode transition:
  - Pass opening context from trainer to game
  - Tutor welcomes player with context about their study
  - Computer makes first move if needed in starting position

- Fix generate-test-fixtures script:
  - Add safety check to prevent overwriting real data
  - Restore full opening database (12,379 openings)
  - Rebuild move index (12,377 sequences)
  - Add clear warnings about test fixtures

- Update ChessGame to accept openingContext prop
- Update Tutor to display contextual greeting in game mode

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-08 15:05:05 +01:00
Stefan 002ed92bea Add mobile app support and opening training feature
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>
2025-12-07 18:40:58 +01:00
Stefan 9ebca615c7 playwright 2025-12-06 17:37:44 +01:00
stefan-kp e01ece4161 Add tests for LLM API endpoints 2025-12-04 10:30:28 +01:00
stefan-kp 32f93b9305 Add LLM tutor API endpoints 2025-12-04 10:30:23 +01:00
stefan-kp cab02cfefd Add Stockfish evaluation API endpoint 2025-12-03 21:30:39 +01:00
Stefan 41ca7ae187 Fix hanging test and update README with resign feature
- Fix page.test.tsx: Use stable mock router reference to prevent infinite loop
  The useRouter mock was returning a new object on every render, causing
  the useEffect with router dependency to re-run infinitely
- Update README to document resign button and analyze game features
2025-12-03 08:56:33 +01:00
Stefan 870efbbff7 Add Clear All Data feature to settings page
- Add 'Clear All Data' button in Danger Zone section
- Implement confirmation dialog before clearing
- Clear all localStorage and redirect to onboarding
- Add translations for clearAllData, clearAllDataConfirm, and clearAllDataDescription in all 5 languages (EN, DE, FR, IT, PL)
- Style with red theme to indicate destructive action
2025-12-01 11:54:35 +01:00
Stefan 13210c61ee Merge Polish language support 2025-12-01 11:24:03 +01:00
Stefan b69d0c3999 Merge remote changes and add evaluation bar to analysis page 2025-12-01 10:30:37 +01:00
Stefan d28914ca35 Add horizontal evaluation bar to analysis page 2025-12-01 10:28:19 +01:00
stefan-kp e5b12ceec1 Add Polish UI language support 2025-12-01 09:52:05 +01:00
Stefan 0e678e0187 analysis 2025-11-29 10:18:23 +01:00
stefan-kp 4102135acd Add play-from-position flow 2025-11-29 08:50:44 +01:00
Stefan 3e8c16b9c2 analysis 2025-11-27 21:23:54 +01:00
Stefan c319904f00 feat: Add debug mode to inspect LLM prompts and responses
- Add DebugContext to track all LLM interactions
- Create DebugPanel component with floating UI
- Track prompts/responses in Tutor component (move analysis, hints, questions)
- Track prompts/responses in Analysis page (move commentary)
- Add NEXT_PUBLIC_DEBUG environment variable to enable/disable
- Include metadata (FEN, personality, language, etc.) in debug entries
- Add copy-to-clipboard and clear functionality
- Add DEBUG_MODE.md documentation
2025-11-27 18:20:12 +01:00
Stefan 54d92eaae5 fix: Update analysis page tests to use aria-labels
- Change from getByText to getByLabelText for navigation buttons
- Buttons now use icon-only display with aria-labels for accessibility
- Fixes tests after UI simplification in previous commit
2025-11-27 12:54:52 +01:00
Stefan 6b50eba05f feat: Add back button and simplify navigation on analysis page
- Import ArrowLeft icon and useRouter from Next.js
- Add back button below header that navigates to home (/)
- Simplify Previous/Next buttons to show only chevron icons
- Remove text labels from navigation buttons for cleaner UI
- Add aria-labels for accessibility
- Consistent with play page navigation pattern
2025-11-27 12:40:21 +01:00
Stefan d3fea58e8e feat: Update analysis page to use multiple opening detection
- Import lookupPossibleOpenings and buildMoveSequenceFromSteps
- Build move sequence from steps array up to currentIndex
- Lookup up to 5 possible openings per position
- Update prompt to include all possible openings
- Update UI to show single opening name or count of possibilities
- Consistent with play page opening detection
2025-11-27 12:38:31 +01:00
Stefan aa389613cb feat: Add chat session to analysis page
- Import ChatSession from @google/generative-ai
- Add chatSession state to maintain conversation history
- Initialize chat session with personality and language context
- Replace stateless generateContent() with chatSession.sendMessage()
- Add FEN before/after to move analysis prompts
- Chat history is preserved when navigating between moves
- LLM can now provide context-aware commentary across the game
2025-11-27 12:36:40 +01:00
Stefan af2ea1c39e fix: Resolve build errors after merging feature branches
- Fix TypeScript errors in analysis page with non-null assertions
- Fix Chessboard component API usage to use options prop
- Fix Analyze Game button placement to be always visible
2025-11-27 09:52:36 +01:00
Stefan 95692ce8f8 Merge game history feature: Add multi-game save and analysis mode 2025-11-27 09:33:23 +01:00
stefan-kp 918bbd2508 Add multi-game resume list with board previews 2025-11-27 09:26:02 +01:00
stefan-kp f7ee818360 Add onboarding flow for missing LLM key 2025-11-27 09:25:39 +01:00
stefan-kp 05f14d30a1 Add analysis page tests for PGN walkthrough 2025-11-26 21:33:45 +01:00
Stefan cd6cab367a Add unified FEN/PGN import with auto-detection
- Create chessFormatDetector utility for automatic format detection
- Update StartScreen with textarea supporting both FEN and PGN input
- Add real-time format detection with visual feedback indicators
- Update translations for all 4 languages (EN, DE, FR, IT)
- Add markdown rendering for Tutor chat messages
- Add comprehensive tests for format detection (20 tests)
- Update game initialization to handle both FEN and PGN formats

This completes the fix/stale-analysis-data branch with:
- Fixed stale evaluation data in hint/best move requests
- Clarified AI's dual role (opponent + tutor) to prevent hint rejection
- Stored complete evaluation history (P0, P1, P2) for all moves
- Improved end-game analysis with better mistake detection
- Fixed duplicate analysis runs with useRef flag
- Added markdown rendering for formatted analysis output
- Added unified FEN/PGN import with auto-detection
2025-11-25 17:54:25 +01:00
google-labs-jules[bot] 4d5ec5ecc3 fix(analysis): Ensure fresh evaluation for hints and analysis
This commit fixes a bug where the AI tutor and end-game analysis would use stale data from previous evaluations.

The `Tutor` component now receives the live `game` instance and has a new function, `evaluateCurrentPosition`, which is called on-demand when a user requests a hint or the best move. This ensures the LLM receives up-to-date information.

The end-game analysis was also corrected to use the proper evaluation data when constructing the move history, preventing incorrect analysis of mistakes and blunders.

The test suite was improved by restoring deleted tests, adding a new test to verify the fix, and making existing tests more robust.
2025-11-25 13:15:49 +00:00
Stefan b923f68841 sounds + layout 2025-11-24 16:12:58 +01:00
Stefan 1f2300e476 footer 2025-11-23 20:56:30 +01:00
Stefan 0aa4370f64 bug fixes and first try of github docker 2025-11-23 16:43:47 +01:00
Stefan a4a42488bb i18n 2025-11-23 13:36:10 +01:00
Stefan 30f1e9e3a5 working app 2025-11-23 10:51:00 +01:00
Stefan f6480a43c6 Initial commit from Create Next App 2025-11-22 10:57:29 +01:00