Flexibles KI Prompt System #48

Merged
Lars merged 56 commits from develop into main 2026-03-26 14:49:48 +01:00
Showing only changes of commit ae6bd0d865 - Show all commits

View File

@ -56,7 +56,7 @@ frontend/src/
└── technical/ # MEMBERSHIP_SYSTEM.md
```
## Aktuelle Version: v9d + Issue #28 🚀 Development seit 25.03.2026
## Aktuelle Version: v9e (Issue #28 Complete) 🚀 Ready for Production 26.03.2026
### Implementiert ✅
- Login (E-Mail + bcrypt), Auth-Middleware alle Endpoints, Rate Limiting
@ -188,7 +188,7 @@ frontend/src/
📚 Details: `.claude/docs/technical/MEMBERSHIP_SYSTEM.md` · `.claude/docs/architecture/FEATURE_ENFORCEMENT.md`
### Issue #28: Unified Prompt System ✅ (Development 25.03.2026)
### Issue #28: Unified Prompt System ✅ (Completed 26.03.2026)
**AI-Prompts Flexibilisierung - Komplett überarbeitet:**
@ -220,21 +220,88 @@ frontend/src/
- JSON-Output erzwingbar pro Prompt
- Cross-Module Korrelationen möglich
**Debug & Development Tools (26.03.2026):**
- ✅ **Comprehensive Debug System:**
- Test-Button in Prompt-Editor mit Debug-Modus
- Shows resolved/unresolved placeholders
- Displays final prompts sent to AI
- Per-stage debug info for pipelines
- Export debug data as JSON
- ✅ **Placeholder Export (per Test):**
- Button in Debug-Viewer
- Exports all placeholders with values per execution
- ✅ **Global Placeholder Export:**
- Settings → "📊 Platzhalter exportieren"
- All 32 placeholders with current values
- Organized by category
- Includes metadata (description, example)
- ✅ **Batch Import/Export:**
- Admin → "📦 Alle exportieren" (all prompts as JSON)
- Admin → "📥 Importieren" (upload JSON, create/update)
- Dev→Prod sync in 2 clicks
**Placeholder System Enhancements:**
- ✅ **6 New Placeholder Functions:**
- `{{sleep_avg_duration}}` - Average sleep duration (7d)
- `{{sleep_avg_quality}}` - Deep+REM percentage (7d)
- `{{rest_days_count}}` - Rest days count (30d)
- `{{vitals_avg_hr}}` - Average resting heart rate (7d)
- `{{vitals_avg_hrv}}` - Average HRV (7d)
- `{{vitals_vo2_max}}` - Latest VO2 Max value
- ✅ **7 Reconstructed Placeholders:**
- `{{caliper_summary}}`, `{{circ_summary}}`
- `{{goal_weight}}`, `{{goal_bf_pct}}`
- `{{nutrition_days}}`
- `{{protein_ziel_low}}`, `{{protein_ziel_high}}`
- `{{activity_detail}}`
- **Total: 32 active placeholders** across 6 categories
**Bug Fixes (26.03.2026):**
- ✅ **PIPELINE_MASTER Response:** Analysis page now uses unified executor
- Fixed: Old `/insights/run` endpoint sent raw template to AI
- Now: `/prompts/execute` with proper stage processing
- ✅ **Age Calculation:** Handle PostgreSQL DATE objects
- Fixed: `calculate_age()` expected string, got date object
- Now: Handles both strings and date objects
- ✅ **Sleep Quality 0%:** Lowercase stage names
- Fixed: Checked ['Deep', 'REM'], but stored as ['deep', 'rem']
- Now: Correct case-sensitive matching
- ✅ **SQL Column Name Errors:**
- Fixed: `bf_jpl``body_fat_pct`
- Fixed: `brust``c_chest`, etc.
- Fixed: `protein``protein_g`
- ✅ **Decimal × Float Type Error:**
- Fixed: `protein_ziel_low/high` calculations
- Now: Convert Decimal to float before multiplication
**Migrations:**
- Migration 020: Unified Prompt System Schema
**Backend Endpoints:**
- `POST /api/prompts/execute` - Universeller Executor
- `POST /api/prompts/execute` - Universeller Executor (with save=true param)
- `POST /api/prompts/unified` - Create unified prompt
- `PUT /api/prompts/unified/{id}` - Update unified prompt
- `GET /api/prompts/export-all` - Export all prompts as JSON
- `POST /api/prompts/import` - Import prompts from JSON (with overwrite option)
- `GET /api/prompts/placeholders/export-values` - Export all placeholder values
**UI:**
- Admin → KI-Prompts: Type-Filter (Alle/Basis/Pipeline)
- Neuer Prompt-Editor mit dynamischem Stage-Builder
- Inline editing von Stages + Prompts
- Test-Button mit Debug-Viewer (always visible)
- Export/Import Buttons (📦 Alle exportieren, 📥 Importieren)
- Settings → 📊 Platzhalter exportieren
📚 Details: `.claude/docs/functional/AI_PROMPTS.md`
**Related Gitea Issues:**
- #28: Unified Prompt System - ✅ CLOSED (26.03.2026)
- #43: Enhanced Debug UI - 🔲 OPEN (Future enhancement)
- #44: BUG - Analysen löschen - 🔲 OPEN (High priority)
- #45: KI Prompt-Optimierer - 🔲 OPEN (Future feature)
- #46: KI Prompt-Ersteller - 🔲 OPEN (Future feature)
## Feature-Roadmap
> 📋 **Detaillierte Roadmap:** `.claude/docs/ROADMAP.md` (Phasen 0-3, Timeline, Abhängigkeiten)