nx-kv 0.66.2 → 0.67.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 (153) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/assets/nx-kv/references/A02-/346/217/220/344/272/244/344/273/273/345/212/241.md +6 -7
  3. package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +1 -1
  4. package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +2 -2
  5. package/package.json +1 -1
  6. package/src/core/attachmentdb/ids.ts +14 -1
  7. package/src/core/attachmentdb/query.ts +0 -38
  8. package/src/core/attachmentdb/repo.ts +98 -0
  9. package/src/core/attachmentdb.ts +5 -1
  10. package/src/core/db/import-json/tasks.ts +10 -9
  11. package/src/core/db/import-json.ts +16 -6
  12. package/src/core/db/index.ts +1 -1
  13. package/src/core/db/migrations/index.ts +2 -0
  14. package/src/core/db/migrations/v15.sql +88 -0
  15. package/src/core/db/verify.ts +7 -3
  16. package/src/core/db/version.ts +4 -1
  17. package/src/core/topic-key.ts +5 -8
  18. package/src/core/workflow/readiness.ts +1 -1
  19. package/src/core/workflow/types.ts +1 -1
  20. package/src/modules/claim/assemble.ts +0 -5
  21. package/src/modules/claim/host.ts +2 -4
  22. package/src/modules/claim/preview.ts +0 -1
  23. package/src/modules/claim/wait.ts +9 -49
  24. package/src/modules/docs/actions/docs-detach.ts +1 -2
  25. package/src/modules/docs/attach.ts +3 -17
  26. package/src/modules/docs/render.ts +4 -13
  27. package/src/modules/localtask/actions/localtask-add.ts +1 -3
  28. package/src/modules/localtask/actions/localtask-attach.ts +4 -2
  29. package/src/modules/localtask/actions/localtask-boardtasks.ts +0 -1
  30. package/src/modules/localtask/actions/localtask-clone.ts +1 -1
  31. package/src/modules/localtask/actions/localtask-config.ts +2 -11
  32. package/src/modules/localtask/actions/localtask-detach.ts +1 -3
  33. package/src/modules/localtask/infra/events.ts +5 -5
  34. package/src/modules/localtask/infra/repo/rows.ts +0 -1
  35. package/src/modules/localtask/infra/repo/settings.ts +1 -9
  36. package/src/modules/localtask/infra/repo/topics.ts +0 -4
  37. package/src/modules/localtask/lifecycle/add.ts +2 -9
  38. package/src/modules/localtask/lifecycle/deletion.ts +7 -15
  39. package/src/modules/localtask/lifecycle/task-lifecycle.ts +2 -2
  40. package/src/modules/localtask/lifecycle/task-ops.ts +14 -56
  41. package/src/modules/localtask/lifecycle/task-templates.ts +0 -13
  42. package/src/modules/localtask/lifecycle/task-view.ts +2 -3
  43. package/src/modules/localtask/lifecycle/topics.ts +3 -8
  44. package/src/modules/localtask/ops/attach-resource.ts +46 -4
  45. package/src/modules/localtask/ops/attach-template.ts +73 -3
  46. package/src/modules/localtask/ops/attach.ts +45 -18
  47. package/src/modules/localtask/paths.ts +7 -17
  48. package/src/modules/localtask/service.ts +3 -7
  49. package/src/modules/localtask/ui/action-flags.ts +2 -2
  50. package/src/modules/localtask/ui/action-render.ts +7 -19
  51. package/src/modules/localtask/waiting.ts +1 -8
  52. package/src/modules/promptplug/compose.ts +1 -3
  53. package/src/modules/promptplug/plugins/attachment.ts +56 -6
  54. package/src/modules/promptplug/plugins/context.ts +11 -2
  55. package/src/modules/promptplug/template-store.ts +25 -3
  56. package/src/modules/templates/scope.ts +1 -1
  57. package/src/shared/prompt-blocks.ts +2 -23
  58. package/src/web/frontend/App.tsx +4 -9
  59. package/src/web/frontend/api/cli-tree.json +6 -6
  60. package/src/web/frontend/api/client.generated.ts +11 -11
  61. package/src/web/frontend/api/tasks.ts +117 -0
  62. package/src/web/frontend/components/Introduction/index.tsx +50 -3
  63. package/src/web/frontend/components/Introduction/style.css +6 -0
  64. package/src/web/frontend/components/Introduction/use-intro.ts +25 -0
  65. package/src/web/frontend/components/md/attachments/attach-area.tsx +9 -11
  66. package/src/web/frontend/components/md/attachments/attach-common.ts +12 -5
  67. package/src/web/frontend/components/md/attachments/attach-modal.tsx +54 -9
  68. package/src/web/frontend/components/md/attachments/attach-repo-pick.tsx +48 -0
  69. package/src/web/frontend/components/sidebar/index.tsx +52 -48
  70. package/src/web/frontend/components/sidebar/model.ts +16 -32
  71. package/src/web/frontend/components/sidebar/queue-nav.ts +3 -4
  72. package/src/web/frontend/components/sidebar/row-menu.tsx +1 -1
  73. package/src/web/frontend/components/sidebar/task-children.tsx +53 -32
  74. package/src/web/frontend/{page/dir → components/task-panel}/dag-editor.tsx +1 -1
  75. package/src/web/frontend/components/task-panel/task-ops.ts +299 -0
  76. package/src/web/frontend/components/task-panel/task-page.tsx +495 -0
  77. package/src/web/frontend/components/tool-acts/modules.ts +3 -0
  78. package/src/web/frontend/modules/board/board-view.ts +2 -56
  79. package/src/web/frontend/modules/md/doc-store.ts +2 -3
  80. package/src/web/frontend/page/dag/head-bar.tsx +0 -1
  81. package/src/web/frontend/page/dag/index.tsx +1 -4
  82. package/src/web/frontend/page/dag/model.ts +0 -1
  83. package/src/web/frontend/page/dir/api.ts +4 -108
  84. package/src/web/frontend/page/dir/index.tsx +161 -348
  85. package/src/web/frontend/page/dir/task-actions.ts +20 -32
  86. package/src/web/frontend/page/dir/task-board-section.tsx +3 -0
  87. package/src/web/frontend/page/dir/task-chain.ts +6 -10
  88. package/src/web/frontend/page/dir/task-dock-panel.tsx +3 -6
  89. package/src/web/frontend/page/dir/task-feedback.ts +9 -17
  90. package/src/web/frontend/page/dir/task-not-found.tsx +2 -3
  91. package/src/web/frontend/page/dir/task-utils.ts +0 -1
  92. package/src/web/frontend/page/dir/task.tsx +14 -18
  93. package/src/web/frontend/page/doc/doc-dock.tsx +1 -1
  94. package/src/web/frontend/page/group/api.ts +3 -21
  95. package/src/web/frontend/page/group/group-project-memo.ts +41 -0
  96. package/src/web/frontend/page/group/index.tsx +289 -429
  97. package/src/web/frontend/page/progress/index.tsx +7 -12
  98. package/src/web/frontend/page/settings/api.ts +1 -2
  99. package/src/web/frontend/page/settings/prompt-templates-section.tsx +12 -44
  100. package/src/web/frontend/panels.tsx +1 -1
  101. package/src/web/frontend/registry.ts +1 -2
  102. package/src/web/frontend/route-map.ts +0 -1
  103. package/src/web/frontend/routes/dir.ts +1 -4
  104. package/src/web/frontend/routes/keys.ts +5 -3
  105. package/src/web/frontend/svghub/catalog-nav.ts +8 -11
  106. package/src/web/public/assets/app-context-CngKv8Tc.js +1 -0
  107. package/src/web/public/assets/{bar-Dy_QDX2h.js → bar-C0Q_Qe4z.js} +1 -1
  108. package/src/web/public/assets/board-view-C8OQhkyi.js +1 -0
  109. package/src/web/public/assets/{button-3JlUeln_.js → button-Cs6w2CDi.js} +1 -1
  110. package/src/web/public/assets/{composer-launch-B7DH53Yf.js → composer-launch-BF3_hyn5.js} +1 -1
  111. package/src/web/public/assets/{composer-panel-Cj1J16r-.js → composer-panel-D6vBrzCs.js} +1 -1
  112. package/src/web/public/assets/{dag-DXRPHVl8.js → dag-CZF6sV2_.js} +1 -1
  113. package/src/web/public/assets/dir-6RhnWw1E.js +1 -0
  114. package/src/web/public/assets/doc-CVIVBV6n.js +6 -0
  115. package/src/web/public/assets/doc-DgYKv2wo.css +1 -0
  116. package/src/web/public/assets/group-AF62Z-_G.js +1 -0
  117. package/src/web/public/assets/group-project-memo-G-O6sPRw.js +1 -0
  118. package/src/web/public/assets/index-Bposj22Z.js +3 -0
  119. package/src/web/public/assets/{list-filter-CWxiOSg_.js → list-search-DFvFY408.js} +1 -1
  120. package/src/web/public/assets/md-history-COQu16vy.js +47 -0
  121. package/src/web/public/assets/{member-picker-BZgE3HGb.js → member-picker-CHX0nS0O.js} +1 -1
  122. package/src/web/public/assets/popup-dBtYqEM1.js +1 -0
  123. package/src/web/public/assets/progress-CDh6DY7g.js +3 -0
  124. package/src/web/public/assets/refs-t79ynSY8.js +2 -0
  125. package/src/web/public/assets/reopen-text-B2d9SZi0.js +13 -0
  126. package/src/web/public/assets/{repo-form-modal-CNLYR12c.js → repo-form-modal-dZqpHyUj.js} +1 -1
  127. package/src/web/public/assets/{repos-BGx-yAXd.js → repos-DdhOQJqF.js} +9 -9
  128. package/src/web/public/assets/{route-crumb-DX9C4jmQ.js → route-crumb-BKq2jry0.js} +1 -1
  129. package/src/web/public/assets/settings-Bk3clN2f.js +1 -0
  130. package/src/web/public/assets/task-C8nax2rT.js +13 -0
  131. package/src/web/public/assets/task-ops-D6E_TgEC.js +2 -0
  132. package/src/web/public/assets/task-utils-Dh33OFKe.js +1 -0
  133. package/src/web/public/assets/{templates-Co1Qb1aA.js → templates-Dusbff7Z.js} +3 -3
  134. package/src/web/public/assets/{tool-bar-D5wLBLRl.js → tool-bar-DPXnjdQF.js} +2 -2
  135. package/src/web/public/assets/use-rail-drag-B6J0iqFK.js +1 -0
  136. package/src/web/public/index.html +13 -13
  137. package/src/web/frontend/page/dir/landing.tsx +0 -553
  138. package/src/web/public/assets/app-context-BqCBcDsx.js +0 -1
  139. package/src/web/public/assets/board-view-Cm8189wG.js +0 -1
  140. package/src/web/public/assets/dir-_M1ciSxM.js +0 -3
  141. package/src/web/public/assets/doc-Iuxssa-b.css +0 -1
  142. package/src/web/public/assets/doc-_iteSM2X.js +0 -6
  143. package/src/web/public/assets/get-loop-modal-DlAfqJMz.js +0 -2
  144. package/src/web/public/assets/group-CH8qe-eg.js +0 -1
  145. package/src/web/public/assets/index-Cui4IuGj.js +0 -3
  146. package/src/web/public/assets/md-history-Bj790fdn.js +0 -46
  147. package/src/web/public/assets/popup-DZ2Khv2c.js +0 -1
  148. package/src/web/public/assets/progress-MPse2JLQ.js +0 -3
  149. package/src/web/public/assets/refs-DiIPoqnJ.js +0 -2
  150. package/src/web/public/assets/settings-Pt4YgGdY.js +0 -1
  151. package/src/web/public/assets/task-DOIIpQ4X.js +0 -13
  152. package/src/web/public/assets/task-utils-CJfMODCP.js +0 -13
  153. package/src/web/public/assets/use-rail-drag-CNOHXWng.js +0 -1
