extend chat model with CRUD actions for event changes

- Add ProposedEventChange type with create/update/delete actions
- Replace proposedEvent with proposedChange in ChatMessage
- Add currentDate to AIContext for time-aware AI responses
- Add AI test endpoint for development (/api/ai/test)
- Fix MongoUserRepository type safety with explicit toUser mapping
- Update CLAUDE.md documentation
This commit is contained in:
2026-01-03 19:37:27 +01:00
parent 105a9a4980
commit e553103470
7 changed files with 82 additions and 34 deletions

View File

@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview
**CalChat** is a calendar mobile app with AI support. The core concept is creating calendar events through a chat interface with an AI chatbot (Claude). Users can add, edit, and delete events via natural language conversation.
**CalChat** is a calendar mobile app with AI support. The core concept is managing calendar events through a chat interface with an AI chatbot. Users can add, edit, and delete events via natural language conversation.
This is a fullstack TypeScript monorepo with npm workspaces.
@@ -152,6 +152,7 @@ src/
- `GET /api/chat/conversations` - Get all conversations (protected)
- `GET /api/chat/conversations/:id` - Get messages of a conversation with cursor-based pagination (protected)
- `GET /health` - Health check
- `POST /api/ai/test` - AI test endpoint (development only)
### Shared Package (packages/shared)
@@ -163,13 +164,15 @@ src/
├── User.ts # User, CreateUserDTO, LoginDTO, AuthResponse
├── CalendarEvent.ts # CalendarEvent, CreateEventDTO, UpdateEventDTO
└── ChatMessage.ts # ChatMessage, Conversation, SendMessageDTO, CreateMessageDTO,
# GetMessagesOptions, ChatResponse, ConversationSummary
# GetMessagesOptions, ChatResponse, ConversationSummary,
# ProposedEventChange, EventAction
```
**Key Types:**
- `User`: id, email, displayName, passwordHash?, createdAt?, updatedAt?
- `CalendarEvent`: id, userId, title, description?, startTime, endTime, note?, isRecurring?, recurrenceRule?
- `ChatMessage`: id, conversationId, sender ('user' | 'assistant'), content, proposedEvent?
- `ChatMessage`: id, conversationId, sender ('user' | 'assistant'), content, proposedChange?
- `ProposedEventChange`: action ('create' | 'update' | 'delete'), eventId?, event?, updates?
- `Conversation`: id, userId, createdAt?, updatedAt? (messages loaded separately via lazy loading)
- `CreateEventDTO`: Used for creating events AND for AI-proposed events
- `GetMessagesOptions`: Cursor-based pagination with `before?: string` and `limit?: number`