lantern-harness 0.1.24 → 0.1.26

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 (88) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/500.html +4 -4
  3. package/dist/_astro/Base.Bilfw8As.css +1 -0
  4. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.DHRjA0au.js → Base.astro_astro_type_script_index_0_lang._n0VHShs.js} +1 -1
  5. package/dist/_astro/{CaseExecBoard.Xd7KUpkU.js → CaseExecBoard.cl2Od7av.js} +1 -1
  6. package/dist/_astro/{CaseGenerateApp.BgIi4YGn.js → CaseGenerateApp.nE3RR7bV.js} +5 -5
  7. package/dist/_astro/CasesLibrary.BkQY421S.js +21 -0
  8. package/dist/_astro/ChatApp.C_nGSCqd.js +226 -0
  9. package/dist/_astro/{DashboardBoard.CmxqpmzI.js → DashboardBoard.g_53rLV5.js} +2 -2
  10. package/dist/_astro/{DocsFileBrowser.Diq5zuSt.js → DocsFileBrowser.BdpWp8zQ.js} +1 -1
  11. package/dist/_astro/DocsPager.D55FTK9d.js +1 -0
  12. package/dist/_astro/{KnowledgeLibrary.CYutSepl.js → KnowledgeLibrary.DKci9jN8.js} +1 -1
  13. package/dist/_astro/NamePromptDialog.Csfnh5eM.js +1 -0
  14. package/dist/_astro/{PluginsPage.CgcXB7Ap.js → PluginsPage.Crrq4Ibd.js} +2 -2
  15. package/dist/_astro/PluginsPage.DzI3Xfa3.js +1 -0
  16. package/dist/_astro/PmBugsBoard.DVhrHxD2.js +1 -0
  17. package/dist/_astro/PmIterationsBoard.BQPHdbpp.js +1 -0
  18. package/dist/_astro/{PmProjectDetail.5tybGC46.js → PmProjectDetail.DZmqbZLO.js} +1 -1
  19. package/dist/_astro/PmProjectsBoard.tk8cI-lO.js +1 -0
  20. package/dist/_astro/PmRequirementsBoard.BjC9CEFr.js +1 -0
  21. package/dist/_astro/PmRequirementsBoard.CtuavIey.js +1 -0
  22. package/dist/_astro/{PmShared.Bzn6AGsN.js → PmShared.DRYCFoRc.js} +1 -1
  23. package/dist/_astro/{PromptsLibrary.DydrgeIw.js → PromptsLibrary.uvoZTwhi.js} +1 -1
  24. package/dist/_astro/{ReportsPage.BRVCnzL-.js → ReportsPage.B7MOskzc.js} +1 -1
  25. package/dist/_astro/{ReqAnalysisBoard.BCq_OoRo.js → ReqAnalysisBoard.Bz2de2Vj.js} +8 -8
  26. package/dist/_astro/{RequirementsLibrary.DtbFESBh.js → RequirementsLibrary._OviMClB.js} +1 -1
  27. package/dist/_astro/{SettingsDialog.DtEJLxtx.js → SettingsDialog.CC5S6knQ.js} +1 -1
  28. package/dist/_astro/SlideOverDrawer.C1IVOc_8.js +1 -0
  29. package/dist/_astro/{SpaceSwitcher.Cdveup1T.js → SpaceSwitcher.DQOG363O.js} +1 -1
  30. package/dist/_astro/TasksBoard.Uj4XWtWz.js +1 -0
  31. package/dist/_astro/{TemplatesLibrary.Bg-MFL57.js → TemplatesLibrary.CEVQPDDz.js} +1 -1
  32. package/dist/_astro/{TestStatsBoard.eiMbNGpn.js → TestStatsBoard.CO4JMh4N.js} +1 -1
  33. package/dist/_astro/TodosBoard.BkszTn-p.js +1 -0
  34. package/dist/_astro/UiAutoBoard.DegcBc_3.js +9 -0
  35. package/dist/_astro/app-version.D-te3dRV.js +1 -0
  36. package/dist/_astro/case-gen-run.Byxy6M5X.js +22 -0
  37. package/dist/_astro/{case-review.D1E3ldss.js → case-review.DlCarphW.js} +1 -1
  38. package/dist/_astro/{llm.BuR7z55C.js → llm.DyweO-KK.js} +1 -1
  39. package/dist/_astro/{pm.pMOkNqqK.js → pm.BXmOiFfW.js} +1 -1
  40. package/dist/_astro/{story-review.BRcUdixS.js → story-review.B5I45C1T.js} +1 -1
  41. package/dist/_astro/tasks.jfnSAEmg.js +1 -0
  42. package/dist/case-exec/index.html +5 -5
  43. package/dist/cases/generate/index.html +5 -5
  44. package/dist/cases/library/index.html +5 -5
  45. package/dist/dashboard/index.html +5 -5
  46. package/dist/docs/changelog/index.html +45 -5
  47. package/dist/docs/install/index.html +4 -4
  48. package/dist/docs/manual/index.html +12 -12
  49. package/dist/knowledge/index.html +5 -5
  50. package/dist/plugins/index.html +5 -5
  51. package/dist/pm/bugs/index.html +5 -5
  52. package/dist/pm/iterations/index.html +5 -5
  53. package/dist/pm/projects/detail/index.html +5 -5
  54. package/dist/pm/projects/index.html +5 -5
  55. package/dist/pm/requirements/index.html +5 -5
  56. package/dist/prompts/index.html +5 -5
  57. package/dist/reports/index.html +5 -5
  58. package/dist/requirement-analysis/index.html +5 -5
  59. package/dist/requirements/index.html +5 -5
  60. package/dist/tasks/index.html +5 -5
  61. package/dist/templates/index.html +5 -5
  62. package/dist/test-automation/index.html +5 -5
  63. package/dist/test-stats/index.html +5 -5
  64. package/dist/todos/index.html +5 -5
  65. package/dist/workbench/index.html +5 -5
  66. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +8 -8
  67. package/lh-plugins/lh-case-review.mjs +115 -34
  68. package/lh-plugins/lh-pm.mjs +6 -2
  69. package/lh-plugins/lh-todos.mjs +59 -18
  70. package/package.json +1 -1
  71. package/dist/_astro/Base.nGl8De0W.css +0 -1
  72. package/dist/_astro/CasesLibrary.B2VCAoTt.js +0 -21
  73. package/dist/_astro/ChatApp.CeSatNSf.js +0 -220
  74. package/dist/_astro/DocsPager.WMztSW4O.js +0 -1
  75. package/dist/_astro/NamePromptDialog.5XFIvdqv.js +0 -1
  76. package/dist/_astro/PluginsPage.pgN80K8r.js +0 -1
  77. package/dist/_astro/PmBugsBoard.Ceyt3pp6.js +0 -1
  78. package/dist/_astro/PmIterationsBoard.Dwsntvw6.js +0 -1
  79. package/dist/_astro/PmProjectsBoard.X2LZfFff.js +0 -1
  80. package/dist/_astro/PmRequirementsBoard.CXaGeFl9.js +0 -1
  81. package/dist/_astro/PmRequirementsBoard.CYbicBqS.js +0 -1
  82. package/dist/_astro/SlideOverDrawer.DMWJPD_W.js +0 -1
  83. package/dist/_astro/TasksBoard.rwdPWLAh.js +0 -1
  84. package/dist/_astro/TodosBoard.CrZMl6Ei.js +0 -1
  85. package/dist/_astro/UiAutoBoard.CLi9vmuE.js +0 -9
  86. package/dist/_astro/app-version.XPYyWuno.js +0 -1
  87. package/dist/_astro/case-gen-run.BbI2iGo9.js +0 -21
  88. package/dist/_astro/tasks.BNBkrFC3.js +0 -1
