lantern-harness 0.1.45 → 0.2.3

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 (274) hide show
  1. package/CHANGELOG.md +242 -0
  2. package/README.md +25 -8
  3. package/builtin/case-backup-contract.mjs +27 -0
  4. package/builtin/case-workflow-contract.mjs +158 -0
  5. package/builtin/session/lh-fs.mjs +93 -4
  6. package/builtin/session/lh-nav-groups.mjs +36 -1
  7. package/builtin/session/mcp-client.mjs +7 -3
  8. package/builtin/session/session-runs.mjs +5 -1
  9. package/builtin/session/skill-validation.mjs +72 -0
  10. package/builtin/session/space-layout.mjs +8 -1
  11. package/builtin/session/space-skills.mjs +758 -0
  12. package/cli/data-root.mjs +21 -4
  13. package/cli/lantern.mjs +26 -1
  14. package/cli/mcp-server.mjs +3733 -0
  15. package/cli/server.mjs +10 -2
  16. package/config/app.defaults.json +4 -2
  17. package/dist/500.html +14 -6
  18. package/dist/_astro/Base.BQf1tZMl.css +1 -0
  19. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.Dm3O_y-S.js +2 -0
  20. package/dist/_astro/BusinessMapBoard.CYxHcku_.js +5 -0
  21. package/dist/_astro/CaseExecBoard.CK9aGPmH.js +1 -0
  22. package/dist/_astro/CaseExecutionBoard.C94pmIMQ.js +5 -0
  23. package/dist/_astro/CaseGenerateApp.D5xlk9At.js +10 -0
  24. package/dist/_astro/CasesLibrary.BHQC955x.js +21 -0
  25. package/dist/_astro/ChatApp.CIt15w_1.js +1 -0
  26. package/dist/_astro/ChatApp.d4a9R3YS.js +262 -0
  27. package/dist/_astro/{ConfirmDialog.DrrPf1MB.js → ConfirmDialog.DQFd6g2r.js} +1 -1
  28. package/dist/_astro/DashboardBoard.qgc1s7pG.js +5 -0
  29. package/dist/_astro/{DatePicker.Bkl71M49.js → DatePicker.BRO_CjVQ.js} +1 -1
  30. package/dist/_astro/DefectSubmitEntry.JI85N1-i.js +2 -0
  31. package/dist/_astro/DocsFileBrowser.z5JZ74cy.js +1 -0
  32. package/dist/_astro/{DocsPager.Duf4I68E.js → DocsPager.Dg765uHW.js} +1 -1
  33. package/dist/_astro/{DrawerField.BH3p4Q4D.js → DrawerField.CLdvmHc6.js} +1 -1
  34. package/dist/_astro/KnowledgeLibrary.mkShtVun.js +1 -0
  35. package/dist/_astro/LifeKrTasksBoard.DpAwQffE.js +1 -0
  36. package/dist/_astro/LifeKrTodosBoard.BIjPiZ8H.js +1 -0
  37. package/dist/_astro/LifeObjectivesBoard.DYwLHPEG.js +1 -0
  38. package/dist/_astro/LifePlanTypeSelect.CYaziESp.js +1 -0
  39. package/dist/_astro/{LifeReviewsBoard.BPXeVpg1.js → LifeReviewsBoard.DIxoWBDA.js} +3 -3
  40. package/dist/_astro/{LifeShared.tnT7aQON.js → LifeShared.DuFQsMEx.js} +2 -2
  41. package/dist/_astro/LifeStagesBoard.DtOri9EW.js +1 -0
  42. package/dist/_astro/LifeYearCycleSelect.ByJ9-PGg.js +1 -0
  43. package/dist/_astro/LifeYearPlansBoard.BQN07wcv.js +1 -0
  44. package/dist/_astro/MultiSelectDropdown.D-rbpivp.js +1 -0
  45. package/dist/_astro/{NamePromptDialog.Csfnh5eM.js → NamePromptDialog.KPCeXmri.js} +1 -1
  46. package/dist/_astro/NavLibraries.BO4ezcUc.js +1 -0
  47. package/dist/_astro/PluginsPage.B1VeDtLx.js +18 -0
  48. package/dist/_astro/PmBugsBoard.Ddl3kqqt.js +1 -0
  49. package/dist/_astro/PmIterationsBoard.BJN7disI.js +1 -0
  50. package/dist/_astro/{PmProjectDetail.DneFVBpy.js → PmProjectDetail.D78gWhqk.js} +1 -1
  51. package/dist/_astro/PmProjectsBoard.Bf8VB3t6.js +1 -0
  52. package/dist/_astro/PmRequirementsBoard.CDyNHN2a.js +1 -0
  53. package/dist/_astro/PmRequirementsBoard.DarfGIrL.js +1 -0
  54. package/dist/_astro/PmShared.TOjBbtV8.js +1 -0
  55. package/dist/_astro/ReportsPage.BXGduuY3.js +1 -0
  56. package/dist/_astro/ReqAnalysisBoard.WLtIfBg8.js +39 -0
  57. package/dist/_astro/RequirementBreakdownLibrary.DMoeTeqX.js +2 -0
  58. package/dist/_astro/RequirementsLibrary.Iv7zOqWe.js +1 -0
  59. package/dist/_astro/SearchableSelect.DXclLMJI.js +1 -0
  60. package/dist/_astro/SelectDropdown.D7IeyHDI.js +1 -0
  61. package/dist/_astro/SettingsDialog.BvDU9EU6.js +1 -0
  62. package/dist/_astro/SlideOverDrawer.CvyB-quk.js +1 -0
  63. package/dist/_astro/SpaceSwitcher.D9bBNQBZ.js +7 -0
  64. package/dist/_astro/{TableFieldConfig.C7O-mL-p.js → TableFieldConfig.DHj25OKN.js} +1 -1
  65. package/dist/_astro/{TagSelect.UUXgkMqJ.js → TagSelect.B_r2p0fp.js} +1 -1
  66. package/dist/_astro/TasksBoard.CXmGdylV.js +1 -0
  67. package/dist/_astro/TemplatesLibrary.DsL2q-wp.js +1 -0
  68. package/dist/_astro/TestReportsLibrary.BBC1TYgP.js +1 -0
  69. package/dist/_astro/TestStatsBoard.VXjP4hu6.js +1 -0
  70. package/dist/_astro/Toast.BydY-X7T.js +1 -0
  71. package/dist/_astro/TodosBoard.-yKgp06M.js +1 -0
  72. package/dist/_astro/UiAutoBoard.BD5ZyLHj.js +3 -0
  73. package/dist/_astro/UiAutoEnvPanel.DrHUOlmH.js +10 -0
  74. package/dist/_astro/UiAutoGenerationDialog.gypq1zP9.js +12 -0
  75. package/dist/_astro/UiAutoProjectsPage.Dhzr09E9.js +3 -0
  76. package/dist/_astro/app-config.BSO5r82v.js +1 -0
  77. package/dist/_astro/app-version.CkDFkv4s.js +1 -0
  78. package/dist/_astro/{bash-tools.D9HCzC_7.js → bash-tools.C4DJiRJs.js} +1 -1
  79. package/dist/_astro/business-map.BiJ85oxm.js +1 -0
  80. package/dist/_astro/business-map.DKwdW1VL.css +1 -0
  81. package/dist/_astro/case-fields.C03NY3zC.js +148 -0
  82. package/dist/_astro/case-gen-run.C4p8uyU3.js +26 -0
  83. package/dist/_astro/case-prompt.ByLTgz4r.js +2 -0
  84. package/dist/_astro/{case-review.TdDs1WFM.js → case-review.BodP2jKm.js} +2 -2
  85. package/dist/_astro/{case-template.Cd2xNbgy.js → case-template.CC2eXegU.js} +2 -2
  86. package/dist/_astro/case-types.BjF1BivA.js +1 -0
  87. package/dist/_astro/case-workflow-contract.BBQ9bbKL.js +1 -0
  88. package/dist/_astro/defect-submit.Dc49lFjm.css +1 -0
  89. package/dist/_astro/defect-workbench.DBmohR-y.js +6 -0
  90. package/dist/_astro/dialog.XgRGNF_Q.js +1 -0
  91. package/dist/_astro/doc-roots.C-20VD0x.js +1 -0
  92. package/dist/_astro/{hydrate-cache.B15Nrpq0.js → hydrate-cache.CMMErx63.js} +1 -1
  93. package/dist/_astro/i18n.CEWjL5GX.js +7 -0
  94. package/dist/_astro/{llm.DN5S1KBK.js → llm.BCYNgppW.js} +1 -1
  95. package/dist/_astro/mcp-tools.Kf-lupGn.js +7 -0
  96. package/dist/_astro/{open-docs-in-session.CRiZT022.js → open-docs-in-session.BoyV6R2A.js} +1 -1
  97. package/dist/_astro/plugins.ChGmBEkF.js +1 -0
  98. package/dist/_astro/project-docs.BRgNjXhG.js +1 -0
  99. package/dist/_astro/prompts-meta.VAjE4OET.js +2 -0
  100. package/dist/_astro/report-prompt.CwHuOcRN.js +1 -0
  101. package/dist/_astro/req-analysis.BLvcktvQ.js +31 -0
  102. package/dist/_astro/requirement-breakdown-library.l0rPd7b3.js +1 -0
  103. package/dist/_astro/{settings.38J2uD5M.js → settings.BojKNwUC.js} +2 -2
  104. package/dist/_astro/space-skills.CPucW8zt.js +1 -0
  105. package/dist/_astro/{spaces-client.DV04tRyD.js → spaces-client.B28rzu8J.js} +1 -1
  106. package/dist/_astro/story-review.dEBWTeOW.js +7 -0
  107. package/dist/_astro/test-points.BuNgdNcU.js +8 -0
  108. package/dist/_astro/test-reports.0gr6-c_0.js +19 -0
  109. package/dist/_astro/ui-auto-prompt.BmO3ja2m.js +8 -0
  110. package/dist/_astro/ui-auto.LUcREUMe.js +1 -0
  111. package/dist/_astro/{view-prefs.DhdLZjGh.js → view-prefs.CWc5cQ2q.js} +1 -1
  112. package/dist/business-map/index.html +988 -0
  113. package/dist/case-exec/index.html +15 -7
  114. package/dist/{prompts → case-execution}/index.html +17 -9
  115. package/dist/cases/api/index.html +988 -0
  116. package/dist/cases/automation/index.html +988 -0
  117. package/dist/cases/functional/index.html +988 -0
  118. package/dist/cases/generate/index.html +14 -6
  119. package/dist/cases/index.html +1 -1
  120. package/dist/cases/library/index.html +1 -980
  121. package/dist/cases/other/index.html +988 -0
  122. package/dist/cases/performance/index.html +988 -0
  123. package/dist/dashboard/index.html +15 -7
  124. package/dist/defect-rules/index.html +695 -0
  125. package/dist/defect-submit/index.html +695 -0
  126. package/dist/defect-submit/templates/index.html +695 -0
  127. package/dist/docs/changelog/index.html +289 -52
  128. package/dist/docs/install/index.html +50 -12
  129. package/dist/docs/manual/index.html +230 -82
  130. package/dist/knowledge/index.html +15 -7
  131. package/dist/life/kr-tasks/index.html +15 -7
  132. package/dist/life/kr-todos/index.html +15 -7
  133. package/dist/life/objectives/index.html +15 -7
  134. package/dist/life/reviews/index.html +15 -7
  135. package/dist/life/stages/index.html +15 -7
  136. package/dist/life/year-plans/index.html +15 -7
  137. package/dist/plugins/index.html +15 -7
  138. package/dist/pm/bugs/index.html +15 -7
  139. package/dist/pm/iterations/index.html +15 -7
  140. package/dist/pm/projects/detail/index.html +15 -7
  141. package/dist/pm/projects/index.html +15 -7
  142. package/dist/pm/requirements/index.html +15 -7
  143. package/dist/reports/index.html +15 -7
  144. package/dist/requirement-analysis/index.html +15 -7
  145. package/dist/requirement-breakdowns/index.html +988 -0
  146. package/dist/requirements/index.html +15 -7
  147. package/dist/tasks/index.html +15 -7
  148. package/dist/templates/index.html +15 -7
  149. package/dist/test-automation/index.html +15 -7
  150. package/dist/test-automation/projects/index.html +15 -7
  151. package/dist/test-reports/index.html +15 -7
  152. package/dist/test-stats/index.html +15 -7
  153. package/dist/todos/index.html +15 -7
  154. package/dist/workbench/index.html +14 -6
  155. package/docs/Codex-MCP/351/233/206/346/210/220.md +340 -0
  156. package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/204/344/274/260.md +39 -0
  157. package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/206/345/210/253/351/207/215/346/236/204/346/226/271/346/241/210.md +88 -0
  158. package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +28 -3
  159. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +41 -1
  160. package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +65 -17
  161. package/docs//346/217/222/344/273/266/344/273/223/345/272/223/344/270/216/346/212/200/350/203/275/346/225/264/345/220/210/346/226/271/346/241/210.md +187 -0
  162. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +219 -74
  163. package/lh-plugins/business-map/assistant.mjs +958 -0
  164. package/lh-plugins/business-map/auth-paths.mjs +61 -0
  165. package/lh-plugins/business-map/jobs.mjs +749 -0
  166. package/lh-plugins/business-map/login.mjs +295 -0
  167. package/lh-plugins/business-map/sources.mjs +1014 -0
  168. package/lh-plugins/case-automation/service.mjs +921 -0
  169. package/lh-plugins/case-automation/store.mjs +231 -0
  170. package/lh-plugins/case-automation/tables.mjs +115 -0
  171. package/lh-plugins/case-automation-prompt.mjs +57 -0
  172. package/lh-plugins/case-execution/assets.mjs +180 -0
  173. package/lh-plugins/case-execution/files.mjs +829 -0
  174. package/lh-plugins/case-execution/plans.mjs +318 -0
  175. package/lh-plugins/case-execution/service.mjs +1026 -0
  176. package/lh-plugins/case-execution-prompt.mjs +36 -0
  177. package/lh-plugins/lh-business-map.mjs +2431 -0
  178. package/lh-plugins/lh-case-automation.mjs +169 -0
  179. package/lh-plugins/lh-case-design.mjs +456 -0
  180. package/lh-plugins/lh-case-execution.mjs +356 -0
  181. package/lh-plugins/lh-case-review.mjs +29 -11
  182. package/lh-plugins/lh-config.mjs +13 -0
  183. package/lh-plugins/lh-defect-submit.mjs +989 -0
  184. package/lh-plugins/lh-project-docs.mjs +55 -140
  185. package/lh-plugins/lh-reports.mjs +29 -57
  186. package/lh-plugins/lh-req-analysis.mjs +32 -3
  187. package/lh-plugins/lh-req-breakdown-library.mjs +1084 -0
  188. package/lh-plugins/lh-uiauto.mjs +625 -24
  189. package/lh-plugins/plugin-prompts.mjs +20 -15
  190. package/lh-plugins/req-analysis-revision.mjs +24 -0
  191. package/lh-plugins/test-points-prompt.mjs +2 -3
  192. package/lh-plugins/uiauto-adapters/playwright.mjs +44 -4
  193. package/lh-plugins/uiauto-adapters/shared.mjs +4 -0
  194. package/lh-plugins/uiauto-auth-setup.mjs +218 -0
  195. package/lh-plugins/uiauto-explorer/apps.mjs +13 -2
  196. package/lh-plugins/uiauto-explorer/emit-files.mjs +16 -2
  197. package/lh-plugins/uiauto-explorer/ir.mjs +3 -0
  198. package/lh-plugins/uiauto-explorer/merge.mjs +37 -1
  199. package/lh-plugins/uiauto-explorer/navigation-guard.mjs +255 -0
  200. package/lh-plugins/uiauto-explorer/runner.mjs +80 -5
  201. package/lh-plugins/uiauto-explorer/sessions.mjs +334 -18
  202. package/lh-plugins/uiauto-node.mjs +102 -11
  203. package/lh-plugins/uiauto-prompt.mjs +20 -15
  204. package/lh-plugins/uiauto-sso.mjs +407 -0
  205. package/package.json +5 -2
  206. package/skills/case-automation-bridge/SKILL.md +27 -0
  207. package/skills/case-execution/SKILL.md +41 -0
  208. package/skills/lantern-defect-submit/SKILL.md +15 -0
  209. package/skills/lantern-workflow/SKILL.md +95 -0
  210. package/skills/office/SKILL.md +26 -0
  211. package/dist/_astro/Base.Bkt1lrgu.css +0 -1
  212. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.UKTVQqk7.js +0 -2
  213. package/dist/_astro/CaseExecBoard.DICluCbK.js +0 -1
  214. package/dist/_astro/CaseGenerateApp.Be3h5XPG.js +0 -10
  215. package/dist/_astro/CasesLibrary.Buys7Cy-.js +0 -21
  216. package/dist/_astro/ChatApp.D3BheKci.js +0 -227
  217. package/dist/_astro/DashboardBoard.Qvf8o4v1.js +0 -5
  218. package/dist/_astro/DocsFileBrowser.DwKBffbM.js +0 -1
  219. package/dist/_astro/KnowledgeLibrary.MDpMqeOd.js +0 -1
  220. package/dist/_astro/LifeKrTasksBoard.DsvW_S66.js +0 -1
  221. package/dist/_astro/LifeKrTodosBoard.D2KTqvg1.js +0 -1
  222. package/dist/_astro/LifeObjectivesBoard.B0cDK934.js +0 -1
  223. package/dist/_astro/LifePlanTypeSelect.BELDvMWU.js +0 -1
  224. package/dist/_astro/LifeStagesBoard.CZftLR9K.js +0 -1
  225. package/dist/_astro/LifeYearCycleSelect.Bw2eRbSm.js +0 -1
  226. package/dist/_astro/LifeYearPlansBoard.DB-RJFEl.js +0 -1
  227. package/dist/_astro/MultiSelectDropdown.CBC7aNOv.js +0 -1
  228. package/dist/_astro/NavLibraries.DdQYsZbe.js +0 -1
  229. package/dist/_astro/OverflowHint.CHZeFfUj.js +0 -1
  230. package/dist/_astro/PluginsPage.C1JnInH4.js +0 -17
  231. package/dist/_astro/PluginsPage.C3eEwy3K.js +0 -1
  232. package/dist/_astro/PmBugsBoard.CGpXUTPu.js +0 -1
  233. package/dist/_astro/PmIterationsBoard.BaKiFIam.js +0 -1
  234. package/dist/_astro/PmProjectsBoard.BxoMF9gK.js +0 -1
  235. package/dist/_astro/PmRequirementsBoard.-SI8VZXI.js +0 -1
  236. package/dist/_astro/PmRequirementsBoard.DsK6RF7Q.js +0 -1
  237. package/dist/_astro/PmShared.BK8kWRSV.js +0 -1
  238. package/dist/_astro/PromptMountDialog.mrTx3U5T.js +0 -1
  239. package/dist/_astro/PromptsLibrary.B_SUf47p.js +0 -1
  240. package/dist/_astro/ReportsPage.B9lGg1_s.js +0 -16
  241. package/dist/_astro/ReqAnalysisBoard.CIZKnCQH.js +0 -39
  242. package/dist/_astro/RequirementsLibrary.cJc-bnGQ.js +0 -1
  243. package/dist/_astro/SearchableSelect.SyLRS-Jj.js +0 -1
  244. package/dist/_astro/SelectDropdown.T3CKHaLt.js +0 -1
  245. package/dist/_astro/SettingsDialog.DYdtCvLc.js +0 -1
  246. package/dist/_astro/SpaceSwitcher.C47_S1g9.js +0 -7
  247. package/dist/_astro/TasksBoard.BUEg2BYk.js +0 -1
  248. package/dist/_astro/TemplatesLibrary.BLVIphXO.js +0 -1
  249. package/dist/_astro/TestReportsLibrary.DVq30Jae.js +0 -1
  250. package/dist/_astro/TestStatsBoard.-5BWQ6bI.js +0 -1
  251. package/dist/_astro/Toast.BO2NFckG.js +0 -1
  252. package/dist/_astro/TodosBoard.DI_lTp2e.js +0 -1
  253. package/dist/_astro/UiAutoBoard.ChFdgv7s.js +0 -2
  254. package/dist/_astro/UiAutoEnvPanel.B50q4kYb.js +0 -19
  255. package/dist/_astro/UiAutoGenerationDialog.CLkFAHrm.js +0 -1
  256. package/dist/_astro/UiAutoProjectsPage.DCsDeN5d.js +0 -3
  257. package/dist/_astro/app-config.DkyjuL-S.js +0 -1
  258. package/dist/_astro/app-version.Cy-5oZO2.js +0 -1
  259. package/dist/_astro/case-fields.CmePqYfh.js +0 -148
  260. package/dist/_astro/case-gen-run.BklG1H8k.js +0 -22
  261. package/dist/_astro/case-types.DlFkbZJN.js +0 -1
  262. package/dist/_astro/dialog.DZHZCe_T.js +0 -1
  263. package/dist/_astro/doc-roots.CO3IBiY6.js +0 -1
  264. package/dist/_astro/i18n.D_aOCHSN.js +0 -7
  265. package/dist/_astro/markdown-client.BS19nLL3.js +0 -62
  266. package/dist/_astro/plugins.BRvXWHLe.js +0 -1
  267. package/dist/_astro/project-docs.CCjtiFjB.js +0 -1
  268. package/dist/_astro/prompts-meta.BUGutlsk.js +0 -2
  269. package/dist/_astro/report-prompt.B9C4cv84.js +0 -1
  270. package/dist/_astro/req-analysis.B12_MGMQ.js +0 -31
  271. package/dist/_astro/story-review.D2W5tEOY.js +0 -14
  272. package/dist/_astro/test-reports.CuIjlEyK.js +0 -19
  273. package/dist/_astro/ui-auto-prompt.H9_yhau9.js +0 -9
  274. package/dist/_astro/ui-auto.DMv940x4.js +0 -1
