ronin-skillforce 0.1.0 → 0.2.0-beta.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 (155) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +202 -21
  3. package/NOTICE +19 -0
  4. package/README.md +38 -5
  5. package/bin/cli.js +15 -3
  6. package/bin/commands/archive.js +192 -0
  7. package/bin/commands/capstone-status.js +82 -0
  8. package/bin/commands/create.js +69 -12
  9. package/bin/commands/import.js +5 -5
  10. package/bin/commands/status.js +1 -1
  11. package/bin/commands/studio-autostart.js +414 -0
  12. package/bin/commands/studio-state.js +159 -0
  13. package/bin/commands/studio.js +351 -17
  14. package/bin/commands/trail.js +153 -3
  15. package/bin/commands/web.js +8 -10
  16. package/bin/course-reader.js +6 -15
  17. package/bin/platforms/_shared.js +154 -28
  18. package/bin/platforms/claude.js +23 -42
  19. package/bin/platforms/cursor.js +23 -20
  20. package/bin/platforms/gemini.js +18 -19
  21. package/bin/platforms/opencode.js +47 -28
  22. package/package.json +5 -4
  23. package/plugin.json +1 -1
  24. package/shared/SKILL.md +102 -72
  25. package/shared/agents/coach.md +19 -16
  26. package/shared/agents/navigator.md +27 -34
  27. package/shared/agents/professor.md +16 -34
  28. package/shared/agents/researcher.md +1 -1
  29. package/shared/agents/spotter.md +3 -4
  30. package/shared/commands/professor/archive.md +65 -72
  31. package/shared/commands/professor/capstone-review.md +5 -5
  32. package/shared/commands/professor/capstone.md +3 -3
  33. package/shared/commands/professor/done.md +59 -31
  34. package/shared/commands/professor/hint.md +14 -2
  35. package/shared/commands/professor/navigator.md +27 -1
  36. package/shared/commands/professor/new-topic.md +3 -3
  37. package/shared/commands/professor/next.md +9 -5
  38. package/shared/commands/professor/note.md +6 -6
  39. package/shared/commands/professor/progress.md +1 -1
  40. package/shared/commands/professor/publish.md +5 -5
  41. package/shared/commands/professor/quiz.md +2 -2
  42. package/shared/commands/professor/recall.md +1 -1
  43. package/shared/commands/professor/review.md +14 -0
  44. package/shared/commands/professor/skill-export.md +3 -4
  45. package/shared/commands/professor/spotter.md +21 -4
  46. package/shared/commands/professor/stuck.md +24 -0
  47. package/shared/commands/professor/switch.md +1 -1
  48. package/shared/commands/professor/syllabus.md +1 -1
  49. package/shared/commands/professor/template-export.md +2 -2
  50. package/shared/commands/professor/worktrees.md +3 -7
  51. package/shared/hooks/pre-compact.js +4 -15
  52. package/studio/dist/assets/BetaReportPanel-BJ9HIAnz.js +1 -0
  53. package/studio/dist/assets/{Capstone-Cv9kH6LY.js → Capstone-CoUU-jP7.js} +1 -1
  54. package/studio/dist/assets/{CodeWorkspace-BwCEINWo.js → CodeWorkspace-BNrL4qvR.js} +2 -2
  55. package/studio/dist/assets/{Course-BJ_hafUP.js → Course-BMGTXus_.js} +1 -1
  56. package/studio/dist/assets/{Editor-CV0mNhlz.js → Editor-Cw9j3cnp.js} +1 -1
  57. package/studio/dist/assets/{Home-C1ry89ak.js → Home-D2woITq5.js} +1 -1
  58. package/studio/dist/assets/{Lesson-2e9TD9yL.js → Lesson-CYQhrDCZ.js} +2 -2
  59. package/studio/dist/assets/{NewCourse-BZeOg2xn.js → NewCourse-CMpwVRQb.js} +1 -1
  60. package/studio/dist/assets/{Progress-CRc_xEWC.js → Progress-2rS19Fur.js} +1 -1
  61. package/studio/dist/assets/{Review-6QEbHEfk.js → Review-SlqK-hjp.js} +1 -1
  62. package/studio/dist/assets/{Settings-NFnqVQui.js → Settings-t42u7n9H.js} +1 -1
  63. package/studio/dist/assets/{TutorPanel-DXQ6Z3BY.js → TutorPanel-DQDWIU7f.js} +3 -3
  64. package/studio/dist/assets/{abnfDiagram-WEYOIA3C-qeSjKlGM.js → abnfDiagram-WEYOIA3C-jTUmGBuB.js} +1 -1
  65. package/studio/dist/assets/{anthropic-D7NiQCUH.js → anthropic-iIm2l85r.js} +3 -3
  66. package/studio/dist/assets/{architecture-WOLXFQ4H-COG-m35l.js → architecture-WOLXFQ4H-Ch9Ld_vv.js} +1 -1
  67. package/studio/dist/assets/{architectureDiagram-ZHVYKT53-VO7uKoeD.js → architectureDiagram-ZHVYKT53-Dy-z6wsy.js} +1 -1
  68. package/studio/dist/assets/{blockDiagram-RJAE7QA3-BGJF_qiL.js → blockDiagram-RJAE7QA3-2fHVrc6N.js} +1 -1
  69. package/studio/dist/assets/{bridge-BTh0AeNX.js → bridge-Cr0q4rLp.js} +1 -1
  70. package/studio/dist/assets/{c4Diagram-XDPPPE54-C-S10RgU.js → c4Diagram-XDPPPE54-BuuKlG4V.js} +1 -1
  71. package/studio/dist/assets/{capstone-Amn6Hztq.js → capstone-DhwBeNqk.js} +1 -1
  72. package/studio/dist/assets/{card-store-BrbrtX9w.js → card-store-CVMBc-Pv.js} +1 -1
  73. package/studio/dist/assets/channel-M_JkdHrL.js +1 -0
  74. package/studio/dist/assets/{chunk-2E7WHVMD-fv-iqTyC.js → chunk-2E7WHVMD-lZdQWttk.js} +1 -1
  75. package/studio/dist/assets/{chunk-4EMNKR2T-CY9IZrgv.js → chunk-4EMNKR2T-C6kbMwke.js} +1 -1
  76. package/studio/dist/assets/{chunk-55XCU76K-DyTZz7v_.js → chunk-55XCU76K-rkBzkZog.js} +1 -1
  77. package/studio/dist/assets/{chunk-7S6XSTFO-BNMzTLRW.js → chunk-7S6XSTFO-Skg347QF.js} +1 -1
  78. package/studio/dist/assets/{chunk-AQDTSKZB-CEYANohH.js → chunk-AQDTSKZB-0pSDBJ23.js} +1 -1
  79. package/studio/dist/assets/{chunk-DSNLSHJZ-CDk5EXjH.js → chunk-DSNLSHJZ-BaeQDl2i.js} +1 -1
  80. package/studio/dist/assets/{chunk-HAGFOTED-hNAi1zh_.js → chunk-HAGFOTED-BEm00juw.js} +1 -1
  81. package/studio/dist/assets/{chunk-HNE4Q36P-COJnSYoZ.js → chunk-HNE4Q36P-DyCR-LvS.js} +1 -1
  82. package/studio/dist/assets/{chunk-NQOKRVIF-BU6KVxRr.js → chunk-NQOKRVIF-BNJ9uMmB.js} +1 -1
  83. package/studio/dist/assets/{chunk-UHW7PFBP-DYvxL9JG.js → chunk-UHW7PFBP-DqJczBLs.js} +1 -1
  84. package/studio/dist/assets/{chunk-VQ5W62QI-CuRfk65j.js → chunk-VQ5W62QI-CVWYSP5Q.js} +1 -1
  85. package/studio/dist/assets/{chunk-WQQL4CDK-KaG7x-Mb.js → chunk-WQQL4CDK-DJf0Dx05.js} +1 -1
  86. package/studio/dist/assets/{chunk-YZO67HFG-DbuqIZmk.js → chunk-YZO67HFG-BFUm_JHA.js} +1 -1
  87. package/studio/dist/assets/{chunk-ZAUX2LTX-bk4ivUmc.js → chunk-ZAUX2LTX-C5ETkkSE.js} +1 -1
  88. package/studio/dist/assets/{chunk-ZCHMQSOR-B_LElfwh.js → chunk-ZCHMQSOR-WVX9r9PZ.js} +1 -1
  89. package/studio/dist/assets/{classDiagram-v2-4MYWR3UA-DtCJ6H_X.js → classDiagram-v2-4MYWR3UA-CI77SpuR.js} +1 -1
  90. package/studio/dist/assets/{course-export-DpaOTT3a.js → course-export-C8jSPuda.js} +1 -1
  91. package/studio/dist/assets/{cynefin-EF2NZ3EQ-D9btHJvU.js → cynefin-EF2NZ3EQ-CLffmM25.js} +1 -1
  92. package/studio/dist/assets/{cynefinDiagram-WF24UDRP-CsFJuv27.js → cynefinDiagram-WF24UDRP-BvLwocOb.js} +1 -1
  93. package/studio/dist/assets/{dagre-NK4GIZVX-Cg1Duec7.js → dagre-NK4GIZVX-C2nMAVdh.js} +1 -1
  94. package/studio/dist/assets/{diagram-CBK3MWTC-_KU2m5gd.js → diagram-CBK3MWTC-Bid-pdax.js} +1 -1
  95. package/studio/dist/assets/{diagram-I5XIIV2D-5RaBrwUA.js → diagram-I5XIIV2D-DYJeAvzl.js} +1 -1
  96. package/studio/dist/assets/{diagram-ODIL2UCW-C0VKxoD3.js → diagram-ODIL2UCW-B06X2r_F.js} +1 -1
  97. package/studio/dist/assets/{diagram-PFBEJUXE-BaHcZEP2.js → diagram-PFBEJUXE-CwY--5Rz.js} +1 -1
  98. package/studio/dist/assets/{diagram-RJA3I4VV-cwSAZ90p.js → diagram-RJA3I4VV-4SqhH8zw.js} +1 -1
  99. package/studio/dist/assets/{diagram-TYUNFSNR-BJImxCEN.js → diagram-TYUNFSNR-CrW4AIM9.js} +1 -1
  100. package/studio/dist/assets/{ebnfDiagram-V4P3TTPT-OQQLRXcm.js → ebnfDiagram-V4P3TTPT-xeoCmH-d.js} +1 -1
  101. package/studio/dist/assets/{elk-QONTBCTQ-BJGhQHxQ.js → elk-QONTBCTQ-Dadmz6iS.js} +1 -1
  102. package/studio/dist/assets/{erDiagram-KYQIGQAA-D91EKSep.js → erDiagram-KYQIGQAA-CSuH0bbF.js} +1 -1
  103. package/studio/dist/assets/{eventmodeling-K75KTNOO-DgdTRgnw.js → eventmodeling-K75KTNOO-CciVfx3I.js} +1 -1
  104. package/studio/dist/assets/flowDiagram-IUGLLWBU-DgNR54qK.js +1 -0
  105. package/studio/dist/assets/{ganttDiagram-R7GPNTJY-CSYLPWEI.js → ganttDiagram-R7GPNTJY-C0wtA-2y.js} +1 -1
  106. package/studio/dist/assets/{gitGraph-VSP46ZUC-D6GWaV9y.js → gitGraph-VSP46ZUC-BXoDzaA3.js} +1 -1
  107. package/studio/dist/assets/{gitGraphDiagram-PDYL7XHY-CaV31bvT.js → gitGraphDiagram-PDYL7XHY-vZBlNRPe.js} +1 -1
  108. package/studio/dist/assets/{index-DioXTZVc.js → index-CS8XPYbB.js} +2 -2
  109. package/studio/dist/assets/{info-OHQRW6UA-BN-x8GoN.js → info-OHQRW6UA-bs2Qpf7P.js} +1 -1
  110. package/studio/dist/assets/{infoDiagram-MVDRKAX5-CIose_cy.js → infoDiagram-MVDRKAX5-rPJio6-1.js} +1 -1
  111. package/studio/dist/assets/{ishikawaDiagram-HPEHV2GE-DCihSNBw.js → ishikawaDiagram-HPEHV2GE-CXf9XFff.js} +1 -1
  112. package/studio/dist/assets/{journeyDiagram-BOSHW7O7-Bz3o3RIX.js → journeyDiagram-BOSHW7O7-C3MSH79o.js} +1 -1
  113. package/studio/dist/assets/{kanban-definition-FNSA4HC5-BUyqvlFE.js → kanban-definition-FNSA4HC5-Bdh7SB4n.js} +1 -1
  114. package/studio/dist/assets/{line-B08T8KlK.js → line-CHkoQXJF.js} +1 -1
  115. package/studio/dist/assets/{mermaid-parser.core-BYwreSUy.js → mermaid-parser.core-Do1oxD1S.js} +3 -3
  116. package/studio/dist/assets/{mermaid.core-DTO1oDmq.js → mermaid.core-DgZUD0sU.js} +4 -4
  117. package/studio/dist/assets/{mindmap-definition-6OY57UG3-BGLwKheY.js → mindmap-definition-6OY57UG3-PUaK6oE_.js} +1 -1
  118. package/studio/dist/assets/{node.browser-BISniYn8.js → node.browser-DkpMze_r.js} +1 -1
  119. package/studio/dist/assets/{ollama-De5w84tG.js → ollama-bJNp3jaD.js} +1 -1
  120. package/studio/dist/assets/{openai-compatible-Joy1oK3L.js → openai-compatible-0tmAyMlN.js} +1 -1
  121. package/studio/dist/assets/{packet-JDAUHWVQ-CDIMjHS_.js → packet-JDAUHWVQ-vf2FtqFr.js} +1 -1
  122. package/studio/dist/assets/{pegDiagram-ECIUJNBX-DWXm4mwS.js → pegDiagram-ECIUJNBX-NEVrgPTY.js} +1 -1
  123. package/studio/dist/assets/{pie-XZMESJXO-CY3QQiKZ.js → pie-XZMESJXO-BIWydVNZ.js} +1 -1
  124. package/studio/dist/assets/{pieDiagram-GNMPY74T-M1aCnI7W.js → pieDiagram-GNMPY74T-BI9_u6rT.js} +1 -1
  125. package/studio/dist/assets/{quadrantDiagram-D57K4MC3-BFFtO7U5.js → quadrantDiagram-D57K4MC3-ryNpoBC5.js} +1 -1
  126. package/studio/dist/assets/{radar-ABXABTNO-DT0W4_Xn.js → radar-ABXABTNO-D8TjnvBB.js} +1 -1
  127. package/studio/dist/assets/{railroad-I3PHUGI6-_VCpgZR5.js → railroad-I3PHUGI6-BmEDV5kf.js} +1 -1
  128. package/studio/dist/assets/{railroad-abnf-LNEFI6M7-DkSpQ5YY.js → railroad-abnf-LNEFI6M7-Cs_sArMc.js} +1 -1
  129. package/studio/dist/assets/{railroad-ebnf-DWYD2UWJ-BqWILdGb.js → railroad-ebnf-DWYD2UWJ-DYuCq46d.js} +1 -1
  130. package/studio/dist/assets/{railroad-peg-JR7BVNR7-BB0bQL-Z.js → railroad-peg-JR7BVNR7-BcXSgdMy.js} +1 -1
  131. package/studio/dist/assets/{railroadDiagram-Y72NRBL7-CjLKjIdJ.js → railroadDiagram-Y72NRBL7-DBcc8b2c.js} +1 -1
  132. package/studio/dist/assets/{rehype-katex-C-sKddsH.js → rehype-katex-BfUIq5As.js} +1 -1
  133. package/studio/dist/assets/{remark-math-C-ox67hE.js → remark-math-XvZOjmDO.js} +1 -1
  134. package/studio/dist/assets/{requirementDiagram-EQYSW5RA-CnwzZqR8.js → requirementDiagram-EQYSW5RA-CVcBgM1L.js} +1 -1
  135. package/studio/dist/assets/{sankeyDiagram-SY24JHO5-CPDugTUl.js → sankeyDiagram-SY24JHO5-DjZ81hDs.js} +1 -1
  136. package/studio/dist/assets/{sequenceDiagram-BLEHNHQU-1dLfeU9Y.js → sequenceDiagram-BLEHNHQU-BNwOa2S7.js} +1 -1
  137. package/studio/dist/assets/{stateDiagram-v2-A6IESKWZ-DR7CmEjj.js → stateDiagram-v2-A6IESKWZ-BFWa5lEx.js} +1 -1
  138. package/studio/dist/assets/{swimlanes-B3ENRKFQ-BAWB9omQ.js → swimlanes-B3ENRKFQ-LfM_Jg6Z.js} +1 -1
  139. package/studio/dist/assets/swimlanesDiagram-AYQRV4AK-BDmpoiGp.js +8 -0
  140. package/studio/dist/assets/{timeline-definition-JXYKGLGB-DNkj8z77.js → timeline-definition-JXYKGLGB-BwGzkWgZ.js} +1 -1
  141. package/studio/dist/assets/{treeView-D4JQ5SDB-BA-ouhMb.js → treeView-D4JQ5SDB-MLk3VuRt.js} +1 -1
  142. package/studio/dist/assets/{treemap-SAJKECNS-BrrGxsAb.js → treemap-SAJKECNS-D8iSjp7L.js} +1 -1
  143. package/studio/dist/assets/{usecaseDiagram-WPOLBNNX-BB3D0Dt_.js → usecaseDiagram-WPOLBNNX-BqxpaNlT.js} +1 -1
  144. package/studio/dist/assets/{vennDiagram-Q3Y3IDCW-BrtqtKTE.js → vennDiagram-Q3Y3IDCW-CpeUDMhQ.js} +1 -1
  145. package/studio/dist/assets/{wardley-7MLQ67FV-BKkemDql.js → wardley-7MLQ67FV-tAMbCZAj.js} +1 -1
  146. package/studio/dist/assets/{wardleyDiagram-IVAIDKWA-DFnI3P5z.js → wardleyDiagram-IVAIDKWA-CDJViWzt.js} +1 -1
  147. package/studio/dist/assets/{xychartDiagram-4URNHDU4-Da0DZG_q.js → xychartDiagram-4URNHDU4-CwaQrd3_.js} +1 -1
  148. package/studio/dist/index.html +1 -1
  149. package/templates/claude/plugin.json +1 -1
  150. package/templates/gemini/GEMINI.md +18 -16
  151. package/web/server.js +3 -3
  152. package/studio/dist/assets/BetaReportPanel-8NrDLiPm.js +0 -1
  153. package/studio/dist/assets/channel-SJiUQu_N.js +0 -1
  154. package/studio/dist/assets/flowDiagram-IUGLLWBU-CVnJYMum.js +0 -1
  155. package/studio/dist/assets/swimlanesDiagram-AYQRV4AK-qeuHru16.js +0 -8
