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
@@ -2,8 +2,9 @@
2
2
  * 「自动化测试」两份提示词:缺省短种子 + 分段解析。
3
3
  *
4
4
  * 运行时与日常维护以空间「提示词管理」里的文件为准;增删改只改那里。
5
- * - `自动化执行提示词.md`:生成用例(规划 / 探索 / 出码),「自动化执行」入口用;
5
+ * - `自动化执行提示词.md`:脚本编排(规划 → 确认并探索 → 出码),「自动化执行」入口用;
6
6
  * - `自动化项目提示词.md`:新建项目时给骨架做体检与补全,「自动化项目」入口用。
7
+ * 种子与仓库 `提示词示例/自动化执行提示词.md` 应对齐;已有空间文件不会被种子覆盖。
7
8
  */
8
9
 
9
10
  import { UI_AUTO_PROMPT_FILE, UI_AUTO_PROJECT_PROMPT_FILE } from './plugin-prompts.mjs';
@@ -18,9 +19,10 @@ export const SKELETON_SECTION = '项目骨架';
18
19
  /** 缺文件时写入的种子;完整正文请维护空间文件,参考稿见仓库 提示词示例/自动化执行提示词.md */
19
20
  export const UI_AUTO_PROMPT_TEMPLATE = `# 自动化执行提示词
20
21
 
21
- > 由「自动化执行」引用,用来生成用例(规划 / 探索 / 出码)。日常增删改请只改本空间「提示词管理」里的本文件。
22
+ > 由「自动化执行 · 脚本编排」引用。流程是:**规划(对话拆步骤)→ 用户确认并探索(绑定位器)→ 出码**。日常增删改请只改本空间「提示词管理」里的本文件。
22
23
  > 参考稿见仓库 \`提示词示例/自动化执行提示词.md\`。占位符:\`{{project}}\` \`{{dir}}\` \`{{kind}}\` \`{{language}}\` \`{{plan}}\`(只在前两段生效)。
23
24
  > 平台只读下面四个 \`##\` 段(项目骨架 / 规划阶段 / 探索阶段 / 生成代码),其它标题下的内容不会进模型,别把要求写在段外。
25
+ > 用户在编排会话里描述需求时,仍属「规划阶段」:只拆步骤,不要当成「立刻写用例并跑通」。
24
26
 
25
27
  ## 项目骨架
26
28
 
@@ -55,7 +57,8 @@ export const UI_AUTO_PROMPT_TEMPLATE = `# 自动化执行提示词
55
57
 
56
58
  ## 规划阶段
57
59
 
58
- 你是自动化测试工程师,本轮负责其中的**浏览器 UI 自动化**:把需求拆成可执行、可人工编辑的测试步骤计划。
60
+ 你是自动化测试工程师,本轮对应产品里的**脚本编排 · 规划**:把需求拆成可执行、可人工编辑的测试步骤计划。
61
+ 用户在编排会话里发的一句话需求(哪怕像用例标题),也只当规划输入,不要直接出码或跑测。
59
62
 
