feat: replace Claude with GPT for AI chat integration
- Replace ClaudeAdapter with GPTAdapter using OpenAI GPT (gpt-5-mini) - Implement function calling for calendar operations (getDay, proposeCreate/Update/Delete, searchEvents) - Add provider-agnostic AI utilities in ai/utils/ (systemPrompt, toolDefinitions, toolExecutor, eventFormatter) - Add USE_TEST_RESPONSES env var to toggle between real AI and test responses - Switch ChatService.processMessage to use real AI provider - Add npm run format command for Prettier - Update CLAUDE.md with new architecture
This commit is contained in:
20
CLAUDE.md
20
CLAUDE.md
@@ -13,6 +13,7 @@ This is a fullstack TypeScript monorepo with npm workspaces.
|
||||
### Root (monorepo)
|
||||
```bash
|
||||
npm install # Install all dependencies for all workspaces
|
||||
npm run format # Format all TypeScript files with Prettier
|
||||
```
|
||||
|
||||
### Client (apps/client) - Expo React Native app
|
||||
@@ -44,7 +45,7 @@ npm run start -w @caldav/server # Run compiled server (port 3000)
|
||||
| Backend | Express.js | Web framework |
|
||||
| | MongoDB | Database |
|
||||
| | Mongoose | ODM |
|
||||
| | Claude (Anthropic) | AI/LLM for chat |
|
||||
| | GPT (OpenAI) | AI/LLM for chat |
|
||||
| | JWT | Authentication |
|
||||
| Planned | iCalendar | Event export/import |
|
||||
|
||||
@@ -134,7 +135,14 @@ src/
|
||||
│ ├── MongoEventRepository.ts
|
||||
│ └── MongoChatRepository.ts
|
||||
├── ai/
|
||||
│ └── ClaudeAdapter.ts # Implements AIProvider
|
||||
│ ├── GPTAdapter.ts # Implements AIProvider using OpenAI GPT
|
||||
│ ├── index.ts # Re-exports GPTAdapter
|
||||
│ └── utils/ # Shared AI utilities (provider-agnostic)
|
||||
│ ├── index.ts # Re-exports
|
||||
│ ├── eventFormatter.ts # formatExistingEvents() for system prompt
|
||||
│ ├── systemPrompt.ts # buildSystemPrompt() - German calendar assistant prompt
|
||||
│ ├── toolDefinitions.ts # TOOL_DEFINITIONS - provider-agnostic tool specs
|
||||
│ └── toolExecutor.ts # executeToolCall() - handles getDay, proposeCreate/Update/Delete, searchEvents
|
||||
└── utils/
|
||||
├── jwt.ts # signToken(), verifyToken()
|
||||
├── password.ts # hash(), compare()
|
||||
@@ -264,6 +272,8 @@ Server requires `.env` file in `apps/server/`:
|
||||
JWT_SECRET=your-secret-key
|
||||
JWT_EXPIRES_IN=1h
|
||||
MONGODB_URI=mongodb://root:mongoose@localhost:27017/calchat?authSource=admin
|
||||
OPENAI_API_KEY=sk-proj-...
|
||||
USE_TEST_RESPONSES=false # true = static test responses, false = real GPT AI
|
||||
```
|
||||
|
||||
## Current Implementation Status
|
||||
@@ -284,15 +294,15 @@ MONGODB_URI=mongodb://root:mongoose@localhost:27017/calchat?authSource=admin
|
||||
- `utils/eventFormatters`: getWeeksOverview(), getMonthOverview() with German localization
|
||||
- `utils/recurrenceExpander`: expandRecurringEvents() using rrule library for RRULE parsing
|
||||
- `ChatController`: getConversations(), getConversation() with cursor-based pagination support
|
||||
- `ChatService`: getConversations(), getConversation(), processMessage() now persists user/assistant messages to DB, confirmEvent()/rejectEvent() update respondedAction and persist response messages
|
||||
- `ChatService`: getConversations(), getConversation(), processMessage() uses real AI or test responses (via USE_TEST_RESPONSES), confirmEvent()/rejectEvent() update respondedAction and persist response messages
|
||||
- `MongoChatRepository`: Full CRUD implemented (getConversationsByUser, createConversation, getMessages with cursor pagination, createMessage, updateMessage)
|
||||
- `ChatRepository` interface: updateMessage() added for respondedAction tracking
|
||||
- `GPTAdapter`: Full implementation with OpenAI GPT (gpt-5-mini model), function calling for calendar operations
|
||||
- `ai/utils/`: Provider-agnostic shared utilities (systemPrompt, toolDefinitions, toolExecutor, eventFormatter)
|
||||
- **Stubbed (TODO):**
|
||||
- `AuthMiddleware.authenticate()`: Currently uses fake user for testing
|
||||
- `AuthController`: refresh(), logout()
|
||||
- `AuthService`: refreshToken()
|
||||
- **Not started:**
|
||||
- `ClaudeAdapter` (AI integration - currently using test responses)
|
||||
|
||||
**Shared:** Types, DTOs, constants (Day, Month with German translations), ExpandedEvent type, and date utilities defined and exported.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user