nx-kv 0.42.3 → 0.44.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 (88) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +1 -1
  3. package/assets/kv-get/SKILL.md +4 -4
  4. package/assets/kv-get/references/localget.md +2 -2
  5. package/package.json +1 -1
  6. package/src/core/attachmentdb/docs.js +12 -0
  7. package/src/core/attachmentdb/relations.js +17 -0
  8. package/src/core/attachmentdb.js +1 -0
  9. package/src/modules/docs/attach.js +46 -1
  10. package/src/modules/docs/brief.js +35 -4
  11. package/src/modules/docs/index.js +15 -1
  12. package/src/modules/docs/service.js +10 -6
  13. package/src/modules/localtask/action-attach.js +25 -0
  14. package/src/modules/localtask/action-flags.js +0 -1
  15. package/src/modules/localtask/action-lifecycle.js +6 -4
  16. package/src/modules/localtask/action-waiting.js +3 -3
  17. package/src/modules/localtask/repo/rows.js +3 -0
  18. package/src/modules/localtask/repo/tasks.js +18 -2
  19. package/src/modules/localtask/task-lifecycle.js +3 -3
  20. package/src/modules/localtask/task-ops.js +17 -4
  21. package/src/modules/localtask/task-view.js +14 -6
  22. package/src/modules/tasktool/attach-resource.js +3 -0
  23. package/src/modules/tasktool/attach.js +62 -0
  24. package/src/modules/tasktool/get.js +1 -2
  25. package/src/modules/tasktool/index.js +12 -5
  26. package/src/modules/tasktool/plugins/goal-template.js +86 -0
  27. package/src/modules/tasktool/plugins/taskgoal-store.js +61 -43
  28. package/src/modules/tasktool/plugins/timegoal-task-store.js +40 -3
  29. package/src/modules/tasktool/plugins/waitgoal-config.js +1 -1
  30. package/src/modules/tasktool/wait.js +20 -4
  31. package/src/shared/doc-title.js +71 -0
  32. package/src/shared/prompt-blocks.js +21 -0
  33. package/src/web/frontend/components/md/attach-area.jsx +56 -6
  34. package/src/web/frontend/components/md/attach-common.js +16 -3
  35. package/src/web/frontend/components/md/attach-modal.jsx +42 -2
  36. package/src/web/frontend/components/md/md-panes-helpers.js +4 -1
  37. package/src/web/frontend/components/repos/get-loop-modal.jsx +1 -1
  38. package/src/web/frontend/components/task-panel/layout.jsx +64 -0
  39. package/src/web/frontend/components/task-panel/page-shell.jsx +38 -0
  40. package/src/web/frontend/components/tool-acts/modules.js +2 -0
  41. package/src/web/frontend/modules/md/md-render.js +34 -11
  42. package/src/web/frontend/modules/md/progress-chain.js +29 -0
  43. package/src/web/frontend/modules/md/progress-search.js +14 -0
  44. package/src/web/frontend/modules/md/styles/chrome.css +9 -0
  45. package/src/web/frontend/modules/md/styles/panels.css +2 -0
  46. package/src/web/frontend/modules/md/styles/shell.css +2 -10
  47. package/src/web/frontend/page/dir/index.jsx +8 -5
  48. package/src/web/frontend/page/dir/landing.jsx +92 -99
  49. package/src/web/frontend/page/dir/task-actions.js +13 -5
  50. package/src/web/frontend/page/dir/task-goal-section.jsx +29 -24
  51. package/src/web/frontend/page/dir/task-goal.js +6 -1
  52. package/src/web/frontend/page/dir/task.jsx +22 -6
  53. package/src/web/frontend/page/doc/index.jsx +24 -12
  54. package/src/web/frontend/page/group/index.jsx +145 -68
  55. package/src/web/frontend/page/progress/index.jsx +67 -19
  56. package/src/web/frontend/page/settings/prompt-template-params.js +38 -2
  57. package/src/web/frontend/styles-v2/views.css +5 -1
  58. package/src/web/public/assets/Introduction-CDSLSy0q.js +6 -0
  59. package/src/web/public/assets/{bar-C0LZwZoX.js → bar-Dp9JHQEk.js} +1 -1
  60. package/src/web/public/assets/{cloud-ol3se4zn.js → cloud-D13Ed3Pg.js} +1 -1
  61. package/src/web/public/assets/{composer-panel-O04Eac_2.js → composer-panel-eKhM7jDM.js} +1 -1
  62. package/src/web/public/assets/deleted-panel-QHsQZ5Ez.js +1 -0
  63. package/src/web/public/assets/dir-CiDjsHfd.js +5 -0
  64. package/src/web/public/assets/group-DDXtRIPf.js +2 -0
  65. package/src/web/public/assets/index-DGvBoOdp.css +1 -0
  66. package/src/web/public/assets/{index-BAS6Qpjs.js → index-Dq7eNqAB.js} +2 -2
  67. package/src/web/public/assets/md-history-DI1Ukbvc.js +39 -0
  68. package/src/web/public/assets/{overview-CIeUo4At.js → overview-BE6O6j51.js} +1 -1
  69. package/src/web/public/assets/progress-Bx0reVYl.js +3 -0
  70. package/src/web/public/assets/{refs-BpET-Lxl.js → refs-BkncFh9X.js} +1 -1
  71. package/src/web/public/assets/{repos-K67Ie07A.js → repos-C9wx2OXj.js} +2 -2
  72. package/src/web/public/assets/{route-crumb-B7T_Hupr.js → route-crumb-_IyS9fTT.js} +1 -1
  73. package/src/web/public/assets/settings-DlgWRz3r.js +7 -0
  74. package/src/web/public/assets/{status-tag-B7CrVhQP.js → status-tag-Bop-R-gG.js} +1 -1
  75. package/src/web/public/assets/task-CNbU9Z6v.js +11 -0
  76. package/src/web/public/assets/{templates-6moKn9GB.js → templates-CK9nH5WD.js} +1 -1
  77. package/src/web/public/assets/tool-bar-9LD5jcE3.js +1 -0
  78. package/src/web/public/index.html +2 -2
  79. package/src/web/public/assets/Introduction--ILYt-bQ.js +0 -1
  80. package/src/web/public/assets/dir-B_HW1kpE.js +0 -5
  81. package/src/web/public/assets/group-BCOXDlvk.js +0 -1
  82. package/src/web/public/assets/index-CZzMw1zg.css +0 -1
  83. package/src/web/public/assets/md-history-DCgN2zcc.js +0 -39
  84. package/src/web/public/assets/progress-DHDlz9O9.js +0 -3
  85. package/src/web/public/assets/settings-Bek4c_r_.js +0 -6
  86. package/src/web/public/assets/task-DHca1uMu.js +0 -11
  87. package/src/web/public/assets/task-row-W12GJMCO.js +0 -1
  88. package/src/web/public/assets/tool-bar-CDUi6q4z.js +0 -1
