lantern-harness 0.1.24 → 0.1.25
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.
- package/CHANGELOG.md +24 -0
- package/dist/500.html +4 -4
- package/dist/_astro/Base.COYvzmy5.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.DHRjA0au.js → Base.astro_astro_type_script_index_0_lang.Cb6ggViJ.js} +1 -1
- package/dist/_astro/{CaseExecBoard.Xd7KUpkU.js → CaseExecBoard.cl2Od7av.js} +1 -1
- package/dist/_astro/{CaseGenerateApp.BgIi4YGn.js → CaseGenerateApp.nE3RR7bV.js} +5 -5
- package/dist/_astro/CasesLibrary.e3vlOqSQ.js +21 -0
- package/dist/_astro/ChatApp.CECImcJo.js +226 -0
- package/dist/_astro/{DocsFileBrowser.Diq5zuSt.js → DocsFileBrowser.BdpWp8zQ.js} +1 -1
- package/dist/_astro/DocsPager.D55FTK9d.js +1 -0
- package/dist/_astro/{KnowledgeLibrary.CYutSepl.js → KnowledgeLibrary.DKci9jN8.js} +1 -1
- package/dist/_astro/NamePromptDialog.Csfnh5eM.js +1 -0
- package/dist/_astro/PluginsPage.B6dsHB44.js +1 -0
- package/dist/_astro/{PluginsPage.CgcXB7Ap.js → PluginsPage.D5LXPMns.js} +2 -2
- package/dist/_astro/{PmBugsBoard.Ceyt3pp6.js → PmBugsBoard.B6w50MHD.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.Dwsntvw6.js → PmIterationsBoard.Dk7JheCU.js} +1 -1
- package/dist/_astro/{PmProjectDetail.5tybGC46.js → PmProjectDetail.O44fnczN.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.X2LZfFff.js → PmProjectsBoard.qgj9HAj8.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.BKY3h4CQ.js +1 -0
- package/dist/_astro/{PmRequirementsBoard.CXaGeFl9.js → PmRequirementsBoard.DTL_RFxq.js} +1 -1
- package/dist/_astro/{PmShared.Bzn6AGsN.js → PmShared.Bwphj4KH.js} +1 -1
- package/dist/_astro/{PromptsLibrary.DydrgeIw.js → PromptsLibrary.Dv5OABdK.js} +1 -1
- package/dist/_astro/{ReportsPage.BRVCnzL-.js → ReportsPage.B7MOskzc.js} +1 -1
- package/dist/_astro/{ReqAnalysisBoard.BCq_OoRo.js → ReqAnalysisBoard.nUp89z1s.js} +8 -8
- package/dist/_astro/{RequirementsLibrary.DtbFESBh.js → RequirementsLibrary._OviMClB.js} +1 -1
- package/dist/_astro/{SettingsDialog.DtEJLxtx.js → SettingsDialog.D3f4EOwl.js} +1 -1
- package/dist/_astro/SlideOverDrawer.CpQu7VMQ.js +1 -0
- package/dist/_astro/{SpaceSwitcher.Cdveup1T.js → SpaceSwitcher.DQOG363O.js} +1 -1
- package/dist/_astro/{TemplatesLibrary.Bg-MFL57.js → TemplatesLibrary.CEVQPDDz.js} +1 -1
- package/dist/_astro/{TestStatsBoard.eiMbNGpn.js → TestStatsBoard.CO4JMh4N.js} +1 -1
- package/dist/_astro/UiAutoBoard.BRMCH1zB.js +9 -0
- package/dist/_astro/app-version.BPkgRlbu.js +1 -0
- package/dist/_astro/case-gen-run.Byxy6M5X.js +22 -0
- package/dist/_astro/{case-review.D1E3ldss.js → case-review.DlCarphW.js} +1 -1
- package/dist/_astro/{llm.BuR7z55C.js → llm.DyweO-KK.js} +1 -1
- package/dist/_astro/{story-review.BRcUdixS.js → story-review.BvgXBApZ.js} +1 -1
- package/dist/case-exec/index.html +5 -5
- package/dist/cases/generate/index.html +5 -5
- package/dist/cases/library/index.html +5 -5
- package/dist/dashboard/index.html +4 -4
- package/dist/docs/changelog/index.html +27 -5
- package/dist/docs/install/index.html +4 -4
- package/dist/docs/manual/index.html +7 -7
- package/dist/knowledge/index.html +5 -5
- package/dist/plugins/index.html +5 -5
- package/dist/pm/bugs/index.html +5 -5
- package/dist/pm/iterations/index.html +5 -5
- package/dist/pm/projects/detail/index.html +5 -5
- package/dist/pm/projects/index.html +5 -5
- package/dist/pm/requirements/index.html +5 -5
- package/dist/prompts/index.html +5 -5
- package/dist/reports/index.html +5 -5
- package/dist/requirement-analysis/index.html +5 -5
- package/dist/requirements/index.html +5 -5
- package/dist/tasks/index.html +4 -4
- package/dist/templates/index.html +5 -5
- package/dist/test-automation/index.html +5 -5
- package/dist/test-stats/index.html +5 -5
- package/dist/todos/index.html +4 -4
- package/dist/workbench/index.html +5 -5
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +3 -3
- package/lh-plugins/lh-case-review.mjs +115 -34
- package/package.json +1 -1
- package/dist/_astro/Base.nGl8De0W.css +0 -1
- package/dist/_astro/CasesLibrary.B2VCAoTt.js +0 -21
- package/dist/_astro/ChatApp.CeSatNSf.js +0 -220
- package/dist/_astro/DocsPager.WMztSW4O.js +0 -1
- package/dist/_astro/NamePromptDialog.5XFIvdqv.js +0 -1
- package/dist/_astro/PluginsPage.pgN80K8r.js +0 -1
- package/dist/_astro/PmRequirementsBoard.CYbicBqS.js +0 -1
- package/dist/_astro/SlideOverDrawer.DMWJPD_W.js +0 -1
- package/dist/_astro/UiAutoBoard.CLi9vmuE.js +0 -9
- package/dist/_astro/app-version.XPYyWuno.js +0 -1
- package/dist/_astro/case-gen-run.BbI2iGo9.js +0 -21
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 路由:
|
|
9
9
|
* - `/__tb_casereview?health=1`、`/__tb_casereview/prompt`、`/__tb_casereview/prompt/sync`
|
|
10
10
|
* - `GET /__tb_casereview/summaries`、`GET|PUT /__tb_casereview/report`、`POST /__tb_casereview/append`
|
|
11
|
-
* - `GET /__tb_casereview/backups`、`POST /__tb_casereview/backups/delete`
|
|
11
|
+
* - `GET /__tb_casereview/backups`、`POST /__tb_casereview/backups/create`、`POST /__tb_casereview/backups/delete`
|
|
12
12
|
* - `/__tb_caseblindspot?health=1`、`/__tb_caseblindspot/prompt`、`POST /__tb_caseblindspot/prompt/sync`
|
|
13
13
|
*/
|
|
14
14
|
import crypto from 'node:crypto';
|
|
@@ -17,7 +17,6 @@ import path from 'node:path';
|
|
|
17
17
|
|
|
18
18
|
import { getDataRoot } from '../builtin/session/space-context.mjs';
|
|
19
19
|
import { resolveContentRoot, spaceLocalFile } from '../builtin/session/space-layout.mjs';
|
|
20
|
-
import { purgeExpiredFilesInDir } from './case-backup-ttl.mjs';
|
|
21
20
|
import { ensurePluginPrompt, isPluginOnInSpace, readPluginPrompt } from './plugin-prompts.mjs';
|
|
22
21
|
import {
|
|
23
22
|
BLINDSPOT_PROMPT_FILE,
|
|
@@ -38,6 +37,8 @@ export const CASE_REVIEW_STORE_FILE = '用例评审.json';
|
|
|
38
37
|
|
|
39
38
|
/** 用例文件根目录(与 lh-project-docs 的 DOC_ROOT_DIRS.cases.dirName 一致) */
|
|
40
39
|
const CASES_DIR_NAME = '用例管理';
|
|
40
|
+
/** 用例管理下的备份文件夹(与前端 CASE_BACKUP_DIR_NAME 一致;首次备份才创建) */
|
|
41
|
+
const CASE_BACKUP_DIR_NAME = '备份列表';
|
|
41
42
|
|
|
42
43
|
const VERDICTS = ['usable', 'revise', 'invalid'];
|
|
43
44
|
const DIMENSION_KEYS = ['coverage', 'steps', 'expected', 'data', 'convention'];
|
|
@@ -149,7 +150,10 @@ function normalizeReview(raw) {
|
|
|
149
150
|
.filter(Boolean)
|
|
150
151
|
.slice(0, MAX_CASES);
|
|
151
152
|
const counts = { usable: 0, revise: 0, invalid: 0 };
|
|
152
|
-
for (const c of cases)
|
|
153
|
+
for (const c of cases) {
|
|
154
|
+
if (c.ignored) continue;
|
|
155
|
+
counts[c.verdict] += 1;
|
|
156
|
+
}
|
|
153
157
|
return {
|
|
154
158
|
at: text(raw.at, 40) || new Date().toISOString(),
|
|
155
159
|
score: int(raw.score, 0, 100, 0),
|
|
@@ -275,52 +279,93 @@ function mdCell(v) {
|
|
|
275
279
|
.replace(/\n+/g, '<br>');
|
|
276
280
|
}
|
|
277
281
|
|
|
278
|
-
|
|
282
|
+
/** 历史路径:空间本地 case-review/backup(只读兼容,新备份不再写入) */
|
|
283
|
+
function legacyReviewBackupDir(root) {
|
|
279
284
|
return spaceLocalFile(root, 'case-review/backup');
|
|
280
285
|
}
|
|
281
286
|
|
|
282
|
-
|
|
283
|
-
|
|
287
|
+
/** 用例管理/备份列表(相对 cases 根) */
|
|
288
|
+
function casesBackupDirAbs(root) {
|
|
289
|
+
return path.join(resolveContentRoot(root, CASES_DIR_NAME).abs, CASE_BACKUP_DIR_NAME);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** 备份文件名:默认用原名(用例名里通常已有时间戳),重名则 stem(2).ext */
|
|
293
|
+
function resolveBackupDest(dir, preferredName) {
|
|
294
|
+
const raw = path.basename(String(preferredName || 'backup').trim()) || 'backup';
|
|
295
|
+
const name = raw.replace(/[\\/]/g, '_');
|
|
296
|
+
const dest0 = path.join(dir, name);
|
|
297
|
+
if (!fs.existsSync(dest0)) return dest0;
|
|
298
|
+
const ext = path.extname(name);
|
|
299
|
+
const stem = ext ? name.slice(0, -ext.length) : name;
|
|
300
|
+
for (let i = 2; i < 1000; i++) {
|
|
301
|
+
const candidate = path.join(dir, `${stem}(${i})${ext}`);
|
|
302
|
+
if (!fs.existsSync(candidate)) return candidate;
|
|
303
|
+
}
|
|
304
|
+
return path.join(dir, `${stem}-${Date.now()}${ext}`);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function backupCaseFile(root, abs, preferredName) {
|
|
308
|
+
const dir = casesBackupDirAbs(root);
|
|
284
309
|
fs.mkdirSync(dir, { recursive: true });
|
|
285
|
-
|
|
286
|
-
purgeExpiredFilesInDir(dir);
|
|
287
|
-
const stamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
288
|
-
const name = path.basename(abs);
|
|
289
|
-
const dest = path.join(dir, `${stamp}-${name}`);
|
|
310
|
+
const dest = resolveBackupDest(dir, preferredName || path.basename(abs));
|
|
290
311
|
fs.copyFileSync(abs, dest);
|
|
291
312
|
return dest;
|
|
292
313
|
}
|
|
293
314
|
|
|
294
|
-
/**
|
|
315
|
+
/** 列出备份:用例管理/备份列表 + 历史 .lantern/case-review/backup */
|
|
295
316
|
function listReviewBackups(root) {
|
|
296
|
-
const dir = reviewBackupDir(root);
|
|
297
|
-
if (!fs.existsSync(dir)) return [];
|
|
298
317
|
const items = [];
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
318
|
+
const folderDir = casesBackupDirAbs(root);
|
|
319
|
+
if (fs.existsSync(folderDir)) {
|
|
320
|
+
for (const name of fs.readdirSync(folderDir)) {
|
|
321
|
+
if (!name || name.startsWith('.') || name.includes('/') || name.includes('..')) continue;
|
|
322
|
+
const abs = path.join(folderDir, name);
|
|
323
|
+
let st;
|
|
324
|
+
try {
|
|
325
|
+
st = fs.statSync(abs);
|
|
326
|
+
} catch {
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (!st.isFile()) continue;
|
|
330
|
+
const casesPath = `${CASE_BACKUP_DIR_NAME}/${name}`.replace(/\\/g, '/');
|
|
331
|
+
items.push({
|
|
332
|
+
name,
|
|
333
|
+
path: casesPath,
|
|
334
|
+
casesPath,
|
|
335
|
+
size: st.size,
|
|
336
|
+
mtime: st.mtimeMs,
|
|
337
|
+
kind: 'folder',
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const legacyDir = legacyReviewBackupDir(root);
|
|
342
|
+
if (fs.existsSync(legacyDir)) {
|
|
343
|
+
for (const name of fs.readdirSync(legacyDir)) {
|
|
344
|
+
if (!name || name.startsWith('.') || name.includes('/') || name.includes('..')) continue;
|
|
345
|
+
const abs = path.join(legacyDir, name);
|
|
346
|
+
let st;
|
|
347
|
+
try {
|
|
348
|
+
st = fs.statSync(abs);
|
|
349
|
+
} catch {
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (!st.isFile()) continue;
|
|
353
|
+
items.push({
|
|
354
|
+
name,
|
|
355
|
+
path: path.relative(root, abs).split(path.sep).join('/'),
|
|
356
|
+
size: st.size,
|
|
357
|
+
mtime: st.mtimeMs,
|
|
358
|
+
kind: 'legacy',
|
|
359
|
+
});
|
|
308
360
|
}
|
|
309
|
-
if (!st.isFile()) continue;
|
|
310
|
-
items.push({
|
|
311
|
-
name,
|
|
312
|
-
path: path.relative(root, abs).split(path.sep).join('/'),
|
|
313
|
-
size: st.size,
|
|
314
|
-
mtime: st.mtimeMs,
|
|
315
|
-
});
|
|
316
361
|
}
|
|
317
362
|
items.sort((a, b) => b.mtime - a.mtime);
|
|
318
363
|
return items;
|
|
319
364
|
}
|
|
320
365
|
|
|
321
|
-
/**
|
|
366
|
+
/** 只删历史 review backup 目录下的 basename(新备份走 cases deleteDocs) */
|
|
322
367
|
function deleteReviewBackups(root, names) {
|
|
323
|
-
const dir = path.resolve(
|
|
368
|
+
const dir = path.resolve(legacyReviewBackupDir(root));
|
|
324
369
|
const deleted = [];
|
|
325
370
|
const list = Array.isArray(names) ? names : [];
|
|
326
371
|
for (const raw of list.slice(0, 200)) {
|
|
@@ -561,11 +606,43 @@ async function reviewRoutes(req, res, root, tail, query) {
|
|
|
561
606
|
return sendJson(res, 200, { ok: true, entry: next });
|
|
562
607
|
}
|
|
563
608
|
|
|
564
|
-
//
|
|
609
|
+
// 备份列表(用例管理「备份列表」抽屉)
|
|
565
610
|
if (method === 'GET' && tail === '/backups') {
|
|
566
611
|
return sendJson(res, 200, { ok: true, items: listReviewBackups(root) });
|
|
567
612
|
}
|
|
568
613
|
|
|
614
|
+
// 手动备份:把正式用例拷进 用例管理/备份列表/(目录不存在则创建)
|
|
615
|
+
if (method === 'POST' && tail === '/backups/create') {
|
|
616
|
+
const body = JSON.parse((await readBody(req)) || '{}');
|
|
617
|
+
const rel = text(body.path, 400);
|
|
618
|
+
if (!rel) return sendJson(res, 400, { ok: false, error: '缺少用例文件路径' });
|
|
619
|
+
let abs;
|
|
620
|
+
try {
|
|
621
|
+
abs = caseFileAbs(root, rel);
|
|
622
|
+
} catch (e) {
|
|
623
|
+
return sendJson(res, e.statusCode || 400, { ok: false, error: e.message || '路径非法' });
|
|
624
|
+
}
|
|
625
|
+
if (!fs.existsSync(abs) || !fs.statSync(abs).isFile()) {
|
|
626
|
+
return sendJson(res, 404, { ok: false, error: `用例文件不存在:${rel}` });
|
|
627
|
+
}
|
|
628
|
+
// 禁止把「备份列表」里的文件再备份进自己
|
|
629
|
+
const norm = rel.replace(/\\/g, '/');
|
|
630
|
+
if (norm === CASE_BACKUP_DIR_NAME || norm.startsWith(`${CASE_BACKUP_DIR_NAME}/`)) {
|
|
631
|
+
return sendJson(res, 400, { ok: false, error: '不能备份「备份列表」内的文件' });
|
|
632
|
+
}
|
|
633
|
+
const preferred = text(body.name, 200) || path.basename(abs);
|
|
634
|
+
const dest = backupCaseFile(root, abs, preferred);
|
|
635
|
+
const casesPath = path
|
|
636
|
+
.relative(resolveContentRoot(root, CASES_DIR_NAME).abs, dest)
|
|
637
|
+
.split(path.sep)
|
|
638
|
+
.join('/');
|
|
639
|
+
return sendJson(res, 200, {
|
|
640
|
+
ok: true,
|
|
641
|
+
backup: casesPath,
|
|
642
|
+
name: path.basename(dest),
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
|
|
569
646
|
if (method === 'POST' && tail === '/backups/delete') {
|
|
570
647
|
const body = JSON.parse((await readBody(req)) || '{}');
|
|
571
648
|
const names = Array.isArray(body.names) ? body.names : [];
|
|
@@ -613,11 +690,15 @@ async function reviewRoutes(req, res, root, tail, query) {
|
|
|
613
690
|
writeStore(root, store);
|
|
614
691
|
}
|
|
615
692
|
|
|
693
|
+
const backupRel = path
|
|
694
|
+
.relative(resolveContentRoot(root, CASES_DIR_NAME).abs, backup)
|
|
695
|
+
.split(path.sep)
|
|
696
|
+
.join('/');
|
|
616
697
|
return sendJson(res, 200, {
|
|
617
698
|
ok: true,
|
|
618
699
|
path: rel,
|
|
619
700
|
appended: rows.length,
|
|
620
|
-
backup:
|
|
701
|
+
backup: backupRel,
|
|
621
702
|
});
|
|
622
703
|
}
|
|
623
704
|
|