lantern-harness 0.1.45 → 0.2.2

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 (244) hide show
  1. package/CHANGELOG.md +215 -0
  2. package/README.md +25 -8
  3. package/builtin/session/lh-fs.mjs +93 -4
  4. package/builtin/session/lh-nav-groups.mjs +3 -0
  5. package/builtin/session/mcp-client.mjs +7 -3
  6. package/builtin/session/session-runs.mjs +5 -1
  7. package/builtin/session/skill-validation.mjs +72 -0
  8. package/builtin/session/space-skills.mjs +751 -0
  9. package/cli/data-root.mjs +21 -4
  10. package/cli/lantern.mjs +26 -1
  11. package/cli/mcp-server.mjs +2779 -0
  12. package/cli/server.mjs +8 -2
  13. package/config/app.defaults.json +4 -2
  14. package/dist/500.html +9 -6
  15. package/dist/_astro/Base.Du_-4L-4.css +1 -0
  16. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.XUV2H6ea.js +2 -0
  17. package/dist/_astro/BusinessMapBoard.mRxl2G3D.js +5 -0
  18. package/dist/_astro/CaseExecBoard.Cqkxuf5c.js +1 -0
  19. package/dist/_astro/CaseExecutionBoard.CjX4CoKd.js +5 -0
  20. package/dist/_astro/CaseGenerateApp.acgnxl79.js +10 -0
  21. package/dist/_astro/CasesLibrary.zmzOQwdn.js +21 -0
  22. package/dist/_astro/ChatApp.Ben9LFra.js +1 -0
  23. package/dist/_astro/ChatApp.DBi6q7Qv.js +262 -0
  24. package/dist/_astro/{ConfirmDialog.DrrPf1MB.js → ConfirmDialog.DQFd6g2r.js} +1 -1
  25. package/dist/_astro/DashboardBoard.CAJVE2G4.js +5 -0
  26. package/dist/_astro/{DatePicker.Bkl71M49.js → DatePicker.BRO_CjVQ.js} +1 -1
  27. package/dist/_astro/DefectSubmitEntry.BzKXJ-zq.js +2 -0
  28. package/dist/_astro/DocsFileBrowser.apKMbGVf.js +1 -0
  29. package/dist/_astro/{DocsPager.Duf4I68E.js → DocsPager.DMN9-Tjg.js} +1 -1
  30. package/dist/_astro/{DrawerField.BH3p4Q4D.js → DrawerField.CLdvmHc6.js} +1 -1
  31. package/dist/_astro/KnowledgeLibrary.BcoMQeUd.js +1 -0
  32. package/dist/_astro/LifeKrTasksBoard.DJU0-QI-.js +1 -0
  33. package/dist/_astro/LifeKrTodosBoard.GK7KRAO3.js +1 -0
  34. package/dist/_astro/LifeObjectivesBoard.DuKa6Q3k.js +1 -0
  35. package/dist/_astro/LifePlanTypeSelect.Cm2lUmnH.js +1 -0
  36. package/dist/_astro/{LifeReviewsBoard.BPXeVpg1.js → LifeReviewsBoard.BWOOVMtz.js} +3 -3
  37. package/dist/_astro/{LifeShared.tnT7aQON.js → LifeShared.bY2l01Ha.js} +2 -2
  38. package/dist/_astro/LifeStagesBoard.CIzxPOJB.js +1 -0
  39. package/dist/_astro/LifeYearCycleSelect.BlsyPmmI.js +1 -0
  40. package/dist/_astro/LifeYearPlansBoard.DaA9O08j.js +1 -0
  41. package/dist/_astro/MultiSelectDropdown.D-rbpivp.js +1 -0
  42. package/dist/_astro/{NamePromptDialog.Csfnh5eM.js → NamePromptDialog.KPCeXmri.js} +1 -1
  43. package/dist/_astro/NavLibraries.DVR5Ua-S.js +1 -0
  44. package/dist/_astro/PluginsPage.B063QIlQ.js +18 -0
  45. package/dist/_astro/PmBugsBoard.Cu-v0Gfd.js +1 -0
  46. package/dist/_astro/PmIterationsBoard.CgRzkP-j.js +1 -0
  47. package/dist/_astro/{PmProjectDetail.DneFVBpy.js → PmProjectDetail.DVCEh0Lm.js} +1 -1
  48. package/dist/_astro/PmProjectsBoard.z-bQa98r.js +1 -0
  49. package/dist/_astro/PmRequirementsBoard.B0W6bsW2.js +1 -0
  50. package/dist/_astro/PmRequirementsBoard.CyfBI0u_.js +1 -0
  51. package/dist/_astro/PmShared.BQVzwsiz.js +1 -0
  52. package/dist/_astro/ReportsPage.najSzJeT.js +1 -0
  53. package/dist/_astro/ReqAnalysisBoard.BQb8dHFD.js +39 -0
  54. package/dist/_astro/RequirementBreakdownLibrary.Cn6OV6xt.js +2 -0
  55. package/dist/_astro/RequirementsLibrary.CqKNFVsP.js +1 -0
  56. package/dist/_astro/SearchableSelect.DXclLMJI.js +1 -0
  57. package/dist/_astro/SelectDropdown.D7IeyHDI.js +1 -0
  58. package/dist/_astro/SettingsDialog.db3BpFw0.js +1 -0
  59. package/dist/_astro/SlideOverDrawer.BMg2tce6.js +1 -0
  60. package/dist/_astro/SpaceSwitcher.DSUVAPOi.js +7 -0
  61. package/dist/_astro/{TableFieldConfig.C7O-mL-p.js → TableFieldConfig.72AL-8p-.js} +1 -1
  62. package/dist/_astro/{TagSelect.UUXgkMqJ.js → TagSelect.B_r2p0fp.js} +1 -1
  63. package/dist/_astro/TasksBoard.CCDhCSR7.js +1 -0
  64. package/dist/_astro/TemplatesLibrary.peYzrHZ2.js +1 -0
  65. package/dist/_astro/TestReportsLibrary.fWiEyCRx.js +1 -0
  66. package/dist/_astro/TestStatsBoard.BSUBsWSu.js +1 -0
  67. package/dist/_astro/Toast.BydY-X7T.js +1 -0
  68. package/dist/_astro/TodosBoard.By5YdlUe.js +1 -0
  69. package/dist/_astro/UiAutoBoard.BGdlp5Sr.js +3 -0
  70. package/dist/_astro/UiAutoEnvPanel.BUASgPLB.js +10 -0
  71. package/dist/_astro/UiAutoGenerationDialog.D1PyCgrD.js +12 -0
  72. package/dist/_astro/UiAutoProjectsPage.B6A9NlVK.js +3 -0
  73. package/dist/_astro/app-config.Dvfzl5_N.js +1 -0
  74. package/dist/_astro/app-version.CNpnKIb9.js +1 -0
  75. package/dist/_astro/{bash-tools.D9HCzC_7.js → bash-tools.CS2w8LOb.js} +1 -1
  76. package/dist/_astro/business-map.BiJ85oxm.js +1 -0
  77. package/dist/_astro/business-map.DKwdW1VL.css +1 -0
  78. package/dist/_astro/case-gen-run.Cvvdv_kv.js +26 -0
  79. package/dist/_astro/case-prompt.CZ3vWUju.js +2 -0
  80. package/dist/_astro/{case-review.TdDs1WFM.js → case-review.DFWZkoR9.js} +1 -1
  81. package/dist/_astro/{case-template.Cd2xNbgy.js → case-template.Clb7HrDB.js} +1 -1
  82. package/dist/_astro/defect-submit.Dc49lFjm.css +1 -0
  83. package/dist/_astro/defect-workbench.CjTb4FDv.js +6 -0
  84. package/dist/_astro/dialog.XgRGNF_Q.js +1 -0
  85. package/dist/_astro/doc-roots.C-20VD0x.js +1 -0
  86. package/dist/_astro/{hydrate-cache.B15Nrpq0.js → hydrate-cache.O4CIma9y.js} +1 -1
  87. package/dist/_astro/i18n.Cp4so7KR.js +7 -0
  88. package/dist/_astro/{llm.DN5S1KBK.js → llm.BCYNgppW.js} +1 -1
  89. package/dist/_astro/mcp-tools.Kf-lupGn.js +7 -0
  90. package/dist/_astro/{open-docs-in-session.CRiZT022.js → open-docs-in-session.BpcAcBSI.js} +1 -1
  91. package/dist/_astro/plugins.Db9xoFZb.js +1 -0
  92. package/dist/_astro/project-docs.bB9lQ1Ki.js +1 -0
  93. package/dist/_astro/prompts-meta.VAjE4OET.js +2 -0
  94. package/dist/_astro/report-prompt.CwHuOcRN.js +1 -0
  95. package/dist/_astro/req-analysis.C_gARMrB.js +31 -0
  96. package/dist/_astro/requirement-breakdown-library.l0rPd7b3.js +1 -0
  97. package/dist/_astro/{settings.38J2uD5M.js → settings.D02wZj3w.js} +2 -2
  98. package/dist/_astro/space-skills.CPucW8zt.js +1 -0
  99. package/dist/_astro/{spaces-client.DV04tRyD.js → spaces-client.BAtG6PkW.js} +1 -1
  100. package/dist/_astro/story-review.DTN91Vl9.js +7 -0
  101. package/dist/_astro/test-points.C7ZgggQT.js +8 -0
  102. package/dist/_astro/test-reports.0gr6-c_0.js +19 -0
  103. package/dist/_astro/ui-auto-prompt.BmO3ja2m.js +8 -0
  104. package/dist/_astro/{view-prefs.DhdLZjGh.js → view-prefs.COAKEQtZ.js} +1 -1
  105. package/dist/business-map/index.html +983 -0
  106. package/dist/case-exec/index.html +10 -7
  107. package/dist/{prompts → case-execution}/index.html +12 -9
  108. package/dist/cases/generate/index.html +9 -6
  109. package/dist/cases/library/index.html +10 -7
  110. package/dist/dashboard/index.html +10 -7
  111. package/dist/defect-rules/index.html +690 -0
  112. package/dist/defect-submit/index.html +690 -0
  113. package/dist/defect-submit/templates/index.html +690 -0
  114. package/dist/docs/changelog/index.html +259 -52
  115. package/dist/docs/install/index.html +44 -12
  116. package/dist/docs/manual/index.html +212 -75
  117. package/dist/knowledge/index.html +10 -7
  118. package/dist/life/kr-tasks/index.html +10 -7
  119. package/dist/life/kr-todos/index.html +10 -7
  120. package/dist/life/objectives/index.html +10 -7
  121. package/dist/life/reviews/index.html +10 -7
  122. package/dist/life/stages/index.html +10 -7
  123. package/dist/life/year-plans/index.html +10 -7
  124. package/dist/plugins/index.html +10 -7
  125. package/dist/pm/bugs/index.html +10 -7
  126. package/dist/pm/iterations/index.html +10 -7
  127. package/dist/pm/projects/detail/index.html +10 -7
  128. package/dist/pm/projects/index.html +10 -7
  129. package/dist/pm/requirements/index.html +10 -7
  130. package/dist/reports/index.html +10 -7
  131. package/dist/requirement-analysis/index.html +10 -7
  132. package/dist/requirement-breakdowns/index.html +983 -0
  133. package/dist/requirements/index.html +10 -7
  134. package/dist/tasks/index.html +10 -7
  135. package/dist/templates/index.html +10 -7
  136. package/dist/test-automation/index.html +10 -7
  137. package/dist/test-automation/projects/index.html +10 -7
  138. package/dist/test-reports/index.html +10 -7
  139. package/dist/test-stats/index.html +10 -7
  140. package/dist/todos/index.html +10 -7
  141. package/dist/workbench/index.html +9 -6
  142. package/docs/Codex-MCP/351/233/206/346/210/220.md +296 -0
  143. package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/204/344/274/260.md +39 -0
  144. 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
  145. package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +22 -3
  146. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +41 -1
  147. package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +63 -17
  148. 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
  149. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +207 -69
  150. package/lh-plugins/business-map/assistant.mjs +958 -0
  151. package/lh-plugins/business-map/auth-paths.mjs +61 -0
  152. package/lh-plugins/business-map/jobs.mjs +749 -0
  153. package/lh-plugins/business-map/login.mjs +295 -0
  154. package/lh-plugins/business-map/sources.mjs +1014 -0
  155. package/lh-plugins/case-execution/files.mjs +777 -0
  156. package/lh-plugins/case-execution/service.mjs +959 -0
  157. package/lh-plugins/case-execution-prompt.mjs +33 -0
  158. package/lh-plugins/lh-business-map.mjs +2431 -0
  159. package/lh-plugins/lh-case-execution.mjs +304 -0
  160. package/lh-plugins/lh-config.mjs +13 -0
  161. package/lh-plugins/lh-defect-submit.mjs +989 -0
  162. package/lh-plugins/lh-project-docs.mjs +31 -140
  163. package/lh-plugins/lh-reports.mjs +29 -57
  164. package/lh-plugins/lh-req-analysis.mjs +32 -3
  165. package/lh-plugins/lh-req-breakdown-library.mjs +1084 -0
  166. package/lh-plugins/lh-uiauto.mjs +514 -22
  167. package/lh-plugins/plugin-prompts.mjs +19 -15
  168. package/lh-plugins/req-analysis-revision.mjs +24 -0
  169. package/lh-plugins/test-points-prompt.mjs +2 -3
  170. package/lh-plugins/uiauto-auth-setup.mjs +218 -0
  171. package/lh-plugins/uiauto-explorer/apps.mjs +13 -2
  172. package/lh-plugins/uiauto-explorer/runner.mjs +15 -2
  173. package/lh-plugins/uiauto-explorer/sessions.mjs +305 -17
  174. package/lh-plugins/uiauto-node.mjs +102 -11
  175. package/lh-plugins/uiauto-prompt.mjs +20 -15
  176. package/lh-plugins/uiauto-sso.mjs +407 -0
  177. package/package.json +5 -2
  178. package/skills/case-execution/SKILL.md +30 -0
  179. package/skills/lantern-defect-submit/SKILL.md +15 -0
  180. package/skills/lantern-workflow/SKILL.md +57 -0
  181. package/skills/office/SKILL.md +26 -0
  182. package/dist/_astro/Base.Bkt1lrgu.css +0 -1
  183. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.UKTVQqk7.js +0 -2
  184. package/dist/_astro/CaseExecBoard.DICluCbK.js +0 -1
  185. package/dist/_astro/CaseGenerateApp.Be3h5XPG.js +0 -10
  186. package/dist/_astro/CasesLibrary.Buys7Cy-.js +0 -21
  187. package/dist/_astro/ChatApp.D3BheKci.js +0 -227
  188. package/dist/_astro/DashboardBoard.Qvf8o4v1.js +0 -5
  189. package/dist/_astro/DocsFileBrowser.DwKBffbM.js +0 -1
  190. package/dist/_astro/KnowledgeLibrary.MDpMqeOd.js +0 -1
  191. package/dist/_astro/LifeKrTasksBoard.DsvW_S66.js +0 -1
  192. package/dist/_astro/LifeKrTodosBoard.D2KTqvg1.js +0 -1
  193. package/dist/_astro/LifeObjectivesBoard.B0cDK934.js +0 -1
  194. package/dist/_astro/LifePlanTypeSelect.BELDvMWU.js +0 -1
  195. package/dist/_astro/LifeStagesBoard.CZftLR9K.js +0 -1
  196. package/dist/_astro/LifeYearCycleSelect.Bw2eRbSm.js +0 -1
  197. package/dist/_astro/LifeYearPlansBoard.DB-RJFEl.js +0 -1
  198. package/dist/_astro/MultiSelectDropdown.CBC7aNOv.js +0 -1
  199. package/dist/_astro/NavLibraries.DdQYsZbe.js +0 -1
  200. package/dist/_astro/OverflowHint.CHZeFfUj.js +0 -1
  201. package/dist/_astro/PluginsPage.C1JnInH4.js +0 -17
  202. package/dist/_astro/PluginsPage.C3eEwy3K.js +0 -1
  203. package/dist/_astro/PmBugsBoard.CGpXUTPu.js +0 -1
  204. package/dist/_astro/PmIterationsBoard.BaKiFIam.js +0 -1
  205. package/dist/_astro/PmProjectsBoard.BxoMF9gK.js +0 -1
  206. package/dist/_astro/PmRequirementsBoard.-SI8VZXI.js +0 -1
  207. package/dist/_astro/PmRequirementsBoard.DsK6RF7Q.js +0 -1
  208. package/dist/_astro/PmShared.BK8kWRSV.js +0 -1
  209. package/dist/_astro/PromptMountDialog.mrTx3U5T.js +0 -1
  210. package/dist/_astro/PromptsLibrary.B_SUf47p.js +0 -1
  211. package/dist/_astro/ReportsPage.B9lGg1_s.js +0 -16
  212. package/dist/_astro/ReqAnalysisBoard.CIZKnCQH.js +0 -39
  213. package/dist/_astro/RequirementsLibrary.cJc-bnGQ.js +0 -1
  214. package/dist/_astro/SearchableSelect.SyLRS-Jj.js +0 -1
  215. package/dist/_astro/SelectDropdown.T3CKHaLt.js +0 -1
  216. package/dist/_astro/SettingsDialog.DYdtCvLc.js +0 -1
  217. package/dist/_astro/SpaceSwitcher.C47_S1g9.js +0 -7
  218. package/dist/_astro/TasksBoard.BUEg2BYk.js +0 -1
  219. package/dist/_astro/TemplatesLibrary.BLVIphXO.js +0 -1
  220. package/dist/_astro/TestReportsLibrary.DVq30Jae.js +0 -1
  221. package/dist/_astro/TestStatsBoard.-5BWQ6bI.js +0 -1
  222. package/dist/_astro/Toast.BO2NFckG.js +0 -1
  223. package/dist/_astro/TodosBoard.DI_lTp2e.js +0 -1
  224. package/dist/_astro/UiAutoBoard.ChFdgv7s.js +0 -2
  225. package/dist/_astro/UiAutoEnvPanel.B50q4kYb.js +0 -19
  226. package/dist/_astro/UiAutoGenerationDialog.CLkFAHrm.js +0 -1
  227. package/dist/_astro/UiAutoProjectsPage.DCsDeN5d.js +0 -3
  228. package/dist/_astro/app-config.DkyjuL-S.js +0 -1
  229. package/dist/_astro/app-version.Cy-5oZO2.js +0 -1
  230. package/dist/_astro/case-gen-run.BklG1H8k.js +0 -22
  231. package/dist/_astro/case-types.DlFkbZJN.js +0 -1
  232. package/dist/_astro/dialog.DZHZCe_T.js +0 -1
  233. package/dist/_astro/doc-roots.CO3IBiY6.js +0 -1
  234. package/dist/_astro/i18n.D_aOCHSN.js +0 -7
  235. package/dist/_astro/markdown-client.BS19nLL3.js +0 -62
  236. package/dist/_astro/plugins.BRvXWHLe.js +0 -1
  237. package/dist/_astro/project-docs.CCjtiFjB.js +0 -1
  238. package/dist/_astro/prompts-meta.BUGutlsk.js +0 -2
  239. package/dist/_astro/report-prompt.B9C4cv84.js +0 -1
  240. package/dist/_astro/req-analysis.B12_MGMQ.js +0 -31
  241. package/dist/_astro/story-review.D2W5tEOY.js +0 -14
  242. package/dist/_astro/test-reports.CuIjlEyK.js +0 -19
  243. package/dist/_astro/ui-auto-prompt.H9_yhau9.js +0 -9
  244. package/dist/_astro/ui-auto.DMv940x4.js +0 -1
