Commit Graph

39 Commits

Author SHA1 Message Date
Stefan 411b072e2e fix: Add FEN context to move exchange analysis prompt
- Include FEN before user's move, after user's move, and current position
- Ensures LLM has complete position context to understand piece locations
- Fixes issue where LLM could 'forget where pieces are' during move analysis
- Add instruction to use FEN data for piece location understanding
2025-11-27 20:06:21 +01:00
Stefan cbfb6eaa30 docs: Add .env.example with debug mode documentation 2025-11-27 18:21:00 +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 a9a5366832 feat: Update play page to use multiple opening detection
- Change openingData from single to array in ChessGame.tsx
- Update all opening lookups to use lookupPossibleOpenings()
- Extract move sequence from PGN for opening lookup
- Update Tutor.tsx to accept array of openings
- Add smart opening instructions based on count:
  - 1 opening: Confident identification with metadata
  - Multiple: List possibilities, suggest general principles
  - None: Focus on position without inventing names
- Pass up to 5 possible openings to LLM in all prompts
2025-11-27 12:32:59 +01:00
Stefan 3f8f623d5c feat: Add lookupPossibleOpenings and PGN parsing helpers
- Add lookupPossibleOpenings() to find multiple openings from move sequence
- Add extractMoveSequenceFromPGN() to parse PGN strings
- Add buildMoveSequenceFromSteps() for analysis page
- Import moveIndex.json for fast lookup
- Returns up to 5 possible openings per sequence
2025-11-27 12:28:37 +01:00
Stefan 3c1ace6aea feat: Add opening move sequence index
- Create buildOpeningIndex.js script to generate moveIndex.json
- Generate moveIndex.json with 12,377 unique move sequences
- Index maps move sequences to arrays of opening metadata
- Sorted by move length then alphabetically
- File size: 4.07 MB
- Enables fast lookup of multiple possible openings from move sequences
2025-11-27 12:26:58 +01:00
Stefan 0d8e7ac142 fix: Always include current position (FEN) in LLM prompts
- Add FEN and opening data to all user question types (best move, hint, general)
- Prevents LLM from losing track of piece positions during conversation
- Ensures accurate responses based on actual board state
- Fixes issue where tutor would forget piece locations in general questions
2025-11-27 10:22:03 +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 11a64ce56f Merge onboarding feature: Add comprehensive onboarding flow for new users 2025-11-27 09:31:48 +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 3afc75f78d docs: Update README with latest features and improved Docker instructions
- Add tactical recognition system documentation
- Update to 9 AI personalities (was 3)
- Improve Quick Start section with Docker Compose as primary method
- Document automated Docker builds via GitHub Actions
- Add detailed tactical detection feature explanation
- Update game flow to mention tactical feedback
- Reorganize deployment sections for clarity
2025-11-26 19:58:23 +01:00
Stefan 1de1296c7d Merge tactic recognition module into main
This adds comprehensive tactical analysis to the chess tutor:
- Detects missed tactical opportunities (pins, forks, skewers, checks, etc.)
- Provides real-time feedback through the AI tutor
- Includes comprehensive test suite (20 tests)
- All tests passing (50/50)
2025-11-26 17:23:15 +01:00
Stefan 49effedf61 Complete tactic recognition module with tests and real-time integration
- Add comprehensive test suite (20 tests) for tactic detection
- Fix pawn detection threshold bug (200 -> 100 centipawns)
- Add error handling to uciToSan for invalid moves
- Integrate tactical data into Tutor component for real-time feedback
- Pass missedTactics from ChessGame to Tutor via props
- Update LLM prompt to explain missed tactical opportunities
- Fix Jest configuration to handle react-markdown ESM issues
- All 50 tests passing
2025-11-26 16:51:38 +01:00
stefan-kp f0e95ae1a0 Implement tactical detection module 2025-11-26 15:16:08 +01:00
Stefan b817182a8b fix: Critical bug fixes and add new personalities
Bug Fixes:
- Fix turn validation: Players can now only move their own pieces
- Fix computer not moving when player moves too quickly (before evalP0 ready)
- Add safety check: Computer move triggered when chat messages sent
- Computer now always responds even if evalP0 is missing (only move history skipped)

New Personalities:
- Add 'Friendly Motivator' - encouraging, positive coach focused on building confidence
- Add 'Bloody Pirate' - theatrical trash-talker with Monkey Island style humor

Personality Reordering:
- Reordered from serious to playful:
  1. Opening Professor (most serious)
  2. Professional Coach
  3. Friendly Motivator
  4. Speedrun Super GM
  5. Hype Streamer
  6. Angry Prodigy
  7. Drunk Russian GM
  8. Bloody Pirate (most playful)
- Added section headers for clarity (Serious/Professional, Balanced/Entertaining, Spicy/Trash-talking)

Technical Details:
- ChessGame: Added checkAndMakeComputerMove() callback
- Tutor: Calls onCheckComputerMove after sending messages
- Both fixes ensure robust gameplay even with race conditions
2025-11-25 20:01:04 +01:00
Stefan d83387debc feat: Improve move history table UX
- Remove auto-scroll to prevent page jumping when moves are added
- Add evaluation change column (Eval Δ) showing centipawn change per move
- Color-code evaluation changes (green=good, red=bad) based on player color
- Use moveHistory state instead of chess.js history for richer data display
- Keep chess board in view as primary focus
2025-11-25 19:34:52 +01:00
Stefan 35df6e145f fix: Handle undefined evaluation score in hint request
- Fix second instance of evaluation.score comparison
- Ensures production build completes successfully
2025-11-25 19:16:26 +01:00
Stefan 95bbb7bf7c fix: Handle undefined evaluation score in Tutor component
- Add proper null check for evaluation.score before comparison
- Prevents TypeScript build error in production build
2025-11-25 19:12:59 +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 1dd54e8937 fixes 2025-11-24 17:53:48 +01: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 c5b763d646 tag fix 2025-11-23 17:55:11 +01:00
Stefan 0aa4370f64 bug fixes and first try of github docker 2025-11-23 16:43:47 +01:00
Stefan 74016f08c6 docker compose fix 2025-11-23 13:47:55 +01:00
Stefan 2383960cdb i18n files 2025-11-23 13:37:43 +01:00
Stefan a4a42488bb i18n 2025-11-23 13:36:10 +01:00
Stefan ad104f2c31 screenshots 2025-11-23 11:58:27 +01:00
Stefan 8a6d6bd780 game ready 2025-11-23 11:44:05 +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