Skip to content

feat: add AI Training Mode with Bedrock exercise generation#31

Open
kiro-agent[bot] wants to merge 6 commits intomainfrom
feat/ai-training-mode
Open

feat: add AI Training Mode with Bedrock exercise generation#31
kiro-agent[bot] wants to merge 6 commits intomainfrom
feat/ai-training-mode

Conversation

@kiro-agent
Copy link
Copy Markdown
Contributor

@kiro-agent kiro-agent bot commented Apr 8, 2026

This pull request was generated by @kiro-agent 👻

Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent


Summary

Implements the full AI Training Mode feature as specified in .kiro/specs/ai-training-mode/. This adds a new AI_TRAINING mode that uses Amazon Bedrock to generate contextual language exercises (fill-in-the-blank, verb conjugation, preposition selection, sentence completion) based on selected vocabulary words.

Changes

Backend - Domain Model & GraphQL Schema

  • Extended TrainingMode type with 'AI_TRAINING' value
  • Added AIExercise interface (prompt, options, correctOptionIndex, exerciseType, sourceWord)
  • Added aiExercises?: AIExercise[] to TrainingExecution
  • Updated GraphQL schema with AI_TRAINING enum value, AIExercise type, and aiExercises field on TrainingExecution

Backend - AI Service (ai-service.ts)

  • Added generateExercises() method: builds structured Bedrock prompt, calls InvokeModelCommand, parses and validates response
  • Added parseAndValidateExercises() with graceful degradation (filters out invalid exercises, logs warnings)
  • Respects existing rate limiting and usage logging

Backend - Training Service (training-service.ts)

  • createTraining: accepts AI_TRAINING mode (static and randomized)
  • startTraining: new AI_TRAINING branch - selects words, fetches full word details + language info, calls AIService.generateExercises, stores aiExercises on execution
  • submitAnswer: new AI_TRAINING branch - compares selected option index against correctOptionIndex, tracks completion

Frontend - Flutter

  • Updated training_provider.dart to fetch aiExercises fields in GraphQL mutations
  • Added AI Training ChoiceChip in training_creation_screen.dart
  • Created ai_exercise_widget.dart - displays exercise type, prompt, answer options as tappable buttons, correct/incorrect feedback
  • Updated training_execution_screen.dart to handle AI_TRAINING mode with progress tracking

Tests

  • ai-service.test.ts - 11 unit tests covering exercise generation, rate limiting, error handling, parsing
  • ai-service.property.test.ts - Property tests for prompt construction, parsing/validation, round-trip serialization
  • ai-training-service.test.ts - 7 unit tests for AI training creation, start, submission, completion
  • ai-training-service.property.test.ts - 4 property tests for creation, start, submission, backward compatibility

All 28 tasks completed

All tasks from .kiro/specs/ai-training-mode/tasks.md have been implemented and marked as complete.

Notes

  • No new DynamoDB tables, GSIs, or CDK stack changes required
  • Lambda resolvers require no changes (they delegate to TrainingService)
  • Existing TEXT_INPUT and MULTIPLE_CHOICE trainings are unaffected (backward compatible)
  • Tests could not be executed in the sandbox environment (no npm/node_modules available) - please run npm test locally to verify

kiro-agent and others added 6 commits April 8, 2026 09:22
…tion

- Add 'AI_TRAINING' to TrainingMode union type in Training.ts
- Add AIExercise interface with prompt, options, correctOptionIndex,
  exerciseType, and sourceWord fields
- Add optional aiExercises field to TrainingExecution interface
- Add AI_TRAINING to TrainingMode enum in GraphQL schema
- Add AIExercise type to GraphQL schema
- Add aiExercises field to TrainingExecution GraphQL type
- Add generateExercises method to AIService with rate limiting,
  Bedrock integration, and response validation
- Extract parseAndValidateExercises as a separate testable method

Co-authored-by: Johannes Koch <github@lockhead.net>
…rt, and answer submission

Co-authored-by: Johannes Koch <github@lockhead.net>
- ai-service.test.ts: unit tests for parseAndValidateExercises (valid, invalid,
  markdown fences, invalid JSON, all-invalid) and generateExercises (Bedrock
  failure, rate limit, empty words, logging, invalid JSON, all-invalid)
- ai-service.property.test.ts: property tests for prompt construction (all words
  and languages included), parsing validation (only valid exercises returned),
  and round-trip serialization (JSON.stringify/parse equivalence)

Co-authored-by: Johannes Koch <github@lockhead.net>
…etion

Co-authored-by: Johannes Koch <github@lockhead.net>
… and backward compatibility

Co-authored-by: Johannes Koch <github@lockhead.net>
…nd mode selection

Co-authored-by: Johannes Koch <github@lockhead.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant