ronin-skillforce 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (429) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +21 -0
  3. package/README.md +225 -2
  4. package/bin/cli.js +811 -0
  5. package/bin/commands/check.js +298 -0
  6. package/bin/commands/create.js +169 -0
  7. package/bin/commands/doctor.js +392 -0
  8. package/bin/commands/import.js +557 -0
  9. package/bin/commands/next.js +125 -0
  10. package/bin/commands/review.js +207 -0
  11. package/bin/commands/status.js +114 -0
  12. package/bin/commands/studio.js +497 -0
  13. package/bin/commands/trail.js +211 -0
  14. package/bin/commands/web.js +350 -0
  15. package/bin/course-reader.js +611 -0
  16. package/bin/node-version.js +60 -0
  17. package/bin/platforms/_shared.js +211 -0
  18. package/bin/platforms/claude.js +104 -0
  19. package/bin/platforms/cursor.js +49 -0
  20. package/bin/platforms/gemini.js +65 -0
  21. package/bin/platforms/opencode.js +95 -0
  22. package/bin/registry-helpers.js +504 -0
  23. package/bin/static-server.js +153 -0
  24. package/bin/studio-store.js +94 -0
  25. package/bin/sync-shared.sh +5 -0
  26. package/package.json +91 -4
  27. package/plugin.json +139 -0
  28. package/shared/SKILL.md +568 -0
  29. package/shared/agents/coach.md +225 -0
  30. package/shared/agents/navigator.md +215 -0
  31. package/shared/agents/professor.md +372 -0
  32. package/shared/agents/researcher.md +181 -0
  33. package/shared/agents/spotter.md +129 -0
  34. package/shared/commands/professor/archive.md +103 -0
  35. package/shared/commands/professor/capstone-review.md +79 -0
  36. package/shared/commands/professor/capstone.md +34 -0
  37. package/shared/commands/professor/discuss.md +18 -0
  38. package/shared/commands/professor/done.md +44 -0
  39. package/shared/commands/professor/export.md +69 -0
  40. package/shared/commands/professor/hint.md +108 -0
  41. package/shared/commands/professor/navigator.md +67 -0
  42. package/shared/commands/professor/new-topic.md +73 -0
  43. package/shared/commands/professor/next.md +174 -0
  44. package/shared/commands/professor/note.md +63 -0
  45. package/shared/commands/professor/onboard.md +95 -0
  46. package/shared/commands/professor/progress.md +46 -0
  47. package/shared/commands/professor/publish.md +93 -0
  48. package/shared/commands/professor/quiz.md +27 -0
  49. package/shared/commands/professor/recall.md +74 -0
  50. package/shared/commands/professor/review.md +43 -0
  51. package/shared/commands/professor/schedule.md +75 -0
  52. package/shared/commands/professor/skill-export.md +87 -0
  53. package/shared/commands/professor/spotter.md +76 -0
  54. package/shared/commands/professor/stuck.md +27 -0
  55. package/shared/commands/professor/switch.md +50 -0
  56. package/shared/commands/professor/syllabus.md +9 -0
  57. package/shared/commands/professor/template-export.md +91 -0
  58. package/shared/commands/professor/template-import.md +111 -0
  59. package/shared/commands/professor/worktrees.md +58 -0
  60. package/shared/hooks/pre-compact.js +232 -0
  61. package/studio/README.md +313 -0
  62. package/studio/dist/assets/BetaReportPanel-8NrDLiPm.js +1 -0
  63. package/studio/dist/assets/Capstone-Cv9kH6LY.js +6 -0
  64. package/studio/dist/assets/CodeWorkspace-BwCEINWo.js +2 -0
  65. package/studio/dist/assets/Course-BJ_hafUP.js +1 -0
  66. package/studio/dist/assets/Editor-CV0mNhlz.js +53 -0
  67. package/studio/dist/assets/Home-C1ry89ak.js +1 -0
  68. package/studio/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  69. package/studio/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  70. package/studio/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  71. package/studio/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  72. package/studio/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  73. package/studio/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  74. package/studio/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  75. package/studio/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  76. package/studio/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  77. package/studio/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  78. package/studio/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  79. package/studio/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  80. package/studio/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  81. package/studio/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  82. package/studio/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  83. package/studio/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  84. package/studio/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  85. package/studio/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  86. package/studio/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  87. package/studio/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  88. package/studio/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  89. package/studio/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  90. package/studio/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  91. package/studio/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  92. package/studio/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  93. package/studio/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  94. package/studio/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  95. package/studio/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  96. package/studio/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  97. package/studio/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  98. package/studio/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  99. package/studio/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  100. package/studio/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  101. package/studio/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  102. package/studio/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  103. package/studio/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  104. package/studio/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  105. package/studio/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  106. package/studio/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  107. package/studio/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  108. package/studio/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  109. package/studio/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  110. package/studio/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  111. package/studio/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  112. package/studio/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  113. package/studio/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  114. package/studio/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  115. package/studio/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  116. package/studio/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  117. package/studio/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  118. package/studio/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  119. package/studio/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  120. package/studio/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  121. package/studio/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  122. package/studio/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  123. package/studio/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  124. package/studio/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  125. package/studio/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  126. package/studio/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  127. package/studio/dist/assets/Lesson-2e9TD9yL.js +2 -0
  128. package/studio/dist/assets/NewCourse-BZeOg2xn.js +952 -0
  129. package/studio/dist/assets/Progress-CRc_xEWC.js +1 -0
  130. package/studio/dist/assets/Review-6QEbHEfk.js +1 -0
  131. package/studio/dist/assets/Settings-NFnqVQui.js +1 -0
  132. package/studio/dist/assets/TutorPanel-DXQ6Z3BY.js +123 -0
  133. package/studio/dist/assets/abnfDiagram-WEYOIA3C-qeSjKlGM.js +1 -0
  134. package/studio/dist/assets/anthropic-D7NiQCUH.js +15 -0
  135. package/studio/dist/assets/arc-Y1ARJVZ4.js +1 -0
  136. package/studio/dist/assets/architecture-WOLXFQ4H-COG-m35l.js +1 -0
  137. package/studio/dist/assets/architectureDiagram-ZHVYKT53-VO7uKoeD.js +36 -0
  138. package/studio/dist/assets/array-BifhSqXX.js +1 -0
  139. package/studio/dist/assets/blockDiagram-RJAE7QA3-BGJF_qiL.js +140 -0
  140. package/studio/dist/assets/bridge-BTh0AeNX.js +1 -0
  141. package/studio/dist/assets/c4Diagram-XDPPPE54-C-S10RgU.js +38 -0
  142. package/studio/dist/assets/capstone-Amn6Hztq.js +135 -0
  143. package/studio/dist/assets/card-store-BrbrtX9w.js +1 -0
  144. package/studio/dist/assets/channel-SJiUQu_N.js +1 -0
  145. package/studio/dist/assets/chunk-2E7WHVMD-fv-iqTyC.js +88 -0
  146. package/studio/dist/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  147. package/studio/dist/assets/chunk-4EMNKR2T-CY9IZrgv.js +1 -0
  148. package/studio/dist/assets/chunk-55XCU76K-DyTZz7v_.js +1 -0
  149. package/studio/dist/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  150. package/studio/dist/assets/chunk-7S6XSTFO-BNMzTLRW.js +2 -0
  151. package/studio/dist/assets/chunk-AQDTSKZB-CEYANohH.js +72 -0
  152. package/studio/dist/assets/chunk-DSNLSHJZ-CDk5EXjH.js +129 -0
  153. package/studio/dist/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
  154. package/studio/dist/assets/chunk-HAGFOTED-hNAi1zh_.js +62 -0
  155. package/studio/dist/assets/chunk-HNE4Q36P-COJnSYoZ.js +1 -0
  156. package/studio/dist/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
  157. package/studio/dist/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  158. package/studio/dist/assets/chunk-NGNAAXSQ-C2Wy9Xmz.js +136 -0
  159. package/studio/dist/assets/chunk-NQOKRVIF-BU6KVxRr.js +213 -0
  160. package/studio/dist/assets/chunk-UHW7PFBP-DYvxL9JG.js +1 -0
  161. package/studio/dist/assets/chunk-VQ5W62QI-CuRfk65j.js +1 -0
  162. package/studio/dist/assets/chunk-WQQL4CDK-KaG7x-Mb.js +10 -0
  163. package/studio/dist/assets/chunk-XXDRQBXY-CnbRkih_.js +1 -0
  164. package/studio/dist/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  165. package/studio/dist/assets/chunk-YZO67HFG-DbuqIZmk.js +1 -0
  166. package/studio/dist/assets/chunk-ZAUX2LTX-bk4ivUmc.js +1 -0
  167. package/studio/dist/assets/chunk-ZCHMQSOR-B_LElfwh.js +2 -0
  168. package/studio/dist/assets/classDiagram-v2-4MYWR3UA-DtCJ6H_X.js +217 -0
  169. package/studio/dist/assets/cose-bilkent-JH36ORCC-DMBAZFnj.js +1 -0
  170. package/studio/dist/assets/course-export-DpaOTT3a.js +1 -0
  171. package/studio/dist/assets/cynefin-EF2NZ3EQ-D9btHJvU.js +1 -0
  172. package/studio/dist/assets/cynefinDiagram-WF24UDRP-CsFJuv27.js +62 -0
  173. package/studio/dist/assets/cytoscape.esm-CHBj4VkZ.js +321 -0
  174. package/studio/dist/assets/dagre-NK4GIZVX-Cg1Duec7.js +4 -0
  175. package/studio/dist/assets/defaultLocale-BFoDCU3G.js +1 -0
  176. package/studio/dist/assets/diagram-CBK3MWTC-_KU2m5gd.js +24 -0
  177. package/studio/dist/assets/diagram-I5XIIV2D-5RaBrwUA.js +24 -0
  178. package/studio/dist/assets/diagram-ODIL2UCW-C0VKxoD3.js +30 -0
  179. package/studio/dist/assets/diagram-PFBEJUXE-BaHcZEP2.js +3 -0
  180. package/studio/dist/assets/diagram-RJA3I4VV-cwSAZ90p.js +41 -0
  181. package/studio/dist/assets/diagram-TYUNFSNR-BJImxCEN.js +200 -0
  182. package/studio/dist/assets/dist-CumnGVmJ.js +1 -0
  183. package/studio/dist/assets/ebnfDiagram-V4P3TTPT-OQQLRXcm.js +1 -0
  184. package/studio/dist/assets/elk-QONTBCTQ-BJGhQHxQ.js +27 -0
  185. package/studio/dist/assets/erDiagram-KYQIGQAA-D91EKSep.js +99 -0
  186. package/studio/dist/assets/error-BTdmRKoB.js +1 -0
  187. package/studio/dist/assets/errors-BZa_CNHL.js +1 -0
  188. package/studio/dist/assets/eventmodeling-K75KTNOO-DgdTRgnw.js +1 -0
  189. package/studio/dist/assets/fetch-local-DG3O3hmQ.js +4 -0
  190. package/studio/dist/assets/flowDiagram-IUGLLWBU-CVnJYMum.js +1 -0
  191. package/studio/dist/assets/ganttDiagram-R7GPNTJY-CSYLPWEI.js +292 -0
  192. package/studio/dist/assets/gitGraph-VSP46ZUC-D6GWaV9y.js +1 -0
  193. package/studio/dist/assets/gitGraphDiagram-PDYL7XHY-CaV31bvT.js +106 -0
  194. package/studio/dist/assets/graphlib-DS17s2tU.js +1 -0
  195. package/studio/dist/assets/index-CVenTTOY.css +2 -0
  196. package/studio/dist/assets/index-DioXTZVc.js +313 -0
  197. package/studio/dist/assets/info-OHQRW6UA-BN-x8GoN.js +1 -0
  198. package/studio/dist/assets/infoDiagram-MVDRKAX5-CIose_cy.js +2 -0
  199. package/studio/dist/assets/init-C-OQMol4.js +1 -0
  200. package/studio/dist/assets/ishikawaDiagram-HPEHV2GE-DCihSNBw.js +70 -0
  201. package/studio/dist/assets/journeyDiagram-BOSHW7O7-Bz3o3RIX.js +139 -0
  202. package/studio/dist/assets/js.worker-AD7DjksO.js +4 -0
  203. package/studio/dist/assets/kanban-definition-FNSA4HC5-BUyqvlFE.js +89 -0
  204. package/studio/dist/assets/katex-B_JcIwqj.js +257 -0
  205. package/studio/dist/assets/katex-BgsA2lO1.css +1 -0
  206. package/studio/dist/assets/line-B08T8KlK.js +1 -0
  207. package/studio/dist/assets/linear-C9iwaMOi.js +1 -0
  208. package/studio/dist/assets/mermaid-parser.core-BYwreSUy.js +7 -0
  209. package/studio/dist/assets/mermaid.core-DTO1oDmq.js +44 -0
  210. package/studio/dist/assets/mindmap-definition-6OY57UG3-BGLwKheY.js +98 -0
  211. package/studio/dist/assets/node.browser-BISniYn8.js +1 -0
  212. package/studio/dist/assets/node.browser-HQ5SKBOf.js +1 -0
  213. package/studio/dist/assets/ollama-De5w84tG.js +1 -0
  214. package/studio/dist/assets/openai-compatible-Joy1oK3L.js +1 -0
  215. package/studio/dist/assets/ordinal-BDEzSJ7C.js +1 -0
  216. package/studio/dist/assets/packet-JDAUHWVQ-CDIMjHS_.js +1 -0
  217. package/studio/dist/assets/path-fybaL0A-.js +1 -0
  218. package/studio/dist/assets/pegDiagram-ECIUJNBX-DWXm4mwS.js +1 -0
  219. package/studio/dist/assets/pie-XZMESJXO-CY3QQiKZ.js +1 -0
  220. package/studio/dist/assets/pieDiagram-GNMPY74T-M1aCnI7W.js +39 -0
  221. package/studio/dist/assets/python.worker-CzTrFdd9.js +24 -0
  222. package/studio/dist/assets/quadrantDiagram-D57K4MC3-BFFtO7U5.js +7 -0
  223. package/studio/dist/assets/radar-ABXABTNO-DT0W4_Xn.js +1 -0
  224. package/studio/dist/assets/railroad-I3PHUGI6-_VCpgZR5.js +1 -0
  225. package/studio/dist/assets/railroad-abnf-LNEFI6M7-DkSpQ5YY.js +1 -0
  226. package/studio/dist/assets/railroad-ebnf-DWYD2UWJ-BqWILdGb.js +1 -0
  227. package/studio/dist/assets/railroad-peg-JR7BVNR7-BB0bQL-Z.js +1 -0
  228. package/studio/dist/assets/railroadDiagram-Y72NRBL7-CjLKjIdJ.js +1 -0
  229. package/studio/dist/assets/react-B8SKf8RM.js +1 -0
  230. package/studio/dist/assets/rehype-katex-C-sKddsH.js +259 -0
  231. package/studio/dist/assets/remark-math-C-ox67hE.js +5 -0
  232. package/studio/dist/assets/requirementDiagram-EQYSW5RA-CnwzZqR8.js +84 -0
  233. package/studio/dist/assets/rolldown-runtime-COiEfhsA.js +1 -0
  234. package/studio/dist/assets/rough.esm-Dy-Kn_BL.js +1 -0
  235. package/studio/dist/assets/sankeyDiagram-SY24JHO5-CPDugTUl.js +40 -0
  236. package/studio/dist/assets/schemas-BOc2YsOP.js +55 -0
  237. package/studio/dist/assets/sequenceDiagram-BLEHNHQU-1dLfeU9Y.js +169 -0
  238. package/studio/dist/assets/settings-DhwuyNPU.js +1 -0
  239. package/studio/dist/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
  240. package/studio/dist/assets/spec-nAnsSMkw.js +1 -0
  241. package/studio/dist/assets/sql-wasm-C1D_RJuy.wasm +0 -0
  242. package/studio/dist/assets/sql.worker-D7pBHOrq.js +4 -0
  243. package/studio/dist/assets/src-BWF7jMDv.js +1 -0
  244. package/studio/dist/assets/stateDiagram-v2-A6IESKWZ-DR7CmEjj.js +291 -0
  245. package/studio/dist/assets/swimlanes-B3ENRKFQ-BAWB9omQ.js +1 -0
  246. package/studio/dist/assets/swimlanesDiagram-AYQRV4AK-qeuHru16.js +8 -0
  247. package/studio/dist/assets/timeline-definition-JXYKGLGB-DNkj8z77.js +120 -0
  248. package/studio/dist/assets/treeView-D4JQ5SDB-BA-ouhMb.js +1 -0
  249. package/studio/dist/assets/treemap-SAJKECNS-BrrGxsAb.js +1 -0
  250. package/studio/dist/assets/useStream-rdsR6A7P.js +1 -0
  251. package/studio/dist/assets/usecaseDiagram-WPOLBNNX-BB3D0Dt_.js +328 -0
  252. package/studio/dist/assets/vennDiagram-Q3Y3IDCW-BrtqtKTE.js +34 -0
  253. package/studio/dist/assets/wardley-7MLQ67FV-BKkemDql.js +1 -0
  254. package/studio/dist/assets/wardleyDiagram-IVAIDKWA-DFnI3P5z.js +78 -0
  255. package/studio/dist/assets/xychartDiagram-4URNHDU4-Da0DZG_q.js +7 -0
  256. package/studio/dist/index.html +20 -0
  257. package/studio/dist/preview.html +22 -0
  258. package/studio/migrations/0001_init.sql +188 -0
  259. package/studio/migrations/0002_external_ids.sql +20 -0
  260. package/studio/migrations/0003_course_language.sql +12 -0
  261. package/studio/migrations/0004_capstone.sql +51 -0
  262. package/studio/migrations/0005_beta_loop.sql +73 -0
  263. package/studio/migrations/0006_interactive_exercises.sql +49 -0
  264. package/studio/src/lib/activity.js +92 -0
  265. package/studio/src/lib/ai/anthropic.js +109 -0
  266. package/studio/src/lib/ai/bridge.js +126 -0
  267. package/studio/src/lib/ai/catalog.js +160 -0
  268. package/studio/src/lib/ai/config.js +70 -0
  269. package/studio/src/lib/ai/errors.js +95 -0
  270. package/studio/src/lib/ai/fetch-local.js +104 -0
  271. package/studio/src/lib/ai/index.js +194 -0
  272. package/studio/src/lib/ai/ollama.js +136 -0
  273. package/studio/src/lib/ai/openai-compatible.js +101 -0
  274. package/studio/src/lib/ai/provider-utils.js +107 -0
  275. package/studio/src/lib/ai/sse.js +99 -0
  276. package/studio/src/lib/ai/status.js +92 -0
  277. package/studio/src/lib/ai/useStream.js +109 -0
  278. package/studio/src/lib/beta/metrics.js +147 -0
  279. package/studio/src/lib/beta/report.js +134 -0
  280. package/studio/src/lib/capstone-evidence.js +758 -0
  281. package/studio/src/lib/capstone.js +663 -0
  282. package/studio/src/lib/chat-store.js +128 -0
  283. package/studio/src/lib/course-export.js +38 -0
  284. package/studio/src/lib/course.js +187 -0
  285. package/studio/src/lib/exercises/journal-entry.js +259 -0
  286. package/studio/src/lib/exercises/placement.js +31 -0
  287. package/studio/src/lib/exercises/registry.js +19 -0
  288. package/studio/src/lib/exercises/spec.js +129 -0
  289. package/studio/src/lib/i18n/detect.js +162 -0
  290. package/studio/src/lib/i18n/en/app.json +23 -0
  291. package/studio/src/lib/i18n/en/betaReport.json +55 -0
  292. package/studio/src/lib/i18n/en/capstone.json +57 -0
  293. package/studio/src/lib/i18n/en/common.json +25 -0
  294. package/studio/src/lib/i18n/en/course.json +27 -0
  295. package/studio/src/lib/i18n/en/data.json +35 -0
  296. package/studio/src/lib/i18n/en/durability.json +5 -0
  297. package/studio/src/lib/i18n/en/errors.json +20 -0
  298. package/studio/src/lib/i18n/en/exercises.json +55 -0
  299. package/studio/src/lib/i18n/en/externalEvidence.json +76 -0
  300. package/studio/src/lib/i18n/en/home.json +18 -0
  301. package/studio/src/lib/i18n/en/lesson.json +33 -0
  302. package/studio/src/lib/i18n/en/nav.json +8 -0
  303. package/studio/src/lib/i18n/en/newCourse.json +51 -0
  304. package/studio/src/lib/i18n/en/onboarding.json +35 -0
  305. package/studio/src/lib/i18n/en/playwrightTemplate.json +20 -0
  306. package/studio/src/lib/i18n/en/practice.json +79 -0
  307. package/studio/src/lib/i18n/en/provider.json +27 -0
  308. package/studio/src/lib/i18n/en/providerMeta.json +26 -0
  309. package/studio/src/lib/i18n/en/reflection.json +17 -0
  310. package/studio/src/lib/i18n/en/revision.json +52 -0
  311. package/studio/src/lib/i18n/en/runnerNotice.json +14 -0
  312. package/studio/src/lib/i18n/en/settings.json +12 -0
  313. package/studio/src/lib/i18n/en/storage.json +49 -0
  314. package/studio/src/lib/i18n/en/tutor.json +39 -0
  315. package/studio/src/lib/i18n/en/workspace.json +50 -0
  316. package/studio/src/lib/i18n/index.js +144 -0
  317. package/studio/src/lib/i18n/languages.js +93 -0
  318. package/studio/src/lib/i18n/vi/app.json +23 -0
  319. package/studio/src/lib/i18n/vi/betaReport.json +55 -0
  320. package/studio/src/lib/i18n/vi/capstone.json +57 -0
  321. package/studio/src/lib/i18n/vi/common.json +25 -0
  322. package/studio/src/lib/i18n/vi/course.json +27 -0
  323. package/studio/src/lib/i18n/vi/data.json +35 -0
  324. package/studio/src/lib/i18n/vi/durability.json +5 -0
  325. package/studio/src/lib/i18n/vi/errors.json +20 -0
  326. package/studio/src/lib/i18n/vi/exercises.json +55 -0
  327. package/studio/src/lib/i18n/vi/externalEvidence.json +76 -0
  328. package/studio/src/lib/i18n/vi/home.json +18 -0
  329. package/studio/src/lib/i18n/vi/lesson.json +33 -0
  330. package/studio/src/lib/i18n/vi/nav.json +8 -0
  331. package/studio/src/lib/i18n/vi/newCourse.json +51 -0
  332. package/studio/src/lib/i18n/vi/onboarding.json +35 -0
  333. package/studio/src/lib/i18n/vi/playwrightTemplate.json +20 -0
  334. package/studio/src/lib/i18n/vi/practice.json +79 -0
  335. package/studio/src/lib/i18n/vi/provider.json +27 -0
  336. package/studio/src/lib/i18n/vi/providerMeta.json +26 -0
  337. package/studio/src/lib/i18n/vi/reflection.json +17 -0
  338. package/studio/src/lib/i18n/vi/revision.json +52 -0
  339. package/studio/src/lib/i18n/vi/runnerNotice.json +14 -0
  340. package/studio/src/lib/i18n/vi/settings.json +12 -0
  341. package/studio/src/lib/i18n/vi/storage.json +49 -0
  342. package/studio/src/lib/i18n/vi/tutor.json +39 -0
  343. package/studio/src/lib/i18n/vi/workspace.json +50 -0
  344. package/studio/src/lib/ids.js +10 -0
  345. package/studio/src/lib/json.js +26 -0
  346. package/studio/src/lib/markdown.js +74 -0
  347. package/studio/src/lib/prompts/base.js +139 -0
  348. package/studio/src/lib/prompts/capstone.js +777 -0
  349. package/studio/src/lib/prompts/course.js +150 -0
  350. package/studio/src/lib/prompts/lesson.js +275 -0
  351. package/studio/src/lib/prompts/practice.js +511 -0
  352. package/studio/src/lib/prompts/tutor.js +509 -0
  353. package/studio/src/lib/repo/blocked-adapter.js +69 -0
  354. package/studio/src/lib/repo/events.js +239 -0
  355. package/studio/src/lib/repo/idb-adapter.js +226 -0
  356. package/studio/src/lib/repo/index.js +1315 -0
  357. package/studio/src/lib/repo/memory-adapter.js +115 -0
  358. package/studio/src/lib/repo/remote-adapter.js +158 -0
  359. package/studio/src/lib/repo/schema.js +143 -0
  360. package/studio/src/lib/repo/select-adapter.js +345 -0
  361. package/studio/src/lib/router.js +71 -0
  362. package/studio/src/lib/runner/browser.js +244 -0
  363. package/studio/src/lib/runner/checks.js +248 -0
  364. package/studio/src/lib/runner/current-code.js +98 -0
  365. package/studio/src/lib/runner/esm-cjs.js +109 -0
  366. package/studio/src/lib/runner/hash.js +34 -0
  367. package/studio/src/lib/runner/history.js +48 -0
  368. package/studio/src/lib/runner/index.js +168 -0
  369. package/studio/src/lib/runner/languages.js +258 -0
  370. package/studio/src/lib/runner/local.js +139 -0
  371. package/studio/src/lib/runner/path.js +104 -0
  372. package/studio/src/lib/runner/skeleton.js +315 -0
  373. package/studio/src/lib/runner/strip-types.js +134 -0
  374. package/studio/src/lib/settings.js +399 -0
  375. package/studio/src/lib/srs.js +39 -0
  376. package/templates/agent/settings.json +6 -0
  377. package/templates/claude/plugin.json +139 -0
  378. package/templates/claude/settings.json +15 -0
  379. package/templates/cursor/professor.mdc +4 -0
  380. package/templates/cursor/settings.json +18 -0
  381. package/templates/gemini/GEMINI.md +28 -0
  382. package/templates/gemini/settings.json +5 -0
  383. package/templates/opencode/opencode.json +3 -0
  384. package/templates/researcher/README.md +61 -0
  385. package/templates/researcher/settings.json +18 -0
  386. package/web/client/components.json +15 -0
  387. package/web/client/index.html +12 -0
  388. package/web/client/package-lock.json +8732 -0
  389. package/web/client/package.json +39 -0
  390. package/web/client/postcss.config.js +6 -0
  391. package/web/client/src/App.jsx +140 -0
  392. package/web/client/src/api/client.js +357 -0
  393. package/web/client/src/components/ChatPanel.jsx +417 -0
  394. package/web/client/src/components/CommandPills.jsx +50 -0
  395. package/web/client/src/components/DeprecationBanner.jsx +21 -0
  396. package/web/client/src/components/ExerciseEditor.jsx +164 -0
  397. package/web/client/src/components/Header.jsx +119 -0
  398. package/web/client/src/components/LecturePanel.jsx +342 -0
  399. package/web/client/src/components/MobileTabSwitcher.jsx +51 -0
  400. package/web/client/src/components/SplitPane.jsx +42 -0
  401. package/web/client/src/components/ui/alert.jsx +38 -0
  402. package/web/client/src/components/ui/badge.jsx +24 -0
  403. package/web/client/src/components/ui/button.jsx +23 -0
  404. package/web/client/src/components/ui/select.jsx +74 -0
  405. package/web/client/src/hooks/useSSE.js +152 -0
  406. package/web/client/src/hooks/useWebSocket.js +98 -0
  407. package/web/client/src/index.css +23 -0
  408. package/web/client/src/lib/utils.js +6 -0
  409. package/web/client/src/main.jsx +12 -0
  410. package/web/client/src/utils/markdown.js +50 -0
  411. package/web/client/tailwind.config.js +8 -0
  412. package/web/client/vite.config.js +21 -0
  413. package/web/dist/assets/index-C1W0eXIQ.js +294 -0
  414. package/web/dist/assets/index-C3OUx70T.css +1 -0
  415. package/web/dist/index.html +13 -0
  416. package/web/lecture-archive.js +172 -0
  417. package/web/legacy-server.js +1277 -0
  418. package/web/package-lock.json +855 -0
  419. package/web/package.json +10 -0
  420. package/web/security.js +1016 -0
  421. package/web/server.js +390 -0
  422. package/web/studio-api/agents.js +580 -0
  423. package/web/studio-api/bridge.js +199 -0
  424. package/web/studio-api/db.js +66 -0
  425. package/web/studio-api/guards.js +201 -0
  426. package/web/studio-api/health.js +538 -0
  427. package/web/studio-api.js +214 -0
  428. package/web/studio-db.js +380 -0
  429. package/web/studio-runner.js +568 -0
