Repository navigation
feat(modules): Add Folders and Repo Sourced Lessons - #36
Conversation
|
@mathewdunne Could you take a look at this please? |
|
@eprig sorry, I didn't see this until you tagged me (my GitHub notifications clearly aren't set up properly), I'll try to fix it tomorrow |
|
@eprig was removing the lesson numbers intentional? I kind of like having them, so if you don't mind, I'll push another commit to this branch adding them back? There are a couple other minor bugs claude flagged, I can fix those as well. For the most part looks good though! |
|
Yes removing the numbers was intentional, mainly because they can get split across folders. I can see it being useful when having individual lessons, but when there are multiple folders it can get messy. |
- Treat a repo module clone holding only .git as empty, so an empty repository fails the load instead of replacing the project with nothing. - Ignore unknown keys on modules and folders again, and pick the folder or module schema by the presence of `folder` so errors point at the failing field instead of a vague union error. - Show "No lessons are available yet." when the catalog has only empty folders. - Log the module repo as cloneUrl for repo-module loads. - Correct the comment on why catalog loads are not rate-limited. - Reject dot-only owner/repo segments such as `../x` in module repos. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eprig Thoughts on this approach? If you're okay with that I'll implement it and then merge. I also have a fix ready for these minor bugs:
|
|
Sounds good 👍 |
A flat catalog counts 1, 2, 3 as it did before folders, and a folder holding only lessons numbers its own from 1. A list that mixes lessons and folders stays unnumbered, so a number never jumps across a folder. Hidden empty folders do not count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@eprig v6.10.0 has the changes, feel free to let me know or raise another PR if you have any other issues! |
Summary
Extends the lesson catalog beyond "a subdir in one catalog repo". A module can
now be sourced from its own public GitHub repository, and the catalog
modulesarray can be a recursive tree of folders and modules. The Switch Project picker
renders that tree as collapsible, multi-level sections.
Closes the gap that made premade curricula (e.g. FRCSoftware.org, where each
stage is a separate repo) impossible to express without duplicating them into a
team's catalog.
Changes
Contracts (
packages/contracts/src/index.ts)lessonModuleSchemanow accepts exactly one source:subdir(existing) orrepo(new).repoacceptshttps://github.com/owner/repo(.git)orowner/reposhorthand; schemas are strict and cross-validate:subdir/repois rejected;preserveGit: trueis rejected withoutrepo.preserveGitdefaults tofalse. Withrepo, it keeps the shallow clone's.git(history andorigin) in the student workspace; otherwise.gitisremoved as before.
lessonFolderSchema(folder, optionaldescription,order,recursive
modules) andlessonCatalogEntrySchema(module or folder).Folder names are trimmed, 1–80 chars, single path segment (no
/,\, orcontrol characters).
lessonCatalogSchema/lessonCatalogResponseSchemanow use the entry unionand validate the whole tree: module ids unique globally, folder names unique
among siblings, repeated ids/duplicate folders reported with full paths.
isLessonFolder(),flattenLessonModules()(depth-first), and theLessonCatalogEntry,LessonFolder,LessonFolderName,LessonModuleRepotypes.
Control plane
catalog.ts: sorting is now recursive byorderat every level; folders andmodules share one ordering scale, array order only breaks ties. Module lookup
flattens nested folders so
/api/lessons/loadresolves ids anywhere in thetree.
app/websocket.ts: forwardssubdir,repo, andpreserveGitto thelesson-load context (
subdirmay now benull).imports.ts: addednormalizeCatalogModuleRepo()(reuses the GitHub-onlyURL parser used by team imports). Catalog loads now:
repomodule's root (git clone --depth 1, argv, no shell);subdirmodules and thecopy path for bundled modules;
.gitexcept forrepomodules withpreserveGit;and
current_modulerecording.Web (
apps/web)useLessons()andlib/contracts.tsnow carry the recursiveLessonCatalogEntrytype and folder helpers.SwitchProjectDialog: recursive rendering of folders with expand/collapsechevrons, optional folder descriptions (visible when collapsed), and module
counts. Collapse state is keyed by folder path and resets on catalog change.
module-groups.tshelpers: grouping consecutive modules into grids,counting modules in a subtree, checking for the current module, and numbering
modules depth-first in render order.
Docs
AGENTS.md: updated Lessons & Modules overview.049-repo-sourced-lesson-modules.mdand050-module-folders.md(both Accepted); indexed indocs/decisions/README.md.docs/lessons/authoring-modules.md(manifest format,repo,preserveGit, folders) anddocs/lessons/overview.md.Tests
preserveGit,folder trees, duplicate detection, and
flattenLessonModules..githandling, validation),lesson routes, and path-traversal security.
SwitchProjectDialogfolder tree interactions plus newmodule-groups.test.ts.scripts/catalog-integrity.test.ts: manifest parses against the new schema.Compatibility / notes
schemaVersionstays1; existingsubdirmodules and bundled catalogs needno changes.
/api/lessonsmodulesfield is now a union array.
published there.
reload (no server-side backup);
preserveGitis opt-in for repo modules.Disclaimer
This PR was written by opencode's big pickle model including the change log. I'm open to suggestions for changes because of my limited knowledge of this project.