package/CHANGELOG.md CHANGED
@@ -4,6 +4,54 @@ All notable changes to **ronin-skillforce** are documented here. The format is b
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.2.0-beta.0] — 2026-11-15
8
+
9
+ ### Changed
10
+
11
+ - **License: Apache-2.0** from this release (was MIT). Adds a `NOTICE` file with attribution,
12
+ third-party licences and a trademark note. Version 0.1.0 and all `course-professor` releases stay MIT.
13
+
14
+
15
+ ### Added
16
+
17
+ - `skillforce studio --autostart on|off` starts Professor Studio at login on macOS through a
18
+ LaunchAgent (`com.ronin-skillforce.studio`), pins the ports the first time so the URL and pairing
19
+ URL stop changing, and refuses to install from an npx cache (use a global install).
20
+ - `skillforce studio --status` reports whether Studio runs, its URL and pairing URL, the autostart
21
+ state and the log path (`${PROFESSOR_HOME:-~/.professor}/logs/studio.log`). `--stop` stops it —
22
+ through launchd when the login item is installed, otherwise through the pid in
23
+ `${PROFESSOR_HOME:-~/.professor}/studio.json` — and never signals a process that is not Studio.
24
+ - `skillforce studio --strict-port` fails instead of moving to another port when one is busy.
25
+
26
+ ### Changed
27
+
28
+ - Courses live only in `learning/<slug>/`. The legacy `courses/` location is no longer read:
29
+ `professor:capstone` and `professor:syllabus` now find every course created since 0.1.0, and the
30
+ CLI and PreCompact hook look in `learning/` only. If you still have a pre-0.1.0 `courses/<slug>/`
31
+ folder, move it to `learning/<slug>/` by hand — nothing is migrated automatically.
32
+
33
+ ### Fixed
34
+
35
+ - New programming courses are created on an **orphan** branch: `learning/<slug>/` holds only course
36
+ files, never a copy of your project, and shares no history with it.
37
+ - `professor:archive` keeps everything: the whole course is copied to `.course_archive/<slug>/`
38
+ (never overwritten), course commits stay on branch `archive/<slug>`, and nothing is removed before
39
+ the copy is verified (`skillforce archive`).
40
+ - `professor:done` no longer loops: Coach asks you to say "confirm"; the section verdict is recorded
41
+ with `skillforce verdict` in the format the CLI reads, and the capstone status line now updates.
42
+ - `professor:hint` and `professor:stuck` refuse during the capstone phase; `professor:next` resumes
43
+ an in-progress section instead of skipping it.
44
+ - Re-running `setup` now refreshes the files the plugin installed (a changed file is kept once as
45
+ `.bak`); Gemini CLI, OpenCode and Cursor get current instructions, an inline Coach flow, and
46
+ Gemini commands receive their arguments.
47
+ - `skillforce studio` polls and prints `http://127.0.0.1:<port>` instead of `http://localhost:<port>`,
48
+ matching the loopback bind. On macOS `localhost` resolves to `::1` first, so a health poll could
49
+ reach another dev server holding `[::1]:3000` and fail with "did not become healthy … (HTTP 404)".
50
+ - `skillforce studio` checks both loopback families before starting. A busy default port moves to the
51
+ next free one with a notice, a busy `--port` / `--api-port` fails with a message naming the port and
52
+ the flag to change, and a health answer that is not Studio says another app is on that port.
53
+ - `skillforce web` prints its UI URL on `127.0.0.1` (legacy Vite dev is unchanged).
54
+
7
55
  ## [0.1.0] — 2026-11-14