@@ -256,7 +256,7 @@ export interface ApiClient {
256
256
  attachments(input: z.input<InstanceType<typeof DocsAttachmentsAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsAttachmentsAction>['run']>>>;
257
257
  /** 查文档归属(--ref <refId> 看这篇被谁引用;--host <repo> 只看仓库自己的文档;--group <组> 看组域文档集:组 → 组内仓库 → 成员仓库自己 → 组内参考仓库自己;hostKind 标宿主是开发仓库/参考仓库/组;position=0 为主篇) */
258
258
  bindings(input?: z.input<InstanceType<typeof DocsBindingsAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsBindingsAction>['run']>>>;
259
- /** 解除文档与附件的关系(默认只解除关系);--purge 无人引用时连资源行与本机字节一起删 */
259
+ /** 解除文档与附件的关系(#189:只解除关联;清理走库级 GC,不在这里删资源) */
260
260
  detach(input: z.input<InstanceType<typeof DocsDetachAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsDetachAction>['run']>>>;
261
261
  /** GC 没有正文的文档(默认只报数;--apply 真删,并清掉宿主里指向它们的主篇/文档集引用) */
262
262
  gc(input?: z.input<InstanceType<typeof DocsGcAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsGcAction>['run']>>>;
@@ -296,11 +296,11 @@ export interface ApiClient {
296
296
  docRemove(input: z.input<InstanceType<typeof RepoDocRemoveAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDocRemoveAction>['run']>>>;
297
297
  /** 取仓库完整知识:项目介绍 + 所属组(介绍/组内描述/绑定文档)+ 参考仓库(--md 拼成单篇 markdown;缺省当前目录) */
298
298
  knowledge(input?: z.input<InstanceType<typeof RepoKnowledgeAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoKnowledgeAction>['run']>>>;
299
- /** 向某主题(工作目录)的队列回填一条任务(正文可多行;--file <文件|-> 从文件/标准输入读,长文本不必靠引号硬拼;有 wait 在等则即时投递,否则排队);--global 推到全局共享池;--duration 给任务带时间目标(领取即计时,完成前必须 check);--board/--project 让任务带工作组语义(正文 frontmatter:board + project + 双方介绍引用),并落进该项目的队列;正文自带 frontmatter 时同样认归属——补介绍引用,落点跟到项目队列(显式给过 --cwd 时不挪窝) */
299
+ /** 向某主题(工作目录)的队列回填一条任务(正文可多行;--file <文件|-> 从文件/标准输入读,长文本不必靠引号硬拼;有 wait 在等则即时投递,否则排队);--duration 给任务带时间目标(领取即计时,完成前必须 check);--board/--project 让任务带工作组语义(正文 frontmatter:board + project + 双方介绍引用),并落进该项目的队列;正文自带 frontmatter 时同样认归属——补介绍引用,落点跟到项目队列(显式给过 --cwd 时不挪窝) */
300
300
  localtaskAdd(input?: z.input<InstanceType<typeof LocaltaskAddAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAddAction>['run']>>>;
301
301
  /** 改一条附件绑定的说明(desc):--attachment <资源 id> --note <说明>(只动说明,角色/位置不变) */
302
302
  attachNote(input: z.input<InstanceType<typeof LocaltaskAttachNoteAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAttachNoteAction>['run']>>>;
303
- /** 给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针)/ --folder(本地文件夹路径);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文) */
303
+ /** 给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针)/ --folder(本地文件夹路径)/ --repo(已登记仓库);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文) */
304
304
  localtaskAttach(input: z.input<InstanceType<typeof LocaltaskAttachAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAttachAction>['run']>>>;
305
305
  /** 列出某条任务引用的附件(正文里的 ![名](fileId) 嵌入),以及本地是否已有(给 agent 直接读本地文件) */
306
306
  localtaskAttachments(input: z.input<InstanceType<typeof LocaltaskAttachmentsAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAttachmentsAction>['run']>>>;
@@ -312,13 +312,13 @@ export interface ApiClient {
312
312
  cancel(input?: z.input<InstanceType<typeof LocaltaskCancelAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskCancelAction>['run']>>>;
313
313
  /** 查一条任务的链:history 节点(origin/reopen/comment/current)+ 旧 forkOf 祖先/子任务;面板点节点可旁路查看正文 */
314
314
  chain(input: z.input<InstanceType<typeof LocaltaskChainAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskChainAction>['run']>>>;
315
- /** 克隆任务:复制正文内容为一条新任务(同主题;全局任务仍进全局池)。不带派生链、不继承时间目标与依赖——开新活用 */
315
+ /** 克隆任务:复制正文内容为一条新任务(同主题)。不带派生链、不继承时间目标与依赖——开新活用 */
316
316
  localtaskClone(input: z.input<InstanceType<typeof LocaltaskCloneAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskCloneAction>['run']>>>;
317
317
  /** 批量收口还没结束的任务(按 --ids,定位到 --cwd 主题或 --key):不要求先领取;--status done 写完成总结,cancelled 只改状态;待领取与已领取都能收(已领取的 agent 侧回执会被忽略),已完成/已取消跳过 */
318
318
  closeMany(input: z.input<InstanceType<typeof LocaltaskCloseManyAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskCloseManyAction>['run']>>>;
319
- /** 配置等待超时(秒)/ 系统上下文追加模式(提示词模板正文固定在插件类里,不再可配) */
319
+ /** 配置等待超时(秒)(系统上下文固定 XML 区块;提示词模板正文固定在插件类里,不再可配) */
320
320
  config(input?: z.input<InstanceType<typeof LocaltaskConfigAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskConfigAction>['run']>>>;
321
- /** 解除任务与附件的关系(默认只解除关系,资源进孤儿池);--purge 在无人引用时连资源行与本机字节一起删 */
321
+ /** 解除任务与附件的关系(#189:只解除关联,资源进孤儿池;清理走库级 GC,不在这里删资源) */
322
322
  localtaskDetach(input: z.input<InstanceType<typeof LocaltaskDetachAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskDetachAction>['run']>>>;
323
323
  /** 标记任务完成:--summary 完成总结必填;带时间目标的任务未到点会被拒绝(blocked),到点自动记录最终 check */
324
324
  done(input: z.input<InstanceType<typeof LocaltaskDoneAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskDoneAction>['run']>>>;
@@ -763,7 +763,7 @@ export function createApiClient(transport: Transport): ApiClient {
763
763
  async detach(input: z.input<InstanceType<typeof DocsDetachAction>['_input']>) {
764
764
  const inp = input ?? ({} as z.input<InstanceType<typeof DocsDetachAction>['_input']>);
765
765
  const path = `/api/docs/attach`;
766
- const body = { "ref": inp["ref"], "attachment": inp["attachment"], "purge": inp["purge"] };
766
+ const body = { "ref": inp["ref"], "attachment": inp["attachment"] };
767
767
  return (await transport.request("DELETE", path, body)) as Awaited<ReturnType<InstanceType<typeof DocsDetachAction>['run']>>;
768
768
  },
769
769
  // action: docs.gc
@@ -923,7 +923,7 @@ export function createApiClient(transport: Transport): ApiClient {
923
923
  async localtaskAdd(input?: z.input<InstanceType<typeof LocaltaskAddAction>['_input']>) {
924
924
  const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskAddAction>['_input']>);
925
925
  const path = `/api/localtasks`;
926
- const body = { "text": inp["text"], "file": inp["file"], "cwd": inp["cwd"], "summary": inp["summary"], "global": inp["global"], "board": inp["board"], "project": inp["project"], "duration": inp["duration"], "goal-prompt": inp["goal-prompt"], "goalPrompt": inp["goalPrompt"], "block-by": inp["block-by"], "blockBy": inp["blockBy"], "gate": inp["gate"], "fork-of": inp["fork-of"], "forkOf": inp["forkOf"], "fork-kind": inp["fork-kind"], "forkKind": inp["forkKind"] };
926
+ const body = { "text": inp["text"], "file": inp["file"], "cwd": inp["cwd"], "summary": inp["summary"], "board": inp["board"], "project": inp["project"], "duration": inp["duration"], "goal-prompt": inp["goal-prompt"], "goalPrompt": inp["goalPrompt"], "block-by": inp["block-by"], "blockBy": inp["blockBy"], "gate": inp["gate"], "fork-of": inp["fork-of"], "forkOf": inp["forkOf"], "fork-kind": inp["fork-kind"], "forkKind": inp["forkKind"] };
927
927
  return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskAddAction>['run']>>;
928
928
  },
929
929
  // action: localtask.attach-note
@@ -937,7 +937,7 @@ export function createApiClient(transport: Transport): ApiClient {
937
937
  async localtaskAttach(input: z.input<InstanceType<typeof LocaltaskAttachAction>['_input']>) {
938
938
  const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskAttachAction>['_input']>);
939
939
  const path = `/api/localtasks/attach`;
940
- const body = { "id": inp["id"], "cwd": inp["cwd"], "key": inp["key"], "path": inp["path"], "fileId": inp["fileId"], "url": inp["url"], "task": inp["task"], "ref": inp["ref"], "mdfile": inp["mdfile"], "folder": inp["folder"], "inline": inp["inline"], "name": inp["name"], "kind": inp["kind"], "note": inp["note"], "noEmbed": inp["noEmbed"], "no-embed": inp["no-embed"] };
940
+ const body = { "id": inp["id"], "cwd": inp["cwd"], "key": inp["key"], "path": inp["path"], "fileId": inp["fileId"], "url": inp["url"], "task": inp["task"], "ref": inp["ref"], "mdfile": inp["mdfile"], "folder": inp["folder"], "repo": inp["repo"], "inline": inp["inline"], "name": inp["name"], "kind": inp["kind"], "note": inp["note"], "noEmbed": inp["noEmbed"], "no-embed": inp["no-embed"] };
941
941
  return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskAttachAction>['run']>>;
942
942
  },
943
943
  // action: localtask.attachments
@@ -1006,14 +1006,14 @@ export function createApiClient(transport: Transport): ApiClient {
1006
1006
  async config(input?: z.input<InstanceType<typeof LocaltaskConfigAction>['_input']>) {
1007
1007
  const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskConfigAction>['_input']>);
1008
1008
  const path = `/api/localtasks/setting`;
1009
- const body = { "timeout": inp["timeout"], "append-mode": inp["append-mode"], "appendMode": inp["appendMode"] };
1009
+ const body = { "timeout": inp["timeout"] };
1010
1010
  return (await transport.request("PATCH", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskConfigAction>['run']>>;
1011
1011
  },
1012
1012
  // action: localtask.detach
1013
1013
  async localtaskDetach(input: z.input<InstanceType<typeof LocaltaskDetachAction>['_input']>) {
1014
1014
  const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskDetachAction>['_input']>);
1015
1015
  const path = `/api/localtasks/attach`;
1016
- const body = { "id": inp["id"], "cwd": inp["cwd"], "key": inp["key"], "attachment": inp["attachment"], "purge": inp["purge"] };
1016
+ const body = { "id": inp["id"], "cwd": inp["cwd"], "key": inp["key"], "attachment": inp["attachment"] };
1017
1017
  return (await transport.request("DELETE", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskDetachAction>['run']>>;
1018
1018
  },
1019
1019
  // action: localtask.done
@@ -0,0 +1,117 @@
1
+ // 任务(localtask)HTTP 收口:任务页模板(page/dir、page/group)与任务编辑器共用的那一组。
2
+ //
3
+ // 为什么在这层:#251 起目录页与组页共用同一套「行尾 / 批量」动作(components/task-panel/
4
+ // task-ops),两个页面都要能调同一组接口;接口定义留在某一页的 api.ts 里会让另一页
5
+ // 反向依赖页面目录。页面自己的 api.ts 保留各自专有的调用,并 re-export 这份公共面。
6
+ //
7
+ // 只搬调用不改语义:路径 / 方法 / body 与原 page/dir/api.ts 逐字一致。
8
+ // scope:主题定位二选一——{ cwd } 或 { key }(#190 起队列一律绑定目录,无全局池)。
9
+ import { api } from './client.js';
10
+
11
+ /** 主题定位:cwd(目录主题)或 key(含全局池)。 */
12
+ export type TaskScope = { cwd?: string; key?: string };
13
+
14
+ /** 变更类返回的公共形状:task=落地后的任务;key/moved/name=落点与归属迁移提示。 */
15
+ export interface TaskMutationResult {
16
+ task?: { id?: number | string; text?: string };
17
+ id?: number | string;
18
+ key?: string;
19
+ moved?: boolean;
20
+ name?: string;
21
+ }
22
+
23
+ /** 批量操作返回:count=处理条数;skipped/missing=跳过 / 未找到的编号。 */
24
+ export interface TaskBulkResult {
25
+ count?: number;
26
+ skipped?: Array<number | string>;
27
+ missing?: Array<number | string>;
28
+ /** closeMany 专用:本轮收口里「原本已被领取」的编号(#184 面板提示用)。 */
29
+ claimedClosed?: Array<number | string>;
30
+ }
31
+
32
+ /** 队列内调序(PATCH /api/localtasks/reorder;beforeId / afterId 二选一)。 */
33
+ export function reorderTask(
34
+ body: TaskScope & { id: number; beforeId?: number | string; afterId?: number | string },
35
+ ): Promise<unknown> {
36
+ return api('/api/localtasks/reorder', { method: 'PATCH', body });
37
+ }
38
+
39
+ export interface PatchTaskItemBody extends TaskScope {
40
+ id: number;
41
+ text?: string;
42
+ gate?: boolean;
43
+ blockBy?: string | number[];
44
+ duration?: string;
45
+ clearGoal?: boolean;
46
+ goalPrompt?: string;
47
+ summary?: string;
48
+ [k: string]: unknown;
49
+ }
50
+
51
+ /** 编辑单个本地任务(PATCH /api/localtasks/item;CLI localtask update 等价)。 */
52
+ export function patchTaskItem(body: PatchTaskItemBody): Promise<TaskMutationResult> {
53
+ return api('/api/localtasks/item', { method: 'PATCH', body });
54
+ }
55
+
56
+ /**
57
+ * 按查询串查单条任务(GET /api/localtasks/item?<q>)。
58
+ * 找不到或出错返回 null(调用方以 null 判「没有这条」)。
59
+ */
60
+ export function findTaskItem(query: string): Promise<any> {
61
+ return api(`/api/localtasks/item?${query}`).catch(() => null);
62
+ }
63
+
64
+ export interface AddTaskBody extends TaskScope {
65
+ global?: boolean;
66
+ text: string;
67
+ forkOf?: string;
68
+ forkKind?: string;
69
+ board?: string;
70
+ project?: string;
71
+ [k: string]: unknown;
72
+ }
73
+
74
+ /** 加任务(POST /api/localtasks;CLI localtask add 等价)。 */
75
+ export function addTask(body: AddTaskBody): Promise<any> {
76
+ return api('/api/localtasks', { method: 'POST', body });
77
+ }
78
+
79
+ /**
80
+ * #126:在 pending ↔ plan 之间切换一条任务(PATCH /api/localtasks/plan)。
81
+ * plan 是不进队列的临时草稿,get/wait 都领不到;转回 pending 才重新排队。
82
+ */
83
+ export function setPlanStatus(body: TaskScope & { id: number; to: 'plan' | 'pending' }): Promise<any> {
84
+ return api('/api/localtasks/plan', { method: 'PATCH', body });
85
+ }
86
+
87
+ /** 重开 / 追加反馈(POST /api/localtasks/reopen;kind=reopen|comment)。 */
88
+ export function postReopen(body: Record<string, unknown>): Promise<TaskMutationResult> {
89
+ return api('/api/localtasks/reopen', { method: 'POST', body });
90
+ }
91
+
92
+ /** 删除单个本地任务(DELETE /api/localtasks/item;purge=true 彻底删除)。 */
93
+ export function removeTaskItem(body: TaskScope & { id: number; purge?: boolean }): Promise<unknown> {
94
+ return api('/api/localtasks/item', { method: 'DELETE', body });
95
+ }
96
+
97
+ /** 批量软删除(DELETE /api/localtasks/items)。 */
98
+ export function removeManyTasks(body: TaskScope & { ids: unknown[] }): Promise<TaskBulkResult> {
99
+ return api('/api/localtasks/items', { method: 'DELETE', body });
100
+ }
101
+
102
+ /** 批量取消(POST /api/localtasks/items/cancel)。 */
103
+ export function cancelManyTasks(body: TaskScope & { ids: unknown[] }): Promise<TaskBulkResult> {
104
+ return api('/api/localtasks/items/cancel', { method: 'POST', body });
105
+ }
106
+
107
+ /** 批量收口(POST /api/localtasks/items/close;status=done|cancelled)。 */
108
+ export function closeManyTasks(
109
+ body: TaskScope & { ids: unknown[]; status: string; summary?: string },
110
+ ): Promise<TaskBulkResult> {
111
+ return api('/api/localtasks/items/close', { method: 'POST', body });
112
+ }
113
+
114
+ /** 恢复软删除的任务(POST /api/localtasks/tasks/restore)。 */
115
+ export function restoreTaskItem(body: TaskScope & { id: number }): Promise<unknown> {
116
+ return api('/api/localtasks/tasks/restore', { method: 'POST', body });
117
+ }
@@ -7,7 +7,9 @@
7
7
  //
8
8
  // #186:以前这份列表是 DocsModal(模态弹窗),与「更多 → 查看列表」的右侧栏重复。
9
9
  // 用户要求「查看列表统一只要右侧边栏,不要 modal 弹窗」→ 弹窗下线,这里只负责开门。
10
+ import { useState } from 'react';
10
11
  import { useApp } from '../../app-context.jsx';
12
+ import { useToast } from '../toast/index.jsx';
11
13
  import type { Model } from 'flexlayout-react';
12
14
  import { useIntro } from './use-intro.js';
13
15
  import type { IntroKind, IntroOwner } from './use-intro.js';
@@ -23,11 +25,15 @@ export interface IntroductionProps {
23
25
 
24
26
  export default function Introduction({ kind, owner, model }: IntroductionProps) {
25
27
  const app = useApp();
26
- const { label, docRef, links, openMain } = useIntro({ kind, owner, model });
28
+ const toast = useToast();
29
+ const { label, docRef, mainDocId, links, openMain, createMain } = useIntro({ kind, owner, model });
30
+ const [creating, setCreating] = useState(false);
27
31
 
28
- if (!owner || !docRef) return null;
32
+ if (!owner) return null;
29
33
 
30
- // 主篇以「介绍文档集」为准
34
+ // 主篇以「介绍文档集」为准:owner.docId 只是快路径,接口(/api/boards/:id、
35
+ // /api/repos/docs)拿到的主篇更实时——新建后哪怕 repoData 还没刷新,这里也会自己切到有主篇态。
36
+ const hasMain = !!(docRef || mainDocId);
31
37
  const mainEntry = links.find((l) => l.main);
32
38
  const pathLabel = mainEntry?.label || '文档库';
33
39
  const extrasCount = links.filter((l) => !l.main).length;
@@ -46,6 +52,47 @@ export default function Introduction({ kind, owner, model }: IntroductionProps)
46
52
  });
47
53
  };
48
54
 
55
+ // 还没有介绍文档(组 / 仓库同一条口径):不留空槽,也不白屏——保持与有主篇时
56
+ // **同一行结构**,主链接与「+ 新建」都能一步建出主篇并直接进去写。
57
+ if (!hasMain) {
58
+ const start = () => {
59
+ if (creating) return;
60
+ setCreating(true);
61
+ createMain()
62
+ .then(() => app.refreshRepos?.())
63
+ .catch((e) => toast(String((e as Error).message || e)))
64
+ .finally(() => setCreating(false));
65
+ };
66
+ return (
67
+ <div className="nx-intro">
68
+ <div className="nx-intro-head">
69
+ <button
70
+ type="button"
71
+ className="nx-intro-link-main is-empty"
72
+ title={`还没有${label}——点这里写第一篇`}
73
+ disabled={creating}
74
+ onClick={start}
75
+ >
76
+ {creating ? '新建中…' : label}
77
+ </button>
78
+ <span className="nx-intro-path mono">未编写</span>
79
+ <span className="nx-intro-spacer" />
80
+ <button type="button" className="nx-intro-btn" disabled={creating} onClick={start}>
81
+ + 新建
82
+ </button>
83
+ <button
84
+ type="button"
85
+ className="nx-intro-btn"
86
+ title={`在右侧栏列出${label}的全部文章(也可以在那里新建)`}
87
+ onClick={openList}
88
+ >
89
+ 查看详情
90
+ </button>
91
+ </div>
92
+ </div>
93
+ );
94
+ }
95
+
49
96
  return (
50
97
  <div className="nx-intro">
51
98
  <div className="nx-intro-head">
@@ -17,6 +17,12 @@
17
17
  border-bottom:1px solid color-mix(in srgb, var(--mdw-accent,#2F6F5E) 40%, transparent);
18
18
  }
19
19
  .nx-intro-link-main:hover{background:var(--mdw-accent-soft,#E8F2EE)}
20
+ /* 未编写态(组 / 仓库还没有介绍文档):仍是同一行,主链接改虚线底提示「点这里写第一篇」 */
21
+ .nx-intro-link-main.is-empty{
22
+ color:var(--ink-2,#4B515A);
23
+ border-bottom-style:dashed;
24
+ }
25
+ .nx-intro-link-main:disabled,.nx-intro-btn:disabled{opacity:.6;cursor:default}
20
26
  .nx-intro-path{font:400 10.5px ui-monospace,Consolas,monospace;letter-spacing:0;color:var(--faint,#A9AEB4);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
21
27
  /* 头部弹性占位:全局 .grow 是 max-width:340px,不是 flex:1 —— 靠右得自己撑 */
22
28
  .nx-intro-spacer{flex:1 1 auto;min-width:0}
@@ -4,6 +4,7 @@
4
4
  import { useCallback, useEffect, useMemo, useState } from 'react';
5
5
  import type { Model } from 'flexlayout-react';
6
6
  import { api } from '../../api/client.js';
7
+ import { createDoc } from '../../refs/ops.js';
7
8
  import { useWikiNav } from '../../page/doc/index.jsx';
8
9
  import type { DocOpenExtra } from '../../page/doc/index.jsx';
9
10
 
@@ -67,6 +68,8 @@ export interface IntroApi {
67
68
  links: IntroLink[];
68
69
  openMain: () => void;
69
70
  openDoc: (id: string) => void;
71
+ /** 没有介绍文档时的一步新建(建完即设为主篇并打开) */
72
+ createMain: () => Promise<void>;
70
73
  reload: () => void;
71
74
  canEdit: boolean;
72
75
  }
@@ -168,6 +171,27 @@ export function useIntro({ kind, owner, model }: UseIntroArgs): IntroApi {
168
171
  [openByDocId, openExtra]
169
172
  );
170
173
 
174
+ /**
175
+ * 没有介绍文档时的一步新建:`createRef` 对「owner 尚无主篇」的仓库 / 组会**直接
176
+ * 绑成主篇**(docs/service 的 createRef 里 board.doc / repo.doc 为空就写入),
177
+ * 所以这里不需要再调 promoteToMain。建完立即在主内容区打开,用户接着写正文。
178
+ *
179
+ * 本地先把主篇钉上(mainDocId / links),这样宿主数据(repoData.boards)还没刷新时
180
+ * 页面也不会停在「未编写」;接口下一次请求会再校准一遍。
181
+ */
182
+ const createMain = useCallback(async () => {
183
+ if (!ownerKey) return;
184
+ const refId = await createDoc({
185
+ owner: kind === 'board' ? 'group' : 'repo',
186
+ ...(kind === 'board' ? { group: ownerKey } : { repo: ownerKey }),
187
+ title: ownerName || label,
188
+ });
189
+ const docId = 'ref:' + refId;
190
+ setMainDocId(docId);
191
+ setLinks([{ docId, label: ownerName || label, main: true }]);
192
+ openByDocId(docId, null, openExtra);
193
+ }, [kind, ownerKey, ownerName, label, openByDocId, openExtra]);
194
+
171
195
  return {
172
196
  kind,
173
197
  label,
@@ -177,6 +201,7 @@ export function useIntro({ kind, owner, model }: UseIntroArgs): IntroApi {
177
201
  links,
178
202
  openMain,
179
203
  openDoc,
204
+ createMain,
180
205
  reload,
181
206
  canEdit: !!mainDocId || !!docRef,
182
207
  };
@@ -5,7 +5,7 @@
5
5
  //
6
6
  // 交互:拖文件进来直接登记(role=attach);「添加附件」打开共享弹窗;
7
7
  // 图片缩略图点开大图;pdf/其它给打开/下载;task 点击跳任务;ref 点击开文档;
8
- // 移除时二选一:只解除关联 / 连资源与字节一起删。
8
+ // 移除 = **只解除关联**(#189):资源行与字节不动,后续清理走库级 GC。
9
9
  import { useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
10
10
  import type { ComponentType, DragEvent, ReactNode, Ref } from 'react';
11
11
  import { Modal, useDialog } from '../../popup/index.jsx';
@@ -173,7 +173,7 @@ export default function AttachArea({
173
173
  hostKey,
174
174
  hostCwd,
175
175
  refId,
176
- allow = { file: true, url: true, folder: true, task: false, ref: false },
176
+ allow = { file: true, url: true, folder: true, task: false, ref: false, repo: false },
177
177
  taskOptions = [],
178
178
  docOptions,
179
179
  disabled = false,
@@ -298,14 +298,15 @@ export default function AttachArea({
298
298
  setModalOpen(true);
299
299
  };
300
300
 
301
- const doRemove = async (purge: boolean) => {
301
+ const doRemove = async () => {
302
302
  const item = removeOf;
303
303
  if (!item) return;
304
304
  setRemoving(true);
305
305
  try {
306
- await ep.detach(item.id, !!purge);
306
+ // #189:只解除关联——不删资源行、不删字节(各 kind 删除语义不一致,统一交给 GC)
307
+ await ep.detach(item.id);
307
308
  setRemoveOf(null);
308
- toast(purge ? `已移除并删除资源:${item.name}` : `已解除关联:${item.name}`);
309
+ toast(`已解除关联:${item.name}`);
309
310
  await load();
310
311
  onChanged?.();
311
312
  } catch (e) {
@@ -432,18 +433,15 @@ export default function AttachArea({
432
433
  footer={
433
434
  <div className="att-foot">
434
435
  <button type="button" className="btn ghost" disabled={removing} onClick={() => setRemoveOf(null)}>取消</button>
435
- <button type="button" className="btn" disabled={removing} onClick={() => doRemove(false)}>只解除关联</button>
436
- <button type="button" className="btn danger" disabled={removing} onClick={() => doRemove(true)}>
437
- {removeOf.kind === 'file' ? '连文件一起删' : '连资源一起删'}
438
- </button>
436
+ <button type="button" className="btn" disabled={removing} onClick={() => void doRemove()}>移除(解除关联)</button>
439
437
  </div>
440
438
  }
441
439
  >
442
440
  <div className="att-confirm">
443
441
  <div className="att-confirm-name">{removeOf.name}</div>
444
442
  <div className="att-confirm-text">
445
- 只解除关联:从这份{host === 'task' ? '任务' : '文档'}的附件清单里移除,资源仍留在孤儿池,可被重新挂载。
446
- 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。
443
+ 会从这份{host === 'task' ? '任务' : '文档'}的附件清单里移除,资源本身(行与字节)保留在孤儿池,
444
+ 之后仍可重新挂载;需要清理时由库级 GC 统一回收。
447
445
  </div>
448
446
  </div>
449
447
  </ModalBox>
@@ -82,6 +82,8 @@ export interface AttachAllow {
82
82
  folder: boolean;
83
83
  task: boolean;
84
84
  ref: boolean;
85
+ /** #184 参考仓库(kind=repo):只登记指针,交付时强制参考源码 */
86
+ repo: boolean;
85
87
  }
86
88
 
87
89
  /** 可关联的任务(本主题内):只用到编号与标题/正文首行。 */
@@ -109,7 +111,8 @@ export interface DocOption {
109
111
  export interface AttachEndpoint {
110
112
  list: () => Promise<AttachListData>;
111
113
  attach: (body: Record<string, any>) => Promise<any>;
112
- detach: (attachment: string | number | undefined, purge: boolean) => Promise<any>;
114
+ /** #189:移除 = 只解除关联(不传 purge——资源清理走库级 GC) */
115
+ detach: (attachment: string | number | undefined) => Promise<any>;
113
116
  }
114
117
 
115
118
  /** 待确认条目 → attach 请求体的最小形状(attachBodyOf 的入参)。 */
@@ -122,6 +125,8 @@ export interface AttachDraftItem {
122
125
  folder?: string;
123
126
  seq?: number | string;
124
127
  docRef?: string;
128
+ /** #184:仓库 key(kind=repo;服务端按它查已登记元数据) */
129
+ repoKey?: string;
125
130
  note?: string;
126
131
  inline?: boolean;
127
132
  }
@@ -192,9 +197,9 @@ export function endpointOf(host: AttachHostKind | undefined, { hostId, hostKey,
192
197
  method: 'POST',
193
198
  body: { id: Number(hostId), ...where, ...body, noEmbed: true },
194
199
  }),
195
- detach: (attachment, purge) => api('/api/localtasks/attach', {
200
+ detach: (attachment) => api('/api/localtasks/attach', {
196
201
  method: 'DELETE',
197
- body: { id: Number(hostId), ...where, attachment, purge },
202
+ body: { id: Number(hostId), ...where, attachment },
198
203
  }),
199
204
  };
200
205
  }
@@ -202,9 +207,9 @@ export function endpointOf(host: AttachHostKind | undefined, { hostId, hostKey,
202
207
  return {
203
208
  list: () => api<AttachListData>(`/api/docs/attachments?${q.toString()}`),
204
209
  attach: (body) => api('/api/docs/attach', { method: 'POST', body: { ref: refId, ...body, noEmbed: true } }),
205
- detach: (attachment, purge) => api('/api/docs/attach', {
210
+ detach: (attachment) => api('/api/docs/attach', {
206
211
  method: 'DELETE',
207
- body: { ref: refId, attachment, purge },
212
+ body: { ref: refId, attachment },
208
213
  }),
209
214
  };
210
215
  }
@@ -222,6 +227,8 @@ export function attachBodyOf(item: AttachDraftItem, host: AttachHostKind = 'task
222
227
  // 本地文件夹(#133):只把**路径**交给服务端(kind=folder),目录内容不入库。
223
228
  if (item.source === 'folder') return { folder: item.folder, name: item.name };
224
229
  if (item.source === 'task') return { task: String(item.seq), name: item.name };
230
+ // #184:参考仓库——只给 key,服务端校验「已登记」后按 repoAttachmentId 去重登记
231
+ if (item.source === 'repo') return { repo: item.repoKey, name: item.name };
225
232
  if (item.source === 'ref') {
226
233
  const body: Record<string, any> = host === 'doc'
227
234
  ? { doc: item.docRef, name: item.name }
@@ -12,6 +12,9 @@ import type { ClipboardEvent, ComponentType, ReactNode } from 'react';
12
12
  import { Modal } from '../../popup/index.jsx';
13
13
  import { api } from '../../../api/client.js';
14
14
  import { clipboardFiles, droppedFiles, readableName, uploadOne } from '../../attach/upload.js';
15
+ import { filterTasks } from '../../../modules/board/task-search.js';
16
+ import { filterByKeyword } from '../../../modules/list-filter.js';
17
+ import AttachRepoPick from './attach-repo-pick.js';
15
18
  import StatusTag from '../../status-tag/index.jsx';
16
19
  import {
17
20
  attachBodyOf,
@@ -39,13 +42,13 @@ const ModalBox = Modal as unknown as ComponentType<{
39
42
  }>;
40
43
 
41
44
  const SOURCE_LABEL: Record<PendingItem['source'], string> = {
42
- file: '本机文件', folder: '本地文件夹', url: '外部链接', task: '任务引用', ref: '文档引用',
45
+ file: '本机文件', folder: '本地文件夹', url: '外部链接', task: '任务引用', ref: '文档引用', repo: '参考仓库',
43
46
  };
44
47
 
45
48
  /** 待确认清单的一条(本地态,不是服务端形状)。 */
46
49
  interface PendingItem {
47
50
  key: string;
48
- source: 'file' | 'folder' | 'url' | 'task' | 'ref';
51
+ source: 'file' | 'folder' | 'url' | 'task' | 'ref' | 'repo';
49
52
  file?: File;
50
53
  fileId?: string;
51
54
  name: string;
@@ -56,6 +59,8 @@ interface PendingItem {
56
59
  folder?: string;
57
60
  seq?: number;
58
61
  docRef?: string;
62
+ /** #184 仓库 key(source='repo') */
63
+ repoKey?: string;
59
64
  note?: string;
60
65
  inline?: boolean;
61
66
  status: 'pending' | 'uploading' | 'error';
@@ -100,7 +105,7 @@ export default function AttachModal({
100
105
  hostKey,
101
106
  hostCwd,
102
107
  refId,
103
- allow = { file: true, url: true, folder: true, task: false, ref: false },
108
+ allow = { file: true, url: true, folder: true, task: false, ref: false, repo: false },
104
109
  taskOptions = [],
105
110
  docOptions = null,
106
111
  replaceAttachment = null,
@@ -118,6 +123,9 @@ export default function AttachModal({
118
123
  const [taskSearch, setTaskSearch] = useState('');
119
124
  const [refSearch, setRefSearch] = useState('');
120
125
  const [docs, setDocs] = useState<DocOption[]>(docOptions || []);
126
+ // #184:参考仓库列表(只用于挂指针,交付时强制参考源码)
127
+ const [repos, setRepos] = useState<Array<{ key: string; name: string; desc?: string; type?: string; path?: string }>>([]);
128
+ const [repoSearch, setRepoSearch] = useState('');
121
129
  const fileRef = useRef<HTMLInputElement | null>(null);
122
130
  const dropRef = useRef<HTMLDivElement | null>(null);
123
131
 
@@ -137,6 +145,7 @@ export default function AttachModal({
137
145
  setFolderErr('');
138
146
  setTaskSearch('');
139
147
  setRefSearch('');
148
+ setRepoSearch('');
140
149
  // 焦点落在拖拽区:不点任何地方直接 Ctrl/⌘+V 也能接住剪贴板里的截图
141
150
  const t = setTimeout(() => dropRef.current?.focus(), 0);
142
151
  return () => clearTimeout(t);
@@ -164,6 +173,23 @@ export default function AttachModal({
164
173
  return () => { alive = false; };
165
174
  }, [open, docOptions, allow.ref]);
166
175
 
176
+ useEffect(() => {
177
+ if (!open || !allow.repo) return undefined;
178
+ let alive = true;
179
+ api<any>('/api/repos').then((r) => {
180
+ if (!alive) return;
181
+ const arr = Array.isArray(r) ? r : (r && Array.isArray(r.repos) ? r.repos : []);
182
+ setRepos(arr.map((x: any) => ({
183
+ key: String(x.key || x.id || ''),
184
+ name: String(x.name || x.key || ''),
185
+ desc: String(x.desc || ''),
186
+ type: String(x.type || ''),
187
+ path: String(x.path || ''),
188
+ })).filter((x: { key: string }) => !!x.key));
189
+ }).catch(() => { /* 拉不到就只显示空态 */ });
190
+ return () => { alive = false; };
191
+ }, [open, allow.repo]);
192
+
167
193
  const addFiles = (list: FileList | File[] | null | undefined) => {
168
194
  if (!allow.file) return;
169
195
  const files = [...(list || [])].filter((f) => f && f.size > 0);
@@ -278,7 +304,7 @@ export default function AttachModal({
278
304
  await ep.attach(attachBodyOf({ ...it, fileId, note: it.note || replaceNote || '' }, host));
279
305
  // #168:换指向——新绑定挂好后解除旧的那条(旧资源进孤儿池,不删字节)
280
306
  if (replaceAttachment) {
281
- try { await ep.detach(replaceAttachment, false); } catch { /* 旧边解不掉也不影响新绑定 */ }
307
+ try { await ep.detach(replaceAttachment); } catch { /* 旧边解不掉也不影响新绑定 */ }
282
308
  }
283
309
  setItems((prev) => prev.filter((x) => x.key !== it.key));
284
310
  return true;
@@ -310,12 +336,21 @@ export default function AttachModal({
310
336
  };
311
337
 
312
338
  const taskList = useMemo(() => {
313
- const q = taskSearch.trim().toLowerCase();
314
- return taskOptions
315
- .filter((t) => String(t.id) !== String(hostId))
316
- .filter((t) => (q ? `${t.id} ${t.text || ''}`.toLowerCase().includes(q) : true))
317
- .slice(0, 12);
339
+ // #183:任务搜索与 topic 页共用 modules/board/task-search.ts 的同一份引擎
340
+ // (空格分词 AND / 剥 frontmatter / 通配 / 编号前缀),弹窗不再自己写 includes。
341
+ const pool = taskOptions.filter((t) => String(t.id) !== String(hostId));
342
+ return filterTasks(pool, taskSearch).slice(0, 12);
318
343
  }, [taskOptions, taskSearch, hostId]);
344
+ const repoList = useMemo(() => filterByKeyword(repos, repoSearch, (r) => [r.name, r.key, r.desc]).slice(0, 12),
345
+ [repos, repoSearch]);
346
+ const addRepo = (r: { key: string; name: string }) => {
347
+ setItems((prev) => [
348
+ ...prev,
349
+ { key: nextKey(), source: 'repo', repoKey: r.key, name: r.name, size: 0, status: 'pending' },
350
+ ]);
351
+ setRepoSearch('');
352
+ };
353
+
319
354
  const refList = useMemo(() => {
320
355
  const q = refSearch.trim().toLowerCase();
321
356
  return docs
@@ -491,6 +526,16 @@ export default function AttachModal({
491
526
  </div>
492
527
  )}
493
528
 
529
+ {allow.repo && (
530
+ <AttachRepoPick
531
+ repos={repos}
532
+ list={repoList}
533
+ search={repoSearch}
534
+ onSearch={setRepoSearch}
535
+ onPick={addRepo}
536
+ />
537
+ )}
538
+
494
539
  {items.length ? (
495
540
  <div className="att-pending">
496
541
  <div className="att-pending-head">待确认清单</div>