nx-kv 0.62.1 → 0.64.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 (225) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +6 -5
  3. package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +2 -1
  4. package/package.json +2 -2
  5. package/src/core/attachmentdb/docs.ts +3 -6
  6. package/src/core/attachmentdb/query.ts +2 -2
  7. package/src/core/attachmentdb/relations.ts +36 -21
  8. package/src/core/db/import-json/refs.ts +17 -19
  9. package/src/core/db/import-json/repos.ts +4 -8
  10. package/src/core/db/migrations/index.ts +2 -0
  11. package/src/core/db/migrations/v13.sql +24 -0
  12. package/src/core/db/seed-templates.ts +86 -3
  13. package/src/core/db/version.ts +3 -1
  14. package/src/modules/docs/actions/_manifest.generated.ts +3 -3
  15. package/src/modules/docs/actions/doc-attach.ts +0 -1
  16. package/src/modules/docs/actions/docs-bindings.ts +2 -5
  17. package/src/modules/docs/actions/docs-link.ts +1 -2
  18. package/src/modules/docs/actions/docs-main.ts +39 -0
  19. package/src/modules/docs/attach.ts +1 -36
  20. package/src/modules/docs/bound-docs.ts +2 -2
  21. package/src/modules/docs/brief.ts +0 -2
  22. package/src/modules/docs/docref.ts +7 -17
  23. package/src/modules/docs/knowledge-md.ts +1 -1
  24. package/src/modules/docs/knowledge.ts +48 -45
  25. package/src/modules/docs/ref-sync.ts +1 -5
  26. package/src/modules/docs/refs.ts +82 -10
  27. package/src/modules/docs/service.ts +1 -3
  28. package/src/modules/localtask/actions/localtask-config.ts +19 -58
  29. package/src/modules/localtask/actions/localtask-prune.ts +7 -2
  30. package/src/modules/localtask/repo/open.ts +0 -4
  31. package/src/modules/localtask/repo/settings.ts +20 -196
  32. package/src/modules/localtask/task-lifecycle.ts +7 -9
  33. package/src/modules/localtask/task-templates.ts +4 -4
  34. package/src/modules/localtask/task-view.ts +4 -0
  35. package/src/modules/localtask/topics.ts +30 -28
  36. package/src/modules/promptplug/actions/_manifest.generated.ts +0 -3
  37. package/src/modules/promptplug/actions/prompt-registry.ts +19 -30
  38. package/src/modules/promptplug/base.ts +69 -25
  39. package/src/modules/promptplug/compose.ts +40 -23
  40. package/src/modules/promptplug/factory.ts +91 -59
  41. package/src/modules/promptplug/index.ts +25 -11
  42. package/src/modules/promptplug/plugins/ack.ts +28 -0
  43. package/src/modules/promptplug/plugins/attachment.ts +237 -19
  44. package/src/modules/promptplug/plugins/context.ts +124 -30
  45. package/src/modules/promptplug/plugins/doneguard.ts +33 -0
  46. package/src/modules/promptplug/plugins/ext.ts +34 -11
  47. package/src/modules/promptplug/plugins/getloop.ts +29 -8
  48. package/src/modules/promptplug/plugins/goal-shape.ts +34 -0
  49. package/src/modules/promptplug/plugins/goalhint.ts +33 -0
  50. package/src/modules/promptplug/plugins/timecheck.ts +33 -0
  51. package/src/modules/promptplug/registry.ts +99 -0
  52. package/src/modules/promptplug/schema-bridge.ts +77 -13
  53. package/src/modules/repos/actions/board-rekey.ts +1 -1
  54. package/src/modules/repos/actions/repo-doc-add.ts +2 -3
  55. package/src/modules/repos/boards/core.ts +1 -13
  56. package/src/modules/repos/boards/docs.ts +2 -12
  57. package/src/modules/repos/boards/members.ts +2 -14
  58. package/src/modules/repos/boards/transfer.ts +2 -11
  59. package/src/modules/repos/keys.ts +4 -11
  60. package/src/modules/repos/repo/refs.ts +3 -5
  61. package/src/modules/repos/repo/repos.ts +12 -13
  62. package/src/modules/repos/repo/rows.ts +2 -8
  63. package/src/modules/repos/service/context.ts +0 -2
  64. package/src/modules/repos/service/crud.ts +1 -4
  65. package/src/modules/repos/service/store.ts +6 -7
  66. package/src/modules/repos/transfer/export.ts +3 -8
  67. package/src/modules/repos/transfer/import.ts +0 -13
  68. package/src/modules/repos/transfer/layout.ts +2 -2
  69. package/src/modules/tasktool/attach-template.ts +3 -3
  70. package/src/modules/tasktool/groupctx.ts +4 -5
  71. package/src/modules/tasktool/plugins/waitgoal-config.ts +5 -6
  72. package/src/modules/tasktool/preview.ts +20 -23
  73. package/src/modules/tasktool/wait.ts +24 -46
  74. package/src/modules/templates/actions/_manifest.generated.ts +3 -0
  75. package/src/modules/templates/actions/templates-reorder.ts +28 -0
  76. package/src/modules/templates/repo/templates.ts +32 -2
  77. package/src/modules/templates/service.ts +45 -0
  78. package/src/shared/prompt-blocks.ts +7 -173
  79. package/src/shared/prompt-plugin.ts +79 -59
  80. package/src/web/frontend/App.tsx +27 -1
  81. package/src/web/frontend/api/cli-tree.json +35 -35
  82. package/src/web/frontend/api/client.generated.ts +32 -32
  83. package/src/web/frontend/components/Introduction/rail.tsx +2 -2
  84. package/src/web/frontend/components/Introduction/use-intro.ts +2 -5
  85. package/src/web/frontend/components/bindings/bind-tags.tsx +1 -3
  86. package/src/web/frontend/components/icons.tsx +12 -0
  87. package/src/web/frontend/components/list-search.tsx +37 -0
  88. package/src/web/frontend/components/md/attach-area.tsx +10 -15
  89. package/src/web/frontend/components/md/live-block.tsx +8 -2
  90. package/src/web/frontend/components/md/md-panes-root.tsx +4 -0
  91. package/src/web/frontend/components/md/md-panes.tsx +11 -1
  92. package/src/web/frontend/components/popup/style.css +4 -0
  93. package/src/web/frontend/components/sidebar/index.tsx +1 -0
  94. package/src/web/frontend/modules/list-filter.ts +37 -0
  95. package/src/web/frontend/modules/md/fill-session.ts +36 -0
  96. package/src/web/frontend/modules/md/manage-session.ts +24 -0
  97. package/src/web/frontend/modules/md/new-task-from-template.ts +22 -0
  98. package/src/web/frontend/modules/md/styles/editor.css +17 -0
  99. package/src/web/frontend/modules/md/styles/panels.css +14 -2
  100. package/src/web/frontend/modules/md/styles/shell.css +4 -0
  101. package/src/web/frontend/modules/md/task-intent.ts +29 -0
  102. package/src/web/frontend/modules/md/use-templates.ts +24 -5
  103. package/src/web/frontend/modules/prompts/template-preview.ts +62 -0
  104. package/src/web/frontend/modules/refs/api.ts +0 -1
  105. package/src/web/frontend/page/dir/index.tsx +36 -9
  106. package/src/web/frontend/page/dir/task-actions.ts +16 -1
  107. package/src/web/frontend/page/dir/task-preview-modal.tsx +1 -1
  108. package/src/web/frontend/page/dir/task.tsx +21 -2
  109. package/src/web/frontend/page/doc/api.ts +2 -3
  110. package/src/web/frontend/page/doc/bindings.tsx +46 -16
  111. package/src/web/frontend/page/doc/index.tsx +3 -4
  112. package/src/web/frontend/page/group/index.tsx +72 -127
  113. package/src/web/frontend/page/refs/index.tsx +76 -13
  114. package/src/web/frontend/page/refs/style.css +7 -0
  115. package/src/web/frontend/page/repos/bind-modals.tsx +18 -2
  116. package/src/web/frontend/page/repos/block-tabs.tsx +30 -24
  117. package/src/web/frontend/page/repos/board-admin.tsx +1 -1
  118. package/src/web/frontend/page/repos/branch-picker.tsx +29 -20
  119. package/src/web/frontend/page/repos/doc-block.tsx +9 -2
  120. package/src/web/frontend/page/repos/index.tsx +67 -39
  121. package/src/web/frontend/page/repos/ref-block.tsx +11 -18
  122. package/src/web/frontend/page/repos/ref-panel.tsx +3 -4
  123. package/src/web/frontend/page/repos/repo-form-modal.tsx +1 -8
  124. package/src/web/frontend/page/repos/repo-table.tsx +12 -37
  125. package/src/web/frontend/page/repos/search-results.tsx +114 -0
  126. package/src/web/frontend/page/repos/use-repos-derive.ts +4 -5
  127. package/src/web/frontend/page/settings/api.ts +7 -15
  128. package/src/web/frontend/page/settings/index.tsx +0 -14
  129. package/src/web/frontend/page/settings/prompt-templates-section.tsx +261 -289
  130. package/src/web/frontend/page/settings/prompt-vars.ts +56 -0
  131. package/src/web/frontend/page/settings/style.css +46 -64
  132. package/src/web/frontend/page/templates/fill.tsx +124 -0
  133. package/src/web/frontend/page/templates/index.tsx +81 -30
  134. package/src/web/frontend/page/templates/manage.tsx +218 -0
  135. package/src/web/frontend/page/templates/style.css +108 -0
  136. package/src/web/frontend/page/templates/template-list.tsx +202 -0
  137. package/src/web/frontend/panels.tsx +2 -2
  138. package/src/web/frontend/refs/api.ts +10 -2
  139. package/src/web/frontend/refs/ops.ts +15 -0
  140. package/src/web/frontend/routes/route-eq.ts +22 -0
  141. package/src/web/frontend/routes/templates.ts +20 -0
  142. package/src/web/frontend/style.css +1 -0
  143. package/src/web/frontend/styles/list-search.css +44 -0
  144. package/src/web/frontend/styles/repos-branch.css +72 -0
  145. package/src/web/frontend/types.ts +6 -0
  146. package/src/web/public/assets/app-context-DDQnrPSP.js +1 -0
  147. package/src/web/public/assets/bar-j14ON7uZ.js +1 -0
  148. package/src/web/public/assets/{board-view-CxihNjDm.js → board-view-BVennxTs.js} +1 -1
  149. package/src/web/public/assets/button-BEWXOABr.js +1 -0
  150. package/src/web/public/assets/composer-launch-DRi9mZE1.js +1 -0
  151. package/src/web/public/assets/composer-panel-swmDqlPw.js +1 -0
  152. package/src/web/public/assets/dag-BzdFYMml.js +1 -0
  153. package/src/web/public/assets/dir-DhsB1ZhL.js +3 -0
  154. package/src/web/public/assets/doc-D4po3sDc.js +6 -0
  155. package/src/web/public/assets/fill-session-fHxQHFaD.js +1 -0
  156. package/src/web/public/assets/frontmatter-CN6IlxWU.js +2 -0
  157. package/src/web/public/assets/group-BxmSNzIB.js +1 -0
  158. package/src/web/public/assets/index-CMjG5NVU.js +2 -0
  159. package/src/web/public/assets/index-uMjSWNVr.css +1 -0
  160. package/src/web/public/assets/list-filter-D-x94TvA.js +1 -0
  161. package/src/web/public/assets/manage-session-CS8UvmUd.js +1 -0
  162. package/src/web/public/assets/md-history-CZUF_FhN.js +39 -0
  163. package/src/web/public/assets/{md-parse-no7xfuA1.js → md-parse-C9Vd6ejP.js} +1 -1
  164. package/src/web/public/assets/member-picker-Cvbv24IK.js +1 -0
  165. package/src/web/public/assets/{model-YH7aER_y.js → model-Cc2EoUQp.js} +1 -1
  166. package/src/web/public/assets/new-task-from-template-DDWu4yR4.js +1 -0
  167. package/src/web/public/assets/overview-CctJfO3D.js +1 -0
  168. package/src/web/public/assets/{frontmatter-BZrdOH46.css → popup-BAvk7J7u.css} +1 -1
  169. package/src/web/public/assets/{frontmatter-CK4ti7be.js → popup-D8KWI6-Q.js} +1 -2
  170. package/src/web/public/assets/progress-CawQRCQf.js +3 -0
  171. package/src/web/public/assets/refs-TuuoaRs7.js +2 -0
  172. package/src/web/public/assets/refs-zSA2k_45.css +1 -0
  173. package/src/web/public/assets/render-template-body-bXdedFig.js +1 -0
  174. package/src/web/public/assets/repo-form-modal-BD4N37MI.js +1 -0
  175. package/src/web/public/assets/repos-BPeuX4N9.js +12 -0
  176. package/src/web/public/assets/route-crumb-BcDPd7Ht.js +1 -0
  177. package/src/web/public/assets/settings-CZJaKLZW.js +1 -0
  178. package/src/web/public/assets/settings-Cc6puKd5.css +1 -0
  179. package/src/web/public/assets/status-tag-BD_0iWMB.js +1 -0
  180. package/src/web/public/assets/task-DgbbF5gy.js +11 -0
  181. package/src/web/public/assets/task-intent-CX5DZccN.js +1 -0
  182. package/src/web/public/assets/task-row-CQgzQmzu.js +1 -0
  183. package/src/web/public/assets/{task-utils-BIUeGQ-v.js → task-utils-bJH1-Cjy.js} +1 -1
  184. package/src/web/public/assets/templates-CBXlwyof.js +11 -0
  185. package/src/web/public/assets/templates-plA8R7jJ.css +1 -0
  186. package/src/web/public/assets/use-rail-drag-ufwy2XZB.js +1 -0
  187. package/src/web/public/assets/{workspace-BFjAH4-Z.js → workspace-D3jbcTwf.js} +2 -2
  188. package/src/web/public/index.html +19 -15
  189. package/src/modules/docs/actions/doc-attach-note.ts +0 -32
  190. package/src/modules/promptplug/Template/blockTemplates.json +0 -90
  191. package/src/modules/promptplug/actions/prompt-order.ts +0 -38
  192. package/src/modules/promptplug/ensure.ts +0 -57
  193. package/src/modules/promptplug/keys.ts +0 -9
  194. package/src/modules/promptplug/plugins/readonly-blocks.ts +0 -75
  195. package/src/modules/promptplug/template-bundle.ts +0 -59
  196. package/src/web/frontend/page/settings/prompt-editor.tsx +0 -279
  197. package/src/web/frontend/page/settings/prompt-rail.tsx +0 -170
  198. package/src/web/frontend/page/settings/task-templates-section.tsx +0 -124
  199. package/src/web/public/assets/app-context-DJ_8MHEG.js +0 -1
  200. package/src/web/public/assets/bar-D_n00iZf.js +0 -1
  201. package/src/web/public/assets/composer-launch-DKpTk_et.js +0 -1
  202. package/src/web/public/assets/composer-panel-BuTQ4otm.js +0 -1
  203. package/src/web/public/assets/dag-B-5Zh9um.js +0 -1
  204. package/src/web/public/assets/dir-XjJQx6mX.js +0 -3
  205. package/src/web/public/assets/doc-nLsdRBww.js +0 -6
  206. package/src/web/public/assets/group-DzkX_qJJ.js +0 -1
  207. package/src/web/public/assets/index-Cuio6jjI.css +0 -1
  208. package/src/web/public/assets/index-kP1chg-J.js +0 -2
  209. package/src/web/public/assets/md-history-Hu_Zzy11.js +0 -39
  210. package/src/web/public/assets/member-picker-BmpHTUrK.js +0 -1
  211. package/src/web/public/assets/overview-BkzCE6-x.js +0 -1
  212. package/src/web/public/assets/progress-uUW8vQTZ.js +0 -3
  213. package/src/web/public/assets/refs-Bs0RZMWI.js +0 -2
  214. package/src/web/public/assets/refs-CIdrPlDN.css +0 -1
  215. package/src/web/public/assets/repo-form-modal-Bwr95n7V.js +0 -1
  216. package/src/web/public/assets/repos-DceWSdjD.js +0 -16
  217. package/src/web/public/assets/route-crumb-D73iZP1h.js +0 -1
  218. package/src/web/public/assets/settings-AwzLRYUu.css +0 -1
  219. package/src/web/public/assets/settings-D9LFuVWi.js +0 -1
  220. package/src/web/public/assets/status-tag-DfTirXD_.js +0 -1
  221. package/src/web/public/assets/task-1TZaYQJI.js +0 -11
  222. package/src/web/public/assets/task-row-DFH4lNSh.js +0 -1
  223. package/src/web/public/assets/templates-B8sOtXTt.js +0 -1
  224. package/src/web/public/assets/use-rail-drag-CWKmhXVF.js +0 -1
  225. /package/src/web/public/assets/{repo-form-modal-DA4lNJeC.css → button-DA4lNJeC.css} +0 -0
