lantern-harness 0.1.13 → 0.1.15

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 (149) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/builtin/session/lh-nav-groups.mjs +141 -30
  3. package/cli/server.mjs +7 -0
  4. package/config/app.defaults.json +5 -1
  5. package/dist/500.html +5 -5
  6. package/dist/_astro/Base.VCz1UVxQ.css +1 -0
  7. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CpzwEBjx.js +1 -0
  8. package/dist/_astro/CaseExecBoard.cBdsZU9e.js +1 -0
  9. package/dist/_astro/CaseGenerateApp.D2ftaUXT.js +9 -0
  10. package/dist/_astro/CasesLibrary.DWXEje9u.js +19 -0
  11. package/dist/_astro/ChatApp.7piDha-y.js +226 -0
  12. package/dist/_astro/ColumnResize.BgYkV9Iy.js +1 -0
  13. package/dist/_astro/{DashboardBoard.uPjTYpJZ.js → DashboardBoard.BIP9es-t.js} +1 -1
  14. package/dist/_astro/DocsFileBrowser.-dkkxR4X.js +1 -0
  15. package/dist/_astro/{DocsPager.EPT5-oEx.js → DocsPager.v4kQH163.js} +1 -1
  16. package/dist/_astro/{DrawerField.DqvXFCFh.js → DrawerField.C0ehOlDt.js} +1 -1
  17. package/dist/_astro/ExcelFieldTags.ytbpKt-Z.js +5 -0
  18. package/dist/_astro/KnowledgeLibrary.Dw-IX3Zt.js +1 -0
  19. package/dist/_astro/NavLibraries.D1J9BwYo.js +1 -0
  20. package/dist/_astro/OverflowHint.pvo2Xc8R.js +1 -0
  21. package/dist/_astro/PluginsPage.DMTsFl_R.js +7 -0
  22. package/dist/_astro/PluginsPage.DMxVKmiY.js +1 -0
  23. package/dist/_astro/PmBugsBoard.BTtm1lki.js +1 -0
  24. package/dist/_astro/PmIterationsBoard.Dm67iXe_.js +1 -0
  25. package/dist/_astro/{PmProjectDetail.BDKXOQJD.js → PmProjectDetail.B7oWL7y-.js} +1 -1
  26. package/dist/_astro/PmProjectsBoard.8QI44RlE.js +1 -0
  27. package/dist/_astro/PmRequirementsBoard.DMJVLCqz.js +1 -0
  28. package/dist/_astro/PmRequirementsBoard.X98441HZ.js +1 -0
  29. package/dist/_astro/{PmShared.D69sPvec.js → PmShared.DbDseTcc.js} +1 -1
  30. package/dist/_astro/PromptMountDialog.YH2odDZx.js +58 -0
  31. package/dist/_astro/PromptsLibrary.B_qFbQGi.js +1 -0
  32. package/dist/_astro/{ReportsPage.N1EaH8E-.js → ReportsPage.BjcajHR6.js} +1 -1
  33. package/dist/_astro/ReqAnalysisBoard.hwNqRyim.js +28 -0
  34. package/dist/_astro/RequirementsLibrary.CGCNnQQG.js +1 -0
  35. package/dist/_astro/SearchableSelect.mvcBwegf.js +1 -0
  36. package/dist/_astro/SelectDropdown.Cb-QtC-D.js +1 -0
  37. package/dist/_astro/SettingsDialog.CnBZRaWE.js +1 -0
  38. package/dist/_astro/SpaceSwitcher.DMoqOVpS.js +7 -0
  39. package/dist/_astro/TasksBoard.DvfyDL76.js +1 -0
  40. package/dist/_astro/TemplatesLibrary.B5KmjjFw.js +1 -0
  41. package/dist/_astro/TestStatsBoard.EIDxmU_8.js +1 -0
  42. package/dist/_astro/Toast.BO2NFckG.js +1 -0
  43. package/dist/_astro/TodosBoard.7IptYUFY.js +1 -0
  44. package/dist/_astro/UiAutoBoard.DJljpjXT.js +9 -0
  45. package/dist/_astro/app-config.CF1xVPmo.js +1 -0
  46. package/dist/_astro/app-version.YyNOCGCb.js +1 -0
  47. package/dist/_astro/bash-tools.CPS0ZiKi.js +25 -0
  48. package/dist/_astro/case-review.DYyZat83.js +3 -0
  49. package/dist/_astro/case-types.DS1EQ5yP.js +1 -0
  50. package/dist/_astro/composer-task.DJmluzPT.js +5 -0
  51. package/dist/_astro/export.joBT53eb.js +148 -0
  52. package/dist/_astro/fs-tools.3F9MFrLf.js +9 -0
  53. package/dist/_astro/{hydrate-cache.zljz1n5X.js → hydrate-cache.CmC22o_H.js} +1 -1
  54. package/dist/_astro/i18n.B3BVhlok.js +7 -0
  55. package/dist/_astro/index.astro_astro_type_script_index_0_lang.CM78W1qz.js +1 -0
  56. package/dist/_astro/jszip.min.Bh2Mgo40.js +2 -0
  57. package/dist/_astro/{lib.BQbwbnfE.js → lib.S37S0T6S.js} +1 -1
  58. package/dist/_astro/{open-docs-in-session.LWVC43xp.js → open-docs-in-session.B6uyOxPn.js} +1 -1
  59. package/dist/_astro/plugins.DYyAjBXb.js +1 -0
  60. package/dist/_astro/prompts-meta.C_MeYq8G.js +2 -0
  61. package/dist/_astro/{req-analysis.C1uUndMm.js → req-analysis.CkLx8c9E.js} +2 -2
  62. package/dist/_astro/{settings.HM3DiNh0.js → settings.BvxRxdqa.js} +2 -2
  63. package/dist/_astro/{spaces-client.CWqBZccW.js → spaces-client.Dy3tSPta.js} +1 -1
  64. package/dist/_astro/story-review.CGcusNKf.js +10 -0
  65. package/dist/_astro/{ui-auto-prompt.B09MVaTI.js → ui-auto-prompt.QcLCZoV6.js} +1 -1
  66. package/dist/_astro/update.DXCPfU4a.js +1 -0
  67. package/dist/_astro/{view-prefs.7wGuDpzi.js → view-prefs.D1snIG5o.js} +1 -1
  68. package/dist/case-exec/index.html +6 -6
  69. package/dist/cases/generate/index.html +5 -5
  70. package/dist/cases/library/index.html +6 -6
  71. package/dist/dashboard/index.html +6 -6
  72. package/dist/docs/changelog/index.html +58 -6
  73. package/dist/docs/install/index.html +5 -5
  74. package/dist/docs/manual/index.html +86 -50
  75. package/dist/index.html +1 -1
  76. package/dist/knowledge/index.html +6 -6
  77. package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +5 -5
  78. package/dist/plugins/index.html +5 -5
  79. package/dist/pm/bugs/index.html +6 -6
  80. package/dist/pm/iterations/index.html +6 -6
  81. package/dist/pm/projects/detail/index.html +6 -6
  82. package/dist/pm/projects/index.html +6 -6
  83. package/dist/pm/requirements/index.html +6 -6
  84. package/dist/prompts/index.html +6 -6
  85. package/dist/reports/index.html +6 -6
  86. package/dist/requirement-analysis/index.html +6 -6
  87. package/dist/requirements/index.html +6 -6
  88. package/dist/tasks/index.html +6 -6
  89. package/dist/templates/index.html +6 -6
  90. package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +5 -5
  91. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +5 -5
  92. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +5 -5
  93. package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +5 -5
  94. package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +5 -5
  95. package/dist/test-automation/index.html +6 -6
  96. package/dist/test-stats/index.html +6 -6
  97. package/dist/todos/index.html +6 -6
  98. package/dist/workbench/index.html +5 -5
  99. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +47 -30
  100. package/lh-plugins/case-review-prompt.mjs +181 -0
  101. package/lh-plugins/lh-case-review.mjs +627 -0
  102. package/lh-plugins/lh-pm.mjs +21 -7
  103. package/lh-plugins/lh-req-analysis.mjs +63 -3
  104. package/lh-plugins/lh-story-review.mjs +98 -0
  105. package/lh-plugins/lh-test-points.mjs +98 -0
  106. package/lh-plugins/plugin-prompts.mjs +8 -0
  107. package/lh-plugins/req-analysis-prompt.mjs +8 -37
  108. package/lh-plugins/story-review-prompt.mjs +97 -0
  109. package/lh-plugins/test-points-prompt.mjs +88 -0
  110. package/package.json +1 -1
  111. package/dist/_astro/Base.UUIdmKid.css +0 -1
  112. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.DSWudA4D.js +0 -1
  113. package/dist/_astro/CaseExecBoard.D8K4NzrB.js +0 -1
  114. package/dist/_astro/CaseGenerateApp.bZ_K72NQ.js +0 -9
  115. package/dist/_astro/CasesLibrary.Dhg2pdwU.js +0 -1
  116. package/dist/_astro/ChatApp.B6I3gGKI.js +0 -221
  117. package/dist/_astro/ColumnResize.BEkEW7qw.js +0 -1
  118. package/dist/_astro/DocsFileBrowser.DvBPLCEp.js +0 -1
  119. package/dist/_astro/ExcelFieldTags.De-C3dqn.js +0 -152
  120. package/dist/_astro/KnowledgeLibrary.BzFTmNwA.js +0 -1
  121. package/dist/_astro/NavLibraries.CVdolwYy.js +0 -1
  122. package/dist/_astro/OverflowHint.D6v4Uj2N.js +0 -1
  123. package/dist/_astro/PluginsPage.B8U4uvD2.js +0 -39
  124. package/dist/_astro/PluginsPage.v6afs984.js +0 -1
  125. package/dist/_astro/PmBugsBoard.CSIGq0wz.js +0 -1
  126. package/dist/_astro/PmIterationsBoard.BmBc90as.js +0 -1
  127. package/dist/_astro/PmProjectsBoard.DIVs_xJu.js +0 -1
  128. package/dist/_astro/PmRequirementsBoard.DcLiUhBe.js +0 -1
  129. package/dist/_astro/PmRequirementsBoard.N0LM5jHo.js +0 -1
  130. package/dist/_astro/PromptsLibrary.B1RVZqj8.js +0 -1
  131. package/dist/_astro/ReqAnalysisBoard.BIIUqGVh.js +0 -25
  132. package/dist/_astro/RequirementsLibrary.BZhxG9VU.js +0 -1
  133. package/dist/_astro/SearchableSelect.BIjXzTPD.js +0 -1
  134. package/dist/_astro/SelectDropdown.B3-XpBpn.js +0 -1
  135. package/dist/_astro/SettingsDialog.DILea5eO.js +0 -1
  136. package/dist/_astro/SpaceSwitcher.BeCumAuj.js +0 -7
  137. package/dist/_astro/TasksBoard.B3SzQ5bR.js +0 -1
  138. package/dist/_astro/TemplatesLibrary.Ci3yHQTr.js +0 -1
  139. package/dist/_astro/TestStatsBoard.CgVvwMzN.js +0 -1
  140. package/dist/_astro/Toast.R8_2OWRX.js +0 -1
  141. package/dist/_astro/TodosBoard.BNDF1iVZ.js +0 -1
  142. package/dist/_astro/UiAutoBoard.BNLRrunE.js +0 -9
  143. package/dist/_astro/app-config.Cq_F8I0l.js +0 -1
  144. package/dist/_astro/i18n.DPw-aTIZ.js +0 -7
  145. package/dist/_astro/index.astro_astro_type_script_index_0_lang.B9YrqBHf.js +0 -1
  146. package/dist/_astro/markdown-client.DRva7DS9.js +0 -58
  147. package/dist/_astro/plugins.CKkgnq4r.js +0 -1
  148. package/dist/_astro/prompts-meta.D_2wiFiH.js +0 -2
  149. package/dist/_astro/update.BSnBvaFF.js +0 -1
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * 需求分析存储(空间级):`<当前数据空间>/需求分析/需求分析.json`。
3
+ * 目录被归进侧栏分组时位置会变(分组 = 物理归档),读写统一走 resolveContentRoot。
3
4
  *