8
56
 
9
57
  First release under the new name. Earlier versions were published as `course-professor`
package/LICENSE CHANGED
@@ -1,21 +1,202 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 ronnie-tk
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,19 @@
1
+ Ronin SkillForce
2
+ Copyright 2026 Tuấn Khuất (ronnie)
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+ Versions 0.1.0 and earlier, and all versions published as `course-professor`,
6
+ were released under the MIT License.
7
+
8
+ "Ronin SkillForce" and "SkillForce" are names of the project owner. The
9
+ Apache License does not grant permission to use these names, logos or other
10
+ trademarks, except as required for describing the origin of the work.
11
+
12
+ Third-party software
13
+ --------------------
14
+ The built Studio app (studio/dist) bundles third-party packages under their
15
+ own licenses, including:
16
+ - elkjs (Eclipse Public License 2.0), used unmodified through Mermaid
17
+ https://github.com/kieler/elkjs
18
+ All other runtime dependencies are under permissive licenses (MIT, ISC,
19
+ BSD-2/3-Clause, Apache-2.0, 0BSD, CC0-1.0, Unlicense, Python-2.0).
package/README.md CHANGED
@@ -25,7 +25,8 @@ you try, you get feedback as questions, and you keep what you learn.
25
25
  - **Grounded lectures.** Before each lecture it researches 3–6 sources and cites key claims. It