60
63
  自动化不只有 UI(接口、App、性能都算),但本功能目前只产出浏览器 UI 脚本(Playwright,或 pytest + \`playwright.sync_api\`),
61
64
  工具也只有浏览器那一套(打开页面、快照、点击、定位探测);接口自动化(requests / httpx)、App(Appium)、性能都没有工具与出码模板。
@@ -65,19 +68,21 @@ export const UI_AUTO_PROMPT_TEMPLATE = `# 自动化执行提示词
65
68
 
66
69
  规则:
67
70
  1. 只调用 ui_plan_steps 一次,提交完整计划;不要打开浏览器、不要写定位器。
68
- 2. 每步只描述「动作 + 目标」:target 用页面上的可见文案 / 位置描述,例如「用户名输入框」「右上角登录按钮」。
69
- 3. 除 goto / wait / press 外,缺 target 的步骤会被直接丢掉、不报错;提交后核对返回的 stepCount(实际保留条数)。
70
- 4. 账号、密码、手机号等占位数据写成 \${ENV_NAME},不要编造真实凭据。
71
- 5. 计划要覆盖:打开页面、关键前置(登录 / 导航)、核心操作、至少一条结果断言(用户能看到什么)。
72
- 6. 步骤 4~12 步为宜(最多 40 步),不要为了凑数拆得过细;一个动作一句话。
73
- 7. 计划里只写测试步骤,不要写「截图」:计划不接受截图步骤,提交了会被丢掉。
71
+ 2. **禁止**创建 / 修改 / 删除项目里的测试或源码文件;**禁止**运行 playwright / pytest / npm test 等命令;**禁止**手写完整测试代码。出码与试跑是后续阶段、由平台与用户按钮触发。
72
+ 3. 每步只描述「动作 + 目标」:target 用页面上的可见文案 / 位置描述,例如「用户名输入框」「右上角登录按钮」。
73
+ 4. 除 goto / wait / press 外,缺 target 的步骤会被直接丢掉、不报错;提交后核对返回的 stepCount(实际保留条数)。
74
+ 5. 账号、密码、手机号等占位数据写成 \${ENV_NAME},不要编造真实凭据。
75
+ 6. 计划要覆盖:打开页面、关键前置(登录 / 导航)、核心操作、至少一条结果断言(用户能看到什么)。
76
+ 7. 步骤 4~12 步为宜(最多 40 步),不要为了凑数拆得过细;一个动作一句话。
77
+ 8. 计划里只写测试步骤,不要写「截图」:计划不接受截图步骤,提交了会被丢掉。
74
78
 
75
- 提交后简短说明你的测试思路与需要人工确认的点。
79
+ 提交后用中文简短说明测试思路,并提醒用户:在右侧步骤栏确认后点「确认并探索」,才会进入绑定位器。
76
80
 
77
81
  ## 探索阶段
78
82
 
79
- 你是自动化测试工程师,本轮负责其中的**浏览器 UI 自动化**:在真实浏览器里把流程点一遍,确认每个元素都能唯一定位,再提交步骤。
83
+ 你是自动化测试工程师,本轮对应产品里的**脚本编排 · 探索**(用户已点「确认并探索」):在真实浏览器里把流程点一遍,确认每个元素都能唯一定位,再提交步骤。
80
84
  本功能只产出浏览器 UI 脚本,接口 / App / 性能自动化没有对应工具;项目类型是「接口」或需求要测接口时,直接说明不支持并停下,不要开浏览器象征性点两下再出个 UI 脚本。
85
+ 本阶段仍**不要**手写或改项目里的测试文件;定位器提交后由平台出码,不要自己 \`npx playwright test\`。
81
86
 
82
87
  当前挂载项目:{{project}}({{dir}}),项目类型:{{kind}},生成目标语言:{{language}}。
83
88
 
@@ -86,7 +91,7 @@ export const UI_AUTO_PROMPT_TEMPLATE = `# 自动化执行提示词
86
91
  2. ref 是临时的,页面导航或刷新后会失效;失效就重新 ui_browser_snapshot,不要猜。
87
92
  需要等异步渲染时用 ui_browser_wait({ text: "某段文案" }),不要用长时间死等。
88
93
  3. 写步骤之前,对每个要操作或断言的元素调用 ui_locator_probe,用返回的 recommended;
89
- 带 stepId 时定位器会回填到左侧对应计划步骤。
94
+ 带 stepId 时定位器会回填到步骤栏对应计划步骤。
90
95
  recommended 带 nth 时表示同名元素取第 N 个(出码时 TS 是 .first()、Python 是 .first,你都不要手写),照抄即可。
91
96
  没有唯一候选时换更具体的元素,不要自己拼长 CSS / XPath。
92
97
  4. 用 ui_test_set_steps 提交整份步骤(会刷新代码预览)。**不要自己试跑**:
@@ -97,19 +102,19 @@ export const UI_AUTO_PROMPT_TEMPLATE = `# 自动化执行提示词
97
102
  6. 如果页面行为本身与需求不符,保留现状并在回答里说明是疑似缺陷,不要为了跑绿改断言。
98
103
  7. 占位数据(账号、手机号)写成 \${ENV_NAME},不要编造真实凭据。
99
104
  8. 至少要有一条 expect 断言,断言用户能看到的结果,而不是断言元素存在就算过。
100
- 9. 关键节点(登录后、进入目标页、操作完成)调用一次 ui_browser_screenshot,用户会在面板里看到这一步的截图。
105
+ 9. 若本轮工具列表里有 ui_browser_screenshot,关键节点(登录后、进入目标页、操作完成)可调用一次;截图只给人看,你看不到图片内容。工具列表里没有就不要调用,用 ui_browser_snapshot 判断结构即可。
101
106
  10. 点击没反应 / 页面报错时,用 ui_browser_console 与 ui_browser_network 看错误,别盲目重试。
102
107
 
103
108
  {{plan}}
104
109
 
105
110
  步骤 IR 的 action 只用:goto / click / fill / select / press / hover / expect / expectUrl / wait。
106
- (枚举里的 screenshot 不要用:它会出成 page.screenshot 写进脚本,本平台不需要;过程截图用 ui_browser_screenshot 工具。)
111
+ (枚举里的 screenshot 不要用:它会出成 page.screenshot 写进脚本,本平台不需要;给人看的过程截图只用 ui_browser_screenshot,且仅当工具可用时。)
107
112
  locator.kind 只用 testid / role / label / placeholder / text / attr / css,按这个顺序优先(testid → role → label)。
108
113
  \${ENV_NAME} 必须是**整个值**,名字用英文大写 / 数字 / 下划线(如 \${USER_NAME});写成 user_\${NAME} 或中文名不会被识别成环境变量。
109
114
 
110
115
  ## 生成代码
111
116
 
112
- 出码与写入项目由平台按模板完成:你不写脚本,也没有读写项目文件的工具。这一段说明哪些必须由你管好、平台会怎么落盘。
117
+ 出码与写入项目由平台按模板完成:你不写脚本,也没有读写项目文件的工具;不要在会话里自己新建 \`.spec.ts\` / \`test_*.py\` 或动手跑测。这一段说明哪些必须由你管好、平台会怎么落盘。
113
118
 
114
119
  1. **用例标题**(决定用例名与文件名):中文一句话说清业务行为,一个用例只验证一件事;不要带路径分隔符。文件名由平台把标题转成 ASCII(纯中文标题会落到 ai-generated.spec.ts / test_ai_generated.py)。
115
120
  2. **步骤 IR 就是脚本内容**:出码只照抄你提交的 action / locator / value / text / ms。定位器必须来自 ui_locator_probe 的 recommended;不要用长 CSS,也不要自己猜 nth。
@@ -0,0 +1,407 @@
1
+ /**
2
+ * 平台侧 SSO / 接口登录:读项目 env → 调 LOGIN_API → 写入 Playwright storageState。
3
+ * 不跑项目里的 auth.setup(那条见 uiauto-auth-setup.mjs)。
4
+ * 给登录墙自动链与手动选 SSO 共用。
5
+ *
6
+ * 登录接口地址:优先骨架约定键,再通配 `LOGIN_API_*`(排除 BODY / TOKEN 等非地址字段)。
7
+ */
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+
11
+ import { envFilePath, parseEnvText, sanitizeEnvName } from './uiauto-env.mjs';
12
+
13
+ const AUTH_REL = path.join('.auth', 'admin.json');
14
+
15
+ /** 骨架 / 常见别名:有值时优先按此顺序取 */
16
+ export const LOGIN_API_ENDPOINT_KEYS = [
17
+ 'LOGIN_API_PATH',
18
+ 'LOGIN_API_URL',
19
+ 'LOGIN_API_ENDPOINT',
20
+ 'LOGIN_URL',
21
+ ];
22
+
23
+ /**
24
+ * `LOGIN_API_*` 里不算「接口地址」的后缀(请求体、token 路径、头等)。
25
+ * 其余后缀走通配,例如 LOGIN_API_SSO_URL、LOGIN_API_HOST。
26
+ */
27
+ export const LOGIN_API_ENDPOINT_DENY_SUFFIXES = [
28
+ 'BODY',
29
+ 'TOKEN_PATH',
30
+ 'TOKEN_KEY',
31
+ 'TOKEN_STORAGE_KEY',
32
+ 'METHOD',
33
+ 'HEADERS',
34
+ 'HEADER',
35
+ 'TIMEOUT',
36
+ 'CONTENT_TYPE',
37
+ 'TYPE',
38
+ ];
39
+
40
+ const ENDPOINT_DENY_RE = new RegExp(`^(${LOGIN_API_ENDPOINT_DENY_SUFFIXES.join('|')})$`, 'i');
41
+
42
+ function looksLikeEndpoint(value) {
43
+ const v = String(value || '').trim();
44
+ if (!v) return 0;
45
+ if (/^https?:\/\//i.test(v)) return 3;
46
+ if (v.startsWith('/')) return 2;
47
+ // 主机或相对路径也尽量认,分最低
48
+ if (/^[a-z0-9.-]+\/[a-z0-9/_.-]+$/i.test(v) || /^[a-z0-9_./-]+$/i.test(v)) return 1;
49
+ return 0;
50
+ }
51
+
52
+ function isDeniedLoginApiKey(key) {
53
+ const raw = String(key || '');
54
+ if (!/^LOGIN_API_/i.test(raw)) return true;
55
+ const suffix = raw.slice('LOGIN_API_'.length);
56
+ return ENDPOINT_DENY_RE.test(suffix);
57
+ }
58
+
59
+ /**
60
+ * 从 env map 里取出登录接口地址(相对 path 或完整 URL)。
61
+ * 1) 优先 LOGIN_API_PATH / URL / ENDPOINT / LOGIN_URL
62
+ * 2) 再通配其它 `LOGIN_API_*`(排除 BODY、TOKEN_* 等)
63
+ * @returns {{ key: string, value: string }}
64
+ */
65
+ export function resolveLoginApiEndpoint(envMap = {}) {
66
+ const map = envMap && typeof envMap === 'object' ? envMap : {};
67
+ for (const key of LOGIN_API_ENDPOINT_KEYS) {
68
+ const value = String(map[key] ?? '').trim();
69
+ if (value) return { key, value };
70
+ }
71
+
72
+ /** @type {Array<{ key: string, value: string, score: number }>} */
73
+ const wild = [];
74
+ for (const [key, raw] of Object.entries(map)) {
75
+ if (isDeniedLoginApiKey(key)) continue;
76
+ // 已在优先列表里扫过
77
+ if (LOGIN_API_ENDPOINT_KEYS.includes(key)) continue;
78
+ const value = String(raw ?? '').trim();
79
+ if (!value) continue;
80
+ const score = looksLikeEndpoint(value);
81
+ if (score <= 0) continue;
82
+ wild.push({ key, value, score });
83
+ }
84
+ if (!wild.length) return { key: '', value: '' };
85
+ wild.sort((a, b) => b.score - a.score || a.key.localeCompare(b.key));
86
+ return { key: wild[0].key, value: wild[0].value };
87
+ }
88
+
89
+ function readEnvFileMap(file) {
90
+ if (!file || !fs.existsSync(file)) return {};
91
+ try {
92
+ const parsed = parseEnvText(fs.readFileSync(file, 'utf8'));
93
+ const map = {};
94
+ for (const entry of parsed.entries) {
95
+ map[entry.key] = entry.value;
96
+ }
97
+ return map;
98
+ } catch {
99
+ return {};
100
+ }
101
+ }
102
+
103
+ /** `.env` 打底,再叠 `.env.<ENV>`(后者覆盖) */
104
+ export function readProjectEnvMap(dir, envName = '') {
105
+ const root = String(dir || '');
106
+ if (!root) return {};
107
+ const base = readEnvFileMap(envFilePath(root, ''));
108
+ const env = sanitizeEnvName(envName);
109
+ if (!env) return base;
110
+ return { ...base, ...readEnvFileMap(envFilePath(root, env)) };
111
+ }
112
+
113
+ export function projectHasSsoConfig(dir, envName = '') {
114
+ const map = readProjectEnvMap(dir, envName);
115
+ return Boolean(resolveLoginApiEndpoint(map).value);
116
+ }
117
+
118
+ function renderBody(template, username, password) {
119
+ const replace = (value) =>
120
+ value
121
+ .replace(/\{\{\s*username\s*\}\}/g, () => username)
122
+ .replace(/\{\{\s*password\s*\}\}/g, () => password);
123
+ try {
124
+ return JSON.stringify(JSON.parse(template), (_key, value) =>
125
+ typeof value === 'string' ? replace(value) : value,
126
+ );
127
+ } catch {
128
+ return replace(String(template || ''));
129
+ }
130
+ }
131
+
132
+ function pickPath(source, target) {
133
+ return String(target || '')
134
+ .split('.')
135
+ .filter(Boolean)
136
+ .reduce((acc, key) => {
137
+ if (acc && typeof acc === 'object') return acc[key];
138
+ return undefined;
139
+ }, source);
140
+ }
141
+
142
+ /** 未配 LOGIN_API_TOKEN_PATH 时按常见字段猜 token */
143
+ export const DEFAULT_TOKEN_PATHS = [
144
+ 'data.authorization',
145
+ 'data.token',
146
+ 'data.accessToken',
147
+ 'data.access_token',
148
+ 'data.data.token',
149
+ 'result.token',
150
+ 'result.access_token',
151
+ 'token',
152
+ 'access_token',
153
+ 'accessToken',
154
+ 'authorization',
155
+ ];
156
+
157
+ /** 未配 LOGIN_TOKEN_STORAGE_KEY 时的默认 localStorage key */
158
+ export const DEFAULT_TOKEN_STORAGE_KEYS = ['token', 'access_token', 'accessToken'];
159
+
160
+ function asTokenString(value) {
161
+ if (value == null) return '';
162
+ if (typeof value === 'string') return value.trim();
163
+ if (typeof value === 'number' && Number.isFinite(value)) return String(value);
164
+ return '';
165
+ }
166
+
167
+ /** 在对象里按 key 名深挖 token(最多 5 层),适配 data.xxx 自定义字段 */
168
+ export function findTokenDeep(node, prefix = '', depth = 0) {
169
+ if (depth > 5 || node == null || typeof node !== 'object') return null;
170
+ const entries = Array.isArray(node) ? node.map((v, i) => [String(i), v]) : Object.entries(node);
171
+ for (const [key, value] of entries) {
172
+ const pathKey = prefix ? `${prefix}.${key}` : key;
173
+ if (/token|jwt|access|authorization|ticket|session|sid/i.test(String(key))) {
174
+ const token = asTokenString(value);
175
+ if (token.length >= 8) return { token, path: pathKey };
176
+ }
177
+ }
178
+ for (const [key, value] of entries) {
179
+ if (value && typeof value === 'object') {
180
+ const pathKey = prefix ? `${prefix}.${key}` : key;
181
+ const hit = findTokenDeep(value, pathKey, depth + 1);
182
+ if (hit) return hit;
183
+ }
184
+ }
185
+ return null;
186
+ }
187
+
188
+ /**
189
+ * 从登录响应 JSON 取 token:显式路径优先,否则扫常见字段,再深挖 data。
190
+ * @returns {{ token: string, path: string }}
191
+ */
192
+ export function resolveLoginToken(json, explicitPath = '') {
193
+ const configured = String(explicitPath || '').trim();
194
+ if (configured) {
195
+ const token = asTokenString(pickPath(json, configured));
196
+ if (token) return { token, path: configured };
197
+ }
198
+ if (!json || typeof json !== 'object') return { token: '', path: '' };
199
+ for (const pathKey of DEFAULT_TOKEN_PATHS) {
200
+ const token = asTokenString(pickPath(json, pathKey));
201
+ if (token) return { token, path: pathKey };
202
+ }
203
+ // data 本身是 JWT / 长串
204
+ const dataAsToken = asTokenString(json.data);
205
+ if (dataAsToken.length >= 16) return { token: dataAsToken, path: 'data' };
206
+ const deep = findTokenDeep(json);
207
+ if (deep) return deep;
208
+ return { token: '', path: '' };
209
+ }
210
+
211
+ /**
212
+ * localStorage 写入用的 key:显式配置优先,否则默认 `token`。
213
+ */
214
+ export function resolveTokenStorageKey(envMap = {}, fallback = 'token') {
215
+ const map = envMap && typeof envMap === 'object' ? envMap : {};
216
+ for (const key of [
217
+ 'LOGIN_TOKEN_STORAGE_KEY',
218
+ 'LOGIN_API_TOKEN_KEY',
219
+ 'LOGIN_API_STORAGE_KEY',
220
+ 'TOKEN_STORAGE_KEY',
221
+ ]) {
222
+ const value = String(map[key] ?? '').trim();
223
+ if (value) return value;
224
+ }
225
+ return String(fallback || 'token').trim() || 'token';
226
+ }
227
+
228
+ function originFromBase(baseURL) {
229
+ try {
230
+ const u = new URL(String(baseURL || '').trim() || 'http://localhost');
231
+ return u.origin;
232
+ } catch {
233
+ return 'http://localhost';
234
+ }
235
+ }
236
+
237
+ function resolveLoginUrl(baseURL, apiPath) {
238
+ const p = String(apiPath || '').trim();
239
+ if (!p) return '';
240
+ if (/^https?:\/\//i.test(p)) return p;
241
+ const base = String(baseURL || '').replace(/\/+$/, '');
242
+ if (!base) return p.startsWith('/') ? p : `/${p}`;
243
+ return `${base}${p.startsWith('/') ? p : `/${p}`}`;
244
+ }
245
+
246
+ /**
247
+ * 调接口登录并写 `.auth/admin.json`。
248
+ * @returns {{ ok: true, storageState: string, tokenSaved: boolean } | { ok: false, error: string }}
249
+ */
250
+ export async function runSsoLoginAndSave({ dir, envName = '', baseURL = '', envMap, signal }) {
251
+ const root = String(dir || '');
252
+ if (!root || !fs.existsSync(root)) {
253
+ return { ok: false, error: '项目目录不存在' };
254
+ }
255
+ const env = envMap ?? readProjectEnvMap(root, envName);
256
+ const endpoint = resolveLoginApiEndpoint(env);
257
+ const apiPath = endpoint.value;
258
+ if (!apiPath) {
259
+ return {
260
+ ok: false,
261
+ error:
262
+ '未配置登录接口地址。请在环境配置填写 LOGIN_API_PATH / LOGIN_API_URL,或其它 LOGIN_API_* 地址类变量。',
263
+ };
264
+ }
265
+ const username = String(env.ADMIN_USERNAME || env.USER_USERNAME || '').trim();
266
+ const password = String(env.ADMIN_PASSWORD || env.USER_PASSWORD || '');
267
+ if (!username || !password) {
268
+ return { ok: false, error: '未配置 ADMIN_USERNAME / ADMIN_PASSWORD(或 USER_*)' };
269
+ }
270
+ const bodyTemplate =
271
+ String(env.LOGIN_API_BODY || '').trim() ||
272
+ '{"username":"{{username}}","password":"{{password}}"}';
273
+ const url = resolveLoginUrl(baseURL || env.BASE_URL || '', apiPath);
274
+ if (!url || !/^https?:\/\//i.test(url)) {
275
+ return {
276
+ ok: false,
277
+ error: `无法拼出登录接口地址:请配置 BASE_URL,或在 ${endpoint.key || 'LOGIN_API_PATH'} 里写完整 URL`,
278
+ };
279
+ }
280
+
281
+ let response;
282
+ try {
283
+ response = await fetch(url, {
284
+ method: 'POST',
285
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
286
+ body: renderBody(bodyTemplate, username, password),
287
+ signal: signal
288
+ ? AbortSignal.any([signal, AbortSignal.timeout(30_000)])
289
+ : AbortSignal.timeout(30_000),
290
+ });
291
+ } catch (err) {
292
+ return {
293
+ ok: false,
294
+ error: `请求登录接口失败:${err instanceof Error ? err.message : String(err)}`,
295
+ };
296
+ }
297
+
298
+ const rawText = await response.text();
299
+ let json = null;
300
+ try {
301
+ json = JSON.parse(rawText);
302
+ } catch {
303
+ json = null;
304
+ }
305
+ if (!response.ok) {
306
+ return {
307
+ ok: false,
308
+ error: `登录接口返回 ${response.status}${rawText ? `:${rawText.slice(0, 200)}` : ''}`,
309
+ };
310
+ }
311
+
312
+ const explicitTokenPath = String(env.LOGIN_API_TOKEN_PATH || env.LOGIN_TOKEN_PATH || '').trim();
313
+ const { token, path: tokenPathUsed } = resolveLoginToken(json, explicitTokenPath);
314
+ const storageKey = token ? resolveTokenStorageKey(env, 'token') : '';
315
+
316
+ const cookies = [];
317
+ const setCookie = [];
318
+ if (typeof response.headers.getSetCookie === 'function') {
319
+ setCookie.push(...response.headers.getSetCookie());
320
+ }
321
+ // 兼容没有 getSetCookie 的运行时:单条 set-cookie
322
+ if (!setCookie.length) {
323
+ const single = response.headers.get('set-cookie');
324
+ if (single) setCookie.push(single);
325
+ }
326
+ for (const line of setCookie) {
327
+ const [pair] = String(line).split(';');
328
+ const eq = pair.indexOf('=');
329
+ if (eq <= 0) continue;
330
+ const name = pair.slice(0, eq).trim();
331
+ const value = pair.slice(eq + 1).trim();
332
+ if (!name) continue;
333
+ try {
334
+ const origin = new URL(url);
335
+ cookies.push({
336
+ name,
337
+ value,
338
+ domain: origin.hostname,
339
+ path: '/',
340
+ expires: -1,
341
+ httpOnly: /httponly/i.test(line),
342
+ secure: origin.protocol === 'https:',
343
+ sameSite: 'Lax',
344
+ });
345
+ } catch {
346
+ // ignore bad cookie
347
+ }
348
+ }
349
+
350
+ // localStorage 必须挂在「打开业务页的 origin」上;登录接口域名常与 BASE_URL 不同,
351
+ // 只写 API origin 时页面读不到 token → 业务请求变成 undefined / 非法请求。
352
+ const appOrigin = originFromBase(baseURL || env.BASE_URL || '');
353
+ const apiOrigin = originFromBase(url);
354
+ const storageOrigins = [
355
+ ...new Set([appOrigin, apiOrigin].filter((item) => item && item !== 'http://localhost')),
356
+ ];
357
+ if (!storageOrigins.length) storageOrigins.push(apiOrigin || appOrigin || 'http://localhost');
358
+
359
+ const localStorage = [];
360
+ if (token) {
361
+ // 与常见 Playwright auth.setup 对齐:主 key 用 token(可用 LOGIN_TOKEN_STORAGE_KEY 覆盖)
362
+ const primary = storageKey || 'token';
363
+ localStorage.push({ name: primary, value: token });
364
+ if (primary !== 'token') localStorage.push({ name: 'token', value: token });
365
+ }
366
+ // 许多中台(含本仓库挂载的热线项目)除 token 外还要 loginUser=整份 data,缺了会「非法请求」
367
+ const loginUser =
368
+ json && typeof json.data === 'object' && json.data
369
+ ? json.data
370
+ : json && typeof json === 'object'
371
+ ? null
372
+ : null;
373
+ if (loginUser) {
374
+ localStorage.push({ name: 'loginUser', value: JSON.stringify(loginUser) });
375
+ }
376
+
377
+ if (!cookies.length && !localStorage.length) {
378
+ const sample =
379
+ json && typeof json === 'object'
380
+ ? ` 响应字段:${Object.keys(json).slice(0, 8).join(', ') || '(空)'}`
381
+ : rawText
382
+ ? ` 响应片段:${rawText.slice(0, 120)}`
383
+ : '';
384
+ return {
385
+ ok: false,
386
+ error:
387
+ '接口已响应,但没有拿到可写入的 cookie / token。可配置 LOGIN_API_TOKEN_PATH(响应里 token 的路径)与 LOGIN_TOKEN_STORAGE_KEY(须与框架读取的 key 一致),或确认接口会 Set-Cookie。' +
388
+ sample,
389
+ };
390
+ }
391
+
392
+ const state = {
393
+ cookies,
394
+ origins: localStorage.length ? storageOrigins.map((origin) => ({ origin, localStorage })) : [],
395
+ };
396
+ const abs = path.join(root, AUTH_REL);
397
+ signal?.throwIfAborted();
398
+ fs.mkdirSync(path.dirname(abs), { recursive: true });
399
+ fs.writeFileSync(abs, `${JSON.stringify(state, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 });
400
+ return {
401
+ ok: true,
402
+ storageState: AUTH_REL.replace(/\\/g, '/'),
403
+ tokenSaved: Boolean(token && storageKey),
404
+ tokenPath: tokenPathUsed || '',
405
+ storageKey: storageKey || '',
406
+ };
407
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lantern-harness",
3
- "version": "0.1.44",
3
+ "version": "0.2.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "AI 工作台:对话与插件工具、内容库、模板库、会话记忆,数据留在本机。",
@@ -39,6 +39,7 @@
39
39
  "lh-plugins",
40
40
  "config",
41
41
  "prompt",
42
+ "skills",
42
43
  "docs",
43
44
  "空间池/.gitkeep",
44
45
  "CHANGELOG.md",
@@ -94,12 +95,14 @@
94
95
  "jszip": "^3.10.2",
95
96
  "mammoth": "^1.13.0",
96
97
  "marked": "^15.0.6",
98
+ "playwright": "^1.65.1",
97
99
  "react": "^19.0.0",
98
100
  "react-dom": "^19.0.0",
99
101
  "react-grid-layout": "2.3.0",
100
102
  "sirv": "^3.0.2",
101
103
  "word-extractor": "^1.0.4",
102
- "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
104
+ "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
105
+ "zod": "^4.6.7"
103
106
  },
