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,150 @@
1
+ /**
2
+ * Syllabus prompt + validator (COURSE-01, COURSE-02, COURSE-05).
3
+ *
4
+ * The model is asked to return JSON only; `validateSyllabus` is the schema gate used both by the
5
+ * provider's repair retry (via `generateJson`) and by the NewCourse page before saving. Small
6
+ * local models fence/invent JSON (Pitfall 5), so validation is tolerant: unknown/missing `kind`
7
+ * falls back to `conceptual` rather than failing the whole proposal.
8
+ */
9
+ import { COURSE_KIND_IDS } from '../course.js';
10
+ import { withLanguage, languageHeadline, appendLanguageInstruction } from './base.js';
11
+
12
+ export const MIN_LESSONS = 4;
13
+ export const MAX_LESSONS = 10;
14
+
15
+ export const SYLLABUS_SHAPE = `{
16
+ "title": "string",
17
+ "description": "one or two sentences",
18
+ "kind": "programming | quantitative | conceptual | skill",
19
+ "kindReason": "one short sentence explaining the kind",
20
+ "artifact": {
21
+ "title": "string",
22
+ "deliverable": "one sentence naming the ONE concrete thing the learner will ship",
23
+ "definitionOfDone": ["3 to 6 checkable finished-state bullets"]
24
+ },
25
+ "lessons": [
26
+ { "title": "string", "summary": "one line describing what this lesson teaches" }
27
+ ]
28
+ }`;
29
+
30
+ const RULES = `You design course syllabi for a Socratic learning app.
31
+ Return ONLY a single JSON object — no prose, no Markdown fences, no trailing commentary.
32
+ The JSON must match exactly this shape:
33
+ ${SYLLABUS_SHAPE}
34
+
35
+ Hard rules:
36
+ - Between ${MIN_LESSONS} and ${MAX_LESSONS} lessons, ordered as a learning path (prerequisites first).
37
+ - Every "title" is short (2–6 words); every "summary" is one clear line.
38
+ - Choose exactly one "kind" from: programming, quantitative, conceptual, skill.
39
+ * programming — the learner writes and runs code.
40
+ * quantitative — math, statistics or data the learner computes.
41
+ * conceptual — ideas, theory and mental models.
42
+ * skill — a practical ability practised in repeated drills.
43
+ - "kindReason" is one short sentence referring to the topic (e.g. "Detected: Conceptual — a history topic").
44
+ - "artifact" names the ONE real, shippable deliverable the course builds toward (not an exam). Make it
45
+ concrete and portfolio-ready, e.g. a deployed mini-app + repo (programming), a 1,500-word analysis
46
+ memo with sources (conceptual), a data notebook + report on a public dataset (quantitative), or a
47
+ recorded performance (skill). "definitionOfDone" is 3–6 bullets describing the finished state —
48
+ each one checkable ("repo has a README and a working demo link", not "understand the topic").`;
49
+
50
+ /**
51
+ * Tolerant normalisation of the syllabus `artifact` block. Missing/blank fields degrade gracefully
52
+ * so a small model returning a partial object never fails the whole proposal.
53
+ * @param {any} obj
54
+ * @returns {{ title: string, deliverable: string, definitionOfDone: string[] }}
55
+ */
56
+ export function normalizeArtifact(obj) {
57
+ const source = obj && typeof obj === 'object' && !Array.isArray(obj) ? obj : {};
58
+ const definitionOfDone = (Array.isArray(source.definitionOfDone) ? source.definitionOfDone : [])
59
+ .map((item) => (typeof item === 'string' ? item.trim() : item && typeof item.title === 'string' ? item.title.trim() : ''))
60
+ .filter(Boolean);
61
+ return {
62
+ title: typeof source.title === 'string' ? source.title.trim() : '',
63
+ deliverable: typeof source.deliverable === 'string' ? source.deliverable.trim() : '',
64
+ definitionOfDone,
65
+ };
66
+ }
67
+
68
+ /**
69
+ * Build the system + messages for the syllabus generation call.
70
+ * @param {{ topic: string, level?: string, goal?: string, language?: string, existingLessons?: string[] }} input
71
+ * @returns {{ system: string, messages: { role: string, content: string }[] }}
72
+ */
73
+ export function buildSyllabusMessages({ topic, level = 'Beginner', goal = '', language, existingLessons = [] } = {}) {
74
+ const lines = [
75
+ `Create a course syllabus for the following request.`,
76
+ ``,
77
+ `Topic: ${String(topic || '').trim() || '(unspecified)'}`,
78
+ `Level: ${level}`,
79
+ ];
80
+ if (goal) lines.push(`Learner goal: ${String(goal).trim()}`);
81
+ if (Array.isArray(existingLessons) && existingLessons.length) {
82
+ lines.push(
83
+ `The learner already suggested these lessons — keep the same spirit and fill gaps rather than starting over:`,
84
+ ...existingLessons.map((l) => `- ${l}`)
85
+ );
86
+ }
87
+ lines.push('', 'Return only the JSON object.');
88
+
89
+ const head = languageHeadline(language);
90
+ const body = withLanguage(RULES, language);
91
+ return {
92
+ system: head ? `${head}\n\n${body}` : body,
93
+ messages: appendLanguageInstruction([{ role: 'user', content: lines.join('\n') }], language),
94
+ };
95
+ }
96
+
97
+ /**
98
+ * Validate and normalise a proposed syllabus. Tolerant by design: a missing or unrecognised
99
+ * `kind` becomes `conceptual`, string lessons are accepted, blank lessons are dropped.
100
+ * @param {any} obj
101
+ * @returns {{ ok: true, value: object } | { ok: false, error: string }}
102
+ */
103
+ export function validateSyllabus(obj) {
104
+ if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
105
+ return { ok: false, error: 'Syllabus must be a JSON object' };
106
+ }
107
+ const title = typeof obj.title === 'string' ? obj.title.trim() : '';
108
+ if (!title) return { ok: false, error: 'Syllabus is missing a title' };
109
+
110
+ if (!Array.isArray(obj.lessons)) return { ok: false, error: 'Syllabus is missing a lessons array' };
111
+
112
+ const lessons = [];
113
+ for (const raw of obj.lessons) {
114
+ const lesson = typeof raw === 'string' ? { title: raw } : raw;
115
+ if (!lesson || typeof lesson !== 'object') continue;
116
+ const lessonTitle = typeof lesson.title === 'string' ? lesson.title.trim() : '';
117
+ if (!lessonTitle) continue;
118
+ lessons.push({
119
+ title: lessonTitle,
120
+ summary: typeof lesson.summary === 'string' ? lesson.summary.trim() : '',
121
+ });
122
+ }
123
+
124
+ if (lessons.length < MIN_LESSONS || lessons.length > MAX_LESSONS) {
125
+ return { ok: false, error: `Expected ${MIN_LESSONS}–${MAX_LESSONS} lessons, got ${lessons.length}` };
126
+ }
127
+
128
+ const kind = COURSE_KIND_IDS.includes(obj.kind) ? obj.kind : 'conceptual';
129
+ return {
130
+ ok: true,
131
+ value: {
132
+ title,
133
+ description: typeof obj.description === 'string' ? obj.description.trim() : '',
134
+ kind,
135
+ kindReason: typeof obj.kindReason === 'string' ? obj.kindReason.trim() : '',
136
+ artifact: normalizeArtifact(obj.artifact),
137
+ lessons,
138
+ },
139
+ };
140
+ }
141
+
142
+ /**
143
+ * A `validate` callback for `generateJson` that throws a readable message on failure.
144
+ * @param {any} obj
145
+ * @returns {true | string}
146
+ */
147
+ export function syllabusValidator(obj) {
148
+ const result = validateSyllabus(obj);
149
+ return result.ok ? true : result.error;
150
+ }
@@ -0,0 +1,275 @@
1
+ /**
2
+ * Lesson prompt builder (LESSON-01, LESSON-02, LESSON-05).
3
+ *
4
+ * A lesson is the shared learning core (in a fixed order) plus exactly ONE kind-specific block
5
+ * placed after the worked example. The kind comes from the course (COURSE-05); see
6
+ * `professor-skill/SKILL.md` § "LECTURE.md Format" for the canonical shape this mirrors.
7
+ *
8
+ * The builder returns a provider-ready `{ system, messages }`: `system` = persona + delimited
9
+ * course context + the full outline (so every heading and rule is in one auditable string),
10
+ * `messages` = the single user turn.
11
+ */
12
+ import {
13
+ LEARNING_CORE_SECTIONS,
14
+ buildSystemPrompt,
15
+ courseContext,
16
+ appendLanguageInstruction,
17
+ languageStrictInstruction,
18
+ } from './base.js';
19
+ import { languageName } from '../i18n/languages.js';
20
+
21
+ /**
22
+ * Localised learning-core headings + labels, keyed by a STABLE internal section id.
23
+ *
24
+ * Code must never match on the heading text (a Vietnamese course emits Vietnamese headings);
25
+ * `LEARNING_CORE_SECTIONS[].id` is the stable key and these tables map it to display text. Add a
26
+ * language here and both the lesson prompt and the exercise-skeleton finder follow automatically.
27
+ * @type {Record<string, { sections: Record<string,string>, misconception: string, reality: string, kindTitles: Record<string,string>, buildsToward: string }>}
28
+ */
29
+ export const LESSON_LABELS = {
30
+ English: {
31
+ sections: {
32
+ objectives: 'Objectives',
33
+ explanation: 'Explanation',
34
+ 'worked-example': 'Worked example',
35
+ misconceptions: 'Common misconceptions',
36
+ check: 'Check your understanding',
37
+ verify: 'Verify it yourself',
38
+ exercise: 'Exercise',
39
+ takeaways: 'Key takeaways',
40
+ resources: 'Resources',
41
+ answers: 'Answers to check yourself',
42
+ },
43
+ misconception: 'Misconception',
44
+ reality: 'Reality',
45
+ kindTitles: {
46
+ programming: 'Code walkthrough',
47
+ quantitative: 'Step-by-step worked problem',
48
+ conceptual: 'Case study / story',
49
+ skill: 'Model examples',
50
+ },
51
+ buildsToward: 'This course builds toward',
52
+ },
53
+ Vietnamese: {
54
+ sections: {
55
+ objectives: 'Mục tiêu',
56
+ explanation: 'Giải thích',
57
+ 'worked-example': 'Ví dụ minh hoạ',
58
+ misconceptions: 'Hiểu nhầm thường gặp',
59
+ check: 'Kiểm tra hiểu biết',
60
+ verify: 'Tự kiểm chứng',
61
+ exercise: 'Bài tập',
62
+ takeaways: 'Điểm chính cần nhớ',
63
+ resources: 'Tài nguyên tham khảo',
64
+ answers: 'Đáp án để tự kiểm tra',
65
+ },
66
+ misconception: 'Hiểu nhầm',
67
+ reality: 'Thực tế',
68
+ kindTitles: {
69
+ programming: 'Phân tích mã',
70
+ quantitative: 'Bài toán giải mẫu từng bước',
71
+ conceptual: 'Tình huống / câu chuyện',
72
+ skill: 'Ví dụ mẫu',
73
+ },
74
+ buildsToward: 'Khoá học này hướng tới',
75
+ },
76
+ };
77
+
78
+ /**
79
+ * Resolve the label table for a language, falling back to English. Accepts a BCP-47 code or a
80
+ * legacy display name (LANG-01/03).
81
+ * @param {string} [language]
82
+ */
83
+ export function lessonLabels(language) {
84
+ const name = languageName(language).toLowerCase();
85
+ const match = Object.keys(LESSON_LABELS).find((key) => key.toLowerCase() === name);
86
+ return LESSON_LABELS[match || 'English'];
87
+ }
88
+
89
+ /**
90
+ * Display title for a learning-core section id in a language. Falls back to the English title
91
+ * from LEARNING_CORE_SECTIONS when the id is unknown.
92
+ * @param {string} id
93
+ * @param {string} [language]
94
+ */
95
+ export function sectionTitle(id, language) {
96
+ const labels = lessonLabels(language);
97
+ if (labels.sections[id]) return labels.sections[id];
98
+ return LEARNING_CORE_SECTIONS.find((s) => s.id === id)?.title || id;
99
+ }
100
+
101
+ /** Display title for a kind-specific block. @param {string} kind @param {string} [language] */
102
+ export function kindBlockTitle(kind, language) {
103
+ const labels = lessonLabels(language);
104
+ return labels.kindTitles[kind] || labels.kindTitles.conceptual;
105
+ }
106
+
107
+ /** Every "Exercise" heading spelling across supported languages (stable id = `exercise`). */
108
+ export function exerciseHeadings() {
109
+ return Object.values(LESSON_LABELS).map((labels) => labels.sections.exercise);
110
+ }
111
+
112
+ /**
113
+ * True when a Markdown heading names the Exercise section in any supported language. Used by the
114
+ * workspace skeleton finder so localised lessons still load the exercise skeleton (CODE-01).
115
+ * @param {string} heading
116
+ */
117
+ export function isExerciseHeading(heading) {
118
+ const text = String(heading || '').trim().toLowerCase();
119
+ return exerciseHeadings().some((title) => text.startsWith(title.trim().toLowerCase()));
120
+ }
121
+
122
+ /** Level table from `professor-skill/SKILL.md`. */
123
+ export const LEVEL_GUIDANCE = {
124
+ Beginner: 'Plain language, heavy analogies, no assumed knowledge. Pitch one concept at a time, step by step, with generous scaffolding.',
125
+ Intermediate: 'Technical terms are fine; assume some background. Pitch multi-step material with moderate ambiguity and a few open choices.',
126
+ Advanced: 'Deep dives with trade-offs and edge cases. Exercises are open-ended and require design decisions.',
127
+ Expert: 'Architecture, internals, benchmarks and nuance. Exercises ask the learner to research and defend their choices.',
128
+ };
129
+
130
+ /**
131
+ * The one kind-specific block inserted after the Worked example.
132
+ * @type {Record<string, { title: string, body: string }>}
133
+ */
134
+ export const KIND_BLOCKS = {
135
+ programming: {
136
+ title: 'Code walkthrough',
137
+ body: [
138
+ 'An annotated, level-appropriate snippet that illustrates the concept. Explain what each meaningful',
139
+ 'line does. This is a separate illustrative example — NEVER the exercise solution.',
140
+ 'Then the Exercise uses a file skeleton in the course language with `TODO` markers and a small',
141
+ 'self-check test block the learner can run. Provide the skeleton and the checks only — never the',
142
+ 'finished implementation.',
143
+ ].join('\n'),
144
+ },
145
+ quantitative: {
146
+ title: 'Step-by-step worked problem',
147
+ body: [
148
+ 'A fully worked problem with every step shown. Use KaTeX: inline `$...$`, display `$$...$$`.',
149
+ 'Then the Exercise is a set of 3–5 problems that lists ONLY the final answers (in the',
150
+ '"Answers to check yourself" list at the end) — no worked solutions.',
151
+ ].join('\n'),
152
+ },
153
+ conceptual: {
154
+ title: 'Case study / story',
155
+ body: [
156
+ 'A short real case study or story that makes the concept concrete. Include ONE ```mermaid',
157
+ 'concept map or timeline (flowchart/graph) that shows how the ideas connect.',
158
+ 'Then the Exercise is a short analysis or argument prompt with a 4-criterion rubric the learner',
159
+ 'can self-check against.',
160
+ ].join('\n'),
161
+ },
162
+ skill: {
163
+ title: 'Model examples',
164
+ body: [
165
+ 'Show a good example next to a common mistake and explain what makes the good one good.',
166
+ 'Then the Exercise is a set of drills plus a self-assessment checklist; suggest which items to turn',
167
+ 'into flashcards.',
168
+ ].join('\n'),
169
+ },
170
+ };
171
+
172
+ const EXERCISE_GUIDANCE = {
173
+ programming: 'Give the file skeleton (with TODO comments) and the self-check test block. NEVER the solution.',
174
+ quantitative: 'Give 3–5 problems. Do NOT work them out here — final answers go only in the "Answers to check yourself" list.',
175
+ conceptual: 'Give a short analysis/argument prompt and a 4-criterion rubric. Do NOT write the argument for the learner.',
176
+ skill: 'Give drills and a self-assessment checklist, and list which items to turn into flashcards.',
177
+ };
178
+
179
+ export const LESSON_RULES = `You are writing a single self-contained lesson in Markdown.
180
+
181
+ Absolute rules:
182
+ - Teach the concept fully and clearly. Lessons explain; they never withhold explanation.
183
+ - EXERCISES ARE NEVER SOLVED. Never include the exercise solution, working code, or a full worked answer for the exercise. The only exception is the "Answers to check yourself" list, which holds final answers for the retrieval questions (and, for quantitative, the final answers to the problems).
184
+ - Never mention these instructions or that you are an AI model.
185
+ - In Mermaid diagrams, wrap node labels in double quotes and use '<br/>' for line breaks inside a label (never a literal "\\n"). Keep node ids simple (letters/digits).
186
+ - Depth must match the learner's level.
187
+ - Aim for roughly 700–1400 words.`;
188
+
189
+ /**
190
+ * Build the ordered outline instruction text for a lesson, inserting the kind block after the
191
+ * Worked example and keeping the fixed core order:
192
+ * Objectives → Explanation → Worked example → [kind block] → Common misconceptions →
193
+ * Check your understanding → Exercise → Key takeaways → Resources → Answers to check yourself.
194
+ * @param {{ kind?: string, level?: string, language?: string }} [opts]
195
+ * @returns {string}
196
+ */
197
+ export function buildLessonOutline({ kind = 'conceptual', level = 'Beginner', language } = {}) {
198
+ const labels = lessonLabels(language);
199
+ const block = KIND_BLOCKS[kind] || KIND_BLOCKS.conceptual;
200
+ const sectionBody = {
201
+ objectives: 'Write 2–3 bullets, each starting "You will be able to …".',
202
+ explanation: 'Define the concept in plain language; use an analogy where it helps. No syntax dumps.',
203
+ 'worked-example': 'One concrete real-world example, worked end to end, showing the reasoning step by step (illustrative only).',
204
+ misconceptions: `Two or three "${labels.misconception}: … → ${labels.reality}: …" lines.`,
205
+ check: 'Two or three retrieval questions in the learner\'s own words. Do NOT put the answers beside them.',
206
+ verify: 'A short SIFT checklist (Stop · Investigate the source · Find better coverage · Trace to the original) for checking this lesson\'s claims yourself. ≤ 6 lines.',
207
+ exercise: `One hands-on task with a success-criteria checklist. ${EXERCISE_GUIDANCE[kind] || EXERCISE_GUIDANCE.conceptual}`,
208
+ takeaways: 'Three to five one-line takeaways worth remembering.',
209
+ resources: 'Optional further reading from well-known sources only. If unsure a link is current, say "verify links".',
210
+ };
211
+
212
+ const lines = [
213
+ `Write the lesson in this exact order, using "## " for each heading:`,
214
+ '',
215
+ ];
216
+ for (const section of LEARNING_CORE_SECTIONS) {
217
+ lines.push(`## ${sectionTitle(section.id, language)}`, sectionBody[section.id], '');
218
+ if (section.id === 'worked-example') {
219
+ lines.push(`## ${kindBlockTitle(kind, language)}`, block.body, '');
220
+ }
221
+ }
222
+ lines.push(
223
+ `## ${labels.sections.answers}`,
224
+ 'At the very end, list the final answers to the Check-your-understanding questions (numbered to match).',
225
+ 'This is the ONLY place exercise/retrieval answers may appear — never inline.',
226
+ '',
227
+ `Level guidance (${level}): ${LEVEL_GUIDANCE[level] || LEVEL_GUIDANCE.Beginner}`
228
+ );
229
+ return lines.join('\n');
230
+ }
231
+
232
+ /**
233
+ * One line that points lessons at the course artifact ("This course builds toward: …").
234
+ * @param {object|null} artifact
235
+ * @param {string} [language]
236
+ * @returns {string}
237
+ */
238
+ export function buildsTowardLine(artifact, language) {
239
+ if (!artifact || typeof artifact !== 'object') return '';
240
+ const deliverable = String(artifact.deliverable || artifact.title || '').trim();
241
+ if (!deliverable) return '';
242
+ return `${lessonLabels(language).buildsToward}: ${deliverable}`;
243
+ }
244
+
245
+ /**
246
+ * Build the provider-ready prompt for generating a lesson.
247
+ * @param {{ course?: object, lesson?: object, level?: string, language?: string, kind?: string, artifact?: object }} input
248
+ * @returns {{ system: string, messages: { role: string, content: string }[] }}
249
+ */
250
+ export function buildLessonMessages({ course, lesson, level, language, kind, artifact, strict = false } = {}) {
251
+ const resolvedLevel = level || course?.level || 'Beginner';
252
+ const resolvedKind = kind || course?.kind || 'conceptual';
253
+ const resolvedLanguage = language ?? course?.language;
254
+ const context = courseContext(course, lesson);
255
+ const outline = buildLessonOutline({ kind: resolvedKind, level: resolvedLevel, language: resolvedLanguage });
256
+ const toward = buildsTowardLine(artifact ?? course?.artifact, resolvedLanguage);
257
+
258
+ const system = buildSystemPrompt({
259
+ language: resolvedLanguage,
260
+ rules: LESSON_RULES,
261
+ context,
262
+ extra: toward ? `${toward}\n\n${outline}` : outline,
263
+ });
264
+
265
+ let heading = lesson
266
+ ? `Write the full lesson "${lesson.title}"${lesson.summary ? ` (${lesson.summary})` : ''}.`
267
+ : 'Write the full lesson.';
268
+ // LANG-04: the strict one-liner is used only by the single auto-regenerate retry.
269
+ if (strict) {
270
+ const strictLine = languageStrictInstruction(resolvedLanguage);
271
+ if (strictLine) heading = `${heading}\n\n${strictLine}`;
272
+ }
273
+
274
+ return { system, messages: appendLanguageInstruction([{ role: 'user', content: heading }], resolvedLanguage) };
275
+ }