lantern-harness 0.1.44 → 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 +224 -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 +265 -51
  115. package/dist/docs/install/index.html +44 -12
  116. package/dist/docs/manual/index.html +213 -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 +208 -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.DIbzr8uT.css +0 -1
  183. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CPR_CfsE.js +0 -2
  184. package/dist/_astro/CaseExecBoard.DICluCbK.js +0 -1
  185. package/dist/_astro/CaseGenerateApp.CcAtVSQJ.js +0 -10
  186. package/dist/_astro/CasesLibrary.Ci_0hYqL.js +0 -21
  187. package/dist/_astro/ChatApp.DFKZOkZy.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.BVrMtkLi.js +0 -17
  202. package/dist/_astro/PluginsPage.xdbDGigE.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.B2LMGsrj.js +0 -1
  211. package/dist/_astro/ReportsPage.B9lGg1_s.js +0 -16
  212. package/dist/_astro/ReqAnalysisBoard.D-KmRwQM.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.C62iJkMt.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.3eY3FSw1.js +0 -1
  230. package/dist/_astro/case-gen-run.BQeK-XUw.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.FrD6BfwK.js +0 -31
  241. package/dist/_astro/story-review.R8iWiFzl.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
@@ -13,6 +13,11 @@ import fs from 'node:fs';
13
13
  import path from 'node:path';
14
14
  import crypto from 'node:crypto';
15
15
 
16
+ import {
17
+ migratedPromptPath,
18
+ migrateSpaceSkills,
19
+ touchMigratedSkill,
20
+ } from '../builtin/session/space-skills.mjs';
16
21
  import { getDataRoot } from '../builtin/session/space-context.mjs';
17
22
  import { resolveContentRoot, spaceLocalFile } from '../builtin/session/space-layout.mjs';
18
23
 
