lantern-harness 0.1.43 → 0.1.45

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 (153) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +1 -1
  3. package/builtin/session/lh-nav-groups.mjs +18 -4
  4. package/dist/500.html +61 -5
  5. package/dist/_astro/Base.Bkt1lrgu.css +1 -0
  6. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.Chv7r8_9.js → Base.astro_astro_type_script_index_0_lang.UKTVQqk7.js} +1 -1
  7. package/dist/_astro/{CaseExecBoard.DUMjSunb.js → CaseExecBoard.DICluCbK.js} +1 -1
  8. package/dist/_astro/{CaseGenerateApp.DtuOyQuv.js → CaseGenerateApp.Be3h5XPG.js} +1 -1
  9. package/dist/_astro/{CasesLibrary.B9o_jvXb.js → CasesLibrary.Buys7Cy-.js} +3 -3
  10. package/dist/_astro/ChatApp.D3BheKci.js +227 -0
  11. package/dist/_astro/ConfirmDialog.DrrPf1MB.js +1 -0
  12. package/dist/_astro/{DashboardBoard.DEvgMoqo.js → DashboardBoard.Qvf8o4v1.js} +1 -1
  13. package/dist/_astro/{DocsFileBrowser.D66pN9rp.js → DocsFileBrowser.DwKBffbM.js} +1 -1
  14. package/dist/_astro/{DocsPager.ceBEecmd.js → DocsPager.Duf4I68E.js} +1 -1
  15. package/dist/_astro/{DrawerField.CWpOf3L_.js → DrawerField.BH3p4Q4D.js} +1 -1
  16. package/dist/_astro/{KnowledgeLibrary.DYqE2mRi.js → KnowledgeLibrary.MDpMqeOd.js} +1 -1
  17. package/dist/_astro/{LifeKrTasksBoard.B7UiEutA.js → LifeKrTasksBoard.DsvW_S66.js} +1 -1
  18. package/dist/_astro/{LifeKrTodosBoard.VL7HdhNY.js → LifeKrTodosBoard.D2KTqvg1.js} +1 -1
  19. package/dist/_astro/{LifeObjectivesBoard.lLBPOHEZ.js → LifeObjectivesBoard.B0cDK934.js} +1 -1
  20. package/dist/_astro/{LifePlanTypeSelect.CdKQmlEK.js → LifePlanTypeSelect.BELDvMWU.js} +1 -1
  21. package/dist/_astro/{LifeReviewsBoard.AjO4SbsR.js → LifeReviewsBoard.BPXeVpg1.js} +1 -1
  22. package/dist/_astro/{LifeShared.CtdsQI43.js → LifeShared.tnT7aQON.js} +1 -1
  23. package/dist/_astro/{LifeStagesBoard.Dl-kTZ6K.js → LifeStagesBoard.CZftLR9K.js} +1 -1
  24. package/dist/_astro/{LifeYearCycleSelect.BILJOKXK.js → LifeYearCycleSelect.Bw2eRbSm.js} +1 -1
  25. package/dist/_astro/{LifeYearPlansBoard.BzJmi7Hw.js → LifeYearPlansBoard.DB-RJFEl.js} +1 -1
  26. package/dist/_astro/{MultiSelectDropdown.y8JMbCxO.js → MultiSelectDropdown.CBC7aNOv.js} +1 -1
  27. package/dist/_astro/NavLibraries.DdQYsZbe.js +1 -0
  28. package/dist/_astro/OverflowHint.CHZeFfUj.js +1 -0
  29. package/dist/_astro/{PluginsPage.D2OrUGY3.js → PluginsPage.C1JnInH4.js} +1 -1
  30. package/dist/_astro/PluginsPage.C3eEwy3K.js +1 -0
  31. package/dist/_astro/{PmBugsBoard.BynUocbE.js → PmBugsBoard.CGpXUTPu.js} +1 -1
  32. package/dist/_astro/{PmIterationsBoard.CvFblvfX.js → PmIterationsBoard.BaKiFIam.js} +1 -1
  33. package/dist/_astro/{PmProjectDetail.Dlm6flwk.js → PmProjectDetail.DneFVBpy.js} +1 -1
  34. package/dist/_astro/{PmProjectsBoard.B5vaWuax.js → PmProjectsBoard.BxoMF9gK.js} +1 -1
  35. package/dist/_astro/PmRequirementsBoard.-SI8VZXI.js +1 -0
  36. package/dist/_astro/{PmRequirementsBoard.piRWjiYA.js → PmRequirementsBoard.DsK6RF7Q.js} +1 -1
  37. package/dist/_astro/PmShared.BK8kWRSV.js +1 -0
  38. package/dist/_astro/{PromptMountDialog.DYojFMok.js → PromptMountDialog.mrTx3U5T.js} +1 -1
  39. package/dist/_astro/PromptsLibrary.B_SUf47p.js +1 -0
  40. package/dist/_astro/{ReportsPage.B-xhGVEU.js → ReportsPage.B9lGg1_s.js} +1 -1
  41. package/dist/_astro/{ReqAnalysisBoard.B3sAOuAq.js → ReqAnalysisBoard.CIZKnCQH.js} +1 -1
  42. package/dist/_astro/{RequirementsLibrary.BGys7DeN.js → RequirementsLibrary.cJc-bnGQ.js} +1 -1
  43. package/dist/_astro/{SearchableSelect.DFZBUFIs.js → SearchableSelect.SyLRS-Jj.js} +1 -1
  44. package/dist/_astro/SelectDropdown.T3CKHaLt.js +1 -0
  45. package/dist/_astro/{SettingsDialog.CEyjZuxq.js → SettingsDialog.DYdtCvLc.js} +1 -1
  46. package/dist/_astro/{SpaceSwitcher.DJqvw5Lw.js → SpaceSwitcher.C47_S1g9.js} +1 -1
  47. package/dist/_astro/{TableFieldConfig.D0v9S2g3.js → TableFieldConfig.C7O-mL-p.js} +1 -1
  48. package/dist/_astro/{TasksBoard.DZ9LLl_c.js → TasksBoard.BUEg2BYk.js} +1 -1
  49. package/dist/_astro/{TemplatesLibrary.iyj_kFMO.js → TemplatesLibrary.BLVIphXO.js} +1 -1
  50. package/dist/_astro/{TestReportsLibrary.B6pf0d7W.js → TestReportsLibrary.DVq30Jae.js} +1 -1
  51. package/dist/_astro/{TestStatsBoard.DS_2bqWI.js → TestStatsBoard.-5BWQ6bI.js} +1 -1
  52. package/dist/_astro/{TodosBoard.CYAVDD1W.js → TodosBoard.DI_lTp2e.js} +1 -1
  53. package/dist/_astro/UiAutoBoard.ChFdgv7s.js +2 -0
  54. package/dist/_astro/UiAutoEnvPanel.B50q4kYb.js +19 -0
  55. package/dist/_astro/UiAutoGenerationDialog.CLkFAHrm.js +1 -0
  56. package/dist/_astro/UiAutoProjectsPage.DCsDeN5d.js +3 -0
  57. package/dist/_astro/app-config.DkyjuL-S.js +1 -0
  58. package/dist/_astro/app-version.Cy-5oZO2.js +1 -0
  59. package/dist/_astro/{bash-tools.CfNj2sh0.js → bash-tools.D9HCzC_7.js} +1 -1
  60. package/dist/_astro/{case-gen-run.nrr97yK3.js → case-gen-run.BklG1H8k.js} +1 -1
  61. package/dist/_astro/{case-types.B51yDRdf.js → case-types.DlFkbZJN.js} +1 -1
  62. package/dist/_astro/composer-draft.llpvz3MW.js +1 -0
  63. package/dist/_astro/composer-task.DRi5tAJs.js +5 -0
  64. package/dist/_astro/{hydrate-cache.CoD1FB3T.js → hydrate-cache.B15Nrpq0.js} +1 -1
  65. package/dist/_astro/i18n.D_aOCHSN.js +7 -0
  66. package/dist/_astro/{open-docs-in-session.DJtuI1C4.js → open-docs-in-session.CRiZT022.js} +1 -1
  67. package/dist/_astro/plugins.BRvXWHLe.js +1 -0
  68. package/dist/_astro/prompts-meta.BUGutlsk.js +2 -0
  69. package/dist/_astro/{req-analysis.qmyv5cBw.js → req-analysis.B12_MGMQ.js} +1 -1
  70. package/dist/_astro/{settings.CYERib3l.js → settings.38J2uD5M.js} +2 -2
  71. package/dist/_astro/{spaces-client.DvIgFink.js → spaces-client.DV04tRyD.js} +1 -1
  72. package/dist/_astro/{story-review.2UUlN3p-.js → story-review.D2W5tEOY.js} +1 -1
  73. package/dist/_astro/{test-reports.DPQ-FMsQ.js → test-reports.CuIjlEyK.js} +1 -1
  74. package/dist/_astro/ui-auto-prompt.H9_yhau9.js +9 -0
  75. package/dist/_astro/ui-auto.DMv940x4.js +1 -0
  76. package/dist/_astro/{view-prefs.GnvelRDj.js → view-prefs.DhdLZjGh.js} +1 -1
  77. package/dist/case-exec/index.html +62 -6
  78. package/dist/cases/generate/index.html +62 -6
  79. package/dist/cases/library/index.html +62 -6
  80. package/dist/dashboard/index.html +62 -6
  81. package/dist/docs/changelog/index.html +138 -50
  82. package/dist/docs/install/index.html +61 -5
  83. package/dist/docs/manual/index.html +129 -21
  84. package/dist/knowledge/index.html +62 -6
  85. package/dist/life/kr-tasks/index.html +62 -6
  86. package/dist/life/kr-todos/index.html +62 -6
  87. package/dist/life/objectives/index.html +62 -6
  88. package/dist/life/reviews/index.html +62 -6
  89. package/dist/life/stages/index.html +62 -6
  90. package/dist/life/year-plans/index.html +62 -6
  91. package/dist/plugins/index.html +62 -6
  92. package/dist/pm/bugs/index.html +62 -6
  93. package/dist/pm/iterations/index.html +62 -6
  94. package/dist/pm/projects/detail/index.html +62 -6
  95. package/dist/pm/projects/index.html +62 -6
  96. package/dist/pm/requirements/index.html +62 -6
  97. package/dist/prompts/index.html +62 -6
  98. package/dist/reports/index.html +62 -6
  99. package/dist/requirement-analysis/index.html +62 -6
  100. package/dist/requirements/index.html +62 -6
  101. package/dist/tasks/index.html +62 -6
  102. package/dist/templates/index.html +62 -6
  103. package/dist/test-automation/index.html +63 -7
  104. package/dist/test-automation/projects/index.html +980 -0
  105. package/dist/test-reports/index.html +62 -6
  106. package/dist/test-stats/index.html +62 -6
  107. package/dist/todos/index.html +62 -6
  108. package/dist/workbench/index.html +62 -6
  109. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +1 -1
  110. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +107 -63
  111. package/lh-plugins/lh-uiauto.mjs +2502 -51
  112. package/lh-plugins/plugin-prompts.mjs +62 -2
  113. package/lh-plugins/storage-domain.mjs +17 -4
  114. package/lh-plugins/uiauto-adapters/playwright.mjs +29 -14
  115. package/lh-plugins/uiauto-adapters/tasks.mjs +8 -2
  116. package/lh-plugins/uiauto-env.mjs +669 -0
  117. package/lh-plugins/uiauto-explorer/apps.mjs +4 -5
  118. package/lh-plugins/uiauto-explorer/emit-files.mjs +32 -9
  119. package/lh-plugins/uiauto-explorer/emit-ts.mjs +13 -2
  120. package/lh-plugins/uiauto-explorer/ir.mjs +20 -0
  121. package/lh-plugins/uiauto-explorer/sessions.mjs +36 -0
  122. package/lh-plugins/uiauto-node.mjs +327 -0
  123. package/lh-plugins/uiauto-pm.mjs +178 -0
  124. package/lh-plugins/uiauto-prompt.mjs +228 -18
  125. package/lh-plugins/uiauto-report.mjs +16 -0
  126. package/lh-plugins/uiauto-scaffold/audit.mjs +356 -0
  127. package/lh-plugins/uiauto-scaffold/index.mjs +25 -0
  128. package/lh-plugins/uiauto-scaffold/library.mjs +508 -0
  129. package/lh-plugins/uiauto-scaffold/manifest.mjs +83 -0
  130. package/lh-plugins/uiauto-scaffold/render.mjs +133 -0
  131. package/lh-plugins/uiauto-scaffold/templates/playwright-ts.json +225 -0
  132. package/lh-plugins/uiauto-scaffold/templates/playwright-ts.mjs +46 -0
  133. package/package.json +1 -1
  134. package/dist/_astro/Base.BnVp5Mf8.css +0 -1
  135. package/dist/_astro/ChatApp.CKPGFibd.js +0 -227
  136. package/dist/_astro/ConfirmDialog.D5qXeML0.js +0 -1
  137. package/dist/_astro/NavLibraries.BnaL-km5.js +0 -1
  138. package/dist/_astro/OverflowHint.pvo2Xc8R.js +0 -1
  139. package/dist/_astro/PluginsPage.CMW4hEFr.js +0 -1
  140. package/dist/_astro/PmRequirementsBoard.B8KTeso8.js +0 -1
  141. package/dist/_astro/PmShared.86HEsdd_.js +0 -1
  142. package/dist/_astro/PromptsLibrary.GpNbBTj1.js +0 -1
  143. package/dist/_astro/SelectDropdown.Dmk5n225.js +0 -1
  144. package/dist/_astro/SlideOverDrawer.C1IVOc_8.js +0 -1
  145. package/dist/_astro/UiAutoBoard.DSsiMfx2.js +0 -9
  146. package/dist/_astro/app-config.DwpFFa5D.js +0 -1
  147. package/dist/_astro/app-version.Dabxyva-.js +0 -1
  148. package/dist/_astro/composer-task.DJmluzPT.js +0 -5
  149. package/dist/_astro/i18n.vo2aElR9.js +0 -7
  150. package/dist/_astro/plugins.BmKRnp4a.js +0 -1
  151. package/dist/_astro/prompts-meta.bF2q5SUy.js +0 -2
  152. package/dist/_astro/ui-auto-prompt.COBTt5Gd.js +0 -4
  153. package/dist/_astro/ui-auto.BmC9JJ_X.js +0 -1