@@ -0,0 +1,71 @@
1
+ // 文档标题口径(#168):**标题 = 正文第一行的 `# 标题`**,其余一律不算。
2
+ //
3
+ // 为什么不用「首个 # 行」或「首个非空行」:
4
+ // · 首个 # 行 —— 正文中间插一行 # 就会改标题(标题不该被正文结构牵动);
5
+ // · 首个非空行 —— 正文第一行是普通文字时,标题被**正文首行顶替**(#168 bug 2:
6
+ // 「正文第一行会影响标题」)。标题是文档自己的字段,只有首行 # 才作数。
7
+ //
8
+ // 纯函数、无依赖:前后端共用(前端文档页取标题 / 后端读盘给 ref 标注标题)。
9
+ // 任务标题另有口径(titleFromMd:首个非空行也可以),两者刻意不合并。
10
+
11
+ /** 去 frontmatter 后的正文首行(trim 后)。没有正文行 → ''。 */
12
+ function firstLineOf(body) {
13
+ const text = String(body ?? '');
14
+ // 去掉 frontmatter(--- … ---),标题只看正文部分
15
+ const s = text.replace(/^/, '').replace(/\r\n/g, '\n');
16
+ const m = s.match(/^---\n([\s\S]*?)\n---\n?/);
17
+ const rest = m ? s.slice(m[0].length) : s;
18
+ for (const line of rest.split('\n')) {
19
+ const t = line.trim();
20
+ if (t) return t;
21
+ }
22
+ return '';
23
+ }
24
+
25
+ /**
26
+ * 文档标题:正文**首行**是 `# 标题` 时取其文字,否则空串(调用方决定回落)。
27
+ * @param {string} body 文档正文
28
+ * @returns {string}
29
+ */
30
+ export function docTitleFromMd(body) {
31
+ const first = firstLineOf(body);
32
+ const m = first.match(/^#\s+(.+)$/);
33
+ return m ? m[1].trim() : '';
34
+ }
35
+
36
+ /**
37
+ * 文档正文是否以 `# 标题` 开头(编辑标题时用来判断「改首行」还是「补首行」)。
38
+ * @param {string} body
39
+ * @returns {boolean}
40
+ */
41
+ export function hasDocTitleLine(body) {
42
+ return !!docTitleFromMd(body);
43
+ }
44
+
45
+ /**
46
+ * 改写文档正文的标题行:首行是 # 标题就替换它,否则在文首补一行。
47
+ * 返回新正文(不改动原字符串)。
48
+ * @param {string} body
49
+ * @param {string} title 新标题(空 → 用「未命名文档」)
50
+ * @returns {string}
51
+ */
52
+ export function setDocTitleInMd(body, title) {
53
+ const text = String(body ?? '');
54
+ const t = String(title || '').trim() || '未命名文档';
55
+ const s = text.replace(/\r\n/g, '\n');
56
+ const m = s.match(/^---\n([\s\S]*?)\n---\n?/);
57
+ const front = m ? s.slice(0, m[0].length) : '';
58
+ const rest = m ? s.slice(m[0].length) : s;
59
+ const lines = rest.split('\n');
60
+ // 找到第一个非空行
61
+ const idx = lines.findIndex((l) => l.trim());
62
+ if (idx < 0) {
63
+ return `${front}# ${t}\n`;
64
+ }
65
+ if (/^#\s+/.test(lines[idx].trim())) {
66
+ lines[idx] = `# ${t}`;
67
+ } else {
68
+ lines.splice(idx, 0, `# ${t}`);
69
+ }
70
+ return `${front}${lines.join('\n')}`;
71
+ }
@@ -142,6 +142,20 @@ export const DEFAULT_TIMECHECK_TEMPLATE = [
142
142
  '{{/if}}',
143
143
  ].join('\n');
144
144
 
145
+ /**
146
+ * 默认「特殊功能提示」段(任务 #87):只在任务带时间目标时出现,给 agent 一份
147
+ * **可运算的**时间上下文(持续 / 剩余 / 是否到点)与任务号。
148
+ *
149
+ * 这一栏存在的意义是「占位符的可见入口」:goal.* 与 task.* 都是每轮 check 同源
150
+ * 渲染的同一份 ctx(check 返回对象走同一套模板),用户在这里改文案即可定制提示,
151
+ * 不必改代码。默认文案刻意不复述 check 指令(那在 timecheck 段里),只补状态。
152
+ */
153
+ export const DEFAULT_GOALHINT_TEMPLATE = [
154
+ '{{#if goal.check}}',
155
+ '〔特殊功能提示 · 时间目标〕任务 #{{task.id}} 正在计时:持续 {{goal.durationHuman}},{{#if goal.reached}}已到点{{else}}剩余 {{goal.remainingHuman}}{{/if}}。',
156
+ '{{/if}}',
157
+ ].join('\n');
158
+
145
159
  /**
146
160
  * 默认 ext(扩展 / 队列余量):同主题还有多少待领取任务、分别是什么标题,
147
161
  * 并明确优先级。队列为空 → `ext` 为 null,整段不出现({{#if ext.count}} 闸门)。
@@ -194,6 +208,13 @@ export const BLOCK_DEFS = Object.freeze([
194
208
  desc: '任务带时间目标时出现:check 指令或目录级状态',
195
209
  defaultTemplate: DEFAULT_TIMECHECK_TEMPLATE,
196
210
  },
211
+ {
212
+ id: 'goalhint',
213
+ tag: 'nx-kv.goalhint',
214
+ label: '特殊功能提示(timegoal)',
215
+ desc: '任务带时间目标时出现:可直接用 goal.* 时间变量与 task 全文占位;每轮 check 同源渲染',
216
+ defaultTemplate: DEFAULT_GOALHINT_TEMPLATE,
217
+ },
197
218
  {
198
219
  id: 'ext',
199
220
  tag: 'nx-kv.ext',
@@ -7,8 +7,9 @@
7
7
  // 图片缩略图点开大图;pdf/其它给打开/下载;task 点击跳任务;ref 点击开文档;
8
8
  // 移除时二选一:只解除关联 / 连资源与字节一起删。
9
9
  import { useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
10
- import { Modal } from '../popup/index.jsx';
10
+ import { Modal, useDialog } from '../popup/index.jsx';
11
11
  import { useToast } from '../toast/index.jsx';
12
+ import { api } from '../../api/client.js';
12
13
  import { uploadOne, droppedFiles } from '../cloud/upload.js';
13
14
  import AttachModal from './attach-modal.jsx';
14
15
  import {
@@ -42,6 +43,7 @@ export default function AttachArea({
42
43
  onOpenDoc,
43
44
  }) {
44
45
  const toast = useToast();
46
+ const { dialog, node: dialogNode } = useDialog();
45
47
  const [list, setList] = useState([]);
46
48
  const [loading, setLoading] = useState(false);
47
49
  const [error, setError] = useState('');
@@ -50,6 +52,8 @@ export default function AttachArea({
50
52
  const [dropping, setDropping] = useState(false);
51
53
  const [sortBy, setSortBy] = useState('position');
52
54
  const [removeOf, setRemoveOf] = useState(null);
55
+ // #168:ref 条目的两个动作——改说明(✎)/ 换指向(⇄,替换成另一篇文档)
56
+ const [replaceOf, setReplaceOf] = useState(null);
53
57
  const [removing, setRemoving] = useState(false);
54
58
  const [preview, setPreview] = useState(null);
55
59
 
@@ -120,6 +124,41 @@ export default function AttachArea({
120
124
  }
121
125
  };
122
126
 
127
+ // #168:改一条绑定的说明(desc)——面板直改,不必重挂
128
+ const editNote = async (item) => {
129
+ if (!item) return;
130
+ try {
131
+ const res = await dialog({
132
+ title: `说明 · ${item.name}`,
133
+ input: true,
134
+ placeholder: '这一行里大概是什么(交付清单会透出给 agent)',
135
+ value: item.note || '',
136
+ okText: '保存说明',
137
+ });
138
+ if (res === null) return;
139
+ const note = typeof res === 'string' ? res : (res && (res.value || res.note)) || '';
140
+ const path = host === 'doc'
141
+ ? `/api/docs/attach-note?ref=${encodeURIComponent(String(refId || ''))}`
142
+ : '/api/localtasks/attach-note';
143
+ const body = host === 'doc'
144
+ ? { attachment: item.id, note }
145
+ : { id: Number(hostId), ...(hostKey ? { key: hostKey } : hostCwd ? { cwd: hostCwd } : {}), attachment: item.id, note };
146
+ await api(path, { method: 'PATCH', body });
147
+ toast(note ? `已保存说明:${note}` : '已清空说明');
148
+ await load();
149
+ onChanged?.();
150
+ } catch (e) {
151
+ toast(`改说明失败:${(e && e.message) || e}`);
152
+ }
153
+ };
154
+
155
+ // #168:换指向——重新打开「添加附件」弹窗(只选文档),提交后把旧绑定换掉
156
+ const startReplace = (item) => {
157
+ if (!item) return;
158
+ setReplaceOf(item);
159
+ setModalOpen(true);
160
+ };
161
+
123
162
  const doRemove = async (purge) => {
124
163
  const item = removeOf;
125
164
  if (!item) return;
@@ -159,6 +198,8 @@ export default function AttachArea({
159
198
  dropFiles(null, e);
160
199
  }}
161
200
  >
201
+ {/* 「改说明」用的输入弹窗挂在这里(#168) */}
202
+ {dialogNode}
162
203
  <div className={'att-area-head' + (dragOver && !disabled ? ' is-over' : '')}>