@@ -3,11 +3,12 @@
3
3
  * - requirements/ → `/__tb_requirements`(界面:需求文档库)
4
4
  * - cases/ → `/__tb_cases`(界面:用例管理)
5
5
  * - templates/ → `/__tb_templates`(界面:测试模板库)
6
- * - prompts/ → `/__tb_prompts`(界面:提示词管理)
6
+ * - 提示词管理只作为技能迁移兼容目录,不再注册用户页面或文档 API
7
7
  * - knowledge/ → `/__tb_knowledge`(界面:知识库管理)
8
8
  * 支持 list / mkdir / rename / upload / read / delete(进系统废纸篓,非空目录拒绝)/ open;路径不得逃出根目录。
9
9
  */
10
10
  import { execFile } from 'node:child_process';
11
+ import { migratedPromptPath, migrateSpaceSkills } from '../builtin/session/space-skills.mjs';
11
12
  import fs from 'node:fs';
12
13
  import os from 'node:os';
13
14
  import path from 'node:path';
@@ -21,7 +22,6 @@ import {
21
22
  spaceLocalFile,
22
23
  } from '../builtin/session/space-layout.mjs';
23
24
  import { forgetSkippedSeed, isSkippedSeed, rememberSkippedSeed } from '../cli/seed-skip.mjs';
