nx-kv 0.52.0 → 0.53.1

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 (99) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/assets/groups.json +3 -21
  3. package/assets/nx-kv/SKILL.md +43 -162
  4. package/assets/nx-kv/references/A01-/351/242/206/345/217/226/344/273/273/345/212/241.md +46 -0
  5. package/assets/nx-kv/references/A02-/346/217/220/344/272/244/344/273/273/345/212/241.md +57 -0
  6. package/assets/nx-kv/references/A03-/345/256/214/346/210/220/344/270/216/351/207/215/345/274/200.md +49 -0
  7. package/assets/nx-kv/references/A04-/351/230/273/345/241/236/347/255/211/345/276/205/344/270/216/346/227/266/351/227/264/347/233/256/346/240/207.md +52 -0
  8. package/assets/nx-kv/references/A05-/351/231/204/344/273/266.md +41 -0
  9. package/assets/nx-kv/references/A06-/344/273/223/345/272/223/344/270/216/351/241/271/347/233/256/347/273/204.md +61 -0
  10. package/assets/nx-kv/references/A07-/345/217/202/350/200/203/344/273/223/345/272/223/345/205/213/351/232/206/344/270/216/345/274/272/345/210/266/350/257/273.md +43 -0
  11. package/assets/nx-kv/references/B01-/346/246/202/345/277/265/344/270/216/345/257/273/345/235/200.md +35 -0
  12. package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +97 -0
  13. package/package.json +1 -1
  14. package/src/modules/docs/actions/_manifest.generated.ts +3 -0
  15. package/src/modules/docs/actions/docs-bindings.ts +45 -8
  16. package/src/modules/docs/actions/docs-gc.ts +32 -0
  17. package/src/modules/docs/gc.ts +87 -0
  18. package/src/modules/docs/refs.ts +4 -1
  19. package/src/modules/docs/service.ts +25 -6
  20. package/src/modules/localtask/action-render.ts +1 -1
  21. package/src/modules/localtask/actions/localtask-claim.ts +1 -1
  22. package/src/modules/localtask/actions/localtask-config.ts +9 -4
  23. package/src/modules/repos/actions/repo-update.ts +1 -1
  24. package/src/modules/tasktool/delivery-template.ts +5 -1
  25. package/src/modules/tasktool/get.ts +12 -5
  26. package/src/modules/tasktool/plugins/waitgoal-config.ts +9 -2
  27. package/src/shared/prompt-blocks.ts +25 -3
  28. package/src/web/frontend/api/cli-tree.json +16 -1
  29. package/src/web/frontend/api/client.generated.ts +12 -2
  30. package/src/web/frontend/components/repos/get-loop-modal.tsx +27 -5
  31. package/src/web/frontend/components/sidebar/task-children.tsx +3 -1
  32. package/src/web/frontend/modules/md/styles/docs.css +8 -0
  33. package/src/web/frontend/page/doc/api.ts +0 -20
  34. package/src/web/frontend/page/doc/index.tsx +64 -17
  35. package/src/web/frontend/page/overview/api.ts +13 -0
  36. package/src/web/frontend/page/overview/index.tsx +60 -7
  37. package/src/web/frontend/page/refs/index.tsx +120 -41
  38. package/src/web/frontend/page/refs/style.css +13 -2
  39. package/src/web/frontend/page/repos/board-admin.tsx +3 -3
  40. package/src/web/frontend/page/repos/board-refs.tsx +3 -3
  41. package/src/web/frontend/page/repos/doc-search-modal.tsx +1 -3
  42. package/src/web/frontend/page/repos/index.tsx +19 -22
  43. package/src/web/frontend/page/repos/repo-table.tsx +1 -1
  44. package/src/web/frontend/page/settings/api.ts +11 -1
  45. package/src/web/frontend/page/settings/prompt-templates-section.tsx +6 -8
  46. package/src/web/frontend/refs/api.ts +65 -0
  47. package/src/web/frontend/refs/follow.ts +91 -0
  48. package/src/web/frontend/refs/index.ts +15 -0
  49. package/src/web/frontend/refs/ops.ts +58 -0
  50. package/src/web/frontend/refs/rows.ts +51 -0
  51. package/src/web/frontend/styles-v2/sidebar.css +6 -0
  52. package/src/web/frontend/workspace/layout.ts +38 -0
  53. package/src/web/frontend/workspace/open.ts +8 -1
  54. package/src/web/frontend/workspace/panels.ts +42 -1
  55. package/src/web/public/assets/{bar-Di7RK1fB.js → bar-BBGb6Y5_.js} +1 -1
  56. package/src/web/public/assets/{composer-launch-yGr4Ayzx.js → composer-launch-CjUpcCqD.js} +1 -1
  57. package/src/web/public/assets/{composer-panel-U2jaQLVQ.js → composer-panel-ECutPtRA.js} +1 -1
  58. package/src/web/public/assets/{dir-BY5ibEGY.js → dir-B8B1sEfY.js} +1 -1
  59. package/src/web/public/assets/doc-CmGraKDe.js +6 -0
  60. package/src/web/public/assets/{group-mIIARpRB.js → group-BA0tiEYP.js} +1 -1
  61. package/src/web/public/assets/{index-j44oS8Y3.css → index-59ZF4OlE.css} +1 -1
  62. package/src/web/public/assets/index-C2C8mDHD.js +2 -0
  63. package/src/web/public/assets/{md-history-wRTMWb12.js → md-history-8KUZ9ipc.js} +1 -1
  64. package/src/web/public/assets/overview-VC4HFUS_.js +1 -0
  65. package/src/web/public/assets/{progress-BRSLsiPg.js → progress-D0qBwZIV.js} +1 -1
  66. package/src/web/public/assets/refs-BhgP7Ryy.js +2 -0
  67. package/src/web/public/assets/refs-IQi1h4-q.css +1 -0
  68. package/src/web/public/assets/{repo-form-modal-dO99i73A.js → repo-form-modal-B_ruPwr0.js} +1 -1
  69. package/src/web/public/assets/repos-DP6AFrI6.js +14 -0
  70. package/src/web/public/assets/settings-C_8mDUqx.js +8 -0
  71. package/src/web/public/assets/{task-Cxa641GX.js → task-IoEm4Lmw.js} +1 -1
  72. package/src/web/public/assets/{task-utils-DSZKkq5e.js → task-utils-BqIPKFHQ.js} +1 -1
  73. package/src/web/public/assets/{templates-CExLUDs6.js → templates-B2zDwQG0.js} +1 -1
  74. package/src/web/public/assets/{use-rail-drag-D-17tqYm.js → use-rail-drag-2mF0AHna.js} +1 -1
  75. package/src/web/public/assets/workspace-BwpvQUst.js +28 -0
  76. package/src/web/public/index.html +7 -7
  77. package/assets/kv-get/SKILL.md +0 -105
  78. package/assets/kv-get/references/localget.md +0 -93
  79. package/assets/kv-get/references/timegoal-workflow.md +0 -158
  80. package/assets/kv-get/references/timegoal.md +0 -181
  81. package/assets/kv-get/references/wait-workflow.md +0 -216
  82. package/assets/kv-get/references/waitloop.md +0 -162
  83. package/assets/kv-repo/SKILL.md +0 -121
  84. package/assets/kv-repo/references/mmx-gitclone.md +0 -101
  85. package/assets/kv-submit/SKILL.md +0 -103
  86. package/assets/kv-submit/references/context-layering.md +0 -121
  87. package/assets/kv-submit/references/submit-workflow.md +0 -116
  88. package/assets/nx-kv/references/agent-workflow.md +0 -191
  89. package/assets/nx-kv/references/localtask-commands.md +0 -179
  90. package/assets/nx-kv/references/repo-registry.md +0 -194
  91. package/src/web/public/assets/doc-DHi__8Em.js +0 -6
  92. package/src/web/public/assets/index-DiOQ8kPZ.js +0 -2
  93. package/src/web/public/assets/overview-DPDbuE5d.js +0 -1
  94. package/src/web/public/assets/refs-C5idWnUj.css +0 -1
  95. package/src/web/public/assets/refs-CZdjVlxE.js +0 -2
  96. package/src/web/public/assets/repos-BaE9B1it.js +0 -14
  97. package/src/web/public/assets/settings-BX78BaLf.js +0 -8
  98. package/src/web/public/assets/workspace-fCTiC3R4.js +0 -28
  99. /package/src/web/frontend/{page → modules}/refs/api.ts +0 -0