104
107
  "optionalDependencies": {
105
108
  "node-pty": "^1.0.0"
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: case-execution
3
+ description: 通过 Lantern 逐条执行已有测试用例、等待 AI 浏览器结果、人工确认后写回用例文件,并在失败或阻塞时衔接缺陷工作流。用于「执行某条用例」「查看执行进度」「确认执行结果」「把结果同步到执行统计」等请求;不用于生成或评审用例。
4
+ ---
5
+
6
+ # Lantern 单条用例执行
7
+
8
+ Lantern 是执行记录、用例文件和确认结果的唯一持久化入口。使用 `lantern_case_execution_*` MCP 工具,不直接编辑 Excel、Markdown、CSV 或隐藏运行记录。
9
+
10
+ ## 开始前
11
+
12
+ 1. 调用 `lantern_case_execution_files`,确认目标文件具备「用例状态」和「实际结果」列。`.xls` 必须先另存为 `.xlsx`,缺少执行列的文件不能执行。
13
+ 2. 调用 `lantern_case_execution_cases` 读取明细,按用例编号或标题定位唯一一行,并记录 `rowIndex`。
14
+ 3. 确认测试地址。目标地址必须来自本次用户输入;不要沿用其他任务或空间中的地址。
15
+ 4. 优先复用用户提供的 storageState 路径,或先检查是否已有保存登录态。需要本人完成验证码、扫码或账号登录时,调用 `lantern_case_execution_login_start`,由用户完成后再调用 `lantern_case_execution_login_complete`;不要在对话中索取或持久化账号密码。
16
+
17
+ ## 执行
18
+
19
+ 1. 每次只对用户指定的一条用例调用 `lantern_case_execution_start`,不要自行连续执行整份文件。
20
+ 2. 调用后用 `lantern_case_execution_wait` 等待,未结束时继续按 `afterSeq` 读取新增日志和进度;等待期间向用户报告当前阶段、已用时和工具操作数。
21
+ 3. 只有页面、截图、控制台或网络证据真正支持预期结果时才能建议「通过」。明确与预期不一致为「不通过」;登录失效、验证码、权限、测试数据或系统弹窗导致无法完成时为「阻塞」;用例不适用且理由充分时为「跳过」。
22
+ 4. 不要替用户确认。向用户展示建议状态、实际结果、判定依据、未验证项和证据;用户可把状态改为「待验证 / 通过 / 不通过 / 阻塞 / 跳过」。
23
+ 5. 需要停止时调用 `lantern_case_execution_stop`,保留已产生的日志和截图。
24
+
25
+ ## 确认与后续
26
+
27
+ 1. 用户明确确认后调用 `lantern_case_execution_apply`,只写回文件已有的执行列。文件已被外部修改时停止并重新读取,不能覆盖新内容。
28
+ 2. 结果为「不通过」或「阻塞」时,主动提供创建缺陷入口,但不要在用户未要求时自动提交。用户要求提缺陷时,转入 `lantern-defect-submit`,把用例、目标地址、实际结果和证据作为待核验上下文。
29
+ 3. 用户要求同步统计时,先调用 `lantern_case_execution_sync_stats` 的 `preview`。已有同日手工统计时不自动覆盖;只有用户明确选择后才使用 `skip` 或 `overwrite`。
30
+ 4. 执行记录、日志和截图保存在当前空间的 `.lantern/local/case-execution/`。不要把这些内部文件加入 `用例管理/`,也不要把浏览器 Cookie、Token 或 API Key 写入结果。
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: lantern-defect-submit
3
+ description: 通过 Lantern 按当前空间规则生成、补全、提交或核验缺陷。用于「生成缺陷」「提交缺陷」「补充缺陷草稿」「查看缺陷提交回执」等请求,适用于已配置的缺陷入口。
4
+ ---
5
+
6
+ # Lantern 缺陷提交
7
+
8
+ 1. 先调用 `lantern_defect_templates` 列出规则。按用户指定的规则调用 `lantern_defect_template_select`,多份规则且用户未指定时询问选择。已有选定规则时可直接使用。调用 `lantern_defect_context` 获取当前空间的缺陷入口、规则、映射字段和可用选项。插件停用或尚未配置时,引导用户在 Lantern「插件仓库 → 测试技能」开启「缺陷规则」。用户明确要求维护缺陷规则时,先用 `lantern_defect_rule_inspect` 读取真实入口、子表和字段,再用 `lantern_defect_rule_save` 保存;删除规则前必须获得用户明确确认并使用 `lantern_defect_rule_delete`。使用上下文返回的规则,避免把具体团队的规则硬编码在 Skill 中。
9
+ 2. 用描述、截图或日志中有依据的事实生成结构化缺陷。以字段 ID 作键。每个字段的 `rule` 是必须执行的判断或生成口径:严重程度、优先级等需要判断的字段,只要 `rule` 提供了判断标准,就应按标准分析问题影响并说明依据,不能仅因需要判断而留空或要求用户决定。`defaultValue` 是规则默认值,只在没有用户值、材料证据或可执行 `rule` 结果时兜底;本次输入或材料明确提供其他值时优先使用本次值。选项和关联字段使用当前平台上下文要求的稳定标识(例如选项 ID、成员 ID、issue key 或 bug ID),多值使用标识数组。规则上下文包含 `iteration` 时,目标字段「迭代版本」必须直接使用这个当前迭代,不再向用户重复询问,也不能被其他来源覆盖。图片字段先用目标平台的上传能力取得 image ID,再传 image ID 数组;附件字段只有在连接器明确支持上传和回写时填写,否则保持为空,不能把本地路径或普通文本写进附件字段;非必填的图片 / 附件没有材料时直接留空,不阻塞提交。通用规则若引用其他文档、知识库页面或目标平台记录,必须先通过当前空间可用且与目标平台匹配的工具读取并核对其中的项目、测试分项目、经办人、迭代等事实;通用规则给出的业务映射优先于常识推断,例如指定经办人归前端、其他经办人归后端时,应先匹配真实经办人,再填写测试项目和测试分项目,空白或无关人员不能自动算作“其他”。负责人、迭代、需求关联等缺少可匹配事实时不能猜;确实无法按 `rule` 和现有证据判断的其他字段应留空或说明待确认。
10
+ 3. 整理「重现步骤」时,操作动作与前置内容分开:账号密码、登录账号、权限、特定数据准备等不属于操作步骤的内容,要放到操作步骤之后的「前置条件:」小节,并以 `1.`、`2.` 逐条编号;没有前置条件时不添加该小节,不能编造账号密码。
11
+ 4. 需要恢复未完成工作时,先调用 `lantern_defect_drafts` 查看当前空间的草稿与状态,避免重复新建。调用 `lantern_defect_draft_save`,传入上下文 `revision` 作为 `contextRevision`。未传入的字段由服务端套用规则默认值。编辑草稿时也传上次返回的草稿 `id` 和草稿 `revision`。如有版本冲突,重新读上下文并检查用户意图。
12
+ 5. 按用户意图处理保存后的草稿:「生成缺陷」「先做个草稿」「预览后再提交」只保存并展示目标、完整非空字段和 `missing`,不提交。用户说「提个缺陷」「提交缺陷」「录入缺陷」等明确要求最终提交的表达,就是授权直接提交:保存草稿后应在同一轮立即用该草稿的 `id` 和 `revision` 调用 `lantern_defect_submit`,不要再要求用户二次确认。只有必填字段缺失、目标有歧义,或负责人、迭代、需求关联等关键字段无法从证据匹配时才停下来说明。修改用户已确认的草稿后应重新提交核验。对于 `platform: manual` 的入口,提供可复制的缺陷正文和目标入口。
13
+ 6. 只有返回 `status: submitted` 才报告成功,并附缺陷编号、目标入口和记录标识(如 record_id、issue key 或 bug ID)。返回 `pending` 时用 `lantern_defect_receipt` 核验同一草稿。没有记录标识时说明需人工核对目标平台,不能重提或新建草稿来绕过。
14
+
15
+ 每个字段的 rule 是该字段的填写要求,defaultValue 是与填写要求分离的规则默认值。手动规则可以尚无目标入口,使用时按用户输入确定目标并通过远端真实字段核对。包含手动字段的规则通过工作台或与目标平台匹配的连接器解析和执行,不使用旧版直接提交工具猜测列名。目标平台可能是腾讯文档、JIRA、禅道或其他已连接系统,必须按任务中的 platform 选择工具,不能默认走腾讯文档。
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: lantern-workflow
3
+ description: Use Lantern Harness MCP tools for requirement import, requirement breakdown, story review, test points and Lantern-backed test assets. Use when the user provides a requirement document or says to analyze, break down, review or generate tests with Lantern.
4
+ ---
5
+
6
+ # Lantern Workflow
7
+
8
+ Lantern is the source of truth for requirement documents and test assets. Codex is the conversation and reasoning entry point.
9
+
10
+ ## Routing
11
+
12
+ - “拆解这个需求” means: import or select the source, run requirement breakdown, save stories, then return a summary. Do not generate test points or test cases unless asked.
13
+ - “完整需求分析” means: breakdown, save stories, review stories, generate test points, then return the combined summary.
14
+ - “生成测试点” means: use existing saved stories and a Lantern test-point skill. Do not silently replace stories.
15
+ - “继续生成用例” or “完整测试设计” continues from the saved requirement analysis.
16
+ - If multiple documents could be “这个需求”, ask which source before writing.
17
+
18
+ ## Requirement breakdown
19
+
20
+ 1. On first use, call `lantern_requirement_prepare` to enable the Lantern workflow capabilities and seed their skills. Repeat calls are safe.
21
+ 2. If the user supplied a local file in Codex, call `lantern_requirement_import` with its absolute path. Set `folder` only when the user specifies a destination folder in Lantern. Keep the returned `sourcePath`.
22
+ 3. When resuming an existing analysis without a known path, call `lantern_requirement_analysis_list` and select by title, source or ID. Otherwise call `lantern_requirement_context` with `sourcePath`, or call `lantern_requirement_sources` first when the desired document is already in Lantern.
23
+ 4. Follow the returned Lantern analysis and outline skill instructions. Produce the `outline` and `stories` objects from its `outputContract`.
24
+ 5. Preserve every exact source reference in `sourceRefs`. Do not invent a source ID.
25
+ 6. For a new analysis, call `lantern_requirement_analysis_save` once with the complete result. For an existing analysis, pass its latest `existingAnalysisRevision` as `expectedRevision`.
26
+ 7. Return the `analysisId`, story count, coverage-relevant source count, unresolved questions and `artifactUrl`.
27
+
28
+ ## Story review
29
+
30
+ 1. Call `lantern_requirement_review_context` with the `analysisId`.
31
+ 2. Follow the returned Lantern review skill and `outputContract`.
32
+ 3. Report only actionable conflicts, ambiguity, missing scenarios and untestable acceptance criteria.
33
+ 4. Call `lantern_requirement_review_save` with the result and the current `revision`. Do not rewrite stories in the same tool call.
34
+
35
+ ## Test points
36
+
37
+ 1. Call `lantern_testpoints_context` with the `analysisId`.
38
+ 2. Follow the returned Lantern test-point skill and `outputContract`.
39
+ 3. Use only `functional`, `boundary`, `exception`, `business`, `nonfunctional`, and P0–P3 priorities.
40
+ 4. Call `lantern_testpoints_save` with the complete report and the current `revision`.
41
+
42
+ ## Editing existing results
43
+
44
+ - To change one story, read the analysis, then call `lantern_requirement_story_patch` with its `storyId`, `revision` and only the changed fields.
45
+ - To remove one story, call `lantern_requirement_story_delete` with its `storyId` and current `revision`. This also removes test points that referenced the story.
46
+ - If any write returns a revision conflict, call `lantern_requirement_analysis_get` again, inspect the newer Lantern content and reapply the intended change. Never retry the old payload blindly.
47
+ - After a story change leaves existing test points, state that they need review or regeneration when the change affects behavior, acceptance criteria, boundaries or source coverage.
48
+
49
+ ## Data and safety
50
+
51
+ - Never edit Lantern JSON files directly.
52
+ - Never use browser automation to click Lantern UI for ordinary operations.
53
+ - Use `analysisId`, `revision` and the latest saved content before modifying.
54
+ - Disabled Lantern skills are not valid workflow rules. Use `lantern_skill_list` to check status; include disabled skills only when the user asks to inspect the store.
55
+ - Previewing means not calling the save tool. Saving is a separate explicit action.
56
+ - Bulk deletion and replacing stories require an explicit user request. Delete whole analyses only with `lantern_requirement_analysis_delete`.
57
+ - Return Lantern artifact URLs and summaries to the user.