@@ -0,0 +1,356 @@
1
+ /**
2
+ * 骨架体检:新建项目前对「要落盘的这套骨架」做确定性检查。
3
+ *
4
+ * 这里只做规则判断,不调模型:模型那一路在 `uiauto-prompt.mjs` 的
5
+ * 「自动化项目提示词」里,输出 findings + patches,由前端应用后再走一遍本文件。
6
+ *
7
+ * 输出两样东西:
8
+ * - `logs`:给「检查」步骤的实时日志(阶段 + 等级 + 一句人话);
9
+ * - `checks`:问题清单,`level=error` 表示不修就不该生成。
10
+ */
11
+
12
+ /** 检查阶段:前端按这个顺序分组显示日志 */
13
+ export const AUDIT_STAGES = ['skeleton', 'structure', 'render', 'target'];
14
+
15
+ const now = () => new Date().toISOString();
16
+
17
+ /** 必需的骨架文件:缺了就不是一个能跑的测试项目 */
18
+ const REQUIRED_FILES = ['package.json', 'playwright.config.ts'];
19
+
20
+ /**
21
+ * 骨架只自带一条框架自检,所以只要求它带 @smoke:
22
+ * 业务用例的分级标签(@regression / @edge)等真的有用例时再检查也不迟。
23
+ */
24
+ const REQUIRED_TAGS = ['@smoke'];
25
+
26
+ /** 硬编码凭据的粗判:赋值语句里直接写 password / token 且看起来像真实值 */
27
+ const HARDCODED_SECRET =
28
+ /(password|passwd|pwd|secret|token|api[_-]?key)\s*[:=]\s*['"`](?!\$\{|\{\{|process\.env|os\.environ)[^'"`\n]{3,}['"`]/i;
29
+
30
+ /** 本机绝对地址写死(应走 BASE_URL) */
31
+ const HARDCODED_URL = /['"`]https?:\/\/(?!localhost|127\.0\.0\.1)[^'"`\s]+['"`]/;
32
+
33
+ function fileOf(files, target) {
34
+ return files.find((file) => file.path === target) ?? null;
35
+ }
36
+
37
+ function anyFile(files, predicate) {
38
+ return files.some((file) => predicate(file.path));
39
+ }
40
+
41
+ /** `package.json` 解析失败时返回 null,由调用方记 error */
42
+ function parsePackage(files) {
43
+ const file = fileOf(files, 'package.json');
44
+ if (!file) return null;
45
+ try {
46
+ return JSON.parse(file.content);
47
+ } catch {
48
+ return null;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * 体检入口。
54
+ *
55
+ * @param {{
56
+ * skeleton: { id: string, stack?: string, options: Array<object>, files: Array<object>, layout?: object },
57
+ * files: Array<{ path: string, content: string }>,
58
+ * options: string[],
59
+ * targetDir?: string,
60
+ * targetProblem?: string,
61
+ * parentProblem?: string,
62
+ * }} input
63
+ * @returns {{
64
+ * ok: boolean,
65
+ * logs: Array<{ at: string, stage: string, level: string, message: string }>,
66
+ * checks: Array<{ id: string, level: 'error'|'warn'|'info', title: string, detail: string, hint?: string, file?: string }>,
67
+ * summary: { errors: number, warnings: number, infos: number, files: number, bytes: number }
68
+ * }}
69
+ */
70
+ export function auditScaffold(input) {
71
+ const skeleton = input?.skeleton ?? null;
72
+ const files = Array.isArray(input?.files) ? input.files : [];
73
+ const picked = new Set(Array.isArray(input?.options) ? input.options : []);
74
+ const logs = [];
75
+ const checks = [];
76
+
77
+ const log = (stage, level, message) => logs.push({ at: now(), stage, level, message });
78
+ const check = (level, id, title, detail, extra = {}) => {
79
+ checks.push({ id, level, title, detail, ...extra });
80
+ log(extra.stage || 'render', level, title);
81
+ };
82
+
83
+ log('skeleton', 'info', `使用骨架 ${skeleton?.id || '(未知)'},${files.length} 个文件`);
84
+ log('structure', 'info', `勾选 ${picked.size} 项附带内容:${[...picked].join(' / ') || '无'}`);
85
+
86
+ /* ── 结构:必需文件 ── */
87
+ for (const required of REQUIRED_FILES) {
88
+ if (!fileOf(files, required)) {
89
+ check(
90
+ 'error',
91
+ `missing-${required}`,
92
+ `缺少 ${required}`,
93
+ '骨架里没有这个文件,生成出来的项目跑不起来。',
94
+ {
95
+ file: required,
96
+ stage: 'structure',
97
+ },
98
+ );
99
+ }
100
+ }
101
+ if (!anyFile(files, (p) => /^tests\/.*\.spec\.ts$/.test(p))) {
102
+ check(
103
+ 'error',
104
+ 'missing-specs',
105
+ '没有用例文件',
106
+ '至少需要一个 tests/**/*.spec.ts,否则 `playwright test` 跑不起来。',
107
+ {
108
+ stage: 'structure',
109
+ },
110
+ );
111
+ }
112
+ for (const laidOut of ['pages/BasePage.ts', 'fixtures/test.ts']) {
113
+ if (!fileOf(files, laidOut)) {
114
+ check(
115
+ 'warn',
116
+ `missing-${laidOut}`,
117
+ `缺少 ${laidOut}`,
118
+ '页面对象基类 / 测试 fixture 缺失,后续生成的用例没有可复用的底座。',
119
+ {
120
+ file: laidOut,
121
+ stage: 'structure',
122
+ },
123
+ );
124
+ }
125
+ }
126
+
127
+ /* ── 渲染结果:package.json / 配置 ── */
128
+ const pkgFile = fileOf(files, 'package.json');
129
+ const pkg = parsePackage(files);
130
+ if (pkgFile && !pkg) {
131
+ check(
132
+ 'error',
133
+ 'package-json-invalid',
134
+ 'package.json 不是合法 JSON',
135
+ '生成出来的项目装不上依赖。',
136
+ {
137
+ file: 'package.json',
138
+ stage: 'render',
139
+ },
140
+ );
141
+ }
142
+ if (pkg) {
143
+ const deps = { ...(pkg.dependencies ?? {}), ...(pkg.devDependencies ?? {}) };
144
+ if (!deps['@playwright/test']) {
145
+ check(
146
+ 'error',
147
+ 'package-json-no-playwright',
148
+ 'package.json 没有 @playwright/test',
149
+ '缺这个依赖,项目识别不出来也跑不了。',
150
+ {
151
+ file: 'package.json',
152
+ stage: 'render',
153
+ },
154
+ );
155
+ } else {
156
+ log('render', 'info', `依赖就绪:@playwright/test ${deps['@playwright/test']}`);
157
+ }
158
+ const scripts = pkg.scripts ?? {};
159
+ if (!scripts.test) {
160
+ check(
161
+ 'warn',
162
+ 'package-json-no-test-script',
163
+ 'package.json 没有 test 脚本',
164
+ '运行页的「全量运行」靠它,缺了只能手写命令。',
165
+ {
166
+ file: 'package.json',
167
+ stage: 'render',
168
+ },
169
+ );
170
+ }
171
+ if (picked.has('allure') && !scripts['report:allure']) {
172
+ check(
173
+ 'error',
174
+ 'allure-script-missing',
175
+ '勾了 Allure 但没有 report:allure 脚本',
176
+ '报告没法生成。',
177
+ {
178
+ file: 'package.json',
179
+ stage: 'render',
180
+ },
181
+ );
182
+ }
183
+ }
184
+
185
+ const configText = fileOf(files, 'playwright.config.ts')?.content ?? '';
186
+ if (configText) {
187
+ if (!/testDir\s*:/.test(configText)) {
188
+ check(
189
+ 'warn',
190
+ 'config-no-testdir',
191
+ 'playwright.config.ts 没有 testDir',
192
+ '出码器按 testDir 决定用例落点,缺了会退化到默认值。',
193
+ {
194
+ file: 'playwright.config.ts',
195
+ stage: 'render',
196
+ },
197
+ );
198
+ } else {
199
+ log('render', 'info', 'playwright.config.ts 已声明 testDir');
200
+ }
201
+ if (!/dependencies\s*:\s*\[\s*['"]setup['"]/.test(configText)) {
202
+ check(
203
+ 'info',
204
+ 'config-no-setup-dep',
205
+ '配置里没有 setup 依赖',
206
+ "如果有登录态,建议加 `dependencies: ['setup']` 保证先登录再跑用例。",
207
+ {
208
+ file: 'playwright.config.ts',
209
+ stage: 'render',
210
+ },
211
+ );
212
+ }
213
+ }
214
+
215
+ /* ── 标签口径 ── */
216
+ const specText = files
217
+ .filter((file) => /^tests\/.*\.spec\.ts$/.test(file.path))
218
+ .map((file) => file.content)
219
+ .join('\n');
220
+ const missingTags = REQUIRED_TAGS.filter((tag) => !specText.includes(tag));
221
+ if (missingTags.length && specText) {
222
+ check(
223
+ 'warn',
224
+ 'tags-incomplete',
225
+ `示例用例没覆盖 ${missingTags.join(' / ')}`,
226
+ '默认的框架自检要带 @smoke,否则 test:smoke 门禁跑不到它。',
227
+ {
228
+ stage: 'render',
229
+ },
230
+ );
231
+ } else if (specText) {
232
+ log('render', 'info', '框架自检带 @smoke 标签');
233
+ }
234
+
235
+ /* ── 写法红线 ── */
236
+ const networkIdle = files.find((file) =>
237
+ /waitForLoadState\(\s*['"]networkidle['"]\s*\)/.test(file.content),
238
+ );
239
+ if (networkIdle) {
240
+ check(
241
+ 'warn',
242
+ 'networkidle',
243
+ `${networkIdle.path} 用了 networkidle`,
244
+ '页面永远等不到 networkidle,容易整条用例超时;改用可见元素断言。',
245
+ {
246
+ file: networkIdle.path,
247
+ stage: 'render',
248
+ },
249
+ );
250
+ }
251
+ const secretFile = files.find((file) => HARDCODED_SECRET.test(file.content));
252
+ if (secretFile) {
253
+ check(
254
+ 'error',
255
+ 'hardcoded-secret',
256
+ `${secretFile.path} 里疑似写死了凭据`,
257
+ '账号密码一律走环境变量,进仓库会泄漏。',
258
+ {
259
+ file: secretFile.path,
260
+ stage: 'render',
261
+ },
262
+ );
263
+ }
264
+ const urlFile = files.find(
265
+ (file) => /^tests\/.*\.spec\.ts$/.test(file.path) && HARDCODED_URL.test(file.content),
266
+ );
267
+ if (urlFile) {
268
+ check(
269
+ 'warn',
270
+ 'hardcoded-url',
271
+ `${urlFile.path} 里写死了非本地地址`,
272
+ '用例里应该用 BASE_URL,否则换环境就得改代码。',
273
+ {
274
+ file: urlFile.path,
275
+ stage: 'render',
276
+ },
277
+ );
278
+ }
279
+
280
+ /* ── 选项与文件一致性 ── */
281
+ const optionChecks = [
282
+ [
283
+ 'authState',
284
+ 'login-state-missing',
285
+ '勾了登录态示例但没有 auth.setup.ts',
286
+ () => fileOf(files, 'tests/auth.setup.ts'),
287
+ ],
288
+ [
289
+ 'husky',
290
+ 'husky-missing',
291
+ '勾了提交规范但没有 husky / commitlint 文件',
292
+ () =>
293
+ anyFile(files, (p) => p.startsWith('.husky/')) || fileOf(files, 'commitlint.config.mjs'),
294
+ ],
295
+ [
296
+ 'ci',
297
+ 'ci-missing',
298
+ '勾了 CI 但没有 workflow 文件',
299
+ () => anyFile(files, (p) => p.startsWith('.github/workflows/') && /\.ya?ml$/.test(p)),
300
+ ],
301
+ [
302
+ 'docker',
303
+ 'docker-missing',
304
+ '勾了 Docker 但没有 Dockerfile / Jenkinsfile',
305
+ () => anyFile(files, (p) => p === 'Dockerfile' || p === 'Jenkinsfile'),
306
+ ],
307
+ [
308
+ 'webServer',
309
+ 'webserver-missing',
310
+ '勾了本地自启动但配置里没有 webServer',
311
+ () => /webServer\s*:/.test(fileOf(files, 'playwright.config.ts')?.content ?? ''),
312
+ ],
313
+ [
314
+ 'lint',
315
+ 'lint-missing',
316
+ '勾了代码规范但没有 ESLint / Prettier 配置',
317
+ () => anyFile(files, (p) => /^eslint\.config\.|^\.prettierrc/.test(p)),
318
+ ],
319
+ ];
320
+ for (const [option, id, title, probe] of optionChecks) {
321
+ if (!picked.has(option)) continue;
322
+ if (!probe()) {
323
+ check('error', id, title, '选项勾了但没产出对应文件,说明骨架里的 when 标记跟选项对不上。', {
324
+ stage: 'render',
325
+ });
326
+ } else {
327
+ log('render', 'info', `${option}:文件齐全`);
328
+ }
329
+ }
330
+
331
+ /* ── 目标目录 ── */
332
+ if (input?.parentProblem) {
333
+ check('error', 'parent-dir', '父目录不可用', input.parentProblem, { stage: 'target' });
334
+ }
335
+ if (input?.targetProblem) {
336
+ check('error', 'target-dir', '目标目录不可用', input.targetProblem, { stage: 'target' });
337
+ } else if (input?.targetDir) {
338
+ log('target', 'info', `目标目录可用:${input.targetDir}`);
339
+ }
340
+
341
+ const errors = checks.filter((item) => item.level === 'error').length;
342
+ const warnings = checks.filter((item) => item.level === 'warn').length;
343
+ const infos = checks.filter((item) => item.level === 'info').length;
344
+ const bytes = files.reduce(
345
+ (sum, file) => sum + Buffer.byteLength(String(file.content ?? ''), 'utf8'),
346
+ 0,
347
+ );
348
+
349
+ log('render', errors ? 'error' : 'info', `体检完成:${errors} 个必须处理、${warnings} 个提示`);
350
+ return {
351
+ ok: errors === 0,
352
+ logs,
353
+ checks,
354
+ summary: { errors, warnings, infos, files: files.length, bytes },
355
+ };
356
+ }
@@ -0,0 +1,25 @@
1
+ export { SCAFFOLD_STACKS, findStack, listStacks } from './manifest.mjs';
2
+ export {
3
+ renderScaffold,
4
+ normalizeProjectName,
5
+ normalizeBaseURL,
6
+ normalizeOptions,
7
+ } from './render.mjs';
8
+ export {
9
+ DEFAULT_LAYOUT,
10
+ SKELETON_SCHEMA,
11
+ applySkeletonToStack,
12
+ assertSafeSkeletonPath,
13
+ defaultSkeletonId,
14
+ ensureSkeletonSeed,
15
+ loadSkeleton,
16
+ parseSkeleton,
17
+ pickOptions,
18
+ readLedger,
19
+ renderFromSkeleton,
20
+ skeletonFile,
21
+ skeletonsDir,
22
+ whenMatches,
23
+ writeLedger,
24
+ } from './library.mjs';
25
+ export { AUDIT_STAGES, auditScaffold } from './audit.mjs';