nx-kv 0.66.2 → 0.66.3
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.
- package/CHANGELOG.md +38 -0
- package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +1 -1
- package/package.json +1 -1
- package/src/core/attachmentdb/ids.ts +14 -1
- package/src/core/attachmentdb/query.ts +0 -38
- package/src/core/attachmentdb/repo.ts +98 -0
- package/src/core/attachmentdb.ts +5 -1
- package/src/core/db/migrations/index.ts +2 -0
- package/src/core/db/migrations/v15.sql +88 -0
- package/src/core/db/version.ts +4 -1
- package/src/modules/claim/assemble.ts +0 -5
- package/src/modules/claim/host.ts +1 -3
- package/src/modules/claim/preview.ts +0 -1
- package/src/modules/docs/actions/docs-detach.ts +1 -2
- package/src/modules/docs/attach.ts +3 -17
- package/src/modules/docs/render.ts +4 -13
- package/src/modules/localtask/actions/localtask-attach.ts +4 -2
- package/src/modules/localtask/actions/localtask-config.ts +2 -11
- package/src/modules/localtask/actions/localtask-detach.ts +1 -3
- package/src/modules/localtask/infra/repo/settings.ts +1 -9
- package/src/modules/localtask/lifecycle/task-templates.ts +0 -13
- package/src/modules/localtask/lifecycle/topics.ts +3 -6
- package/src/modules/localtask/ops/attach-resource.ts +46 -4
- package/src/modules/localtask/ops/attach-template.ts +73 -3
- package/src/modules/localtask/ops/attach.ts +45 -18
- package/src/modules/localtask/ui/action-render.ts +3 -12
- package/src/modules/promptplug/compose.ts +1 -3
- package/src/modules/promptplug/plugins/attachment.ts +56 -6
- package/src/modules/promptplug/plugins/context.ts +11 -2
- package/src/modules/promptplug/template-store.ts +25 -3
- package/src/shared/prompt-blocks.ts +2 -23
- package/src/web/frontend/api/cli-tree.json +4 -4
- package/src/web/frontend/api/client.generated.ts +8 -8
- package/src/web/frontend/api/tasks.ts +117 -0
- package/src/web/frontend/components/Introduction/index.tsx +50 -3
- package/src/web/frontend/components/Introduction/style.css +6 -0
- package/src/web/frontend/components/Introduction/use-intro.ts +25 -0
- package/src/web/frontend/components/md/attachments/attach-area.tsx +9 -11
- package/src/web/frontend/components/md/attachments/attach-common.ts +12 -5
- package/src/web/frontend/components/md/attachments/attach-modal.tsx +54 -9
- package/src/web/frontend/components/md/attachments/attach-repo-pick.tsx +48 -0
- package/src/web/frontend/components/sidebar/task-children.tsx +14 -11
- package/src/web/frontend/{page/dir → components/task-panel}/dag-editor.tsx +1 -1
- package/src/web/frontend/components/task-panel/task-ops.ts +299 -0
- package/src/web/frontend/components/task-panel/task-page.tsx +495 -0
- package/src/web/frontend/components/tool-acts/modules.ts +3 -0
- package/src/web/frontend/page/dir/api.ts +4 -108
- package/src/web/frontend/page/dir/index.tsx +148 -331
- package/src/web/frontend/page/dir/task-board-section.tsx +3 -0
- package/src/web/frontend/page/dir/task-dock-panel.tsx +1 -1
- package/src/web/frontend/page/dir/task.tsx +1 -1
- package/src/web/frontend/page/doc/doc-dock.tsx +1 -1
- package/src/web/frontend/page/group/api.ts +3 -21
- package/src/web/frontend/page/group/group-project-memo.ts +41 -0
- package/src/web/frontend/page/group/index.tsx +287 -426
- package/src/web/frontend/page/settings/api.ts +1 -2
- package/src/web/frontend/page/settings/prompt-templates-section.tsx +12 -44
- package/src/web/public/assets/{bar-Dy_QDX2h.js → bar-D7cWe7Kp.js} +1 -1
- package/src/web/public/assets/{composer-launch-B7DH53Yf.js → composer-launch--nJGFG35.js} +1 -1
- package/src/web/public/assets/{composer-panel-Cj1J16r-.js → composer-panel-Dhivt7UJ.js} +1 -1
- package/src/web/public/assets/{dag-DXRPHVl8.js → dag-DUhHxgTk.js} +1 -1
- package/src/web/public/assets/dir-CkYGYT9e.js +1 -0
- package/src/web/public/assets/doc-DgYKv2wo.css +1 -0
- package/src/web/public/assets/doc-QBHQi1EV.js +6 -0
- package/src/web/public/assets/group-CfJxWA7V.js +1 -0
- package/src/web/public/assets/group-project-memo-G-O6sPRw.js +1 -0
- package/src/web/public/assets/index-ByAPGidL.js +3 -0
- package/src/web/public/assets/{list-filter-CWxiOSg_.js → list-search-B2S2g8kn.js} +1 -1
- package/src/web/public/assets/md-history-DdM6P9Gq.js +47 -0
- package/src/web/public/assets/{progress-MPse2JLQ.js → progress-BVpSy-uF.js} +1 -1
- package/src/web/public/assets/refs-CCZgGPlL.js +2 -0
- package/src/web/public/assets/reopen-text-BC9a8KOp.js +13 -0
- package/src/web/public/assets/{repo-form-modal-CNLYR12c.js → repo-form-modal-D8WabN0R.js} +1 -1
- package/src/web/public/assets/{repos-BGx-yAXd.js → repos-V5xb5Kz-.js} +9 -9
- package/src/web/public/assets/settings-CAOSCF3E.js +1 -0
- package/src/web/public/assets/task-BwWlNP0i.js +13 -0
- package/src/web/public/assets/task-ops-DZgza5eZ.js +2 -0
- package/src/web/public/assets/task-utils--WIpAwUx.js +1 -0
- package/src/web/public/assets/{templates-Co1Qb1aA.js → templates-6ClSnYJN.js} +3 -3
- package/src/web/public/assets/{tool-bar-D5wLBLRl.js → tool-bar-BYdfBQeo.js} +1 -1
- package/src/web/public/assets/use-rail-drag-BMXJ48je.js +1 -0
- package/src/web/public/index.html +8 -8
- package/src/web/frontend/page/dir/landing.tsx +0 -553
- package/src/web/public/assets/dir-_M1ciSxM.js +0 -3
- package/src/web/public/assets/doc-Iuxssa-b.css +0 -1
- package/src/web/public/assets/doc-_iteSM2X.js +0 -6
- package/src/web/public/assets/get-loop-modal-DlAfqJMz.js +0 -2
- package/src/web/public/assets/group-CH8qe-eg.js +0 -1
- package/src/web/public/assets/index-Cui4IuGj.js +0 -3
- package/src/web/public/assets/md-history-Bj790fdn.js +0 -46
- package/src/web/public/assets/refs-DiIPoqnJ.js +0 -2
- package/src/web/public/assets/settings-Pt4YgGdY.js +0 -1
- package/src/web/public/assets/task-DOIIpQ4X.js +0 -13
- package/src/web/public/assets/task-utils-CJfMODCP.js +0 -13
- package/src/web/public/assets/use-rail-drag-CNOHXWng.js +0 -1
|
@@ -107,6 +107,9 @@ function groupHasContent(g: any): boolean {
|
|
|
107
107
|
if (!g) return false;
|
|
108
108
|
if (g.desc) return true;
|
|
109
109
|
if (g.intro && g.intro.body) return true;
|
|
110
|
+
// #185:组主篇只有 ref(正文未读 / 没写标题描述)也算有料——否则组上下文整段消失,
|
|
111
|
+
// 提示词里连「组介绍在哪取」都看不到。
|
|
112
|
+
if (g.intro && (g.intro.refId || g.intro.path)) return true;
|
|
110
113
|
if (g.docLinks && g.docLinks.length) return true;
|
|
111
114
|
return !!(g.refRepos && g.refRepos.length);
|
|
112
115
|
}
|
|
@@ -204,10 +207,16 @@ const BUILTIN: TemplateText = {
|
|
|
204
207
|
{{#if group.desc}}
|
|
205
208
|
组定位:{{group.desc}}
|
|
206
209
|
{{/if}}
|
|
210
|
+
{{#if group.intro}}
|
|
211
|
+
〔组介绍 · {{group.name}}〕
|
|
212
|
+
{{group.intro}}
|
|
213
|
+
{{/if}}
|
|
207
214
|
{{#if group.introRefId}}
|
|
208
|
-
|
|
215
|
+
组介绍文档:{{#if group.introDesc}}{{group.introDesc}}{{else}}(无标题 / 描述,按 ref 取全文){{/if}}
|
|
209
216
|
取用:nx-kv docs get --ref {{group.introRefId}}
|
|
210
|
-
{{
|
|
217
|
+
{{else}}{{#if group.intro}}{{else}}
|
|
218
|
+
组介绍:无(组主篇与 repo 主篇独立加载——repo 没主篇不影响这里,组有主篇时请补 ref)
|
|
219
|
+
{{/if}}{{/if}}
|
|
211
220
|
{{#if group.peers}}
|
|
212
221
|
组内成员:
|
|
213
222
|
{{#each group.peers}}
|
|
@@ -27,7 +27,7 @@ import { dbPath, openStore } from '../../core/db/index.js';
|
|
|
27
27
|
import { deleteSettingRaw, readSettingRaw, writeSettingRaw } from '../../core/db/settings.js';
|
|
28
28
|
import { tx } from '../../core/db/tx.js';
|
|
29
29
|
import type { DbApi } from '../../core/db/driver.js';
|
|
30
|
-
import { allPluginIds } from './registry.js';
|
|
30
|
+
import { allPluginIds, pluginMeta } from './registry.js';
|
|
31
31
|
import type { TemplateText } from './base.js';
|
|
32
32
|
|
|
33
33
|
/** 按段键的前缀(导出/清理可据此列举;读取只用精确键)。 */
|
|
@@ -280,10 +280,32 @@ export function activateTemplate(segment: string, id: string): SegmentTemplates
|
|
|
280
280
|
return cloneSegment(seg);
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
/**
|
|
283
|
+
/** 内置(出厂)模板正文:代码即真相,随发布实时更新。 */
|
|
284
|
+
export function builtinTemplateTextOf(id: string): string {
|
|
285
|
+
const p = pluginMeta(id);
|
|
286
|
+
const first = p?.templates?.[0];
|
|
287
|
+
return first ? String(first.text ?? '') : '';
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** 两份模板是否「实质相同」(忽略空白差异)。 */
|
|
291
|
+
function sameTemplate(a: string, b: string): boolean {
|
|
292
|
+
const norm = (x: string): string => String(x || '').replace(/\s+/g, ' ').trim();
|
|
293
|
+
return !!norm(a) && norm(a) === norm(b);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* 某段当前**启用模板的正文**(装配时传给插件构造;builtin → '' 用类内默认)。
|
|
298
|
+
*
|
|
299
|
+
* #185:**内置模板随代码发布更新**——用户若只是把内置「复制为新模板」却没改过,
|
|
300
|
+
* 副本文本与新版内置实质相同 → 这里返回 '' 直接跟随内置,不会卡在旧版本上。
|
|
301
|
+
* 只有真正自定义过的副本才用 `hit.text`。
|
|
302
|
+
*/
|
|
284
303
|
export function activeTemplateTextOf(id: string): string {
|
|
285
304
|
const seg = readSegment(id);
|
|
286
305
|
if (seg.activeId === 'builtin') return '';
|
|
287
306
|
const hit = seg.items.find((t) => t.id === seg.activeId);
|
|
288
|
-
|
|
307
|
+
if (!hit) return '';
|
|
308
|
+
const text = String(hit.text ?? '');
|
|
309
|
+
if (sameTemplate(text, builtinTemplateTextOf(id))) return '';
|
|
310
|
+
return text;
|
|
289
311
|
}
|
|
@@ -3,32 +3,11 @@
|
|
|
3
3
|
// **#152 起这里不再持有任何模板正文,也不再定义「每区块模板列表」。**
|
|
4
4
|
// 模板正文的唯一真相是插件类(modules/promptplug/plugins/*.ts 的 `templates`);
|
|
5
5
|
// 段落清单的唯一真相是注册表(modules/promptplug/registry.ts 的 PLUGIN_CLASSES)。
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// - 把已渲染的段落包进根标签(compose 的最后一步)。
|
|
6
|
+
// 本文件只剩一件跨端共享的纯逻辑:把已渲染的段落包进根标签(compose 的最后一步)。
|
|
7
|
+
// #186 起「追加方式」选择已删除——**固定 XML 区块**,不再有 plain 直拼。
|
|
9
8
|
//
|
|
10
9
|
// 区块标记是给 agent 读的「类 XML」分隔语法,不对正文做实体转义。
|
|
11
10
|
|
|
12
|
-
/** 追加模式条目。 */
|
|
13
|
-
export interface AppendMode {
|
|
14
|
-
id: string;
|
|
15
|
-
label: string;
|
|
16
|
-
desc: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** 追加模式:xml = 区块标记(默认);plain = 老行为,按空行直接拼正文。 */
|
|
20
|
-
export const APPEND_MODES: readonly AppendMode[] = Object.freeze([
|
|
21
|
-
{
|
|
22
|
-
id: 'xml',
|
|
23
|
-
label: 'XML 区块(默认)',
|
|
24
|
-
desc: '每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: 'plain',
|
|
28
|
-
label: '正文直追加',
|
|
29
|
-
desc: '不包标签,按空行拼接(与改造前的 instruction 逐字一致)',
|
|
30
|
-
},
|
|
31
|
-
]);
|
|
32
11
|
|
|
33
12
|
export const DEFAULT_APPEND_MODE = 'xml';
|
|
34
13
|
export const XML_ROOT_TAG = 'nx-kv';
|
|
@@ -885,7 +885,7 @@
|
|
|
885
885
|
"action": {
|
|
886
886
|
"id": "docs.detach",
|
|
887
887
|
"module": "docs",
|
|
888
|
-
"summary": "
|
|
888
|
+
"summary": "解除文档与附件的关系(#189:只解除关联;清理走库级 GC,不在这里删资源)",
|
|
889
889
|
"usage": "docs detach",
|
|
890
890
|
"http": "DELETE /api/docs/attach"
|
|
891
891
|
},
|
|
@@ -1193,7 +1193,7 @@
|
|
|
1193
1193
|
"action": {
|
|
1194
1194
|
"id": "localtask.attach",
|
|
1195
1195
|
"module": "localtask",
|
|
1196
|
-
"summary": "给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针)/ --folder
|
|
1196
|
+
"summary": "给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针)/ --folder(本地文件夹路径)/ --repo(已登记仓库);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文)",
|
|
1197
1197
|
"usage": "localtask attach",
|
|
1198
1198
|
"http": "POST /api/localtasks/attach"
|
|
1199
1199
|
},
|
|
@@ -1313,7 +1313,7 @@
|
|
|
1313
1313
|
"action": {
|
|
1314
1314
|
"id": "localtask.config",
|
|
1315
1315
|
"module": "localtask",
|
|
1316
|
-
"summary": "
|
|
1316
|
+
"summary": "配置等待超时(秒)(系统上下文固定 XML 区块;提示词模板正文固定在插件类里,不再可配)",
|
|
1317
1317
|
"usage": "localtask config",
|
|
1318
1318
|
"http": "PATCH /api/localtasks/setting"
|
|
1319
1319
|
},
|
|
@@ -1328,7 +1328,7 @@
|
|
|
1328
1328
|
"action": {
|
|
1329
1329
|
"id": "localtask.detach",
|
|
1330
1330
|
"module": "localtask",
|
|
1331
|
-
"summary": "
|
|
1331
|
+
"summary": "解除任务与附件的关系(#189:只解除关联,资源进孤儿池;清理走库级 GC,不在这里删资源)",
|
|
1332
1332
|
"usage": "localtask detach",
|
|
1333
1333
|
"http": "DELETE /api/localtasks/attach"
|
|
1334
1334
|
},
|
|
@@ -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
|
-
/**
|
|
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']>>>;
|
|
@@ -300,7 +300,7 @@ export interface ApiClient {
|
|
|
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
|
|
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
|
/** 列出某条任务引用的附件(正文里的  嵌入),以及本地是否已有(给 agent 直接读本地文件) */
|
|
306
306
|
localtaskAttachments(input: z.input<InstanceType<typeof LocaltaskAttachmentsAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAttachmentsAction>['run']>>>;
|
|
@@ -316,9 +316,9 @@ export interface ApiClient {
|
|
|
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
|
-
/**
|
|
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"]
|
|
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
|
|
@@ -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"]
|
|
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"]
|
|
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 }(全局池用 key=__GLOBAL__)。
|
|
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
|
|
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
|
|
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 (
|
|
301
|
+
const doRemove = async () => {
|
|
302
302
|
const item = removeOf;
|
|
303
303
|
if (!item) return;
|
|
304
304
|
setRemoving(true);
|
|
305
305
|
try {
|
|
306
|
-
|
|
306
|
+
// #189:只解除关联——不删资源行、不删字节(各 kind 删除语义不一致,统一交给 GC)
|
|
307
|
+
await ep.detach(item.id);
|
|
307
308
|
setRemoveOf(null);
|
|
308
|
-
toast(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
200
|
+
detach: (attachment) => api('/api/localtasks/attach', {
|
|
196
201
|
method: 'DELETE',
|
|
197
|
-
body: { id: Number(hostId), ...where, attachment
|
|
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
|
|
210
|
+
detach: (attachment) => api('/api/docs/attach', {
|
|
206
211
|
method: 'DELETE',
|
|
207
|
-
body: { ref: refId, attachment
|
|
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 }
|