@@ -20,6 +20,23 @@ import {
20
20
  } from './fs-observation-policy.mjs';
21
21
  import { convertOfficeToPdf, probeOfficeToPdf } from './office-to-pdf.mjs';
22
22
  import { listWorkspaceSkills, loadWorkspaceSkill } from './skill-fs.mjs';
23
+ import {
24
+ listSpaceSkills,
25
+ loadSpaceSkill,
26
+ migrateSpaceSkills,
27
+ getSpaceSkill,
28
+ updateSpaceSkill,
29
+ createSpaceSkill,
30
+ ensureSpaceSkillSeed,
31
+ restoreSpaceSkill,
32
+ syncPluginSkills,
33
+ setSpaceSkillGroupEnabled,
34
+ validateSpaceSkill,
35
+ skillHistory,
36
+ exportSpaceSkill,
37
+ importSpaceSkill,
38
+ rollbackSkillMigration,
39
+ } from './space-skills.mjs';
23
40
  import { getDataRoot } from './space-context.mjs';
24
41
  import { LOCAL_REL, resolveContentRoot } from './space-layout.mjs';
25
42
  import { loadWorkspaceDependencies } from './workspace-deps.mjs';
@@ -866,7 +883,12 @@ export function lhFsPlugin() {
866
883
  }