@@ -55,6 +55,14 @@ export const BUILTIN_TEMPLATE_NAME = '系统内置';
55
55
  /**
56
56
  * 默认交付上下文模板(Handlebars 语法):
57
57
  * 项目介绍 / 补充文档 / 组上下文 / 成员 / 参考文件,全部由同一条 ctx 用 #if + #each 组织。
58
+ *
59
+ * #104:**缺失必须可见**。此前两种「没有上下文」的情形都是静默的——context 段渲染成
60
+ * 空串、整块消失,用户只看到「这条任务怎么没有 nx-kv.context」,无从判断是没登记、
61
+ * 还是登记了没写介绍。现在各补一句显式说明(含可执行的修复命令),agent 与用户都能
62
+ * 一眼看出原因:
63
+ * - 目录未登记为本机仓库 → 说明 + `repo add`(**不需要 .git,给 key 即可**);
64
+ * - 已登记但没有项目介绍主篇 → 说明 + `repo doc add`。
65
+ * 全局池(cwd 为空)不触发,避免噪音。
58
66
  */
59
67
  export const DEFAULT_CONTEXT_TEMPLATE = [
60
68
  '{{#if repo}}',
@@ -65,11 +73,19 @@ export const DEFAULT_CONTEXT_TEMPLATE = [
65
73
  '{{#if repo.docs}}',
66
74
  '〔项目文档〕按需取用:nx-kv docs get --ref <refId>',
67
75
  '{{#each repo.docs}}',
68
- ' - {{#if desc}}{{desc}}{{else}}{{#if title}}{{title}}{{else}}未命名文档{{/if}}{{/if}}{{#if hasBody}}{{else}}(无正文){{/if}}{{#if note}} # {{note}}{{/if}}',
76
+ ' - {{#if desc}}{{desc}}{{else}}{{#if title}}{{title}}{{else}}未命名文档{{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}',
69
77
  ' 取用:nx-kv docs get --ref {{refId}}',
70
78
  '{{/each}}',
71
79
  '{{/if}}',
80
+ // 已登记但没有任何材料:别让整块消失(#104)
81
+ '{{#if repo.intro}}{{else}}{{#if repo.docs}}{{else}}',
82
+ '〔项目上下文 · {{repo.name}}〕已登记为本机仓库({{repo.key}}),但没有项目介绍文档:nx-kv repo doc add {{repo.key}} --ref <refId>',
83
+ '{{/if}}{{/if}}',
72
84
  '{{/if}}',
85
+ // 目录根本没登记:说清原因 + 给登记命令(key 必填,不需要 .git)(#104)
86
+ '{{#if repo}}{{else}}{{#if cwd}}',
87
+ '〔项目上下文〕工作目录 {{cwd}} 未登记为本机仓库,本次交付没有项目介绍 / 组上下文。登记(不需要 .git,给 key 即可):nx-kv repo add "{{cwd}}" --key <key>',
88
+ '{{/if}}{{/if}}',
73
89
  '{{#if group}}',
74
90
  '〔项目组上下文 · {{group.name}}〕',
75
91
  '{{#if group.desc}}',
@@ -91,7 +107,7 @@ export const DEFAULT_CONTEXT_TEMPLATE = [
91
107
  '{{#if group.docs}}',
92
108
  '组文档(按需取用):',
93
109
  '{{#each group.docs}}',
94
- ' - {{#if desc}}{{desc}}{{else}}{{#if title}}{{title}}{{else}}未命名文档{{/if}}{{/if}}{{#if hasBody}}{{else}}(无正文){{/if}}{{#if note}} # {{note}}{{/if}}',
110
+ ' - {{#if desc}}{{desc}}{{else}}{{#if title}}{{title}}{{else}}未命名文档{{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}',
95
111
  ' 取用:nx-kv docs get --ref {{refId}}',
96
112
  '{{/each}}',
97
113
  '{{/if}}',
@@ -216,10 +232,16 @@ export const DEFAULT_ACK_PROMPT =
216
232
  * (区块默认模板已把内文写进去,不再是 {{getloop.text}} 这种间接层)。
217
233
  * 槽位口径:{{task.id}} = 任务编号;{{getloop.waitMinutes}} = 阻塞窗口分钟数。
218
234
  *
235
+ * #112(用户口径):这里的「阻塞 N 分钟」说的是 **nx-kv 的 get 命令自己会阻塞多久**
236
+ * (没任务时服务端挂住请求、到点返回 timeout),**不是**让 agent 去 sleep——agent 没有
237
+ * 感受时间的器官。所以窗口配 0(= get 不阻塞,没活立刻 timeout)时,这句话整段不该出现:
238
+ * 只留「完成之后再调一次 get」这层意思。用 `{{#if (gt getloop.waitMinutes 0)}}` 闸住即可,
239
+ * 不要给 0 造别的说法。
240
+ *
219
241
  * 放共享层是因为前后端都要用同一份:服务端渲染,前端「持续 get」弹窗展示说明。
220
242
  */
221
243
  export const DEFAULT_GETLOOP_INSTRUCTION =
222
- '{{#if task}}不要直接结束本轮:完成上面的任务({{task.id}})之后,继续调用 nx-kv localtask get 领取下一条任务。队列里有活会立即返回;没活时每次最多阻塞 {{getloop.waitMinutes}} 分钟,直到 get 返回 timeout 为止。{{/if}}';
244
+ '{{#if task}}不要直接结束本轮:完成上面的任务({{task.id}})之后,继续调用 nx-kv localtask get 领取下一条任务。队列里有活会立即返回;{{#if (gt getloop.waitMinutes 0)}}没活时每次最多阻塞 {{getloop.waitMinutes}} 分钟,直到 get 返回 timeout 为止。{{/if}}{{/if}}';
223
245
 
224
246
  /**
225
247
  * 默认「持续 get」段:项目开启时出现。
@@ -1047,12 +1047,27 @@
1047
1047
  "action": {
1048
1048
  "id": "docs.bindings",
1049
1049
  "module": "docs",
1050
- "summary": "查文档归属(--ref <refId> 看这篇被谁引用;--host <repo> / --group <组> 看宿主文档集;position=0 为主篇)",
1050
+ "summary": "查文档归属(--ref <refId> 看这篇被谁引用;--host <repo> 只看仓库自己的文档;--group <组> 看组域文档集:组 → 组内仓库 → 仓库自己;position=0 为主篇)",
1051
1051
  "usage": "docs bindings",
1052
1052
  "http": "GET /api/docs/bindings"
1053
1053
  },
1054
1054
  "children": []
1055
1055
  },
1056
+ {
1057
+ "name": "gc",
1058
+ "path": [
1059
+ "docs",
1060
+ "gc"
1061
+ ],
1062
+ "action": {
1063
+ "id": "docs.gc",
1064
+ "module": "docs",
1065
+ "summary": "GC 没有正文的文档(默认只报数;--apply 真删,并清掉宿主里指向它们的主篇/文档集引用)",
1066
+ "usage": "docs gc",
1067
+ "http": "POST /api/docs/gc"
1068
+ },
1069
+ "children": []
1070
+ },
1056
1071
  {
1057
1072
  "name": "index",
1058
1073
  "path": [
@@ -27,6 +27,7 @@ import type {
27
27
  DocRemoveAction,
28
28
  DocUpdateAction,
29
29
  DocsBindingsAction,
30
+ DocsGcAction,
30
31
  DocsIndexAction,
31
32
  DocsLinkAction,
32
33
  } from '../../../modules/docs/actions/_manifest.generated.js';
@@ -269,8 +270,10 @@ export interface ApiClient {
269
270
  unbind(input: z.input<InstanceType<typeof DocRefUnbindAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocRefUnbindAction>['run']>>>;
270
271
  /** 写文档正文 / 描述(面板保存走这里;ref 是 DB 实体,--ref 可给 refId;只给 --desc 时不动正文) */
271
272
  docUpdate(input: z.input<InstanceType<typeof DocUpdateAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocUpdateAction>['run']>>>;
272
- /** 查文档归属(--ref <refId> 看这篇被谁引用;--host <repo> / --group <组> 看宿主文档集;position=0 为主篇) */
273
+ /** 查文档归属(--ref <refId> 看这篇被谁引用;--host <repo> 只看仓库自己的文档;--group <组> 看组域文档集:组 → 组内仓库 → 仓库自己;position=0 为主篇) */
273
274
  bindings(input?: z.input<InstanceType<typeof DocsBindingsAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsBindingsAction>['run']>>>;
275
+ /** GC 没有正文的文档(默认只报数;--apply 真删,并清掉宿主里指向它们的主篇/文档集引用) */
276
+ gc(input?: z.input<InstanceType<typeof DocsGcAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsGcAction>['run']>>>;
274
277
  /** 双链索引(docId + 文件名;前端点击 [[..]] 前拉一次;解析规则见 core/wikilink.js) */
275
278
  index(): Promise<Awaited<ReturnType<InstanceType<typeof DocsIndexAction>['run']>>>;
276
279
  /** 维护组的附加文档列表(--ref <refId> | --path <外部路径> + --note/--tag;--remove <序号> 移除;--before <序号> 插位;同 ref 重复添加 = 更新) */
@@ -845,6 +848,13 @@ export function createApiClient(transport: Transport): ApiClient {
845
848
  if (query) path += path.includes('?') ? '&' + query : '?' + query;
846
849
  return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof DocsBindingsAction>['run']>>;
847
850
  },
851
+ // action: docs.gc
852
+ async gc(input?: z.input<InstanceType<typeof DocsGcAction>['_input']>) {
853
+ const inp = input ?? ({} as z.input<InstanceType<typeof DocsGcAction>['_input']>);
854
+ const path = `/api/docs/gc`;
855
+ const body = { "apply": inp["apply"] };
856
+ return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof DocsGcAction>['run']>>;
857
+ },
848
858
  // action: docs.index
849
859
  async index() {
850
860
  const path = `/api/docs/index`;
@@ -941,7 +951,7 @@ export function createApiClient(transport: Transport): ApiClient {
941
951
  async config(input?: z.input<InstanceType<typeof LocaltaskConfigAction>['_input']>) {
942
952
  const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskConfigAction>['_input']>);
943
953
  const path = `/api/localtasks/setting`;
944
- const body = { "timeout": inp["timeout"], "ack": inp["ack"], "ack-list": inp["ack-list"], "ackList": inp["ackList"], "delivery-template": inp["delivery-template"], "reset-delivery-template": inp["reset-delivery-template"], "attach-template": inp["attach-template"], "attachTemplate": inp["attachTemplate"], "reset-attach-template": inp["reset-attach-template"], "append-mode": inp["append-mode"], "block-templates": inp["block-templates"] };
954
+ const body = { "timeout": inp["timeout"], "ack": inp["ack"], "ack-list": inp["ack-list"], "ackList": inp["ackList"], "delivery-template": inp["delivery-template"], "reset-delivery-template": inp["reset-delivery-template"], "attach-template": inp["attach-template"], "attachTemplate": inp["attachTemplate"], "reset-attach-template": inp["reset-attach-template"], "append-mode": inp["append-mode"], "appendMode": inp["appendMode"], "block-templates": inp["block-templates"], "blockTemplates": inp["blockTemplates"] };
945
955
  return (await transport.request("PATCH", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskConfigAction>['run']>>;
946
956
  },
947
957
  // action: localtask.detach
@@ -33,9 +33,20 @@ export default function GetLoopModal({ repo, onClose, onSaved }: GetLoopModalPro
33
33
  const toast = useToast();
34
34
  const loop = repo.getLoop && typeof repo.getLoop === 'object' ? repo.getLoop : null;
35
35
  const [on, setOn] = useState(!!(loop && loop.enabled));
36
- const [minutes, setMinutes] = useState(String((loop && loop.waitMinutes) || DEFAULT_MINUTES));
36
+ // #112:0 是合法值(= 不设项目级窗口,沿用 get 的默认阻塞),不能被 `|| 默认值` 吞掉
37
+ const [minutes, setMinutes] = useState(
38
+ loop && loop.waitMinutes !== undefined && loop.waitMinutes !== null ? String(loop.waitMinutes) : String(DEFAULT_MINUTES)
39
+ );
37
40
  const [busy, setBusy] = useState(false);
38
41
 
42
+ /** 输入框 → 落库值:空/非法回落默认;0 原样保留(#112)。 */
43
+ const minutesOf = (raw: string): number => {
44
+ const s = String(raw ?? '').trim();
45
+ if (s === '') return DEFAULT_MINUTES;
46
+ const n = Number(s);
47
+ return Number.isFinite(n) && n >= 0 ? Math.min(Math.floor(n), 600) : DEFAULT_MINUTES;
48
+ };
49
+
39
50
  const save = async (override?: { enabled?: boolean }) => {
40
51
  setBusy(true);
41
52
  try {
@@ -46,9 +57,14 @@ export default function GetLoopModal({ repo, onClose, onSaved }: GetLoopModalPro
46
57
  // 于是「保存成功」但落库纹丝不动(#182 探针抓个正着)。
47
58
  await updateRepo(repo.id, {
48
59
  'get-loop': enabled ? 'on' : 'off',
49
- ...(enabled ? { 'get-loop-minutes': Number(minutes) || DEFAULT_MINUTES } : {}),
60
+ ...(enabled ? { 'get-loop-minutes': minutesOf(minutes) } : {}),
50
61
  });
51
- toast(enabled ? `已保存「${repo.name}」的持续 get 设置(${Number(minutes) || DEFAULT_MINUTES} 分钟)` : `已关闭「${repo.name}」的持续 get`);
62
+ const mm = minutesOf(minutes);
63
+ toast(
64
+ enabled
65
+ ? `已保存「${repo.name}」的持续 get 设置(${mm > 0 ? `${mm} 分钟阻塞窗口` : '不阻塞,没活立即返回'})`
66
+ : `已关闭「${repo.name}」的持续 get`
67
+ );
52
68
  if (app.refreshRepos) app.refreshRepos();
53
69
  if (onSaved) onSaved();
54
70
  } catch (e) {
@@ -86,12 +102,18 @@ export default function GetLoopModal({ repo, onClose, onSaved }: GetLoopModalPro
86
102
  <div className="rp-gl-row">
87
103
  <span>阻塞窗口</span>
88
104
  <span className="rp-gl-unit">
89
- <input className="rp-gl-min" value={minutes} onChange={(e) => setMinutes(e.target.value)} inputMode="numeric" />
105
+ <input
106
+ className="rp-gl-min"
107
+ value={minutes}
108
+ onChange={(e) => setMinutes(e.target.value)}
109
+ inputMode="numeric"
110
+ title="0 = 不阻塞:没任务时 get 立即返回 timeout"
111
+ />
90
112
  分钟
91
113
  </span>
92
114
  </div>
93
115
  <div className="rp-gl-note">
94
- {'领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。这里只决定这个仓库开不开、每轮最多等多久。'}
116
+ {'这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。'}
95
117
  </div>
96
118
  <div className="rp-gl-acts">
97
119
  <span className="spacer" />
@@ -71,7 +71,9 @@ export default function TaskChildren({ row, onNavigate, refreshLocal }: TaskChil
71
71
  onNavigate?.(`${base}?task=${encodeURIComponent(String(t.id))}`);
72
72
  }}
73
73
  >
74
- <span className="gico"><Icon name="list" size={12} /></span>
74
+ {/* #106:这里原本是统一的 list 图标——子行按类型只有 task 一种,图标没有
75
+ 信息量;换成任务编号(序列号)能一眼看出队列规模与位置。 */}
76
+ <span className="gico num" aria-hidden="true">#{t.id}</span>
75
77
  <span className="nm">{taskLabel(t)}</span>
76
78
  <span className={`cnt ${statusTone(t)}`}>
77
79
  {statusShort(t)}
@@ -121,6 +121,14 @@
121
121
  .docp-desc .k{flex:none;font-size:10px;color:var(--faint,#A9AEB4);letter-spacing:.04em}
122
122
  .docp-desc .v{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
123
123
  .docp-desc.empty .v{color:var(--faint,#A9AEB4)}
124
+ /* #107:描述行直接输入——看起来是文字,聚焦时才显出输入框(无边框、无弹窗) */
125
+ .docp-desc-input{
126
+ flex:1;min-width:0;border:0;background:transparent;padding:1px 4px;border-radius:5px;
127
+ font:inherit;font-size:11px;line-height:1.6;color:inherit;outline:none;
128
+ }
129
+ .docp-desc-input::placeholder{color:var(--faint,#A9AEB4)}
130
+ .docp-desc-input:hover{background:var(--soft,#F1F0EC)}
131
+ .docp-desc-input:focus{background:var(--paper,#fff);box-shadow:0 0 0 1px var(--mdw-accent,#2F6F5E) inset}
124
132
  .docp-desc-edit{
125
133
  flex:none;border:0;background:transparent;padding:1px 6px;border-radius:5px;
126
134
  font:inherit;font-size:10.5px;color:var(--mdw-accent,#2F6F5E);cursor:pointer;
@@ -64,26 +64,6 @@ export interface DocItemBody {
64
64
  body?: string;
65
65
  }
66
66
 
67
- /** 写文档正文 / 描述(PATCH /api/docs/item)。 */
68
- export function updateDocItem(body: { ref?: string; body?: string; desc?: string }): Promise<any> {
69
- return api('/api/docs/item', { method: 'PATCH', body });
70
- }
71
-
72
- /** 删除文档(DELETE /api/docs/item;ref 是 docId)。 */
73
- export function removeDocItem(body: { ref?: string }): Promise<any> {
74
- return api('/api/docs/item', { method: 'DELETE', body });
75
- }
76
-
77
- /** 新建直接 ref(POST /api/docs/ref;desc + 归属,不创建任何文件)。 */
78
- export function createRefDoc(body: {
79
- owner: 'repo' | 'group' | 'group_repo';
80
- repo?: string;
81
- group?: string;
82
- desc?: string;
83
- }): Promise<{ refId: string; docId: string; desc?: string }> {
84
- return api('/api/docs/ref', { method: 'POST', body });
85
- }
86
-
87
67
  /** 把文档登记进参考仓库的文档集(POST /api/repos/docs)。 */
88
68
  export function bindRepoDoc(body: { id: string; ref?: string; path?: string; note?: string; tag?: string }): Promise<any> {
89
69
  return api('/api/repos/docs', { method: 'POST', body });
@@ -6,16 +6,15 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
6
6
  import { Actions } from 'flexlayout-react';
7
7
  import type { Model } from 'flexlayout-react';
8
8
  import {
9
- createRefDoc,
10
9
  docAttachments,
11
- docHostBindings,
12
10
  listBoards,
13
11
  loadDocsIndex,
14
- removeDocItem,
15
12
  getDocItem,
16
- updateDocItem,
17
13
  type DocItem,
18
14
  } from './api.js';
15
+ // #120:文档条目的读写统一走 refs 模块(列表 CRUD 的唯一入口)
16
+ import { docsBindings, removeDocItem, updateDocItem } from '../../refs/api.js';
17
+ import { createDoc, saveDesc as saveDocDesc } from '../../refs/ops.js';
19
18
  import { useToast } from '../../components/toast/index.jsx';
20
19
  import { useDialog } from '../../components/popup/index.jsx';
21
20
  import { useApp } from '../../app-context.jsx';
@@ -90,6 +89,9 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
90
89
  const [error, setError] = useState('');
91
90
  const [dirty, setDirty] = useState(false);
92
91
  const [mode, setMode] = useState('split');
92
+ // #107:描述行直接可编辑(不再点「改」弹窗)——草稿 + 保存态
93
+ const [descDraft, setDescDraft] = useState('');
94
+ const [descBusy, setDescBusy] = useState(false);
93
95
  // 底部信息面板(附件 / 归属):与任务页同一套 dock 状态,存储空间另用 'doc';
94
96
  // 文档页首次进入默认收起(编辑正文为主),入口常驻在底部状态栏
95
97
  const dock = useDock('doc', false);
@@ -100,6 +102,12 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
100
102
  const docRef = useRef<DocItem | null>(null);
101
103
  useEffect(() => { docRef.current = doc; }, [doc]);
102
104
 
105
+ // #107:描述草稿跟随文档(换文档、保存回来都会重置)。用 desc 而不是 refId 作依赖,
106
+ // 保存成功后服务端回填的 desc 立即反映到输入框,不会和用户正在敲的内容打架。
107
+ useEffect(() => {
108
+ setDescDraft(doc?.desc || '');
109
+ }, [doc?.refId, doc?.desc]);
110
+
103
111
  const load = useCallback(async () => {
104
112
  setError('');
105
113
  try {
@@ -139,7 +147,7 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
139
147
  return out;
140
148
  };
141
149
  if (ownerKind === 'repo') {
142
- docHostBindings({ host: ownerKey })
150
+ docsBindings({ host: ownerKey })
143
151
  .then((d) => setIntroLinks(toLinks(d.bindings || [])))
144
152
  .catch(() => setIntroLinks(current));
145
153
  return;
@@ -149,7 +157,7 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
149
157
  .then(async (d) => {
150
158
  const boards = (d && d.boards) || (Array.isArray(d) ? d : []);
151
159
  const b = boards.find((x: { id?: string; key?: string }) => x.id === ownerKey || x.key === ownerKey);
152
- const res = await docHostBindings({ group: String(b?.key || ownerKey) });
160
+ const res = await docsBindings({ group: String(b?.key || ownerKey) });
153
161
  setIntroLinks(toLinks(res.bindings || []));
154
162
  })
155
163
  .catch(() => setIntroLinks(current));
@@ -243,17 +251,15 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
243
251
  if (name === null) return;
244
252
  const desc = String(name).trim();
245
253
  if (!desc) return;
246
- const res = await createRefDoc(
254
+ // 建文档 + 起标题骨架 + 广播刷新,都在 refs.ops 里(列表 CRUD 唯一入口)
255
+ const refId = await createDoc(
247
256
  ownerKind === 'repo'
248
- ? { owner: 'repo', repo: ownerKey, desc }
249
- : { owner: 'group', group: ownerKey, desc }
257
+ ? { owner: 'repo', repo: ownerKey, desc, title: desc }
258
+ : { owner: 'group', group: ownerKey, desc, title: desc }
250
259
  );
251
- // 空正文直接可编辑;给一个标题骨架,打开后就是「待补」状态。
252
- await updateDocItem({ ref: 'ref:' + res.refId, body: `# ${desc}\n\n(待补)\n` });
253
260
  toast(`已补充:${desc}`);
254
- notifyDocsChanged();
255
261
  loadIntroLinks();
256
- openByDocId('ref:' + res.refId, null, openExtra);
262
+ openByDocId('ref:' + refId, null, openExtra);
257
263
  });
258
264
  };
259
265
 
@@ -343,6 +349,8 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
343
349
  };
344
350
 
345
351
  // ─── 改描述:ref 是 DB 实体,没有路径可改;desc 是列表 / 提示词模板的快速定位标签 ───
352
+ // #107 起主入口是标题下面那一行**直接输入**(见 renderDescRow),菜单里的「改描述」
353
+ // 保留给习惯弹窗的人;两条路走同一个 PATCH。
346
354
  const renameDoc = () => {
347
355
  if (!doc) return;
348
356
  guard(async () => {
@@ -361,6 +369,25 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
361
369
  });
362
370
  };
363
371
 
372
+ /** #107:行内描述保存(失焦 / 回车触发;Esc 放弃)。空串合法 = 清掉描述。 */
373
+ const saveDesc = async () => {
374
+ if (!doc || !writable || descBusy || !docId) return;
375
+ const next = descDraft.trim();
376
+ if (next === String(doc.desc || '').trim()) return;
377
+ setDescBusy(true);
378
+ try {
379
+ // #120:写入 + 广播统一走 refs 模块,不在页面里另拼一次
380
+ const saved = await saveDocDesc(docId, next);
381
+ setDoc((d) => (d ? { ...d, desc: saved } : d));
382
+ toast('描述已更新');
383
+ } catch (e) {
384
+ toast(String((e as Error).message || e));
385
+ setDescDraft(doc.desc || '');
386
+ } finally {
387
+ setDescBusy(false);
388
+ }
389
+ };
390
+
364
391
  // ─── 删除:danger 确认 → DELETE 落盘 → 主布局就地回归属页(不拆面板,#191 同规)───
365
392
  const delDoc = () => {
366
393
  if (!doc) return;
@@ -489,12 +516,32 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
489
516
  ]) as unknown as never[]}
490
517
  onSave={save as unknown as null}
491
518
  />
492
- {/* desc 是「快速定位」的一句话:标题下面是它自己的位置,可看可改 */}
519
+ {/* desc 是「快速定位」的一句话:标题下面直接可编辑(#107:不再点「改」),
520
+ 失焦 / 回车保存,Esc 放弃;只读文档照旧显示成文字。 */}
493
521
  <div className={'docp-desc' + (doc.desc ? '' : ' empty')}>
494
522
  <span className="k">描述</span>
495
- <span className="v">{doc.desc || '未填写——写一句这篇讲什么,列表与提示词里用它快速定位'}</span>
496
- {writable && (
497
- <button type="button" className="docp-desc-edit" onClick={renameDoc}>改</button>
523
+ {writable ? (
524
+ <input
525
+ className="docp-desc-input"
526
+ value={descDraft}
527
+ disabled={descBusy}
528
+ spellCheck={false}
529
+ placeholder="未填写——写一句这篇讲什么,列表与提示词里用它快速定位"
530
+ aria-label="文档描述(失焦或回车保存)"
531
+ onChange={(e) => setDescDraft(e.target.value)}
532
+ onBlur={() => { void saveDesc(); }}
533
+ onKeyDown={(e) => {
534
+ if (e.key === 'Enter') {
535
+ e.preventDefault();
536
+ e.currentTarget.blur();
537
+ } else if (e.key === 'Escape') {
538
+ setDescDraft(doc.desc || '');
539
+ e.currentTarget.blur();
540
+ }
541
+ }}
542
+ />
543
+ ) : (
544
+ <span className="v">{doc.desc || '未填写——写一句这篇讲什么,列表与提示词里用它快速定位'}</span>
498
545
  )}
499
546
  </div>
500
547
  <MdPanes
@@ -14,3 +14,16 @@ export interface RemoveManyResult {
14
14
  export function removeTasks(input: { key: string; ids: number[] }): Promise<any> {
15
15
  return api('/api/localtasks/items', { method: 'DELETE', body: input });
16
16
  }
17
+
18
+ /** 批量收口返回:count=收口数;claimedClosed=其中原本已领取的;skipped=终态跳过明细。 */
19
+ export interface CloseManyResult {
20
+ count?: number;
21
+ claimedClosed?: number[];
22
+ skipped?: Array<{ id: number; status?: string; reason?: string }>;
23
+ missing?: number[];
24
+ }
25
+
26
+ /** 批量收口任务(POST /api/localtasks/items/close;status=done|cancelled)。 */
27
+ export function closeTasks(input: { key: string; ids: number[]; status: string; summary?: string }): Promise<CloseManyResult> {
28
+ return api('/api/localtasks/items/close', { method: 'POST', body: input });
29
+ }
@@ -14,12 +14,13 @@
14
14
  // 1. **每行任务带状态 tag**(待领取 / 已领取,口径与 splitQueueTasks 一致;
15
15
  // #121 起渲染走统一组件 components/status-tag——蓝=进行中、绿=已完成、浅灰=待领取);
16
16
  // 行可点:直接进该任务的工作台详情(#/dir/<key>?task=<id>)。
17
- // 2. **批量删除的落点在底部操作条**:勾选任意行后出现(position:sticky),
18
- // 跨目录一次删完(按目录分组逐个调 DELETE /api/localtasks/items);
19
- // 仍是软删除(CLI localtask task restore 可恢复)。
17
+ // 2. **批量操作的落点在底部操作条**:勾选任意行后出现(position:sticky),
18
+ // 跨目录一次处理完(按目录分组逐个调批量接口):标为完成(#103,POST
19
+ // /api/localtasks/items/close,与目录页「标为完成选中」同口径)+ 批量删除
20
+ //(DELETE /api/localtasks/items);删除仍是软删除(CLI localtask task restore 可恢复)。
20
21
  import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
21
22
  import { useMemo, useState } from 'react';
22
- import { removeTasks } from './api.js';
23
+ import { closeTasks, removeTasks } from './api.js';
23
24
  import { useToast } from '../../components/toast/index.jsx';
24
25
  import { useDialog } from '../../components/popup/index.jsx';
25
26
  import StatusTag from '../../components/status-tag/index.jsx';
@@ -130,8 +131,8 @@ export default function Overview({ rows, onNavigate, refreshLocal }: OverviewPro
130
131
  };
131
132
  const allOn = shown.length > 0 && picked.length === shown.length;
132
133
 
133
- /** 底部操作条的删除:把选中项按目录分组,逐组调批量删除接口。 */
134
- const dropAll = async () => {
134
+ /** 选中项按目录分组(批量删除 / 批量收口共用:接口都按单主题寻址)。 */
135
+ const pickGroups = () => {
135
136
  const pickedSet = new Set(picked);
136
137
  const groups: { key: string; name: string; ids: number[] }[] = [];
137
138
  for (const f of flat) {
@@ -143,6 +144,12 @@ export default function Overview({ rows, onNavigate, refreshLocal }: OverviewPro
143
144
  }
144
145
  g.ids.push(Number(f.t.id));
145
146
  }
147
+ return groups;
148
+ };
149
+
150
+ /** 底部操作条的删除:把选中项按目录分组,逐组调批量删除接口。 */
151
+ const dropAll = async () => {
152
+ const groups = pickGroups();
146
153
  const total = groups.reduce((n, g) => n + g.ids.length, 0);
147
154
  if (!total) return;
148
155
  const scope = groups.length > 1 ? `(跨 ${groups.length} 个目录)` : '';
@@ -180,6 +187,49 @@ export default function Overview({ rows, onNavigate, refreshLocal }: OverviewPro
180
187
  refreshLocal?.();
181
188
  };
182
189
 
190
+ /** 底部操作条的批量收口(#103 总览补齐,与目录页「标为完成选中」同口径):
191
+ 待领取与已领取(正在跑)都收,已完成/已取消/已删除跳过,agent 回执被忽略。 */
192
+ const finishAll = async () => {
193
+ const groups = pickGroups();
194
+ const total = groups.reduce((n, g) => n + g.ids.length, 0);
195
+ if (!total) return;
196
+ const scope = groups.length > 1 ? `(跨 ${groups.length} 个目录)` : '';
197
+ const ok = await dialog({
198
+ title: `把 ${total} 条任务标为完成${scope}`,
199
+ message: '待领取与已领取(正在跑)都能收:已领取的直接收口,agent 侧回执会被忽略。已完成/已取消会跳过。完成会补一条完成记录,原文留档。',
200
+ okText: '标为完成',
201
+ });
202
+ if (!ok) return;
203
+ let n = 0;
204
+ let claimed = 0;
205
+ let skip = 0;
206
+ const errs = [];
207
+ for (const g of groups) {
208
+ try {
209
+ const r = await closeTasks({ key: g.key, ids: g.ids, status: 'done' });
210
+ n += Number(r?.count ?? 0);
211
+ claimed += (r?.claimedClosed || []).length;
212
+ skip += (r?.skipped || []).length;
213
+ } catch (e) {
214
+ const msg = String((e as Error).message || e);
215
+ if (/接口不存在/.test(msg)) {
216
+ toast('本机面板服务较旧,重启面板后再试(批量收口接口未上线)');
217
+ return;
218
+ }
219
+ errs.push(`${g.name}: ${msg}`);
220
+ }
221
+ }
222
+ if (errs.length) {
223
+ toast(`已标为完成 ${n} 条;${errs.length} 个目录失败:${errs[0]}${errs.length > 1 ? ` 等 ${errs.length} 项` : ''}`);
224
+ } else {
225
+ toast(
226
+ `已标为完成 ${n} 条${claimed ? `(含 ${claimed} 条已领取)` : ''}${skip ? `,跳过 ${skip} 条` : ''}`,
227
+ );
228
+ }
229
+ setSel(new Set());
230
+ refreshLocal?.();
231
+ };
232
+
183
233
  /** 行点击:组任务走组锚定路由(#86:#/group/<boardMark>?task=N),其余进目录工作台。 */
184
234
  const openTask = (f: FlatRow, id: number | string) => {
185
235
  const url = f.t.boardMark
@@ -260,7 +310,7 @@ export default function Overview({ rows, onNavigate, refreshLocal }: OverviewPro
260
310
  )}
261
311
 
262
312
  {selCount > 0 && (
263
- <div className="ov-bar" role="toolbar" aria-label="批量删除操作条">
313
+ <div className="ov-bar" role="toolbar" aria-label="批量操作条">
264
314
  <span className="ov-bar-n">
265
315
  已选 <b>{selCount}</b> 条任务
266
316
  </span>
@@ -268,6 +318,9 @@ export default function Overview({ rows, onNavigate, refreshLocal }: OverviewPro
268
318
  <button type="button" className="mini" onClick={() => setSel(new Set())}>
269
319
  取消选择
270
320
  </button>
321
+ <button type="button" className="btn small" onClick={finishAll}>
322
+ 标为完成 {selCount}
323
+ </button>
271
324
  <button type="button" className="btn small danger" onClick={dropAll}>
272
325
  删除选中 {selCount}
273
326
  </button>