26
26
  never invents links, and marks claims it could not source as unverified.
27
27
  - **Your progress stays on your machine.** Courses are plain Markdown files. Programming courses
28
- are git worktrees on their own `learning/<slug>` branch, so they never mix with your project.
28
+ are git worktrees on their own `learning/<slug>` branch, which starts with no history and none of
29
+ your project's files, so they never mix with your project.
29
30
  - **Remembers how you learn.** Coach keeps a trail of every review round, flags weak concepts and
30
31
  builds spaced-repetition flashcards.
31
32
 
@@ -76,8 +77,8 @@ npm i -g ronin-skillforce # then run `skillforce <command>`
76
77
  npm uninstall -g ronin-skillforce
77
78
  ```
78
79
 
79
- Your courses (`learning/`, `courses/`) and Studio's database live outside the package and are not
80
- removed when you uninstall.
80
+ Your courses (in `learning/`) and Studio's database live outside the package and are not removed
81
+ when you uninstall.
81
82
 
82
83
  ---
83
84
 
@@ -120,13 +121,40 @@ npx ronin-skillforce <command> # or `skillforce <command>` after a globa
120
121
  | `next [slug]` | Current lesson summary and how to continue |
121
122
  | `check [slug]` | Run the active exercise's self-checks (never shows solutions) |
122
123
  | `doctor` | Check Node, git, agents, Ollama, ports and the database, with fix hints |
123
- | `studio [--no-open] [--port N --api-port N]` | Start the local server and Studio, print a pairing URL |
124
+ | `studio [--no-open] [--port N --api-port N] [--status \| --stop \| --autostart on\|off]` | Start the local server and Studio, print a pairing URL, or check/stop the background copy |
124
125
  | `review [--limit N]` | Review due flashcards in the terminal (shared with Studio) |
125
126
  | `import [slug \| --all] [--dry-run]` | Import Markdown courses into Studio's database |
126
127
  | `create`, `save`, `context`, `trail` | Course steps the agent commands run for you |
127
128
  | `courses`, `search`, `install`, `update`, `installed`, `remove` | Community courses and skills (beta) |
128
129
  | `web` | Start only the bridge server (see below) |
129
130
 
131
+ ### Run Studio in the background (macOS)
132
+
133
+ On macOS you can let Studio start at login instead of running `npx ronin-skillforce studio` yourself.
134
+ Auto-start needs a global install, because a path in the npx cache can be deleted at any time:
135
+
136
+ ```bash
137
+ npm i -g ronin-skillforce
138
+ skillforce studio --autostart on # installs the login item and prints the fixed URL
139
+ ```
140
+
141
+ The LaunchAgent (`~/Library/LaunchAgents/com.ronin-skillforce.studio.plist`) pins the ports in use
142
+ when you ran the command and starts Studio with `--strict-port`, so the URL and pairing URL stay the
143
+ same at every login. If a pinned port is busy at login, Studio does not start: the reason is the last
144
+ line of `~/.professor/logs/studio.log` (or `$PROFESSOR_HOME/logs/studio.log` when that is set).
145
+
146
+ ```bash
147
+ skillforce studio --status # running? URL, pairing URL, autostart, log path
148
+ skillforce studio --stop # stop it; never touches another app's process
149
+ skillforce studio --autostart off # remove the login item
150
+ ```
151
+
152
+ Pick a specific port with `--autostart on --port 5190 --api-port 3005` (a busy port is refused, not
153
+ silently changed). Re-run `--autostart on` after changing Node (nvm, a global upgrade) so the agent
154
+ points at the new binary, and run `--autostart off` before uninstalling the package. Log out and back
155
+ in once to see it start by itself; `--status` may say "not running" for a moment after login while
156
+ Studio boots.
157
+
130
158
  ### Starting the bridge manually
131
159
 
132
160
  `skillforce web` starts the Studio bridge server and serves the built Studio app from the
@@ -223,4 +251,9 @@ runs where and how to report a vulnerability.
223
251
 
224
252
  ## License
225
253
 
226
- MIT
254
+ [Apache License 2.0](LICENSE) from version 0.2.0. See [`NOTICE`](NOTICE) for attribution and
255
+ third-party licenses. Version 0.1.0 and every release published as `course-professor` were MIT.
256
+
257
+ "Ronin SkillForce" and "SkillForce" are the project owner's names; the licence does not grant
258
+ permission to use them for other products. Contributions are accepted under the terms in
259
+ [`CONTRIBUTING.md`](CONTRIBUTING.md).
package/bin/cli.js CHANGED
@@ -662,11 +662,15 @@ switch (command) {
662
662
  case 'import':
663
663
  case 'create':
664
664
  case 'save':
665
+ case 'archive':
665
666
  case 'context':
666
- case 'trail': {
667
- const file = { save: 'create', context: 'trail' }[command] || command;
667
+ case 'trail':
668
+ case 'verdict':
669
+ case 'capstone-status': {
670
+ const file = { save: 'create', context: 'trail', verdict: 'trail' }[command] || command;
668
671
  const { run } = await import(`./commands/${file}.js`);
669
- await run({ args: args.slice(1), cwd: process.cwd(), chalk, style, command });
672
+ const code = await run({ args: args.slice(1), cwd: process.cwd(), chalk, style, command });
673
+ if (typeof code === 'number' && code !== 0) process.exit(code);
670
674
  break;
671
675
  }
672
676
 
@@ -739,8 +743,11 @@ COMMANDS
739
743
  ${chalk.bold('check')} [slug] Run the active exercise's self-checks
740
744
  ${chalk.bold('create')} <slug> --kind K Create a course folder (programming = verified git worktree)
741
745
  ${chalk.bold('save')} <slug> [-m msg] Commit a programming course's worktree
746
+ ${chalk.bold('archive')} <slug> [--json] Copy a course to .course_archive/ and keep its branch
742
747
  ${chalk.bold('context')} [slug] --json Course context for Coach (path, section, exercise, trail)
743
748
  ${chalk.bold('trail')} <slug> --learner .. --asked .. --concept .. Record a Coach review round
749
+ ${chalk.bold('verdict')} <slug> --stdin Record a Coach done-gate verdict (section entry + watch flag)
750
+ ${chalk.bold('capstone-status')} <slug> --set locked|active|done Update the capstone header and row
744
751
  ${chalk.bold('doctor')} Check the local environment (Node, git, agents, Ollama, port, DB)
745
752
  ${chalk.bold('studio')} Start local server + Studio, pair and open the browser (Node 22.5+)
746
753
  ${chalk.bold('review')} [--limit N] Review due flashcards in the terminal (SM-2) (Node 22.5+)
@@ -776,6 +783,10 @@ FLAGS
776
783
  --port <n> For \`studio\`, the Studio port (default 5180)
777
784
  --api-port <n> For \`studio\`, the local server port (default 3000)
778
785
  --no-open For \`studio\`, do not open the browser
786
+ --strict-port For \`studio\`, never fall back to another port when one is busy
787
+ --autostart on|off For \`studio\`, start at login with a macOS LaunchAgent (global install only)
788
+ --status For \`studio\`, show whether Studio is running, its URLs and the log path
789
+ --stop For \`studio\`, stop the running Studio
779
790
  --limit <n> For \`review\`, max cards to review (default 20)
780
791
  --dry-run For \`import\`, print what would be imported without writing
781
792
 
@@ -784,6 +795,7 @@ EXAMPLES
784
795
  npx ronin-skillforce status --json # Machine-readable status
785
796
  npx ronin-skillforce next # What to work on, and how to continue
786
797
  npx ronin-skillforce check nextjs # Run the active exercise's self-checks
798
+ npx ronin-skillforce archive nextjs # Archive a course, keeping every file and commit
787
799
  npx ronin-skillforce doctor # Diagnose your local setup
788
800
  npx ronin-skillforce studio # One command: server + Studio + pairing
789
801
  npx ronin-skillforce review # Review due flashcards in the terminal
@@ -0,0 +1,192 @@
1
+ /**
2
+ * `skillforce archive <slug> [--json]` — retire a course without losing learner work.
3
+ *
4
+ * - Copies the whole `learning/<slug>/` directory, minus `.git`, to
5
+ * `.course_archive/<slug>[-N]` (an existing archive is never overwritten).
6
+ * - Programming courses keep their commits on branch `archive/<slug>` instead of `-D`.
7
+ * - Plain-folder courses are removed only after the copy is verified.
8
+ */
9
+ import { execFileSync } from 'child_process';
10
+ import {
11
+ cpSync,
12
+ existsSync,
13
+ lstatSync,
14
+ readdirSync,
15
+ realpathSync,
16
+ rmSync,
17
+ } from 'fs';
18
+ import { basename, join, relative } from 'path';
19
+ import { listWorktrees, saveCourse, excludeRepoPath, SLUG_RE } from './create.js';
20
+ import { style } from '../registry-helpers.js';
21
+
22
+ function git(cwd, args) {
23
+ return execFileSync('git', args, {
24
+ cwd,
25
+ encoding: 'utf-8',
26
+ stdio: ['ignore', 'pipe', 'pipe'],
27
+ }).trim();
28
+ }
29
+
30
+ function tryGit(cwd, args) {
31
+ try { return git(cwd, args); } catch { return null; }
32
+ }
33
+
34
+ /** First non-existing path among `<base>`, `<base>-2`, `<base>-3`, … */
35
+ export function nextFreePath(base) {
36
+ if (!existsSync(base)) return base;
37
+ for (let n = 2; ; n++) {
38
+ const candidate = `${base}-${n}`;
39
+ if (!existsSync(candidate)) return candidate;
40
+ }
41
+ }
42
+
43
+ function nextFreeBranch(cwd, base) {
44
+ if (tryGit(cwd, ['rev-parse', '--verify', '-q', `refs/heads/${base}`]) === null) return base;
45
+ for (let n = 2; ; n++) {
46
+ const candidate = `${base}-${n}`;
47
+ const exists = tryGit(cwd, ['rev-parse', '--verify', '-q', `refs/heads/${candidate}`]);
48
+ if (exists === null) return candidate;
49
+ }
50
+ }
51
+
52
+ /** Every entry under `dir`, as paths relative to it, skipping any `.git` entry. */
53
+ function entries(dir, prefix = '') {
54
+ const out = [];
55
+ for (const name of readdirSync(dir).sort()) {
56
+ if (name === '.git') continue;
57
+ const rel = prefix ? join(prefix, name) : name;
58
+ const abs = join(dir, name);
59
+ const stat = lstatSync(abs);
60
+ out.push({ rel, stat });
61
+ if (stat.isDirectory()) out.push(...entries(abs, rel));
62
+ }
63
+ return out;
64
+ }
65
+
66
+ /** Throw unless every source entry exists in the copy with the same type and byte size. */
67
+ export function verifyCopy(src, dest) {
68
+ for (const { rel, stat } of entries(src)) {
69
+ const copy = join(dest, rel);
70
+ if (!existsSync(copy)) throw new Error(`Archive copy is missing ${rel}.`);
71
+ const copied = lstatSync(copy);
72
+ if (copied.isDirectory() !== stat.isDirectory()) {
73
+ throw new Error(`Archive copy has the wrong type for ${rel}.`);
74
+ }
75
+ if (!stat.isDirectory() && copied.size !== stat.size) {
76
+ throw new Error(`Archive copy size differs for ${rel}.`);
77
+ }
78
+ }
79
+ }
80
+
81
+ /** Collapse multiline git stderr into one readable line. */
82
+ function detail(err) {
83
+ return (err.stderr || err.message || '').toString().trim().split('\n')[0];
84
+ }
85
+
86
+ function archiveProgramming({ root, cwd, slug, courseDir, branch, target }) {
87
+ let archiveBranch = branch;
88
+ if (!branch || !branch.startsWith('archive/')) {
89
+ try {
90
+ saveCourse({ cwd, slug });
91
+ } catch (err) {
92
+ throw new Error(`Could not commit learning/${slug}/ — nothing was removed. ${detail(err)} ` +
93
+ `The copy is at ${relative(cwd, target)}.`);
94
+ }
95
+ const dirty = tryGit(courseDir, ['status', '--porcelain']);
96
+ if (dirty === null) {
97
+ throw new Error(`Could not read the status of learning/${slug}/ — nothing was removed. ` +
98
+ `The copy is at ${relative(cwd, target)}.`);
99
+ }
100
+ if (dirty !== '') {
101
+ throw new Error(`learning/${slug}/ still has uncommitted changes — nothing was removed. ` +
102
+ `The copy is at ${relative(cwd, target)}.`);
103
+ }
104
+ archiveBranch = nextFreeBranch(root, `archive/${slug}`);
105
+ try {
106
+ git(courseDir, ['branch', '-m', archiveBranch]);
107
+ } catch (err) {
108
+ throw new Error(`Could not rename the course branch to ${archiveBranch} — nothing was ` +
109
+ `removed. ${detail(err)} The copy is at ${relative(cwd, target)}.`);
110
+ }
111
+ }
112
+
113
+ try {
114
+ git(root, ['worktree', 'remove', courseDir]);
115
+ } catch (err) {
116
+ throw new Error(`Could not remove learning/${slug}/ (it is still registered on branch ` +
117
+ `${archiveBranch}). ${detail(err)} The copy is at ${relative(cwd, target)}.`);
118
+ }
119
+ return { archivedTo: relative(cwd, target), branch: archiveBranch, removed: true };
120
+ }
121
+
122
+ /**
123
+ * Archive one course. Throws with a user-facing message on any failure; the course is then
124
+ * still in `learning/<slug>/` unless the error says git removed it.
125
+ * @returns {{ archivedTo: string, branch: string|null, removed: boolean, warning?: string }}
126
+ */
127
+ export function archiveCourse({ cwd, slug, verify = verifyCopy }) {
128
+ if (!SLUG_RE.test(slug || '')) {
129
+ throw new Error(`Invalid slug ${JSON.stringify(slug)} — use lowercase a-z, 0-9 and single hyphens.`);
130
+ }
131
+ const courseDir = join(cwd, 'learning', slug);
132
+ if (!existsSync(join(courseDir, 'COURSE.md'))) {
133
+ throw new Error(`No course at learning/${slug}/.`);
134
+ }
135
+
136
+ let warning;
137
+ const root = tryGit(cwd, ['rev-parse', '--show-toplevel']);
138
+ if (root) {
139
+ try {
140
+ excludeRepoPath(root, cwd, join(cwd, '.course_archive'));
141
+ } catch (err) {
142
+ warning = `Could not add .course_archive/ to git info/exclude: ${detail(err)}`;
143
+ }
144
+ }
145
+
146
+ const target = nextFreePath(join(cwd, '.course_archive', slug));
147
+ cpSync(courseDir, target, {
148
+ recursive: true,
149
+ filter: (source) => basename(source) !== '.git',
150
+ });
151
+ verify(courseDir, target);
152
+
153
+ const worktree = root
154
+ ? listWorktrees(root).find((tree) => tree.path === realpathSync.native(courseDir))
155
+ : null;
156
+ if (worktree) {
157
+ const result = archiveProgramming({ root, cwd, slug, courseDir, branch: worktree.branch, target });
158
+ return warning ? { ...result, warning } : result;
159
+ }
160
+
161
+ rmSync(courseDir, { recursive: true });
162
+ const result = { archivedTo: relative(cwd, target), branch: null, removed: true };
163
+ return warning ? { ...result, warning } : result;
164
+ }
165
+
166
+ function positionals(args) {
167
+ return args.filter((arg) => !arg.startsWith('-'));
168
+ }
169
+
170
+ /** CLI entry point for `skillforce archive`. */
171
+ export async function run({ args = [], cwd = process.cwd() } = {}) {
172
+ const slug = positionals(args)[0];
173
+ const json = args.includes('--json');
174
+ try {
175
+ const result = archiveCourse({ cwd, slug });
176
+ if (json) {
177
+ console.log(JSON.stringify({
178
+ archivedTo: result.archivedTo,
179
+ branch: result.branch,
180
+ removed: result.removed,
181
+ }));
182
+ return;
183
+ }
184
+ console.log(style('success', `Archived learning/${slug}/ → ${result.archivedTo}`));
185
+ if (result.branch) console.log(style('info', `History kept on branch ${result.branch}.`));
186
+ if (result.warning) console.log(style('warning', result.warning));
187
+ } catch (err) {
188
+ if (json) console.log(JSON.stringify({ error: err.message }));
189
+ else console.error(style('error', err.message));
190
+ process.exitCode = 1;
191
+ }
192
+ }