867
884
 
868
885
  if (url === `${PREFIX}/skills` && req.method === 'GET') {
869
- const skills = listWorkspaceSkills(workspace, projectRoot);
886
+ const skills = [
887
+ ...listSpaceSkills(projectRoot)
888
+ .filter((x) => x.active)
889
+ .map((x) => ({ ...x, id: x.key })),
890
+ ...listWorkspaceSkills(workspace, projectRoot),
891
+ ];
870
892
  return sendJson(res, 200, { ok: true, count: skills.length, skills });
871
893
  }
872
894
 
@@ -899,6 +921,64 @@ export function lhFsPlugin() {
899
921
 
900
922
  const body = req.method === 'POST' ? JSON.parse((await readBody(req)) || '{}') : {};
901
923
  const access = normalizeAccess(body.access);
924
+ if (url === `${PREFIX}/skill-store` && req.method === 'POST') {
925
+ const { action, id } = body;
926
+ let result;
927
+ if (action === 'migrate') result = migrateSpaceSkills(projectRoot);
928
+ else if (action === 'export') result = { bundle: exportSpaceSkill(projectRoot, id) };
929
+ else if (action === 'import')
930
+ result = { skill: importSpaceSkill(projectRoot, body.bundle) };
931
+ else if (action === 'rollback-migration') result = rollbackSkillMigration(projectRoot);
932
+ else if (action === 'list') result = { skills: listSpaceSkills(projectRoot) };
933
+ else if (action === 'read') result = { skill: getSpaceSkill(projectRoot, id) };
934
+ else if (action === 'save')
935
+ result = { skill: updateSpaceSkill(projectRoot, id, body.patch || {}) };
936
+ else if (action === 'set-enabled')
937
+ result = {
938
+ skills: setSpaceSkillGroupEnabled(
939
+ projectRoot,
940
+ String(body.group || ''),
941
+ body.enabled === true,
942
+ ),
943
+ };
944
+ else if (action === 'create')
945
+ result = { skill: createSpaceSkill(projectRoot, body.name, body.content) };
946
+ else if (action === 'ensure-seed')
947
+ result = ensureSpaceSkillSeed(
948
+ projectRoot,
949
+ body.name,
950
+ body.content,
951
+ String(body.owner || ''),
952
+ );
953
+ else if (action === 'restore')
954
+ result = { skill: restoreSpaceSkill(projectRoot, id, body.version, body.hash) };
955
+ else if (action === 'history') result = { versions: skillHistory(projectRoot, id) };
956
+ else if (action === 'lifecycle')
957
+ result = { skills: syncPluginSkills(projectRoot, body.owner, body.enabled === true) };
958
+ else if (action === 'validate')
959
+ result = validateSpaceSkill(projectRoot, id, body.input);
960
+ else return sendJson(res, 400, { error: '未知技能操作' });
961
+ return sendJson(res, 200, { ...result, ok: result?.ok ?? true });
962
+ }
963
+ if (url === `${PREFIX}/skill/list` && req.method === 'POST') {
964
+ const skills = [
965
+ ...listSpaceSkills(projectRoot)
966
+ .filter((x) => x.active)
967
+ .map((x) => ({ ...x, id: x.key })),
968
+ ...listWorkspaceSkills(workspace, projectRoot),
969
+ ];
970
+ return sendJson(res, 200, { ok: true, count: skills.length, skills });
971
+ }
972
+ if (url === `${PREFIX}/skill/validate` && req.method === 'POST')
973
+ return sendJson(
974
+ res,
975
+ 200,
976
+ validateSpaceSkill(
977
+ projectRoot,
978
+ String(body.id || '').replace(/^space:/, ''),
979
+ body.input,
980
+ ),
981
+ );
902
982
 
903
983
  if (url === `${PREFIX}/workspace` && req.method === 'POST') {
904
984
  const reg = ensureWorkspaceRegistry(projectRoot);
@@ -1133,9 +1213,16 @@ export function lhFsPlugin() {
1133
1213
  });
1134
1214
  }