4
5
  * 一次分析 = 一份文档:来源需求文档的路径 / 指纹、抽出的需求条目、拆出的用户故事、
5
6
  * 最近一次体检报告。目录只在真的有数据时创建(第一次保存时),与其它空间插件一致。
@@ -43,11 +44,19 @@ export const GAP_TYPES = [
43
44
  ];
44
45
  export const GAP_SEVERITIES = ['high', 'medium', 'low'];
45
46
  export const GAP_ORIGINS = ['rule', 'model'];
46
- export const CHECK_STAGES = ['idle', 'outline', 'stories', 'audit', 'done'];
47
+ export const CHECK_STAGES = ['idle', 'outline', 'stories', 'audit', 'points', 'done'];
47
48
 
48
- /** 数据文件路径:只算路径,不建目录 */
49
+ /** 测试点维度:功能 / 边界值 / 异常 / 业务规则 / 非功能 */
50
+ export const TEST_DIMENSIONS = ['functional', 'boundary', 'exception', 'business', 'nonfunctional'];
51
+ /** 测试点优先级:P0 最高 */
52
+ export const TEST_PRIORITIES = ['P0', 'P1', 'P2', 'P3'];
53
+ /** 单份分析最多保留的测试点条数 */
54
+ const MAX_TEST_POINTS = 500;
55
+
56
+ /** 数据文件路径:只算路径,不建目录。分组即物理归档,目录可能被搬进分组文件夹 */
49
57
  export function reqAnalysisStorePath(spaceDir) {
50
- return path.join(path.resolve(spaceDir), REQ_ANALYSIS_DIR_NAME, REQ_ANALYSIS_STORE_FILE);
58
+ const dir = resolveContentRoot(spaceDir, REQ_ANALYSIS_DIR_NAME).abs;
59
+ return path.join(dir, REQ_ANALYSIS_STORE_FILE);
51
60
  }