@@ -0,0 +1,611 @@
1
+ /**
2
+ * Course reader — pure parsers for course files on disk.
3
+ *
4
+ * Reads `learning/{slug}/` (primary) and `courses/{slug}/` (legacy). Every
5
+ * function here is side-effect free apart from reading files, so Phase 31
6
+ * (`studio`, `review`, `import`) can reuse the same shapes without going
7
+ * through the CLI.
8
+ */
9
+ import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
10
+ import { basename, isAbsolute, join } from 'path';
11
+
12
+ // ─── Constants ────────────────────────────────────────────────────────────────
13
+
14
+ export const COURSE_KINDS = ['programming', 'quantitative', 'conceptual', 'skill'];
15
+ export const DEFAULT_KIND = 'programming';
16
+
17
+ const STATUS_BY_EMOJI = {
18
+ '⬜': 'todo',
19
+ '🔄': 'active',
20
+ '✅': 'done',
21
+ '🔒': 'locked',
22
+ };
23
+
24
+ const SECTION_EMOJI_RE = /[⬜🔄✅🔒]/;
25
+ const MONTHS = [
26
+ 'january', 'february', 'march', 'april', 'may', 'june',
27
+ 'july', 'august', 'september', 'october', 'november', 'december',
28
+ ];
29
+
30
+ // ─── Date helpers ─────────────────────────────────────────────────────────────
31
+
32
+ function pad2(n) {
33
+ return String(n).padStart(2, '0');
34
+ }
35
+
36
+ /**
37
+ * Normalize a human date ("March 15, 2026", "2026-03-15", "15/03/2026") to ISO.
38
+ * @param {string} value
39
+ * @returns {string|null} YYYY-MM-DD or null
40
+ */
41
+ export function normalizeDate(value) {
42
+ if (!value) return null;
43
+ const text = String(value).trim();
44
+ if (!text || text === '—' || text === '-') return null;
45
+
46
+ let m = text.match(/(\d{4})-(\d{2})-(\d{2})/);
47
+ if (m) return `${m[1]}-${m[2]}-${m[3]}`;
48
+
49
+ m = text.match(/(\d{4})\/(\d{1,2})\/(\d{1,2})/);
50
+ if (m) return `${m[1]}-${pad2(m[2])}-${pad2(m[3])}`;
51
+
52
+ m = text.match(/([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4})/);
53
+ if (m) {
54
+ const month = MONTHS.indexOf(m[1].toLowerCase());
55
+ if (month !== -1) return `${m[3]}-${pad2(month + 1)}-${pad2(m[2])}`;
56
+ }
57
+
58
+ m = text.match(/(\d{1,2})\s+([A-Za-z]+)\s+(\d{4})/);
59
+ if (m) {
60
+ const month = MONTHS.indexOf(m[2].toLowerCase());
61
+ if (month !== -1) return `${m[3]}-${pad2(month + 1)}-${pad2(m[1])}`;
62
+ }
63
+
64
+ return null;
65
+ }
66
+
67
+ function toDayNumber(iso) {
68
+ const [y, m, d] = iso.split('-').map(Number);
69
+ return Math.floor(Date.UTC(y, m - 1, d) / 86400000);
70
+ }
71
+
72
+ function fromDayNumber(n) {
73
+ const date = new Date(n * 86400000);
74
+ return `${date.getUTCFullYear()}-${pad2(date.getUTCMonth() + 1)}-${pad2(date.getUTCDate())}`;
75
+ }
76
+
77
+ /** Today's local date as YYYY-MM-DD. */
78
+ export function todayISO(now = new Date()) {
79
+ return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}`;
80
+ }
81
+
82
+ /**
83
+ * Extract every distinctive date from a blob of Markdown.
84
+ * @param {string} text
85
+ * @returns {string[]} unique ISO dates
86
+ */
87
+ export function extractDates(text) {
88
+ if (!text) return [];
89
+ const found = new Set();
90
+
91
+ for (const m of text.matchAll(/\d{4}-\d{2}-\d{2}/g)) {
92
+ const iso = normalizeDate(m[0]);
93
+ if (iso) found.add(iso);
94
+ }
95
+
96
+ const monthRe = new RegExp(
97
+ `(${MONTHS.join('|')})\\s+\\d{1,2},?\\s+\\d{4}`,
98
+ 'gi'
99
+ );
100
+ for (const m of text.matchAll(monthRe)) {
101
+ const iso = normalizeDate(m[0]);
102
+ if (iso) found.add(iso);
103
+ }
104
+
105
+ return [...found];
106
+ }
107
+
108
+ /**
109
+ * Consecutive days of activity ending today or yesterday.
110
+ * @param {string[]} dates ISO dates
111
+ * @param {string} [today] ISO date
112
+ * @returns {number}
113
+ */
114
+ export function computeStreak(dates, today = todayISO()) {
115
+ const set = new Set(dates);
116
+ if (set.size === 0) return 0;
117
+
118
+ const todayNum = toDayNumber(today);
119
+ let cursor;
120
+ if (set.has(fromDayNumber(todayNum))) cursor = todayNum;
121
+ else if (set.has(fromDayNumber(todayNum - 1))) cursor = todayNum - 1;
122
+ else return 0;
123
+
124
+ let streak = 0;
125
+ while (set.has(fromDayNumber(cursor))) {
126
+ streak += 1;
127
+ cursor -= 1;
128
+ }
129
+ return streak;
130
+ }
131
+
132
+ // ─── Markdown helpers ─────────────────────────────────────────────────────────
133
+
134
+ function stripMarkdown(text) {
135
+ return String(text)
136
+ .replace(/\*\*?([^*]+)\*\*?/g, '$1')
137
+ .replace(/`([^`]+)`/g, '$1')
138
+ .replace(/[⬜🔄✅🔒🏗️]/g, '')
139
+ .trim();
140
+ }
141
+
142
+ function isSeparatorRow(cells) {
143
+ return cells.every((c) => /^:?-{2,}:?$/.test(c) || c === '');
144
+ }
145
+
146
+ function splitTableRow(line) {
147
+ return line.replace(/^\s*\|/, '').replace(/\|\s*$/, '').split('|').map((c) => c.trim());
148
+ }
149
+
150
+ /** Slice the body of the first `## <heading>` matching the pattern. */
151
+ function sliceSection(content, headingRe) {
152
+ const lines = content.split('\n');
153
+ let start = -1;
154
+ for (let i = 0; i < lines.length; i++) {
155
+ if (/^##\s+/.test(lines[i]) && headingRe.test(lines[i])) { start = i + 1; break; }
156
+ }
157
+ if (start === -1) return null;
158
+ let end = lines.length;
159
+ for (let i = start; i < lines.length; i++) {
160
+ if (/^##\s+/.test(lines[i])) { end = i; break; }
161
+ }
162
+ return lines.slice(start, end).join('\n');
163
+ }
164
+
165
+ function metaValue(content, label) {
166
+ const re = new RegExp(`^\\s*[-*]?\\s*\\*\\*${label}\\*\\*\\s*:?\\s*(.*?)\\s*$`, 'mi');
167
+ const m = content.match(re);
168
+ return m ? m[1].trim() : null;
169
+ }
170
+
171
+ // ─── COURSE.md ────────────────────────────────────────────────────────────────
172
+
173
+ function statusFromCell(cell) {
174
+ for (const emoji of Object.keys(STATUS_BY_EMOJI)) {
175
+ if (cell.includes(emoji)) return STATUS_BY_EMOJI[emoji];
176
+ }
177
+ return null;
178
+ }
179
+
180
+ function parseTitle(content, slug) {
181
+ const named = content.match(/^#\s*(?:[^\w\n]*)?Course\s*:\s*(.+?)\s*$/mi);
182
+ if (named) return named[1].trim();
183
+ const plain = content.match(/^#\s+(.+?)\s*$/m);
184
+ return plain ? stripMarkdown(plain[1]) : slug;
185
+ }
186
+
187
+ function parseTableSections(region) {
188
+ const sections = [];
189
+ let capstoneStatus = null;
190
+ const lines = region.split('\n');
191
+
192
+ for (const line of lines) {
193
+ if (!/^\s*\|.*\|\s*$/.test(line)) continue;
194
+ const cells = splitTableRow(line);
195
+ if (isSeparatorRow(cells)) continue;
196
+ if (!cells.some((c) => SECTION_EMOJI_RE.test(c))) continue;
197
+
198
+ const statusCell = cells.find((c) => SECTION_EMOJI_RE.test(c));
199
+ const status = statusFromCell(statusCell) || 'todo';
200
+ const isCapstone = cells.some((c) => /capstone/i.test(c));
201
+
202
+ if (isCapstone) { capstoneStatus = status; continue; }
203
+
204
+ const n = cells.find((c) => /^\d+(\.\d+)*$/.test(c)) || null;
205
+ const dateCell = cells.find((c) => normalizeDate(c));
206
+ const candidates = cells.filter((c) =>
207
+ c !== statusCell && c !== n && c !== dateCell &&
208
+ c !== '' && c !== '—' && !normalizeDate(c) && !/^\d+(\.\d+)*$/.test(c)
209
+ );
210
+ const titleCell = candidates.sort((a, b) => b.length - a.length)[0] || '';
211
+ const title = stripMarkdown(titleCell);
212
+ if (!title) continue;
213
+
214
+ sections.push({ n, title, status, completedAt: dateCell ? normalizeDate(dateCell) : null });
215
+ }
216
+ return { sections, capstoneStatus };
217
+ }
218
+
219
+ function parseListSections(region) {
220
+ const sections = [];
221
+ let capstoneStatus = null;
222
+ const lines = region.split('\n');
223
+
224
+ for (const line of lines) {
225
+ const m = line.match(
226
+ /^\s*(?:[-*+]\s*)?(⬜|🔄|✅|🔒)\s*(?:Section\s+)?(\d+(?:\.\d+)*)?\s*[.):\-—]?\s*(.+?)\s*$/
227
+ );
228
+ if (!m) continue;
229
+ const [, emoji, number, rawTitle] = m;
230
+ const title = stripMarkdown(rawTitle);
231
+ if (!title) continue;
232
+ if (/capstone/i.test(title)) { capstoneStatus = STATUS_BY_EMOJI[emoji]; continue; }
233
+ const n = number || String(sections.length + 1);
234
+ sections.push({ n, title, status: STATUS_BY_EMOJI[emoji], completedAt: null });
235
+ }
236
+ return { sections, capstoneStatus };
237
+ }
238
+
239
+ /**
240
+ * Parse a COURSE.md syllabus in any of its flavours:
241
+ * - `⬜ 1. Title`
242
+ * - `- ⬜ Section 1: Title`
243
+ * - `| # | **Title** | 🔄 In progress |`
244
+ * @param {string} content
245
+ * @returns {{ sections: object[], capstoneStatus: string|null }}
246
+ */
247
+ export function parseSections(content) {
248
+ if (!content) return { sections: [], capstoneStatus: null };
249
+ const region = sliceSection(content, /syllabus|sections/i) || content;
250
+ const table = parseTableSections(region);
251
+ if (table.sections.length > 0) return table;
252
+ return parseListSections(region);
253
+ }
254
+
255
+ function parseCapstoneStatus(content, rowStatus) {
256
+ const raw = metaValue(content, 'Capstone status');
257
+ if (raw) {
258
+ const lower = raw.toLowerCase();
259
+ if (lower.includes('locked') || raw.includes('🔒')) return 'locked';
260
+ if (lower.includes('complete') || raw.includes('✅')) return 'done';
261
+ if (lower.includes('progress') || raw.includes('🔄')) return 'active';
262
+ }
263
+ return rowStatus || 'none';
264
+ }
265
+
266
+ // ─── LECTURE.md ───────────────────────────────────────────────────────────────
267
+
268
+ function sectionBody(content, headingRe) {
269
+ const lines = content.split('\n');
270
+ let start = -1;
271
+ for (let i = 0; i < lines.length; i++) {
272
+ if (/^##\s+/.test(lines[i]) && headingRe.test(lines[i])) { start = i + 1; break; }
273
+ }
274
+ if (start === -1) return null;
275
+ let end = lines.length;
276
+ for (let i = start; i < lines.length; i++) {
277
+ if (/^##\s+/.test(lines[i]) || /^---\s*$/.test(lines[i])) { end = i; break; }
278
+ }
279
+ return lines.slice(start, end).join('\n');
280
+ }
281
+
282
+ function firstParagraph(body) {
283
+ if (!body) return null;
284
+ const paragraph = [];
285
+ for (const raw of body.split('\n')) {
286
+ const line = raw.trim();
287
+ if (!line) { if (paragraph.length) break; else continue; }
288
+ paragraph.push(line);
289
+ }
290
+ return paragraph.length ? paragraph.join(' ') : null;
291
+ }
292
+
293
+ const EXERCISE_PATH_RE = /exercises\/[A-Za-z0-9._-]+\.[A-Za-z0-9]+/;
294
+
295
+ /** Find the first `exercises/<file>.<ext>` path in a chunk of Markdown. */
296
+ function findExercisePath(text) {
297
+ if (!text) return null;
298
+ const m = text.match(EXERCISE_PATH_RE);
299
+ return m ? m[0] : null;
300
+ }
301
+
302
+ /**
303
+ * Parse the active LECTURE.md.
304
+ * @param {string} content
305
+ * @returns {object}
306
+ */
307
+ export function parseLecture(content) {
308
+ if (!content) return null;
309
+ const heading =
310
+ content.match(/^#\s*(?:📖\s*)?Section\s+([\d.]+)\s*[:\-—]\s*(.+?)\s*$/mi) ||
311
+ content.match(/^#\s+(.+?)\s*$/m);
312
+ const sectionNumber = heading && heading.length === 3 ? heading[1] : null;
313
+ const title = heading ? stripMarkdown(heading[heading.length - 1]) : null;
314
+
315
+ const objectivesBody = sectionBody(content, /objectives/i);
316
+ const objectives = objectivesBody
317
+ ? objectivesBody.split('\n')
318
+ .map((l) => l.match(/^\s*[-*]\s+(.+?)\s*$/))
319
+ .filter(Boolean)
320
+ .map((m) => stripMarkdown(m[1]))
321
+ : [];
322
+
323
+ const explanation = firstParagraph(sectionBody(content, /explanation/i));
324
+
325
+ const exerciseBody = sectionBody(content, /exercise/i);
326
+ let successCriteria = [];
327
+ let exerciseTask = null;
328
+ if (exerciseBody) {
329
+ successCriteria = exerciseBody.split('\n')
330
+ .map((l) => l.match(/^\s*(?:>\s*)?[-*]\s*\[[ xX]\]\s*(.+?)\s*$/))
331
+ .filter(Boolean)
332
+ .map((m) => stripMarkdown(m[1]));
333
+ const quote = exerciseBody.split('\n')
334
+ .find((l) => /^\s*>\s+\S/.test(l) && !/success criteria/i.test(l));
335
+ exerciseTask = quote ? stripMarkdown(quote.replace(/^\s*>\s*/, '')) : null;
336
+ }
337
+
338
+ const exercisePath = findExercisePath(exerciseBody) || findExercisePath(content);
339
+
340
+ return {
341
+ sectionNumber, title, objectives, explanation, successCriteria, exerciseTask, exercisePath,
342
+ };
343
+ }
344
+
345
+ // ─── LEARNING-LOG.md ──────────────────────────────────────────────────────────
346
+
347
+ function parseSectionEntries(region) {
348
+ const entries = [];
349
+ const blocks = region.split(/^###\s+/m).slice(1);
350
+ for (const block of blocks) {
351
+ const lines = block.split('\n');
352
+ const section = stripMarkdown(lines[0]);
353
+ const dateLine = block.match(/^\s*[-*]\s*Date\s*:\s*(.+?)\s*$/mi);
354
+ const verdictLine = block.match(/^\s*[-*]\s*Verdict\s*:\s*(.+?)\s*$/mi);
355
+ entries.push({
356
+ date: dateLine ? normalizeDate(dateLine[1]) : null,
357
+ section,
358
+ verdict: verdictLine ? verdictLine[1].trim() : null,
359
+ });
360
+ }
361
+ return entries;
362
+ }
363
+
364
+ /**
365
+ * Parse LEARNING-LOG.md Section Entries.
366
+ * @param {string} content
367
+ * @returns {{ date: string|null, section: string, verdict: string|null }[]}
368
+ */
369
+ export function parseLearningLog(content) {
370
+ if (!content) return [];
371
+ const region = sliceSection(content, /section entries/i);
372
+ if (!region) return [];
373
+ return parseSectionEntries(region);
374
+ }
375
+
376
+ // ─── SCHEDULE.md ──────────────────────────────────────────────────────────────
377
+
378
+ /**
379
+ * Parse SCHEDULE.md flashcards into `{ front, due }` pairs.
380
+ * @param {string} content
381
+ * @returns {{ front: string, due: string|null }[]}
382
+ */
383
+ export function parseSchedule(content) {
384
+ if (!content) return [];
385
+ const region = sliceSection(content, /flashcard/i) || content;
386
+ const lines = region.split('\n');
387
+
388
+ let header = null;
389
+ const cards = [];
390
+ for (const line of lines) {
391
+ if (!/^\s*\|.*\|\s*$/.test(line)) continue;
392
+ const cells = splitTableRow(line);
393
+ if (isSeparatorRow(cells)) continue;
394
+
395
+ if (!header) {
396
+ const frontIdx = cells.findIndex((c) => /question|front/i.test(c));
397
+ const dueIdx = cells.findIndex((c) => /next review|due/i.test(c));
398
+ if (frontIdx !== -1 && dueIdx !== -1) header = { frontIdx, dueIdx };
399
+ continue;
400
+ }
401
+
402
+ const front = stripMarkdown(cells[header.frontIdx] || '');
403
+ if (!front) continue;
404
+ cards.push({ front, due: normalizeDate(cells[header.dueIdx]) });
405
+ }
406
+ return cards;
407
+ }
408
+
409
+ // ─── Exercise resolution ──────────────────────────────────────────────────────
410
+
411
+ const EXERCISE_EXT_BY_KIND = {
412
+ programming: 'js', quantitative: 'md', conceptual: 'md', skill: 'md',
413
+ };
414
+
415
+ /** Lowercase + hyphenate a section title into an ASCII-ish file slug. */
416
+ export function slugify(text) {
417
+ return String(text || '')
418
+ .toLowerCase()
419
+ .replace(/[^a-z0-9]+/g, '-')
420
+ .replace(/^-+|-+$/g, '');
421
+ }
422
+
423
+ /** Synthetic exercise path for the current section (`exercises/NN-slug.ext`). */
424
+ function deriveExercisePath(course) {
425
+ if (!course.currentSection) return null;
426
+ const n = String(course.currentSection.n).padStart(2, '0');
427
+ const slug = slugify(course.currentSection.title);
428
+ const ext = EXERCISE_EXT_BY_KIND[course.kind] || 'md';
429
+ return `exercises/${n}-${slug}.${ext}`;
430
+ }
431
+
432
+ /** Newest `exercises/NN-*` file for the current section, if one exists on disk. */
433
+ function newestSectionExercise(course) {
434
+ const exercisesDir = join(course.dir, 'exercises');
435
+ if (!existsSync(exercisesDir)) return null;
436
+ let files;
437
+ try {
438
+ files = readdirSync(exercisesDir).filter((f) => !f.startsWith('.'));
439
+ } catch { return null; }
440
+
441
+ if (!files.length) return null;
442
+ if (course.currentSection?.n) {
443
+ const prefix = String(course.currentSection.n).padStart(2, '0');
444
+ const matching = files.filter((f) => f.startsWith(`${prefix}-`));
445
+ if (matching.length) files = matching;
446
+ }
447
+
448
+ const latest = files.map((f) => {
449
+ try { return { f, m: statSync(join(exercisesDir, f)).mtimeMs }; } catch { return null; }
450
+ }).filter(Boolean).sort((a, b) => b.m - a.m)[0];
451
+
452
+ return latest ? `exercises/${latest.f}` : null;
453
+ }
454
+
455
+ /**
456
+ * Resolve one exercise path for a course. Shared by `next` and `check` so both
457
+ * always agree. Order:
458
+ * 1. the COURSE.md `**Active exercise**` field
459
+ * 2. an `exercises/<file>` path written in LECTURE.md
460
+ * 3. the newest `exercises/NN-*` file matching the current section number
461
+ * 4. a synthetic `exercises/NN-slug.ext` path (not yet on disk)
462
+ * @param {object} course readCourse output
463
+ * @param {{ lecture?: object|null }} [opts]
464
+ * @returns {{ path: string|null, source: string|null, exists: boolean }}
465
+ */
466
+ export function resolveExercise(course, { lecture = null } = {}) {
467
+ const declared = [];
468
+ if (course.activeExercise) declared.push({ path: course.activeExercise, source: 'course' });
469
+ if (lecture?.exercisePath) declared.push({ path: lecture.exercisePath, source: 'lecture' });
470
+
471
+ for (const candidate of declared) {
472
+ if (existsSync(join(course.dir, candidate.path))) {
473
+ return { ...candidate, exists: true };
474
+ }
475
+ }
476
+
477
+ const matching = newestSectionExercise(course);
478
+ if (matching) return { path: matching, source: 'matching', exists: true };
479
+
480
+ if (declared.length) return { ...declared[0], exists: false };
481
+
482
+ const derived = deriveExercisePath(course);
483
+ if (derived) return { path: derived, source: 'derived', exists: false };
484
+ return { path: null, source: null, exists: false };
485
+ }
486
+
487
+ // ─── Course discovery ─────────────────────────────────────────────────────────
488
+
489
+ /**
490
+ * Find every course directory on disk.
491
+ * Scans `learning/*​/` first, then legacy `courses/*​/` (dedup by slug).
492
+ * @param {string} cwd
493
+ * @param {{ dir?: string }} [opts] `dir` overrides the roots (single course or parent)
494
+ * @returns {{ slug: string, dir: string, location: 'learning'|'courses'|'custom' }[]}
495
+ */
496
+ export function findCourses(cwd, { dir } = {}) {
497
+ if (dir) {
498
+ const abs = isAbsolute(dir) ? dir : join(cwd, dir);
499
+ if (existsSync(join(abs, 'COURSE.md'))) {
500
+ return [{ slug: basename(abs), dir: abs, location: 'custom' }];
501
+ }
502
+ return scanRoot(abs, 'custom');
503
+ }
504
+ const results = [];
505
+ const seen = new Set();
506
+ for (const [name, location] of [['learning', 'learning'], ['courses', 'courses']]) {
507
+ for (const course of scanRoot(join(cwd, name), location)) {
508
+ if (seen.has(course.slug)) continue;
509
+ seen.add(course.slug);
510
+ results.push(course);
511
+ }
512
+ }
513
+ return results;
514
+ }
515
+
516
+ function scanRoot(root, location) {
517
+ if (!existsSync(root)) return [];
518
+ const found = [];
519
+ let entries;
520
+ try { entries = readdirSync(root); } catch { return []; }
521
+ for (const name of entries.sort()) {
522
+ const dir = join(root, name);
523
+ try {
524
+ if (!statSync(dir).isDirectory()) continue;
525
+ if (!existsSync(join(dir, 'COURSE.md'))) continue;
526
+ } catch { continue; }
527
+ found.push({ slug: name, dir, location });
528
+ }
529
+ return found;
530
+ }
531
+
532
+ // ─── readCourse ───────────────────────────────────────────────────────────────
533
+
534
+ /**
535
+ * Read and parse a single course directory.
536
+ * @param {string} dir
537
+ * @param {{ slug?: string, today?: string }} [opts]
538
+ * @returns {object}
539
+ */
540
+ export function readCourse(dir, { slug = basename(dir), today = todayISO() } = {}) {
541
+ const coursePath = join(dir, 'COURSE.md');
542
+ if (!existsSync(coursePath)) {
543
+ throw new Error(`No COURSE.md in ${dir}`);
544
+ }
545
+ const content = readFileSync(coursePath, 'utf-8');
546
+
547
+ const { sections, capstoneStatus: rowCapstone } = parseSections(content);
548
+ const kindRaw = (metaValue(content, 'Kind') || '').toLowerCase().trim();
549
+ const kind = kindRaw || DEFAULT_KIND;
550
+
551
+ const progressRegion = sliceSection(content, /progress log/i);
552
+ const progressDates = extractDates(progressRegion || '');
553
+
554
+ const logPath = join(dir, 'LEARNING-LOG.md');
555
+ const logText = existsSync(logPath) ? readFileSync(logPath, 'utf-8') : '';
556
+ const log = parseLearningLog(logText);
557
+
558
+ const schedulePath = join(dir, 'SCHEDULE.md');
559
+ const scheduleText = existsSync(schedulePath) ? readFileSync(schedulePath, 'utf-8') : '';
560
+ const cards = parseSchedule(scheduleText);
561
+
562
+ const lecturesDir = join(dir, 'lectures');
563
+ let lectures = [];
564
+ if (existsSync(lecturesDir)) {
565
+ try {
566
+ lectures = readdirSync(lecturesDir).filter((f) => f.endsWith('.md')).sort();
567
+ } catch { lectures = []; }
568
+ }
569
+
570
+ const activeExerciseRaw = metaValue(content, 'Active exercise');
571
+ const activeExercise = activeExerciseRaw && activeExerciseRaw !== '—' && activeExerciseRaw !== '-'
572
+ ? activeExerciseRaw : null;
573
+
574
+ const done = sections.filter((s) => s.status === 'done').length;
575
+ const current = sections.find((s) => s.status === 'active')
576
+ || sections.find((s) => s.status === 'todo')
577
+ || null;
578
+
579
+ const activityDates = [...new Set([
580
+ ...progressDates,
581
+ ...extractDates(logText),
582
+ ...log.map((e) => e.date).filter(Boolean),
583
+ ])];
584
+
585
+ const lastActive = normalizeDate(metaValue(content, 'Last active'))
586
+ || [...activityDates].sort().pop()
587
+ || null;
588
+
589
+ return {
590
+ slug,
591
+ dir,
592
+ title: parseTitle(content, slug),
593
+ level: metaValue(content, 'Level') || null,
594
+ kind,
595
+ sections: sections.map((s) => ({ ...s, status: s.status === 'locked' ? 'todo' : s.status })),
596
+ activeExercise,
597
+ lastActive,
598
+ capstoneStatus: parseCapstoneStatus(content, rowCapstone),
599
+ lectures,
600
+ log,
601
+ cards,
602
+ streak: computeStreak(activityDates, today),
603
+ activityDates,
604
+ progress: {
605
+ done,
606
+ total: sections.length,
607
+ percent: sections.length ? Math.round((done / sections.length) * 100) : 0,
608
+ },
609
+ currentSection: current ? { n: current.n, title: current.title, status: current.status } : null,
610
+ };
611
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * node-version — the single source of truth for the Node.js floor required by Professor Studio.
3
+ *
4
+ * Studio's SQLite storage layer (`web/studio-db.js`) uses the built-in `node:sqlite` module, which
5
+ * ships from Node 22.5.0. The setup/registry commands and `doctor` only need Node 18 (see
6
+ * `package.json` `engines`), so the stricter Studio floor is checked at the point of use — the
7
+ * `studio`, `review` and `import` commands — and reported by `doctor`.
8
+ */
9
+
10
+ export const STUDIO_MIN_NODE = { major: 22, minor: 5 };
11
+
12
+ /**
13
+ * Parse a `process.version`-style string into `{ major, minor }`.
14
+ * @param {string} version e.g. "v22.5.0"
15
+ * @returns {{ major: number, minor: number }|null}
16
+ */
17
+ export function parseNodeVersion(version) {
18
+ const match = String(version || '').replace(/^v/, '').match(/^(\d+)\.(\d+)/);
19
+ if (!match) return null;
20
+ return { major: Number(match[1]), minor: Number(match[2]) };
21
+ }
22
+
23
+ /**
24
+ * Whether `version` is >= the Studio floor (Node 22.5.0) and can use `node:sqlite`.
25
+ * @param {string} [version]
26
+ * @returns {boolean}
27
+ */
28
+ export function nodeSupportsSqlite(version = process.version) {
29
+ const parsed = parseNodeVersion(version);
30
+ if (!parsed) return false;
31
+ const { major, minor } = STUDIO_MIN_NODE;
32
+ return parsed.major > major || (parsed.major === major && parsed.minor >= minor);
33
+ }
34
+
35
+ /**
36
+ * The message shown when the Node version is too old for Studio.
37
+ * @param {string} [version]
38
+ * @returns {string}
39
+ */
40
+ export function studioNodeMessage(version = process.version) {
41
+ return `Professor Studio needs Node 22.5+ (you have ${version}). Install from https://nodejs.org`;
42
+ }
43
+
44
+ /**
45
+ * Throw when the running Node cannot use `node:sqlite`. Pure — callers decide how to surface it.
46
+ * @param {string} [version]
47
+ */
48
+ export function assertStudioNode(version = process.version) {
49
+ if (!nodeSupportsSqlite(version)) throw new Error(studioNodeMessage(version));
50
+ }
51
+
52
+ /**
53
+ * Guard for CLI command entry points: print a one-line error and exit 1 when Node is too old.
54
+ * @param {string} [version]
55
+ */
56
+ export function requireStudioNode(version = process.version) {
57
+ if (nodeSupportsSqlite(version)) return;
58
+ console.error(studioNodeMessage(version));
59
+ process.exit(1);
60
+ }