nx-kv 0.59.0 → 0.60.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.
- package/CHANGELOG.md +35 -0
- package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +3 -2
- package/assets/nx-kv/references/A04-/344/273/223/345/272/223/344/270/216/351/241/271/347/233/256/347/273/204.md +2 -1
- package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +3 -3
- package/package.json +1 -1
- package/src/core/attachmentdb/docs.ts +3 -5
- package/src/core/db/import-json/refs.ts +2 -2
- package/src/core/db/migrations/index.ts +2 -0
- package/src/core/db/migrations/v12.sql +14 -0
- package/src/core/db/migrations/v8-data.ts +20 -4
- package/src/core/db/version.ts +3 -1
- package/src/modules/docs/actions/docs-bindings.ts +2 -3
- package/src/modules/docs/actions/docs-link.ts +1 -2
- package/src/modules/docs/brief.ts +0 -2
- package/src/modules/docs/docref.ts +8 -7
- package/src/modules/docs/knowledge.ts +1 -4
- package/src/modules/docs/ref-sync.ts +1 -5
- package/src/modules/docs/refs.ts +66 -8
- package/src/modules/docs/render.ts +1 -1
- package/src/modules/docs/service.ts +1 -3
- package/src/modules/repos/actions/repo-doc-add.ts +1 -2
- package/src/modules/repos/actions/repo-doc-list.ts +1 -1
- package/src/modules/repos/actions/repo-knowledge.ts +1 -1
- package/src/modules/repos/actions/repo-ref-note.ts +4 -4
- package/src/modules/repos/boards/core.ts +0 -3
- package/src/modules/repos/{link-note.ts → ref-note-doc.ts} +53 -29
- package/src/modules/repos/ref.ts +8 -36
- package/src/modules/repos/transfer/export.ts +3 -3
- package/src/modules/repos/transfer/layout.ts +3 -3
- package/src/modules/tasktool/delivery-template.ts +3 -4
- package/src/web/frontend/api/cli-tree.json +2 -2
- package/src/web/frontend/api/client.generated.ts +4 -4
- package/src/web/frontend/components/Introduction/use-intro.ts +2 -4
- package/src/web/frontend/modules/refs/api.ts +0 -1
- package/src/web/frontend/page/repos/index.tsx +1 -1
- package/src/web/frontend/refs/api.ts +0 -1
- package/src/web/public/assets/{composer-panel-MB_2m-jI.js → composer-panel-BhT_eFic.js} +1 -1
- package/src/web/public/assets/{dir-BQZAPk92.js → dir-1w7D_lg7.js} +1 -1
- package/src/web/public/assets/{doc-CKkCGsZ4.js → doc-Dn4-viog.js} +1 -1
- package/src/web/public/assets/{group-CXDiKp4X.js → group-BsvhgO5r.js} +1 -1
- package/src/web/public/assets/{index-Dmlh01et.js → index-CBVkXanT.js} +2 -2
- package/src/web/public/assets/{refs-DvvwZmdl.js → refs-BHzLZnJn.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-pyqiC7pB.js → repo-form-modal-BafSPVlv.js} +1 -1
- package/src/web/public/assets/{repos-CeyrjSQ_.js → repos-CmlsSN0h.js} +2 -2
- package/src/web/public/assets/{settings-KNodW2wX.js → settings-C_Dkc9gQ.js} +1 -1
- package/src/web/public/assets/{task-DJF54sKp.js → task-Ci94al50.js} +1 -1
- package/src/web/public/assets/{templates-BaX3bQsl.js → templates-Dc5Pln-Q.js} +1 -1
- package/src/web/public/index.html +3 -3
- package/src/modules/docs/link-note.ts +0 -171
|
@@ -25,7 +25,6 @@ export interface IntroMainOut {
|
|
|
25
25
|
title: string;
|
|
26
26
|
desc: string;
|
|
27
27
|
note: string;
|
|
28
|
-
tag: string;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
// 组内描述:同一个仓库在不同看板里的角色可以各不相同(「fr 组里它是 API 契约方」,
|
|
@@ -189,7 +188,6 @@ export async function getBoard(idOrKey: unknown): Promise<GetBoardResult> {
|
|
|
189
188
|
title: set.main.title,
|
|
190
189
|
desc: set.main.desc,
|
|
191
190
|
note: set.main.note,
|
|
192
|
-
tag: set.main.tag,
|
|
193
191
|
} : null,
|
|
194
192
|
introExtras: set.links.map((d) => ({
|
|
195
193
|
refId: d.refId,
|
|
@@ -197,7 +195,6 @@ export async function getBoard(idOrKey: unknown): Promise<GetBoardResult> {
|
|
|
197
195
|
title: d.title,
|
|
198
196
|
desc: d.desc,
|
|
199
197
|
note: d.note,
|
|
200
|
-
tag: d.tag,
|
|
201
198
|
name: d.title,
|
|
202
199
|
})),
|
|
203
200
|
introCount: set.count,
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
// 绑定描述(组 ↔ 参考仓库 / 开发仓库 ↔
|
|
1
|
+
// 绑定描述(组 ↔ 参考仓库 / 开发仓库 ↔ 参考仓库)= **参考仓库文档列表里的一篇文档**。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// #137:原来这套机制靠 `ref_bindings.tag = link-note:<关系 key>` 定位「这条关系的那一篇」,
|
|
4
|
+
// 那其实是把**分类标签**(一个没有入口、没人用的无效概念)当成了定位器。
|
|
5
|
+
// 现在定位回归它本来的样子:**desc 就在 ref 上**——
|
|
6
|
+
// 同一条关系 = 该参考仓库文档列表里 desc 等于「在组「X」里参考什么」的那一篇;
|
|
7
|
+
// 找不到就是还没写过;写一次即创建,再写即改同一篇。
|
|
8
|
+
//
|
|
9
|
+
// 关键口径:
|
|
10
|
+
// · 描述的**短标签(desc)由系统生成**(关系 + 「参考什么」),用户可在面板里改;
|
|
11
|
+
// 改了就等于换了一条关系(新的短标签 → 新的一篇)——可接受的代价:
|
|
12
|
+
// 关系描述本来就是「一句给人看的话」,不是机器主键;
|
|
13
|
+
// · 描述的**全文(body)**是用户写的内容(多行、含关键路径/搜索词),
|
|
14
|
+
// 长文本走 `--body-file`;
|
|
15
|
+
// · 关系本身不再有专门的存储:绑定关系在 `group_refs` / `ext_linked` 上,
|
|
16
|
+
// 描述在文档里,两者靠「宿主 + desc」对上。
|
|
6
17
|
//
|
|
7
18
|
// 单独成文件的原因:ref.ts 已在行数门禁的上限上,绑定描述这套逻辑独立成块
|
|
8
19
|
// (校验关系存在 → 写文档),拆出去两边都清爽。
|
|
9
20
|
import * as service from './service.js';
|
|
10
21
|
import { loadRef, boardKeyInside, repoKeyInside } from './ref.js';
|
|
11
22
|
import { badInput, notFound, conflict } from '../../core/errors.js';
|
|
23
|
+
import { getDb } from '../../core/db/index.js';
|
|
12
24
|
|
|
13
25
|
/** setLinkNote 的返回:写组级带 group、写仓库级带 repo。 */
|
|
14
26
|
export interface SetLinkNoteResult {
|
|
@@ -17,7 +29,7 @@ export interface SetLinkNoteResult {
|
|
|
17
29
|
group?: string;
|
|
18
30
|
repo?: string;
|
|
19
31
|
note: string;
|
|
20
|
-
/**
|
|
32
|
+
/** 描述落成的文档(refId / docId) */
|
|
21
33
|
refId?: string;
|
|
22
34
|
docId?: string;
|
|
23
35
|
}
|
|
@@ -31,13 +43,36 @@ export interface SetLinkNoteInput {
|
|
|
31
43
|
note?: unknown;
|
|
32
44
|
}
|
|
33
45
|
|
|
46
|
+
/** 关系描述的短标签(desc):系统生成,形如「在组「csharp」里参考什么」。 */
|
|
47
|
+
export function relationDescOf(scope: { kind: 'board' | 'repo'; name: string }): string {
|
|
48
|
+
return scope.kind === 'board'
|
|
49
|
+
? `在组「${scope.name}」里参考什么`
|
|
50
|
+
: `在仓库「${scope.name}」里参考什么`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** 这条关系对应的描述文档(按 desc 找;没有 → 空串)。 */
|
|
54
|
+
export function findRelationDoc(refKey: string, scope: { kind: 'board' | 'repo'; name: string }): string {
|
|
55
|
+
const desc = relationDescOf(scope);
|
|
56
|
+
const row = getDb().get(
|
|
57
|
+
`SELECT b.ref_id AS refId
|
|
58
|
+
FROM ref_bindings b
|
|
59
|
+
JOIN refs r ON r.id = b.ref_id AND r.deleted_at IS NULL
|
|
60
|
+
WHERE b.type = 'repo' AND b.repo_key = :refKey AND r."desc" = :desc
|
|
61
|
+
ORDER BY b.position, b.rowid
|
|
62
|
+
LIMIT 1`,
|
|
63
|
+
{ refKey: String(refKey || ''), desc },
|
|
64
|
+
);
|
|
65
|
+
return row ? String(row.refId || '') : '';
|
|
66
|
+
}
|
|
67
|
+
|
|
34
68
|
/**
|
|
35
69
|
* 绑定描述:这条绑定「参考什么」。note 留空 = 清除。
|
|
36
70
|
* --board b 写组级绑定(组 ↔ 参考仓库)的描述
|
|
37
71
|
* --repo x 写仓库级绑定(开发仓库 ↔ 参考仓库)的描述
|
|
38
72
|
* 两者只能选一个(一条绑定一条描述);目标关系不存在时显式报错。
|
|
39
73
|
*
|
|
40
|
-
*
|
|
74
|
+
* 关系必须真实存在——描述得挂在一条存在的关系上;描述本身落成**文档**
|
|
75
|
+
* (该参考仓库文档列表里的一篇,desc 由系统生成)。
|
|
41
76
|
*/
|
|
42
77
|
export async function setLinkNote({ id, key, repo, board, note }: SetLinkNoteInput = {}): Promise<SetLinkNoteResult> {
|
|
43
78
|
const ref = await loadRef(id || key);
|
|
@@ -77,35 +112,24 @@ export async function setLinkNote({ id, key, repo, board, note }: SetLinkNoteInp
|
|
|
77
112
|
}
|
|
78
113
|
|
|
79
114
|
// docs 域用**动态 import**(模块之间不静态互依,见 docs/repos-bridge 的同款约定)
|
|
80
|
-
const {
|
|
81
|
-
const
|
|
115
|
+
const { setDocLinkDoc } = await import('../docs/refs.js');
|
|
116
|
+
const desc = relationDescOf(scope);
|
|
117
|
+
const out = text
|
|
118
|
+
? await setDocLinkDoc({ repoKey: refKey, desc, body: text })
|
|
119
|
+
: { refId: findRelationDoc(refKey, scope), desc, created: false };
|
|
82
120
|
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (scope.kind === 'board') {
|
|
89
|
-
const db = d.boards.find((x: any) => service.storedBoardKey(x) === scope.key);
|
|
90
|
-
const link = db && (db.refs || []).find((l: any) => l.id === refKey);
|
|
91
|
-
if (!link) return;
|
|
92
|
-
if (text) link.note = text;
|
|
93
|
-
else delete link.note;
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const dev = d.repos.find((x: any) => service.deriveKey(x) === scope.key);
|
|
97
|
-
const link = dev && (dev.linked || []).find((l: any) => l && l.kind === 'ref' && String(l.id) === refKey);
|
|
98
|
-
if (!link) return;
|
|
99
|
-
if (text) link.note = text;
|
|
100
|
-
else delete link.note;
|
|
101
|
-
});
|
|
121
|
+
// 留空 = 清除:删掉那篇描述文档(正文与归属一起清)
|
|
122
|
+
if (!text && out.refId) {
|
|
123
|
+
const { removeDoc } = await import('../docs/service.js');
|
|
124
|
+
await removeDoc({ ref: out.refId }).catch(() => null);
|
|
125
|
+
}
|
|
102
126
|
|
|
103
127
|
return {
|
|
104
128
|
key: refKey,
|
|
105
129
|
name: r.name,
|
|
106
130
|
...relation,
|
|
107
131
|
note: text,
|
|
108
|
-
refId: out.refId,
|
|
109
|
-
docId: out.refId ? `ref:${out.refId}` : '',
|
|
132
|
+
refId: text ? out.refId : '',
|
|
133
|
+
docId: text && out.refId ? `ref:${out.refId}` : '',
|
|
110
134
|
};
|
|
111
135
|
}
|
package/src/modules/repos/ref.ts
CHANGED
|
@@ -457,27 +457,16 @@ export async function refReposOfRepo(idOrPathOrName: unknown): Promise<RefsOfRep
|
|
|
457
457
|
const repoKey = service.deriveKey(repo);
|
|
458
458
|
const groups = groupsOfRepo(s, repoKey);
|
|
459
459
|
// #134:描述已经不在关系边上了(在文档里)——只读展示从文档取,缺省回落旧 note。
|
|
460
|
-
const boardsOut =
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
name: b.name,
|
|
467
|
-
desc: b.desc || '',
|
|
468
|
-
refRepos: linksOfBoard(s, b).map(({ ref, note }) => ({
|
|
469
|
-
...projectRef(ref),
|
|
470
|
-
note: bodies.get(service.deriveKey(ref)) || note,
|
|
471
|
-
})),
|
|
472
|
-
};
|
|
460
|
+
const boardsOut = groups.map((b) => ({
|
|
461
|
+
id: b.id,
|
|
462
|
+
key: service.storedBoardKey(b),
|
|
463
|
+
name: b.name,
|
|
464
|
+
desc: b.desc || '',
|
|
465
|
+
refRepos: linksOfBoard(s, b).map(({ ref, note }) => ({ ...projectRef(ref), note })),
|
|
473
466
|
}));
|
|
474
467
|
|
|
475
468
|
// 仓库级直接绑定:与组无关,永远原样回显(组级结果不覆盖它)
|
|
476
|
-
const
|
|
477
|
-
const direct = directLinksOfRepo(s, repo).map(({ ref, note }) => ({
|
|
478
|
-
...projectRef(ref),
|
|
479
|
-
note: repoBodies.get(service.deriveKey(ref)) || note,
|
|
480
|
-
}));
|
|
469
|
+
const direct = directLinksOfRepo(s, repo).map(({ ref, note }) => ({ ...projectRef(ref), note }));
|
|
481
470
|
|
|
482
471
|
return {
|
|
483
472
|
repo: { id: repo.id, key: repoKey, name: repo.name, path: repo.path, desc: repo.desc || '' },
|
|
@@ -486,18 +475,6 @@ export async function refReposOfRepo(idOrPathOrName: unknown): Promise<RefsOfRep
|
|
|
486
475
|
};
|
|
487
476
|
}
|
|
488
477
|
|
|
489
|
-
/**
|
|
490
|
-
* #134:这条关系下各参考仓库的**描述正文**(refKey → 正文)。
|
|
491
|
-
*
|
|
492
|
-
* 描述已经不在关系边上了(归档成文档),但只读展示(面板 chip、交付上下文)
|
|
493
|
-
* 仍要给出「这个参考在本组里参考什么」——出处是文档。docs 域用**动态 import**
|
|
494
|
-
* (模块之间不静态互依,见 docs/repos-bridge 的同款约定)。
|
|
495
|
-
*/
|
|
496
|
-
async function linkNoteBodiesOf(scope: { kind: 'board' | 'repo'; key: string; name: string }): Promise<Map<string, string>> {
|
|
497
|
-
const { linkNoteBodiesOf: f } = await import('../docs/link-note.js');
|
|
498
|
-
return f(scope);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
478
|
/** syncRef 的结果(status: missing/upToDate/updated/conflict;syncAllRefs 里还有 error)。 */
|
|
502
479
|
export interface SyncRefResult {
|
|
503
480
|
id: string;
|
|
@@ -637,13 +614,8 @@ export async function refReposOfBoard(boardIdOrKey: unknown): Promise<RefsOfBoar
|
|
|
637
614
|
if (!b) b = s.boards.find((x) => String(x.name).toLowerCase() === raw.toLowerCase());
|
|
638
615
|
if (!b) throw notFound('看板不存在: ' + raw);
|
|
639
616
|
const bkey = service.storedBoardKey(b);
|
|
640
|
-
// #134:描述正文从文档取(关系边上已经没有它了)
|
|
641
|
-
const bodies = await linkNoteBodiesOf({ kind: 'board', key: bkey, name: b.name });
|
|
642
617
|
return {
|
|
643
618
|
board: { id: b.id, key: bkey, name: b.name },
|
|
644
|
-
refRepos: linksOfBoard(s, b).map(({ ref, note }) => ({
|
|
645
|
-
...projectRef(ref),
|
|
646
|
-
note: bodies.get(service.deriveKey(ref)) || note,
|
|
647
|
-
})),
|
|
619
|
+
refRepos: linksOfBoard(s, b).map(({ ref, note }) => ({ ...projectRef(ref), note })),
|
|
648
620
|
};
|
|
649
621
|
}
|
|
@@ -28,7 +28,7 @@ export interface ExportRepoEntry {
|
|
|
28
28
|
type: string;
|
|
29
29
|
/** 文档绑定(主篇 refId) */
|
|
30
30
|
doc?: any;
|
|
31
|
-
/** 项目补充文档(refId + note
|
|
31
|
+
/** 项目补充文档(refId + note) */
|
|
32
32
|
docLinks?: any[];
|
|
33
33
|
remote?: string;
|
|
34
34
|
remotes?: string[];
|
|
@@ -49,7 +49,7 @@ export interface ExportBoardEntry {
|
|
|
49
49
|
repos: ExportBoardRepoEntry[];
|
|
50
50
|
/** 文档绑定(v4):组介绍覆盖 */
|
|
51
51
|
doc?: any;
|
|
52
|
-
/** 组级附加文档列表(note
|
|
52
|
+
/** 组级附加文档列表(note 注解跟条目一起走) */
|
|
53
53
|
docLinks?: any[];
|
|
54
54
|
/** 组内描述覆盖(v4) */
|
|
55
55
|
repoDocs?: Record<string, any>;
|
|
@@ -166,7 +166,7 @@ export async function repoExport({ repoKeys, boardKeys, includeUnassigned = true
|
|
|
166
166
|
// 文档绑定(v4):组介绍覆盖 / 组级附加列表 / 组内描述覆盖
|
|
167
167
|
const bdoc = sanitizeDocRef(b.doc);
|
|
168
168
|
if (bdoc) entry.doc = bdoc;
|
|
169
|
-
// docLinks 条目 = DocRef + 注解(note
|
|
169
|
+
// docLinks 条目 = DocRef + 注解(note),注解跟条目一起走(withLinkMeta 统一口径)
|
|
170
170
|
const links = (Array.isArray(b.docLinks) ? b.docLinks : [])
|
|
171
171
|
.map((l: any) => {
|
|
172
172
|
const d = sanitizeDocRef(l);
|
|
@@ -87,12 +87,12 @@ export function parseLayout(json: unknown): Layout {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// v2 → v3:没有 key 的条目用 remote/name 现算,让老导出文件也能导入。
|
|
90
|
-
// v3 → v4:文档绑定字段做形状归一(非法形状丢弃;note
|
|
90
|
+
// v3 → v4:文档绑定字段做形状归一(非法形状丢弃;note 注解原样保留)。
|
|
91
91
|
const refOf = (raw: unknown): any => {
|
|
92
92
|
const d = sanitizeDocRef(raw);
|
|
93
93
|
if (!d) return null;
|
|
94
|
-
// sanitizeDocRef 通过即说明 raw 是 DocRef 形状对象(note
|
|
95
|
-
return withLinkMeta(d, raw as { note?: unknown
|
|
94
|
+
// sanitizeDocRef 通过即说明 raw 是 DocRef 形状对象(note 注解原样带出)
|
|
95
|
+
return withLinkMeta(d, raw as { note?: unknown });
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
function normalizeLayout(data: any): Layout {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
// {{task.text}} 原始提示词(任务正文,逐字)
|
|
15
15
|
// {{task.id}} 任务编号
|
|
16
16
|
// {{repo.name}} {{repo.intro}} {{repo.introPath}} 项目介绍(正文 + 可读路径)
|
|
17
|
-
// {{#each repo.docs}}…{{/each}} 项目补充文档(数组:path /
|
|
17
|
+
// {{#each repo.docs}}…{{/each}} 项目补充文档(数组:path / note)
|
|
18
18
|
// {{group.name}} {{group.desc}} {{group.intro}} {{group.introPath}} {{group.note}}
|
|
19
19
|
// {{#each group.peers}}…{{/each}} 组内成员(数组:name / note)
|
|
20
|
-
// {{#each group.docs}}…{{/each}} 组绑定参考文件(数组:path /
|
|
20
|
+
// {{#each group.docs}}…{{/each}} 组绑定参考文件(数组:path / note)
|
|
21
21
|
// {{#each repo.refRepos}}…{{/each}} 本仓库直接绑定的参考仓库(name / path / note)
|
|
22
22
|
// {{#each group.refRepos}}…{{/each}} 本组绑定的参考仓库(name / path / note)
|
|
23
23
|
// {{#each refRepos.list}}…{{/each}} 两者去重并集({{refRepos.count}} 总数)
|
|
@@ -45,14 +45,13 @@ export const DEFAULT_DELIVERY_TEMPLATE = DEFAULT_CONTEXT_TEMPLATE;
|
|
|
45
45
|
* 「项目文档 / 组文档」→ 结构化数组(模板用 {{#each}} 组织行)。
|
|
46
46
|
* v7:ref 是 DB 实体,没有路径——只给 desc / title / refId / hasBody。
|
|
47
47
|
*/
|
|
48
|
-
function docItems(links: any): { refId: string; desc: string; title: string; hasBody: boolean; note: string
|
|
48
|
+
function docItems(links: any): { refId: string; desc: string; title: string; hasBody: boolean; note: string }[] {
|
|
49
49
|
return (links || []).map((d: any) => ({
|
|
50
50
|
refId: d.refId || '',
|
|
51
51
|
desc: d.desc || '',
|
|
52
52
|
title: d.title || '',
|
|
53
53
|
hasBody: d.hasBody !== false,
|
|
54
54
|
note: d.note || '',
|
|
55
|
-
tag: d.tag || '',
|
|
56
55
|
}));
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -658,7 +658,7 @@
|
|
|
658
658
|
"action": {
|
|
659
659
|
"id": "repo.ref.note",
|
|
660
660
|
"module": "repos",
|
|
661
|
-
"summary": "
|
|
661
|
+
"summary": "写/清绑定描述:这个参考在该组/该仓库里参考什么(描述落成该参考仓库文档列表里的一篇文档,desc 由系统生成;--note 留空 = 清除那篇)",
|
|
662
662
|
"usage": "repo ref note",
|
|
663
663
|
"http": "POST /api/repos/ref/note"
|
|
664
664
|
},
|
|
@@ -1092,7 +1092,7 @@
|
|
|
1092
1092
|
"action": {
|
|
1093
1093
|
"id": "docs.link",
|
|
1094
1094
|
"module": "docs",
|
|
1095
|
-
"summary": "维护组的附加文档列表(--ref <refId> | --path <外部路径> + --note
|
|
1095
|
+
"summary": "维护组的附加文档列表(--ref <refId> | --path <外部路径> + --note;--remove <序号> 移除;--before <序号> 插位;同 ref 重复添加 = 更新)",
|
|
1096
1096
|
"usage": "docs link",
|
|
1097
1097
|
"http": "POST /api/docs/link"
|
|
1098
1098
|
},
|
|
@@ -229,7 +229,7 @@ export interface ApiClient {
|
|
|
229
229
|
check(): Promise<Awaited<ReturnType<InstanceType<typeof RepoRefCheckAction>['run']>>>;
|
|
230
230
|
/** 克隆远程仓库为参考仓库(落到 gitRepoRoot,登记 + 可选绑定当前目录的开发仓库) */
|
|
231
231
|
refClone(input: z.input<InstanceType<typeof RepoRefCloneAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoRefCloneAction>['run']>>>;
|
|
232
|
-
/**
|
|
232
|
+
/** 写/清绑定描述:这个参考在该组/该仓库里参考什么(描述落成该参考仓库文档列表里的一篇文档,desc 由系统生成;--note 留空 = 清除那篇) */
|
|
233
233
|
refNote(input: z.input<InstanceType<typeof RepoRefNoteAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoRefNoteAction>['run']>>>;
|
|
234
234
|
/** 查参考仓库:--id 某仓库(缺省当前目录)看它直接绑的 + 所属组绑的,两类并列;--board 某组 看这个组绑定的(带绑定描述) */
|
|
235
235
|
of(input?: z.input<InstanceType<typeof RepoRefOfAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoRefOfAction>['run']>>>;
|
|
@@ -281,7 +281,7 @@ export interface ApiClient {
|
|
|
281
281
|
gc(input?: z.input<InstanceType<typeof DocsGcAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsGcAction>['run']>>>;
|
|
282
282
|
/** 双链索引(docId + 文件名;前端点击 [[..]] 前拉一次;解析规则见 core/wikilink.js) */
|
|
283
283
|
index(): Promise<Awaited<ReturnType<InstanceType<typeof DocsIndexAction>['run']>>>;
|
|
284
|
-
/** 维护组的附加文档列表(--ref <refId> | --path <外部路径> + --note
|
|
284
|
+
/** 维护组的附加文档列表(--ref <refId> | --path <外部路径> + --note;--remove <序号> 移除;--before <序号> 插位;同 ref 重复添加 = 更新) */
|
|
285
285
|
link(input: z.input<InstanceType<typeof DocsLinkAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsLinkAction>['run']>>>;
|
|
286
286
|
/** 孤儿到期清理(默认只预演;--apply 软删空正文到期孤儿,有正文的只列清单) */
|
|
287
287
|
purge(input?: z.input<InstanceType<typeof DocsOrphansPurgeAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsOrphansPurgeAction>['run']>>>;
|
|
@@ -545,7 +545,7 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
545
545
|
async docAdd(input: z.input<InstanceType<typeof RepoDocAddAction>['_input']>) {
|
|
546
546
|
const inp = input ?? ({} as z.input<InstanceType<typeof RepoDocAddAction>['_input']>);
|
|
547
547
|
const path = `/api/repos/docs`;
|
|
548
|
-
const body = { "id": inp["id"], "ref": inp["ref"], "path": inp["path"], "note": inp["note"]
|
|
548
|
+
const body = { "id": inp["id"], "ref": inp["ref"], "path": inp["path"], "note": inp["note"] };
|
|
549
549
|
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof RepoDocAddAction>['run']>>;
|
|
550
550
|
},
|
|
551
551
|
// action: repo.doc.list
|
|
@@ -880,7 +880,7 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
880
880
|
async link(input: z.input<InstanceType<typeof DocsLinkAction>['_input']>) {
|
|
881
881
|
const inp = input ?? ({} as z.input<InstanceType<typeof DocsLinkAction>['_input']>);
|
|
882
882
|
const path = `/api/docs/link`;
|
|
883
|
-
const body = { "board": inp["board"], "ref": inp["ref"], "path": inp["path"], "note": inp["note"], "
|
|
883
|
+
const body = { "board": inp["board"], "ref": inp["ref"], "path": inp["path"], "note": inp["note"], "remove": inp["remove"], "before": inp["before"] };
|
|
884
884
|
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof DocsLinkAction>['run']>>;
|
|
885
885
|
},
|
|
886
886
|
// action: docs.orphans.purge
|
|
@@ -15,7 +15,6 @@ export interface IntroLink {
|
|
|
15
15
|
docId: string;
|
|
16
16
|
label: string;
|
|
17
17
|
note?: string;
|
|
18
|
-
tag?: string;
|
|
19
18
|
main?: boolean;
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -29,7 +28,6 @@ export interface IntroDocEntry {
|
|
|
29
28
|
title?: string;
|
|
30
29
|
desc?: string;
|
|
31
30
|
note?: string;
|
|
32
|
-
tag?: string;
|
|
33
31
|
[k: string]: any;
|
|
34
32
|
}
|
|
35
33
|
|
|
@@ -129,11 +127,11 @@ export function useIntro({ kind, owner, model }: UseIntroArgs): IntroApi {
|
|
|
129
127
|
const mid = linkDocId(main);
|
|
130
128
|
setMainDocId(mid || docRef);
|
|
131
129
|
if (mid && main) {
|
|
132
|
-
out.push({ docId: mid, label: labelOf(main, '主篇'), note: main.note || '',
|
|
130
|
+
out.push({ docId: mid, label: labelOf(main, '主篇'), note: main.note || '', main: true });
|
|
133
131
|
}
|
|
134
132
|
for (const l of extras) {
|
|
135
133
|
const id = linkDocId(l);
|
|
136
|
-
if (id) out.push({ docId: id, label: labelOf(l, '补充'), note: l.note || '',
|
|
134
|
+
if (id) out.push({ docId: id, label: labelOf(l, '补充'), note: l.note || '', main: false });
|
|
137
135
|
}
|
|
138
136
|
setLinks(out);
|
|
139
137
|
};
|
|
@@ -140,7 +140,7 @@ export default function ReposView() {
|
|
|
140
140
|
const main = r.descDocs && r.descDocs.main;
|
|
141
141
|
if (main && [main.title, main.summary, main.desc].some((s) => s && String(s).toLowerCase().includes(kw))) return true;
|
|
142
142
|
return ((r.descDocs && r.descDocs.links) || []).some((l) =>
|
|
143
|
-
[l.title, l.desc, l.
|
|
143
|
+
[l.title, l.desc, l.note].some((s) => s && String(s).toLowerCase().includes(kw)));
|
|
144
144
|
};
|
|
145
145
|
return list.filter((r) =>
|
|
146
146
|
[r.name, r.key, r.path, r.desc].some((s) => s && String(s).toLowerCase().includes(kw))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,_ as t,b as n,m as r,y as i}from"./frontmatter-DEIM0yF2.js";import{t as a}from"./workspace-C0PPPfA1.js";import{n as o}from"./app-context-CR7f0AtI.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./md-history-BF85zuFo.js";import"./index-
|
|
1
|
+
import{C as e,_ as t,b as n,m as r,y as i}from"./frontmatter-DEIM0yF2.js";import{t as a}from"./workspace-C0PPPfA1.js";import{n as o}from"./app-context-CR7f0AtI.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./md-history-BF85zuFo.js";import"./index-CBVkXanT.js";import{i as p,o as m,r as ee,t as h}from"./composer-launch-h-8g0f8A.js";var g=e(n(),1),_=i(),v=96;function y({token:e,mode:n=`comment`,quote:i=``,prevQuote:y=``,taskLabel:b=``,taskTitle:x=``,src:S=null}){let C=o(),w=t(),[T,E]=(0,g.useState)(``),[D,O]=(0,g.useState)([]),[k,A]=(0,g.useState)(!1),j=(0,g.useRef)(null),M=n===`feedback`,N=(0,g.useRef)(new Map),P=`compose-`+e,F=()=>{f(N.current,P),ee(C.model,e)},I=(e,t=`op`)=>{l(N.current,P,{title:``,body:T},t),E(e)},L=()=>{let e=c(N.current,P,{title:``,body:T});e&&E(e.body)},R=()=>{let e=d(N.current,P,{title:``,body:T});e&&E(e.body)},z=async()=>{let t=String(T||``).trim();if(!t&&!D.length){w(M?`写一下要改的地方`:`写一下要提的问题`);return}let n=h(e);if(!n||!n.onSubmit){w(`提交入口已失效(来源页面已关闭)`);return}A(!0);try{await n.onSubmit({text:t,attachments:D,inserts:``}),F()}catch(e){w(String(e.message||e))}finally{A(!1)}},B=async e=>{if(!e||!e.length)return;let{items:t,imageInserts:n,fileInserts:r}=await p(e),i=[...n,...r].join(``);i&&E(e=>u(e,i,{}).body),t.length&&O(e=>[...e,...t])},V=(0,g.useRef)(null),[H,U]=(0,g.useState)(()=>localStorage.getItem(`nxkv.cmpDockOpen`)!==`0`),[W,G]=(0,g.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.cmpDockH`));return Number.isFinite(e)&&e>=v?e:176}),K=(0,g.useRef)(W);K.current=W;let[q,J]=(0,g.useState)(!1),Y=(0,g.useRef)(176);(0,g.useEffect)(()=>{localStorage.setItem(`nxkv.cmpDockOpen`,H?`1`:`0`)},[H]);let X=()=>{if(q){G(Y.current),J(!1);return}Y.current=W;let e=document.querySelector(`.cmp`)?.clientHeight||window.innerHeight;G(Math.max(v,Math.round(e*.62))),J(!0)},Z=e=>{if(!H)return;e.preventDefault(),J(!1);let t=e.clientY,n=K.current,r=e=>Math.max(v,Math.min(Math.round(e),Math.round((document.querySelector(`.cmp`)?.clientHeight||window.innerHeight)*.62))),i=e=>{K.current=r(n-(e.clientY-t)),G(K.current)},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.cmpDockH`,String(K.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},Q=()=>{let e=C.model;e&&S&&S.task&&a(e,{component:`page`,name:S.name||`原文`,config:{dirKey:S.dirKey,task:String(S.task)}})},$=!!(S&&S.task);return(0,_.jsxs)(`div`,{className:`cmp`,children:[(0,_.jsxs)(`div`,{className:`cmp-head`,children:[(0,_.jsx)(`span`,{className:`cmp-tag`+(M?` is-fb`:``),children:M?`反馈`:`评论`}),(0,_.jsx)(`div`,{className:`cmp-ctx`,children:M?(0,_.jsxs)(`span`,{className:`cmp-ctx-line`,title:x||``,children:[`反馈 `,b||``,` 的任务`,x?` · ${x}`:``]}):(0,_.jsx)(`span`,{className:`cmp-ctx-line`,children:`对本任务提出问题`})}),(0,_.jsx)(`span`,{className:`grow`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:F,disabled:k,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:z,disabled:k,children:M?`提交反馈`:`提交评论`})]}),M?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`之前的引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:y||`(这条任务还没有可引用的上轮总结)`}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:y||`(这条任务还没有可引用的上轮总结)`})]}):i?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:i}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:i})]}):null,(0,_.jsx)(`div`,{className:`cmp-body`,children:(0,_.jsx)(s,{mode:`split`,title:``,body:T,onTitle:()=>{},onBody:I,attachments:D,docKey:`compose-`+e,editorApiRef:j,onFiles:B,onSave:z,onUndo:L,onRedo:R,hideTitle:!0})}),H&&(0,_.jsxs)(`div`,{className:`mdw-dock`,style:{height:`${W}px`},children:[(0,_.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:Z,onDoubleClick:X}),(0,_.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,_.jsx)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:(0,_.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":`true`,className:`mdw-dock-tab is-on`,onClick:()=>U(!0),children:[`附件`,D.length?(0,_.jsx)(`span`,{className:`mdw-dock-tab-num`,children:D.length}):null]})}),(0,_.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,title:`添加附件`,"aria-label":`添加附件`,onClick:()=>V.current?.click(),children:(0,_.jsx)(r,{name:`plus`,title:void 0})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:X,title:q?`还原面板高度`:`最大化面板高度`,"aria-label":q?`还原面板高度`:`最大化面板高度`,children:(0,_.jsx)(r,{name:q?`collapse`:`expand`,title:void 0})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>U(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,_.jsx)(r,{name:`x`,title:void 0})})]})]}),(0,_.jsx)(`div`,{className:`mdw-dock-body`,children:D.length?(0,_.jsx)(m,{attachments:D,onRemove:e=>O(t=>t.filter(t=>t.id!==e))}):(0,_.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有附件——粘贴 / 拖图片进正文即附件,或点右上「+」添加文件。`})})]}),(0,_.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${H?` is-on`:``}`,onClick:()=>U(e=>!e),title:`附件(点击展开/收起信息面板)`,children:[(0,_.jsx)(r,{name:`list`,title:void 0}),(0,_.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),D.length?(0,_.jsx)(`span`,{className:`mdw-sbar-num`,children:D.length}):null]}),(0,_.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${H?` is-open`:``}`,onClick:()=>U(e=>!e),title:H?`收起信息面板`:`展开信息面板`,"aria-expanded":H,"aria-label":H?`收起信息面板`:`展开信息面板`,children:(0,_.jsx)(r,{name:`chevron`,title:void 0})})]}),(0,_.jsx)(`input`,{ref:V,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&B(t)}})]})}export{y as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{C as e,_ as t,b as n,d as r,f as i,m as a,p as o,u as s,y as c}from"./frontmatter-DEIM0yF2.js";import{r as l,u}from"./workspace-C0PPPfA1.js";import{n as d}from"./app-context-CR7f0AtI.js";import{r as f}from"./doc-CKkCGsZ4.js";import{r as p}from"./md-parse-BE6EWfZ1.js";import{r as m,t as h}from"./board-view-CUeSVy9F.js";import{a as ee,f as g,i as _,l as v,n as y,o as b,p as x,r as S}from"./index-Dmlh01et.js";import{t as C}from"./graph-BTEfvFz6.js";import{C as te,S as w,T,a as ne,b as re,f as ie,i as ae,l as E,o as oe,p as se,s as ce,u as D,w as le,y as O}from"./task-utils-WfeuGNak.js";import{a as k,i as A,n as j,o as M,r as N,t as P}from"./task-row-CHSIDNmR.js";import{t as ue}from"./bar-CmzzOYQi.js";var F=e(n(),1),I=c(),de=j,L=N,R=P;function z({isGlobal:e,topic:n,repo:r=null,model:o=null,tasks:s=[],taskCount:c=0,pendingCount:l=0,page:u=0,pageCount:p=1,onPage:m,onNew:h,onOpenTask:ee,onDeleteTask:g,onDeleteTasks:_,onCancelTasks:v,onCompleteTasks:y,onReopenTask:b,onTplMenu:x,onImport:S,onProg:C,onMoveTask:te,onOpenDag:w,onOpenFlow:ne,onToggleGate:re,downstreamOf:ie,onRefs:ae,q:E=``,onQuery:oe}){let se=e?`全局池`:n?.name||`目录`,ce=!!String(E).trim(),D=(0,F.useRef)(null),[le,O]=(0,F.useState)(null),[k,j]=(0,F.useState)(null),[M,N]=(0,F.useState)(()=>new Set);(0,F.useEffect)(()=>{N(new Set)},[u]);let P=s.map(e=>Number(e.id)),z=P.length>0&&P.every(e=>M.has(e)),B=s.filter(e=>M.has(Number(e.id))),V=B.filter(e=>(e.status===`pending`||e.status===`claimed`)&&!e.migratedTo&&!e.deletedAt),H=V.filter(e=>e.status===`claimed`).length,U=B.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),fe=e=>{let t=Number(e);N(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},W=()=>{N(e=>{let t=new Set(e);return z?P.forEach(e=>t.delete(e)):P.forEach(e=>t.add(e)),t})},G=async e=>{let t=[...M],n=e===`cancel`?v:e===`complete`?y:_;t.length&&n&&await n(t)&&N(new Set)},pe=d(),K=t(),q=n?.key?{key:n.key}:{},J=B,Y=J.filter(e=>e.status===`pending`),me=J.filter(e=>e.status===`plan`),he=async(e,t)=>{if(e.length)try{for(let n of e)await T({...q,id:Number(n.id),to:t});K(t===`plan`?`已把 ${e.length} 条任务转为草稿(不进队列)`:`已把 ${e.length} 条草稿转回待领取`),N(new Set),pe.refreshLocal?.()}catch(e){K(String(e.message||e))}},ge=Y.length?Y:me,X=Y.length?`plan`:`pending`,Z=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,_e=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ve=(e,t)=>{D.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),O(Number(t.id))},Q=(e,t)=>{D.current&&Z(t)&&Number(t.id)!==D.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,j({id:Number(t.id),zone:_e(e,e.currentTarget)}))},$=e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||j(null)},ye=(e,t)=>{e.preventDefault();let n=_e(e,e.currentTarget),r=D.current;D.current=null,O(null),j(null),r&&Z(t)&&Number(t.id)!==r.id&&te&&te({id:r.id},t.id,n)},be=()=>{D.current=null,O(null),j(null)},xe=B.length>0?(0,I.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,I.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,B.length,` 条`]}),y&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!V.length,title:V.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${H?`;其中 ${H} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>G(`complete`),children:[`标为完成选中`,V.length?` (${V.length})`:``]}),v&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!U.length,title:U.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>G(`cancel`),children:[`取消选中`,U.length?` (${U.length})`:``]}),_&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>G(`delete`),children:[`删除选中 (`,B.length,`)`]}),(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>N(new Set),children:`清空`})]}):null,Se=(0,I.jsx)(L,{title:e?`全局池任务`:`任务`,pendingCount:l,headerExtra:(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,I.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:E,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>oe&&oe(e.target.value)}),s.length?(0,I.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:z,onChange:W,"aria-label":`全选当前页任务`}),`全选本页`]}):null]})}),emptyText:ce?`没有匹配「${E.trim()}」的任务(标题与正文都搜过了)`:`还没有页面:点「+ 新建页」写第一篇,或让 agent 往${e?`全局池`:`这个目录`}投递任务。`,children:s.map(e=>{let t=Z(e),n=ie&&ie[e.id]||[];return(0,I.jsx)(R,{t:e,selectable:!0,picked:M.has(Number(e.id)),onTogglePick:fe,draggable:t,dragHandlers:t?{onDragStart:t=>ve(t,e),onDragOver:t=>Q(t,e),onDragLeave:$,onDrop:t=>ye(t,e),onDragEnd:be}:null,dragVisual:{dragging:le===Number(e.id),drop:k&&k.id===Number(e.id)?k.zone:null},showTimes:!0,downs:n,onOpen:e=>ee(e.id),ops:(0,I.jsx)(i,{items:[e.status===`pending`||e.status===`plan`?{label:e.status===`pending`?`转为草稿(不进队列)`:`转回待领取`,onPick:()=>void he([e],e.status===`pending`?`plan`:`pending`)}:null,t&&w?{label:`编排依赖…`,onPick:()=>w(e)}:null,t&&re?{label:e.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>re(e)}:null,b&&e.status!==`cancelled`&&!e.childCount&&(e.status===`claimed`||e.status===`done`||e.completedAt)?{label:e.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,onPick:()=>b(e)}:null,g?{label:`删除此任务(软删除,CLI 可恢复)`,danger:!0,onPick:()=>g(e)}:null]})},e.id)})}),Ce=c>0?(0,I.jsx)(`div`,{className:`mdw-land-pager`,children:(0,I.jsx)(A,{page:u,pageCount:p,total:c,onPage:m,unit:`个任务`})}):null;return(0,I.jsx)(de,{name:se,counts:ce?[`命中 ${c} 个任务`,...l>0?[`待领取 ${l}`]:[]]:[`${c} 个任务`,...l>0?[`待领取 ${l}`]:[]],intro:!e&&r?(0,I.jsx)(f,{kind:`repo`,owner:r,model:o}):null,batch:xe,list:Se,footer:Ce,actions:(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(ue,{kind:`dir`,labels:{more:`更多`,plan:J.length?X===`plan`?`转草稿 (${Y.length})`:`转回待领取 (${me.length})`:`草稿态`},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,more:`更多操作`,refs:`查看文档 / reference 列表`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`},renderers:{new:()=>(0,I.jsx)(`span`,{className:`rp-newtask`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,onClick:()=>h(),children:[`+ 新建页`,(0,I.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),x?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),x?.(e))},children:(0,I.jsx)(a,{name:`chevron`,size:11,title:void 0})})]})})},actions:{new:h,import:S,progress:C,orch:ne,refs:ae,plan:()=>{if(!ge.length){K(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}he(ge,X)}}})})})}var B=s,V=(e,t,n)=>C(e=>n.get(Number(e))||[],e,t);function H({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),a=i(e),o=t.filter(e=>i(e)!==a),[s,c]=(0,F.useState)(!!e.blocksFollowing),[l,u]=(0,F.useState)(()=>new Set((e.blockBy||[]).map(Number))),[d,f]=(0,F.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,F.useState)(!1),ee=t.findIndex(e=>i(e)===a),g=t.slice(ee+1).map(i),_=new Map(t.map(e=>[i(e),i(e)===a?[...l]:(e.blockBy||[]).map(Number)])),v=e=>s||!l.has(i(e))&&V(i(e),a,_),y=e=>!d.has(i(e))&&V(a,i(e),_),b=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),x=()=>c(e=>(e||u(new Set),!e)),S=async()=>{h(!0);try{let e=[{id:a,gate:s,blockBy:[...l]}];if(!s)for(let t of o){let n=i(t),r=d.has(n),o=(t.blockBy||[]).map(Number);r!==o.includes(a)&&e.push({id:n,blockBy:r?[...o,a]:o.filter(e=>e!==a)})}await r(e),n()}catch{}finally{h(!1)}},C=(e,t,n,r)=>{let a=p(e.text)||`#${i(e)}`;return(0,I.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,I.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,I.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,I.jsx)(B,{title:`编排 · #${a} ${p(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:S,children:m?`保存中…`:`保存编排`})]}),children:(0,I.jsxs)(`div`,{className:`mdw-dag`,children:[(0,I.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:x}),(0,I.jsx)(`b`,{children:`闸门`}),(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,I.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,g.length,` 个后续任务`,g.length?`:${g.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>C(e,l.has(i(e)),v(e),b(u))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>C(e,d.has(i(e)),s||y(e),b(f))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}var U=20;function fe({dirKey:e}){let{dialog:n,node:i}=o(),a=d(),s=t(),c=a.rows||[],f=a.refreshLocal,p=a.tpl,C=a.model,T=a.repoData&&a.repoData.repos||[],A=!e||e===`__GLOBAL__`,[j,N]=(0,F.useState)(null),[P,ue]=(0,F.useState)(null),de=(0,F.useRef)(null),L=(0,F.useMemo)(()=>A?c.find(e=>e.isGlobal)||null:c.find(t=>t.key===e)||null,[c,e,A]),R=(0,F.useMemo)(()=>{if(!L||A)return null;let e=L.repo&&L.repo.key;if(e){let t=T.find(t=>t.key===e);if(t)return t}let t=String(L.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&T.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[L,T,A]),B=(0,F.useMemo)(()=>ae((L?.tasks||[]).filter(e=>!e.deletedAt&&!m(e))),[L]),[V,fe]=(0,F.useState)(``),W=(0,F.useMemo)(()=>M(B,V),[B,V]),G=k(W,U);(0,F.useEffect)(()=>{G.setPage(0)},[V]);let pe=(0,F.useMemo)(()=>W.filter(e=>e.status===`pending`&&!e.migratedTo).length,[W]),K=e=>e().catch(e=>s(String(e.message||e))),q=()=>A?{key:h}:{cwd:L?.cwd},J=(e,t,n)=>{K(async()=>{await le({...q(),id:e.id,...n===`before`?{beforeId:t}:{afterId:t}}),f?.()})},Y=e=>{K(async()=>{await O({...q(),id:e.id,gate:!e.blocksFollowing}),s(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),f?.()})},me=async e=>{try{for(let t of e)await O({...q(),...t});s(`编排已保存`),f?.()}catch(e){throw s(String(e.message||e)),e}},he=(0,F.useMemo)(()=>{let e={},t=B.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt);return t.forEach((n,r)=>{n.blocksFollowing&&(e[n.id]=t.slice(r+1).map(e=>e.id))}),e},[B]),ge=(0,F.useMemo)(()=>B.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[B]),X=t=>{a.openPage&&a.openPage({dirKey:e,task:String(t),name:`#${t}`})},Z=t=>{let n=v();g(b(x(e),n),{title:``,body:t}),a.openPage&&a.openPage({dirKey:e,task:n,name:`新任务`})},_e=()=>{C&&_(C)},ve=()=>{C&&l(C,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},Q=A?h:e||`__GLOBAL__`,$=y(Q).templates||p&&p.templates||[],ye=()=>{if(!C){s(`工作区未就绪`);return}ee(C,{mode:`new`,topic:Q,scope:A?[]:[`topic:${Q}`],name:``})},be=[...$.length?$.map(e=>({label:(e.id===p?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Z(S(e.body,e.values||{}))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>Z(p?p.defaultBody():``)}],`sep`,{label:`为本${A?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:ye},{label:`管理模板…`,icon:`gear`,onClick:_e}],xe=async e=>{if(e==null)return null;let t=A?`key=${encodeURIComponent(h)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(L?.cwd||``)}&id=${Number(e.id)}`;return se(t)},Se=t=>{if(!t)return;let r=(t.text||``).split(`
|
|
1
|
+
import{C as e,_ as t,b as n,d as r,f as i,m as a,p as o,u as s,y as c}from"./frontmatter-DEIM0yF2.js";import{r as l,u}from"./workspace-C0PPPfA1.js";import{n as d}from"./app-context-CR7f0AtI.js";import{r as f}from"./doc-Dn4-viog.js";import{r as p}from"./md-parse-BE6EWfZ1.js";import{r as m,t as h}from"./board-view-CUeSVy9F.js";import{a as ee,f as g,i as _,l as v,n as y,o as b,p as x,r as S}from"./index-CBVkXanT.js";import{t as C}from"./graph-BTEfvFz6.js";import{C as te,S as w,T,a as ne,b as re,f as ie,i as ae,l as E,o as oe,p as se,s as ce,u as D,w as le,y as O}from"./task-utils-WfeuGNak.js";import{a as k,i as A,n as j,o as M,r as N,t as P}from"./task-row-CHSIDNmR.js";import{t as ue}from"./bar-CmzzOYQi.js";var F=e(n(),1),I=c(),de=j,L=N,R=P;function z({isGlobal:e,topic:n,repo:r=null,model:o=null,tasks:s=[],taskCount:c=0,pendingCount:l=0,page:u=0,pageCount:p=1,onPage:m,onNew:h,onOpenTask:ee,onDeleteTask:g,onDeleteTasks:_,onCancelTasks:v,onCompleteTasks:y,onReopenTask:b,onTplMenu:x,onImport:S,onProg:C,onMoveTask:te,onOpenDag:w,onOpenFlow:ne,onToggleGate:re,downstreamOf:ie,onRefs:ae,q:E=``,onQuery:oe}){let se=e?`全局池`:n?.name||`目录`,ce=!!String(E).trim(),D=(0,F.useRef)(null),[le,O]=(0,F.useState)(null),[k,j]=(0,F.useState)(null),[M,N]=(0,F.useState)(()=>new Set);(0,F.useEffect)(()=>{N(new Set)},[u]);let P=s.map(e=>Number(e.id)),z=P.length>0&&P.every(e=>M.has(e)),B=s.filter(e=>M.has(Number(e.id))),V=B.filter(e=>(e.status===`pending`||e.status===`claimed`)&&!e.migratedTo&&!e.deletedAt),H=V.filter(e=>e.status===`claimed`).length,U=B.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),fe=e=>{let t=Number(e);N(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},W=()=>{N(e=>{let t=new Set(e);return z?P.forEach(e=>t.delete(e)):P.forEach(e=>t.add(e)),t})},G=async e=>{let t=[...M],n=e===`cancel`?v:e===`complete`?y:_;t.length&&n&&await n(t)&&N(new Set)},pe=d(),K=t(),q=n?.key?{key:n.key}:{},J=B,Y=J.filter(e=>e.status===`pending`),me=J.filter(e=>e.status===`plan`),he=async(e,t)=>{if(e.length)try{for(let n of e)await T({...q,id:Number(n.id),to:t});K(t===`plan`?`已把 ${e.length} 条任务转为草稿(不进队列)`:`已把 ${e.length} 条草稿转回待领取`),N(new Set),pe.refreshLocal?.()}catch(e){K(String(e.message||e))}},ge=Y.length?Y:me,X=Y.length?`plan`:`pending`,Z=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,_e=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ve=(e,t)=>{D.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),O(Number(t.id))},Q=(e,t)=>{D.current&&Z(t)&&Number(t.id)!==D.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,j({id:Number(t.id),zone:_e(e,e.currentTarget)}))},$=e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||j(null)},ye=(e,t)=>{e.preventDefault();let n=_e(e,e.currentTarget),r=D.current;D.current=null,O(null),j(null),r&&Z(t)&&Number(t.id)!==r.id&&te&&te({id:r.id},t.id,n)},be=()=>{D.current=null,O(null),j(null)},xe=B.length>0?(0,I.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,I.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,B.length,` 条`]}),y&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!V.length,title:V.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${H?`;其中 ${H} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>G(`complete`),children:[`标为完成选中`,V.length?` (${V.length})`:``]}),v&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!U.length,title:U.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>G(`cancel`),children:[`取消选中`,U.length?` (${U.length})`:``]}),_&&(0,I.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>G(`delete`),children:[`删除选中 (`,B.length,`)`]}),(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>N(new Set),children:`清空`})]}):null,Se=(0,I.jsx)(L,{title:e?`全局池任务`:`任务`,pendingCount:l,headerExtra:(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,I.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:E,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>oe&&oe(e.target.value)}),s.length?(0,I.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:z,onChange:W,"aria-label":`全选当前页任务`}),`全选本页`]}):null]})}),emptyText:ce?`没有匹配「${E.trim()}」的任务(标题与正文都搜过了)`:`还没有页面:点「+ 新建页」写第一篇,或让 agent 往${e?`全局池`:`这个目录`}投递任务。`,children:s.map(e=>{let t=Z(e),n=ie&&ie[e.id]||[];return(0,I.jsx)(R,{t:e,selectable:!0,picked:M.has(Number(e.id)),onTogglePick:fe,draggable:t,dragHandlers:t?{onDragStart:t=>ve(t,e),onDragOver:t=>Q(t,e),onDragLeave:$,onDrop:t=>ye(t,e),onDragEnd:be}:null,dragVisual:{dragging:le===Number(e.id),drop:k&&k.id===Number(e.id)?k.zone:null},showTimes:!0,downs:n,onOpen:e=>ee(e.id),ops:(0,I.jsx)(i,{items:[e.status===`pending`||e.status===`plan`?{label:e.status===`pending`?`转为草稿(不进队列)`:`转回待领取`,onPick:()=>void he([e],e.status===`pending`?`plan`:`pending`)}:null,t&&w?{label:`编排依赖…`,onPick:()=>w(e)}:null,t&&re?{label:e.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>re(e)}:null,b&&e.status!==`cancelled`&&!e.childCount&&(e.status===`claimed`||e.status===`done`||e.completedAt)?{label:e.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,onPick:()=>b(e)}:null,g?{label:`删除此任务(软删除,CLI 可恢复)`,danger:!0,onPick:()=>g(e)}:null]})},e.id)})}),Ce=c>0?(0,I.jsx)(`div`,{className:`mdw-land-pager`,children:(0,I.jsx)(A,{page:u,pageCount:p,total:c,onPage:m,unit:`个任务`})}):null;return(0,I.jsx)(de,{name:se,counts:ce?[`命中 ${c} 个任务`,...l>0?[`待领取 ${l}`]:[]]:[`${c} 个任务`,...l>0?[`待领取 ${l}`]:[]],intro:!e&&r?(0,I.jsx)(f,{kind:`repo`,owner:r,model:o}):null,batch:xe,list:Se,footer:Ce,actions:(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(ue,{kind:`dir`,labels:{more:`更多`,plan:J.length?X===`plan`?`转草稿 (${Y.length})`:`转回待领取 (${me.length})`:`草稿态`},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,more:`更多操作`,refs:`查看文档 / reference 列表`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`},renderers:{new:()=>(0,I.jsx)(`span`,{className:`rp-newtask`,children:(0,I.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,onClick:()=>h(),children:[`+ 新建页`,(0,I.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),x?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),x?.(e))},children:(0,I.jsx)(a,{name:`chevron`,size:11,title:void 0})})]})})},actions:{new:h,import:S,progress:C,orch:ne,refs:ae,plan:()=>{if(!ge.length){K(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}he(ge,X)}}})})})}var B=s,V=(e,t,n)=>C(e=>n.get(Number(e))||[],e,t);function H({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),a=i(e),o=t.filter(e=>i(e)!==a),[s,c]=(0,F.useState)(!!e.blocksFollowing),[l,u]=(0,F.useState)(()=>new Set((e.blockBy||[]).map(Number))),[d,f]=(0,F.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,F.useState)(!1),ee=t.findIndex(e=>i(e)===a),g=t.slice(ee+1).map(i),_=new Map(t.map(e=>[i(e),i(e)===a?[...l]:(e.blockBy||[]).map(Number)])),v=e=>s||!l.has(i(e))&&V(i(e),a,_),y=e=>!d.has(i(e))&&V(a,i(e),_),b=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),x=()=>c(e=>(e||u(new Set),!e)),S=async()=>{h(!0);try{let e=[{id:a,gate:s,blockBy:[...l]}];if(!s)for(let t of o){let n=i(t),r=d.has(n),o=(t.blockBy||[]).map(Number);r!==o.includes(a)&&e.push({id:n,blockBy:r?[...o,a]:o.filter(e=>e!==a)})}await r(e),n()}catch{}finally{h(!1)}},C=(e,t,n,r)=>{let a=p(e.text)||`#${i(e)}`;return(0,I.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,I.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,I.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,I.jsx)(B,{title:`编排 · #${a} ${p(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:S,children:m?`保存中…`:`保存编排`})]}),children:(0,I.jsxs)(`div`,{className:`mdw-dag`,children:[(0,I.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:x}),(0,I.jsx)(`b`,{children:`闸门`}),(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,I.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,g.length,` 个后续任务`,g.length?`:${g.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>C(e,l.has(i(e)),v(e),b(u))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,I.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,I.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>C(e,d.has(i(e)),s||y(e),b(f))):(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,I.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}var U=20;function fe({dirKey:e}){let{dialog:n,node:i}=o(),a=d(),s=t(),c=a.rows||[],f=a.refreshLocal,p=a.tpl,C=a.model,T=a.repoData&&a.repoData.repos||[],A=!e||e===`__GLOBAL__`,[j,N]=(0,F.useState)(null),[P,ue]=(0,F.useState)(null),de=(0,F.useRef)(null),L=(0,F.useMemo)(()=>A?c.find(e=>e.isGlobal)||null:c.find(t=>t.key===e)||null,[c,e,A]),R=(0,F.useMemo)(()=>{if(!L||A)return null;let e=L.repo&&L.repo.key;if(e){let t=T.find(t=>t.key===e);if(t)return t}let t=String(L.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&T.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[L,T,A]),B=(0,F.useMemo)(()=>ae((L?.tasks||[]).filter(e=>!e.deletedAt&&!m(e))),[L]),[V,fe]=(0,F.useState)(``),W=(0,F.useMemo)(()=>M(B,V),[B,V]),G=k(W,U);(0,F.useEffect)(()=>{G.setPage(0)},[V]);let pe=(0,F.useMemo)(()=>W.filter(e=>e.status===`pending`&&!e.migratedTo).length,[W]),K=e=>e().catch(e=>s(String(e.message||e))),q=()=>A?{key:h}:{cwd:L?.cwd},J=(e,t,n)=>{K(async()=>{await le({...q(),id:e.id,...n===`before`?{beforeId:t}:{afterId:t}}),f?.()})},Y=e=>{K(async()=>{await O({...q(),id:e.id,gate:!e.blocksFollowing}),s(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),f?.()})},me=async e=>{try{for(let t of e)await O({...q(),...t});s(`编排已保存`),f?.()}catch(e){throw s(String(e.message||e)),e}},he=(0,F.useMemo)(()=>{let e={},t=B.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt);return t.forEach((n,r)=>{n.blocksFollowing&&(e[n.id]=t.slice(r+1).map(e=>e.id))}),e},[B]),ge=(0,F.useMemo)(()=>B.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[B]),X=t=>{a.openPage&&a.openPage({dirKey:e,task:String(t),name:`#${t}`})},Z=t=>{let n=v();g(b(x(e),n),{title:``,body:t}),a.openPage&&a.openPage({dirKey:e,task:n,name:`新任务`})},_e=()=>{C&&_(C)},ve=()=>{C&&l(C,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},Q=A?h:e||`__GLOBAL__`,$=y(Q).templates||p&&p.templates||[],ye=()=>{if(!C){s(`工作区未就绪`);return}ee(C,{mode:`new`,topic:Q,scope:A?[]:[`topic:${Q}`],name:``})},be=[...$.length?$.map(e=>({label:(e.id===p?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Z(S(e.body,e.values||{}))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>Z(p?p.defaultBody():``)}],`sep`,{label:`为本${A?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:ye},{label:`管理模板…`,icon:`gear`,onClick:_e}],xe=async e=>{if(e==null)return null;let t=A?`key=${encodeURIComponent(h)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(L?.cwd||``)}&id=${Number(e.id)}`;return se(t)},Se=t=>{if(!t)return;let r=(t.text||``).split(`
|
|
2
2
|
`).find(e=>e.trim())||`#${t.id}`;K(async()=>{let i=!!t.completedAt,a=await n({title:i?`反馈 · #${t.id}`:`反馈修改 · #${t.id}`,input:!0,placeholder:i?`写下反馈(将新开一条任务,原任务不动)`:`写下要改的地方(留空 = 只重开,不改正文)`});if(a==null)return;let o=String(a).trim(),c=await xe(t),l=String(c?.text??``).trim()||String(t.text||``).trim(),u=i&&(c?.roundSummary||t.roundSummary)||``;if(!o&&!i&&!l){s(`拿不到任务当前正文,已取消(防止丢内容)`);return}if(i){let n=o?ne({base:l,feedback:o,ackSummary:u,feedbackHeading:oe,bold:!0}):``;if(!n){s(`写一下反馈`);return}let i=await E(A?{global:!0,text:n,forkOf:String(t.id),forkKind:`reopen`}:{cwd:L?.cwd,text:n,forkOf:String(t.id),forkKind:`reopen`}),a=String(i?.task?.id??i?.id??``),c=i?.key||e;a&&g(b(x(c),a),{body:n}),s(`已反馈「${r.replace(/^#\s*/,``)}」→ 新任务 #${a||`?`}`),f?.();return}let d=await re({...q(),id:t.id,kind:`reopen`,...o?{feedback:o,feedbackHeading:ce,feedbackBold:!1}:{}}),p=d?.key||e,m=String(d?.task?.id??t.id),h=String(d?.task?.text??``);h&&g(b(x(p),m),{body:h}),s(`已回写「${r.replace(/^#\s*/,``)}」#${m}`+(d?.moved&&d.name?`;归属迁到「${d.name}」`:``)),f?.()})},Ce=async t=>{if(!t)return;let r=(t.text||``).split(`
|
|
3
3
|
`).find(e=>e.trim())||`#${t.id}`;await n({title:`删除任务「${r.replace(/^#\s*/,``)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&K(async()=>{if(await te(A?{key:h,id:t.id}:{cwd:L?.cwd,id:t.id}),s(`已删除「${r.replace(/^#\s*/,``)}」`),C){let n=u(C,`page`,{dirKey:e,task:String(t.id)});n&&a.closePanel&&a.closePanel(n.getId())}f?.()})},we=async e=>{let t=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!t.length||!await n({title:`删除选中的 ${t.length} 条任务`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})?!1:K(async()=>{let e=await w({...q(),ids:t});return s(`已删除 ${e?.count??t.length} 条任务`),f?.(),!0})},Te=async e=>{let t=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!t.length||!await n({title:`取消选中的 ${t.length} 条待领取任务`,message:`只处理待领取任务;已领取/已完成/已取消会跳过。取消为终态,原文留档。`,okText:`取消任务`})?!1:K(async()=>{let e=await D({...q(),ids:t}),n=e?.skipped?.length||0;return s(`已取消 ${e?.count??0} 条任务${n?`,跳过 ${n} 条`:``}`),f?.(),!0})},Ee=async e=>{let t=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!t.length||!await n({title:`把选中的 ${t.length} 条任务标为完成`,message:`待领取与已领取(正在跑)都能收:已领取的直接收口,agent 侧回执会被忽略。已完成/已取消会跳过。完成会补一条完成记录,原文留档。`,okText:`标为完成`})?!1:K(async()=>{let e=await ie({...q(),ids:t,status:`done`}),n=e?.skipped?.length||0,r=e?.claimedClosed?.length||0;return s(`已标为完成 ${e?.count??0} 条任务${r?`(含 ${r} 条已领取)`:``}${n?`,跳过 ${n} 条`:``}`),f?.(),!0})},De=()=>{if(A||!R){s(`全局池没有项目文档列表`);return}if(!C)return;let e=R.key||L?.repo&&L.repo.key||``;if(!e){s(`这个项目还没有仓库标识(key),无法定位文档列表`);return}l(C,{component:`refs`,name:`文档列表`,config:{repoKey:e},location:`right`})},Oe=async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await K(async()=>{let r=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,i=await E(A?{global:!0,text:r}:{cwd:L?.cwd,text:r});s(`已导入:${e.name}`),f?.();let a=i?.task?.id??i?.id;a!=null&&X(a)})};return!L&&!A?(0,I.jsx)(`div`,{className:`mdw`,children:(0,I.jsx)(`div`,{className:`mdw-main`,children:(0,I.jsx)(`div`,{className:`mdw-top`,children:(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:`目录不存在`}),(0,I.jsx)(`div`,{className:`mdw-path`,children:`—`})]})})})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{isGlobal:A,topic:L,repo:R,model:C,tasks:G.items,taskCount:G.total,q:V,onQuery:fe,pendingCount:pe,page:G.page,pageCount:G.pageCount,onPage:G.setPage,onNew:()=>Z(p?p.defaultBody():``),onOpenTask:X,onDeleteTask:Ce,onDeleteTasks:we,onCancelTasks:Te,onCompleteTasks:Ee,onReopenTask:Se,onTplMenu:e=>N({x:e.clientX,y:e.clientY}),onImport:()=>de.current?.click(),onProg:ve,onMoveTask:J,onOpenDag:ue,onOpenFlow:()=>C&&l(C,{component:`dag`,name:`编排`,config:{dirKey:e}}),onToggleGate:Y,downstreamOf:he,onRefs:De}),P&&(0,I.jsx)(H,{task:P,tasks:ge,onClose:()=>ue(null),onSave:me}),j&&(0,I.jsx)(r,{x:j.x,y:j.y,items:be,onClose:()=>N(null)}),(0,I.jsx)(`input`,{ref:de,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&Oe(t)}}),i]})}export{fe as default};
|