163
204
  <span className="att-area-title">
164
205
  附件
@@ -194,14 +235,14 @@ export default function AttachArea({
194
235
  {inline.length ? (
195
236
  <div className="att-section">
196
237
  <div className="att-section-head">{AREA_LABEL.inline}<span className="att-section-hint">正文里的引用,删正文行会跟着消失</span></div>
197
- {inline.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, key: a.id }))}
238
+ {inline.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, onEditNote: editNote, onReplace: startReplace, key: a.id }))}
198
239
  </div>
199
240
  ) : null}
200
241
 
201
242
  {area.length ? (
202
243
  <div className="att-section">
203
244
  <div className="att-section-head">{AREA_LABEL.area}<span className="att-section-hint">不依赖正文,删正文行也不会丢</span></div>
204
- {area.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, key: a.id }))}
245
+ {area.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, onEditNote: editNote, onReplace: startReplace, key: a.id }))}
205
246
  </div>
206
247
  ) : null}
207
248
 
@@ -215,8 +256,10 @@ export default function AttachArea({
215
256
  allow={allow}
216
257
  taskOptions={taskOptions}
217
258
  docOptions={docOptions}
218
- onClose={() => setModalOpen(false)}
219
- onDone={async () => { await load(); onChanged?.(); }}
259
+ replaceAttachment={replaceOf ? replaceOf.id : null}
260
+ replaceNote={replaceOf ? replaceOf.note || '' : ''}
261
+ onClose={() => { setModalOpen(false); setReplaceOf(null); }}
262
+ onDone={async () => { setReplaceOf(null); await load(); onChanged?.(); }}
220
263
  />
221
264
 
222
265
  {removeOf ? (
@@ -261,7 +304,7 @@ export default function AttachArea({
261
304
  );
262
305
  }
263
306
 
264
- function renderItem(a, { onRemove, onPreview, onOpenTask, onOpenDoc }) {
307
+ function renderItem(a, { onRemove, onPreview, onOpenTask, onOpenDoc, onEditNote, onReplace }) {
265
308
  const src = a.kind === 'image' ? contentUrl(a.id) : '';
266
309
  return (
267
310
  <div className={`att-item att-kind-${a.kind}`} key={a.id}>
@@ -310,6 +353,13 @@ function renderItem(a, { onRemove, onPreview, onOpenTask, onOpenDoc }) {
310
353
  </span>
311
354
  ) : null}
312
355
 
356
+ {a.kind === 'ref' ? (
357
+ <span className="att-item-acts">
358
+ <button type="button" className="att-act" title="改这条绑定的一行说明(交付清单会透出)" onClick={() => onEditNote?.(a)}>✎ 说明</button>
359
+ <button type="button" className="att-act" title="换成另一篇文档(替换这条绑定)" onClick={() => onReplace?.(a)}>⇄ 更换</button>
360
+ </span>
361
+ ) : null}
362
+
313
363
  <button type="button" className="att-x" aria-label={`移除 ${a.name}`} onClick={() => onRemove(a)}>×</button>
314
364
  </div>
315
365
  );
@@ -85,11 +85,24 @@ export function endpointOf(host, { hostId, hostKey, hostCwd, refId }) {
85
85
  };
86
86
  }
87
87
 
88
- /** 待确认条目 → attach 请求体(文件先上传拿到 fileId)。 */
89
- export function attachBodyOf(item) {
88
+ /** 待确认条目 → attach 请求体(文件先上传拿到 fileId)。
89
+ *
90
+ * 文档来源的**字段名按宿主分**(#165 二轮):任务侧 action 收 `ref`
91
+ * (localtask.attach),文档侧收 `doc`(docs.attach)——之前两侧都发 `doc`,
92
+ * 面板「给任务挂文档」必然失败(未知键透传,attachToTask 收不到 ref)。
93
+ * `note`(绑定说明 / desc)与 `inline`(文档进原文,#162)随条目透传。
94
+ */
95
+ export function attachBodyOf(item, host = 'task') {
90
96
  if (item.source === 'file') return { fileId: item.fileId, name: item.name };
91
97
  if (item.source === 'url') return { url: item.url, name: item.name };
92
98
  if (item.source === 'task') return { task: String(item.seq), name: item.name };
93
- if (item.source === 'ref') return { doc: item.docRef, name: item.name };
99
+ if (item.source === 'ref') {
100
+ const body = host === 'doc'
101
+ ? { doc: item.docRef, name: item.name }
102
+ : { ref: item.docRef, name: item.name };
103
+ if (item.note) body.note = item.note;
104
+ if (host !== 'doc' && item.inline) body.inline = true;
105
+ return body;
106
+ }
94
107
  return {};
95
108
  }
@@ -41,6 +41,10 @@ export default function AttachModal({
41
41
  allow = { file: true, url: true, task: false, ref: false },
42
42
  taskOptions = [],
43
43
  docOptions = null,
44
+ // #168:替换模式——提交成功后把这条旧绑定换掉(换指向)
45
+ replaceAttachment = null,
46
+ // #168:换指向时沿用旧绑定的说明(用户写的 desc 不该因为换篇文档就丢)
47
+ replaceNote = '',
44
48
  onClose,
45
49
  onDone,
46
50
  }) {
@@ -152,11 +156,19 @@ export default function AttachModal({
152
156
  rel: d.rel || '',
153
157
  size: 0,
154
158
  status: 'pending',
159
+ // 文档绑定的两个可选属性(#162):说明(desc,随边落库、交付清单透出)
160
+ // 与「进原文」(任务侧:交付带全文而不是只给路径)
161
+ note: '',
162
+ inline: false,
155
163
  },
156
164
  ]);
157
165
  setRefSearch('');
158
166
  };
159
167
 
168
+ /** 改某个待确认文档条目的说明 / 进原文开关 */
169
+ const patchRefItem = (key, patch) =>
170
+ setItems((prev) => prev.map((x) => (x.key === key ? { ...x, ...patch } : x)));
171
+
160
172
  const removeItem = (key) => setItems((prev) => prev.filter((x) => x.key !== key));
161
173
 
162
174
  const submitOne = async (it) => {
@@ -168,7 +180,11 @@ export default function AttachModal({
168
180
  fileId = r.fileId || r.id;
169
181
  if (!fileId) throw new Error('上传未返回 fileId');
170
182
  }
171
- await ep.attach(attachBodyOf({ ...it, fileId }));
183
+ await ep.attach(attachBodyOf({ ...it, fileId, note: it.note || replaceNote || '' }, host));
184
+ // #168:换指向——新绑定挂好后解除旧的那条(旧资源进孤儿池,不删字节)
185
+ if (replaceAttachment) {
186
+ try { await ep.detach(replaceAttachment, false); } catch { /* 旧边解不掉也不影响新绑定 */ }
187
+ }
172
188
  setItems((prev) => prev.filter((x) => x.key !== it.key));
173
189
  return true;
174
190
  } catch (e) {
@@ -228,7 +244,7 @@ export default function AttachModal({
228
244
 
229
245
  return (
230
246
  <Modal
231
- title="添加附件"
247
+ title={replaceAttachment ? '更换文档绑定' : '添加附件'}
232
248
  size="md"
233
249
  onClose={busy ? undefined : onClose}
234
250
  busy={busy}
@@ -368,6 +384,30 @@ export default function AttachModal({
368
384
  {badgeOf(it.source === 'file' ? (/^image\//i.test(it.mime) ? 'image' : 'file') : it.source)}
369
385
  </span>
370
386
  {it.size ? <span className="att-pending-size">{fmtSize(it.size)}</span> : null}
387
+ {/* 文档条目:说明(desc)+ 进原文(任务侧才有效,#162) */}
388
+ {it.source === 'ref' ? (
389
+ <span className="att-pending-ref-opts">
390
+ <input
391
+ className="att-pending-note"
392
+ type="text"
393
+ value={it.note || ''}
394
+ placeholder="说明(这一行里大概是什么)"
395
+ disabled={busy}
396
+ onChange={(e) => patchRefItem(it.key, { note: e.target.value })}
397
+ />
398
+ {host === 'task' ? (
399
+ <label className="att-pending-inline" title="交付时把文档全文附进提示词,而不是只给路径">
400
+ <input
401
+ type="checkbox"
402
+ checked={!!it.inline}
403
+ disabled={busy}
404
+ onChange={(e) => patchRefItem(it.key, { inline: e.target.checked })}
405
+ />
406
+ 进原文
407
+ </label>
408
+ ) : null}
409
+ </span>
410
+ ) : null}
371
411
  {it.status === 'uploading' ? <span className="att-pending-state">上传中…</span> : null}
372
412
  {it.status === 'error' ? (
373
413
  <>
@@ -33,7 +33,10 @@ export function blockHtml(text, attachments) {
33
33
  // 下发——本函数是**逐块**调用的,renderMarkdownHtml 会把文件附件拼成 chip
34
34
  // 附在每个块末尾,拖一个 md 进来就是「每一行都显示」(#118)。
35
35
  const imgs = (attachments || []).filter((a) => a?.type === 'image');
36
- return renderMarkdownHtml(raw, imgs).replace(
36
+ // #168:ref 条目也传下去——只用来把 `nxkv://ref/<id>` 的显示名换成**文档标题**
37
+ // (渲染层只查标题表,不产生任何 chip,逐块下发是安全的)。
38
+ const refs = (attachments || []).filter((a) => a?.kind === 'ref');
39
+ return renderMarkdownHtml(raw, [...imgs, ...refs]).replace(
37
40
  /<p class="mdw-empty">[\s\S]*?<\/p>/g,
38
41
  ''
39
42
  );
@@ -22,7 +22,7 @@ const GETLOOP_LINE_MAX = 2000;
22
22
  // 内置「持续 get」默认模板的预设文案(与服务端 waitgoal-config 默认同文案;%s = 任务编号,
23
23
  // 存取时与 {{task.id}} 互转)。服务端常量带 core 依赖,前端本地声明。
24
24
  const GETLOOP_DEFAULT_PRESET =
25
- '不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get(带 --summary 当前现状)领取下一条任务,直到 get 返回 timeout 为止。';
25
+ '不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get 领取下一条任务,直到 get 返回 timeout 为止。';
26
26
 
27
27
  /**
28
28
  * @param {object} repo 仓库记录(含 getLoop)
@@ -0,0 +1,64 @@
1
+ // 任务面板页的**整页布局组件**(#170):项目组页与目录(dir)任务页共用。
2
+ //
3
+ // 用户口径:「路由还是各自路由,指的 ui 样式统一,布局完全抽离出组件复用」——
4
+ // 两页的**路由与数据语义各自保留**(组页 = 多条成员 topic 的视图,目录页 = 一条
5
+ // topic 的视图),但**排布骨架必须同源**:否则两页各写一遍容器/间距/块序,
6
+ // 改一处另一处就漂(「仍然不一致」的根因)。
7
+ //
8
+ // 骨架(块序固定,间距由 rp-page 的 flex gap 统一):
9
+ //
10
+ // rp-page
11
+ // ├ rp-group-head 头部:h2(图标 + 名字 + 计数 chips)+ 右对齐动作区
12
+ // ├ intro 简介槽(组介绍 / 项目介绍)
13
+ // ├ batch 批量条槽(多选操作;没有就不占位)
14
+ // ├ list 任务列表槽(TaskPanel)
15
+ // └ footer 页脚槽(翻页条)
16
+ //
17
+ // 各页只往槽里放自己的内容与动作,**不自己写布局**。
18
+ import { Icon } from '../icons.jsx';
19
+
20
+ /**
21
+ * @param {object} props
22
+ * @param {string} props.name 页面主体名(组名 / 目录名)
23
+ * @param {Array<{text:string}|string>} [props.counts] 头部计数 chips
24
+ * @param {string} [props.icon] 名字前的图标(缺省 folder)
25
+ * @param {React.ReactNode} [props.actions] 头部右侧动作区(工具区)
26
+ * @param {React.ReactNode} [props.intro] 简介槽
27
+ * @param {React.ReactNode} [props.batch] 批量条槽
28
+ * @param {React.ReactNode} [props.list] 任务列表槽
29
+ * @param {React.ReactNode} [props.footer] 页脚槽(翻页条)
30
+ * @param {React.ReactNode} [props.extra] 额外内容(骨架之外的零散块)
31
+ */
32
+ export default function TaskPanelLayout({
33
+ name,
34
+ counts = [],
35
+ icon = 'folder',
36
+ actions = null,
37
+ intro = null,
38
+ batch = null,
39
+ list = null,
40
+ footer = null,
41
+ extra = null,
42
+ }) {
43
+ return (
44
+ <div className="rp-page">
45
+ <div className="rp-group-head">
46
+ <h2>
47
+ <Icon name={icon} size={15} /> {name}
48
+ {counts.map((c, i) => {
49
+ const text = typeof c === 'string' ? c : (c && c.text) || '';
50
+ return text ? (
51
+ <span className="rp-chip-count" key={i}>{text}</span>
52
+ ) : null;
53
+ })}
54
+ </h2>
55
+ {actions ? <div className="rp-group-acts">{actions}</div> : null}
56
+ </div>
57
+ {intro}
58
+ {batch}
59
+ {list}
60
+ {footer}
61
+ {extra}
62
+ </div>
63
+ );
64
+ }
@@ -0,0 +1,38 @@
1
+ // 任务面板页的**共享外壳**(#169):项目组页与目录(dir)任务页共用同一份结构。
2
+ //
3
+ // 为什么抽组件:两页此前各写各的容器类名(.rp-page / .rp-group-head 各写一遍),
4
+ // 背景、内距、间距靠 CSS 巧合对齐——一处改了另一处就漂(用户验收:「两个页面的
5
+ // 背景色不一致,复用组件呀」)。现在**结构与样式同源**:一个组件一份 DOM,
6
+ // 两页只传数据(名字 / 计数 chips / 工具区 / 内容)。
7
+ //
8
+ // 结构:rp-page 容器 → rp-group-head(h2:图标 + 名字 + 计数 chips;右侧动作区
9
+ // 右对齐)→ 内容。动作区由调用方传入(ToolActsBar),组件只管摆位。
10
+ import { Icon } from '../icons.jsx';
11
+
12
+ /**
13
+ * @param {object} props
14
+ * @param {string} props.name 页面主体名(组名 / 目录名)
15
+ * @param {Array<{text:string}|string>} [props.counts] 头部计数 chips(字符串或 {text})
16
+ * @param {string} [props.icon] 名字前的图标(缺省 folder)
17
+ * @param {React.ReactNode} [props.actions] 右侧动作区(工具区)
18
+ * @param {React.ReactNode} props.children 页面内容
19
+ */
20
+ export default function PageShell({ name, counts = [], icon = 'folder', actions = null, children }) {
21
+ return (
22
+ <div className="rp-page">
23
+ <div className="rp-group-head">
24
+ <h2>
25
+ <Icon name={icon} size={15} /> {name}
26
+ {counts.map((c, i) => {
27
+ const text = typeof c === 'string' ? c : (c && c.text) || '';
28
+ return text ? (
29
+ <span className="rp-chip-count" key={i}>{text}</span>
30
+ ) : null;
31
+ })}
32
+ </h2>
33
+ {actions ? <div className="rp-group-acts">{actions}</div> : null}
34
+ </div>
35
+ {children}
36
+ </div>
37
+ );
38
+ }
@@ -20,6 +20,8 @@ export const GROUP_MODULES = [
20
20
  { id: 'addMember', label: '添加成员', section: 'bar' },
21
21
  { id: 'orch', label: '编排', section: 'bar' },
22
22
  { id: 'more', label: '更多', section: 'bar', noHide: true },
23
+ // #169:组页补「已删除任务」(与目录页同款入口,组任务跨多个成员队列)
24
+ { id: 'deleted', label: '已删除任务', section: 'more' },
23
25
  { id: 'refs', label: '查看列表', section: 'more' },
24
26
  ];
25
27
 
@@ -61,7 +61,19 @@ function wikiKnown(target, knownNames) {
61
61
  return knownNames.has(norm) || knownNames.has(norm.split('/').pop());
62
62
  }
63
63
 
64
- function inline(s, knownNames) {
64
+ /**
65
+ * ref 链接的显示名(#168):优先**文档标题**(refId → title 的映射,来自附件
66
+ * 清单——服务端读盘补的正文首行 # 标题),没有映射才用链接原文。
67
+ */
68
+ function refTitleOf(target, text, refTitles) {
69
+ if (!refTitles || !refTitles.size) return text;
70
+ const m = String(target || '').match(/^nxkv:\/\/ref\/([^)\s]+)$/i);
71
+ if (!m) return text;
72
+ const t = refTitles.get(m[1]);
73
+ return t ? esc(t) : text;
74
+ }
75
+
76
+ function inline(s, knownNames, refTitles) {
65
77
  const base = esc(s)
66
78
  .replace(/`([^`]+)`/g, '<code>$1</code>')
67
79
  .replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>');
@@ -83,7 +95,9 @@ function inline(s, knownNames) {
83
95
  // 不让它落到「普通 markdown 链接」而被当外链。
84
96
  const withInternal = withAtt.replace(/\[([^\]]+)\]\((nxkv:\/\/[^)\s]+)\)/g, (m, text, target) => {
85
97
  if (!/^nxkv:\/\/(?:task|ref)\//i.test(target)) return m;
86
- return `<a class="md-wl" data-nxkv="${target}" title="内部资源:${target}">${text}</a>`;
98
+ // #168:ref 引用显示**文档标题**(用户在文档里填的那行 # 标题),没有标题才用原文
99
+ const label = refTitleOf(target, text, refTitles);
100
+ return `<a class="md-wl" data-nxkv="${target}" title="内部资源:${target}">${label}</a>`;
87
101
  });
88
102
  return withInternal.replace(/\[\[([^\[\]|]+)(?:\|([^\[\]]+))?\]\]/g, (_, target, label) => {
89
103
  const t = target.trim();
@@ -100,8 +114,17 @@ function inline(s, knownNames) {
100
114
  */
101
115
  export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
102
116
  const imgMap = {};
117
+ // ref 标题映射(#168):附件清单里 kind=ref 的条目 → refId → 文档标题,
118
+ // 渲染 ref 链接时用标题当显示名(用户填了标题,编辑器里就该看到标题)。
119
+ const refTitles = new Map();
103
120
  for (const a of attachments) {
121
+ if (!a) continue;
104
122
  if (a.type === 'image' && a.url) imgMap[a.name] = a.url;
123
+ if (a.kind === 'ref') {
124
+ const id = String(a.refId || a.targetKey || a.targetRef || '');
125
+ const title = String(a.docTitle || a.title || a.name || '');
126
+ if (id && title) refTitles.set(id, title);
127
+ }
105
128
  }
106
129
  // frontmatter **不再渲染成属性卡**(#113):board/project 这些是投递元数据,
107
130
  // 摆在一堆任务正文上方纯属噪音——正文里剥掉即可(编辑态仍能点开原 YAML 看)。
@@ -183,14 +206,14 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
183
206
  }
184
207
  if (curPara.length) paras.push(curPara);
185
208
  const bodyHtml = paras
186
- .map((p) => p.map((l) => inline(l, knownNames)).join('<br>'))
209
+ .map((p) => p.map((l) => inline(l, knownNames, refTitles)).join('<br>'))
187
210
  .join('<br><br>');
188
211
  html += `<div class="md-callout md-callout-${esc(type)}">`
189
- + (title ? `<div class="md-callout-t">${inline(title, knownNames)}</div>` : '')
212
+ + (title ? `<div class="md-callout-t">${inline(title, knownNames, refTitles)}</div>` : '')
190
213
  + `<div class="md-callout-b">${bodyHtml}</div></div>`;
191
214
  continue;
192
215
  }
193
- html += `<blockquote>${q.map((l) => inline(l, knownNames)).join('<br>')}</blockquote>`;
216
+ html += `<blockquote>${q.map((l) => inline(l, knownNames, refTitles)).join('<br>')}</blockquote>`;
194
217
  continue;
195
218
  }
196
219
  if (line.startsWith('### ')) {
@@ -198,7 +221,7 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
198
221
  {
199
222
  const text = line.slice(4);
200
223
  const id = headingAnchorId(text.trim(), usedIds);
201
- html += `<h3 id="${esc(id)}">${inline(text, knownNames)}</h3>`;
224
+ html += `<h3 id="${esc(id)}">${inline(text, knownNames, refTitles)}</h3>`;
202
225
  }
203
226
  continue;
204
227
  }
@@ -207,7 +230,7 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
207
230
  {
208
231
  const text = line.slice(3);
209
232
  const id = headingAnchorId(text.trim(), usedIds);
210
- html += `<h2 id="${esc(id)}">${inline(text, knownNames)}</h2>`;
233
+ html += `<h2 id="${esc(id)}">${inline(text, knownNames, refTitles)}</h2>`;
211
234
  }
212
235
  continue;
213
236
  }
@@ -216,7 +239,7 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
216
239
  {
217
240
  const text = line.slice(2);
218
241
  const id = headingAnchorId(text.trim(), usedIds);
219
- html += `<h1 id="${esc(id)}">${inline(text, knownNames)}</h1>`;
242
+ html += `<h1 id="${esc(id)}">${inline(text, knownNames, refTitles)}</h1>`;
220
243
  }
221
244
  continue;
222
245
  }
@@ -229,15 +252,15 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
229
252
  const done = m[1] && /x/i.test(m[1]);
230
253
  if (m[1]) {
231
254
  const mark = done ? '☑' : '☐';
232
- html += `<li class="${done ? 'done' : 'todo'}"><span class="mdw-cb" aria-hidden="true">${mark}</span>${inline(m[2], knownNames)}</li>`;
255
+ html += `<li class="${done ? 'done' : 'todo'}"><span class="mdw-cb" aria-hidden="true">${mark}</span>${inline(m[2], knownNames, refTitles)}</li>`;
233
256
  } else {
234
- html += `<li>${inline(m[2], knownNames)}</li>`;
257
+ html += `<li>${inline(m[2], knownNames, refTitles)}</li>`;
235
258
  }
236
259
  continue;
237
260
  }
238
261
  flush();
239
262
  if (!line.trim()) continue;
240
- html += `<p>${inline(line, knownNames)}</p>`;
263
+ html += `<p>${inline(line, knownNames, refTitles)}</p>`;
241
264
  }
242
265
  if (inCode) html += '</code></pre>';
243
266
  flush();
@@ -0,0 +1,29 @@
1
+ // 进程面板的任务链折叠(#172):反馈任务链动辄几十轮,进程面板不再把它们**累计**
2
+ // 摊开——只留**链尖**(最新一轮),旧轮次去任务页的「更多 → 任务链」里看。
3
+ //
4
+ // 判据用后端的 childRoundCount(reopen 边数):>0 = 这件活儿已经在下一轮继续,
5
+ // 本条就是旧轮次。comment / feedback 边是**旁支新活**(评论派生 / 反馈里提的新需求),
6
+ // 不算「被取代」——父任务照旧该显示。
7
+ //
8
+ // 纯函数、无 DOM、无 IO,可单测(与 progress-search.js 同层)。
9
+
10
+ /** 这条任务是不是链尖(最新一轮,没有后续轮次)。 */
11
+ export function isChainTip(task) {
12
+ return !(Number(task && task.childRoundCount) || 0);
13
+ }
14
+
15
+ /**
16
+ * 按「链尖 / 旧轮次」切分一批任务。
17
+ * @param {Array<object>} tasks 任务列表(视图形状)
18
+ * @returns {{tips: Array<object>, folded: Array<object>}} 顺序保持原样
19
+ */
20
+ export function splitChainTips(tasks) {
21
+ const tips = [];
22
+ const folded = [];
23
+ for (const t of tasks || []) {
24
+ (isChainTip(t) ? tips : folded).push(t);
25
+ }
26
+ return { tips, folded };
27
+ }
28
+
29
+ export default isChainTip;
@@ -93,4 +93,18 @@ export function hitQuery(card, q) {
93
93
  return title.includes(body);
94
94
  }
95
95
 
96
+ /**
97
+ * 查询串是不是「精确编号」(12 / #12)且与卡片编号**等值**命中。
98
+ *
99
+ * #172:进程面板把反馈链的旧轮次折叠了(只留链尖),但「我要找 #87」这种
100
+ * 明确点名必须还能找到——所以旧轮次只按**编号等值**召回,标题模糊 / 前缀命中
101
+ * 不召回(一召回就把几十条旧轮次重新堆回屏上,等于没折叠)。
102
+ */
103
+ export function hitExactId(card, q) {
104
+ const raw = String(q ?? '').trim().toLowerCase();
105
+ const body = raw.startsWith('#') ? raw.slice(1).trim() : raw;
106
+ if (!body || !/^\d+$/.test(body)) return false;
107
+ return cardIdOf(card) === body;
108
+ }
109
+
96
110
  export default hitQuery;