@@ -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) counts[c.verdict] += 1;
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
- function reviewBackupDir(root) {
282
+ /** 历史路径:空间本地 case-review/backup(只读兼容,新备份不再写入) */
283
+ function legacyReviewBackupDir(root) {
279
284
  return spaceLocalFile(root, 'case-review/backup');
280
285
  }
281
286
 
282
- function backupCaseFile(root, abs) {
283
- const dir = reviewBackupDir(root);
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
- // 写新备份前顺带清掉超过 7 天的旧备份
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
- for (const name of fs.readdirSync(dir)) {
300
- if (!name || name.startsWith('.')) continue;
301
- if (name.includes('/') || name.includes('\\') || name.includes('..')) continue;
302
- const abs = path.join(dir, name);
303
- let st;
304
- try {
305
- st = fs.statSync(abs);
306
- } catch {
307
- continue;
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
- /** 只删 backup 目录下的 basename,防路径穿越 */
366
+ /** 只删历史 review backup 目录下的 basename(新备份走 cases deleteDocs) */
322
367
  function deleteReviewBackups(root, names) {
323
- const dir = path.resolve(reviewBackupDir(root));
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: path.relative(root, backup).split(path.sep).join('/'),
701
+ backup: backupRel,
621
702
  });
622
703
  }
623
704
 
@@ -493,6 +493,9 @@ function saveUpload(root, raw) {
493
493
  *
494
494
  * 记录里存的是稳定相对路径(`缺陷管理/附件/xxx`),而缺陷管理目录可能被归进分组
495
495
  * (分组 = 物理归档),所以先把第一层目录名摘掉,再拼到解析出来的实际目录上。
496
+ *
497
+ * 注意:摘掉 `缺陷管理/` 后剩下的是 `附件/xxx`,必须拼到「缺陷管理」根上,
498
+ * 不能再拼到「缺陷管理/附件」上,否则会变成 `附件/附件/xxx` → 404 裂图。
496
499
  */
497
500
  function attachmentPath(root, url) {
498
501
  let rel = '';
@@ -505,8 +508,9 @@ function attachmentPath(root, url) {
505
508
  const normalized = path.posix.normalize(rel.replace(/\\/g, '/')).replace(/^\/+/, '');
506
509
  const prefix = `${ATTACHMENT_DIR}/`;
507
510
  const sub = normalized.startsWith(prefix) ? normalized.slice(prefix.length) : normalized;
508
- const allowed = path.resolve(attachmentBase(root), ATTACHMENT_SUBDIR);
509
- const target = path.resolve(allowed, sub);
511
+ const base = attachmentBase(root);
512
+ const allowed = path.resolve(base, ATTACHMENT_SUBDIR);
513
+ const target = path.resolve(base, sub);
510
514
  if (target !== allowed && !target.startsWith(`${allowed}${path.sep}`)) return '';
511
515
  return target;
512
516
  }
@@ -101,18 +101,35 @@ function endDateFor(status, existing) {
101
101
  }
102
102
 
103
103
  /**
104
- * 自动标记「已延期」:未结束且截止日期早于今天 → status = overdue。
105
- * 只在读取 / 写入时顺着日期单向升级,不往回改(用户把截止日推后可以自己改回进行中)。
106
- * 返回是否真的改了,调用方据此决定要不要落盘。
107
- * @param {Array<{status: string, dueDate: string}>} items
104
+ * 按起止日期推断未结束态:
105
+ * 截止已过 → overdue;开始在未来 → pending;开始≤今天 → in_progress;仅有未过期截止 → pending。
106
+ * @param {string} startDate
107
+ * @param {string} dueDate
108
+ * @param {string} today
109
+ * @returns {string | null}
108
110
  */
109
- function markOverdue(items) {
111
+ function inferStatusFromDates(startDate, dueDate, today) {
112
+ if (dueDate && dueDate < today) return 'overdue';
113
+ if (startDate && startDate > today) return 'pending';
114
+ if (startDate && startDate <= today) return 'in_progress';
115
+ if (dueDate && dueDate >= today) return 'pending';
116
+ return null;
117
+ }
118
+
119
+ /**
120
+ * 未手锁状态时按日期自动推 status(含已延期 / 待开始 / 进行中)。
121
+ * statusManual = true 的条目跳过;已完成 / 已取消不动。
122
+ * 返回是否真的改了,调用方据此决定要不要落盘(不改 updatedAt,避免刷屏排序)。
123
+ * @param {Array<{status: string, statusManual?: boolean, startDate: string, dueDate: string}>} items
124
+ */
125
+ function applyAutoStatus(items) {
110
126
  const today = todayLocal();
111
127
  let changed = false;
112
128
  for (const item of items) {
113
- if (CLOSED_STATUSES.has(item.status) || item.status === 'overdue') continue;
114
- if (item.dueDate && item.dueDate < today) {
115
- item.status = 'overdue';
129
+ if (CLOSED_STATUSES.has(item.status) || item.statusManual) continue;
130
+ const next = inferStatusFromDates(item.startDate || '', item.dueDate || '', today);
131
+ if (next && next !== item.status) {
132
+ item.status = next;
116
133
  item.taskEndDate = '';
117
134
  changed = true;
118
135
  }
@@ -160,6 +177,7 @@ function normalizeStored(raw) {
160
177
  id: text(raw.id, 64) || newId(),
161
178
  title,
162
179
  status,
180
+ statusManual: Boolean(raw.statusManual),
163
181
  priority: oneOf(raw.priority, TODO_PRIORITIES, ''),
164
182
  linkedTask: text(raw.linkedTask, 200),
165
183
  taskId: text(raw.taskId, 64),
@@ -181,6 +199,7 @@ function normalizePatch(raw, base) {
181
199
  if (!raw || typeof raw !== 'object') return patch;
182
200
  if ('title' in raw) patch.title = text(raw.title, 200);
183
201
  if ('status' in raw) patch.status = oneOf(raw.status, TODO_STATUSES, base.status);
202
+ if ('statusManual' in raw) patch.statusManual = Boolean(raw.statusManual);
184
203
  if ('priority' in raw) patch.priority = oneOf(raw.priority, TODO_PRIORITIES, '');
185
204
  if ('linkedTask' in raw) patch.linkedTask = text(raw.linkedTask, 200);
186
205
  if ('taskId' in raw) patch.taskId = text(raw.taskId, 64);
@@ -196,16 +215,25 @@ function normalizePatch(raw, base) {
196
215
  */
197
216
  function buildItem(raw, meta = {}) {
198
217
  const now = new Date().toISOString();
199
- const status = oneOf(raw?.status, TODO_STATUSES, 'pending');
218
+ const startDate = dateOrEmpty(raw?.startDate);
219
+ const dueDate = dateOrEmpty(raw?.dueDate);
220
+ const statusManual = Boolean(raw?.statusManual);
221
+ let status = oneOf(raw?.status, TODO_STATUSES, 'pending');
222
+ // 新建未手锁时按日期推一次(今天开始 → 进行中;未来 → 待开始)
223
+ if (!statusManual && !CLOSED_STATUSES.has(status)) {
224
+ const inferred = inferStatusFromDates(startDate, dueDate, todayLocal());
225
+ if (inferred) status = inferred;
226
+ }
200
227
  return {
201
228
  id: newId(),
202
229
  title: text(raw?.title, 200),
203
230
  status,
231
+ statusManual,
204
232
  priority: oneOf(raw?.priority, TODO_PRIORITIES, ''),
205
233
  linkedTask: text(raw?.linkedTask, 200),
206
234
  taskId: text(raw?.taskId, 64),
207
- startDate: dateOrEmpty(raw?.startDate),
208
- dueDate: dateOrEmpty(raw?.dueDate),
235
+ startDate,
236
+ dueDate,
209
237
  taskEndDate: endDateFor(status, ''),
210
238
  note: text(raw?.note),
211
239
  source: meta.mode === 'ai' ? 'ai' : 'manual',
@@ -240,8 +268,8 @@ export function lhTodosPlugin() {
240
268
 
241
269
  if (method === 'GET' && !itemId) {
242
270
  const store = readStore(root);
243
- // 过了截止日期的自动升级成「已延期」并落库,页面与 AI 读到的是同一个状态
244
- if (markOverdue(store.items)) writeStore(root, store);
271
+ // 未手锁条目按日期自动推状态并落库,页面与 AI 读到的是同一个状态
272
+ if (applyAutoStatus(store.items)) writeStore(root, store);
245
273
  return sendJson(res, 200, { ok: true, ...store });
246
274
  }
247
275
 
@@ -259,7 +287,7 @@ export function lhTodosPlugin() {
259
287
  created.push(item);
260
288
  }
261
289
  store.items.push(...created);
262
- markOverdue(store.items);
290
+ applyAutoStatus(store.items);
263
291
  writeStore(root, store);
264
292
  // 新建时就带了关联任务:任务池 / 已完成 → 进行中
265
293
  for (const item of created) promoteLinkedTask(root, item.taskId);
@@ -286,10 +314,23 @@ export function lhTodosPlugin() {
286
314
  // 已经是结束态时沿用原值,改别的字段不会把结束日期刷新成今天。
287
315
  const wasClosed = CLOSED_STATUSES.has(base.status);
288
316
  next.taskEndDate = endDateFor(next.status, wasClosed ? base.taskEndDate : '');
289
- // 改完截止日期已经过期了:顺手标成「已延期」,不用等下次刷新
290
- if (!CLOSED_STATUSES.has(next.status) && next.dueDate && next.dueDate < todayLocal()) {
291
- next.status = 'overdue';
292
- next.taskEndDate = '';
317
+ // 用户手选状态 → 上锁;只改正日期且未上锁 → 按日期重推状态
318
+ if ('status' in patch && body.statusManual === true) next.statusManual = true;
319
+ if (
320
+ !CLOSED_STATUSES.has(next.status) &&
321
+ !next.statusManual &&
322
+ ('startDate' in patch || 'dueDate' in patch) &&
323
+ !('status' in patch && body.statusManual === true)
324
+ ) {
325
+ const inferred = inferStatusFromDates(
326
+ next.startDate || '',
327
+ next.dueDate || '',
328
+ todayLocal(),
329
+ );
330
+ if (inferred) {
331
+ next.status = inferred;
332
+ next.taskEndDate = endDateFor(next.status, '');
333
+ }
293
334
  }
294
335
  store.items[idx] = next;
295
336
  writeStore(root, store);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lantern-harness",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "AI 工作台:对话与插件工具、内容库、模板库、会话记忆,数据留在本机。",