1135
1215
 
1136
- if (url === `${PREFIX}/skill-load` && req.method === 'POST') {
1216
+ if (
1217
+ [`${PREFIX}/skill-load`, `${PREFIX}/skill/read`].includes(url) &&
1218
+ req.method === 'POST'
1219
+ ) {
1137
1220
  const name = String(body.name ?? body.path ?? body.id ?? '').trim();
1138
- return sendJson(res, 200, loadWorkspaceSkill(workspace, name, projectRoot));
1221
+ return sendJson(
1222
+ res,
1223
+ 200,
1224
+ loadSpaceSkill(projectRoot, name) ?? loadWorkspaceSkill(workspace, name, projectRoot),
1225
+ );
1139
1226
  }
1140
1227
 
1141
1228
  if (url === `${PREFIX}/office-to-pdf` && req.method === 'POST') {
@@ -1312,7 +1399,9 @@ export function lhFsPlugin() {
1312
1399
 
1313
1400
  return sendJson(res, 404, { error: 'not found' });
1314
1401
  } catch (e) {
1315
- return sendJson(res, 500, { error: e instanceof Error ? e.message : String(e) });
1402
+ return sendJson(res, Number(e?.statusCode) || 500, {
1403
+ error: e instanceof Error ? e.message : String(e),
1404
+ });
1316
1405
  }
1317
1406
  });
