feat(ai): Tec21 calendar awareness + Canvas-aware materias#18
Merged
Conversation
The model was using ISO calendar weeks instead of the Tec21 academic calendar,
and only saw materias from materias_inscritas. Two fixes:
1. Tec21 calendar awareness
- New lib/tec21/calendar.ts: given a semester start date, computes current
block (1/2/3), week within block (1-5), and whether it's Semana Tec.
- Stored per-user in profiles.semestre_inicio (depends on enrollment period).
- Onboarding step 2 adds a date input for the semester start date.
- Prompt updated with the 5+1+5+1+5 block pattern and rules about Semana Tec
(no regular study blocks; project focus) and end-of-block urgency.
2. Canvas-aware context
- Eventos passed to Gemini now include `fuente` (canvas/google/...).
- Prompt rules: canvas events are deadlines and weigh heavily; google events
are calendar blocks to avoid.
- Materias inferred from Canvas event titles via clave regex
(e.g. "TC2025 - Tarea 3"). If a clave appears in canvas events but not in
materias_inscritas, it's added to context with `inferida: true` and the
model is instructed to flag the discrepancy.
DB migration:
ALTER TABLE profiles ADD COLUMN IF NOT EXISTS semestre_inicio date;
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Por qué
materias_inscritas; ignoraba materias que aparecen en eventos sincronizados de Canvas.Qué cambia
Tec21 calendar
lib/tec21/calendar.tscalcula bloque actual, semana en bloque, y Semana Tec dado unsemestre_inicio.profiles.semestre_inicio(date) — guardado por usuario porque depende del periodo de inscripción.Canvas-aware
fuente.materias_inscritas, se agrega comoinferida: truey el modelo lo señala.Migration requerida
Test plan
profiles.semestre_inicioPOST /api/insights/generateincluyecalendario_tec21en contextinferidaen prioridades🤖 Generated with Claude Code