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:
2026-01-10 00:22:59 +01:00
parent c897b6d680
commit 675785ec93
17 changed files with 599 additions and 61 deletions

View File

@@ -0,0 +1,29 @@
import { CalendarEvent } from "@caldav/shared";
// German date/time formatting helpers
export const formatDate = (d: Date) => d.toLocaleDateString("de-DE");
export const formatTime = (d: Date) =>
d.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit" });
export const formatDateTime = (d: Date) =>
`${formatDate(d)} ${d.toLocaleTimeString("de-DE")}`;
/**
* Format a list of events for display in the system prompt.
* Output is in German with date/time formatting.
*/
export function formatExistingEvents(events: CalendarEvent[]): string {
if (events.length === 0) {
return "Keine Termine vorhanden.";
}
return events
.map((e) => {
const start = new Date(e.startTime);
const end = new Date(e.endTime);
const timeStr = `${formatTime(start)} - ${formatTime(end)}`;
const recurring = e.isRecurring ? " (wiederkehrend)" : "";
const desc = e.description ? ` | ${e.description}` : "";
return `- ${e.title} (ID: ${e.id}) | ${formatDate(start)} ${timeStr}${recurring}${desc}`;
})
.join("\n");
}