nx-kv 0.68.2 → 0.69.0

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 (142) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/package.json +1 -1
  3. package/src/core/attachmentdb/query.ts +10 -1
  4. package/src/core/attachmentdb/resources.ts +4 -16
  5. package/src/core/db/bootstrap.ts +4 -3
  6. package/src/core/db/import-json/links.ts +2 -2
  7. package/src/core/db/import-json/repos.ts +3 -24
  8. package/src/core/db/import-json/tasks.ts +92 -7
  9. package/src/core/db/import-json.ts +1 -2
  10. package/src/core/db/migrations/index.ts +6 -0
  11. package/src/core/db/migrations/v16-data.ts +167 -0
  12. package/src/core/db/migrations/v16.sql +15 -0
  13. package/src/core/db/migrations/v17-data.ts +110 -0
  14. package/src/core/db/migrations/v17.sql +112 -0
  15. package/src/core/db/repo-match.ts +52 -0
  16. package/src/core/db/seed-templates.ts +46 -11
  17. package/src/core/db/verify.ts +2 -2
  18. package/src/core/db/version.ts +5 -1
  19. package/src/modules/claim/groupctx.ts +1 -1
  20. package/src/modules/claim/host.ts +5 -5
  21. package/src/modules/goals/plugins/timegoal-task-store.ts +1 -1
  22. package/src/modules/localtask/actions/_manifest.generated.ts +3 -0
  23. package/src/modules/localtask/actions/localtask-boardtasks.ts +39 -39
  24. package/src/modules/localtask/actions/localtask-reopen.ts +5 -0
  25. package/src/modules/localtask/actions/localtask-sync-queues.ts +35 -0
  26. package/src/modules/localtask/actions/localtask-tasks.ts +3 -2
  27. package/src/modules/localtask/actions/localtask-update.ts +6 -0
  28. package/src/modules/localtask/infra/repo/goals.ts +2 -2
  29. package/src/modules/localtask/infra/repo/links.ts +1 -1
  30. package/src/modules/localtask/infra/repo/rows.ts +16 -0
  31. package/src/modules/localtask/infra/repo/tasks.ts +45 -41
  32. package/src/modules/localtask/infra/repo/topics.ts +61 -4
  33. package/src/modules/localtask/lifecycle/add.ts +15 -23
  34. package/src/modules/localtask/lifecycle/task-lifecycle.ts +7 -7
  35. package/src/modules/localtask/lifecycle/task-ops.ts +22 -11
  36. package/src/modules/localtask/lifecycle/task-view.ts +17 -11
  37. package/src/modules/localtask/lifecycle/topics.ts +79 -3
  38. package/src/modules/localtask/lifecycle/update.ts +28 -29
  39. package/src/modules/localtask/ops/attach-resource.ts +3 -4
  40. package/src/modules/localtask/ops/attach.ts +2 -2
  41. package/src/modules/localtask/ops/board-target.ts +8 -28
  42. package/src/modules/repos/actions/board-add.ts +5 -1
  43. package/src/modules/repos/actions/board-assign.ts +5 -1
  44. package/src/modules/repos/actions/board-remove.ts +5 -1
  45. package/src/modules/repos/actions/repo-add.ts +5 -1
  46. package/src/modules/repos/actions/repo-update.ts +5 -1
  47. package/src/modules/repos/boards/transfer.ts +3 -2
  48. package/src/modules/repos/orchestrate.ts +17 -0
  49. package/src/modules/repos/transfer/export.ts +24 -18
  50. package/src/modules/templates/actions/template-update.ts +1 -1
  51. package/src/modules/templates/service.ts +3 -0
  52. package/src/web/frontend/api/cli-tree.json +16 -1
  53. package/src/web/frontend/api/client.generated.ts +11 -3
  54. package/src/web/frontend/components/Introduction/style.css +1 -1
  55. package/src/web/frontend/components/layout/vsc-crumbs-model.ts +16 -8
  56. package/src/web/frontend/components/layout/vsc-crumbs.css +9 -16
  57. package/src/web/frontend/components/layout/vsc-crumbs.tsx +63 -57
  58. package/src/web/frontend/components/md/panes/live-block.tsx +3 -11
  59. package/src/web/frontend/components/md/panes/md-panes-keys.ts +1 -2
  60. package/src/web/frontend/components/md/panes/md-panes.tsx +2 -4
  61. package/src/web/frontend/components/popup/index.tsx +17 -3
  62. package/src/web/frontend/components/popup/style.css +9 -0
  63. package/src/web/frontend/components/sidebar/model.ts +2 -2
  64. package/src/web/frontend/components/tool-acts/modules.ts +1 -0
  65. package/src/web/frontend/modules/md/doc-store.ts +6 -0
  66. package/src/web/frontend/modules/md/md-blocks.ts +4 -43
  67. package/src/web/frontend/modules/md/md-parse.ts +2 -5
  68. package/src/web/frontend/modules/md/md-render.ts +2 -2
  69. package/src/web/frontend/modules/md/styles/docs.css +1 -1
  70. package/src/web/frontend/modules/prompts/template-preview.ts +5 -6
  71. package/src/web/frontend/page/dag/index.tsx +6 -5
  72. package/src/web/frontend/page/dir/task-actions.ts +16 -13
  73. package/src/web/frontend/page/dir/task-beside.ts +10 -20
  74. package/src/web/frontend/page/dir/task-board-section.tsx +3 -5
  75. package/src/web/frontend/page/dir/task-derived-ctx.ts +10 -5
  76. package/src/web/frontend/page/dir/task-utils.ts +9 -1
  77. package/src/web/frontend/page/dir/task.tsx +4 -4
  78. package/src/web/frontend/page/group/index.tsx +8 -8
  79. package/src/web/frontend/page/progress/index.tsx +7 -11
  80. package/src/web/frontend/page/repos/api.ts +5 -0
  81. package/src/web/frontend/page/repos/index.tsx +12 -1
  82. package/src/web/frontend/page/settings/style.css +12 -2
  83. package/src/web/frontend/page/templates/index.tsx +9 -0
  84. package/src/web/frontend/page/templates/template-list.tsx +2 -1
  85. package/src/web/frontend/styles/base.css +1 -1
  86. package/src/web/frontend/styles/bindings.css +1 -1
  87. package/src/web/frontend/styles-v2/shell.css +16 -1
  88. package/src/web/public/assets/app-context-DPFYOrgE.js +1 -0
  89. package/src/web/public/assets/{bar-DEY9q8mI.js → bar-I4qGaKTO.js} +1 -1
  90. package/src/web/public/assets/board-view-jt8QixVg.js +1 -0
  91. package/src/web/public/assets/{button-BRGGaUcY.js → button-VP4pjVsx.js} +1 -1
  92. package/src/web/public/assets/{composer-launch-DEHhs8k_.js → composer-launch-BL344XZg.js} +1 -1
  93. package/src/web/public/assets/composer-panel-D0ojgf7z.js +1 -0
  94. package/src/web/public/assets/dag-BY0lf-Nl.js +1 -0
  95. package/src/web/public/assets/{dir-B0nwSQhy.js → dir-BNHyviHQ.js} +1 -1
  96. package/src/web/public/assets/{doc-DgYKv2wo.css → doc-Ka-2V5jn.css} +1 -1
  97. package/src/web/public/assets/doc-wmc4swmo.js +6 -0
  98. package/src/web/public/assets/group-BSQ9_Gjs.js +1 -0
  99. package/src/web/public/assets/index-D2P-v30u.js +3 -0
  100. package/src/web/public/assets/{index-GyxCJY9y.css → index-DHLeXl42.css} +1 -1
  101. package/src/web/public/assets/md-history-D0bYVPZY.js +47 -0
  102. package/src/web/public/assets/md-parse-BjzYV8n7.js +6 -0
  103. package/src/web/public/assets/{member-picker-BJ-Ucm-9.js → member-picker-BtWykPer.js} +1 -1
  104. package/src/web/public/assets/{popup-BdVXUaJk.js → popup-DLfU1TXG.js} +1 -1
  105. package/src/web/public/assets/{popup-CHK8uSG4.css → popup-DzBICcYS.css} +1 -1
  106. package/src/web/public/assets/progress-CQAvP9-n.js +3 -0
  107. package/src/web/public/assets/{refs-Cb9pmVsb.js → refs-Cf4ZbAra.js} +1 -1
  108. package/src/web/public/assets/{reopen-text-C3dnqygC.js → reopen-text-D0eQ2XAC.js} +1 -1
  109. package/src/web/public/assets/repo-form-modal-BahZhXq3.js +1 -0
  110. package/src/web/public/assets/repos-C2cZtRFo.js +12 -0
  111. package/src/web/public/assets/{route-crumb-DvXzznKm.js → route-crumb-DS76cmRK.js} +1 -1
  112. package/src/web/public/assets/{settings-BD9rXOpy.js → settings-C_VmzG7F.js} +1 -1
  113. package/src/web/public/assets/settings-CjXDi7qu.css +1 -0
  114. package/src/web/public/assets/task-C4Sqe4vT.js +14 -0
  115. package/src/web/public/assets/{task-j7fMfJUp.css → task-Dcd2eA8B.css} +1 -1
  116. package/src/web/public/assets/task-ops-SFagO-OC.js +2 -0
  117. package/src/web/public/assets/task-utils-Y-j-zi8J.js +1 -0
  118. package/src/web/public/assets/template-preview-EM3OQ1Rc.js +1 -0
  119. package/src/web/public/assets/templates-B8jnGSAl.js +10 -0
  120. package/src/web/public/assets/{tool-bar-CAMqYt5j.js → tool-bar-NHeX0Kmo.js} +2 -2
  121. package/src/web/public/assets/use-rail-drag-CtZxisjE.js +1 -0
  122. package/src/web/public/index.html +15 -15
  123. package/src/shared/frontmatter.ts +0 -107
  124. package/src/web/public/assets/app-context-KCsdqNTq.js +0 -1
  125. package/src/web/public/assets/board-view-C8OQhkyi.js +0 -1
  126. package/src/web/public/assets/composer-panel-Btmv_9MI.js +0 -1
  127. package/src/web/public/assets/dag-CD7N_yfu.js +0 -1
  128. package/src/web/public/assets/doc-R8KHVCxp.js +0 -6
  129. package/src/web/public/assets/group-B-f_aoow.js +0 -1
  130. package/src/web/public/assets/index-Bs5BehN8.js +0 -3
  131. package/src/web/public/assets/md-history-BR2jLhFQ.js +0 -47
  132. package/src/web/public/assets/progress-CLSIX544.js +0 -3
  133. package/src/web/public/assets/repo-form-modal-awEPCcJK.js +0 -1
  134. package/src/web/public/assets/repos-CIgKjolu.js +0 -12
  135. package/src/web/public/assets/settings-d2ah_h6O.css +0 -1
  136. package/src/web/public/assets/task-CJyFbImw.js +0 -14
  137. package/src/web/public/assets/task-ops-CsiArYZB.js +0 -2
  138. package/src/web/public/assets/task-status-Cjsm0xF7.js +0 -7
  139. package/src/web/public/assets/task-utils-Dh33OFKe.js +0 -1
  140. package/src/web/public/assets/template-preview-CjQ-ucPt.js +0 -1
  141. package/src/web/public/assets/templates-BC-bPIfY.js +0 -10
  142. package/src/web/public/assets/use-rail-drag-C3GpkThI.js +0 -1