52
61
 
53
62
  /* ------------------------ 来源需求文档(只读) ------------------------ */
@@ -347,6 +356,52 @@ function normalizeCheck(raw) {
347
356
  };
348
357
  }
349
358
 
359
+ /* ------------------------------ 测试点 ------------------------------ */
360
+
361
+ const DIMENSION_ORDER = new Map(TEST_DIMENSIONS.map((key, i) => [key, i]));
362
+ const PRIORITY_ORDER = new Map(TEST_PRIORITIES.map((key, i) => [key, i]));
363
+
364
+ /** 单条测试点白名单;id 统一在 normalizeTestPoints 里按顺序重编 */
365
+ function normalizeTestPoint(raw) {
366
+ if (!raw || typeof raw !== 'object') return null;
367
+ const title = text(raw.title, 200);
368
+ if (!title) return null;
369
+ const storyId = /^US-\d{1,4}$/.test(String(raw.storyId ?? '')) ? String(raw.storyId) : '';
370
+ return {
371
+ id: '',
372
+ storyId,
373
+ dimension: oneOf(raw.dimension, TEST_DIMENSIONS, 'functional'),
374
+ priority: oneOf(raw.priority, TEST_PRIORITIES, 'P1'),
375
+ title,
376
+ precondition: text(raw.precondition, 1000),
377
+ steps: list(raw.steps, 20, 500),
378
+ expected: text(raw.expected, 1000),
379
+ };
380
+ }
381
+
382
+ /** 测试点报告:按「维度 → 优先级 → 标题」稳定排序,id 依次补 TP-001 */
383
+ function normalizeTestPoints(raw) {
384
+ if (!raw || typeof raw !== 'object') return null;
385
+ const summary = text(raw.summary, 2000);
386
+ const points = (Array.isArray(raw.points) ? raw.points : [])
387
+ .map(normalizeTestPoint)
388
+ .filter(Boolean)
389
+ .sort(
390
+ (a, b) =>
391
+ (DIMENSION_ORDER.get(a.dimension) ?? 9) - (DIMENSION_ORDER.get(b.dimension) ?? 9) ||
392
+ (PRIORITY_ORDER.get(a.priority) ?? 9) - (PRIORITY_ORDER.get(b.priority) ?? 9) ||
393
+ a.title.localeCompare(b.title, 'zh'),
394
+ )
395
+ .slice(0, MAX_TEST_POINTS)
396
+ .map((point, i) => ({ ...point, id: `TP-${String(i + 1).padStart(3, '0')}` }));
397
+ if (!points.length && !summary) return null;
398
+ return {
399
+ at: text(raw.at, 40) || new Date().toISOString(),
400
+ summary,
401
+ points,
402
+ };
403
+ }
404
+
350
405
  /* ------------------------------ 文档 ------------------------------ */
351
406
 