1318
1407
  },
@@ -27,6 +27,7 @@ import { CASE_EXEC_DIR_NAME, TEST_STATS_DIR_NAME } from '../../lh-plugins/lh-sta
27
27
  import { PM_DIR_NAMES, PM_ENTITY_META } from '../../lh-plugins/lh-pm.mjs';
28
28
  import { LIFE_DIR_NAMES, LIFE_ENTITY_META } from '../../lh-plugins/lh-life.mjs';
29
29
  import { REQ_ANALYSIS_DIR_NAME } from '../../lh-plugins/lh-req-analysis.mjs';
30
+ import { REQ_BREAKDOWN_DIR_NAME } from '../../lh-plugins/lh-req-breakdown-library.mjs';
30
31
  import {
31
32
  UIAUTO_DIR_NAME,
32
33
  UIAUTO_PROJECTS_DIR_NAME,
@@ -110,6 +111,7 @@ const WORK_ITEM_DIR_NAMES = new Map([
110
111
  ['lifeStages', LIFE_ENTITY_META.lifeStages.dir],
111
112
  // 需求分析的分析结果、自动化项目 / 自动化执行的记录与报告
112
113
  ['reqAnalysis', REQ_ANALYSIS_DIR_NAME],
114
+ ['reqBreakdowns', REQ_BREAKDOWN_DIR_NAME],
113
115
  ['uiAuto', UIAUTO_RUNS_DIR_NAME],
114
116
  ['uiAutoProjects', UIAUTO_PROJECTS_DIR_NAME],
115
117
  ]);
@@ -137,6 +139,7 @@ const SKIP_DIR_NAMES = new Set([
137
139
  ...LIFE_DIR_NAMES,
138
140
  // 需求分析 / 自动化项目 / 自动化执行的数据目录,同样是插件的而不是导航分组
139
141
  REQ_ANALYSIS_DIR_NAME,
142
+ REQ_BREAKDOWN_DIR_NAME,
140
143
  UIAUTO_DIR_NAME,
141
144
  UIAUTO_PROJECTS_DIR_NAME,
142
145
  UIAUTO_RUNS_DIR_NAME,
@@ -231,6 +234,9 @@ function nestedContentItems(absDir) {
231
234
  const out = [];
232
235
  for (const name of safeReaddir(absDir)) {
233
236
  if (name.startsWith('.')) continue;
237
+ // 子分组文件夹可能刚好和内容根重名(例如「用例管理」)。
238
+ // 带清单的是分组,不是内容目录;否则父组会把子组的菜单抢走。
239
+ if (readManifest(path.join(absDir, name))) continue;
234
240
  const navId = DIR_ITEM_IDS.get(name);
235
241
  if (!navId) continue;
236
242
  if (isDir(path.join(absDir, name))) out.push(navId);
@@ -524,6 +530,25 @@ function claimName(parentAbs, desired) {
524
530
  return name;
525
531
  }
526
532
 
533
+ /**
534
+ * 顶级同名分组至少应有一个 <分组>/<内容根> 子目录。
535
+ * 兼容历史 / iCloud 冲突产生的「用例管理 2」「用例管理 (2)」,
536
+ * 在同步时收敛回规范目录,避免接口把分组壳当内容根后显示为空。
537
+ */
538
+ function canonicalAdoptedContentDir(root, groupRel, dirName) {
539
+ const groupAbs = path.join(root, groupRel);
540
+ if (!isDir(groupAbs)) return;
541
+ const targetAbs = path.join(groupAbs, dirName);
542
+ const escaped = dirName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
543
+ const duplicateRe = new RegExp(`^${escaped} (?:\\(\\d+\\)|\\d+)$`);
544
+ for (const name of safeReaddir(groupAbs)) {
545
+ if (name === dirName || !duplicateRe.test(name)) continue;
546
+ const abs = path.join(groupAbs, name);
547
+ if (!isDir(abs) || readManifest(abs)) continue;
548
+ moveDir(abs, targetAbs);
549
+ }
550
+ }
551
+
527
552
  /**
528
553
  * 分组采纳保留目录名(分组叫「需求管理」,而「需求管理」本来是插件的数据目录)。
529
554
  *
@@ -796,7 +821,10 @@ export function syncNavGroups(spaceDir, groups) {
796
821
  }
797
822
  const parentAbs = path.join(root, parentNew);
798
823
  const oldAbs = oldRel ? path.join(root, oldRel) : '';
799
- let name = g.name;
824
+ // 子分组同样要避开内容根 / 插件数据目录的同名冲突。
825
+ // 例如「测试管理 → 用例管理」应落成「测试管理/用例管理 (分组)」,
826
+ // 否则分组壳会被解析成用例内容根。
827
+ let name = safeName(g.label);
800
828
  const targetRel = `${parentNew}/${name}`;
801
829
  if (oldRel !== targetRel) {
802
830
  if (fs.existsSync(path.join(parentAbs, name))) name = claimName(parentAbs, name);
@@ -806,6 +834,13 @@ export function syncNavGroups(spaceDir, groups) {
806
834
  newRel.set(g.id, `${parentNew}/${name}`);
807
835
  }
808
836
 
837
+ for (const g of wanted) {
838
+ if (!g.adoptItem) continue;
839
+ const dirName = ITEM_DIR_NAMES.get(g.adoptItem);
840
+ const groupRel = newRel.get(g.id);
841
+ if (dirName && groupRel) canonicalAdoptedContentDir(root, groupRel, dirName);
842
+ }
843
+
809
844
  // 分组 = 物理归档:把组内菜单对应的内容目录搬进分组文件夹,取消分组的搬回空间根。
810
845
  // 必须在写清单 / 删分组之前做:被删掉的分组里的内容要先搬出来,否则会变成「挂在废目录里的数据」。
811
846
  const desiredRel = new Map();
@@ -491,10 +491,10 @@ export async function reconnectMcpServer(root = getDataRoot(), name) {
491
491
  * @param {string} [root]
492
492
  */
493
493
  export async function listMcpTools(root = getDataRoot()) {
494
- await ensureMcpClients(root);
495
- /** @type {Array<{ name: string, description?: string, inputSchema?: object, server: string, remoteName: string }>} */
494
+ const connection = await ensureMcpClients(root);
495
+ /** @type {Array<{ name: string, description?: string, inputSchema?: object, server: string, remoteName: string, annotations?: import('@modelcontextprotocol/sdk/types.js').ToolAnnotations }>} */
496
496
  const tools = [];
497
- const errors = [];
497
+ const errors = [...connection.errors];
498
498
  for (const key of [...toolIndex.keys()]) {
499
499
  if (key.startsWith('mcp__')) toolIndex.delete(key);
500
500
  }
@@ -513,6 +513,7 @@ export async function listMcpTools(root = getDataRoot()) {
513
513
  inputSchema: t.inputSchema || { type: 'object', properties: {} },
514
514
  server: entry.conf.name,
515
515
  remoteName,
516
+ ...(t.annotations ? { annotations: t.annotations } : {}),
516
517
  });
517
518
  }
518
519
  } catch (e) {
@@ -533,6 +534,7 @@ export async function listMcpTools(root = getDataRoot()) {
533
534
  * @param {string} toolName mcp__server__tool
534
535
  * @param {unknown} args
535
536
  * @param {string} [root]
537
+ * @returns {Promise<{ok: boolean, error?: string, text?: string, isError?: boolean, content?: any[], structuredContent?: object}>}
536
538
  */
537
539
  export async function callMcpTool(toolName, args, root = getDataRoot()) {
538
540
  const name = String(toolName || '');
@@ -565,6 +567,8 @@ export async function callMcpTool(toolName, args, root = getDataRoot()) {
565
567
  ok: result?.isError ? false : true,
566
568
  text: text.slice(0, 80_000),
567
569
  isError: Boolean(result?.isError),
570
+ content,
571
+ ...(result?.structuredContent ? { structuredContent: result.structuredContent } : {}),
568
572
  };
569
573
  } catch (e) {
570
574
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
@@ -660,7 +660,11 @@ async function runToolLoopback(origin, name, argsJson, ctx) {
660
660
  if (name.startsWith('skill_')) {
661
661
  const data = await loopbackPost(
662
662
  origin,
663
- name === 'skill_list' ? '/__tb_fs/skill/list' : '/__tb_fs/skill/read',
663
+ name === 'skill_list'
664
+ ? '/__tb_fs/skill/list'
665
+ : name === 'skill_validate'
666
+ ? '/__tb_fs/skill/validate'
667
+ : '/__tb_fs/skill/read',
664
668
  { ...args, access },
665
669
  signal,
666
670
  );
@@ -0,0 +1,72 @@
1
+ /** 技能输出的确定性校验;不调用模型、不执行用户代码。也可复制到技能包独立运行。 */
2
+ export function validateSkillOutput(input = {}) {
3
+ if (!input || typeof input !== 'object' || Array.isArray(input))
4
+ return { ok: false, errors: ['输入必须是对象'], warnings: [] };
5
+ const errors = [],
6
+ warnings = [];
7
+ const rows = input.rows ?? input.用例 ?? input.items;
8
+ if (!Array.isArray(rows))
9
+ return { ok: false, errors: ['需要 rows / 用例 / items 数组'], warnings };
10
+ const columns = Array.isArray(input.columns) ? input.columns : [];
11
+ const known = new Set(input.sourceIds ?? []),
12
+ ids = new Set();
13
+ rows.forEach((row, index) => {
14
+ const at = `第 ${index + 1} 项`;
15
+ if (!row || typeof row !== 'object' || Array.isArray(row)) {
16
+ errors.push(`${at}不是对象`);
17
+ return;
18
+ }
19
+ if (columns.length) {
20
+ const missing = columns.filter((key) => !(key in row));
21
+ const extra = Object.keys(row).filter((key) => !columns.includes(key));
22
+ if (missing.length) errors.push(`${at}缺少字段:${missing.join('、')}`);
23
+ if (extra.length) errors.push(`${at}多出字段:${extra.join('、')}`);
24
+ }
25
+ const id = row.id ?? row['用例编号'] ?? row.code;
26
+ if (id != null && String(id).trim()) {
27
+ if (ids.has(String(id))) errors.push(`${at}编号重复:${id}`);
28
+ ids.add(String(id));
29
+ }
30
+ const refs = row.sourceRefs ?? row.sourceIds ?? [];
31
+ if (!Array.isArray(refs)) errors.push(`${at}来源引用必须是数组`);
32
+ else if (known.size)
33
+ for (const ref of refs) if (!known.has(ref)) errors.push(`${at}引用不存在:${ref}`);
34
+ if (row.priority != null && !['P0', 'P1', 'P2', 'P3'].includes(row.priority))
35
+ errors.push(`${at}优先级应为 P0–P3`);
36
+ if (row.score != null && (!Number.isFinite(row.score) || row.score < 0 || row.score > 100))
37
+ errors.push(`${at}分数应在 0–100`);
38
+ for (const [key, allowed] of Object.entries(input.enums ?? {})) {
39
+ if (key in row && Array.isArray(allowed) && !allowed.includes(row[key]))
40
+ errors.push(`${at}${key}不在允许值内`);
41
+ }
42
+ });
43
+ if (input.stats) {
44
+ const { total, passed, failed, skipped = 0 } = input.stats;
45
+ if (![total, passed, failed, skipped].every((x) => Number.isInteger(x) && x >= 0))
46
+ errors.push('统计数量必须是非负整数');
47
+ else if (passed + failed + skipped !== total) errors.push('通过、失败、跳过之和不等于总数');
48
+ }
49
+
50
+ if (Array.isArray(input.requiredSections)) {
51
+ const sections = Array.isArray(input.sections) ? input.sections : [];
52
+ for (const section of input.requiredSections)
53
+ if (!sections.includes(section)) errors.push(`缺少章节:${section}`);
54
+ }
55
+ if (Array.isArray(input.metrics))
56
+ for (const metric of input.metrics) {
57
+ if (!metric || !Number.isFinite(metric.value) || metric.value < 0)
58
+ errors.push('指标必须具有非负实测数值');
59
+ if (!metric?.unit || typeof metric.unit !== 'string') errors.push('指标缺少单位');
60
+ if (metric?.threshold == null)
61
+ warnings.push(`指标 ${metric?.name || ''} 未提供阈值,不判断达标`);
62
+ }
63
+ if (Array.isArray(input.requiredFiles))
64
+ for (const file of input.requiredFiles) {
65
+ if (!Array.isArray(input.files) || !input.files.includes(file))
66
+ errors.push(`缺少项目文件:${file}`);
67
+ }
68
+ if (!columns.length) warnings.push('未提供模板字段,未检查表头一致性');
69
+ if (!known.size) warnings.push('未提供合法来源 ID,未检查引用有效性');
70
+ if (!rows.length) warnings.push('输出为空,请检查输入材料和未覆盖说明');
71
+ return { ok: errors.length === 0, errors, warnings, count: rows.length };
72
+ }
@@ -218,5 +218,12 @@ export function resolveContentRoot(spaceDir, dirName) {
218
218
  // 不存在就继续找
219
219
  }
220
220
  }
221
- return { abs: path.join(root, leaf), rel: leaf, grouped: false };
221
+ const rootAbs = path.join(root, leaf);
222
+ // 顶级分组名与内容根同名时,分组目录本身不能当内容根。
223
+ // 内容必须是分组内的同名子目录,否则「用例管理/.group.json」
224
+ // 会被误当成用例库,真实文件放在下一层时页面就会为空。
225
+ if (isGroupDir(rootAbs)) {
226
+ return { abs: path.join(rootAbs, leaf), rel: `${leaf}/${leaf}`, grouped: true };
227
+ }
228
+ return { abs: rootAbs, rel: leaf, grouped: false };
222
229
  }