@@ -17,6 +17,12 @@ export interface DocRecord {
17
17
  body: string;
18
18
  attachments: Attachment[];
19
19
  mode?: string;
20
+ /** #197:草稿归属(结构化,不再写正文 frontmatter)。提交时直接传给后端。 */
21
+ boardKey?: string;
22
+ projectKey?: string;
23
+ /** #197:评论草稿的原文锚点(替代 frontmatter.parent / parentDir) */
24
+ parentTask?: string;
25
+ parentDir?: string;
20
26
  }
21
27
 
22
28
  /** 内部状态:docId → 文档(对外只透出 docs,不透出包装)。 */
@@ -4,7 +4,6 @@
4
4
  // 空块编码是这里的核心不变量:空块在正文里用 ZWSP 独占一行占位(join/split 可往返),
5
5
  // 编辑态按空串处理;纯空白块(用户敲的空格是内容)用 ZWSP+空白 落盘,防止被当成
6
6
  // 块分隔符(markdown 语义:空行 = 段落分隔)。
7
- import { parseFrontmatter } from '../../../../shared/frontmatter.js';
8
7
 
9
8
  /** 空块占位(ZWSP):join/split 可往返,渲染与编辑按空串处理 */
10
9
  export const EMPTY_BLOCK = '\u200b';