@@ -20,7 +20,6 @@ const input = z.object({
20
20
  mdfile: z.string().optional().describe("本地 .md 文件路径(kind=mdfile:只登记指针,不复制正文)"),
21
21
  folder: z.string().optional().describe("本地文件夹路径(kind=folder:只登记目录路径,不复制内容)"),
22
22
  name: z.string().optional().describe("显示名(默认取文件名/原名)"),
23
- note: z.string().optional().describe("附件区备注"),
24
23
  noEmbed: z.boolean().optional().describe("只写 ref_attach(role=attach),不改正文"),
25
24
  'no-embed': z.boolean().optional().describe("同 --noEmbed"),
26
25
  });
@@ -87,11 +87,9 @@ export class DocsBindingsAction extends ActionBase<typeof input> {
87
87
  http: ['GET', '/api/docs/bindings'],
88
88
  summary: '查文档归属(--ref <refId> 看这篇被谁引用;--host <repo> 只看仓库自己的文档;--group <组> 看组域文档集:组 → 组内仓库 → 成员仓库自己 → 组内参考仓库自己;hostKind 标宿主是开发仓库/参考仓库/组;position=0 为主篇)',
89
89
  input,
90
- // 备注(只有附加篇有:主篇 push 时不带 note)跟着 main 一起打,和前端注解上的
91
- // 「附加 · 备注」保持同一口径——否则 CLI 里看不出自己刚填的备注有没有落库。
92
90
  render: (d: any) => (d.bindings || [])
93
91
  .map((b: any) => {
94
- const role = b.main ? '主篇' : b.note ? `附加 · ${b.note}` : '附加';
92
+ const role = b.main ? '主篇' : '附加';
95
93
  const label = b.desc || b.title || b.refId;
96
94
  return ` ${b.type} ${b.repoKey}${b.groupKey ? ' @' + b.groupKey : ''} ${role} ${label} [${b.refId}]`;
97
95
  })
@@ -153,7 +151,7 @@ export class DocsBindingsAction extends ActionBase<typeof input> {
153
151
  }
154
152
 
155
153
  const rows = db.all(
156
- `SELECT b.repo_key AS repoKey, b.group_key AS groupKey, b.type, b.position, b.note,
154
+ `SELECT b.repo_key AS repoKey, b.group_key AS groupKey, b.type, b.position,
157
155
  r.id AS refId, r."desc", r.origin, r.locator,
158
156
  CASE WHEN rb.ref_id IS NULL THEN 0 ELSE 1 END AS has_body,
159
157
  rb.body
@@ -184,7 +182,6 @@ export class DocsBindingsAction extends ActionBase<typeof input> {
184
182
  type,
185
183
  position,
186
184
  main: position === 0,
187
- note: String(r.note || ''),
188
185
  // 宿主 kind(#132):dev 开发仓库 / ref 参考仓库 / group 组。
189
186
  // 参考仓库与开发仓库在底层只有这一个差异,列表上标出来才不会看不懂。
190
187
  hostKind: kindOf.get(String(r.repoKey)) || 'dev',
@@ -14,7 +14,6 @@ const input = z.object({
14
14
  board: z.string(),
15
15
  ref: z.string().optional().describe("文档 refId(ref_<16hex>)"),
16
16
  path: z.string().optional().describe("外部文件/目录绝对路径(登记成 origin=external 的 ref)"),
17
- note: z.string().optional().describe("条目说明"),
18
17
  remove: z.number().optional().describe("移除第 N 条(1 起)"),
19
18
  before: z.number().optional().describe("插到第 N 条之前(缺省追加到末尾)"),
20
19
  });
@@ -24,7 +23,7 @@ export class DocsLinkAction extends ActionBase<typeof input> {
24
23
  id: 'docs.link',
25
24
  cli: ['docs', 'link'],
26
25
  http: ['POST', '/api/docs/link'],
27
- summary: '维护组的附加文档列表(--ref <refId> | --path <外部路径> + --note;--remove <序号> 移除;--before <序号> 插位;同 ref 重复添加 = 更新)',
26
+ summary: '维护组的附加文档列表(--ref <refId> | --path <外部路径>;--remove <序号> 移除;--before <序号> 插位;同 ref 重复添加 = 移位)',
28
27
  args: ['board'],
29
28
  input,
30
29
  render: renderLink,
@@ -0,0 +1,39 @@
1
+ // docs.main —— 把某一篇设为宿主的**主篇**(#144)。
2
+ //
3
+ // 与 docs.bind 的分工:
4
+ // · `docs bind` 是「指定主篇指针」的老命令,只换指针、不动附加篇(CLI 专用);
5
+ // · `docs main` 是**换位**:目标从附加篇摘出、原主篇退回附加篇,两边都不丢归属。
6
+ // 面板的「⋯ → 设为主篇」走这条(面板只认真实语义,不制造孤儿文档)。
7
+ //
8
+ // 宿主:`--repo <仓库>` 或 `--board <组>`(二选一);目标是 `--ref <refId>` 或 `--path`。
9
+ import { action } from '../../../runtime/action-decorator.js';
10
+ import { z } from 'zod';
11
+ import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
12
+ import * as refsNs from '../refs.js';
13
+ const refs: any = refsNs;
14
+
15
+ /** docs.main 的入参契约(CLI 与 HTTP 共用同一份)。 */
16
+ const input = z.object({
17
+ repo: z.string().optional().describe('仓库(id / key / 名称)——与 --board 二选一'),
18
+ board: z.string().optional().describe('项目组(id / key / 名称)——与 --repo 二选一'),
19
+ ref: z.string().optional().describe('文档 refId(ref_<16hex>)'),
20
+ path: z.string().optional().describe('外部文件绝对路径(会登记成 origin=external 的 ref)'),
21
+ });
22
+
23
+ export class DocsMainAction extends ActionBase<typeof input> {
24
+ @action({
25
+ id: 'docs.main',
26
+ cli: ['docs', 'main'],
27
+ http: ['POST', '/api/docs/main'],
28
+ summary: '把某一篇设为主篇:原主篇退回附加篇(不丢归属),目标从附加篇摘出(不会出现两份)',
29
+ input,
30
+ render: (d: any) => (
31
+ d && d.alreadyMain
32
+ ? `已经是主篇: ${d.name}`
33
+ : `已设为主篇: ${d.name}(原主篇${d.previous ? ` ${d.previous} ` : ' '}退回附加篇;列表共 ${d.count} 篇)`
34
+ ),
35
+ })
36
+ override async run(ctx: ActionInput<this['_input']>) {
37
+ return refs.setDocMain(ctx);
38
+ }
39
+ }
@@ -15,7 +15,6 @@ import {
15
15
  registerMdfile,
16
16
  registerFolder,
17
17
  unlinkAttachment,
18
- updateAttachmentNote,
19
18
  upsertFileAttachment,
20
19
  } from '../../core/attachmentdb.js';
21
20
  import type { LinkedAttachmentView } from '../../core/attachmentdb/query.js';
@@ -88,7 +87,6 @@ export interface AttachToDocCtx {
88
87
  /** 本地文件夹(登记为 kind=folder,只存路径) */
89
88
  folder?: unknown;
90
89
  noEmbed?: unknown;
91
- note?: unknown;
92
90
  [key: string]: unknown;
93
91
  }
94
92
 
@@ -209,7 +207,7 @@ export async function attachToDoc(ctx: AttachToDocCtx): Promise<AttachToDocResul
209
207
  if (noEmbed) {
210
208
  tx(
211
209
  (conn) => {
212
- linkAttachment(conn, { host: 'ref', hostId: hostRefId, attachmentId, role: 'attach', note: ctx.note as string | undefined });
210
+ linkAttachment(conn, { host: 'ref', hostId: hostRefId, attachmentId, role: 'attach' });
213
211
  },
214
212
  { db, mode: 'IMMEDIATE' }
215
213
  );
@@ -230,39 +228,6 @@ export async function attachToDoc(ctx: AttachToDocCtx): Promise<AttachToDocResul
230
228
  };
231
229
  }
232
230
 
233
- /** docs attach --note 的入参。 */
234
- export interface NoteOnDocInput {
235
- ref?: unknown;
236
- attachment?: unknown;
237
- note?: unknown;
238
- }
239
-
240
- /** docs attach --note 的出参。 */
241
- export interface NoteOnDocResult {
242
- refId: string;
243
- attachment: string;
244
- note: string;
245
- }
246
-
247
- /**
248
- * 改一条文档侧绑定上的说明(desc,#168):与任务侧同一口径——只动 note。
249
- */
250
- export async function noteOnDoc({ ref, attachment, note = '' }: NoteOnDocInput = {}): Promise<NoteOnDocResult> {
251
- const { refId } = await docRefOf(ref);
252
- const attId = String(attachment || '').trim();
253
- if (!attId) throw badInput('需要 --attachment <资源 id>(见 docs attachments 输出)');
254
- const db = getDb();
255
- let changed = 0;
256
- tx(
257
- (conn) => {
258
- changed = updateAttachmentNote(conn, { host: 'ref', hostId: refId, attachmentId: attId, note: note as string | undefined });
259
- },
260
- { db, mode: 'IMMEDIATE' }
261
- );
262
- if (!changed) throw badInput(`这篇文档上没有附件 ${attId}`);
263
- return { refId, attachment: attId, note: String(note || '') };
264
- }
265
-
266
231
  /** docs detach 的入参。 */
267
232
  export interface DetachFromDocInput {
268
233
  ref?: unknown;
@@ -35,7 +35,7 @@ export function boundDocs({ repoKey = '', groupKey = '' }: { repoKey?: string; g
35
35
  const group = String(groupKey || '').trim();
36
36
  if (!repo && !group) return [];
37
37
  const rows: any[] = getDb().all(
38
- `SELECT b.type, b.repo_key, b.group_key, b.position, b.note,
38
+ `SELECT b.type, b.repo_key, b.group_key, b.position,
39
39
  r.id AS ref_id, r."desc", r.origin,
40
40
  CASE WHEN rb.ref_id IS NULL THEN 0 ELSE 1 END AS has_body,
41
41
  rb.body
@@ -67,7 +67,7 @@ export function boundDocs({ repoKey = '', groupKey = '' }: { repoKey?: string; g
67
67
  repoKey: String(x.repo_key || ''),
68
68
  groupKey: x.group_key == null ? null : String(x.group_key),
69
69
  position,
70
- note: String(x.note || ''),
70
+ note: '', // v13 起 ref_bindings 无 note 列;字段保留仅为兼容旧调用方
71
71
  body,
72
72
  };
73
73
  });
@@ -45,7 +45,6 @@ export interface DocBriefView {
45
45
  desc: string;
46
46
  /** 正文摘要(首个非标题行);没有正文时为空 */
47
47
  summary: string;
48
- note: string;
49
48
  /** 有正文(外部镜像也算存在:正文在库外) */
50
49
  exists: boolean;
51
50
  missing?: boolean;
@@ -103,7 +102,6 @@ export async function docSetOf(owner: any, _kind: 'repo' | 'board' = 'repo'): Pr
103
102
  title,
104
103
  desc: row.desc,
105
104
  summary: body ? summaryFromMd(body) : '',
106
- note: String((raw && raw.note) || ''),
107
105
  exists: row.hasBody || row.origin === 'external',
108
106
  ...(row.hasBody || row.origin === 'external' ? {} : { missing: true }),
109
107
  };
@@ -10,17 +10,16 @@
10
10
  import { badInput } from '../../core/errors.js';
11
11
 
12
12
  /**
13
- * DocRef:{ ref } 指向文档库条目;note 是列表条目的注解(docLinks 用)。
13
+ * DocRef:{ ref } 指向文档库条目。
14
14
  *
15
- * #137 之前还有 `tag`(分类标签)——面板没有入口、无处可用,已在 v12 整个删掉。
15
+ * #137 的 `tag` 已在 v12 删掉;#148 的 `note`(列表条目注解)在 v13 删掉——
16
+ * 描述走 ref 自己的 desc + 正文标题,关系表不再挂业务字段。
16
17
  */
17
18
  export interface DocRef {
18
19
  ref?: string;
19
- /** 链接级注解(note,docLinks 条目用) */
20
- note?: string;
21
20
  }
22
21
 
23
- /** DocRef + 链接级注解(withLinkMeta 的产出形状)。 */
22
+ /** 兼容旧调用方的类型别名(现在与 DocRef 同形)。 */
24
23
  export type DocRefWithMeta = DocRef;
25
24
 
26
25
  const REF_ID_RE = /^ref_[0-9a-f]{16}$/i;
@@ -52,18 +51,9 @@ export function sanitizeDocRef(raw: unknown): DocRef | null {
52
51
  }
53
52
  }
54
53
 
55
- /**
56
- * DocRef + 链接级注解(note)合成列表条目。
57
- *
58
- * 注解要过三道关(写入口合并 / 读归一化回贴 / 导出保留),三处口径必须一致——
59
- * 实现只此一份,docs/refs 与 repos/service、transfer 都从这里拿。
60
- * 空串/缺省 = 不落字段(对已有条目即「清掉」)。
61
- */
62
- export function withLinkMeta(ref: DocRef, raw: { note?: unknown } = {}): DocRefWithMeta {
63
- const note = typeof raw.note === 'string' ? raw.note.trim() : '';
64
- const entry: DocRefWithMeta = { ...ref };
65
- if (note) entry.note = note;
66
- return entry;
54
+ /** 归一化一条文档条目(v13 去 note 后就是浅拷贝,保留名字让调用方语义统一)。 */
55
+ export function withLinkMeta(ref: DocRef): DocRefWithMeta {
56
+ return { ...ref };
67
57
  }
68
58
 
69
59
  // ─── docId(前后端统一寻址)────────────────────────────────────────────
@@ -40,7 +40,7 @@ export function renderRepoKnowledgeMd(k: RepoKnowledgeResult): string {
40
40
  heading('## 参考仓库');
41
41
  for (const r of k.refRepos) {
42
42
  const src = r.direct && !r.groups.length ? '[直接绑定]' : r.direct ? '[组 + 直接绑定]' : '';
43
- lines.push(`- ${r.name}${r.remote ? `(${r.remote})` : ''}${src}${r.note ? ` —— ${r.note.split('\n')[0] ?? ''}` : ''}`);
43
+ lines.push(`- ${r.name}${r.remote ? `(${r.remote})` : ''}${src}`);
44
44
  }
45
45
  }
46
46
  return lines.join('\n');
@@ -9,6 +9,7 @@ import { reposBridge } from './repos-bridge.js';
9
9
  import { getDb } from '../../core/db/index.js';
10
10
  import { refDocById } from '../../core/attachmentdb.js';
11
11
  import { renderRepoKnowledgeMd } from './knowledge-md.js';
12
+ import { docTitleFromMd } from '../../shared/doc-title.js';
12
13
  import type { DocRef } from './docref.js';
13
14
 
14
15
  const MAX_DOC_BYTES = 256 * 1024;
@@ -53,7 +54,6 @@ export interface RefRepoItem {
53
54
  name: string;
54
55
  path: string;
55
56
  remote: string;
56
- note: string;
57
57
  groups: string[];
58
58
  direct: boolean;
59
59
  }
@@ -145,7 +145,7 @@ async function readRefDocs(raw: DocRef | null | undefined, opts: ReadOpts): Prom
145
145
  }
146
146
  return docs;
147
147
  }
148
- return [{ ...one, refId, note: String((raw && raw.note) || '') }];
148
+ return [{ ...one, refId }];
149
149
  }
150
150
  if (!row.hasBody) {
151
151
  return [{
@@ -153,13 +153,11 @@ async function readRefDocs(raw: DocRef | null | undefined, opts: ReadOpts): Prom
153
153
  refId,
154
154
  docId: 'ref:' + refId,
155
155
  title: row.desc,
156
- note: String((raw && raw.note) || ''),
157
156
  }];
158
157
  }
159
158
  return [{
160
159
  ...docOut('ref:' + refId, row.body ?? '', opts),
161
160
  refId,
162
- note: String((raw && raw.note) || ''),
163
161
  }];
164
162
  }
165
163
 
@@ -230,10 +228,9 @@ export async function repoKnowledge(locator?: string, { md = false }: { md?: boo
230
228
  const hit = seenRefRepos.get(l.id);
231
229
  if (hit) {
232
230
  if (!hit.groups.includes(b.name)) hit.groups.push(b.name);
233
- if (l.note && !hit.note) hit.note = l.note;
234
231
  continue;
235
232
  }
236
- const item: RefRepoItem = { name: r.name, path: r.path || '', remote: r.remote || '', note: l.note || '', groups: [b.name], direct: false };
233
+ const item: RefRepoItem = { name: r.name, path: r.path || '', remote: r.remote || '', groups: [b.name], direct: false };
237
234
  seenRefRepos.set(l.id, item);
238
235
  refRepos.push(item);
239
236
  }
@@ -246,10 +243,9 @@ export async function repoKnowledge(locator?: string, { md = false }: { md?: boo
246
243
  const hit = seenRefRepos.get(id);
247
244
  if (hit) {
248
245
  hit.direct = true;
249
- if (l.note && !hit.note) hit.note = l.note;
250
246
  continue;
251
247
  }
252
- const item: RefRepoItem = { name: r.name, path: r.path || '', remote: r.remote || '', note: l.note || '', groups: [], direct: true };
248
+ const item: RefRepoItem = { name: r.name, path: r.path || '', remote: r.remote || '', groups: [], direct: true };
253
249
  seenRefRepos.set(id, item);
254
250
  refRepos.push(item);
255
251
  }
@@ -295,31 +291,36 @@ export async function groupContextFor(cwd: unknown, { board = '' }: { board?: st
295
291
  refId: (repoMain && repoMain.refId) || '',
296
292
  desc: '',
297
293
  };
298
- const repoDocLinks: BoundDoc[] = (Array.isArray(repo.docLinks) ? repo.docLinks : []).map((l: any) => ({
299
- refId: String(l.ref || ''),
300
- desc: String(l.note || ''),
301
- title: '',
302
- hasBody: true,
303
- origin: '',
304
- type: 'repo' as const,
305
- repoKey: rk,
306
- groupKey: null,
307
- position: 0,
308
- note: String(l.note || ''),
309
- body: '',
310
- }));
294
+ // #148:补充篇的 title/desc 必须从 refs 查真实值——原来写死 title:''、desc:note,
295
+ // 模板里 {{title}} 永远空、{{desc}} 拿到的是 note。DB 查不到时留空由模板回落。
296
+ const repoDocLinks: BoundDoc[] = (Array.isArray(repo.docLinks) ? repo.docLinks : []).map((l: any) => {
297
+ const refId = String(l.ref || '');
298
+ const d = refDocById(getDb(), refId);
299
+ return {
300
+ refId,
301
+ desc: String((d && d.desc) || ''),
302
+ title: d && d.hasBody ? docTitleFromMd(String(d.body ?? '')) : '',
303
+ hasBody: !!(d && (d.hasBody || d.origin === 'external')),
304
+ origin: '',
305
+ type: 'repo' as const,
306
+ repoKey: rk,
307
+ groupKey: null,
308
+ position: 0,
309
+ body: '',
310
+ };
311
+ });
311
312
 
312
313
  // 参考仓库(repos 里 type=ref,不是文档库 refs):本仓库直接绑定与组级绑定
313
- // 是两类并列来源,交付时要给「名称 + 本机路径 + 一句描述」。
314
- const refRepoItemOf = (id: unknown, note?: string): { key: string; name: string; path: string; note: string } | null => {
314
+ // 是两类并列来源,交付时给「名称 + 本机路径」;说明走绑定 ref 的文档列表(v13)。
315
+ const refRepoItemOf = (id: unknown): { key: string; name: string; path: string } | null => {
315
316
  const rr = s.repos.find((x: any) => x.type === 'ref' && deriveKey(x) === String(id));
316
317
  if (!rr) return null;
317
- return { key: String(id), name: rr.name, path: rr.path || '', note: note || '' };
318
+ return { key: String(id), name: rr.name, path: rr.path || '' };
318
319
  };
319
320
  const repoRefRepos = (Array.isArray(repo.linked) ? repo.linked : [])
320
321
  .filter((l: any) => l && l.kind === 'ref')
321
- .map((l: any) => refRepoItemOf(l.id, l.note))
322
- .filter(Boolean) as Array<{ key: string; name: string; path: string; note: string }>;
322
+ .map((l: any) => refRepoItemOf(l.id))
323
+ .filter(Boolean) as Array<{ key: string; name: string; path: string }>;
323
324
 
324
325
  // #64 作用域:只有组任务(正文 frontmatter 带 board)才挂组上下文。
325
326
  const wantBoard = String(board || '').trim();
@@ -338,19 +339,22 @@ export async function groupContextFor(cwd: unknown, { board = '' }: { board?: st
338
339
  refId: (gMain && gMain.refId) || '',
339
340
  desc: '',
340
341
  };
341
- const docLinks: BoundDoc[] = (Array.isArray(b.docLinks) ? b.docLinks : []).map((l: any) => ({
342
- refId: String(l.ref || ''),
343
- desc: String(l.note || ''),
344
- title: '',
345
- hasBody: true,
346
- origin: '',
347
- type: 'group' as const,
348
- repoKey: gkey,
349
- groupKey: null,
350
- position: 0,
351
- note: String(l.note || ''),
352
- body: '',
353
- }));
342
+ const docLinks: BoundDoc[] = (Array.isArray(b.docLinks) ? b.docLinks : []).map((l: any) => {
343
+ const refId = String(l.ref || '');
344
+ const d = refDocById(getDb(), refId);
345
+ return {
346
+ refId,
347
+ desc: String((d && d.desc) || ''),
348
+ title: d && d.hasBody ? docTitleFromMd(String(d.body ?? '')) : '',
349
+ hasBody: !!(d && (d.hasBody || d.origin === 'external')),
350
+ origin: '',
351
+ type: 'group' as const,
352
+ repoKey: gkey,
353
+ groupKey: null,
354
+ position: 0,
355
+ body: '',
356
+ };
357
+ });
354
358
  // 本项目在组里的位置
355
359
  const noteDocs = await readRefDocs((b.repoDocs || {})[rk], { warnings, label: `组内描述·${b.name}` });
356
360
  const noteOwn = noteDocs[0] || null;
@@ -364,7 +368,7 @@ export async function groupContextFor(cwd: unknown, { board = '' }: { board?: st
364
368
  const peer = peerDocs[0];
365
369
  peers.push({
366
370
  name: mname,
367
- note: (peer && peer.body) || (b.repoNotes || {})[mkey] || '',
371
+ note: (peer && peer.body) || '',
368
372
  path: (mr && mr.path) || '',
369
373
  });
370
374
  }
@@ -374,10 +378,10 @@ export async function groupContextFor(cwd: unknown, { board = '' }: { board?: st
374
378
  desc: b.desc || '',
375
379
  intro,
376
380
  introSet: { main: null, extras: [], count: 0 },
377
- note: ((noteOwn && noteOwn.body) || (b.repoNotes || {})[rk] || ''),
381
+ note: (noteOwn && noteOwn.body) || '',
378
382
  peers,
379
383
  docLinks,
380
- refRepos: (Array.isArray(b.refs) ? b.refs : []).map((l: any) => refRepoItemOf(l.id, l.note)).filter(Boolean) as Array<{ key: string; name: string; path: string; note: string }>,
384
+ refRepos: (Array.isArray(b.refs) ? b.refs : []).map((l: any) => refRepoItemOf(l.id)).filter(Boolean) as Array<{ key: string; name: string; path: string }>,
381
385
  });
382
386
  }
383
387
  return {
@@ -405,7 +409,7 @@ export interface GroupContextGroup {
405
409
  note: string;
406
410
  peers: Array<{ name: string; path: string; note: string }>;
407
411
  docLinks: BoundDoc[];
408
- refRepos: Array<{ key: string; name: string; path: string; note: string }>;
412
+ refRepos: Array<{ key: string; name: string; path: string }>;
409
413
  }
410
414
 
411
415
  /** groupContextFor 的出参。 */
@@ -416,7 +420,7 @@ export interface GroupContextResult {
416
420
  intro: ContextIntro;
417
421
  introSet: IntroSet;
418
422
  docLinks: BoundDoc[];
419
- refRepos: Array<{ key: string; name: string; path: string; note: string }>;
423
+ refRepos: Array<{ key: string; name: string; path: string }>;
420
424
  };
421
425
  groups: GroupContextGroup[];
422
426
  }
@@ -432,6 +436,5 @@ interface BoundDoc {
432
436
  repoKey: string;
433
437
  groupKey: string | null;
434
438
  position: number;
435
- note: string;
436
439
  body: string;
437
440
  }
@@ -21,7 +21,6 @@ interface DesiredBinding {
21
21
  type: 'repo' | 'group' | 'group_repo';
22
22
  refId: string;
23
23
  position: number;
24
- note: string;
25
24
  }
26
25
 
27
26
  export interface SyncRefIndexInput {
@@ -43,8 +42,7 @@ export function desiredBindings(s: any): DesiredBinding[] {
43
42
  groupKey: string | null,
44
43
  type: DesiredBinding['type'],
45
44
  raw: any,
46
- position: number,
47
- note = ''
45
+ position: number
48
46
  ): void => {
49
47
  const refId = String((raw && raw.ref) || '').trim();
50
48
  if (!refId) return;
@@ -54,7 +52,6 @@ export function desiredBindings(s: any): DesiredBinding[] {
54
52
  type,
55
53
  refId,
56
54
  position: Number(position) || 0,
57
- note: String((raw && raw.note) ?? note ?? ''),
58
55
  });
59
56
  };
60
57
 
@@ -111,7 +108,6 @@ export async function syncRefIndex({ store: s }: SyncRefIndexInput = {}): Promis
111
108
  refId: b.refId,
112
109
  type: b.type,
113
110
  position: b.position,
114
- note: b.note,
115
111
  });
116
112
  markRefBound(conn, b.refId);
117
113
  n += 1;
@@ -94,6 +94,81 @@ export async function setDocRef({ repo, board, ref, path, reset }: SetDocRefInpu
94
94
  return res;
95
95
  }
96
96
 
97
+ /** setDocMain 的入参:宿主(repo / board 二选一)+ 目标文档(ref / path)。 */
98
+ export interface SetDocMainInput {
99
+ repo?: unknown;
100
+ board?: unknown;
101
+ ref?: unknown;
102
+ path?: unknown;
103
+ }
104
+
105
+ /**
106
+ * 把某一篇设成宿主的**主篇**(#144)。
107
+ *
108
+ * 与 `docs bind` 的差别(用户视角正是这一点):这是**换位**,不是覆盖——
109
+ * · 目标那篇如果已经在附加篇(docLinks)里,先把它摘出来,避免同一篇出现两次;
110
+ * · 原主篇还在、且不是目标 → 挪到 docLinks 头部,**保住它的归属**
111
+ * (`docs bind` 会直接把原主篇甩成孤儿,3 天后被清理);
112
+ * · 目标没绑在这个宿主上 → 显式报错,先加进列表(不做「顺手加一篇」的隐式行为)。
113
+ *
114
+ * 宿主 = 仓库(repo.doc/docLinks)或组(board.doc/docLinks);组内仓库描述
115
+ * (board.repoDocs)不在这个语义里。
116
+ */
117
+ export async function setDocMain({ repo, board, ref, path }: SetDocMainInput = {}): Promise<any> {
118
+ if (!!repo === !!board) throw badInput('请给 --repo <仓库> 或 --board <看板>(二选一)');
119
+ const docRef = await docRefOf({ ref, path });
120
+ const { mutateStore, deriveKey, boardKeyOf } = await reposBridge();
121
+ const nk = { normalizeKey, boardKeyOf };
122
+ const repoKeyIn = makeRepoKeyIn({ normalizeKey, deriveKey });
123
+ const res = await mutateStore((s: any) => {
124
+ const host = repo
125
+ ? (() => {
126
+ const rkey = repoKeyIn(s, repo);
127
+ if (!rkey) throw notFound('repo 不存在: ' + String(repo));
128
+ const r = s.repos.find((x: any) => deriveKey(x) === rkey);
129
+ if (!r) throw notFound('repo 不存在: ' + String(repo));
130
+ return r;
131
+ })()
132
+ : (() => {
133
+ const b = findBoardIn(s, board, nk);
134
+ if (!b) throw notFound('看板不存在: ' + String(board));
135
+ return b;
136
+ })();
137
+ const links: any[] = Array.isArray(host.docLinks) ? host.docLinks : [];
138
+ const inLinks = links.findIndex((x: any) => x && x.ref === docRef.ref);
139
+ const isMain = !!(host.doc && host.doc.ref === docRef.ref);
140
+ if (isMain && inLinks < 0) {
141
+ return { changed: false, alreadyMain: true, name: host.name, key: deriveKey(host), ref: docRef.ref };
142
+ }
143
+ // 目标必须已经在这个宿主的文档列表里(主篇或附加篇)。不在这里就显式报错——
144
+ // 「顺手把它加成主篇」是隐式行为,会让列表凭空多一篇。
145
+ if (!isMain && inLinks < 0) {
146
+ throw conflict('这篇不在这个宿主的文档列表里:先加进去(repo doc add / docs link)再设主篇');
147
+ }
148
+ // ① 目标从附加篇里摘出来(同一篇不能既是主篇又在附加篇里)
149
+ if (inLinks >= 0) links.splice(inLinks, 1);
150
+ // ② 原主篇退回附加篇头部(保住归属;只有它还在、且不是目标时才动)
151
+ const prev = host.doc;
152
+ if (prev && prev.ref && prev.ref !== docRef.ref) links.unshift(prev);
153
+ // ③ 目标上位
154
+ host.doc = docRef;
155
+ if (links.length) host.docLinks = links;
156
+ else delete host.docLinks;
157
+ host.updatedAt = new Date().toISOString();
158
+ return {
159
+ changed: true,
160
+ alreadyMain: false,
161
+ name: host.name,
162
+ key: deriveKey(host),
163
+ ref: docRef.ref,
164
+ previous: prev && prev.ref ? prev.ref : '',
165
+ count: links.length + 1,
166
+ };
167
+ });
168
+ await syncRefIndex();
169
+ return res;
170
+ }
171
+
97
172
  /** setNoteDocRef 的入参。 */
98
173
  export interface SetNoteDocRefInput {
99
174
  board?: string;
@@ -138,7 +213,6 @@ export interface SetDocLinkInput {
138
213
  board?: string;
139
214
  ref?: string;
140
215
  path?: string;
141
- note?: string;
142
216
  remove?: number;
143
217
  before?: number;
144
218
  }
@@ -146,13 +220,12 @@ export interface SetDocLinkInput {
146
220
  /**
147
221
  * 维护组的 docLinks。
148
222
  * --ref <refId> 或 --path <绝对路径>(外部只读)
149
- * note 条目注解
150
223
  * remove --remove <序号>(1 起)
151
224
  * before --before <序号>(插到该条之前;缺省追加)
152
225
  *
153
- * 同 ref 重复添加 = 更新该条(note 以本次为准)。
226
+ * 同 ref 重复添加 = 把该条移到新位置。
154
227
  */
155
- export async function setDocLink({ board, ref, path, note, remove, before }: SetDocLinkInput = {}): Promise<any> {
228
+ export async function setDocLink({ board, ref, path, remove, before }: SetDocLinkInput = {}): Promise<any> {
156
229
  if (!board) throw badInput('缺少看板(id / key / 名称)');
157
230
  const { mutateStore, boardKeyOf } = await reposBridge();
158
231
  const docRef = remove === undefined ? await docRefOf({ ref, path }) : null;
@@ -174,8 +247,8 @@ export async function setDocLink({ board, ref, path, note, remove, before }: Set
174
247
  return { boardName: b.name, removed: describeLink(gone), count: b.docLinks.length };
175
248
  }
176
249
 
177
- // 条目 = DocRef + 注解(note);合成逻辑收在 docref.withLinkMeta
178
- const entry = withLinkMeta(docRef!, { note });
250
+ // 条目 = DocRef(去 note 后只剩 ref 本体)
251
+ const entry = withLinkMeta(docRef!);
179
252
  const at = b.docLinks.findIndex((x: any) => (x && x.ref) === entry.ref);
180
253
  if (at >= 0) b.docLinks.splice(at, 1);
181
254
  const want = before !== undefined ? idxOf(before) : -1;
@@ -216,20 +289,19 @@ export async function listRepoDocs(locator: string): Promise<any> {
216
289
  };
217
290
  }
218
291
 
219
- /** addRepoDoc 的入参(refId 或外部路径 + 可选注解)。 */
292
+ /** addRepoDoc 的入参(refId 或外部路径)。 */
220
293
  export interface AddRepoDocInput {
221
294
  ref?: string;
222
295
  path?: string;
223
- note?: string;
224
296
  }
225
297
 
226
- /** 往项目的介绍文档集里加一篇(同 ref 重复添加 = 更新注解)。 */
298
+ /** 往项目的介绍文档集里加一篇(同 ref 重复添加 = 移到末尾)。 */
227
299
  export async function addRepoDoc(locator: string, raw: unknown): Promise<any> {
228
300
  const { getRepo, deriveKey, mutateStore } = await reposBridge();
229
301
  const repo = await getRepo(locator);
230
302
  const input = (raw && typeof raw === 'object' ? raw : {}) as AddRepoDocInput;
231
303
  const docRef = await docRefOf({ ref: input.ref, path: input.path });
232
- const entry = withLinkMeta(docRef, { note: input.note });
304
+ const entry = withLinkMeta(docRef);
233
305
  const res = await mutateStore((s: any) => {
234
306
  const r = s.repos.find((x: any) => deriveKey(x) === deriveKey(repo));
235
307
  if (!r) throw notFound('repo 不存在: ' + locator);
@@ -81,7 +81,6 @@ export interface RefBindingView {
81
81
  repoKey: string;
82
82
  groupKey: string | null;
83
83
  position: number;
84
- note: string;
85
84
  main: boolean;
86
85
  }
87
86
 
@@ -197,7 +196,7 @@ function bindingsOfRef(refId: string): RefBindingView[] {
197
196
  if (!clean(refId)) return [];
198
197
  return getDb()
199
198
  .all(
200
- `SELECT type, repo_key AS repoKey, group_key AS groupKey, position, note
199
+ `SELECT type, repo_key AS repoKey, group_key AS groupKey, position
201
200
  FROM ref_bindings WHERE ref_id = :id ORDER BY type, position`,
202
201
  { id: refId }
203
202
  )
@@ -206,7 +205,6 @@ function bindingsOfRef(refId: string): RefBindingView[] {
206
205
  repoKey: String(r.repoKey),
207
206
  groupKey: r.groupKey == null ? null : String(r.groupKey),
208
207
  position: Number(r.position) || 0,
209
- note: String(r.note || ''),
210
208
  main: (Number(r.position) || 0) === 0,
211
209
  }));
212
210
  }