Seed the vendor catalogue into SQL and add an optional AI course advisor

Course metadata: a scan now gives every course a course_meta row from the
downloader's sidecar JSON when the folder has one, else from catalog_courses
matched by the folder name the downloader would create (folderKeyFor, a port
of ine.py's sanitize_name). tools/build-catalog-seed.php turns the INE export
into seeds/ine_catalog.sql, an idempotent patch that creates its own table and
upserts by id, so it can be applied to the live server before or after the
code and re-run freely. Course pages show the blurb, difficulty, vendor and
tags; search matches tags and blurbs; Settings reports how each course got its
details. Against the live library 163 of 179 courses match.

Course advisor, off by default: api/advisor.php answers "which course should I
take to learn X / what comes before Y" with courses from the library, in
order, plus vendor courses not yet downloaded. includes/ai_client.php is a
small curl wrapper for any OpenAI-format chat endpoint (DeepSeek V4 Flash by
default, no composer); the prompt is a byte-stable catalogue of the library so
the provider's prefix cache covers it. Every course id the model returns is
validated server-side, a bad JSON reply gets one retry then a plain-text
fallback, and a per-user daily cap with token counts lives in
advisor_requests. With AI_ENABLED false the app makes no outbound requests
and the box does not appear; users can also hide it per browser.

Claude-Session: https://claude.ai/code/session_012enquL2RZdjy3D5AcKP5yx
This commit is contained in:
Harwinder Sekhon
2026-09-08 18:36:43 -04:00
parent 04314327db
commit 59fab56359
14 changed files with 1548 additions and 16 deletions
+68
View File
@@ -1209,3 +1209,71 @@ button, input { font-family: inherit; font-size: inherit; }
white-space: pre-wrap;
word-break: break-word;
}
/* ===========================================================================
Course blurbs (from the catalogue) and the AI course advisor
========================================================================= */
.course-about { margin: 0 0 22px; max-width: 820px; }
.course-about p { font: 500 16px/1.55 var(--font-ui); color: var(--ink-2); margin: 0 0 10px; }
.chips-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.advisor { padding: 20px; margin-bottom: 32px; }
.advisor-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.advisor-head h2 { margin: 0; font-size: 22px; }
.advisor-sub { font: 500 15px/1.5 var(--font-ui); color: var(--ink-3); margin: 0 0 16px; }
.advisor-thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.advisor-thread:empty { display: none; }
.advisor-msg { max-width: 760px; }
.advisor-msg.is-user {
align-self: flex-end;
background: var(--accent-soft);
color: var(--ink);
border-radius: 12px 12px 4px 12px;
padding: 10px 14px;
font: 500 15px/1.5 var(--font-ui);
white-space: pre-wrap;
word-break: break-word;
}
.advisor-msg.is-bot { align-self: stretch; max-width: none; }
.advisor-answer { font: 500 16px/1.6 var(--font-ui); color: var(--ink-2); max-width: 760px; }
.advisor-answer p { margin: 0 0 10px; }
.advisor-answer ul { margin: 0 0 10px 22px; padding: 0; }
.advisor-answer li { margin: 3px 0; }
.advisor-label {
font: 600 13px/1 var(--font-ui);
letter-spacing: .06em;
text-transform: uppercase;
color: var(--ink-3);
margin: 14px 0 8px;
}
.advisor-list { display: flex; flex-direction: column; gap: 8px; }
.advisor-list .row-card { align-items: flex-start; }
.advisor-list .row-bar { align-self: center; max-width: 220px; }
.advisor-reason { font: 500 14px/1.45 var(--font-ui); color: var(--ink-3); margin-top: 3px; }
.advisor-prereqs { display: flex; flex-wrap: wrap; gap: 6px; }
.advisor-pending { display: flex; align-items: center; gap: 10px; font: 500 15px/1 var(--font-ui); color: var(--ink-3); }
.advisor-msg .alert { margin-bottom: 0; }
.advisor-form { display: flex; gap: 10px; align-items: flex-end; }
.advisor-form textarea {
flex: 1;
min-height: 44px;
max-height: 180px;
padding: 10px 14px;
border: 1px solid var(--line-strong);
border-radius: 8px;
background: var(--surface);
color: var(--ink);
font: 500 15px/1.5 var(--font-ui);
resize: vertical;
outline: none;
}
.advisor-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.advisor-form textarea:disabled { opacity: .6; }
.advisor-form .btn { height: 44px; }
.advisor-note { font: 500 13px/1.4 var(--font-ui); color: var(--ink-4); margin-top: 8px; }
@media (max-width: 900px) {
.advisor-form { flex-direction: column; align-items: stretch; }
.advisor-msg { max-width: 100%; }
.advisor-list .row-bar { display: none; }
}