@@ -163,34 +162,10 @@ export function liveBodyBlocks(body: unknown): string[] {
163
162
  return i < 0 ? blocks : blocks.filter((_, k) => k !== i);
164
163
  }
165
164
 
166
- /** 块是否是文档头部 frontmatter(`---`…`---` 且含 key: value)。 */
167
- export function isFrontmatterBlock(text: unknown): boolean {
168
- return Object.keys(parseFrontmatter(String(text ?? ''))).length > 0;
169
- }
170
-
171
- /**
172
- * 正文头部 frontmatter 结束后的字符偏移;没有有效 frontmatter → 0。
173
- * 贴图/嵌入禁止落在 FM 内部——插进去会在保存时被 stripFrontmatter 剥掉,
174
- * 并可能把 `board:` 撕成残留键(用户案例:`d: b_…`)。
175
- */
176
- export function frontmatterEndOffset(src: unknown): number {
177
- const text = String(src ?? '');
178
- if (!Object.keys(parseFrontmatter(text)).length) return 0;
179
- const m = text.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);
180
- return m ? (m[0] ?? '').length : 0;
181
- }
182
-
183
165
  function recomposeLiveBody(liveBlocks: string[], titleBlock: string | null): string {
166
+ // #197:正文不再有 frontmatter 头——直接标题 + 正文块重组。
184
167
  if (!titleBlock) return joinMdBlocks(liveBlocks);
185
- const out: string[] = [];
186
- let start = 0;
187
- if (liveBlocks[0] && isFrontmatterBlock(liveBlocks[0])) {
188
- out.push(liveBlocks[0]);
189
- start = 1;
190
- }
191
- out.push(titleBlock);
192
- out.push(...liveBlocks.slice(start));
193
- return joinMdBlocks(out);
168
+ return joinMdBlocks([titleBlock, ...liveBlocks]);
194
169
  }
195
170
 
196
171
  /**
@@ -237,27 +212,15 @@ export function insertAttachmentSnippet(
237
212
  }
238
213
 
239
214
  fi = Math.min(fi, live.length - 1);
240
- if (isFrontmatterBlock(live[fi])) {
241
- const content = snip.replace(/^\n+/, '').replace(/\n+$/, '');
242
- if (fi + 1 < live.length) {
243
- live[fi + 1] = content + (live[fi + 1] ? `\n${live[fi + 1]}` : '');
244
- } else {
245
- live.push(content);
246
- }
247
- const next = recomposeLiveBody(live, title);
248
- return { body: next, insertAt: frontmatterEndOffset(next) };
249
- }
250
215
 
251
216
  const block = live[fi] || '';
252
217
  const caret = opts.caretInBlock;
253
218
  const at = caret == null ? block.length : Math.min(Math.max(0, caret), block.length);
254
219
  live[fi] = block.slice(0, at) + snip + block.slice(at);
255
220
  const next = recomposeLiveBody(live, title);
256
- // 近似:FM(+标题)之后再累加此前块;够用在编辑器重设光标
221
+ // 近似:标题之后再累加此前块;够用在编辑器重设光标
257
222
  const prefixBlocks: string[] = [];
258
- if (title && live[0] && isFrontmatterBlock(live[0])) {
259
- prefixBlocks.push(live[0], title, ...live.slice(1, fi));
260
- } else if (title) {
223
+ if (title) {
261
224
  prefixBlocks.push(title, ...live.slice(0, fi));
262
225
  } else {
263
226
  prefixBlocks.push(...live.slice(0, fi));
@@ -271,7 +234,5 @@ export function insertAttachmentSnippet(
271
234
  return { body: src + snip, insertAt: src.length };
272
235
  }
273
236
  at = Math.min(Math.max(0, at), src.length);
274
- const fmEnd = frontmatterEndOffset(src);
275
- if (at < fmEnd) at = fmEnd;
276
237
  return { body: src.slice(0, at) + snip + src.slice(at), insertAt: at };
277
238
  }
@@ -7,8 +7,6 @@
7
7
  // 任务 frontmatter(工作组语义)**共用模块内同一份实现**:CLI(node)与面板(浏览器)
8
8
  // 各写一套正则,必然出现「面板认得出、CLI 认不出」这种最难查的分叉。
9
9
  import type { LocalTask } from '../../types.js';
10
- import { parseFrontmatter, stripFrontmatter, withFrontmatter } from '../../../../shared/frontmatter.js';
11
- export { parseFrontmatter, stripFrontmatter, withFrontmatter };
12
10
 
13
11
  export { headingAnchorId, extractMdHeadings, renderMarkdownHtml } from './md-render.js';
14
12
  export {
@@ -20,13 +18,12 @@ export {
20
18
  splitMdBlocks,
21
19
  joinMdBlocks,
22
20
  liveBodyBlocks,
23
- isFrontmatterBlock,
24
- frontmatterEndOffset,
25
21
  insertAttachmentSnippet,
26
22
  } from './md-blocks.js';
27
23
 
28
24
  export function titleFromMd(body: string, fallback = '未命名任务'): string {
29
- const lines = stripFrontmatter(body).split('\n');
25
+ // #197:正文无 frontmatter 头,直接取首行
26
+ const lines = body.split('\n');
30
27
  for (const line of lines) {
31
28
  const m = line.match(/^#\s+(.+)$/);
32
29
  if (m) return (m[1] ?? '').trim();
@@ -14,7 +14,6 @@
14
14
  // 双链 [[目标|显示]] 与 shared/wikilink.js 同一套正则与归一(收在同构层防两端漂移)。
15
15
  import { normalizeWikiTarget } from '../../../../shared/wikilink.js';
16
16
  import { looksLikeFileId } from '../../../../shared/attach.js';
17
- import { stripFrontmatter } from '../../../../shared/frontmatter.js';
18
17
  import type { Attachment } from '../../components/md/attachments/attach-common.js';
19
18
  import {
20
19
  BLOCK_RULES,
@@ -265,7 +264,8 @@ export function renderMarkdownHtml(
265
264
  // 1) 定义行先抽走(脚注正文、引用式链接目标),剩下的正文才逐行渲染
266
265
  const lines = DOC_RULES.reduce(
267
266
  (acc, rule) => rule.collect(acc, doc),
268
- stripFrontmatter(src).split('\n'),
267
+ // #197:正文无 frontmatter 头,直接渲染
268
+ src.split('\n'),
269
269
  );
270
270
  const env: InlineEnv = { footnotes: doc.footnotes, refLinks: doc.refLinks };
271
271
  const usedIds = new Set<string>();
@@ -249,7 +249,7 @@
249
249
  .docp-file:hover{background:var(--soft,#F1F0EC)}
250
250
 
251
251
  /* 组详情页的介绍块与绑定 chips(rp-page 系列) */