352
407
  function normalizeProgress(raw) {
@@ -375,6 +430,7 @@ function normalizeDoc(raw) {
375
430
  outline: [],
376
431
  stories: [],
377
432
  check: normalizeCheck(raw.check),
433
+ testPoints: normalizeTestPoints(raw.testPoints),
378
434
  progress: normalizeProgress(raw.progress),
379
435
  storySeq: Math.max(0, Number(raw.storySeq) || 0),
380
436
  createdAt: text(raw.createdAt, 40) || now,
@@ -489,6 +545,7 @@ function buildDoc(raw) {
489
545
  outline: [],
490
546
  stories: [],
491
547
  check: null,
548
+ testPoints: null,
492
549
  progress: null,
493
550
  storySeq: 0,
494
551
  createdAt: now,
@@ -509,6 +566,7 @@ function normalizePatch(base, raw) {
509
566
  if ('summary' in raw) patch.summary = text(raw.summary, 2000);
510
567
  if ('progress' in raw) patch.progress = normalizeProgress(raw.progress);
511
568
  if ('check' in raw) patch.check = normalizeCheck(raw.check);
569
+ if ('testPoints' in raw) patch.testPoints = normalizeTestPoints(raw.testPoints);
512
570
  return patch;
513
571
  }
514
572
 
@@ -642,6 +700,8 @@ export function lhReqAnalysisPlugin() {
642
700
  const next = { ...base, ...normalizePatch(base, body) };
643
701
  if ('outline' in body) applyOutline(next, body.outline);
644
702
  if ('stories' in body) applyStories(next, body.stories, body.replaceStories === true);
703
+ // 重新拆解后故事全换了:旧测试点不再对应,一起清掉
704
+ if (body.replaceStories === true) next.testPoints = null;
645
705
  next.updatedAt = new Date().toISOString();
646
706
  store.docs[idx] = next;
647
707
  writeStore(root, store);
@@ -0,0 +1,98 @@
1
+ /**
2
+ * 「用户故事审查」提示词中间件。
3
+ *
4
+ * 本插件不存自己的数据:审查结果写回 `需求分析/需求分析.json` 的 `check` 字段,
5
+ * 这里只负责两件事——探测服务是否就绪、把插件提示词同步进「提示词管理」并读出两段正文。
6
+ *
7
+ * 路由:`/__tb_storyreview?health=1`、`GET /__tb_storyreview/prompt`、`POST /__tb_storyreview/prompt/sync`
8
+ */
9
+ import { getDataRoot } from '../builtin/session/space-context.mjs';
10
+ import { ensurePluginPrompt, isPluginOnInSpace, readPluginPrompt } from './plugin-prompts.mjs';
11
+ import {
12
+ STORY_REVIEW_PROMPT_FILE,
13
+ STORY_REVIEW_PROMPT_TEMPLATE,
14
+ parseStoryReviewPromptSections,
15
+ } from './story-review-prompt.mjs';
16
+
17
+ const PREFIX = '/__tb_storyreview';
18
+ const VERSION = 1;
19
+
20
+ function sendJson(res, status, body) {
21
+ res.statusCode = status;
22
+ res.setHeader('Content-Type', 'application/json; charset=utf-8');
23
+ res.setHeader('Cache-Control', 'no-store');
24
+ res.end(JSON.stringify(body));
25
+ }
26
+
27
+ async function readBody(req) {
28
+ const chunks = [];
29
+ for await (const chunk of req) chunks.push(chunk);
30
+ return Buffer.concat(chunks).toString('utf8');
31
+ }
32
+
33
+ /**
34
+ * @returns {import('vite').Plugin}
35
+ */
36
+ export function lhStoryReviewPlugin() {
37
+ return {
38
+ name: 'lh-story-review',
39
+ configureServer(server) {
40
+ server.middlewares.use(async (req, res, next) => {
41
+ const parsed = new URL(req.url ?? '/', 'http://127.0.0.1');
42
+ if (!parsed.pathname.startsWith(PREFIX)) return next();
43
+ // 数据根惰性读取:切换数据空间后无需重启
44
+ const root = getDataRoot();
45
+ const tail = parsed.pathname.slice(PREFIX.length) || '/';
46
+
47
+ try {
48
+ const method = req.method || 'GET';
49
+
50
+ if (method === 'GET' && parsed.searchParams.get('health') === '1') {
51
+ // 探测不算读写:只算路径,不建目录
52
+ return sendJson(res, 200, { ok: true, files: {}, version: VERSION });
53
+ }
54
+
55
+ if (method === 'GET' && tail === '/prompt') {
56
+ // 插件还开着但文件被删(外部删除 / 换空间)时自动补种子
57
+ if (isPluginOnInSpace('storyReview', root)) {
58
+ ensurePluginPrompt(STORY_REVIEW_PROMPT_FILE, STORY_REVIEW_PROMPT_TEMPLATE, root);
59
+ }
60
+ const content = readPluginPrompt(STORY_REVIEW_PROMPT_FILE, root);
61
+ const sections = parseStoryReviewPromptSections(content);
62
+ return sendJson(res, 200, {
63
+ ok: true,
64
+ file: STORY_REVIEW_PROMPT_FILE,
65
+ exists: Boolean(content.trim()),
66
+ ...sections,
67
+ });
68
+ }
69
+
70
+ if (method === 'POST' && tail === '/prompt/sync') {
71
+ const body = JSON.parse((await readBody(req)) || '{}');
72
+ if (body.enabled !== true) {
73
+ // 关闭只停用:文件保留,再打开仍引用同一份
74
+ return sendJson(res, 200, {
75
+ ok: true,
76
+ enabled: false,
77
+ removed: false,
78
+ exists: Boolean(readPluginPrompt(STORY_REVIEW_PROMPT_FILE, root).trim()),
79
+ file: STORY_REVIEW_PROMPT_FILE,
80
+ });
81
+ }
82
+ const out = ensurePluginPrompt(
83
+ STORY_REVIEW_PROMPT_FILE,
84
+ STORY_REVIEW_PROMPT_TEMPLATE,
85
+ root,
86
+ );
87
+ return sendJson(res, 200, { ok: true, enabled: true, ...out });
88
+ }
89
+
90
+ return sendJson(res, 405, { ok: false, error: 'Method Not Allowed' });
91
+ } catch (err) {
92
+ const status = Number(err?.statusCode) || 500;
93
+ return sendJson(res, status, { ok: false, error: String(err?.message ?? err) });
94
+ }
95
+ });
96
+ },
97
+ };
98
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * 「生成测试点」提示词中间件。
3
+ *
4
+ * 本插件不存自己的数据:测试点写回 `需求分析/需求分析.json` 的 `testPoints` 字段,
5
+ * 这里只负责两件事——探测服务是否就绪、把插件提示词同步进「提示词管理」并读出正文。
6
+ *
7
+ * 路由:`/__tb_testpoints?health=1`、`GET /__tb_testpoints/prompt`、`POST /__tb_testpoints/prompt/sync`
8
+ */
9
+ import { getDataRoot } from '../builtin/session/space-context.mjs';
10
+ import { ensurePluginPrompt, isPluginOnInSpace, readPluginPrompt } from './plugin-prompts.mjs';
11
+ import {
12
+ TEST_POINTS_PROMPT_FILE,
13
+ TEST_POINTS_PROMPT_TEMPLATE,
14
+ parseTestPointsPromptSections,
15
+ } from './test-points-prompt.mjs';
16
+
17
+ const PREFIX = '/__tb_testpoints';
18
+ const VERSION = 1;
19
+
20
+ function sendJson(res, status, body) {
21
+ res.statusCode = status;
22
+ res.setHeader('Content-Type', 'application/json; charset=utf-8');
23
+ res.setHeader('Cache-Control', 'no-store');
24
+ res.end(JSON.stringify(body));
25
+ }
26
+
27
+ async function readBody(req) {
28
+ const chunks = [];
29
+ for await (const chunk of req) chunks.push(chunk);
30
+ return Buffer.concat(chunks).toString('utf8');
31
+ }
32
+
33
+ /**
34
+ * @returns {import('vite').Plugin}
35
+ */
36
+ export function lhTestPointsPlugin() {
37
+ return {
38
+ name: 'lh-test-points',
39
+ configureServer(server) {
40
+ server.middlewares.use(async (req, res, next) => {
41
+ const parsed = new URL(req.url ?? '/', 'http://127.0.0.1');
42
+ if (!parsed.pathname.startsWith(PREFIX)) return next();
43
+ // 数据根惰性读取:切换数据空间后无需重启
44
+ const root = getDataRoot();
45
+ const tail = parsed.pathname.slice(PREFIX.length) || '/';
46
+
47
+ try {
48
+ const method = req.method || 'GET';
49
+
50
+ if (method === 'GET' && parsed.searchParams.get('health') === '1') {
51
+ // 探测不算读写:只算路径,不建目录
52
+ return sendJson(res, 200, { ok: true, files: {}, version: VERSION });
53
+ }
54
+
55
+ if (method === 'GET' && tail === '/prompt') {
56
+ // 插件还开着但文件被删(外部删除 / 换空间)时自动补种子
57
+ if (isPluginOnInSpace('testPoints', root)) {
58
+ ensurePluginPrompt(TEST_POINTS_PROMPT_FILE, TEST_POINTS_PROMPT_TEMPLATE, root);
59
+ }
60
+ const content = readPluginPrompt(TEST_POINTS_PROMPT_FILE, root);
61
+ const sections = parseTestPointsPromptSections(content);
62
+ return sendJson(res, 200, {
63
+ ok: true,
64
+ file: TEST_POINTS_PROMPT_FILE,
65
+ exists: Boolean(content.trim()),
66
+ ...sections,
67
+ });
68
+ }
69
+
70
+ if (method === 'POST' && tail === '/prompt/sync') {
71
+ const body = JSON.parse((await readBody(req)) || '{}');
72
+ if (body.enabled !== true) {
73
+ // 关闭只停用:文件保留,再打开仍引用同一份
74
+ return sendJson(res, 200, {
75
+ ok: true,
76
+ enabled: false,
77
+ removed: false,
78
+ exists: Boolean(readPluginPrompt(TEST_POINTS_PROMPT_FILE, root).trim()),
79
+ file: TEST_POINTS_PROMPT_FILE,
80
+ });
81
+ }
82
+ const out = ensurePluginPrompt(
83
+ TEST_POINTS_PROMPT_FILE,
84
+ TEST_POINTS_PROMPT_TEMPLATE,
85
+ root,
86
+ );
87
+ return sendJson(res, 200, { ok: true, enabled: true, ...out });
88
+ }
89
+
90
+ return sendJson(res, 405, { ok: false, error: 'Method Not Allowed' });
91
+ } catch (err) {
92
+ const status = Number(err?.statusCode) || 500;
93
+ return sendJson(res, status, { ok: false, error: String(err?.message ?? err) });
94
+ }
95
+ });
96
+ },
97
+ };
98
+ }
@@ -57,10 +57,18 @@ export const PLUGIN_PROMPT_FILES = Object.freeze({
57
57
  '工作汇报提示词.md': 'reports',
58
58
  'Playwright提示词.md': 'uiAuto',
59
59
  '需求分析提示词.md': 'reqAnalysis',
60
+ '用户故事审查提示词.md': 'storyReview',
61
+ '测试点生成提示词.md': 'testPoints',
62
+ '用例质量评审提示词.md': 'caseReview',
63
+ '场景遗漏补全提示词.md': 'caseBlindspot',
60
64
  });
61
65
 
62
66
  export const UI_AUTO_PROMPT_FILE = 'Playwright提示词.md';
63
67
  export const REQ_ANALYSIS_PROMPT_FILE = '需求分析提示词.md';
68
+ export const STORY_REVIEW_PROMPT_FILE = '用户故事审查提示词.md';
69
+ export const TEST_POINTS_PROMPT_FILE = '测试点生成提示词.md';
70
+ export const CASE_REVIEW_PROMPT_FILE = '用例质量评审提示词.md';
71
+ export const BLINDSPOT_PROMPT_FILE = '场景遗漏补全提示词.md';
64
72
 
65
73
  /** 当前空间的提示词目录(可能被归进分组文件夹) */
66
74
  export function promptsDir(spaceDir = getDataRoot()) {
@@ -3,13 +3,12 @@
3
3
  *
4
4
  * 文件放在当前空间的「提示词管理/需求分析提示词.md」,由插件开关联动:
5
5
  * 打开插件时缺就补种子(没人改过时会跟着内置模板升级),插件开启期间不允许删除 / 改名。
6
- * 拆解 / 体检 / 补写前各读一次,改完提示词不用重启服务。
6
+ * 拆解前读一次,改完提示词不用重启服务。
7
7
  *
8
- * 文件用两级标题分三段:
9
- * - `## 拆解`:抽需求条目、拆用户故事的 system prompt
10
- * - `## 体检`:找场景遗漏与维度缺失的评审 prompt(只出问题,不改写)
11
- * - `## 补写`:按勾选缺口补写故事的 prompt
12
- * 占位符:{{source}} 原始需求、{{outline}} 需求条目、{{stories}} 故事集、{{gaps}} 勾选缺口
8
+ * 文件只有一个 `## 拆解` 段:抽需求条目、拆用户故事的 system prompt。
9
+ * 「体检」与「补写」已抽到「用户故事审查」插件,对应 `用户故事审查提示词.md`;
10
+ * 老空间里这两段如果还在,解析照旧识别,但需求分析不再使用。
11
+ * 占位符:{{source}} 原始需求、{{outline}} 需求条目、{{stories}} 故事集
13
12
  */
14
13
 
15
14
  import { REQ_ANALYSIS_PROMPT_FILE } from './plugin-prompts.mjs';
@@ -17,14 +16,15 @@ import { REQ_ANALYSIS_PROMPT_FILE } from './plugin-prompts.mjs';
17
16
  export { REQ_ANALYSIS_PROMPT_FILE };
18
17
 
19
18
  export const DECOMPOSE_SECTION = '拆解';
19
+ /** 旧版把体检 / 补写放在这里,仅用于识别老文件;新文件不该再有这两段 */
20
20
  export const AUDIT_SECTION = '体检';
21
21
  export const FIX_SECTION = '补写';
22
22
 
23
23
  export const REQ_ANALYSIS_PROMPT_TEMPLATE = `# 需求分析提示词
24
24
 
25
- > 这份提示词由「需求分析」插件生成并引用,分「拆解」「体检」「补写」三段。
25
+ > 这份提示词由「需求分析」插件生成并引用,只负责「拆解」;体检与补写见「用户故事审查提示词.md」。
26
26
  > 插件开启期间不能删除本文件;关闭插件后可以删掉,再次打开会重新生成。
27
- > 可用占位符:\`{{source}}\` 原始需求正文、\`{{outline}}\` 需求条目、\`{{stories}}\` 已拆出的用户故事、\`{{gaps}}\` 勾选待补写的缺口。
27
+ > 可用占位符:\`{{source}}\` 原始需求正文、\`{{outline}}\` 需求条目、\`{{stories}}\` 已拆出的用户故事。
28
28
 
29
29
  ## 拆解
30
30
 
@@ -49,35 +49,6 @@ export const REQ_ANALYSIS_PROMPT_TEMPLATE = `# 需求分析提示词
49
49
  - \`acceptance\` 每条都是 Given / When / Then,\`then\` 必须可判定(看得到、查得到、算得出),不要写「正常显示」。
50
50
  - \`dimensions\` 从这几项里挑本故事覆盖到的:权限、边界值、并发与幂等、空数据、超时与失败、国际化与时区。
51
51
 
52
- ## 体检
53
-
54
- 你是需求评审人。只出问题,不改写故事。
55
-
56
- 输入是需求条目与已拆出的用户故事。请调用 \`req_save_check\` 一次提交体检结果。
57
-
58
- 只查下面这几类语义问题,不要重复规则已经能判定的(缺字段、条目没被引用、维度没覆盖):
59
- 1. 场景遗漏:原文提到的角色 / 分支 / 状态变化没有对应故事,或故事只覆盖了顺利路径。
60
- 2. 替代流程不成立:trigger 与 steps 对不上、替代路径最后又绕回主流程、和异常场景混写。
61
- 3. 异常不现实:写的异常这条故事根本遇不到,或真实高发的异常没写。
62
- 4. 验收不可测:then 无法判定、缺阈值、缺具体文案 / 状态。
63
- 5. 与原文冲突:故事的行为、角色、字段与原文不一致。
64
- 6. 过度拆分:同一目标被拆成多条故事,或一条故事里塞了多个目标。
65
-
66
- 每条缺口给:\`storyTitle\`(相关故事标题,全局问题填空串)、\`type\`、\`severity\`(high / medium / low)、\`title\`(一句话)、\`detail\`(位置 + 原因)、\`suggestion\`(建议补写什么,不要直接改写整条故事)。
67
- \`type\` 只能是:missing-scenario / missing-dimension / untestable-acceptance / conflict / over-split / other。
68
- 宁可少报也不要编:原文没有的信息不要当缺口。最后在 \`summary\` 里用两三句话给整体结论。
69
-
70
- ## 补写
71
-
72
- 你是需求分析师。按用户勾选的缺口补写故事,只改被点名的部分。
73
-
74
- 输入是当前完整故事集和勾选的缺口。调用 \`req_set_stories\` 提交**合并后的完整故事集**:带原 \`id\` 的故事原地更新,新增故事不要带 id(服务端会分配)。
75
-
76
- 规则:
77
- 1. 不允许删掉没被点名的故事,也不允许顺手改写它们的措辞。
78
- 2. 补缺口时优先在原故事上补分支 / 字段;确实是新场景才新增故事,并在 \`sourceRefs\` 引用已有条目 id。
79
- 3. 与原故事或原文冲突的改动不要做,先在回答里说明原因。
80
- 4. 提交后简短说明改了哪几条、新增了哪几条。
81
52
  `;
82
53
 
83
54
  /**
@@ -0,0 +1,97 @@
1
+ /**
2
+ * 「用户故事审查」的提示词文件:种子正文 + 分段解析。
3
+ *
4
+ * 文件放在当前空间的「提示词管理/用户故事审查提示词.md」,由插件开关联动:
5
+ * 打开插件时缺就补种子(没人改过时会跟着内置模板升级),插件开启期间不允许删除 / 改名。
6
+ * 每次审查 / 补写前各读一次,改完提示词不用重启服务。
7
+ *
8
+ * 文件用两级标题分两段:
9
+ * - `## 审查`:对已拆好的用户故事做体检的 system prompt(只出问题,不改写)
10
+ * - `## 补写`:按勾选缺口补写故事的 prompt
11
+ * 占位符:{{stories}} 故事集、{{outline}} 需求条目、{{gaps}} 勾选缺口
12
+ */
13
+
14
+ import { STORY_REVIEW_PROMPT_FILE } from './plugin-prompts.mjs';
15
+
16
+ export { STORY_REVIEW_PROMPT_FILE };
17
+
18
+ export const REVIEW_SECTION = '审查';
19
+ export const FIX_SECTION = '补写';
20
+
21
+ export const STORY_REVIEW_PROMPT_TEMPLATE = `# 用户故事审查提示词
22
+
23
+ > 这份提示词由「用户故事审查」插件生成并引用,分「审查」「补写」两段。
24
+ > 插件开启期间不能删除本文件;关闭插件后可以删掉,再次打开会重新生成。
25
+ > 可用占位符:\`{{stories}}\` 待审查的用户故事、\`{{outline}}\` 需求条目、\`{{gaps}}\` 勾选待补写的缺口。
26
+
27
+ ## 审查
28
+
29
+ 你是用户故事审查人。对已经拆好的用户故事做系统性体检,只出问题,不改写故事。
30
+
31
+ 工作方式(必须遵守):
32
+ 1. 先通读需求条目与全部用户故事,再开始判断;不要只看单条故事就下结论。
33
+ 2. 调用 \`req_save_check\` 一次提交审查结果,不要一条缺口调一次。
34
+ 3. 规则侧已经能判定的问题(字段缺失、条目没被引用、维度没覆盖)代码会自己算,你只补语义问题,不要重复报。
35
+ 4. 提交后用中文简述:一共几条缺口、最该先补的是哪几条。
36
+
37
+ 重点查这两类(这是本插件的核心):
38
+ - 场景遗漏:原文提到的角色 / 分支 / 状态变化没有对应故事;故事只覆盖顺利路径;写操作没有失败路径;列表类功能没有空态;多人操作没有并发场景。
39
+ - 维度缺失:这条故事在权限与角色、边界值、并发与幂等、空数据、超时与失败、国际化与时区这六个维度上,哪些明显该覆盖却完全没提。
40
+
41
+ 还可以查下面几类,但不要为了凑数硬报:
42
+ - 替代流程不成立:trigger 与 steps 对不上、替代路径最后又绕回主流程、和异常场景混写。
43
+ - 验收不可测:then 无法判定、缺阈值、缺具体文案 / 状态。
44
+ - 与原文冲突:故事的行为、角色、字段与原文不一致。
45
+ - 过度拆分:同一目标被拆成多条故事,或一条故事里塞了多个目标。
46
+
47
+ 每条缺口给:\`storyId\`(相关故事 id,全局问题填空串)、\`type\`、\`severity\`(high / medium / low)、\`title\`(一句话)、\`detail\`(位置 + 原因)、\`suggestion\`(建议补什么,不要直接改写整条故事)。
48
+ \`type\` 只能是:missing-scenario / missing-dimension / untestable-acceptance / conflict / over-split / other。
49
+ 宁可少报也不要编:原文没有的信息不要当缺口。最后在 \`summary\` 里用两三句话给整体结论。
50
+
51
+ ## 补写
52
+
53
+ 你是需求分析师。按用户勾选的缺口补写故事,只改被点名的部分。
54
+
55
+ 输入是当前完整故事集和勾选的缺口。调用 \`req_set_stories\` 提交**合并后的完整故事集**:带原 \`id\` 的故事原地更新,新增故事不要带 id(服务端会分配)。
56
+
57
+ 规则:
58
+ 1. 不允许删掉没被点名的故事,也不允许顺手改写它们的措辞。
59
+ 2. 补缺口时优先在原故事上补分支 / 字段;确实是新场景才新增故事,并在 \`sourceRefs\` 引用已有条目 id。
60
+ 3. 与原故事或原文冲突的改动不要做,先在回答里说明原因。
61
+ 4. 提交后简短说明改了哪几条、新增了哪几条。
62
+ `;
63
+
64
+ /**
65
+ * 解析提示词文件里的两段正文。
66
+ * 认 `## 审查`(也接受「体检」「检查」「评审」)与 `## 补写`(也接受「修订」「修复」);
67
+ * 某段缺失或为空时返回空串,调用方拦下来提示,不用代码里的兜底顶替。
68
+ */
69
+ export function parseStoryReviewPromptSections(text) {
70
+ const raw = String(text ?? '');
71
+ const out = { review: '', fix: '' };
72
+ if (!raw.trim()) return out;
73
+ let current = '';
74
+ let buffer = [];
75
+ const flush = () => {
76
+ const body = buffer.join('\n').trim();
77
+ if (current === 'review') out.review = body;
78
+ else if (current === 'fix') out.fix = body;
79
+ buffer = [];
80
+ };
81
+ for (const line of raw.split('\n')) {
82
+ const heading = /^##\s+(.+?)\s*$/.exec(line);
83
+ if (heading) {
84
+ flush();
85
+ const name = heading[1];
86
+ if (/审查|体检|检查|评审/.test(name)) current = 'review';
87
+ else if (/补写|修订|修复|补齐/.test(name)) current = 'fix';
88
+ else current = '';
89
+ continue;
90
+ }
91
+ // 一级标题 / 引用块在段外,忽略即可(段内保留引用)
92
+ if (!current && (/^#\s/.test(line) || /^>\s?/.test(line))) continue;
93
+ if (current) buffer.push(line);
94
+ }
95
+ flush();
96
+ return out;
97
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * 「生成测试点」的提示词文件:种子正文 + 分段解析。
3
+ *
4
+ * 文件放在当前空间的「提示词管理/测试点生成提示词.md」,由插件开关联动:
5
+ * 打开插件时缺就补种子(没人改过时会跟着内置模板升级),插件开启期间不允许删除 / 改名。
6
+ * 每次生成前读一次,改完提示词不用重启服务。
7
+ *
8
+ * 文件用一级标题分一段:
9
+ * - `## 生成`:基于用户故事拆测试点的 system prompt
10
+ * 占位符:{{docTitle}} 分析标题、{{outline}} 需求条目、{{stories}} 用户故事
11
+ */
12
+
13
+ import { TEST_POINTS_PROMPT_FILE } from './plugin-prompts.mjs';
14
+
15
+ export { TEST_POINTS_PROMPT_FILE };
16
+
17
+ export const GENERATE_SECTION = '生成';
18
+
19
+ export const TEST_POINTS_PROMPT_TEMPLATE = `# 测试点生成提示词
20
+
21
+ > 这份提示词由「生成测试点」插件生成并引用。
22
+ > 插件开启期间不能删除本文件;关闭插件后可以删掉,再次打开会重新生成。
23
+ > 可用占位符:\`{{docTitle}}\` 分析标题、\`{{outline}}\` 需求条目、\`{{stories}}\` 用户故事。
24
+
25
+ ## 生成
26
+
27
+ 你是测试分析师。基于已经拆好的用户故事,拆出可直接执行、可判定结果的测试点。
28
+
29
+ 工作方式(必须遵守):
30
+ 1. 先通读需求条目与全部用户故事,再开始拆;不要只看单条故事就下结论。
31
+ 2. 调用 \`req_save_test_points\` 一次提交全部测试点,不要分多次提交。
32
+ 3. 只拆这些故事与条目能支撑的测试点,原文没有的信息不要编;需要假设的写进 \`precondition\`。
33
+ 4. 提交后用中文简述:一共几条、五维覆盖情况、最该先测的是哪几条。
34
+
35
+ 五个维度必须都过一遍(不适用就说明原因,不要硬凑):
36
+ - 功能(functional):主流程、替代流程、每个功能点是否都能走到。
37
+ - 边界值(boundary):为空 / 最小 / 最大 / 刚好越界、长度与数量上下限、分页与条数、金额与精度、时间边界。
38
+ - 异常(exception):失败路径、非法输入、超时、重复提交、并发、网络中断、权限不足、数据被删除后被引用。
39
+ - 业务规则(business):状态流转、角色与权限、唯一性 / 互斥 / 依赖、计算规则、审批与回退、幂等。
40
+ - 非功能(nonfunctional):性能与响应时间、并发与稳定性、安全与越权、兼容与适配、国际化与时区、可恢复性。
41
+
42
+ 优先级(每条都要标,P0 最高):
43
+ - P0:主流程、钱与权限、数据安全;坏了就不能上线。
44
+ - P1:常用分支与关键边界;影响主要使用场景。
45
+ - P2:异常与次要边界;影响体验但不阻断主流程。
46
+ - P3:低频 / 极端 / 兼容性补充。
47
+
48
+ 每条测试点提交这些字段:
49
+ - \`storyId\`:对应故事 id(US-001 这种);跨故事的全局测试点填空串。
50
+ - \`dimension\`:functional / boundary / exception / business / nonfunctional 之一。
51
+ - \`priority\`:P0 / P1 / P2 / P3 之一。
52
+ - \`title\`:一句话说清测什么(动词开头,带条件)。
53
+ - \`precondition\`:执行前需要的数据 / 角色 / 状态。
54
+ - \`steps\`:可执行步骤数组,一步一个动作。
55
+ - \`expected\`:可以判定的预期结果,有阈值就写具体数值。
56
+
57
+ 宁可少而准,也不要为凑五维报重复测试点:同一个校验点只报一次,优先归到最贴近的维度。
58
+ `;
59
+
60
+ /**
61
+ * 解析提示词文件里的「生成」段正文。
62
+ * 认 `## 生成`(也接受「测试点」「拆解」「生成测试点」);
63
+ * 缺失或为空时返回空串,调用方拦下来提示,不用代码里的兜底顶替。
64
+ */
65
+ export function parseTestPointsPromptSections(text) {
66
+ const raw = String(text ?? '');
67
+ const out = { generate: '' };
68
+ if (!raw.trim()) return out;
69
+ let current = false;
70
+ let buffer = [];
71
+ const flush = () => {
72
+ if (current) out.generate = buffer.join('\n').trim();
73
+ buffer = [];
74
+ };
75
+ for (const line of raw.split('\n')) {
76
+ const heading = /^##\s+(.+?)\s*$/.exec(line);
77
+ if (heading) {
78
+ flush();
79
+ current = /生成|测试点|拆解/.test(heading[1]);
80
+ continue;
81
+ }
82
+ // 一级标题 / 引用块在段外,忽略即可(段内保留引用)
83
+ if (!current && (/^#\s/.test(line) || /^>\s?/.test(line))) continue;
84
+ if (current) buffer.push(line);
85
+ }
86
+ flush();
87
+ return out;
88
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lantern-harness",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "AI 工作台:对话与插件工具、内容库、模板库、会话记忆,数据留在本机。",