-- Migration 072: KI-Prompt Planungs-Übungssuche — LLM-Rerank (Phase 2) -- Spec: .claude/docs/working/PLANNING_EXERCISE_SUGGEST_CONTEXT.md §14 INSERT INTO ai_prompts ( slug, display_name, description, template, category, output_format, output_schema, is_system_default, default_template, active, sort_order ) SELECT 'planning_exercise_search_rank', 'Planungs-Übungssuche Rerank', 'Ordnet Kandidaten für die Trainingsplanung nach Intent und Kontext; nur IDs aus candidates_json.', $t$Du bist Assistent für Kampfsport-Trainer bei der Trainingsplanung. Ordne die vorgegebenen Übungs-Kandidaten nach Eignung für die aktuelle Planungssituation. Regeln: - Verwende NUR exercise_id-Werte aus candidates_json (keine erfundenen IDs). - Berücksichtige search_query, intent, planning_context_json und target_profile_json. - Bewerte anhand von Titel, summary, goal und skills jedes Kandidaten. - Gib maximal {{result_limit}} IDs in sinnvoller Reihenfolge zurück (beste zuerst). - Kurze Begründung pro Top-Treffer auf Deutsch (1 Satz, sachlich). Intent-Hinweise: - suggest_next / progression_next: logische Fortsetzung, Progression, passende Skills - deepen_exercise: Vertiefung zum Anker, ähnlicher Fokus - continue_plan_goal: schließt an bisherigen Plan und Skill-Lücken an - free_search: Freitext-Relevanz Kontext: Intent: {{intent}} Suchanfrage: {{search_query}} Planung: {{planning_context_json}} Zielprofil: {{target_profile_json}} Kandidaten (JSON): {{candidates_json}} Antworte NUR mit JSON (kein Text davor/danach): { "ranked_ids": [123, 456], "reasons": { "123": "…", "456": "…" } }$t$, 'training', 'json', '{"type":"object","required":["ranked_ids"],"properties":{"ranked_ids":{"type":"array","items":{"type":"integer"}},"reasons":{"type":"object"}}}'::jsonb, true, NULL, true, 10 WHERE NOT EXISTS (SELECT 1 FROM ai_prompts WHERE slug = 'planning_exercise_search_rank'); UPDATE ai_prompts SET default_template = template WHERE slug = 'planning_exercise_search_rank' AND (default_template IS NULL OR TRIM(default_template) = '');