252
- .rp-intro{border:1px solid var(--line,#E4E2DC);border-radius:8px;background:#FBFAF8;margin:0 0 12px;overflow:hidden}
252
+ .rp-intro{border:1px solid var(--line,#E4E2DC);border-radius:8px;background:#f9f8f7;margin:0 0 12px;overflow:hidden}
253
253
  .rp-intro-head{
254
254
  display:flex;align-items:center;gap:8px;padding:6px 12px;
255
255
  border-bottom:1px solid var(--line,#E4E2DC);
@@ -5,7 +5,7 @@
5
5
  //
6
6
  // 两套语义分开,是因为它们的消费者不同:前者进交付正文,后者进设置页的预览框。
7
7
  // 预览**不写任何存储**、不改变真相——模板正文(templates.json / sqlite)仍是唯一真源。
8
- import { withFrontmatter } from '../../../../shared/frontmatter.js';
8
+
9
9
  import { renderTemplateBody } from './render-template-body.js';
10
10
 
11
11
  const SLOT_RE = /\{\{\s*([^}{\s][^{}]*?)\s*\}\}/g;
@@ -50,13 +50,12 @@ export function templateDraftBody(
50
50
  body?: unknown;
51
51
  values?: Record<string, unknown> | null;
52
52
  },
53
- /** 同时要写的其它归属字段(board / project…) */
54
- extra: Record<string, unknown> = {},
53
+ /** @deprecated #197:归属已改成草稿的结构化字段,不再写进正文头;保留参数只为调用点不漂 */
54
+ _extra: Record<string, unknown> = {},
55
55
  /** 参数页填写后的槽位值(覆盖 tpl.values);不传用模板默认值 */
56
56
  valuesOverride?: Record<string, unknown> | null,
57
57
  ): string {
58
58
  const values = valuesOverride !== undefined ? valuesOverride : tpl.values;
59
- const body = renderTemplateBody(tpl.body, values);
60
- const fields: Record<string, unknown> = { ...extra };
61
- return Object.keys(fields).length ? withFrontmatter(body, fields) : body;
59
+ // #197:只渲染正文——归属由 DocRecord 的 boardKey / projectKey 承载
60
+ return renderTemplateBody(tpl.body, values);
62
61
  }
@@ -15,7 +15,6 @@ import type { PointerEvent as ReactPointerEvent } from 'react';
15
15
  import { useApp } from '../../app-context.jsx';
16
16
  import { useToast } from '../../components/toast/index.jsx';
17
17
  import { PopMenu, useDialog } from '../../components/popup/index.jsx';
18
- import { parseFrontmatter } from '../../modules/md/md-parse.js';
19
18
  import { isGroupTask } from '../../modules/board/board-view.js';
20
19
  import { reaches } from '../../../../shared/graph.js';
21
20
  import { depToNodeKey, formatDepForTarget, isPending, nodeKeyOf, parseDep } from './model.js';
@@ -66,8 +65,9 @@ export default function DagPanel({ dirKey, groupId }: DagPanelProps) {
66
65
  const boardIds = [board.id, board.key, board.name].filter(Boolean);
67
66
  const pendingTasks = (t.tasks || []).filter((task) => {
68
67
  if (!isPending(task)) return false;
69
- const fm = parseFrontmatter(task.text);
70
- return fm.board && boardIds.includes(fm.board);
68
+ // #197:组归属读库内关联(boardMark),不再解析正文
69
+ const board = String((task as any).boardMark || (task as any).boardKey || '');
70
+ return board && boardIds.includes(board);
71
71
  });
72
72
  if (!pendingTasks.length) continue;
73
73
  out.push({
@@ -103,8 +103,9 @@ export default function DagPanel({ dirKey, groupId }: DagPanelProps) {
103
103
  if (filterKey && t.key !== filterKey) continue;
104
104
  for (const task of t.tasks || []) {
105
105
  if (!isPending(task)) continue;
106
- const fm = parseFrontmatter(task.text);
107
- if (!fm.board || !boardIds.includes(fm.board)) continue;
106
+ // #197:组归属读库内关联(boardMark),不再解析正文
107
+ const board = String((task as any).boardMark || (task as any).boardKey || '');
108
+ if (!board || !boardIds.includes(board)) continue;
108
109
  out.push({
109
110
  ...task,
110
111
  topicKey: t.key,
@@ -20,10 +20,7 @@ import {
20
20
  insertAttachmentSnippet,
21
21
  slugName,
22
22
  titleFromMd,
23
- parseFrontmatter,
24
- stripFrontmatter,
25
23
  stripPhantomEmptyLines,
26
- withFrontmatter,
27
24
  } from '../../modules/md/md-parse.js';
28
25
  import {
29
26
  docIdOf,
@@ -96,17 +93,20 @@ export function useTaskActions({
96
93
  }: UseTaskActionsArgs) {
97
94
  const toast = useToast();
98
95
 
99
- /** 标题 + frontmatter 拼装(提交/贴图同步共用)——标题行永远在 FM 之后。 */
96
+ /**
97
+ * 标题 + 正文拼装(提交/贴图同步共用)。
98
+ * #197:正文只存 markdown——归属在草稿的结构化字段里,这里不碰任何头部块;
99
+ * 历史正文若还残留 --- 头,顺手剥掉(迁移已清,纯保险)。
100
+ */
100
101
  const composeText = useCallback((title: string, bodyText: string) => {
101
102
  const t = (title || '').trim() || '未命名任务';
102
- const fm = parseFrontmatter(bodyText);
103
- const hasFm = Object.keys(fm).length > 0;
104
- let bare = stripFrontmatter(bodyText);
103
+ // #197:正文无 frontmatter 头
104
+ let bare = bodyText;
105
105
  // 幻影空块清洗(#92):块编辑器的 ZWSP 空块不落库——落库即「一段莫名空白」,下次打开还在、再编辑又攒一条。
106
106
  bare = stripPhantomEmptyLines(bare);
107
107
  if (!/^#\s+/m.test(bare)) bare = `# ${t}\n\n${bare}`;
108
108
  else bare = bare.replace(/^#\s+.+$/m, `# ${t}`);
109
- return hasFm ? withFrontmatter(bare, fm) : bare;
109
+ return bare;
110
110
  }, []);
111
111
 
112
112
  // 时间目标的落库口径:草稿 → POST 带 duration/goalPrompt;已有任务 → 与服务端声明比对,有变化才发。
@@ -135,7 +135,7 @@ export function useTaskActions({
135
135
  const submit = useCallback(() => guard(async () => {
136
136
  if (!doc) return;
137
137
  const t = (doc.title || '').trim() || '未命名任务';
138
- const fm = parseFrontmatter(doc.body);
138
+ const fm = docFm; // #197:归属来自草稿的结构化字段(不再解析正文)
139
139
  const b = composeText(t, doc.body);
140
140
  const groupSubmit = !!(boardCtx && fm.project &&
141
141
  boardCtx.members.some((m) => m.key === fm.project));
@@ -152,6 +152,9 @@ export function useTaskActions({
152
152
  cwd: topic?.cwd,
153
153
  id: Number(task),
154
154
  text: b,
155
+ // #197:改动归属用显式参数(后端按它搬家),不再改正文
156
+ ...(fm.project ? { project: fm.project } : {}),
157
+ ...(fm.board ? { board: fm.board } : {}),
155
158
  ...gp,
156
159
  });
157
160
  if (res?.moved) {
@@ -383,12 +386,12 @@ export function useTaskActions({
383
386
  const newTask = useCallback(() => {
384
387
  const draftId = nextDraftId();
385
388
  const docId = docIdOf(groupAnchored ? scopeOf(groupId) : scopeOf(topicKey), draftId);
386
- const fm: DocFm = {};
387
- if (boardCtx && boardCtx.board && boardCtx.board.id) fm.board = boardCtx.board.id;
388
- if (docFm.project) fm.project = docFm.project;
389
+ // #197:归属写成草稿的结构化字段(正文不再带 --- 头)
389
390
  saveDoc(docId, {
390
391
  title: '',
391
- body: withFrontmatter(tpl ? tpl.defaultPick().body : '', fm),
392
+ body: tpl ? tpl.defaultPick().body : '',
393
+ boardKey: boardCtx && boardCtx.board ? String(boardCtx.board.id) : undefined,
394
+ projectKey: docFm.project || undefined,
392
395
  });
393
396
  if (app.openPage) {
394
397
  app.openPage(
@@ -9,16 +9,14 @@ import type { ParentRef } from './task-utils.js';
9
9
  export interface BesideOpsArgs {
10
10
  parentRef: ParentRef | null;
11
11
  model: Model | null;
12
- appModel: Model | null;
12
+ appModel?: Model | null;
13
13
  toast: (msg: string) => void;
14
- isDraft: boolean;
15
- task: string;
16
14
  topicKey: string;
17
15
  tabId?: string;
18
16
  }
19
17
 
20
18
  export function useBesideOps(args: BesideOpsArgs) {
21
- const { parentRef, model, appModel, toast, isDraft, task, topicKey, tabId } = args;
19
+ const { parentRef, model, appModel, toast, topicKey, tabId } = args;
22
20
 
23
21
  const openParentBeside = useCallback(() => {
24
22
  if (!parentRef) {
@@ -40,25 +38,17 @@ export function useBesideOps(args: BesideOpsArgs) {
40
38
  m.doAction(Actions.deleteTab(tabId));
41
39
  }, [model, appModel, tabId]);
42
40
 
43
- // 面包屑任务段的「预览原文」:评论任务跳它的来源原文;普通任务把自己的原文
44
- // 旁路打开(openBesideMain 会先收掉旧旁路,同一时刻只有一块)。草稿没有原文。
45
- const previewOriginal = useCallback(() => {
46
- if (isDraft) {
47
- toast('草稿还没有原文');
48
- return;
49
- }
50
- if (parentRef) {
51
- openParentBeside();
52
- return;
53
- }
41
+ // #261:下拉任务条目的「预览原文」——把**任意**同队列任务的原文旁路打开
42
+ // (openBesideMain 会先收掉旧旁路,同一时刻只有一块)。
43
+ const openTaskBeside = useCallback((taskId: string | number) => {
54
44
  const m = model || appModel;
55
- if (!m) return;
45
+ if (!m || !topicKey) return;
56
46
  openBesideMain(m, {
57
47
  component: 'page',
58
- name: `原文 #${task}`,
59
- config: { dirKey: topicKey, task: String(task) },
48
+ name: `原文 #${taskId}`,
49
+ config: { dirKey: topicKey, task: String(taskId) },
60
50
  });
61
- }, [isDraft, parentRef, openParentBeside, model, appModel, toast, task, topicKey]);
51
+ }, [model, appModel, topicKey]);
62
52
 
63
- return { openParentBeside, closeBesideSelf, previewOriginal };
53
+ return { openParentBeside, closeBesideSelf, openTaskBeside };
64
54
  }
@@ -1,6 +1,5 @@
1
1
  // 归属项目(组任务):组面板「新增任务」带 frontmatter 的草稿/任务才显示。
2
2
  import { saveDoc } from '../../modules/md/doc-store.js';
3
- import { withFrontmatter } from '../../modules/md/md-parse.js';
4
3
  import type { BoardCtx, DocFm, DocState } from './task-utils.js';
5
4
  import { rememberGroupProject } from '../group/group-project-memo.js';
6
5
 
@@ -14,7 +13,7 @@ interface BoardSectionProps {
14
13
  markDirty: () => void;
15
14
  }
16
15
 
17
- export function BoardSection({ boardCtx, docFm, projectEditable, doc, id, markDirty }: BoardSectionProps) {
16
+ export function BoardSection({ boardCtx, docFm, projectEditable, id, markDirty }: BoardSectionProps) {
18
17
  if (!boardCtx) return null;
19
18
  const picked = boardCtx.members.find((m) => m.key === docFm.project);
20
19
 
@@ -33,9 +32,8 @@ export function BoardSection({ boardCtx, docFm, projectEditable, doc, id, markDi
33
32
  onChange={(e) => {
34
33
  // #187:记住这次选择——下次在这个组里新建任务直接用它当默认归属
35
34
  rememberGroupProject(boardCtx.board.id, e.target.value);
36
- saveDoc(id, {
37
- body: withFrontmatter(doc.body, { ...docFm, board: boardCtx.board.id, project: e.target.value }),
38
- });
35
+ // #197:归属存成草稿的结构化字段,正文不再带 frontmatter
36
+ saveDoc(id, { projectKey: e.target.value, boardKey: String(boardCtx.board.id) });
39
37
  markDirty();
40
38
  }}
41
39
  >
@@ -1,6 +1,6 @@
1
1
  // 派生上下文:frontmatter / 父任务锚点 / 工作组语义。
2
2
  import { useMemo } from 'react';
3
- import { parseFrontmatter, titleFromMd } from '../../modules/md/md-parse.js';
3
+ import { titleFromMd } from '../../modules/md/md-parse.js';
4
4
  import type { LocalTask, LocalTopic, RepoRow } from '../../types.js';
5
5
  import type { AppSlice, BoardCtx, DocFm, DocState, ParentRef } from './task-utils.js';
6
6
 
@@ -14,11 +14,16 @@ interface UseDerivedCtxArgs {
14
14
  }
15
15
 
16
16
  export function useDerivedCtx({ doc, beside, topicKey, topic, task, app }: UseDerivedCtxArgs) {
17
- // 工作组语义(frontmatter):组面板「新增任务」创建的草稿带 board/project——
18
- // 工具区给「归属项目」下拉(限本组成员),提交按 project 路由进对应项目的队列。
19
- const docFm = useMemo<DocFm>(() => (doc ? parseFrontmatter(doc.body) : {}), [doc && doc.body]);
17
+ // 工作组语义:**草稿的结构化字段**(#197 起不再读写正文 frontmatter)——
18
+ // 组面板「新增任务」创建的草稿带 boardKey/projectKey,提交按 projectKey 路由。
19
+ const docFm = useMemo<DocFm>(
20
+ () => (doc
21
+ ? { board: doc.boardKey || '', project: doc.projectKey || '', parent: doc.parentTask || '', parentDir: doc.parentDir || '' }
22
+ : {}),
23
+ [doc && doc.boardKey, doc && doc.projectKey, doc && doc.parentTask, doc && doc.parentDir],
24
+ );
20
25
 
21
- // 评论任务的原文锚点:frontmatter.parent(新建评论写入);旧数据从「锚定自「标题」」回推
26
+ // 评论任务的原文锚点:草稿的 parentTask(新建评论写入);旧数据从「锚定自「标题」」回推
22
27
  const parentRef = useMemo<ParentRef | null>(() => {
23
28
  if (beside) return null; // 旁路原文自己不再开旁路
24
29
  const pid = String(docFm.parent || '').trim();
@@ -65,9 +65,17 @@ export interface DocState {
65
65
  body: string;
66
66
  attachments: Attachment[];
67
67
  mode?: string;
68
+ /** #197:草稿归属与锚点(结构化字段,正文不再有 frontmatter) */
69
+ boardKey?: string;
70
+ projectKey?: string;
71
+ parentTask?: string;
72
+ parentDir?: string;
68
73
  }
69
74
 
70
- /** frontmatter:正文头部解析出来的键值(外部数据边界,按需读)。 */
75
+ /**
76
+ * 归属语义的原子字段(#197 起由草稿的结构化字段提供,不再从正文解析)。
77
+ * 保留 DocFm 这个名字是为了少改调用点;它已经不是「frontmatter」了。
78
+ */
71
79
  export type DocFm = Record<string, any>;
72
80
 
73
81
  /** 时间目标(可编辑态):时长 + 附加要求。 */
@@ -345,9 +345,9 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
345
345
  placeSelMenu('task', text, last.right - 60, last.bottom + 8, blockRange ? { blockRange } : {});
346
346
  };
347
347
 
348
- // 旁路三件套(打开来源原文 / 关闭自己 / 面包屑预览原文)抽到 task-beside.ts(行数门禁)
349
- const { openParentBeside, closeBesideSelf, previewOriginal } = useBesideOps({
350
- parentRef, model: model ?? null, appModel: app.model ?? null, toast, isDraft, task, topicKey, tabId,
348
+ // 旁路三件套(打开来源原文 / 关闭自己 / 下拉任务预览原文)抽到 task-beside.ts(行数门禁)
349
+ const { openParentBeside, closeBesideSelf, openTaskBeside } = useBesideOps({
350
+ parentRef, model: model ?? null, appModel: app.model ?? null, toast, topicKey, tabId,
351
351
  });
352
352
 
353
353
  const pickAtt = (accept: string) => {
@@ -398,7 +398,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
398
398
  {/* #254:顶条换 VS Code 式面包屑(命名空间 > 组/目录 > 任务;点段弹同级、
399
399
  悬浮出复制钮)。不再显示标题行——原 mdw-path 的两个信号
400
400
  (未保存 / 目录已不存在)下沉到这一行保留。 */}
401
- <VscCrumbs onPreview={previewOriginal} />
401
+ <VscCrumbs onPreviewTask={openTaskBeside} />
402
402
  {dirty ? <span className="mdw-top-note">未保存</span> : null}
403
403
  {topic?.cwdExists === false && (
404
404
  <span
@@ -37,7 +37,6 @@ import { openTemplateEditor } from '../../panels.jsx';
37
37
  import GetLoopMembersMenu from '../../components/repos/get-loop-members.js';
38
38
  import GetLoopModal from '../../components/repos/get-loop-modal.js';
39
39
  import { docIdOf, nextDraftId, saveDoc, scopeOf } from '../../modules/md/doc-store.js';
40
- import { parseFrontmatter } from '../../modules/md/md-parse.js';
41
40
  import { templateDraftBody } from '../../modules/prompts/template-preview.js';
42
41
  import { startFillIfSlotted } from '../../modules/md/new-task-from-template.js';
43
42
  import { sortTasksForDisplay } from '../../modules/board/board-view.js';
@@ -167,16 +166,16 @@ export default function GroupView({ dirKey, rows, repoData, model }: {
167
166
  return map;
168
167
  }, [topics]);
169
168
 
170
- // 本组任务 = 成员队列里**正文 frontmatter.board 指向本组**的任务。
171
- // 显示序与目录页同源(sortTasksForDisplay:待领取在前,历史按状态沉底)。
169
+ // 本组任务 = 成员队列里**归属本组**的任务(#197:读 DB 关联的 boardKey =
170
+ // topics.group_key,不再解析正文 frontmatter)。显示序与目录页同源。
172
171
  const groupRows = useMemo(() => {
173
172
  const ids = board ? [board.id, board.key, board.name].filter(Boolean) : [];
174
173
  const list: Array<{ member: MemberItem; task: TopicTask }> = [];
175
174
  for (const it of items) {
176
175
  for (const t of it.tasks || []) {
177
176
  if (t.deletedAt) continue; // 软删的不进列表(#180 起 web 不再提供回收站入口,恢复走 CLI)
178
- const fm = parseFrontmatter(t.text);
179
- if (!fm.board || !ids.includes(fm.board)) continue;
177
+ const bk = String((t as any).boardKey || '');
178
+ if (!bk || !ids.includes(bk)) continue;
180
179
  list.push({ member: it, task: t });
181
180
  }
182
181
  }
@@ -260,11 +259,12 @@ export default function GroupView({ dirKey, rows, repoData, model }: {
260
259
  const id = nextDraftId();
261
260
  // 草稿 doc 种在**组 scope**:从 #/group/<id>?task=draft-N 打开寻得回同一份(#86)
262
261
  const docId = docIdOf(scopeOf(board.id), id);
263
- // 与目录任务页同一条口径:正文取模板原文,归属字段写进 frontmatter。
264
- const extra = { board: board.id, project: sel.key };
262
+ // 与目录任务页同一条口径:正文取模板原文,归属写草稿的结构化字段(#197 无 frontmatter)。
265
263
  saveDoc(docId, {
266
264
  title: '',
267
- body: pick ? templateDraftBody(pick, extra) : templateDraftBody(tpl.defaultPick(), extra),
265
+ body: pick ? templateDraftBody(pick) : templateDraftBody(tpl.defaultPick()),
266
+ boardKey: board.id,
267
+ projectKey: sel.key,
268
268
  });
269
269
  app.openPage?.({ groupId: board.id, task: id, name: '新任务' });
270
270
  };
@@ -19,7 +19,7 @@ import type { ChainViewTarget } from './chain-view.js';
19
19
  import { Icon } from '../../components/icons.jsx';
20
20
  import { MenuPortal, openMenuAt, useMenu } from '../../components/md/shell/tool-bar.js';
21
21
  import { isGroupTask } from '../../modules/board/board-view.js';
22
- import { parseFrontmatter, taskToProgress } from '../../modules/md/md-parse.js';
22
+ import { taskToProgress } from '../../modules/md/md-parse.js';
23
23
  import { hitQuery } from '../../modules/md/progress-search.js';
24
24
  import { closeRightSidebar, findOpenPanel } from '../../workspace.js';
25
25
  import { useToast } from '../../components/toast/index.jsx';
@@ -158,23 +158,19 @@ export default function ProgressPanel({
158
158
  const inGroupQueue = !!member; // 成员队列 → 整组口径;否则走旧口径兜底
159
159
  for (const t of r.tasks) {
160
160
  if (!t || t.deletedAt) continue;
161
- let fm: { board?: string; project?: string } = {};
162
- try {
163
- fm = parseFrontmatter(t.text || '');
164
- } catch {
165
- fm = {};
166
- }
167
- if (!inGroupQueue && (!fm.board || !ids.includes(fm.board))) continue;
161
+ // #197:归属读库内关联(boardMark = 组、repoKey = 归属仓库),不再解析正文
162
+ const board = String((t as any).boardMark || (t as any).boardKey || '');
163
+ if (!inGroupQueue && (!board || !ids.includes(board))) continue;
168
164
  out.push({
169
165
  ...taskToProgress(t),
170
166
  key: `${r.key}:${t.id}`,
171
167
  taskId: t.id,
172
168
  topicKey: r.key,
173
169
  topicCwd: r.cwd || '',
174
- project: fm.project || '',
170
+ project: String((t as any).repoKey || ''),
175
171
  projectName: inGroupQueue
176
- ? ((member && member.name) || projectNameOf(fm.project, r))
177
- : projectNameOf(fm.project, r),
172
+ ? ((member && member.name) || projectNameOf(String((t as any).repoKey || ''), r))
173
+ : projectNameOf(String((t as any).repoKey || ''), r),
178
174
  });
179
175
  }
180
176
  }
@@ -49,6 +49,11 @@ export function listBoards(): Promise<BoardsPayload> {
49
49
  return api('/api/boards');
50
50
  }
51
51
 
52
+ /** 补齐仓库/组缺的队列 topic(POST /api/localtask/queues/sync;幂等只补不删)。 */
53
+ export function syncQueues(): Promise<{ repos: number; groups: number }> {
54
+ return api('/api/localtask/queues/sync', { method: 'POST', body: {} });
55
+ }
56
+
52
57
  /** 参考仓库体检(GET /api/repos/ref/check)。 */
53
58
  export function fetchRefCheck(): Promise<RefCheckPayload> {
54
59
  return api('/api/repos/ref/check');
@@ -20,7 +20,7 @@
20
20
  // bind-modals(绑定)/ remote-modal(对齐 remote)。
21
21
  import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
22
22
  import { useCallback, useEffect, useMemo, useState } from 'react';
23
- import { bindRef, createBoard, fetchRefCheck, listBoards, listDocs, listRepos, openRepo, refSync, removeRepo, type RefCheckPayload } from './api.js';
23
+ import { bindRef, createBoard, fetchRefCheck, listBoards, listDocs, listRepos, openRepo, refSync, removeRepo, syncQueues, type RefCheckPayload } from './api.js';
24
24
  import { useGuard, useToast } from '../../components/toast/index.jsx';
25
25
  import { RowMenu, useDialog } from '../../components/popup/index.jsx';
26
26
  import MemberPicker from '../../components/board/member-picker.jsx';
@@ -181,6 +181,15 @@ export default function ReposView() {
181
181
 
182
182
  // ---- 跨区块共享动作 ----
183
183
 
184
+ // #199:刷新队列——补齐仓库/组缺的队列 topic(幂等只补不删)。
185
+ // 登记仓库 / 建组 / 成员编排后后端已自动刷新;这个按钮兜历史数据与失败缺口。
186
+ const syncQueuesNow = () => guard(async () => {
187
+ const d = await syncQueues();
188
+ const n = (Number(d.repos) || 0) + (Number(d.groups) || 0);
189
+ toast(n > 0 ? `队列已同步:新补仓库队列 ${d.repos} 条、组队列 ${d.groups} 条` : '队列已同步:没有缺的');
190
+ await reload.all();
191
+ });
192
+
184
193
  const syncOne = (r: RepoRecord) => guard(async () => {
185
194
  const d = await refSync({ id: r.id });
186
195
  toast(d.status === 'updated' ? `已更新: ${d.name}` : d.status === 'upToDate' ? `${d.name} 已是最新` : `${d.name}: ${d.status} ${d.output || ''}`);
@@ -372,12 +381,14 @@ export default function ReposView() {
372
381
  kind="repos"
373
382
  titles={{
374
383
  add: '登记本机开发仓库',
384
+ queues: '补齐仓库/组缺的队列 topic(登记与编排后会自动刷新,这里兜历史缺口)',
375
385
  boards: '分组管理:建组 / 成员 / 组介绍文档',
376
386
  refs: '参考仓库面板:克隆 / 绑定 / 同步 / 检查 / 存储根',
377
387
  transfer: '布局与仓库的导入导出(逐条选择 / 冲突方案 / 差异检查)',
378
388
  }}
379
389
  actions={{
380
390
  add: () => setFormFor(null),
391
+ queues: () => syncQueuesNow(),
381
392
  boards: () => setBoardAdminOpen(true),
382
393
  refs: () => setRefOpen(true),
383
394
  transfer: () => setTransferOpen(true),
@@ -39,7 +39,8 @@
39
39
  background: var(--paper);
40
40
  color: var(--ink);
41
41
  font-weight: 650;
42
- box-shadow: 0 1px 2px rgba(20, 22, 26, .07);
42
+ /* #260 验收(材质):白底胶囊加发丝环,浮起但不脱手 */
43
+ box-shadow: 0 1px 2px rgba(20, 22, 26, .07), 0 0 0 1px var(--line);
43
44
  }
44
45
  .setp-navitem .ic { color: var(--mid); }
45
46
  .setp-navitem.on .ic { color: var(--ink); }
@@ -49,7 +50,7 @@
49
50
  flex: 1;
50
51
  min-width: 0;
51
52
  overflow: auto;
52
- padding: 12px 16px 18px;
53
+ padding: 14px 18px 20px;
53
54
  display: flex;
54
55
  flex-direction: column;
55
56
  gap: 10px;
@@ -60,6 +61,9 @@
60
61
  letter-spacing: 1px;
61
62
  color: var(--mid);
62
63
  text-transform: uppercase;
64
+ /* #260 验收(层级):分区标题压一条细线,与内容拉开 */
65
+ padding-bottom: 6px;
66
+ border-bottom: 1px solid var(--line);
63
67
  }
64
68
 
65
69
  .setp-row {
@@ -68,6 +72,12 @@
68
72
  gap: 10px;
69
73
  min-height: 26px;
70
74
  justify-content: space-between;
75
+ /* #260 验收(层级):相邻行之间发丝分隔(中间隔了别的元素就不画) */
76
+ padding: 3px 0;
77
+ }
78
+ .setp-row + .setp-row {
79
+ border-top: 1px solid var(--line);
80
+ padding-top: 9px;
71
81
  }
72
82
  .setp-row > span:first-child { color: var(--ink-2); }
73
83
  .setp-row .toggle { flex: none; }
@@ -247,6 +247,15 @@ export default function TemplatePanel({ config, model, tabId }: TemplatePanelPro
247
247
  </div>
248
248
  );
249
249
  }
250
+ // #195:内置模板不可改(出厂正文随版本升级自动覆盖)——即使手输路由也挡住编辑器
251
+ if (!isNew && existing?.builtin) {
252
+ return (
253
+ <div className="mdw-tpl-panel">
254
+ <RouteBreadcrumb />
255
+ <div className="pad muted">内置模板不可修改——出厂正文随版本升级自动覆盖。要定制请新建一条自己的模板。</div>
256
+ </div>
257
+ );
258
+ }
250
259
 
251
260
  const saveEditing = async ({ name, body }: TemplateDraft) => {
252
261
  setBusy(true);