nx-kv 0.65.3 → 0.65.4
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 +20 -0
- package/README.md +15 -37
- package/assets/nx-kv/QUICKSTART.md +110 -0
- package/assets/nx-kv/references/A05-/344/273/273/345/212/241/351/223/276/344/270/216/345/217/215/351/246/210/346/261/207/346/200/273.md +1 -1
- package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +1 -2
- package/package.json +1 -1
- package/src/core/config.ts +23 -0
- package/src/core/instruction-template.ts +1 -1
- package/src/core/workflow/project.ts +1 -1
- package/src/core/workflow/types.ts +1 -1
- package/src/modules/claim/actions/_manifest.generated.ts +0 -3
- package/src/modules/claim/actions/localtask-claim.ts +3 -3
- package/src/modules/claim/actions/localtask-preview.ts +2 -2
- package/src/modules/{delivery → claim}/assemble.ts +3 -3
- package/src/modules/claim/get.ts +3 -4
- package/src/modules/{delivery → claim}/groupctx.ts +4 -7
- package/src/modules/{delivery → claim}/host.ts +4 -4
- package/src/modules/claim/index.ts +1 -1
- package/src/modules/claim/panel-escort.ts +1 -1
- package/src/modules/claim/params.ts +2 -2
- package/src/modules/{delivery → claim}/preview.ts +3 -3
- package/src/modules/claim/wait.ts +14 -14
- package/src/modules/claim/waitgoal-config.ts +1 -22
- package/src/modules/docs/actions/_manifest.generated.ts +12 -0
- package/src/modules/{repos → docs}/actions/repo-doc-add.ts +3 -2
- package/src/modules/{repos → docs}/actions/repo-doc-list.ts +3 -2
- package/src/modules/{repos → docs}/actions/repo-doc-remove.ts +3 -2
- package/src/modules/{repos → docs}/actions/repo-knowledge.ts +3 -2
- package/src/modules/docs/knowledge.ts +8 -16
- package/src/modules/goals/actions/timegoal-check.ts +1 -1
- package/src/modules/goals/actions/timegoal-clear.ts +1 -1
- package/src/modules/goals/actions/timegoal-list.ts +1 -1
- package/src/modules/goals/actions/timegoal-log.ts +1 -1
- package/src/modules/goals/actions/timegoal-set.ts +1 -1
- package/src/modules/goals/actions/timegoal-show.ts +1 -1
- package/src/modules/goals/actions/timegoal-update.ts +1 -1
- package/src/modules/goals/plugins/timegoal-cwd-store.ts +1 -1
- package/src/modules/goals/plugins/timegoal-store.ts +3 -3
- package/src/modules/goals/plugins/timegoal-task-store.ts +2 -2
- package/src/modules/{localtask → goals}/support.ts +3 -1
- package/src/modules/localtask/actions/localtask-add.ts +3 -3
- package/src/modules/localtask/actions/localtask-attach-note.ts +1 -1
- package/src/modules/localtask/actions/localtask-attach.ts +1 -1
- package/src/modules/localtask/actions/localtask-attachments.ts +2 -2
- package/src/modules/localtask/actions/localtask-cancel.ts +1 -1
- package/src/modules/localtask/actions/localtask-chain.ts +1 -1
- package/src/modules/localtask/actions/localtask-detach.ts +2 -2
- package/src/modules/localtask/actions/localtask-done.ts +1 -1
- package/src/modules/localtask/actions/localtask-get.ts +3 -3
- package/src/modules/localtask/actions/localtask-list.ts +1 -1
- package/src/modules/localtask/actions/localtask-reopen.ts +5 -5
- package/src/modules/localtask/actions/localtask-topic-removeMany.ts +1 -1
- package/src/modules/localtask/actions/localtask-update.ts +2 -2
- package/src/modules/localtask/{bus → infra/bus}/index.ts +1 -1
- package/src/modules/localtask/{engine.ts → infra/engine.ts} +1 -1
- package/src/modules/localtask/{events.ts → infra/events.ts} +3 -3
- package/src/modules/localtask/{mutator → infra/mutator}/index.ts +2 -2
- package/src/modules/localtask/{mutator → infra/mutator}/validate.ts +4 -4
- package/src/modules/localtask/{repo → infra/repo}/goals.ts +2 -2
- package/src/modules/localtask/{repo → infra/repo}/index.ts +1 -1
- package/src/modules/localtask/{repo → infra/repo}/links.ts +2 -2
- package/src/modules/localtask/{repo → infra/repo}/open.ts +4 -4
- package/src/modules/localtask/{repo → infra/repo}/presence.ts +1 -1
- package/src/modules/localtask/{repo → infra/repo}/rows.ts +1 -1
- package/src/modules/localtask/{repo → infra/repo}/settings.ts +5 -5
- package/src/modules/localtask/{repo → infra/repo}/snapshot.ts +9 -7
- package/src/modules/localtask/{repo → infra/repo}/tasks.ts +82 -4
- package/src/modules/localtask/{repo → infra/repo}/topics.ts +3 -3
- package/src/modules/localtask/{repo-ctx.ts → infra/repo-ctx.ts} +1 -1
- package/src/modules/localtask/{scheduler → infra/scheduler}/index.ts +1 -1
- package/src/modules/localtask/{scheduler → infra/scheduler}/state-drive.ts +4 -4
- package/src/modules/localtask/{store → infra/store}/file-adapter.ts +2 -2
- package/src/modules/localtask/{store → infra/store}/index.ts +4 -4
- package/src/modules/localtask/{store → infra/store}/memory-adapter.ts +2 -2
- package/src/modules/localtask/{store-io.ts → infra/store-io.ts} +1 -1
- package/src/modules/localtask/{writes.ts → infra/writes.ts} +3 -3
- package/src/modules/localtask/{add.ts → lifecycle/add.ts} +5 -5
- package/src/modules/localtask/{deletion.ts → lifecycle/deletion.ts} +4 -4
- package/src/modules/localtask/{task-lifecycle.ts → lifecycle/task-lifecycle.ts} +16 -17
- package/src/modules/localtask/{task-ops.ts → lifecycle/task-ops.ts} +14 -14
- package/src/modules/localtask/{task-remove.ts → lifecycle/task-remove.ts} +4 -4
- package/src/modules/localtask/{task-templates.ts → lifecycle/task-templates.ts} +2 -2
- package/src/modules/localtask/{task-view.ts → lifecycle/task-view.ts} +14 -13
- package/src/modules/localtask/{topics.ts → lifecycle/topics.ts} +7 -7
- package/src/modules/localtask/{update.ts → lifecycle/update.ts} +5 -5
- package/src/modules/{delivery → localtask/ops}/attach-resource.ts +4 -4
- package/src/modules/{delivery → localtask/ops}/attach-template.ts +3 -3
- package/src/modules/{delivery → localtask/ops}/attach.ts +11 -11
- package/src/modules/localtask/{board-target.ts → ops/board-target.ts} +1 -1
- package/src/modules/{delivery → localtask/ops}/doc-inline.ts +3 -3
- package/src/modules/localtask/{group-store.ts → ops/group-store.ts} +1 -1
- package/src/modules/localtask/service.ts +16 -16
- package/src/modules/localtask/{action-render.ts → ui/action-render.ts} +2 -2
- package/src/modules/localtask/{panel-guard.ts → ui/panel-guard.ts} +1 -1
- package/src/modules/localtask/{panel-presence.ts → ui/panel-presence.ts} +6 -6
- package/src/modules/localtask/waiters.ts +2 -2
- package/src/modules/localtask/waiting.ts +1 -1
- package/src/modules/promptplug/factory.ts +2 -2
- package/src/modules/promptplug/index.ts +5 -5
- package/src/modules/promptplug/plugins/attachment.ts +1 -1
- package/src/modules/promptplug/plugins/context.ts +9 -20
- package/src/modules/repos/actions/_manifest.generated.ts +0 -12
- package/src/modules/repos/service/crud.ts +1 -1
- package/src/runtime/cli.ts +1 -1
- package/src/runtime/registry.ts +0 -2
- package/src/{modules/delivery → shared}/delivery-text.ts +5 -4
- package/src/shared/feedback-text.ts +80 -20
- package/src/shared/task-status.ts +42 -0
- package/src/web/frontend/api/cli-tree.json +73 -88
- package/src/web/frontend/api/client.generated.ts +51 -51
- package/src/web/frontend/modules/board/ack-nodes.ts +10 -13
- package/src/web/frontend/modules/board/reopen-text.ts +5 -0
- package/src/web/frontend/modules/md/styles/editor.css +8 -0
- package/src/web/public/assets/{bar-Dc5Tq1eE.js → bar-kaVB6FAa.js} +1 -1
- package/src/web/public/assets/{board-view-BVennxTs.js → board-view-Cwot54HC.js} +1 -1
- package/src/web/public/assets/{composer-launch-fp2IzGzQ.js → composer-launch-BMTU-BD9.js} +1 -1
- package/src/web/public/assets/{composer-panel-Dh681iO6.js → composer-panel-BF6gjNXv.js} +1 -1
- package/src/web/public/assets/{dag-DnaU0I_z.js → dag-BRE33yI8.js} +1 -1
- package/src/web/public/assets/dir-B0IW4NIn.js +3 -0
- package/src/web/public/assets/{doc-DRSKD0Re.js → doc-DsRb-4WT.js} +1 -1
- package/src/web/public/assets/frontmatter-Bcseml1q.js +2 -0
- package/src/web/public/assets/{group-Dc3ZgW24.js → group-CS8VP6z0.js} +1 -1
- package/src/web/public/assets/{index-Bg0m8gbJ.js → index-BT2y9cTX.js} +2 -2
- package/src/web/public/assets/{index-BIVxGd6t.css → index-DSAamoav.css} +1 -1
- package/src/web/public/assets/{md-history-DNtgaIdH.js → md-history-CJ1N9-Jf.js} +1 -1
- package/src/web/public/assets/{md-parse-C9Vd6ejP.js → md-parse-DAYCREP1.js} +1 -1
- package/src/web/public/assets/{model-CtG2jIDv.js → model-TD5kGXzR.js} +1 -1
- package/src/web/public/assets/{overview-C68QpcT9.js → overview-Bsq58sDd.js} +1 -1
- package/src/web/public/assets/{progress-CEmAFxo9.js → progress-B4DfpsyS.js} +1 -1
- package/src/web/public/assets/{refs-TzxZYy7T.js → refs-DIiA_49Z.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-Dg3hJWUV.js → repo-form-modal-DChK4NSX.js} +1 -1
- package/src/web/public/assets/{repos-uNqSR5YB.js → repos-PGFYkUgf.js} +1 -1
- package/src/web/public/assets/{route-crumb-C4DgkJ8G.js → route-crumb-SiMi2C_T.js} +1 -1
- package/src/web/public/assets/{status-tag-8cLH8hl9.js → status-tag-C9YVBvQh.js} +1 -1
- package/src/web/public/assets/task-BL5uxmJh.js +11 -0
- package/src/web/public/assets/{task-row-CRjuAfKW.js → task-row-cE7qblNK.js} +1 -1
- package/src/web/public/assets/{task-utils-DAPxKm4c.js → task-utils-cBR6Gj_c.js} +8 -7
- package/src/web/public/assets/{templates-DNiGvmdq.js → templates-Cfn3Xmsf.js} +3 -3
- package/src/web/public/assets/{use-rail-drag-DxIYcszo.js → use-rail-drag-Boxl7pOG.js} +1 -1
- package/src/web/public/index.html +11 -11
- package/src/modules/claim/actions/localtask-wait.ts +0 -41
- package/src/modules/delivery/index.ts +0 -18
- package/src/web/public/assets/dir-d16q1GLe.js +0 -3
- package/src/web/public/assets/frontmatter-CN6IlxWU.js +0 -2
- package/src/web/public/assets/task-DuFOXLPC.js +0 -11
- /package/src/modules/localtask/{store → infra/store}/topic-adapter.ts +0 -0
- /package/src/modules/localtask/{action-flags.ts → ui/action-flags.ts} +0 -0
- /package/src/modules/localtask/{contract-views.ts → ui/contract-views.ts} +0 -0
|
@@ -36,6 +36,10 @@ import type {
|
|
|
36
36
|
DocsMainAction,
|
|
37
37
|
DocsOrphansAction,
|
|
38
38
|
DocsOrphansPurgeAction,
|
|
39
|
+
RepoDocAddAction,
|
|
40
|
+
RepoDocListAction,
|
|
41
|
+
RepoDocRemoveAction,
|
|
42
|
+
RepoKnowledgeAction,
|
|
39
43
|
} from '../../../modules/docs/actions/_manifest.generated.js';
|
|
40
44
|
import type {
|
|
41
45
|
FileContentAction,
|
|
@@ -111,9 +115,6 @@ import type {
|
|
|
111
115
|
RepoBindTopicsAction,
|
|
112
116
|
RepoCloneAction,
|
|
113
117
|
RepoDetectAction,
|
|
114
|
-
RepoDocAddAction,
|
|
115
|
-
RepoDocListAction,
|
|
116
|
-
RepoDocRemoveAction,
|
|
117
118
|
RepoExportAction,
|
|
118
119
|
RepoGetAction,
|
|
119
120
|
RepoImportAction,
|
|
@@ -121,7 +122,6 @@ import type {
|
|
|
121
122
|
RepoKeyMigrateAction,
|
|
122
123
|
RepoKeyRefreshAction,
|
|
123
124
|
RepoKeySetAction,
|
|
124
|
-
RepoKnowledgeAction,
|
|
125
125
|
RepoListAction,
|
|
126
126
|
RepoOpenAction,
|
|
127
127
|
RepoRefAddAction,
|
|
@@ -206,12 +206,6 @@ export interface ApiClient {
|
|
|
206
206
|
clone(input: z.input<InstanceType<typeof RepoCloneAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoCloneAction>['run']>>>;
|
|
207
207
|
/** 探测目录的 git remote(添加仓库前自动填充远程地址;只读) */
|
|
208
208
|
detect(input: z.input<InstanceType<typeof RepoDetectAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDetectAction>['run']>>>;
|
|
209
|
-
/** 给项目加一篇介绍文档:--ref <refId> | --path <外部绝对路径>(同 ref 重复添加 = 移到末尾) */
|
|
210
|
-
docAdd(input: z.input<InstanceType<typeof RepoDocAddAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDocAddAction>['run']>>>;
|
|
211
|
-
/** 列出项目的介绍文档集(主篇 + 其余各篇,refId + desc) */
|
|
212
|
-
docList(input: z.input<InstanceType<typeof RepoDocListAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDocListAction>['run']>>>;
|
|
213
|
-
/** 从项目的介绍文档集里摘掉一篇(--index 从 1 起,1 = 主篇) */
|
|
214
|
-
docRemove(input: z.input<InstanceType<typeof RepoDocRemoveAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDocRemoveAction>['run']>>>;
|
|
215
209
|
/** 导出仓库布局 JSON(全局 key + 分组 + 参考关系;不含本地路径);--zip 打包成 zip */
|
|
216
210
|
repoExport(input?: z.input<InstanceType<typeof RepoExportAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoExportAction>['run']>>>;
|
|
217
211
|
/** 查看单个仓库的登记信息 */
|
|
@@ -226,8 +220,6 @@ export interface ApiClient {
|
|
|
226
220
|
refresh(input?: z.input<InstanceType<typeof RepoKeyRefreshAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoKeyRefreshAction>['run']>>>;
|
|
227
221
|
/** 设置自定义 key(全局唯一,不跟随远程地址自动变);--follow 恢复为跟随 remote */
|
|
228
222
|
keySet(input: z.input<InstanceType<typeof RepoKeySetAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoKeySetAction>['run']>>>;
|
|
229
|
-
/** 取仓库完整知识:项目介绍 + 所属组(介绍/组内描述/绑定文档)+ 参考仓库(--md 拼成单篇 markdown;缺省当前目录) */
|
|
230
|
-
knowledge(input?: z.input<InstanceType<typeof RepoKnowledgeAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoKnowledgeAction>['run']>>>;
|
|
231
223
|
/** 仓库清单(本地任务的主题会按路径匹配到这里,取它的上下文) */
|
|
232
224
|
repoList(input?: z.input<InstanceType<typeof RepoListAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoListAction>['run']>>>;
|
|
233
225
|
/** 在系统文件管理器中打开 */
|
|
@@ -269,7 +261,7 @@ export interface ApiClient {
|
|
|
269
261
|
/** 把本地 md 文件登记为 mdfile 附件并挂到文档附件区:只存路径指针,不复制正文,不改文档正文 */
|
|
270
262
|
linkFile(input: z.input<InstanceType<typeof DocLinkFileAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocLinkFileAction>['run']>>>;
|
|
271
263
|
/** 文档树索引(自有 + 可选外部;零副作用,双链解析的数据源) */
|
|
272
|
-
|
|
264
|
+
docList(input?: z.input<InstanceType<typeof DocListAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocListAction>['run']>>>;
|
|
273
265
|
/** 读本地 md 文件的正文(只读原文件,核对指纹;文件缺失时返回空正文并标 missing) */
|
|
274
266
|
mdfile(input: z.input<InstanceType<typeof DocMdfileAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocMdfileAction>['run']>>>;
|
|
275
267
|
/** 列出已登记的本地 md 文件(mdfile 附件;--missing 只看失效行) */
|
|
@@ -277,7 +269,7 @@ export interface ApiClient {
|
|
|
277
269
|
/** 新建文档条目(desc + 归属;正文为空、直接可编辑;不创建任何文件) */
|
|
278
270
|
refAdd2(input?: z.input<InstanceType<typeof DocRefAddAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocRefAddAction>['run']>>>;
|
|
279
271
|
/** 删除自有文档(外部绑定不可删) */
|
|
280
|
-
|
|
272
|
+
docRemove(input: z.input<InstanceType<typeof DocRemoveAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocRemoveAction>['run']>>>;
|
|
281
273
|
/** 解绑直接 ref 的归属(不删文档;没有归属后回到 orphan) */
|
|
282
274
|
unbind(input: z.input<InstanceType<typeof DocRefUnbindAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocRefUnbindAction>['run']>>>;
|
|
283
275
|
/** 写文档正文 / 描述(面板保存走这里;ref 是 DB 实体,--ref 可给 refId;只给 --desc 时不动正文) */
|
|
@@ -296,6 +288,14 @@ export interface ApiClient {
|
|
|
296
288
|
purge(input?: z.input<InstanceType<typeof DocsOrphansPurgeAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsOrphansPurgeAction>['run']>>>;
|
|
297
289
|
/** 列出无归属的孤儿文档(失绑时间 / 剩余天数 / 是否有正文;只读) */
|
|
298
290
|
orphans(input?: z.input<InstanceType<typeof DocsOrphansAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocsOrphansAction>['run']>>>;
|
|
291
|
+
/** 给项目加一篇介绍文档:--ref <refId> | --path <外部绝对路径>(同 ref 重复添加 = 移到末尾) */
|
|
292
|
+
docAdd(input: z.input<InstanceType<typeof RepoDocAddAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDocAddAction>['run']>>>;
|
|
293
|
+
/** 列出项目的介绍文档集(主篇 + 其余各篇,refId + desc) */
|
|
294
|
+
docList2(input: z.input<InstanceType<typeof RepoDocListAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDocListAction>['run']>>>;
|
|
295
|
+
/** 从项目的介绍文档集里摘掉一篇(--index 从 1 起,1 = 主篇) */
|
|
296
|
+
docRemove2(input: z.input<InstanceType<typeof RepoDocRemoveAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDocRemoveAction>['run']>>>;
|
|
297
|
+
/** 取仓库完整知识:项目介绍 + 所属组(介绍/组内描述/绑定文档)+ 参考仓库(--md 拼成单篇 markdown;缺省当前目录) */
|
|
298
|
+
knowledge(input?: z.input<InstanceType<typeof RepoKnowledgeAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoKnowledgeAction>['run']>>>;
|
|
299
299
|
/** 向某主题(工作目录)的队列回填一条任务(正文可多行;--file <文件|-> 从文件/标准输入读,长文本不必靠引号硬拼;有 wait 在等则即时投递,否则排队);--global 推到全局共享池;--duration 给任务带时间目标(领取即计时,完成前必须 check);--board/--project 让任务带工作组语义(正文 frontmatter:board + project + 双方介绍引用),并落进该项目的队列;正文自带 frontmatter 时同样认归属——补介绍引用,落点跟到项目队列(显式给过 --cwd 时不挪窝) */
|
|
300
300
|
localtaskAdd(input?: z.input<InstanceType<typeof LocaltaskAddAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAddAction>['run']>>>;
|
|
301
301
|
/** 改一条附件绑定的说明(desc):--attachment <资源 id> --note <说明>(只动说明,角色/位置不变) */
|
|
@@ -560,30 +560,6 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
560
560
|
const body = { "path": inp["path"] };
|
|
561
561
|
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof RepoDetectAction>['run']>>;
|
|
562
562
|
},
|
|
563
|
-
// action: repo.doc.add
|
|
564
|
-
async docAdd(input: z.input<InstanceType<typeof RepoDocAddAction>['_input']>) {
|
|
565
|
-
const inp = input ?? ({} as z.input<InstanceType<typeof RepoDocAddAction>['_input']>);
|
|
566
|
-
const path = `/api/repos/docs`;
|
|
567
|
-
const body = { "id": inp["id"], "ref": inp["ref"], "path": inp["path"] };
|
|
568
|
-
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof RepoDocAddAction>['run']>>;
|
|
569
|
-
},
|
|
570
|
-
// action: repo.doc.list
|
|
571
|
-
async docList(input: z.input<InstanceType<typeof RepoDocListAction>['_input']>) {
|
|
572
|
-
const inp = input ?? ({} as z.input<InstanceType<typeof RepoDocListAction>['_input']>);
|
|
573
|
-
let path = `/api/repos/docs`;
|
|
574
|
-
const q = new URLSearchParams();
|
|
575
|
-
if (inp["id"] !== undefined) q.set("id", String(inp["id"]));
|
|
576
|
-
const query = q.toString();
|
|
577
|
-
if (query) path += path.includes('?') ? '&' + query : '?' + query;
|
|
578
|
-
return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof RepoDocListAction>['run']>>;
|
|
579
|
-
},
|
|
580
|
-
// action: repo.doc.remove
|
|
581
|
-
async docRemove(input: z.input<InstanceType<typeof RepoDocRemoveAction>['_input']>) {
|
|
582
|
-
const inp = input ?? ({} as z.input<InstanceType<typeof RepoDocRemoveAction>['_input']>);
|
|
583
|
-
const path = `/api/repos/docs`;
|
|
584
|
-
const body = { "id": inp["id"], "index": inp["index"] };
|
|
585
|
-
return (await transport.request("DELETE", path, body)) as Awaited<ReturnType<InstanceType<typeof RepoDocRemoveAction>['run']>>;
|
|
586
|
-
},
|
|
587
563
|
// action: repo.export
|
|
588
564
|
async repoExport(input?: z.input<InstanceType<typeof RepoExportAction>['_input']>) {
|
|
589
565
|
const inp = input ?? ({} as z.input<InstanceType<typeof RepoExportAction>['_input']>);
|
|
@@ -638,17 +614,6 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
638
614
|
const body = { "id": inp["id"], "key": inp["key"], "follow": inp["follow"] };
|
|
639
615
|
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof RepoKeySetAction>['run']>>;
|
|
640
616
|
},
|
|
641
|
-
// action: repo.knowledge
|
|
642
|
-
async knowledge(input?: z.input<InstanceType<typeof RepoKnowledgeAction>['_input']>) {
|
|
643
|
-
const inp = input ?? ({} as z.input<InstanceType<typeof RepoKnowledgeAction>['_input']>);
|
|
644
|
-
let path = `/api/repos/knowledge`;
|
|
645
|
-
const q = new URLSearchParams();
|
|
646
|
-
if (inp["id"] !== undefined) q.set("id", String(inp["id"]));
|
|
647
|
-
if (inp["md"] !== undefined) q.set("md", String(inp["md"]));
|
|
648
|
-
const query = q.toString();
|
|
649
|
-
if (query) path += path.includes('?') ? '&' + query : '?' + query;
|
|
650
|
-
return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof RepoKnowledgeAction>['run']>>;
|
|
651
|
-
},
|
|
652
617
|
// action: repo.list
|
|
653
618
|
async repoList(input?: z.input<InstanceType<typeof RepoListAction>['_input']>) {
|
|
654
619
|
const inp = input ?? ({} as z.input<InstanceType<typeof RepoListAction>['_input']>);
|
|
@@ -807,7 +772,7 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
807
772
|
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof DocLinkFileAction>['run']>>;
|
|
808
773
|
},
|
|
809
774
|
// action: doc.list
|
|
810
|
-
async
|
|
775
|
+
async docList(input?: z.input<InstanceType<typeof DocListAction>['_input']>) {
|
|
811
776
|
const inp = input ?? ({} as z.input<InstanceType<typeof DocListAction>['_input']>);
|
|
812
777
|
let path = `/api/docs`;
|
|
813
778
|
const q = new URLSearchParams();
|
|
@@ -844,7 +809,7 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
844
809
|
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof DocRefAddAction>['run']>>;
|
|
845
810
|
},
|
|
846
811
|
// action: doc.remove
|
|
847
|
-
async
|
|
812
|
+
async docRemove(input: z.input<InstanceType<typeof DocRemoveAction>['_input']>) {
|
|
848
813
|
const inp = input ?? ({} as z.input<InstanceType<typeof DocRemoveAction>['_input']>);
|
|
849
814
|
const path = `/api/docs/item`;
|
|
850
815
|
const body = { "ref": inp["ref"] };
|
|
@@ -919,6 +884,41 @@ export function createApiClient(transport: Transport): ApiClient {
|
|
|
919
884
|
if (query) path += path.includes('?') ? '&' + query : '?' + query;
|
|
920
885
|
return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof DocsOrphansAction>['run']>>;
|
|
921
886
|
},
|
|
887
|
+
// action: repo.doc.add
|
|
888
|
+
async docAdd(input: z.input<InstanceType<typeof RepoDocAddAction>['_input']>) {
|
|
889
|
+
const inp = input ?? ({} as z.input<InstanceType<typeof RepoDocAddAction>['_input']>);
|
|
890
|
+
const path = `/api/repos/docs`;
|
|
891
|
+
const body = { "id": inp["id"], "ref": inp["ref"], "path": inp["path"] };
|
|
892
|
+
return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof RepoDocAddAction>['run']>>;
|
|
893
|
+
},
|
|
894
|
+
// action: repo.doc.list
|
|
895
|
+
async docList2(input: z.input<InstanceType<typeof RepoDocListAction>['_input']>) {
|
|
896
|
+
const inp = input ?? ({} as z.input<InstanceType<typeof RepoDocListAction>['_input']>);
|
|
897
|
+
let path = `/api/repos/docs`;
|
|
898
|
+
const q = new URLSearchParams();
|
|
899
|
+
if (inp["id"] !== undefined) q.set("id", String(inp["id"]));
|
|
900
|
+
const query = q.toString();
|
|
901
|
+
if (query) path += path.includes('?') ? '&' + query : '?' + query;
|
|
902
|
+
return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof RepoDocListAction>['run']>>;
|
|
903
|
+
},
|
|
904
|
+
// action: repo.doc.remove
|
|
905
|
+
async docRemove2(input: z.input<InstanceType<typeof RepoDocRemoveAction>['_input']>) {
|
|
906
|
+
const inp = input ?? ({} as z.input<InstanceType<typeof RepoDocRemoveAction>['_input']>);
|
|
907
|
+
const path = `/api/repos/docs`;
|
|
908
|
+
const body = { "id": inp["id"], "index": inp["index"] };
|
|
909
|
+
return (await transport.request("DELETE", path, body)) as Awaited<ReturnType<InstanceType<typeof RepoDocRemoveAction>['run']>>;
|
|
910
|
+
},
|
|
911
|
+
// action: repo.knowledge
|
|
912
|
+
async knowledge(input?: z.input<InstanceType<typeof RepoKnowledgeAction>['_input']>) {
|
|
913
|
+
const inp = input ?? ({} as z.input<InstanceType<typeof RepoKnowledgeAction>['_input']>);
|
|
914
|
+
let path = `/api/repos/knowledge`;
|
|
915
|
+
const q = new URLSearchParams();
|
|
916
|
+
if (inp["id"] !== undefined) q.set("id", String(inp["id"]));
|
|
917
|
+
if (inp["md"] !== undefined) q.set("md", String(inp["md"]));
|
|
918
|
+
const query = q.toString();
|
|
919
|
+
if (query) path += path.includes('?') ? '&' + query : '?' + query;
|
|
920
|
+
return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof RepoKnowledgeAction>['run']>>;
|
|
921
|
+
},
|
|
922
922
|
// action: localtask.add
|
|
923
923
|
async localtaskAdd(input?: z.input<InstanceType<typeof LocaltaskAddAction>['_input']>) {
|
|
924
924
|
const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskAddAction>['_input']>);
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
// 纯函数、零依赖(只 import 同为纯前端的 md-parse.js):前端取节点、单测都能用。
|
|
19
19
|
|
|
20
20
|
import { liveBodyBlocks } from '../md/md-parse.js';
|
|
21
|
+
import { parseCalloutHead, calloutRoleOf, type CalloutHead } from '../../../../shared/feedback-text.js';
|
|
21
22
|
|
|
22
23
|
/** 一轮 ack 节点(extractAckNodes 的出站形状)。 */
|
|
23
24
|
export interface AckNode {
|
|
@@ -34,23 +35,19 @@ export const ACK_NODE_HEADING = '## 上一轮完成总结';
|
|
|
34
35
|
export const ACK_NODE_FEEDBACK_HEADING = '## 验收反馈';
|
|
35
36
|
|
|
36
37
|
// callout 形态(#144):`> [!NOTE] 第 1 轮 · 完成总结` / `> [!WARNING] 第 1 轮 · 验收反馈`
|
|
37
|
-
|
|
38
|
-
const ACK_TITLE_RE = /完成总结/;
|
|
39
|
-
const FB_TITLE_RE = /反馈/;
|
|
40
|
-
const ROUND_NUM_RE = /第\s*(\d+)\s*轮/;
|
|
38
|
+
// 语义角色判据与 reorderRounds / countAckRounds 共用 feedback-text 的「类型优先」口径。
|
|
41
39
|
|
|
42
|
-
/** callout 块 → {
|
|
43
|
-
function calloutOf(block: unknown): {
|
|
40
|
+
/** callout 块 → { head, body }(body 为剥掉 `> ` 的正文行);不是 callout 返回 null */
|
|
41
|
+
function calloutOf(block: unknown): { head: CalloutHead; body: string } | null {
|
|
44
42
|
const lines = String(block ?? '').split('\n');
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
if (!m) return null;
|
|
43
|
+
const head = parseCalloutHead(lines[0]);
|
|
44
|
+
if (!head) return null;
|
|
48
45
|
const body = lines
|
|
49
46
|
.slice(1)
|
|
50
47
|
.map((l) => l.replace(/^>[ \t]?/, ''))
|
|
51
48
|
.filter((l) => l.trim() !== '')
|
|
52
49
|
.join('\n');
|
|
53
|
-
return {
|
|
50
|
+
return { head, body };
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
/**
|
|
@@ -79,9 +76,9 @@ export function extractAckNodes(body: unknown): AckNode[] {
|
|
|
79
76
|
blocks.forEach((raw, i) => {
|
|
80
77
|
const b = String(raw || '').trim();
|
|
81
78
|
const co = calloutOf(b);
|
|
82
|
-
if (co &&
|
|
79
|
+
if (co && calloutRoleOf(co.head) === 'summary') {
|
|
83
80
|
// callout 完成总结块:轮次号优先取标题里的「第 N 轮」
|
|
84
|
-
const rNum =
|
|
81
|
+
const rNum = co.head.round;
|
|
85
82
|
cur = {
|
|
86
83
|
round: Number.isFinite(rNum) && rNum > 0 ? rNum : out.length + 1,
|
|
87
84
|
blockIndex: i,
|
|
@@ -105,7 +102,7 @@ export function extractAckNodes(body: unknown): AckNode[] {
|
|
|
105
102
|
phase = 'ack';
|
|
106
103
|
return;
|
|
107
104
|
}
|
|
108
|
-
if (co &&
|
|
105
|
+
if (co && calloutRoleOf(co.head) === 'feedback') {
|
|
109
106
|
// callout 反馈块归属**当前正在填的 ack 段**(孤儿反馈块不算节点)
|
|
110
107
|
if (cur && phase === 'ack') {
|
|
111
108
|
cur.feedbackBlockIndex = i;
|
|
@@ -18,6 +18,11 @@ export {
|
|
|
18
18
|
PLAIN_FEEDBACK_HEADING,
|
|
19
19
|
ACK_CALLOUT_TYPE,
|
|
20
20
|
FEEDBACK_CALLOUT_TYPE,
|
|
21
|
+
parseCalloutHead,
|
|
22
|
+
calloutRoleOf,
|
|
23
|
+
calloutTypeTitleConflict,
|
|
24
|
+
type CalloutRole,
|
|
25
|
+
type CalloutHead,
|
|
21
26
|
ackCalloutSection,
|
|
22
27
|
feedbackCalloutSection,
|
|
23
28
|
ackCalloutTitle,
|
|
@@ -287,6 +287,14 @@
|
|
|
287
287
|
.md-callout .md-callout-b{font-size:13px;line-height:1.55;color:var(--ink-2,#4B515A)}
|
|
288
288
|
.md-callout .md-callout-b>:first-child{margin-top:0}
|
|
289
289
|
.md-callout .md-callout-b>:last-child{margin-bottom:0}
|
|
290
|
+
/* NOTE 显式选择器:与 WARNING/TIP/IMPORTANT/CAUTION 对齐,避免调基础 .md-callout 时
|
|
291
|
+
连带改动完成总结块;值与基础样式一致(绿 accent)。 */
|
|
292
|
+
.md-callout-note{
|
|
293
|
+
border-color:var(--mdw-accent-line,#B7D4C8);
|
|
294
|
+
border-left-color:var(--mdw-accent,#2F6F5E);
|
|
295
|
+
background:var(--mdw-accent-soft,#E8F2EE);
|
|
296
|
+
}
|
|
297
|
+
.md-callout-note .md-callout-t{color:var(--mdw-accent,#2F6F5E)}
|
|
290
298
|
.md-callout-warning{
|
|
291
299
|
border-color:#E8D9B5;border-left-color:#C08A2D;background:#FBF3E1;
|
|
292
300
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r}from"./popup-DZ2Khv2c.js";import{w as i}from"./workspace-DojQ3RP4.js";import{_ as a,b as o,v as s,x as c,y as l}from"./md-history-
|
|
1
|
+
import{a as e,d as t,f as n,h as r}from"./popup-DZ2Khv2c.js";import{w as i}from"./workspace-DojQ3RP4.js";import{_ as a,b as o,v as s,x as c,y as l}from"./md-history-CJ1N9-Jf.js";var u=r(n(),1),d=i(),f=t();function p({kind:t,renderers:n={},actions:r={},titles:i={},disabled:p={},labels:m={},className:h=``}){let{layout:g,setLayout:_}=s(t),[v,y]=(0,u.useState)(!1),[b,x]=(0,u.useState)(null),[S,C]=(0,u.useState)(!1),w=(0,u.useRef)(null),T=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!v)return;let e=e=>{let t=e.target;w.current?.contains(t)||T.current?.contains(t)||y(!1)},t=e=>{e.key===`Escape`&&y(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[v]);let E=g.filter(e=>c(t,e)),D=g.filter(e=>l(t,e)),O=e=>m[e]||o(t,e).label||e,k=(n,a={})=>{let s=o(t,n);return(0,f.jsxs)(`button`,{type:`button`,className:a.primary?`btn small primary`:`btn small ghost`,title:i[n]||O(n),disabled:!!p[n],onClick:()=>r[n]&&r[n](),children:[s.icon?(0,f.jsx)(e,{name:s.icon}):null,O(n)]},n)},A=r=>{if(r===`more`)return(0,f.jsxs)(`button`,{ref:w,type:`button`,className:`btn small ghost`+(v?` is-open`:``),title:i.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":v,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();x({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),y(e=>!e)},children:[(0,f.jsx)(e,{name:`dots`}),O(`more`),` ▾`]},`more`);let a=n[r];return a?(0,f.jsx)(`span`,{className:`ta-slot`,children:a({open:v})},r):k(r,{primary:o(t,r).section===`primary`})};return(0,f.jsxs)(`div`,{className:`ta-bar`+(h?` ${h}`:``),children:[E.map(e=>A(e.id)),v&&b&&(0,d.createPortal)((0,f.jsxs)(`div`,{ref:T,className:`ta-more-menu`,role:`menu`,style:{top:b.top,right:b.right},children:[D.length===0&&(0,f.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),D.map(n=>{let a=o(t,n.id);return(0,f.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!p[n.id],title:i[n.id]||O(n.id),onClick:()=>{y(!1);let e=r[n.id];e&&e()},children:[a.icon?(0,f.jsx)(e,{name:a.icon}):null,O(n.id)]},n.id)}),(0,f.jsx)(`div`,{className:`ta-more-sep`}),(0,f.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{y(!1),C(!0)},children:[(0,f.jsx)(e,{name:`gear`}),`自定义工具栏…`]})]}),document.body),S&&(0,d.createPortal)((0,f.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>C(!1),children:(0,f.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,f.jsx)(a,{kind:t,layout:g,setLayout:_,onClose:()=>C(!1)})})}),document.body)]})}export{p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./frontmatter-
|
|
1
|
+
import{c as e}from"./frontmatter-Bcseml1q.js";var t=`__GLOBAL__`;function n(e=[]){let t=Array.isArray(e)?e:[];return{pending:t.filter(e=>e.status===`pending`&&!e.deletedAt&&!e.migratedTo),claimed:t.filter(e=>e.status===`claimed`&&!e.deletedAt).slice().reverse(),done:t.filter(e=>e.status===`done`&&!e.deletedAt).slice().reverse(),cancelled:t.filter(e=>e.status===`cancelled`&&!e.deletedAt).slice().reverse(),deleted:t.filter(e=>!!e.deletedAt).slice().reverse(),migrated:t.filter(e=>!!e.migratedTo&&!e.deletedAt)}}function r(e=[]){let t=Array.isArray(e)?e:[],n=[],r=[],i=[],a=[],o=[],s=[];for(let e of t)e.deletedAt?s.push(e):e.status===`claimed`?r.push(e):e.status===`done`?i.push(e):e.status===`cancelled`?a.push(e):e.migratedTo?o.push(e):n.push(e);return[...n,...r.reverse(),...o,...i.reverse(),...a.reverse(),...s.reverse()]}function i(e){return!!(e&&e.boardMark)}function a(t){return e(t)}function o(e=[]){return(Array.isArray(e)?e:[]).filter(e=>!e.deletedAt&&!i(e))}function s(e=[]){return o(e).filter(a).length}function c(e){return[e&&e.id,e&&e.key,e&&e.name].filter(Boolean).map(String)}function l(e,t){return!i(e)||!e?!1:(Array.isArray(t)?t:c(t)).includes(String(e.boardMark))}function u(e=[],t=[],n,r){let i=(t||[]).find(e=>e&&(e.id===n||e.key===n||e.name===n))||null,a={board:i,topic:null,taskRow:null};if(!i||r==null||String(r)===``)return a;let o=new Set((i.repos||[]).map(e=>e&&(e.key||e.id)).filter(Boolean)),s=e=>{let t=e&&e.repo;return[t&&t.key,t&&t.id,e&&e.key].filter(Boolean)},l=c(i);for(let t of e||[]){if(!t||t.isGlobal||o.size&&!s(t).some(e=>o.has(e)))continue;let e=(t.tasks||[]).find(e=>e&&!e.deletedAt&&String(e.id)===String(r));if(e&&(a.topic||(a.topic=t,a.taskRow=e),l.includes(String(e.boardMark||``)))){a.topic=t,a.taskRow=e;break}}return a}export{s as a,l as c,a as i,u as n,r as o,i as r,n as s,t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t}from"./popup-DZ2Khv2c.js";import{c as n,r}from"./workspace-DojQ3RP4.js";import{T as i}from"./md-history-
|
|
1
|
+
import{a as e,d as t}from"./popup-DZ2Khv2c.js";import{c as n,r}from"./workspace-DojQ3RP4.js";import{T as i}from"./md-history-CJ1N9-Jf.js";var a=t();function o({attachments:t,onRemove:n}){return t?.length?(0,a.jsxs)(`div`,{className:`mdw-attach`,children:[(0,a.jsx)(`div`,{className:`lab`,children:`附件 / 图片`}),(0,a.jsx)(`div`,{className:`list`,children:t.map(t=>(0,a.jsxs)(`div`,{className:`att`,children:[t.type===`image`&&t.url?(0,a.jsx)(`img`,{src:t.url,alt:``}):(0,a.jsx)(`div`,{className:`ico`,children:(0,a.jsx)(e,{name:`list`,size:14,title:void 0})}),(0,a.jsxs)(`div`,{className:`meta`,children:[(0,a.jsx)(`div`,{className:`n`,children:t.name}),(0,a.jsx)(`div`,{className:`s`,children:t.size})]}),(0,a.jsx)(`button`,{type:`button`,className:`x`,"aria-label":`移除`,onClick:()=>n(t.id),children:`×`})]},t.id))})]}):null}var s=`nx-kv-md-attachments-v1`;function c(){try{return JSON.parse(localStorage.getItem(s)||`{}`)||{}}catch{return{}}}function l(e){try{localStorage.setItem(s,JSON.stringify(e))}catch{}}function u(e,t){let n=c();n[e]=t,l(n)}function d(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function f(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``)),r.onerror=n,r.readAsDataURL(e)})}async function p(e){let t=[],n=[];for(let r of[...e]){let e=`a`+Date.now()+Math.random().toString(16).slice(2,6),i=/^image\//.test(r.type),a={id:e,name:r.name,type:i?`image`:`file`,size:d(r.size)};i&&(a.url=await f(r),n.push(`\n\n`)),t.push(a)}return{items:t,imageInserts:n,fileInserts:[]}}async function m(e){let t=[...e||[]];if(!t.length)return{items:[],imageInserts:[],fileInserts:[]};try{let e=await i(t),n=[],r=[],a=[];for(let t of e){let e=t.fileId||t.id,i=!!t.isImage;n.push({id:e,name:t.name,type:i?`image`:`file`,size:d(Number(t.size)||0),url:`/api/file/content/${e}`});let o=t.markdown||{},s=i?o.image||``:o.file||`[${t.name}](${e})`;(i?r:a).push(`\n${s}\n`)}return{items:n,imageInserts:r,fileInserts:a}}catch{return p(e||[])}}var h=new Map;function g(e,t={}){if(!e)return null;let{mode:i=`comment`,quote:a=``,prevQuote:o=``,taskLabel:s=``,taskTitle:c=``,src:l=null,onSubmit:u=null,onFiles:d=null}=t,f=`cmp`+Date.now().toString(36)+Math.random().toString(36).slice(2,8),p=n(e);return h.set(f,{onSubmit:u,onFiles:d,prev:p}),r(e,{component:`compose`,name:i===`feedback`?`反馈`:`评论`,config:{token:f,mode:i,quote:a,prevQuote:o,taskLabel:s,taskTitle:c,src:l},location:`center`}),f}function _(e,t){let i=h.get(t);if(h.delete(t),!i||!i.prev||!e)return null;let a=n(e);return a&&a.component!==`compose`?null:r(e,i.prev)}function v(e){return h.get(e)||null}export{u as a,m as i,g as n,o,_ as r,v as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,l as i}from"./popup-DZ2Khv2c.js";import{t as a}from"./workspace-DojQ3RP4.js";import{n as o}from"./app-context-BqCBcDsx.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./md-history-
|
|
1
|
+
import{a as e,d as t,f as n,h as r,l as i}from"./popup-DZ2Khv2c.js";import{t as a}from"./workspace-DojQ3RP4.js";import{n as o}from"./app-context-BqCBcDsx.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./md-history-CJ1N9-Jf.js";import"./index-BT2y9cTX.js";import{i as p,o as m,r as ee,t as h}from"./composer-launch-BMTU-BD9.js";var g=r(n(),1),_=t(),v=96;function y({token:t,mode:n=`comment`,quote:r=``,prevQuote:y=``,taskLabel:b=``,taskTitle:x=``,src:S=null}){let C=o(),w=i(),[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-`+t,F=()=>{f(N.current,P),ee(C.model,t)},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 e=String(T||``).trim();if(!e&&!D.length){w(M?`写一下要改的地方`:`写一下要提的问题`);return}let n=h(t);if(!n||!n.onSubmit){w(`提交入口已失效(来源页面已关闭)`);return}A(!0);try{await n.onSubmit({text:e,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||`(这条任务还没有可引用的上轮总结)`})]}):r?(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:r}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:r})]}):null,(0,_.jsx)(`div`,{className:`cmp-body`,children:(0,_.jsx)(s,{mode:`split`,title:``,body:T,onTitle:()=>{},onBody:I,attachments:D,docKey:`compose-`+t,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)(e,{name:`plus`,title:void 0})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:X,title:q?`还原面板高度`:`最大化面板高度`,"aria-label":q?`还原面板高度`:`最大化面板高度`,children:(0,_.jsx)(e,{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)(e,{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)(e,{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)(e,{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 +1 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,i,l as a,n as o,u as s}from"./popup-DZ2Khv2c.js";import{n as c}from"./app-context-BqCBcDsx.js";import{t as l}from"./frontmatter-CN6IlxWU.js";import{r as u}from"./md-parse-C9Vd6ejP.js";import{r as d}from"./board-view-BVennxTs.js";import{i as f}from"./model-CtG2jIDv.js";import{t as p}from"./graph-BTEfvFz6.js";var m=r(n(),1);function h(e){return!(!e||e.deletedAt||e.migratedTo)}function g(e){return h(e)&&e?.status===`pending`}function _(e){return u(e.text)||f(e)||`#${e.id}`}function v(e,t){return`${e}:${Number(t)}`}function y(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return{kind:`local`,id:Math.trunc(e)};let t=String(e??``).trim();if(!t)return null;let n=/^([A-Za-z0-9_-]+):(\d+)$/.exec(t),r=n?.[1],i=n?.[2];if(r&&i)return{kind:`foreign`,key:r,id:Number(i)};if(/^\d+$/.test(t)){let e=Number(t);if(e>0)return{kind:`local`,id:e}}return null}function b(e,t){let n=y(e);return n?n.kind===`foreign`?v(n.key,n.id):v(t,n.id):null}function ee(e,t){return e.topicKey===t?Number(e.id):v(e.topicKey,e.id)}function te(e){return s(`/api/localtasks/item`,{method:`PATCH`,body:e})}function x(e,t={}){let n=Math.max(3,Number(t.perCol)||8),r=new Map;for(let t of e){let e=r.get(t.topicKey);e?e.push(t):r.set(t.topicKey,[t])}let i=new Map,a=0;for(let[,e]of r)e.forEach((e,t)=>{let r=a+Math.floor(t/n),o=t%n;i.set(e.nodeKey,{x:56+r*320,y:28+o*94})}),a+=Math.ceil(e.length/n);return i}var S=e=>`nx-kv-dag-pos:${e}`;function ne(e){try{let t=JSON.parse(localStorage.getItem(S(e))||`{}`),n=new Map;for(let[e,r]of Object.entries(t||{}))if(Array.isArray(r)&&Number.isFinite(r[0])&&Number.isFinite(r[1])){let t=Number(r[0]),i=Number(r[1]);n.set(e,{x:t,y:i})}return n}catch{return new Map}}function re(e){try{localStorage.removeItem(S(e))}catch{}}function C(e,t){try{let n={};for(let[e,r]of t)r&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&(n[e]=[Math.round(r.x),Math.round(r.y)]);return localStorage.setItem(S(e),JSON.stringify(n)),!0}catch{return!1}}function ie(e,t,n,r){let i=Math.max(48,Math.abs(n-e)*.5);return`M ${e} ${t} C ${e+i} ${t}, ${n-i} ${r}, ${n} ${r}`}function w(e,t,n){let r=e.getBoundingClientRect();return{x:t-r.left+e.scrollLeft,y:n-r.top+e.scrollTop}}function ae(e,t,n,r){let i=t.get(n)||{x:0,y:0};return{x:i.x+280,y:i.y+r(n)/2}}function oe(e,t,n,r){let i=[];for(let a of e){let e=t.get(a.nodeKey);if(!e)continue;let o=r(a.nodeKey);for(let s of a.blockBy||[]){let c=b(s,a.topicKey);if(!c||!n.has(c))continue;let l=t.get(c);if(!l)continue;let u=r(c),d=e.x>l.x+280-8;i.push({from:c,to:a.nodeKey,x1:d?l.x+280:l.x,y1:l.y+u/2,x2:d?e.x:e.x+280,y2:e.y+o/2})}}return i}function se({canvasRef:e,modeRef:t,posRef:n,nodesRef:r,byNodeKeyRef:i,scopeKeyRef:a,userMovedRef:o,commitRef:s,toastRef:c,setPos:l,setDragId:u,setLinking:d}){let f=(t,i)=>{let a=e.current;if(!a)return null;let{x:o,y:s}=w(a,t,i),c=r.current;for(let e=c.length-1;e>=0;e--){let t=c[e];if(!t)continue;let r=t.nodeKey,i=n.current.get(r);if(!i)continue;let l=a.querySelector(`[data-node-id="${CSS.escape(r)}"]`),u=l instanceof HTMLElement?l.offsetHeight:64;if(o>=i.x-10&&o<=i.x+280+28&&s>=i.y-6&&s<=i.y+u+6)return r}return null},p=e=>{if(!e||e.kind!==`link`){d(null);return}d({sourceId:e.sourceId,x:e.x1,y:e.y1,cx:e.cx,cy:e.cy,overId:e.overId,dragged:!!e.dragged})},h=()=>{t.current=null,u(null),d(null)};return(0,m.useEffect)(()=>{let r=n=>{let r=t.current;if(!r)return;let i=e.current;if(!i)return;let a=w(i,n.clientX,n.clientY);if(r.kind===`drag`){let e=Math.max(8,a.x-r.ox),t=Math.max(8,a.y-r.oy);l(n=>{let i=new Map(n);return i.set(r.id,{x:e,y:t}),i});return}if(r.kind===`link`){let e=f(n.clientX,n.clientY),i=e&&e!==r.sourceId?e:null,o=Math.hypot(a.x-r.sx,a.y-r.sy),s=r.dragged||o>=6,c={...r,cx:a.x,cy:a.y,overId:i,dragged:s};t.current=c,p(c)}},u=async e=>{let r=t.current;if(r){if(r.kind===`drag`){o.current.add(r.id),C(a.current,n.current),h();return}if(r.kind===`link`){let t=r.overId||f(e.clientX,e.clientY),n=r.sourceId;if(t&&t!==n){h(),await s.current(n,t);return}if(r.dragged){h();return}let a=i.current.get(n);c.current(`已选 #${a?.id??n},再点目标画出有向边`)}}},d=e=>{e.key===`Escape`&&h()};return window.addEventListener(`pointermove`,r),window.addEventListener(`mousemove`,r),window.addEventListener(`pointerup`,u),window.addEventListener(`mouseup`,u),window.addEventListener(`pointercancel`,h),window.addEventListener(`keydown`,d),()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`mousemove`,r),window.removeEventListener(`pointerup`,u),window.removeEventListener(`mouseup`,u),window.removeEventListener(`pointercancel`,h),window.removeEventListener(`keydown`,d)}},[]),{publishLink:p,clearMode:h}}var T=t();function ce({title:e,count:t,linkArmed:n,srcLabel:r,groupMode:i,queues:a,filterKey:o,onFilter:s,onReset:c}){return(0,T.jsxs)(`div`,{className:`dagp-head`,children:[(0,T.jsx)(`span`,{className:`dagp-title`,children:e}),(0,T.jsxs)(`span`,{className:`dagp-count`,children:[t,` 个待领取节点`]}),(0,T.jsx)(`span`,{className:`dagp-hint`,children:n?`连线中:再点目标完成 #${r} → 目标(Esc 取消)`:i?`组内全量任务;跨项目连线对 get 生效;未连线走各队列默认序`:`点右侧 ● 再点目标 = 有向顺序;未连线 = 无先后、走默认序`}),i&&a.length>0&&(0,T.jsxs)(`span`,{className:`dagp-queues`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(o===``?` on`:``),onClick:()=>s(``),children:[`全部`,(0,T.jsx)(`i`,{children:a.reduce((e,t)=>e+t.total,0)})]}),a.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(e.key===o?` on`:``),title:`${e.name} · ${e.count}/${e.total}`,onClick:()=>s(e.key),children:[e.name,(0,T.jsx)(`i`,{children:e.count})]},e.key))]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-reset`,onClick:c,title:`清掉记住的摆位,按默认分栏重排`,children:`恢复默认布局`})]})}function le({n:t,p:n,byNodeKey:r,groupMode:i,dragId:a,linking:o,linkArmed:s,onStartDrag:c,onStartLink:l,onOpenTask:u,onToggleGate:d,onAddTimegoal:f,onRemoveDep:p,onOpsMenu:m}){let h=(t.blockBy||[]).map(e=>({token:e,key:b(e,t.topicKey)})).filter(e=>e.key&&r.has(e.key)),g=o&&o.overId===t.nodeKey,v=o&&o.sourceId===t.nodeKey;return(0,T.jsxs)(`div`,{"data-node-id":t.nodeKey,className:`dagp-node`+(a===t.nodeKey?` dragging`:``)+(g?` over`:``)+(v?` linking-src`:``)+(t.blocksFollowing?` gate`:``)+(s&&!v?` link-target`:``),style:{transform:`translate(${n.x}px, ${n.y}px)`,width:280},onPointerDown:e=>c(e,t),children:[(0,T.jsx)(`span`,{className:`dagp-port in`,title:`入:箭头指向我 = 我等对方`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`dagp-body`,children:[(0,T.jsxs)(`div`,{className:`dagp-top`,children:[(0,T.jsxs)(`span`,{className:`dagp-no mono`,children:[`#`,t.id]}),i&&(0,T.jsx)(`span`,{className:`dagp-chip proj`,children:t.projectName}),t.blocksFollowing&&(0,T.jsx)(`span`,{className:`dagp-chip gate`,children:`闸门`}),t.ready===!1&&(0,T.jsx)(`span`,{className:`dagp-chip lock`,children:`锁定`}),t.timegoal?.duration&&(0,T.jsxs)(`span`,{className:`dagp-chip goal`,children:[`⏱ `,t.timegoal.duration]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-ops`,title:`节点操作`,"aria-label":`节点操作`,onClick:e=>{e.stopPropagation();let n=[{label:`打开任务`,onClick:()=>u(t)},{label:t.blocksFollowing?`取消闸门`:`设为闸门(挡住后续)`,onClick:()=>d(t)},{label:t.timegoal?.duration?`改时间目标`:`加时间目标(timegoal)`,onClick:()=>f(t)}],r=e.currentTarget.getBoundingClientRect();m({x:r.left,y:r.bottom,items:n})},children:(0,T.jsx)(e,{name:`dots`,size:13,title:void 0})})]}),(0,T.jsx)(`div`,{className:`dagp-name`,title:t.text,onDoubleClick:e=>{e.stopPropagation(),u(t)},children:_(t)}),h.length>0&&(0,T.jsx)(`div`,{className:`dagp-deps`,children:h.map(({token:e,key:n})=>{let i=n?r.get(n):void 0,a=!!i&&i.topicKey!==t.topicKey;return(0,T.jsxs)(`span`,{className:`dagp-chip dep`,title:a&&i?`跨项目 #${i.id}@${i.projectName} → #${t.id}`:`#${i?.id} → #${t.id}`,children:[`← #`,i?.id,a?`@${i.projectName}`:``,(0,T.jsx)(`i`,{role:`button`,"aria-label":`解除依赖`,onClick:n=>{n.stopPropagation(),p(t,e)},children:`×`})]},String(e))})})]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-port out`,title:`点一下再点目标,或按住拖到目标 = 有向顺序(可跨项目)`,"aria-label":`从 #${t.id} 开始连线`,onPointerDown:e=>l(e,t)})]})}function E({dirKey:e,groupId:t}){let n=c(),r=a(),{dialog:s,node:u}=i(),f=n.rows||[],h=n.refreshLocal,_=(0,m.useId)().replace(/:/g,``),S=n.repoData&&n.repoData.boards||[],C=(0,m.useMemo)(()=>S.find(e=>e.id===t||e.key===t)||null,[S,t]),E=!!C,ue=(0,m.useMemo)(()=>{if(!C)return[];let e=[];for(let t of C.repos||[]){let n=f.find(e=>e.repo&&e.repo.key===t.key);if(!n)continue;let r=[C.id,C.key,C.name].filter(Boolean),i=(n.tasks||[]).filter(e=>{if(!g(e))return!1;let t=l(e.text);return t.board&&r.includes(t.board)});i.length&&e.push({key:n.key,name:t.name||t.key,cwd:n.cwd,isGlobal:!!n.isGlobal,count:i.length,total:i.length})}return e},[C,f]),[D,de]=(0,m.useState)(``);(0,m.useEffect)(()=>{E||de(``)},[E,t]);let O=(0,m.useMemo)(()=>E?null:f.find(t=>t.key===e)||null,[E,f,e]),k=(0,m.useMemo)(()=>{if(E&&C){let e=[C.id,C.key,C.name].filter(Boolean),t=[];for(let n of C.repos||[]){let r=f.find(e=>e.repo&&e.repo.key===n.key);if(r&&!(D&&r.key!==D))for(let i of r.tasks||[]){if(!g(i))continue;let a=l(i.text);a.board&&e.includes(a.board)&&t.push({...i,topicKey:r.key,topicCwd:r.cwd,topicIsGlobal:!!r.isGlobal,projectName:n.name||n.key,nodeKey:v(r.key,i.id)})}}return t}return O?(O.tasks||[]).filter(e=>g(e)&&!d(e)).map(e=>({...e,topicKey:O.key,topicCwd:O.cwd,topicIsGlobal:!!O.isGlobal,projectName:O.name||O.key,nodeKey:v(O.key,e.id)})):[]},[E,C,f,D,O]),A=(0,m.useMemo)(()=>new Map(k.map(e=>[e.nodeKey,e])),[k]),j=(0,m.useRef)(A);j.current=A;let M=(0,m.useRef)(k);M.current=k;let N=(0,m.useRef)(null),[P,F]=(0,m.useState)(()=>new Map),I=(0,m.useRef)(P);I.current=P;let[fe,pe]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=N.current;if(!e)return;let t=()=>pe(e.clientHeight||0);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[]);let L=Math.max(3,Math.floor(((fe||720)-56)/94)||8),R=E?`g:${C?.id||t||``}`:`d:${e||``}`,z=(0,m.useRef)(R);z.current=R;let B=(0,m.useMemo)(()=>ne(R),[R]),V=(0,m.useRef)(R),H=(0,m.useRef)(new Set);(0,m.useEffect)(()=>{let e=V.current!==R;V.current=R,F(t=>{let n=new Map,r=x(k,{perCol:L});for(let i of k){let a=B.get(i.nodeKey)||(!e&&H.current.has(i.nodeKey)?t.get(i.nodeKey):null)||r.get(i.nodeKey)||{x:56,y:28};n.set(i.nodeKey,a)}return n})},[k,L,B,R]);let U=(0,m.useRef)(null),[W,me]=(0,m.useState)(null),[G,he]=(0,m.useState)(null),[K,ge]=(0,m.useState)(null),[_e,ve]=(0,m.useState)(!1),q=(0,m.useRef)(!1);q.current=_e;let J=(0,m.useRef)(async()=>!1),Y=(0,m.useRef)(r);Y.current=r;let X=async(e,t,n)=>{ve(!0);try{let i={...t};Array.isArray(i.blockBy)&&(i.blockBy=i.blockBy.join(`,`)),await te({...e.topicIsGlobal?{key:e.topicKey}:{cwd:e.topicCwd},id:Number(e.id),...i}),n&&r(n),h&&await h()}catch(e){r(String(e.message||e))}finally{ve(!1)}},{publishLink:ye,clearMode:Z}=se({canvasRef:N,modeRef:U,posRef:I,nodesRef:M,byNodeKeyRef:j,scopeKeyRef:z,userMovedRef:H,commitRef:J,toastRef:Y,setPos:F,setDragId:me,setLinking:he});J.current=async(e,t)=>{if(!t||t===e)return!1;let n=j.current.get(e),r=j.current.get(t);if(!n||!r||!g(r))return Y.current(`只能连到待领取任务`),!1;if(r.blocksFollowing)return Y.current(`#${r.id} 是闸门,不能声明上游`),!1;let i=ee(n,r.topicKey),a=[...r.blockBy||[]];if(a.some(e=>{let t=y(e),n=y(i);return!t||!n||t.kind!==n.kind?!1:(t.kind===`local`&&n.kind===`local`||t.kind===`foreign`&&n.kind===`foreign`&&t.key===n.key)&&t.id===n.id}))return Y.current(`已有该有向边`),!1;if(p(e=>{let t=j.current.get(String(e));if(!t)return[];let n=[];for(let e of t.blockBy||[]){let r=b(e,t.topicKey);r&&j.current.has(r)&&n.push(r)}return n},e,t))return Y.current(`会形成环,已取消`),!1;let o=n.topicKey!==r.topicKey;return await X(r,{blockBy:[...a,i]},o?`#${n.id}@${n.projectName} → #${r.id}@${r.projectName}`:`#${n.id} → #${r.id}`),!0};let be=(e,t)=>{if(q.current||e.button!==0||e.target instanceof Element&&e.target.closest(`.dagp-port, .dagp-ops, .dagp-chip, button, a`))return;let n=U.current;if(n&&n.kind===`link`){if(e.preventDefault(),e.stopPropagation(),t.nodeKey===n.sourceId){Z();return}if(!g(t)){Y.current(`只能连到待领取任务`);return}let r=n.sourceId;Z(),J.current(r,t.nodeKey);return}if(U.current||!g(t))return;e.preventDefault();let r=N.current;if(!r)return;let i=I.current.get(t.nodeKey)||{x:0,y:0},a=w(r,e.clientX,e.clientY);U.current={kind:`drag`,id:t.nodeKey,ox:a.x-i.x,oy:a.y-i.y},me(t.nodeKey)},xe=(e,t)=>{if(q.current||!g(t)||e.button!==0)return;if(e.preventDefault(),e.stopPropagation(),U.current?.kind===`link`&&U.current.sourceId===t.nodeKey){Z();return}let n=ae(N.current,I.current,t.nodeKey,De),r=N.current,i=r?w(r,e.clientX,e.clientY):{x:n.x,y:n.y},a={kind:`link`,sourceId:t.nodeKey,x1:n.x,y1:n.y,cx:i.x,cy:i.y,overId:null,dragged:!1,sx:i.x,sy:i.y};U.current=a,ye(a)},Se=e=>{U.current&&U.current.kind===`link`&&(e.target instanceof Element&&e.target.closest(`.dagp-node`)||Z())},Ce=async(e,t)=>{let n=[...e.blockBy||[]].filter(e=>{let n=y(e),r=y(t);return!n||!r?String(e)!==String(t):n.kind===r.kind?n.kind===`local`&&r.kind===`local`?n.id!==r.id:n.kind===`foreign`&&r.kind===`foreign`?n.key!==r.key||n.id!==r.id:!0:!0});await X(e,{blockBy:n},`已解除依赖 → #${e.id}`)},we=e=>X(e,{gate:!e.blocksFollowing},e.blocksFollowing?`#${e.id} 取消闸门`:`#${e.id} 设为闸门`),Te=async e=>{let t=await s({title:`时间目标 · #${e.id}`,input:!0,placeholder:`如 2h / 90m`,value:e.timegoal?.duration||``});if(t==null)return;let n=String(t).trim();if(!n){await X(e,{clearGoal:!0},`#${e.id} 已清除时间目标`);return}await X(e,{duration:n},`#${e.id} 时间目标 ${n}`)},Ee=e=>{n.openPage&&(t?n.openPage({groupId:t,task:String(e.id),name:`#${e.id}`}):n.openPage({dirKey:e.topicKey,task:String(e.id),name:`#${e.id}`}))},De=e=>{let t=N.current?.querySelector(`[data-node-id="${CSS.escape(e)}"]`);return t instanceof HTMLElement?t.offsetHeight:64},Oe=(0,m.useMemo)(()=>oe(k,P,A,De),[k,P,A,W,G]),Q=(0,m.useMemo)(()=>{let e=480,t=240;for(let n of k){let r=P.get(n.nodeKey);r&&(e=Math.max(e,r.x+280+100),t=Math.max(t,r.y+140))}return G&&(e=Math.max(e,G.cx+40),t=Math.max(t,G.cy+40)),{w:e,h:t}},[k,P,G]),ke=E?C?.name||`组编排`:O?.name||e||`编排`,Ae=()=>{re(z.current),H.current.clear(),F(x(k,{perCol:L})),r(`已恢复默认布局`)},$=!!G,je=G?A.get(G.sourceId)?.id??G.sourceId:``;return(0,T.jsxs)(`div`,{className:`dagp`+($?` is-linking`:``)+(W==null?``:` is-dragging`),children:[(0,T.jsx)(ce,{title:ke,count:k.length,linkArmed:$,srcLabel:je,groupMode:E,queues:ue,filterKey:D,onFilter:de,onReset:Ae}),(0,T.jsxs)(`div`,{className:`dagp-canvas`,ref:N,onPointerDown:Se,children:[(0,T.jsxs)(`svg`,{className:`dagp-edges`,width:Q.w,height:Q.h,style:{width:Q.w,height:Q.h},"aria-hidden":`true`,children:[(0,T.jsx)(`defs`,{children:(0,T.jsx)(`marker`,{id:`dagp-arrow-${_}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,T.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--mdw-accent, #2F6F5E)`})})}),Oe.map(e=>(0,T.jsx)(`path`,{className:`dagp-edge`,d:ie(e.x1,e.y1,e.x2,e.y2),markerEnd:`url(#dagp-arrow-${_})`},`${e.from}->${e.to}`)),G&&(0,T.jsx)(`path`,{className:`dagp-edge preview`,d:ie(G.x,G.y,G.cx,G.cy),markerEnd:`url(#dagp-arrow-${_})`})]}),(0,T.jsx)(`div`,{className:`dagp-nodes`,style:{width:Q.w,height:Q.h},children:k.map(e=>(0,T.jsx)(le,{n:e,p:P.get(e.nodeKey)||{x:56,y:28},byNodeKey:A,groupMode:E,dragId:W,linking:G,linkArmed:$,onStartDrag:be,onStartLink:xe,onOpenTask:Ee,onToggleGate:we,onAddTimegoal:Te,onRemoveDep:Ce,onOpsMenu:ge},e.nodeKey))}),!k.length&&(0,T.jsx)(`div`,{className:`dagp-empty`,children:E?`本组还没有带 board 归属的任务。连线可跨项目,对 get 生效。`:`这个队列没有任务。连线是编排里唯一的顺序关系;不连就保持默认序。`})]}),K&&(0,T.jsx)(o,{x:K.x,y:K.y,items:K.items,onClose:()=>ge(null)}),u]})}export{E as default};
|
|
1
|
+
import{a as e,d as t,f as n,h as r,i,l as a,n as o,u as s}from"./popup-DZ2Khv2c.js";import{n as c}from"./app-context-BqCBcDsx.js";import{t as l}from"./frontmatter-Bcseml1q.js";import{r as u}from"./md-parse-DAYCREP1.js";import{r as d}from"./board-view-Cwot54HC.js";import{i as f}from"./model-TD5kGXzR.js";import{t as p}from"./graph-BTEfvFz6.js";var m=r(n(),1);function h(e){return!(!e||e.deletedAt||e.migratedTo)}function g(e){return h(e)&&e?.status===`pending`}function _(e){return u(e.text)||f(e)||`#${e.id}`}function v(e,t){return`${e}:${Number(t)}`}function y(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return{kind:`local`,id:Math.trunc(e)};let t=String(e??``).trim();if(!t)return null;let n=/^([A-Za-z0-9_-]+):(\d+)$/.exec(t),r=n?.[1],i=n?.[2];if(r&&i)return{kind:`foreign`,key:r,id:Number(i)};if(/^\d+$/.test(t)){let e=Number(t);if(e>0)return{kind:`local`,id:e}}return null}function b(e,t){let n=y(e);return n?n.kind===`foreign`?v(n.key,n.id):v(t,n.id):null}function ee(e,t){return e.topicKey===t?Number(e.id):v(e.topicKey,e.id)}function te(e){return s(`/api/localtasks/item`,{method:`PATCH`,body:e})}function x(e,t={}){let n=Math.max(3,Number(t.perCol)||8),r=new Map;for(let t of e){let e=r.get(t.topicKey);e?e.push(t):r.set(t.topicKey,[t])}let i=new Map,a=0;for(let[,e]of r)e.forEach((e,t)=>{let r=a+Math.floor(t/n),o=t%n;i.set(e.nodeKey,{x:56+r*320,y:28+o*94})}),a+=Math.ceil(e.length/n);return i}var S=e=>`nx-kv-dag-pos:${e}`;function ne(e){try{let t=JSON.parse(localStorage.getItem(S(e))||`{}`),n=new Map;for(let[e,r]of Object.entries(t||{}))if(Array.isArray(r)&&Number.isFinite(r[0])&&Number.isFinite(r[1])){let t=Number(r[0]),i=Number(r[1]);n.set(e,{x:t,y:i})}return n}catch{return new Map}}function re(e){try{localStorage.removeItem(S(e))}catch{}}function C(e,t){try{let n={};for(let[e,r]of t)r&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&(n[e]=[Math.round(r.x),Math.round(r.y)]);return localStorage.setItem(S(e),JSON.stringify(n)),!0}catch{return!1}}function ie(e,t,n,r){let i=Math.max(48,Math.abs(n-e)*.5);return`M ${e} ${t} C ${e+i} ${t}, ${n-i} ${r}, ${n} ${r}`}function w(e,t,n){let r=e.getBoundingClientRect();return{x:t-r.left+e.scrollLeft,y:n-r.top+e.scrollTop}}function ae(e,t,n,r){let i=t.get(n)||{x:0,y:0};return{x:i.x+280,y:i.y+r(n)/2}}function oe(e,t,n,r){let i=[];for(let a of e){let e=t.get(a.nodeKey);if(!e)continue;let o=r(a.nodeKey);for(let s of a.blockBy||[]){let c=b(s,a.topicKey);if(!c||!n.has(c))continue;let l=t.get(c);if(!l)continue;let u=r(c),d=e.x>l.x+280-8;i.push({from:c,to:a.nodeKey,x1:d?l.x+280:l.x,y1:l.y+u/2,x2:d?e.x:e.x+280,y2:e.y+o/2})}}return i}function se({canvasRef:e,modeRef:t,posRef:n,nodesRef:r,byNodeKeyRef:i,scopeKeyRef:a,userMovedRef:o,commitRef:s,toastRef:c,setPos:l,setDragId:u,setLinking:d}){let f=(t,i)=>{let a=e.current;if(!a)return null;let{x:o,y:s}=w(a,t,i),c=r.current;for(let e=c.length-1;e>=0;e--){let t=c[e];if(!t)continue;let r=t.nodeKey,i=n.current.get(r);if(!i)continue;let l=a.querySelector(`[data-node-id="${CSS.escape(r)}"]`),u=l instanceof HTMLElement?l.offsetHeight:64;if(o>=i.x-10&&o<=i.x+280+28&&s>=i.y-6&&s<=i.y+u+6)return r}return null},p=e=>{if(!e||e.kind!==`link`){d(null);return}d({sourceId:e.sourceId,x:e.x1,y:e.y1,cx:e.cx,cy:e.cy,overId:e.overId,dragged:!!e.dragged})},h=()=>{t.current=null,u(null),d(null)};return(0,m.useEffect)(()=>{let r=n=>{let r=t.current;if(!r)return;let i=e.current;if(!i)return;let a=w(i,n.clientX,n.clientY);if(r.kind===`drag`){let e=Math.max(8,a.x-r.ox),t=Math.max(8,a.y-r.oy);l(n=>{let i=new Map(n);return i.set(r.id,{x:e,y:t}),i});return}if(r.kind===`link`){let e=f(n.clientX,n.clientY),i=e&&e!==r.sourceId?e:null,o=Math.hypot(a.x-r.sx,a.y-r.sy),s=r.dragged||o>=6,c={...r,cx:a.x,cy:a.y,overId:i,dragged:s};t.current=c,p(c)}},u=async e=>{let r=t.current;if(r){if(r.kind===`drag`){o.current.add(r.id),C(a.current,n.current),h();return}if(r.kind===`link`){let t=r.overId||f(e.clientX,e.clientY),n=r.sourceId;if(t&&t!==n){h(),await s.current(n,t);return}if(r.dragged){h();return}let a=i.current.get(n);c.current(`已选 #${a?.id??n},再点目标画出有向边`)}}},d=e=>{e.key===`Escape`&&h()};return window.addEventListener(`pointermove`,r),window.addEventListener(`mousemove`,r),window.addEventListener(`pointerup`,u),window.addEventListener(`mouseup`,u),window.addEventListener(`pointercancel`,h),window.addEventListener(`keydown`,d),()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`mousemove`,r),window.removeEventListener(`pointerup`,u),window.removeEventListener(`mouseup`,u),window.removeEventListener(`pointercancel`,h),window.removeEventListener(`keydown`,d)}},[]),{publishLink:p,clearMode:h}}var T=t();function ce({title:e,count:t,linkArmed:n,srcLabel:r,groupMode:i,queues:a,filterKey:o,onFilter:s,onReset:c}){return(0,T.jsxs)(`div`,{className:`dagp-head`,children:[(0,T.jsx)(`span`,{className:`dagp-title`,children:e}),(0,T.jsxs)(`span`,{className:`dagp-count`,children:[t,` 个待领取节点`]}),(0,T.jsx)(`span`,{className:`dagp-hint`,children:n?`连线中:再点目标完成 #${r} → 目标(Esc 取消)`:i?`组内全量任务;跨项目连线对 get 生效;未连线走各队列默认序`:`点右侧 ● 再点目标 = 有向顺序;未连线 = 无先后、走默认序`}),i&&a.length>0&&(0,T.jsxs)(`span`,{className:`dagp-queues`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(o===``?` on`:``),onClick:()=>s(``),children:[`全部`,(0,T.jsx)(`i`,{children:a.reduce((e,t)=>e+t.total,0)})]}),a.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(e.key===o?` on`:``),title:`${e.name} · ${e.count}/${e.total}`,onClick:()=>s(e.key),children:[e.name,(0,T.jsx)(`i`,{children:e.count})]},e.key))]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-reset`,onClick:c,title:`清掉记住的摆位,按默认分栏重排`,children:`恢复默认布局`})]})}function le({n:t,p:n,byNodeKey:r,groupMode:i,dragId:a,linking:o,linkArmed:s,onStartDrag:c,onStartLink:l,onOpenTask:u,onToggleGate:d,onAddTimegoal:f,onRemoveDep:p,onOpsMenu:m}){let h=(t.blockBy||[]).map(e=>({token:e,key:b(e,t.topicKey)})).filter(e=>e.key&&r.has(e.key)),g=o&&o.overId===t.nodeKey,v=o&&o.sourceId===t.nodeKey;return(0,T.jsxs)(`div`,{"data-node-id":t.nodeKey,className:`dagp-node`+(a===t.nodeKey?` dragging`:``)+(g?` over`:``)+(v?` linking-src`:``)+(t.blocksFollowing?` gate`:``)+(s&&!v?` link-target`:``),style:{transform:`translate(${n.x}px, ${n.y}px)`,width:280},onPointerDown:e=>c(e,t),children:[(0,T.jsx)(`span`,{className:`dagp-port in`,title:`入:箭头指向我 = 我等对方`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`dagp-body`,children:[(0,T.jsxs)(`div`,{className:`dagp-top`,children:[(0,T.jsxs)(`span`,{className:`dagp-no mono`,children:[`#`,t.id]}),i&&(0,T.jsx)(`span`,{className:`dagp-chip proj`,children:t.projectName}),t.blocksFollowing&&(0,T.jsx)(`span`,{className:`dagp-chip gate`,children:`闸门`}),t.ready===!1&&(0,T.jsx)(`span`,{className:`dagp-chip lock`,children:`锁定`}),t.timegoal?.duration&&(0,T.jsxs)(`span`,{className:`dagp-chip goal`,children:[`⏱ `,t.timegoal.duration]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-ops`,title:`节点操作`,"aria-label":`节点操作`,onClick:e=>{e.stopPropagation();let n=[{label:`打开任务`,onClick:()=>u(t)},{label:t.blocksFollowing?`取消闸门`:`设为闸门(挡住后续)`,onClick:()=>d(t)},{label:t.timegoal?.duration?`改时间目标`:`加时间目标(timegoal)`,onClick:()=>f(t)}],r=e.currentTarget.getBoundingClientRect();m({x:r.left,y:r.bottom,items:n})},children:(0,T.jsx)(e,{name:`dots`,size:13,title:void 0})})]}),(0,T.jsx)(`div`,{className:`dagp-name`,title:t.text,onDoubleClick:e=>{e.stopPropagation(),u(t)},children:_(t)}),h.length>0&&(0,T.jsx)(`div`,{className:`dagp-deps`,children:h.map(({token:e,key:n})=>{let i=n?r.get(n):void 0,a=!!i&&i.topicKey!==t.topicKey;return(0,T.jsxs)(`span`,{className:`dagp-chip dep`,title:a&&i?`跨项目 #${i.id}@${i.projectName} → #${t.id}`:`#${i?.id} → #${t.id}`,children:[`← #`,i?.id,a?`@${i.projectName}`:``,(0,T.jsx)(`i`,{role:`button`,"aria-label":`解除依赖`,onClick:n=>{n.stopPropagation(),p(t,e)},children:`×`})]},String(e))})})]}),(0,T.jsx)(`button`,{type:`button`,className:`dagp-port out`,title:`点一下再点目标,或按住拖到目标 = 有向顺序(可跨项目)`,"aria-label":`从 #${t.id} 开始连线`,onPointerDown:e=>l(e,t)})]})}function E({dirKey:e,groupId:t}){let n=c(),r=a(),{dialog:s,node:u}=i(),f=n.rows||[],h=n.refreshLocal,_=(0,m.useId)().replace(/:/g,``),S=n.repoData&&n.repoData.boards||[],C=(0,m.useMemo)(()=>S.find(e=>e.id===t||e.key===t)||null,[S,t]),E=!!C,ue=(0,m.useMemo)(()=>{if(!C)return[];let e=[];for(let t of C.repos||[]){let n=f.find(e=>e.repo&&e.repo.key===t.key);if(!n)continue;let r=[C.id,C.key,C.name].filter(Boolean),i=(n.tasks||[]).filter(e=>{if(!g(e))return!1;let t=l(e.text);return t.board&&r.includes(t.board)});i.length&&e.push({key:n.key,name:t.name||t.key,cwd:n.cwd,isGlobal:!!n.isGlobal,count:i.length,total:i.length})}return e},[C,f]),[D,de]=(0,m.useState)(``);(0,m.useEffect)(()=>{E||de(``)},[E,t]);let O=(0,m.useMemo)(()=>E?null:f.find(t=>t.key===e)||null,[E,f,e]),k=(0,m.useMemo)(()=>{if(E&&C){let e=[C.id,C.key,C.name].filter(Boolean),t=[];for(let n of C.repos||[]){let r=f.find(e=>e.repo&&e.repo.key===n.key);if(r&&!(D&&r.key!==D))for(let i of r.tasks||[]){if(!g(i))continue;let a=l(i.text);a.board&&e.includes(a.board)&&t.push({...i,topicKey:r.key,topicCwd:r.cwd,topicIsGlobal:!!r.isGlobal,projectName:n.name||n.key,nodeKey:v(r.key,i.id)})}}return t}return O?(O.tasks||[]).filter(e=>g(e)&&!d(e)).map(e=>({...e,topicKey:O.key,topicCwd:O.cwd,topicIsGlobal:!!O.isGlobal,projectName:O.name||O.key,nodeKey:v(O.key,e.id)})):[]},[E,C,f,D,O]),A=(0,m.useMemo)(()=>new Map(k.map(e=>[e.nodeKey,e])),[k]),j=(0,m.useRef)(A);j.current=A;let M=(0,m.useRef)(k);M.current=k;let N=(0,m.useRef)(null),[P,F]=(0,m.useState)(()=>new Map),I=(0,m.useRef)(P);I.current=P;let[fe,pe]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=N.current;if(!e)return;let t=()=>pe(e.clientHeight||0);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[]);let L=Math.max(3,Math.floor(((fe||720)-56)/94)||8),R=E?`g:${C?.id||t||``}`:`d:${e||``}`,z=(0,m.useRef)(R);z.current=R;let B=(0,m.useMemo)(()=>ne(R),[R]),V=(0,m.useRef)(R),H=(0,m.useRef)(new Set);(0,m.useEffect)(()=>{let e=V.current!==R;V.current=R,F(t=>{let n=new Map,r=x(k,{perCol:L});for(let i of k){let a=B.get(i.nodeKey)||(!e&&H.current.has(i.nodeKey)?t.get(i.nodeKey):null)||r.get(i.nodeKey)||{x:56,y:28};n.set(i.nodeKey,a)}return n})},[k,L,B,R]);let U=(0,m.useRef)(null),[W,me]=(0,m.useState)(null),[G,he]=(0,m.useState)(null),[K,ge]=(0,m.useState)(null),[_e,ve]=(0,m.useState)(!1),q=(0,m.useRef)(!1);q.current=_e;let J=(0,m.useRef)(async()=>!1),Y=(0,m.useRef)(r);Y.current=r;let X=async(e,t,n)=>{ve(!0);try{let i={...t};Array.isArray(i.blockBy)&&(i.blockBy=i.blockBy.join(`,`)),await te({...e.topicIsGlobal?{key:e.topicKey}:{cwd:e.topicCwd},id:Number(e.id),...i}),n&&r(n),h&&await h()}catch(e){r(String(e.message||e))}finally{ve(!1)}},{publishLink:ye,clearMode:Z}=se({canvasRef:N,modeRef:U,posRef:I,nodesRef:M,byNodeKeyRef:j,scopeKeyRef:z,userMovedRef:H,commitRef:J,toastRef:Y,setPos:F,setDragId:me,setLinking:he});J.current=async(e,t)=>{if(!t||t===e)return!1;let n=j.current.get(e),r=j.current.get(t);if(!n||!r||!g(r))return Y.current(`只能连到待领取任务`),!1;if(r.blocksFollowing)return Y.current(`#${r.id} 是闸门,不能声明上游`),!1;let i=ee(n,r.topicKey),a=[...r.blockBy||[]];if(a.some(e=>{let t=y(e),n=y(i);return!t||!n||t.kind!==n.kind?!1:(t.kind===`local`&&n.kind===`local`||t.kind===`foreign`&&n.kind===`foreign`&&t.key===n.key)&&t.id===n.id}))return Y.current(`已有该有向边`),!1;if(p(e=>{let t=j.current.get(String(e));if(!t)return[];let n=[];for(let e of t.blockBy||[]){let r=b(e,t.topicKey);r&&j.current.has(r)&&n.push(r)}return n},e,t))return Y.current(`会形成环,已取消`),!1;let o=n.topicKey!==r.topicKey;return await X(r,{blockBy:[...a,i]},o?`#${n.id}@${n.projectName} → #${r.id}@${r.projectName}`:`#${n.id} → #${r.id}`),!0};let be=(e,t)=>{if(q.current||e.button!==0||e.target instanceof Element&&e.target.closest(`.dagp-port, .dagp-ops, .dagp-chip, button, a`))return;let n=U.current;if(n&&n.kind===`link`){if(e.preventDefault(),e.stopPropagation(),t.nodeKey===n.sourceId){Z();return}if(!g(t)){Y.current(`只能连到待领取任务`);return}let r=n.sourceId;Z(),J.current(r,t.nodeKey);return}if(U.current||!g(t))return;e.preventDefault();let r=N.current;if(!r)return;let i=I.current.get(t.nodeKey)||{x:0,y:0},a=w(r,e.clientX,e.clientY);U.current={kind:`drag`,id:t.nodeKey,ox:a.x-i.x,oy:a.y-i.y},me(t.nodeKey)},xe=(e,t)=>{if(q.current||!g(t)||e.button!==0)return;if(e.preventDefault(),e.stopPropagation(),U.current?.kind===`link`&&U.current.sourceId===t.nodeKey){Z();return}let n=ae(N.current,I.current,t.nodeKey,De),r=N.current,i=r?w(r,e.clientX,e.clientY):{x:n.x,y:n.y},a={kind:`link`,sourceId:t.nodeKey,x1:n.x,y1:n.y,cx:i.x,cy:i.y,overId:null,dragged:!1,sx:i.x,sy:i.y};U.current=a,ye(a)},Se=e=>{U.current&&U.current.kind===`link`&&(e.target instanceof Element&&e.target.closest(`.dagp-node`)||Z())},Ce=async(e,t)=>{let n=[...e.blockBy||[]].filter(e=>{let n=y(e),r=y(t);return!n||!r?String(e)!==String(t):n.kind===r.kind?n.kind===`local`&&r.kind===`local`?n.id!==r.id:n.kind===`foreign`&&r.kind===`foreign`?n.key!==r.key||n.id!==r.id:!0:!0});await X(e,{blockBy:n},`已解除依赖 → #${e.id}`)},we=e=>X(e,{gate:!e.blocksFollowing},e.blocksFollowing?`#${e.id} 取消闸门`:`#${e.id} 设为闸门`),Te=async e=>{let t=await s({title:`时间目标 · #${e.id}`,input:!0,placeholder:`如 2h / 90m`,value:e.timegoal?.duration||``});if(t==null)return;let n=String(t).trim();if(!n){await X(e,{clearGoal:!0},`#${e.id} 已清除时间目标`);return}await X(e,{duration:n},`#${e.id} 时间目标 ${n}`)},Ee=e=>{n.openPage&&(t?n.openPage({groupId:t,task:String(e.id),name:`#${e.id}`}):n.openPage({dirKey:e.topicKey,task:String(e.id),name:`#${e.id}`}))},De=e=>{let t=N.current?.querySelector(`[data-node-id="${CSS.escape(e)}"]`);return t instanceof HTMLElement?t.offsetHeight:64},Oe=(0,m.useMemo)(()=>oe(k,P,A,De),[k,P,A,W,G]),Q=(0,m.useMemo)(()=>{let e=480,t=240;for(let n of k){let r=P.get(n.nodeKey);r&&(e=Math.max(e,r.x+280+100),t=Math.max(t,r.y+140))}return G&&(e=Math.max(e,G.cx+40),t=Math.max(t,G.cy+40)),{w:e,h:t}},[k,P,G]),ke=E?C?.name||`组编排`:O?.name||e||`编排`,Ae=()=>{re(z.current),H.current.clear(),F(x(k,{perCol:L})),r(`已恢复默认布局`)},$=!!G,je=G?A.get(G.sourceId)?.id??G.sourceId:``;return(0,T.jsxs)(`div`,{className:`dagp`+($?` is-linking`:``)+(W==null?``:` is-dragging`),children:[(0,T.jsx)(ce,{title:ke,count:k.length,linkArmed:$,srcLabel:je,groupMode:E,queues:ue,filterKey:D,onFilter:de,onReset:Ae}),(0,T.jsxs)(`div`,{className:`dagp-canvas`,ref:N,onPointerDown:Se,children:[(0,T.jsxs)(`svg`,{className:`dagp-edges`,width:Q.w,height:Q.h,style:{width:Q.w,height:Q.h},"aria-hidden":`true`,children:[(0,T.jsx)(`defs`,{children:(0,T.jsx)(`marker`,{id:`dagp-arrow-${_}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,T.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--mdw-accent, #2F6F5E)`})})}),Oe.map(e=>(0,T.jsx)(`path`,{className:`dagp-edge`,d:ie(e.x1,e.y1,e.x2,e.y2),markerEnd:`url(#dagp-arrow-${_})`},`${e.from}->${e.to}`)),G&&(0,T.jsx)(`path`,{className:`dagp-edge preview`,d:ie(G.x,G.y,G.cx,G.cy),markerEnd:`url(#dagp-arrow-${_})`})]}),(0,T.jsx)(`div`,{className:`dagp-nodes`,style:{width:Q.w,height:Q.h},children:k.map(e=>(0,T.jsx)(le,{n:e,p:P.get(e.nodeKey)||{x:56,y:28},byNodeKey:A,groupMode:E,dragId:W,linking:G,linkArmed:$,onStartDrag:be,onStartLink:xe,onOpenTask:Ee,onToggleGate:we,onAddTimegoal:Te,onRemoveDep:Ce,onOpsMenu:ge},e.nodeKey))}),!k.length&&(0,T.jsx)(`div`,{className:`dagp-empty`,children:E?`本组还没有带 board 归属的任务。连线可跨项目,对 get 生效。`:`这个队列没有任务。连线是编排里唯一的顺序关系;不连就保持默认序。`})]}),K&&(0,T.jsx)(o,{x:K.x,y:K.y,items:K.items,onClose:()=>ge(null)}),u]})}export{E as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e,d as t,f as n,h as r,i,l as a,n as o,r as s,t as c}from"./popup-DZ2Khv2c.js";import{r as l,u}from"./workspace-DojQ3RP4.js";import{n as d}from"./app-context-BqCBcDsx.js";import{r as f}from"./doc-DsRb-4WT.js";import{r as p}from"./md-parse-DAYCREP1.js";import{r as m,t as h}from"./board-view-Cwot54HC.js";import{f as g,l as _,n as v,o as y,p as b,r as x}from"./index-BT2y9cTX.js";import{t as S}from"./graph-BTEfvFz6.js";import{D as C,E as w,S as ee,T as te,a as ne,d as re,f as ie,h as ae,i as oe,m as T,o as se,s as ce,w as le,x as E}from"./task-utils-cBR6Gj_c.js";import{a as ue,i as D,n as O,o as k,r as A,t as j}from"./task-row-cE7qblNK.js";import{t as de}from"./bar-kaVB6FAa.js";import{n as M}from"./manage-session-CS8UvmUd.js";var N=r(n(),1),P=t(),F=O,I=A,L=j;function R({isGlobal:t,topic:n,repo:r=null,model:i=null,tasks:o=[],taskCount:c=0,pendingCount:l=0,page:u=0,pageCount:p=1,onPage:m,onNew:h,onOpenTask:g,onDeleteTask:_,onDeleteTasks:v,onCancelTasks:y,onCompleteTasks:b,onReopenTask:x,onTplMenu:S,onImport:w,onProg:ee,onMoveTask:te,onOpenDag:ne,onOpenFlow:re,onToggleGate:ie,downstreamOf:ae,onRefs:oe,q:T=``,onQuery:se}){let ce=t?`全局池`:n?.name||`目录`,le=!!String(T).trim(),E=(0,N.useRef)(null),[ue,O]=(0,N.useState)(null),[k,A]=(0,N.useState)(null),[j,M]=(0,N.useState)(()=>new Set);(0,N.useEffect)(()=>{M(new Set)},[u]);let R=o.map(e=>Number(e.id)),z=R.length>0&&R.every(e=>j.has(e)),B=o.filter(e=>j.has(Number(e.id))),V=B.filter(e=>(e.status===`pending`||e.status===`claimed`)&&!e.migratedTo&&!e.deletedAt),fe=V.filter(e=>e.status===`claimed`).length,H=B.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),U=e=>{let t=Number(e);M(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},W=()=>{M(e=>{let t=new Set(e);return z?R.forEach(e=>t.delete(e)):R.forEach(e=>t.add(e)),t})},G=async e=>{let t=[...j],n=e===`cancel`?y:e===`complete`?b:v;t.length&&n&&await n(t)&&M(new Set)},K=d(),q=a(),pe=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 C({...pe,id:Number(n.id),to:t});q(t===`plan`?`已把 ${e.length} 条任务转为草稿(不进队列)`:`已把 ${e.length} 条草稿转回待领取`),M(new Set),K.refreshLocal?.()}catch(e){q(String(e.message||e))}},X=Y.length?Y:me,Z=Y.length?`plan`:`pending`,Q=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,ge=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},$=(e,t)=>{E.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),O(Number(t.id))},_e=(e,t)=>{E.current&&Q(t)&&Number(t.id)!==E.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,A({id:Number(t.id),zone:ge(e,e.currentTarget)}))},ve=e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||A(null)},ye=(e,t)=>{e.preventDefault();let n=ge(e,e.currentTarget),r=E.current;E.current=null,O(null),A(null),r&&Q(t)&&Number(t.id)!==r.id&&te&&te({id:r.id},t.id,n)},be=()=>{E.current=null,O(null),A(null)},xe=B.length>0?(0,P.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,P.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,B.length,` 条`]}),b&&(0,P.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!V.length,title:V.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${fe?`;其中 ${fe} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>G(`complete`),children:[`标为完成选中`,V.length?` (${V.length})`:``]}),y&&(0,P.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!H.length,title:H.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>G(`cancel`),children:[`取消选中`,H.length?` (${H.length})`:``]}),v&&(0,P.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>G(`delete`),children:[`删除选中 (`,B.length,`)`]}),(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>M(new Set),children:`清空`})]}):null,Se=(0,P.jsx)(I,{title:t?`全局池任务`:`任务`,pendingCount:l,headerExtra:(0,P.jsx)(P.Fragment,{children:(0,P.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,P.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:T,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>se&&se(e.target.value)}),o.length?(0,P.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:z,onChange:W,"aria-label":`全选当前页任务`}),`全选本页`]}):null]})}),emptyText:le?`没有匹配「${T.trim()}」的任务(标题与正文都搜过了)`:`还没有页面:点「+ 新建页」写第一篇,或让 agent 往${t?`全局池`:`这个目录`}投递任务。`,children:o.map(e=>{let t=Q(e),n=ae&&ae[e.id]||[];return(0,P.jsx)(L,{t:e,selectable:!0,picked:j.has(Number(e.id)),onTogglePick:U,draggable:t,dragHandlers:t?{onDragStart:t=>$(t,e),onDragOver:t=>_e(t,e),onDragLeave:ve,onDrop:t=>ye(t,e),onDragEnd:be}:null,dragVisual:{dragging:ue===Number(e.id),drop:k&&k.id===Number(e.id)?k.zone:null},showTimes:!0,downs:n,onOpen:e=>g(e.id),ops:(0,P.jsx)(s,{items:[e.status===`pending`||e.status===`plan`?{label:e.status===`pending`?`转为草稿(不进队列)`:`转回待领取`,onPick:()=>void he([e],e.status===`pending`?`plan`:`pending`)}:null,t&&ne?{label:`编排依赖…`,onPick:()=>ne(e)}:null,t&&ie?{label:e.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>ie(e)}:null,x&&e.status!==`cancelled`&&!e.childCount&&(e.status===`claimed`||e.status===`done`||e.completedAt)?{label:e.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,onPick:()=>x(e)}:null,_?{label:`删除此任务(软删除,CLI 可恢复)`,danger:!0,onPick:()=>_(e)}:null]})},e.id)})}),Ce=c>0?(0,P.jsx)(`div`,{className:`mdw-land-pager`,children:(0,P.jsx)(D,{page:u,pageCount:p,total:c,onPage:m,unit:`个任务`})}):null;return(0,P.jsx)(F,{name:ce,counts:le?[`命中 ${c} 个任务`,...l>0?[`待领取 ${l}`]:[]]:[`${c} 个任务`,...l>0?[`待领取 ${l}`]:[]],intro:!t&&r?(0,P.jsx)(f,{kind:`repo`,owner:r,model:i}):null,batch:xe,list:Se,footer:Ce,actions:(0,P.jsx)(P.Fragment,{children:(0,P.jsx)(de,{kind:`dir`,labels:{more:`更多`,plan:J.length?Z===`plan`?`转草稿 (${Y.length})`:`转回待领取 (${me.length})`:`草稿态`},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,more:`更多操作`,refs:`查看文档 / reference 列表`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`},renderers:{new:()=>(0,P.jsx)(`span`,{className:`rp-newtask`,children:(0,P.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,onClick:()=>h(),children:[`+ 新建页`,(0,P.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),S?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),S?.(e))},children:(0,P.jsx)(e,{name:`chevron`,size:11,title:void 0})})]})})},actions:{new:h,import:w,progress:ee,orch:re,refs:oe,plan:()=>{if(!X.length){q(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}he(X,Z)}}})})})}var z=c,B=(e,t,n)=>S(e=>n.get(Number(e))||[],e,t);function V({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,N.useState)(!!e.blocksFollowing),[l,u]=(0,N.useState)(()=>new Set((e.blockBy||[]).map(Number))),[d,f]=(0,N.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,N.useState)(!1),g=t.findIndex(e=>i(e)===a),_=t.slice(g+1).map(i),v=new Map(t.map(e=>[i(e),i(e)===a?[...l]:(e.blockBy||[]).map(Number)])),y=e=>s||!l.has(i(e))&&B(i(e),a,v),b=e=>!d.has(i(e))&&B(a,i(e),v),x=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),S=()=>c(e=>(e||u(new Set),!e)),C=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)}},w=(e,t,n,r)=>{let a=p(e.text)||`#${i(e)}`;return(0,P.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,P.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,P.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,P.jsx)(z,{title:`编排 · #${a} ${p(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,P.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:C,children:m?`保存中…`:`保存编排`})]}),children:(0,P.jsxs)(`div`,{className:`mdw-dag`,children:[(0,P.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:S}),(0,P.jsx)(`b`,{children:`闸门`}),(0,P.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,P.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,_.length,` 个后续任务`,_.length?`:${_.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,P.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,P.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,P.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,l.has(i(e)),y(e),x(u))):(0,P.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,P.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,P.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,P.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,d.has(i(e)),s||b(e),x(f))):(0,P.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,P.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}var fe=20;function H({dirKey:e}){let{dialog:t,node:n}=i(),r=d(),s=a(),c=r.rows||[],f=r.refreshLocal,p=r.tpl,S=r.model,C=r.repoData&&r.repoData.repos||[],D=!e||e===`__GLOBAL__`,[O,A]=(0,N.useState)(null),[j,de]=(0,N.useState)(null),F=(0,N.useRef)(null),I=(0,N.useMemo)(()=>D?c.find(e=>e.isGlobal)||null:c.find(t=>t.key===e)||null,[c,e,D]),L=(0,N.useMemo)(()=>{if(!I||D)return null;let e=I.repo&&I.repo.key;if(e){let t=C.find(t=>t.key===e);if(t)return t}let t=String(I.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&C.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[I,C,D]),z=(0,N.useMemo)(()=>oe((I?.tasks||[]).filter(e=>!e.deletedAt&&!m(e))),[I]),[B,H]=(0,N.useState)(``),U=(0,N.useMemo)(()=>k(z,B),[z,B]),W=ue(U,fe);(0,N.useEffect)(()=>{W.setPage(0)},[B]);let G=(0,N.useMemo)(()=>U.filter(e=>e.status===`pending`&&!e.migratedTo).length,[U]),K=e=>e().catch(e=>s(String(e.message||e))),q=()=>D?{key:h}:{cwd:I?.cwd},pe=(e,t,n)=>{K(async()=>{await w({...q(),id:e.id,...n===`before`?{beforeId:t}:{afterId:t}}),f?.()})},J=e=>{K(async()=>{await E({...q(),id:e.id,gate:!e.blocksFollowing}),s(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),f?.()})},Y=async e=>{try{for(let t of e)await E({...q(),...t});s(`编排已保存`),f?.()}catch(e){throw s(String(e.message||e)),e}},me=(0,N.useMemo)(()=>{let e={},t=z.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},[z]),he=(0,N.useMemo)(()=>z.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[z]),X=t=>{r.openPage&&r.openPage({dirKey:e,task:String(t),name:`#${t}`})},Z=t=>{let n=_();g(y(b(e),n),{title:``,body:t}),r.openPage&&r.openPage({dirKey:e,task:n,name:`新任务`})},Q=()=>{let t=M({topic:$,repo:D?``:L?.key||``,label:D?`全局池`:I?.name||e||`本目录`});r.onNavigate?.(`#/templates/manage/${t}`)},ge=()=>{S&&l(S,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},$=D?h:e||`__GLOBAL__`,_e=v($).templates||p&&p.templates||[],ve=()=>{if(!S){s(`工作区未就绪`);return}x(S,{mode:`new`,topic:$,scope:D?[]:[`topic:${$}`],name:``})},ye=[..._e.length?_e.map(e=>({label:(e.id===p?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Z(String(e.body||``))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>{let e=p?p.defaultPick():null;Z(e?e.body:``)}}],`sep`,{label:`为本${D?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:ve},{label:`管理模板…`,icon:`gear`,onClick:Q}],be=async e=>{if(e==null)return null;let t=D?`key=${encodeURIComponent(h)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(I?.cwd||``)}&id=${Number(e.id)}`;return ae(t)},xe=n=>{if(!n)return;let r=(n.text||``).split(`
|
|
2
|
+
`).find(e=>e.trim())||`#${n.id}`;K(async()=>{let i=!!n.completedAt,a=await t({title:i?`反馈 · #${n.id}`:`反馈修改 · #${n.id}`,input:!0,placeholder:i?`写下反馈(将新开一条任务,原任务不动)`:`写下要改的地方(留空 = 只重开,不改正文)`});if(a==null)return;let o=String(a).trim(),c=await be(n),l=String(c?.text??``).trim()||String(n.text||``).trim(),u=i&&(c?.roundSummary||n.roundSummary)||``;if(!o&&!i&&!l){s(`拿不到任务当前正文,已取消(防止丢内容)`);return}if(i){let t=o?ne({base:l,feedback:o,ackSummary:u,feedbackHeading:se,bold:!0}):``;if(!t){s(`写一下反馈`);return}let i=await re(D?{global:!0,text:t,forkOf:String(n.id),forkKind:`reopen`}:{cwd:I?.cwd,text:t,forkOf:String(n.id),forkKind:`reopen`}),a=String(i?.task?.id??i?.id??``),c=i?.key||e;a&&g(y(b(c),a),{body:t}),s(`已反馈「${r.replace(/^#\s*/,``)}」→ 新任务 #${a||`?`}`),f?.();return}let d=await ee({...q(),id:n.id,kind:`reopen`,...o?{feedback:o,feedbackHeading:ce,feedbackBold:!1}:{}}),p=d?.key||e,m=String(d?.task?.id??n.id),h=String(d?.task?.text??``);h&&g(y(b(p),m),{body:h}),s(`已回写「${r.replace(/^#\s*/,``)}」#${m}`+(d?.moved&&d.name?`;归属迁到「${d.name}」`:``)),f?.()})},Se=async n=>{if(!n)return;let i=(n.text||``).split(`
|
|
3
|
+
`).find(e=>e.trim())||`#${n.id}`;await t({title:`删除任务「${i.replace(/^#\s*/,``)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&K(async()=>{if(await te(D?{key:h,id:n.id}:{cwd:I?.cwd,id:n.id}),s(`已删除「${i.replace(/^#\s*/,``)}」`),S){let t=u(S,`page`,{dirKey:e,task:String(n.id)});t&&r.closePanel&&r.closePanel(t.getId())}f?.()})},Ce=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`删除选中的 ${n.length} 条任务`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})?!1:K(async()=>{let e=await le({...q(),ids:n});return s(`已删除 ${e?.count??n.length} 条任务`),f?.(),!0})},we=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`取消选中的 ${n.length} 条待领取任务`,message:`只处理待领取任务;已领取/已完成/已取消会跳过。取消为终态,原文留档。`,okText:`取消任务`})?!1:K(async()=>{let e=await ie({...q(),ids:n}),t=e?.skipped?.length||0;return s(`已取消 ${e?.count??0} 条任务${t?`,跳过 ${t} 条`:``}`),f?.(),!0})},Te=async e=>{let n=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!n.length||!await t({title:`把选中的 ${n.length} 条任务标为完成`,message:`待领取与已领取(正在跑)都能收:已领取的直接收口,agent 侧回执会被忽略。已完成/已取消会跳过。完成会补一条完成记录,原文留档。`,okText:`标为完成`})?!1:K(async()=>{let e=await T({...q(),ids:n,status:`done`}),t=e?.skipped?.length||0,r=e?.claimedClosed?.length||0;return s(`已标为完成 ${e?.count??0} 条任务${r?`(含 ${r} 条已领取)`:``}${t?`,跳过 ${t} 条`:``}`),f?.(),!0})},Ee=()=>{if(D||!L){s(`全局池没有项目文档列表`);return}if(!S)return;let e=L.key||I?.repo&&I.repo.key||``;if(!e){s(`这个项目还没有仓库标识(key),无法定位文档列表`);return}l(S,{component:`refs`,name:`文档列表`,config:{repoKey:e},location:`right`})},De=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 re(D?{global:!0,text:r}:{cwd:I?.cwd,text:r});s(`已导入:${e.name}`),f?.();let a=i?.task?.id??i?.id;a!=null&&X(a)})};return!I&&!D?(0,P.jsx)(`div`,{className:`mdw`,children:(0,P.jsx)(`div`,{className:`mdw-main`,children:(0,P.jsx)(`div`,{className:`mdw-top`,children:(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:`目录不存在`}),(0,P.jsx)(`div`,{className:`mdw-path`,children:`—`})]})})})}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(R,{isGlobal:D,topic:I,repo:L,model:S,tasks:W.items,taskCount:W.total,q:B,onQuery:H,pendingCount:G,page:W.page,pageCount:W.pageCount,onPage:W.setPage,onNew:()=>{let e=p?p.defaultPick():null;Z(e?e.body:``)},onOpenTask:X,onDeleteTask:Se,onDeleteTasks:Ce,onCancelTasks:we,onCompleteTasks:Te,onReopenTask:xe,onTplMenu:e=>A({x:e.clientX,y:e.clientY}),onImport:()=>F.current?.click(),onProg:ge,onMoveTask:pe,onOpenDag:de,onOpenFlow:()=>S&&l(S,{component:`dag`,name:`编排`,config:{dirKey:e}}),onToggleGate:J,downstreamOf:me,onRefs:Ee}),j&&(0,P.jsx)(V,{task:j,tasks:he,onClose:()=>de(null),onSave:Y}),O&&(0,P.jsx)(o,{x:O.x,y:O.y,items:ye,onClose:()=>A(null)}),(0,P.jsx)(`input`,{ref:F,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&De(t)}}),n]})}export{H as default};
|