24
- import { pluginPromptLock } from './plugin-prompts.mjs';
25
25
 
26
26
  const execFileAsync = promisify(execFile);
27
27
 
@@ -47,7 +47,7 @@ export async function openLocalPath(absPath) {
47
47
  * - win32:Microsoft.VisualBasic 的 SendToRecycleBin。
48
48
  * - linux:按 freedesktop Trash 规范移动到 ~/.local/share/Trash。
49
49
  */
50
- async function trashLocalPath(absPath) {
50
+ export async function trashLocalPath(absPath) {
51
51
  if (process.platform === 'darwin') {
52
52
  await execFileAsync('osascript', [
53
53
  '-e',
@@ -215,6 +215,23 @@ export function migrateLegacyRoot(projectRoot, legacyNames, dirName) {
215
215
  }
216
216
  }
217
217
 
218
+ /** 兼容旧规则文件名;正文不动,只在目标不存在时改名。 */
219
+ function migratePromptFile(absRoot, fromNames, toName) {
220
+ const dest = path.join(absRoot, toName);
221
+ if (fs.existsSync(dest)) return dest;
222
+ for (const name of fromNames) {
223
+ const source = path.join(absRoot, name);
224
+ if (!fs.existsSync(source)) continue;
225
+ try {
226
+ fs.renameSync(source, dest);
227
+ return dest;
228
+ } catch {
229
+ // 改名失败时保留旧文件,下次再试。
230
+ }
231
+ }
232
+ return dest;
233
+ }
234
+
218
235
  /**
219
236
  * @param {{ prefix: string, dirName: string, name: string, legacyDirNames?: string[], onReady?: (absRoot: string) => void, shared?: boolean, spaceLocalFiles?: string[] }} opts
220
237
  * @returns {import('vite').Plugin}
@@ -491,7 +508,12 @@ function createDocsPlugin(opts) {
491
508
  const opRoot = overlayRoot(rel) || absRoot;
492
509
  const { abs, display } = resolveUnderRoot(opRoot, rel);
493
510
  fs.mkdirSync(path.dirname(abs), { recursive: true });
511
+ if (dirName === '提示词管理' && migratedPromptPath(getDataRoot(), display))
512
+ return sendJson(res, 409, {
513
+ error: '该规则已迁入技能,请在插件仓库中编辑,避免覆盖已有版本',
514
+ });
494
515
  fs.writeFileSync(abs, content, 'utf8');
516
+ if (dirName === '提示词管理') migrateSpaceSkills(getDataRoot());
495
517
  forgetSkippedSeed(seedSkipOwner(display), `${dirName}/${display}`);
496
518
  return sendJson(res, 200, { ok: true, path: display, size: bytes });
497
519
  }
@@ -521,7 +543,12 @@ function createDocsPlugin(opts) {
521
543
  if (url === `${prefix}/read` && req.method === 'POST') {
522
544
  const body = JSON.parse((await readBody(req)).toString('utf8') || '{}');
523
545
  const opRoot = overlayRoot(body.path) || absRoot;
524
- const { abs, display } = resolveUnderRoot(opRoot, body.path);
546
+ const resolved = resolveUnderRoot(opRoot, body.path);
547
+ const display = resolved.display;
548
+ const abs =
549
+ dirName === '提示词管理'
550
+ ? migratedPromptPath(getDataRoot(), display) || resolved.abs
551
+ : resolved.abs;
525
552
  if (!fs.existsSync(abs))
526
553
  return sendJson(res, 404, { error: 'not found', path: display });
527
554
  const st = fs.statSync(abs);
@@ -555,16 +582,6 @@ function createDocsPlugin(opts) {
555
582
  const opRoot = overlayRoot(body.path) || absRoot;
556
583
  const { abs, display } = resolveUnderRoot(opRoot, body.path);
557
584
  if (display === '.') return sendJson(res, 400, { error: '不能删除根目录' });
558
- if (dirName === '提示词管理' && PROTECTED_PROMPT_FILES.has(path.basename(display))) {
559
- return sendJson(res, 403, { error: '默认提示词不可删除', path: display });
560
- }
561
- // 插件开启期间,插件自己维护的提示词也不允许删除(关闭插件后可删)
562
- if (dirName === '提示词管理' && !isSpaceLocalRel(body.path)) {
563
- const lockedReason = pluginPromptLock(display, getDataRoot());
564
- if (lockedReason) {
565
- return sendJson(res, 403, { error: lockedReason, path: display });
566
- }
567
- }
568
585
  if (!fs.existsSync(abs))
569
586
  return sendJson(res, 404, { error: 'not found', path: display });
570
587
  const st = fs.statSync(abs);
@@ -605,16 +622,6 @@ function createDocsPlugin(opts) {
605
622
  ) {
606
623
  return sendJson(res, 400, { error: '无效名称' });
607
624
  }
608
- // 与删除保持一致:默认提示词为受保护文件,不允许改名
609
- if (dirName === '提示词管理' && PROTECTED_PROMPT_FILES.has(path.basename(display))) {
610
- return sendJson(res, 403, { error: '默认提示词不可重命名', path: display });
611
- }
612
- if (dirName === '提示词管理' && !isSpaceLocalRel(body.path)) {
613
- const lockedReason = pluginPromptLock(display, getDataRoot());
614
- if (lockedReason) {
615
- return sendJson(res, 403, { error: lockedReason, path: display });
616
- }
617
- }
618
625
  const st = fs.statSync(abs);
619
626
  // 文件改名须保持允许的扩展名,否则后续无法预览 / 再次上传
620
627
  if (st.isFile()) {
@@ -795,75 +802,6 @@ export function lhTestReportsPlugin() {
795
802
  });
796
803
  }
797
804
 
798
- const CHAT_SYSTEM_PROMPT_FILE = '默认提示词.md';
799
- /** prompts 下禁止删除的文件(含旧名,防止误删) */
800
- const PROTECTED_PROMPT_FILES = new Set([
801
- CHAT_SYSTEM_PROMPT_FILE,
802
- '空间提示词.md',
803
- '空间默认提示词.md',
804
- '系统提示词.md',
805
- 'AI工作台系统提示词.md',
806
- ]);
807
-
808
- const PKG_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
809
- const PROMPT_SEEDS = path.join(PKG_ROOT, 'config', 'seeds', DOC_ROOT_DIRS.prompts.dirName);
810
-
811
- const DEFAULT_CHAT_SYSTEM_PROMPT =
812
- '你是 Lantern Harness 的 AI 助手,协助思考、写作、分析、编程与日常工作。\n';
813
-
814
- /** 把 config/seeds/提示词管理 里缺失的文件补进当前空间(不覆盖已有) */
815
- function plantPromptSeeds(absRoot) {
816
- if (!fs.existsSync(PROMPT_SEEDS)) return;
817
- const publicPrompts = resolveContentRoot(getPublicSpaceRoot(), DOC_ROOT_DIRS.prompts.dirName).abs;
818
- const isPublic = path.resolve(absRoot) === path.resolve(publicPrompts);
819
- const owner = isPublic ? getPublicSpaceRoot() : getDataRoot();
820
- for (const name of fs.readdirSync(PROMPT_SEEDS)) {
821
- if (name.startsWith('.')) continue;
822
- if (!isPublic && name !== CHAT_SYSTEM_PROMPT_FILE) continue;
823
- const from = path.join(PROMPT_SEEDS, name);
824
- const to = path.join(absRoot, name);
825
- try {
826
- if (!fs.statSync(from).isFile() || fs.existsSync(to)) continue;
827
- if (isSkippedSeed(owner, `${DOC_ROOT_DIRS.prompts.dirName}/${name}`)) continue;
828
- copyFileNew(from, to);
829
- } catch {
830
- // 种子只是初始内容:失败不阻断访问
831
- }
832
- }
833
- }
834
-
835
- /** 已废弃的「默认用例提示词」文件名,启动时清理,避免与插件所选提示词混淆 */
836
- const LEGACY_CASE_DEFAULT_NAMES = ['默认用例生成.md', '用例生成默认提示词.md'];
837
-
838
- function migratePromptFile(absRoot, fromNames, toName) {
839
- const dest = path.join(absRoot, toName);
840
- if (fs.existsSync(dest)) {
841
- for (const n of fromNames) {
842
- const p = path.join(absRoot, n);
843
- if (fs.existsSync(p) && p !== dest) {
844
- try {
845
- fs.unlinkSync(p);
846
- } catch {
847
- // ignore
848
- }
849
- }
850
- }
851
- return dest;
852
- }
853
- for (const n of fromNames) {
854
- const p = path.join(absRoot, n);
855
- if (fs.existsSync(p)) {
856
- try {
857
- fs.renameSync(p, dest);
858
- return dest;
859
- } catch {
860
- // ignore
861
- }
862
- }
863
- }
864
- return dest;
865
- }
866
-
867
805
  export function lhKnowledgePlugin() {
868
806
  return createDocsPlugin({
869
807
  prefix: '/__tb_knowledge',
@@ -872,50 +810,3 @@ export function lhKnowledgePlugin() {
872
810
  // 知识库按空间隔离:分类只写在 frontmatter 的 category,不再按分类建子目录
873
811
  });
874
812
  }
875
-
876
- export function lhPromptsPlugin() {
877
- return createDocsPlugin({
878
- prefix: '/__tb_prompts',
879
- ...DOC_ROOT_DIRS.prompts,
880
- name: 'lh-prompts',
881
- // 提示词按空间隔离;新空间只有「默认提示词」
882
- onReady(absRoot) {
883
- // 清理旧版用例生成默认文件名,避免与插件所选提示词混淆
884
- for (const n of LEGACY_CASE_DEFAULT_NAMES) {
885
- const p = path.join(absRoot, n);
886
- if (fs.existsSync(p)) {
887
- try {
888
- fs.unlinkSync(p);
889
- } catch {
890
- // ignore
891
- }
892
- }
893
- }
894
- const chatSeed = migratePromptFile(
895
- absRoot,
896
- ['AI工作台系统提示词.md', '系统提示词.md', '空间默认提示词.md', '空间提示词.md'],
897
- CHAT_SYSTEM_PROMPT_FILE,
898
- );
899
- // 公共空间补齐全部提示词种子;其它空间只保证「默认提示词」
900
- plantPromptSeeds(absRoot);
901
- if (!fs.existsSync(chatSeed)) {
902
- fs.writeFileSync(chatSeed, DEFAULT_CHAT_SYSTEM_PROMPT, 'utf8');
903
- }
904
- // 清理旧版种子目录:提示词管理/功能测试/
905
- const legacyDir = path.join(absRoot, '功能测试');
906
- if (fs.existsSync(legacyDir) && fs.statSync(legacyDir).isDirectory()) {
907
- try {
908
- const names = fs.readdirSync(legacyDir).filter((n) => n !== '.DS_Store');
909
- if (
910
- names.length === 0 ||
911
- (names.length === 1 && LEGACY_CASE_DEFAULT_NAMES.includes(names[0]))
912
- ) {
913
- fs.rmSync(legacyDir, { recursive: true, force: true });
914
- }
915
- } catch {
916
- // ignore
917
- }
918
- }
919
- },
920
- });
921
- }
@@ -1,19 +1,19 @@
1
1
  /**
2
- * 工作汇报插件:开关联动「提示词 + 汇报文件夹」。
2
+ * 工作汇报插件:开关联动「关联技能 + 汇报文件夹」。
3
3
  *
4
- * - 打开:补齐 `提示词管理/工作汇报提示词.md`(已存在不覆盖,保留用户改过的内容),
4
+ * - 打开:补齐工作汇报技能(已存在不覆盖,保留用户改过的内容),
5
5
  * 同时在当前空间铺出 `工作汇报/日报`、`工作汇报/周报`、`工作汇报/月报` 三个目录
6
- * - 关闭:只把插件停用,**提示词文件保留**(下次打开还是原来那份,改过的内容不会丢);
6
+ * - 关闭:只把插件停用,**技能保留**(下次打开还是原来那份,改过的内容不会丢);
7
7
  * 汇报文件夹与里面已有的汇报同样保留
8
8
  *
9
- * 用哪份提示词可以换:状态存在 `.lantern/local/reports.json`,页面上的下拉框直接改;
10
- * 选中的文件被改名或删掉时,自动回退到默认名 / 名字里带「工作汇报」的提示词。
9
+ * 固定使用默认工作汇报技能;状态只记录插件是否开启。
11
10
  *
12
11
  * 汇报列表直接读上面三个目录里的文本文件(.md / .txt / .html),文件就是数据,
13
12
  * 页面上按「生成日期 + 文件名」展示,点文件名用系统默认程序在本地打开(`/__tb_reports/open`);
14
13
  * 删除走 `/__tb_reports/delete`(单条 / 批量,只删当前类型目录内的文件);
15
14
  * `/__tb_reports/file` 仍保留,供其它客户端直接取正文。
16
15
  */
16
+ import { migratedPromptPath, migrateSpaceSkills } from '../builtin/session/space-skills.mjs';
17
17
  import fs from 'node:fs';
18
18
  import path from 'node:path';
19
19
 
@@ -23,7 +23,7 @@ import { DOC_ROOT_DIRS, openLocalPath } from './lh-project-docs.mjs';
23
23
 
24
24
  const PREFIX = '/__tb_reports';
25
25
 
26
- /** 提示词管理里的默认文件名(前端读同一个名字) */
26
+ /** 默认技能兼容路径(前端读同一个名字) */
27
27
  export const REPORT_PROMPT_FILE = '工作汇报提示词.md';
28
28
 
29
29
  /** 汇报根目录与三类子目录:日报 / 周报 / 月报 */
@@ -34,44 +34,44 @@ export const REPORT_KINDS = {
34
34
  month: '月报',
35
35
  };
36
36
 
37
- /** 提示词下拉里不参与选择的文件:空间默认提示词不属于任何插件 */
37
+ /** 技能选择器里不参与选择的文件:空间基础规则不属于普通业务技能 */
38
38
  const RESERVED_PROMPT_FILES = new Set(['默认提示词.md']);
39
39
 
40
40
  const PROMPT_EXTS = new Set(['.md', '.markdown', '.txt']);
41
41
 
42
42
  /**
43
- * 缺文件时写入提示词管理的短种子。
44
- * 运行时整份追加进系统提示词;日常增删改只改空间「提示词管理/工作汇报提示词.md」。
43
+ * 缺文件时写入技能迁移兼容目录的短种子。
44
+ * 运行时整份追加进系统提示词;日常增删改请到「插件仓库 → 技能」。
45
45
  * 完整写法可参考仓库 `prompt/工作汇报提示词.md`。
46
46
  */
47
47
  export const REPORT_PROMPT_TEMPLATE = `# 工作汇报提示词
48
48
 
49
- > 由「工作汇报」插件引用。日常增删改请只改本空间「提示词管理」里的本文件。
49
+ > 由「工作汇报」插件关联。日常增删改请到本空间「插件仓库 → 技能」。
50
50
  > 完整写法可参考仓库 \`prompt/工作汇报提示词.md\`。运行时整份追加进系统提示词。
51
51
 
52
52
  ## 角色
53
53
 
54
- (请在提示词管理中维护汇报角色说明。)
54
+ (请在关联技能中维护汇报角色说明。)
55
55
 
56
56
  ## 任务
57
57
 
58
- (请在提示词管理中维护:按周期生成并 fs_write 落盘。)
58
+ (请在关联技能中维护:按周期生成并 fs_write 落盘。)
59
59
 
60
60
  ## 数据来源
61
61
 
62
- (请在提示词管理中维护数据来源与区间约定。)
62
+ (请在关联技能中维护数据来源与区间约定。)
63
63
 
64
64
  ## 正文结构(按此顺序,不要改成别的模板口径)
65
65
 
66
- (请在提示词管理中维护日报 / 周报 / 月报结构。)
66
+ (请在关联技能中维护日报 / 周报 / 月报结构。)
67
67
 
68
68
  ## 落盘
69
69
 
70
- (请在提示词管理中维护落盘路径约定。)
70
+ (请在关联技能中维护落盘路径约定。)
71
71
 
72
72
  ## 限制
73
73
 
74
- (请在提示词管理中维护限制条款。)
74
+ (请在关联技能中维护限制条款。)
75
75
  `;
76
76
 
77
77
  /** 列表里认的文本文件:其它格式(docx / pdf)交给系统程序打开,不在页面渲染 */
@@ -128,7 +128,7 @@ function kindDir(spaceDir, kind) {
128
128
  * 只有真正写进汇报文件时,才由写入方(fs 工具等)铺出对应目录。
129
129
  */
130
130
 
131
- /* ── 插件状态:开关 + 选中的提示词文件名 ── */
131
+ /* ── 插件状态:开关 ── */
132
132
 
133
133
  function statePath(spaceDir) {
134
134
  return spaceLocalFile(spaceDir, 'reports.json');
@@ -139,10 +139,9 @@ function readState(spaceDir) {
139
139
  const raw = JSON.parse(fs.readFileSync(statePath(spaceDir), 'utf8'));
140
140
  return {
141
141
  enabled: raw?.enabled === true,
142
- promptFile: typeof raw?.promptFile === 'string' ? raw.promptFile.trim() : '',
143
142
  };
144
143
  } catch {
145
- return { enabled: false, promptFile: '' };
144
+ return { enabled: false };
146
145
  }
147
146
  }
148
147
 
@@ -153,11 +152,7 @@ function writeState(spaceDir, state) {
153
152
  const tmp = `${fp}.${process.pid}.tmp`;
154
153
  fs.writeFileSync(
155
154
  tmp,
156
- `${JSON.stringify(
157
- { enabled: state.enabled === true, promptFile: state.promptFile || '' },
158
- null,
159
- 2,
160
- )}\n`,
155
+ `${JSON.stringify({ enabled: state.enabled === true }, null, 2)}\n`,
161
156
  'utf8',
162
157
  );
163
158
  fs.renameSync(tmp, fp);
@@ -166,7 +161,7 @@ function writeState(spaceDir, state) {
166
161
  }
167
162
  }
168
163
 
169
- /** 提示词目录里的候选文件(排除空间默认提示词与隐藏文件) */
164
+ /** 当前空间可挂载技能的兼容路径列表(排除空间基础规则与隐藏文件) */
170
165
  function listPromptFiles(spaceDir) {
171
166
  const dir = promptsDir(spaceDir);
172
167
  let names = [];
@@ -199,10 +194,9 @@ function listPromptFiles(spaceDir) {
199
194
  * 选中的文件被改名 / 删除时,依次回退:默认名 → 名字里带「工作汇报」→ 无。
200
195
  * @returns {string} 文件名;没有可用文件时为空串
201
196
  */
202
- function resolvePromptName(spaceDir, state) {
197
+ function resolvePromptName(spaceDir) {
203
198
  const files = listPromptFiles(spaceDir);
204
199
  const names = new Set(files.map((f) => f.name));
205
- if (state.promptFile && names.has(state.promptFile)) return state.promptFile;
206
200
  if (names.has(REPORT_PROMPT_FILE)) return REPORT_PROMPT_FILE;
207
201
  const guess = files.find((f) => f.name.includes('工作汇报'));
208
202
  return guess ? guess.name : '';
@@ -211,12 +205,13 @@ function resolvePromptName(spaceDir, state) {
211
205
  /** 打开插件:缺提示词就补一份;已有内容不覆盖(用户的修改优先) */
212
206
  function ensurePrompt(spaceDir, state) {
213
207
  // 只认现在还在的文件;选中的文件被改名 / 删掉时回退到默认名,不复活旧名字
214
- const name = resolvePromptName(spaceDir, state) || REPORT_PROMPT_FILE;
208
+ const name = resolvePromptName(spaceDir) || REPORT_PROMPT_FILE;
215
209
  const dir = promptsDir(spaceDir);
216
210
  const dest = path.join(dir, name);
217
211
  if (fs.existsSync(dest)) return { created: false, name };
218
212
  fs.mkdirSync(dir, { recursive: true });
219
213
  fs.writeFileSync(dest, REPORT_PROMPT_TEMPLATE, 'utf8');
214
+ migrateSpaceSkills(spaceDir);
220
215
  return { created: true, name };
221
216
  }
222
217
 
@@ -292,7 +287,7 @@ export function lhReportsPlugin() {
292
287
  const spaceDir = getDataRoot();
293
288
  const query = new URLSearchParams(req.url?.split('?')[1] ?? '');
294
289
  const state = readState(spaceDir);
295
- const promptName = resolvePromptName(spaceDir, state);
290
+ const promptName = resolvePromptName(spaceDir);
296
291
 
297
292
  if (url === `${PREFIX}/health` && req.method === 'GET') {
298
293
  return sendJson(res, 200, {
@@ -314,36 +309,13 @@ export function lhReportsPlugin() {
314
309
  });
315
310
  }
316
311
 
317
- /** 提示词下拉的候选列表 */
318
- if (url === `${PREFIX}/prompts` && req.method === 'GET') {
319
- const files = listPromptFiles(spaceDir);
320
- return sendJson(res, 200, {
321
- ok: true,
322
- promptFile: promptName,
323
- items: files.map((f) => ({
324
- ...f,
325
- selected: f.name === promptName,
326
- })),
327
- });
328
- }
329
-
330
- /** 切换生效的提示词:只改「用哪份」,不动文件内容 */
331
- if (url === `${PREFIX}/select` && req.method === 'POST') {
332
- const body = JSON.parse((await readBody(req)) || '{}');
333
- const file = path.basename(String(body.file ?? '').trim());
334
- const names = new Set(listPromptFiles(spaceDir).map((f) => f.name));
335
- if (!file || !names.has(file)) {
336
- return sendJson(res, 404, { ok: false, error: '提示词不存在' });
337
- }
338
- writeState(spaceDir, { enabled: state.enabled, promptFile: file });
339
- return sendJson(res, 200, { ok: true, promptFile: file });
340
- }
341
-
342
312
  if (url === `${PREFIX}/prompt` && req.method === 'GET') {
343
313
  if (!promptName) {
344
314
  return sendJson(res, 200, { ok: true, exists: false, content: '' });
345
315
  }
346
- const dest = path.join(promptsDir(spaceDir), promptName);
316
+ const dest =
317
+ migratedPromptPath(spaceDir, promptName) ||
318
+ path.join(promptsDir(spaceDir), promptName);
347
319
  return sendJson(res, 200, {
348
320
  ok: true,
349
321
  exists: true,
@@ -356,7 +328,7 @@ export function lhReportsPlugin() {
356
328
  const body = JSON.parse((await readBody(req)) || '{}');
357
329
  if (body.enabled === true) {
358
330
  const out = ensurePrompt(spaceDir, state);
359
- writeState(spaceDir, { enabled: true, promptFile: out.name });
331
+ writeState(spaceDir, { enabled: true });
360
332
  return sendJson(res, 200, {
361
333
  ok: true,
362
334
  enabled: true,
@@ -366,7 +338,7 @@ export function lhReportsPlugin() {
366
338
  });
367
339
  }
368
340
  // 关闭只停用,不删文件:重新打开仍是原来那份(改过的内容也还在)
369
- writeState(spaceDir, { enabled: false, promptFile: promptName });
341
+ writeState(spaceDir, { enabled: false });
370
342
  return sendJson(res, 200, {
371
343
  ok: true,
372
344
  enabled: false,
@@ -23,6 +23,8 @@ import {
23
23
  SOURCE_STRUCTURE_PROMPT_TEMPLATE,
24
24
  parseReqPromptSections,
25
25
  } from './req-analysis-prompt.mjs';
26
+ import { analysisRevision } from './req-analysis-revision.mjs';
27
+ import { recordRequirementBreakdown } from './lh-req-breakdown-library.mjs';
26
28
 
27
29
  const PREFIX = '/__tb_reqanalysis';
28
30
  const VERSION = 1;
@@ -897,10 +899,14 @@ export function lhReqAnalysisPlugin() {
897
899
  if (method === 'POST' && tail === '/create') {
898
900
  const body = JSON.parse((await readBody(req)) || '{}');
899
901
  const store = readStore(root);
900
- const doc = buildDoc(body);
902
+ const doc = normalizeDoc(buildDoc(body));
901
903
  store.docs.push(doc);
902
904
  writeStore(root, store);
903
- return sendJson(res, 200, { ok: true, doc });
905
+ return sendJson(res, 200, {
906
+ ok: true,
907
+ doc,
908
+ revision: analysisRevision(doc),
909
+ });
904
910
  }
905
911
 
906
912
  if (method === 'PUT' && (tail === '/' || tail === '')) {
@@ -911,6 +917,16 @@ export function lhReqAnalysisPlugin() {
911
917
  const idx = store.docs.findIndex((x) => x.id === id);
912
918
  if (idx < 0) return sendJson(res, 404, { ok: false, error: '分析文档不存在' });
913
919
  const base = store.docs[idx];
920
+ const expectedRevision = text(body.expectedRevision, 64);
921
+ const currentRevision = analysisRevision(base);
922
+ if (expectedRevision && expectedRevision !== currentRevision) {
923
+ return sendJson(res, 409, {
924
+ ok: false,
925
+ error: '需求分析已被更新,请重新读取后再修改',
926
+ currentRevision,
927
+ currentUpdatedAt: base.updatedAt,
928
+ });
929
+ }
914
930
  const next = { ...base, ...normalizePatch(base, body) };
915
931
  if ('outline' in body) applyOutline(next, body.outline);
916
932
  if ('stories' in body) applyStories(next, body.stories, body.replaceStories === true);
@@ -919,7 +935,20 @@ export function lhReqAnalysisPlugin() {
919
935
  next.updatedAt = new Date().toISOString();
920
936
  store.docs[idx] = next;
921
937
  writeStore(root, store);
922
- return sendJson(res, 200, { ok: true, doc: next });
938
+ if ('sourceExport' in body && next.sourceExport?.groups?.length) {
939
+ try {
940
+ await recordRequirementBreakdown(root, next);
941
+ } catch (error) {
942
+ console.warn(
943
+ `需求拆解库自动入库失败:${error instanceof Error ? error.message : error}`,
944
+ );
945
+ }
946
+ }
947
+ return sendJson(res, 200, {
948
+ ok: true,
949
+ doc: next,
950
+ revision: analysisRevision(next),
951
+ });
923
952
  }
924
953
 
925
954
  if (method === 'POST' && tail === '/delete') {