@@ -59,10 +64,12 @@ export const PLUGIN_PROMPT_FILES = Object.freeze({
59
64
  '自动化项目提示词.md': 'uiAuto',
60
65
  '需求分析提示词.md': 'reqAnalysis',
61
66
  '原文结构提示词.md': 'reqAnalysis',
67
+ '业务地图识别提示词.md': 'businessMap',
62
68
  '用户故事审查提示词.md': 'storyReview',
63
69
  '测试点生成提示词.md': 'testPoints',
64
70
  '用例质量评审提示词.md': 'caseReview',
65
71
  '场景遗漏补全提示词.md': 'caseBlindspot',
72
+ '用例执行提示词.md': 'caseExecution',
66
73
  '功能测试报告提示词.md': 'testReports',
67
74
  '接口测试报告提示词.md': 'testReports',
68
75
  '性能测试报告提示词.md': 'testReports',
@@ -97,6 +104,7 @@ export const STORY_REVIEW_PROMPT_FILE = '用户故事审查提示词.md';
97
104
  export const TEST_POINTS_PROMPT_FILE = '测试点生成提示词.md';
98
105
  export const CASE_REVIEW_PROMPT_FILE = '用例质量评审提示词.md';
99
106
  export const BLINDSPOT_PROMPT_FILE = '场景遗漏补全提示词.md';
107
+ export const CASE_EXECUTION_PROMPT_FILE = '用例执行提示词.md';
100
108
 
101
109
  /** 当前空间的提示词目录(可能被归进分组文件夹) */
102
110
  export function promptsDir(spaceDir = getDataRoot()) {
@@ -105,7 +113,7 @@ export function promptsDir(spaceDir = getDataRoot()) {
105
113
 
106
114
  /** 空间里某份插件提示词的绝对路径 */
107
115
  export function pluginPromptPath(name, spaceDir = getDataRoot()) {
108
- return path.join(promptsDir(spaceDir), name);
116
+ return migratedPromptPath(spaceDir, name) || path.join(promptsDir(spaceDir), name);
109
117
  }
110
118
 
111
119
  /** 读插件提示词正文;不存在返回空串 */
@@ -139,6 +147,13 @@ export function migrateLegacyPluginPrompts(spaceDir = getDataRoot()) {
139
147
  if (!fs.existsSync(src) || fs.existsSync(dest)) continue;
140
148
  try {
141
149
  fs.mkdirSync(path.dirname(dest), { recursive: true });
150
+ const canonical = migratedPromptPath(spaceDir, from);
151
+ if (canonical) {
152
+ fs.copyFileSync(canonical, dest);
153
+ migrateSpaceSkills(spaceDir);
154
+ moved.push({ from, to });
155
+ continue;
156
+ }
142
157
  fs.renameSync(src, dest);
143
158
  const state = readSeedState(spaceDir);
144
159
  if (state[from]) {
@@ -173,6 +188,7 @@ export function ensurePluginPrompt(name, template, spaceDir = getDataRoot()) {
173
188
  fs.mkdirSync(path.dirname(dest), { recursive: true });
174
189
  fs.writeFileSync(dest, rendered, 'utf8');
175
190
  writeSeedState(spaceDir, { ...state, [name]: renderedHash });
191
+ migrateSpaceSkills(spaceDir);
176
192
  return { created: true, updated: false, exists: true, file: name };
177
193
  } catch {
178
194
  return { created: false, updated: false, exists: false, file: name };
@@ -203,6 +219,7 @@ export function ensurePluginPrompt(name, template, spaceDir = getDataRoot()) {
203
219
  try {
204
220
  fs.writeFileSync(dest, rendered, 'utf8');
205
221
  writeSeedState(spaceDir, { ...state, [name]: renderedHash });
222
+ touchMigratedSkill(spaceDir, name);
206
223
  return { created: false, updated: true, exists: true, file: name };
207
224
  } catch {
208
225
  return { created: false, updated: false, exists: true, file: name };
@@ -223,6 +240,7 @@ export function resetPluginPrompt(name, template, spaceDir = getDataRoot()) {
223
240
  fs.mkdirSync(path.dirname(dest), { recursive: true });
224
241
  fs.writeFileSync(dest, rendered, 'utf8');
225
242
  writeSeedState(spaceDir, { ...readSeedState(spaceDir), [name]: digest(rendered) });
243
+ touchMigratedSkill(spaceDir, name);
226
244
  return { ok: true, file: name };
227
245
  } catch {
228
246
  return { ok: false, file: name };
@@ -259,17 +277,3 @@ export function isPluginOnInSpace(pluginId, spaceDir = getDataRoot()) {
259
277
  const local = readJsonOr(spaceLocalFile(spaceDir, 'app.config.json'), {})?.plugins ?? {};
260
278
  return (local[pluginId] ?? defaults[pluginId]) === true;
261
279
  }
262
-
263
- /**
264
- * 这份提示词当前是否被某个「开启中」的插件锁定(不可删除 / 改名)。
265
- * @returns {string} 锁定原因;未锁定时为空串
266
- */
267
- export function pluginPromptLock(name, spaceDir = getDataRoot()) {
268
- const base = String(name ?? '')
269
- .split('/')
270
- .pop();
271
- const owner = PLUGIN_PROMPT_FILES[base];
272
- if (!owner) return '';
273
- if (!isPluginOnInSpace(owner, spaceDir)) return '';
274
- return '插件开启中,这份提示词由插件引用;先在「我的插件」里关闭对应插件再删除';
275
- }
@@ -0,0 +1,24 @@
1
+ import crypto from 'node:crypto';
2
+
3
+ function stableValue(value) {
4
+ if (Array.isArray(value)) return value.map(stableValue);
5
+ if (!value || typeof value !== 'object') return value;
6
+ const out = {};
7
+ for (const key of Object.keys(value).sort()) {
8
+ if (key === 'updatedAt' || key === 'revision') continue;
9
+ out[key] = stableValue(value[key]);
10
+ }
11
+ return out;
12
+ }
13
+
14
+ /**
15
+ * 需求分析内容指纹:忽略顶层 updatedAt,用于 Codex / 页面并发写入保护。
16
+ * 同一份内容无论对象键顺序如何都得到同一 revision。
17
+ */
18
+ export function analysisRevision(doc) {
19
+ if (!doc || typeof doc !== 'object') return '';
20
+ return crypto
21
+ .createHash('sha256')
22
+ .update(JSON.stringify(stableValue(doc)), 'utf8')
23
+ .digest('hex');
24
+ }
@@ -2,7 +2,7 @@
2
2
  * 「生成测试点」的提示词文件:种子正文 + 分段解析。
3
3
  *
4
4
  * 文件放在当前空间的「提示词管理/测试点生成提示词.md」,由插件开关联动:
5
- * 打开插件时缺就补种子(没人改过时会跟着内置模板升级),插件开启期间不允许删除 / 改名。
5
+ * 打开插件时缺就补种子(没人改过时会跟着内置模板升级)。
6
6
  * 每次生成前读一次,改完提示词不用重启服务。
7
7
  *
8
8
  * 文件用一级标题分一段:
@@ -19,8 +19,7 @@ export const GENERATE_SECTION = '生成';
19
19
 
20
20
  export const TEST_POINTS_PROMPT_TEMPLATE = `# 测试点生成提示词
21
21
 
22
- > 这份提示词由「生成测试点」插件生成并引用。
23
- > 插件开启期间不能删除本文件;关闭插件后可以删掉,再次打开会重新生成。
22
+ > 由「生成测试点」插件关联。
24
23
  > 本文件不使用占位符:分析标题、需求条目与用户故事由运行时以「## 分析标题」「## 需求条目」「## 用户故事」三个小节拼在用户消息里。
25
24
 
26
25
  ## 生成
@@ -0,0 +1,218 @@
1
+ /**
2
+ * 项目内 auth.setup / Playwright setup 工程:探测 + 无头跑一遍产出 storageState。
3
+ * 登录墙自动链在 SSO 不可用或失败时回落走这里;不扫任意业务 *login*.spec。
4
+ *
5
+ * 跑 setup 时会把项目 .env 注入子进程,并把 LOGIN_API_URL 等别名回填为
6
+ * LOGIN_API_PATH,避免项目里的 tryApiLogin 只认 PATH 而空跑。
7
+ */
8
+ import { spawn } from 'node:child_process';
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
11
+
12
+ import { resolvePackageManager } from './uiauto-pm.mjs';
13
+ import { withProjectNode } from './uiauto-node.mjs';
14
+ import { detectStorageState, findPlaywrightConfig } from './uiauto-explorer/sessions.mjs';
15
+ import { readProjectEnvMap, resolveLoginApiEndpoint } from './uiauto-sso.mjs';
16
+
17
+ const AUTH_SETUP_FILES = [
18
+ 'tests/auth.setup.ts',
19
+ 'tests/auth.setup.js',
20
+ 'auth.setup.ts',
21
+ 'auth.setup.js',
22
+ ];
23
+
24
+ const SETUP_TIMEOUT_MS = 120_000;
25
+
26
+ function readText(file) {
27
+ try {
28
+ return fs.readFileSync(file, 'utf8');
29
+ } catch {
30
+ return '';
31
+ }
32
+ }
33
+
34
+ function existsFile(root, rel) {
35
+ try {
36
+ return fs.statSync(path.join(root, rel)).isFile();
37
+ } catch {
38
+ return false;
39
+ }
40
+ }
41
+
42
+ /** playwright.config 里是否声明了 name: 'setup' / "setup" 的 project */
43
+ export function playwrightHasSetupProject(dir) {
44
+ const root = String(dir || '');
45
+ if (!root) return false;
46
+ const configName = findPlaywrightConfig(root);
47
+ if (!configName) return false;
48
+ const content = readText(path.join(root, configName));
49
+ if (!content) return false;
50
+ // name: 'setup' | name: "setup" | name: `setup`
51
+ return /\bname\s*:\s*(['"`])setup\1/.test(content);
52
+ }
53
+
54
+ /** 命中的 auth.setup 相对路径;没有则空串 */
55
+ export function findAuthSetupFile(dir) {
56
+ const root = String(dir || '');
57
+ if (!root) return '';
58
+ for (const rel of AUTH_SETUP_FILES) {
59
+ if (existsFile(root, rel)) return rel.replace(/\\/g, '/');
60
+ }
61
+ // 挂载项目常见 tests/auth-unit.setup.ts、tests/xxx.auth.setup.ts
62
+ try {
63
+ const names = fs.readdirSync(path.join(root, 'tests'));
64
+ const hit = names
65
+ .filter((name) => /\.setup\.(ts|js|mjs|cjs)$/i.test(name) && /auth/i.test(name))
66
+ .sort();
67
+ if (hit.length) return path.posix.join('tests', hit[0]);
68
+ } catch {
69
+ // no tests/
70
+ }
71
+ return '';
72
+ }
73
+
74
+ /**
75
+ * 项目是否具备可跑的登录态 setup(文件或 setup 工程)。
76
+ */
77
+ export function projectHasAuthSetup(dir) {
78
+ const root = String(dir || '');
79
+ if (!root || !fs.existsSync(root)) return false;
80
+ return Boolean(findAuthSetupFile(root) || playwrightHasSetupProject(root));
81
+ }
82
+
83
+ /**
84
+ * 决定怎么调 Playwright:优先 --project=setup,否则跑 auth.setup 文件。
85
+ * @returns {{ mode: 'project'|'file', target: string, command: string } | null}
86
+ */
87
+ export function resolveAuthSetupCommand(dir) {
88
+ const root = String(dir || '');
89
+ if (!root) return null;
90
+ const { commands } = resolvePackageManager({ dir: root });
91
+ const hasProject = playwrightHasSetupProject(root);
92
+ const file = findAuthSetupFile(root);
93
+ if (hasProject) {
94
+ return {
95
+ mode: 'project',
96
+ target: 'setup',
97
+ command: commands.exec('playwright', ['test', '--project=setup']),
98
+ };
99
+ }
100
+ if (file) {
101
+ return {
102
+ mode: 'file',
103
+ target: file,
104
+ command: commands.exec('playwright', ['test', file]),
105
+ };
106
+ }
107
+ return null;
108
+ }
109
+
110
+ function runShell(command, cwd, env, timeoutMs) {
111
+ return new Promise((resolve) => {
112
+ let output = '';
113
+ let done = false;
114
+ const finish = (code, extra = '') => {
115
+ if (done) return;
116
+ done = true;
117
+ resolve({ code, output: `${output}${extra}`.slice(-20_000) });
118
+ };
119
+ let child;
120
+ try {
121
+ child = spawn(command, {
122
+ cwd,
123
+ shell: true,
124
+ env: { ...env, FORCE_COLOR: '0', CI: '1' },
125
+ });
126
+ } catch (error) {
127
+ finish(
128
+ -1,
129
+ `\n[lantern] 启动失败:${error instanceof Error ? error.message : String(error)}\n`,
130
+ );
131
+ return;
132
+ }
133
+ const push = (chunk) => {
134
+ output += String(chunk);
135
+ if (output.length > 40_000) output = output.slice(-20_000);
136
+ };
137
+ child.stdout?.setEncoding('utf8');
138
+ child.stderr?.setEncoding('utf8');
139
+ child.stdout?.on('data', push);
140
+ child.stderr?.on('data', push);
141
+ const timer = setTimeout(() => {
142
+ try {
143
+ child.kill('SIGTERM');
144
+ } catch {
145
+ // ignore
146
+ }
147
+ finish(-1, `\n[lantern] auth.setup 超过 ${Math.round(timeoutMs / 1000)} 秒,已终止。\n`);
148
+ }, timeoutMs);
149
+ timer.unref?.();
150
+ child.on('error', (error) => {
151
+ clearTimeout(timer);
152
+ finish(-1, `\n[lantern] ${error instanceof Error ? error.message : String(error)}\n`);
153
+ });
154
+ child.on('close', (code) => {
155
+ clearTimeout(timer);
156
+ finish(typeof code === 'number' ? code : -1);
157
+ });
158
+ });
159
+ }
160
+
161
+ /**
162
+ * 无头跑 auth.setup,成功后探测 storageState。
163
+ * @returns {{ ok: true, storageState: string, command: string, output: string } | { ok: false, error: string, output?: string }}
164
+ */
165
+ export async function runAuthSetupAndSave({ dir, envName = '' }) {
166
+ const root = String(dir || '');
167
+ if (!root || !fs.existsSync(root)) {
168
+ return { ok: false, error: '项目目录不存在' };
169
+ }
170
+ const plan = resolveAuthSetupCommand(root);
171
+ if (!plan) {
172
+ return { ok: false, error: '未检测到 auth.setup 文件或 Playwright setup 工程' };
173
+ }
174
+
175
+ const projectEnv = readProjectEnvMap(root, envName);
176
+ const endpoint = resolveLoginApiEndpoint(projectEnv);
177
+ // 项目代码多半只读 LOGIN_API_PATH:把 URL 等别名回填进去
178
+ const aliasPath =
179
+ endpoint.value && !String(projectEnv.LOGIN_API_PATH || '').trim()
180
+ ? { LOGIN_API_PATH: endpoint.value }
181
+ : {};
182
+ const env = withProjectNode(
183
+ {
184
+ ...process.env,
185
+ ...projectEnv,
186
+ ...aliasPath,
187
+ ...(envName ? { ENV: String(envName) } : {}),
188
+ CI: '1',
189
+ },
190
+ root,
191
+ );
192
+ const { code, output } = await runShell(plan.command, root, env, SETUP_TIMEOUT_MS);
193
+ if (code !== 0) {
194
+ const tail = String(output || '')
195
+ .trim()
196
+ .slice(-500);
197
+ return {
198
+ ok: false,
199
+ error: `auth.setup 未成功(exit ${code})${tail ? `:${tail}` : ''}`,
200
+ output,
201
+ };
202
+ }
203
+
204
+ const storageState = detectStorageState(root);
205
+ if (!storageState) {
206
+ const text = String(output || '');
207
+ const skipped = /\bskipped\b|\b跳过\b|未配置.*账号/i.test(text);
208
+ const hint = skipped
209
+ ? '用例可能被 skip(检查 ADMIN_USERNAME / ADMIN_PASSWORD)。'
210
+ : '若 setup 走 UI 登录且有验证码,无头跑会写不出登录态。';
211
+ return {
212
+ ok: false,
213
+ error: `auth.setup 已执行(${plan.command}),但项目里仍未找到 .auth / storageState 文件。${hint}`,
214
+ output,
215
+ };
216
+ }
217
+ return { ok: true, storageState, command: plan.command, output };
218
+ }
@@ -306,12 +306,23 @@ export async function openWith({ abs, dir, app, line }) {
306
306
  }
307
307
 
308
308
  // editor:CLI 优先(能带行号),否则交给 open -a
309
+ // 有项目目录时先带上 dir,避免只开单个草稿文件、看起来像「孤立文件」
309
310
  if (cli) {
310
- const arg = abs && line ? `${abs}:${line}` : abs || dir;
311
- await execFileAsync(cli, ['-g', arg], { timeout: 10000 });
311
+ const fileArg = abs && line ? `${abs}:${line}` : abs || '';
312
+ if (dir && fileArg && path.resolve(fileArg.split(':')[0]) !== path.resolve(dir)) {
313
+ await execFileAsync(cli, [dir, '-g', fileArg], { timeout: 10000 });
314
+ return;
315
+ }
316
+ await execFileAsync(cli, ['-g', fileArg || dir], { timeout: 10000 });
312
317
  return;
313
318
  }
314
319
  if (process.platform === 'darwin' && appPath) {
320
+ if (dir && abs && path.resolve(abs) !== path.resolve(dir)) {
321
+ // 先开项目目录进工作区,再定位到文件
322
+ await execFileAsync('open', ['-a', appPath, dir], { timeout: 10000 });
323
+ await execFileAsync('open', ['-a', appPath, abs], { timeout: 10000 });
324
+ return;
325
+ }
315
326
  await execFileAsync('open', ['-a', appPath, abs || dir], { timeout: 10000 });
316
327
  return;
317
328
  }
@@ -242,6 +242,8 @@ const handlers = {
242
242
  },
243
243
 
244
244
  async close() {
245
+ // 回包后立刻关;不要只靠外层 .then,避免父进程哨兵 id / 并发命令时漏关
246
+ void Promise.resolve().then(() => shutdown());
245
247
  return { closed: true };
246
248
  },
247
249
  };
@@ -345,7 +347,19 @@ rl.on('line', (line) => {
345
347
  return;
346
348
  }
347
349
  const { id, cmd, args } = message || {};
348
- if (!id) return;
350
+ // 主动关窗优先:父进程可能用哨兵 id(如 -1),不能按 !id 直接丢弃
351
+ if (cmd === 'close') {
352
+ if (id != null && id !== '') {
353
+ try {
354
+ process.stdout.write(`${JSON.stringify({ id, ok: true, result: { closed: true } })}\n`);
355
+ } catch {
356
+ // 管道已断
357
+ }
358
+ }
359
+ void shutdown();
360
+ return;
361
+ }
362
+ if (id == null || id === '') return;
349
363
  const handler = handlers[cmd];
350
364
  if (!handler) {
351
365
  process.stdout.write(
@@ -357,7 +371,6 @@ rl.on('line', (line) => {
357
371
  .then(() => handler(args || {}))
358
372
  .then((result) => {
359
373
  process.stdout.write(`${JSON.stringify({ id, ok: true, result })}\n`);
360
- if (cmd === 'close') void shutdown();
361
374
  })
362
375
  .catch((err) => {
363
376
  process.stdout.write(`${JSON.stringify({ id, ok: false, error: describeError(err) })}\n`);