nx-kv 0.25.0 → 0.26.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 +22 -0
- package/assets/kv-get/SKILL.md +7 -11
- package/package.json +1 -1
- package/src/modules/localtask/index.js +36 -15
- package/src/modules/localtask/task-lifecycle.js +128 -55
- package/src/modules/localtask/task-view.js +89 -12
- package/src/web/frontend/components/md/sel-menu.jsx +112 -19
- package/src/web/frontend/components/md/task-chain.jsx +75 -0
- package/src/web/frontend/components/md/tool-bar.jsx +6 -0
- package/src/web/frontend/modules/board/ack-nodes.js +2 -2
- package/src/web/frontend/modules/md/style.css +44 -0
- package/src/web/frontend/page/dir/index.jsx +32 -15
- package/src/web/frontend/page/dir/landing.jsx +2 -2
- package/src/web/frontend/page/dir/task.jsx +300 -89
- package/src/web/frontend/panels.jsx +13 -3
- package/src/web/public/assets/{Introduction-VfytFhtV.js → Introduction-ka0UxW_S.js} +1 -1
- package/src/web/public/assets/{cloud-DolkshAI.js → cloud-y1mZIdlN.js} +1 -1
- package/src/web/public/assets/{dag-C-E5GoLz.js → dag-CiMSs7uT.js} +1 -1
- package/src/web/public/assets/dir-DKzzrY8P.js +3 -0
- package/src/web/public/assets/{group-BQTuoGyZ.js → group-DOLdLkaj.js} +1 -1
- package/src/web/public/assets/{index-BryAyn_9.js → index-CbZfbzqr.js} +2 -2
- package/src/web/public/assets/{index-B48b_WIl.css → index-DUvCgdUV.css} +1 -1
- package/src/web/public/assets/{md-history-vwtmQsFJ.js → md-history-Ddk04A_2.js} +1 -1
- package/src/web/public/assets/{member-picker-DwJAdKTe.js → member-picker-Dsy1GH0E.js} +1 -1
- package/src/web/public/assets/{overview-Crnguaek.js → overview-ty9m-bCh.js} +1 -1
- package/src/web/public/assets/{progress-ijTyMRPT.js → progress-BQJhISlF.js} +1 -1
- package/src/web/public/assets/{repos-C_dN0b6h.js → repos-Di5InllN.js} +1 -1
- package/src/web/public/assets/{route-crumb-DZw2J3Nx.js → route-crumb-g3leiQhY.js} +1 -1
- package/src/web/public/assets/{settings-C7zGy-xI.js → settings-CE-rlcXr.js} +1 -1
- package/src/web/public/assets/task-D97dEZdc.js +6 -0
- package/src/web/public/assets/{template-slots-DhPGCIqW.js → template-slots-D40ponA2.js} +1 -1
- package/src/web/public/assets/{templates-xXPow5BD.js → templates-Ca1jXhnO.js} +1 -1
- package/src/web/public/assets/{upload-uBhGCTZ2.js → upload-BeiJetbd.js} +1 -1
- package/src/web/public/index.html +2 -2
- package/src/web/public/assets/dir-kBhfKX8r.js +0 -3
- package/src/web/public/assets/task-CqoiXFKL.js +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
本文件记录对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
|
|
4
4
|
|
|
5
|
+
## [0.26.0] - 2026-11-05 ack 与评论统一回写原任务 + 任务链可视化
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **修正 ack 与评论机制(任务 #74)——推翻 v0.24.9 的「重开即新建」方向**:验收反馈与
|
|
10
|
+
划选评论**就地回写原任务**(同一编号、同一 md),不再新建队列行 + 归档旧任务。
|
|
11
|
+
「新建任务」会把同一件活拆成多条待领,验收 / 评论闭环断在新号上;现在闭环回到同号。
|
|
12
|
+
- `reopenTask`:旧态压进 `history[]` 链(起点 → 反馈 / 评论 → 当前),正文 = 原正文 +
|
|
13
|
+
上一轮完成总结 + 本轮反馈;清领取 / 完成标记回 pending,等再领(同号继续)。
|
|
14
|
+
- `archived` 状态仍保留给旧口径(#59 fork 取代)的残留行,但不再由 reopen 写入。
|
|
15
|
+
- **评论与反馈都支持附件 / 图片**(划选评论入口同样可带图,走附件链路)。
|
|
16
|
+
- 评论入口新增 `quote`(划选原文)与 `kind`(reopen / comment)参数,
|
|
17
|
+
`localtask reopen --kind comment --quote "…" --feedback "…"`。
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **任务链可视化(弹窗)**:编辑页可打开本任务的链——`history` 节点(起点 / 反馈 / 评论 /
|
|
21
|
+
当前)按时间排列,点任一节点**旁路只读查看那一轮的正文**(页签带 historyId 只读形态);
|
|
22
|
+
旧 `forkOf` 派生链(祖先 + 子任务)继续兼容显示。`localtask chain --id <n>` 人读输出同步
|
|
23
|
+
改为以 history 节点为主。
|
|
24
|
+
|
|
25
|
+
> 与 v0.24.9 的关系:那版把「重开」改成了「新建任务 + 归档」,实践下来验收 / 评论闭环断在
|
|
26
|
+
> 新号上(#74 要求统一回写原任务、历史用链可视化),本版改回就地重开,历史不丢(history 链)。
|
|
5
27
|
## [0.25.0] - 2026-11-05 新建任务不再丢上下文 + 交付预览 + 存储层收口
|
|
6
28
|
|
|
7
29
|
### Added
|
package/assets/kv-get/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kv-get
|
|
3
|
-
description: 领取与完成排给本工作目录的本地任务(别人通过 kv-submit 委托的、用户排队的,都落在「目录名即主题」的队列里)——用 localtask get 取活(默认直接领;项目开启「持续 get」后自动阻塞等人回填)、localtask wait 挂着等人接力、localtask done 标记完成(带时间目标的任务未到点会被拒绝,提示派 sub agent 重提需求)、localtask reopen
|
|
3
|
+
description: 领取与完成排给本工作目录的本地任务(别人通过 kv-submit 委托的、用户排队的,都落在「目录名即主题」的队列里)——用 localtask get 取活(默认直接领;项目开启「持续 get」后自动阻塞等人回填)、localtask wait 挂着等人接力、localtask done 标记完成(带时间目标的任务未到点会被拒绝,提示派 sub agent 重提需求)、localtask reopen **就地重开原任务**(历史进 history 链,已完成则回到待领取)。触发词:领取本地任务、看看有没有排给我的任务、本地队列、领取委托任务、拿任务、本目录的任务、排队任务、localtask get、localtask wait、标记完成、任务完成、修改反馈、重新执行、kv-get。凡「主动获取排给本目录的任务」以及「把任务标记完成/按反馈重开」的场景都走本 skill。反例:把需求提交/委托给别的目录用 kv-submit;查本机仓库分组与参考仓库用 kv-repo;操作远程 KV 清单(todo)用 nx-kv。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# kv-get — 领取、执行、完成(领取侧)
|
|
@@ -69,20 +69,16 @@ nx-kv localtask done --id <n> --summary "<完成总结>" --json
|
|
|
69
69
|
# 标记完成(完成总结必填——它就是下一轮 agent 能看到的「上轮做了什么」)
|
|
70
70
|
nx-kv localtask done --id <n> --summary "<完成总结>" [--progress "<完成度/下一步>"]
|
|
71
71
|
|
|
72
|
-
# 用户看了结果提修改意见 →
|
|
73
|
-
nx-kv localtask reopen --id <n> [--text "<改后的正文(Markdown)>"] --json
|
|
72
|
+
# 用户看了结果提修改意见 → **就地重开原任务**(同号回写,旧态压进 history)
|
|
73
|
+
nx-kv localtask reopen --id <n> [--text "<改后的正文(Markdown)>"] [--kind reopen|comment] --json
|
|
74
74
|
|
|
75
|
-
#
|
|
75
|
+
# 查任务链:同任务 history 节点(origin/reopen/comment/current)+ 旧 forkOf 派生(若有)
|
|
76
76
|
nx-kv localtask chain --id <n> --json
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
`reopen`
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
并用 `forkOf` 指回上一条。
|
|
83
|
-
|
|
84
|
-
任务状态是**单向**的:`待领取 → 已领取 → 已归档`,**没有回退边**——
|
|
85
|
-
完成等待验收之后不会回到「重新开始」。
|
|
79
|
+
`reopen` **回写同一条任务**:正文 = `--text`;上一轮完成总结等压进 `history[]`。
|
|
80
|
+
若任务已完成(有 `completedAt`),清领取/完成标记并回到 `pending` 等待再领;
|
|
81
|
+
未完成则只改正文 + 记链。面板的验收重做与划选评论共用这一入口(可带附件)。
|
|
86
82
|
|
|
87
83
|
## 硬规则
|
|
88
84
|
|
package/package.json
CHANGED
|
@@ -79,18 +79,28 @@ function renderAdd(d) {
|
|
|
79
79
|
return body + ignored;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// `localtask chain` 的人读输出(#
|
|
83
|
-
const KIND_TAG = { reopen: '反馈', comment: '评论' };
|
|
82
|
+
// `localtask chain` 的人读输出(#74):同任务 history 节点为主;旧 forkOf 祖先/子任务为辅
|
|
83
|
+
const KIND_TAG = { origin: '起点', reopen: '反馈', comment: '评论', current: '当前' };
|
|
84
84
|
function renderChain(d) {
|
|
85
85
|
const self = d.task;
|
|
86
86
|
const lines = [
|
|
87
87
|
`#${self.id} [${STATUS_TAG[self.status] || self.status}] ${d.name}`,
|
|
88
88
|
` ${self.text.split('\n').map((l) => l.trim()).find(Boolean) || ''}`,
|
|
89
89
|
];
|
|
90
|
+
const nodes = Array.isArray(d.nodes) ? d.nodes : [];
|
|
91
|
+
if (nodes.length) {
|
|
92
|
+
lines.push(` 任务链(${nodes.length} 节点):`);
|
|
93
|
+
for (const n of nodes) {
|
|
94
|
+
const tag = KIND_TAG[n.kind] || n.kind || '?';
|
|
95
|
+
const mark = n.current ? '●' : '○';
|
|
96
|
+
const att = n.attachmentCount ? ` 📎${n.attachmentCount}` : '';
|
|
97
|
+
lines.push(` ${mark} [${tag}] ${n.excerpt || '—'}${att}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
90
100
|
if (self.forkOf) {
|
|
91
101
|
lines.push(` 派生自: ${self.forkOf}${self.forkKind ? `(${KIND_TAG[self.forkKind] || self.forkKind})` : ''}`);
|
|
92
102
|
}
|
|
93
|
-
if (d.ancestors.length) {
|
|
103
|
+
if (d.ancestors && d.ancestors.length) {
|
|
94
104
|
lines.push(` 祖先链(${d.ancestors.length} 级):`);
|
|
95
105
|
for (const a of d.ancestors) {
|
|
96
106
|
lines.push(
|
|
@@ -100,7 +110,7 @@ function renderChain(d) {
|
|
|
100
110
|
);
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
|
-
if (d.children.length) {
|
|
113
|
+
if (d.children && d.children.length) {
|
|
104
114
|
lines.push(` 子任务(${d.children.length} 条):`);
|
|
105
115
|
for (const c of d.children) {
|
|
106
116
|
lines.push(
|
|
@@ -109,8 +119,8 @@ function renderChain(d) {
|
|
|
109
119
|
);
|
|
110
120
|
}
|
|
111
121
|
}
|
|
112
|
-
if (!self.forkOf && !d.ancestors.length && !d.children.length) {
|
|
113
|
-
lines.push('
|
|
122
|
+
if (!nodes.length && !self.forkOf && !(d.ancestors && d.ancestors.length) && !(d.children && d.children.length)) {
|
|
123
|
+
lines.push(' (这条任务还没有链节点)');
|
|
114
124
|
}
|
|
115
125
|
return lines.join('\n');
|
|
116
126
|
}
|
|
@@ -225,13 +235,12 @@ export default {
|
|
|
225
235
|
render: renderTask,
|
|
226
236
|
},
|
|
227
237
|
{
|
|
228
|
-
// 任务链(#
|
|
229
|
-
// forkOf + forkKind。这里把一条任务的祖先链与全部子任务一次查清(跨主题)。
|
|
238
|
+
// 任务链(#74):同任务 history 节点(就地重开/评论)为主;旧 forkOf 祖先/子任务仍返回。
|
|
230
239
|
id: 'localtask.chain',
|
|
231
240
|
cli: ['localtask', 'chain'],
|
|
232
241
|
http: ['GET', '/api/localtasks/chain'],
|
|
233
242
|
summary:
|
|
234
|
-
'
|
|
243
|
+
'查一条任务的链:history 节点(origin/reopen/comment/current)+ 旧 forkOf 祖先/子任务;面板点节点可旁路查看正文',
|
|
235
244
|
flags: { id: { type: 'number', required: true, hint: '任务编号' }, cwd: CWD, key: KEY },
|
|
236
245
|
run: (ctx) => service.taskChain({ id: ctx.id, cwd: ctx.cwd, key: ctx.key }),
|
|
237
246
|
render: renderChain,
|
|
@@ -314,27 +323,39 @@ export default {
|
|
|
314
323
|
render: renderPreview,
|
|
315
324
|
},
|
|
316
325
|
{
|
|
317
|
-
// 修改反馈 / 重做 /
|
|
318
|
-
// 状态单向:完成等待验收之后没有回退边——不会回到「重新开始」(任务 #59)。
|
|
326
|
+
// 修改反馈 / 重做 / 划选评论 → **就地重开原任务**(#74),历史进 history 链。
|
|
319
327
|
id: 'localtask.reopen',
|
|
320
328
|
cli: ['localtask', 'reopen'],
|
|
321
329
|
http: ['POST', '/api/localtasks/reopen'],
|
|
322
330
|
summary:
|
|
323
|
-
'
|
|
331
|
+
'重开任务(验收反馈 / 重做 / 评论):回写原任务正文,旧态压进 history;已完成则回到 pending 待再领',
|
|
324
332
|
flags: {
|
|
325
333
|
id: { type: 'number', required: true, hint: '任务编号' },
|
|
326
334
|
cwd: CWD,
|
|
327
335
|
key: KEY,
|
|
328
336
|
text: { type: 'string', hint: '修改后的任务正文(Markdown);不给则只重开不改内容' },
|
|
337
|
+
kind: { type: 'string', hint: 'reopen(验收反馈,默认)或 comment(划选评论)' },
|
|
338
|
+
quote: { type: 'string', hint: '划选原文(comment 时)' },
|
|
339
|
+
feedback: { type: 'string', hint: '用户反馈原文(写入 history 节点)' },
|
|
329
340
|
},
|
|
330
341
|
run: async (ctx) => {
|
|
331
342
|
// 重开也可能带着改过的归属(--text 的 frontmatter.project 变了)→ 同样搬家
|
|
332
343
|
const { reopenTask } = await import('../tasktool/update.js');
|
|
333
|
-
return reopenTask({
|
|
344
|
+
return reopenTask({
|
|
345
|
+
id: ctx.id,
|
|
346
|
+
cwd: ctx.cwd,
|
|
347
|
+
key: ctx.key,
|
|
348
|
+
text: ctx.text,
|
|
349
|
+
kind: ctx.kind,
|
|
350
|
+
quote: ctx.quote,
|
|
351
|
+
feedback: ctx.feedback,
|
|
352
|
+
attachments: ctx.attachments,
|
|
353
|
+
});
|
|
334
354
|
},
|
|
335
355
|
render: (d) =>
|
|
336
|
-
|
|
337
|
-
(d.
|
|
356
|
+
`已重开 #${d.id} @ ${d.name}` +
|
|
357
|
+
(d.before?.completedAt ? '(已完成→待领取)' : '') +
|
|
358
|
+
(d.historyId != null ? `;链节点 #${d.historyId}` : '') +
|
|
338
359
|
(d.moved && d.movedFrom ? `;已改归属项目,原 ${d.movedFrom.name} #${d.movedFrom.id}` : ''),
|
|
339
360
|
},
|
|
340
361
|
{
|
|
@@ -1,104 +1,178 @@
|
|
|
1
1
|
// (#54 自 service.js 拆出)队列出口的任务生命周期:consumeFirstPending(D-first 领取,
|
|
2
2
|
// 跳过被依赖/闸门挡住的 pending)、completeTask(完成门禁:timegoal 未到点返回 blocked
|
|
3
|
-
// 业务值而不是抛错)、reopenTask(用户修改反馈 →
|
|
3
|
+
// 业务值而不是抛错)、reopenTask(用户修改反馈 → **就地重开原任务**,历史进 history 链)。
|
|
4
4
|
import { badInput, notFound } from '../../core/errors.js';
|
|
5
5
|
import { formatDuration } from '../../core/instruction-template.js';
|
|
6
6
|
import { preserveFrontmatter } from '../../shared/frontmatter.js';
|
|
7
7
|
import { findFirstReadyPending } from './dag.js';
|
|
8
8
|
import { basename } from 'node:path';
|
|
9
9
|
import { isGlobalKey, resolveTaskKey, topicKeyFor } from './paths.js';
|
|
10
|
-
import { loadStore, saveStore, stampNow, normalizeSummary, normalizeText, bumpWorkflowRevision
|
|
10
|
+
import { loadStore, saveStore, stampNow, normalizeSummary, normalizeText, bumpWorkflowRevision } from './store-io.js';
|
|
11
11
|
import { normalizeTask, foreignResolver, isPending } from './task-view.js';
|
|
12
12
|
import { normalizeBlockBy } from './dag.js';
|
|
13
13
|
import { markConsumed } from './waiters.js';
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
/** 下一条 history 节点编号(任务内自增) */
|
|
16
|
+
function nextHistoryId(history) {
|
|
17
|
+
let max = 0;
|
|
18
|
+
for (const h of history || []) {
|
|
19
|
+
const n = Number(h && h.id) || 0;
|
|
20
|
+
if (n > max) max = n;
|
|
21
|
+
}
|
|
22
|
+
return max + 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** 把当前任务态压成一条 history 节点(就地重开前留档) */
|
|
26
|
+
function snapshotNode(task, { kind, quote, feedback, attachments } = {}) {
|
|
27
|
+
const excerpt =
|
|
28
|
+
String(task.text ?? '')
|
|
29
|
+
.split('\n')
|
|
30
|
+
.map((l) => l.trim())
|
|
31
|
+
.find(Boolean) || '';
|
|
32
|
+
return {
|
|
33
|
+
id: nextHistoryId(task.history),
|
|
34
|
+
kind: kind === 'comment' ? 'comment' : kind === 'origin' ? 'origin' : 'reopen',
|
|
35
|
+
at: stampNow(),
|
|
36
|
+
text: String(task.text ?? ''),
|
|
37
|
+
summary: String(task.roundSummary ?? ''),
|
|
38
|
+
status: String(task.status || 'pending'),
|
|
39
|
+
completedAt: String(task.completedAt ?? ''),
|
|
40
|
+
quote: String(quote ?? ''),
|
|
41
|
+
feedback: String(feedback ?? ''),
|
|
42
|
+
attachments: Array.isArray(attachments)
|
|
43
|
+
? attachments
|
|
44
|
+
.filter((a) => a && typeof a === 'object')
|
|
45
|
+
.map((a) => ({
|
|
46
|
+
id: String(a.id || ''),
|
|
47
|
+
name: String(a.name || ''),
|
|
48
|
+
type: a.type === 'image' ? 'image' : 'file',
|
|
49
|
+
size: String(a.size || ''),
|
|
50
|
+
url: a.url ? String(a.url) : '',
|
|
51
|
+
}))
|
|
52
|
+
: [],
|
|
53
|
+
excerpt: excerpt.replace(/^#+\s*/, '').slice(0, 100),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 把一条任务重新开放(用户的**修改反馈** / 重做 / 划选评论)。
|
|
15
58
|
//
|
|
16
|
-
// 语义(任务 #
|
|
17
|
-
// -
|
|
18
|
-
//
|
|
19
|
-
// -
|
|
20
|
-
//
|
|
21
|
-
// - 落点:默认同主题;带改过归属(moveTo)就落那边——归属决定落点。
|
|
59
|
+
// 语义(任务 #74):**就地重开原任务**——同一编号、同一 md,不新建队列行。
|
|
60
|
+
// - 旧态压进 `history[]`(可追链、可点开旁路查看)
|
|
61
|
+
// - 正文 = 调用方拼好的(面板口径:原正文 + 上一轮完成总结 + 本轮反馈)
|
|
62
|
+
// - 清领取/完成标记,状态回到 pending,等再领(同号继续)
|
|
63
|
+
// - 落点:默认同主题;带改过归属(moveTo)就搬整条任务
|
|
22
64
|
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
65
|
+
// 对比 #59「新建 md + 归档」:那会把同一件活拆成多条待领,验收/评论闭环断在新号上;
|
|
66
|
+
// #74 要求 ack 与评论统一回写原任务,历史用链可视化而不是多条归档任务。
|
|
67
|
+
export async function reopenTask({
|
|
68
|
+
cwd: rawCwd,
|
|
69
|
+
key: rawKey,
|
|
70
|
+
id,
|
|
71
|
+
text,
|
|
72
|
+
moveTo,
|
|
73
|
+
kind: rawKind,
|
|
74
|
+
quote,
|
|
75
|
+
feedback,
|
|
76
|
+
attachments,
|
|
77
|
+
} = {}) {
|
|
28
78
|
const key = resolveTaskKey({ key: rawKey, cwd: rawCwd });
|
|
29
79
|
const want = Number(id);
|
|
30
80
|
if (!Number.isFinite(want) || want <= 0) throw badInput('缺少参数 --id <任务编号>');
|
|
31
81
|
const store = await loadStore();
|
|
32
82
|
const t = store.topics[key];
|
|
33
83
|
if (!t) throw notFound('主题不存在: ' + key);
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
|
|
84
|
+
const task = t.tasks.find((x) => Number(x.id) === want);
|
|
85
|
+
if (!task || task.deletedAt) throw notFound('任务不存在或已删除: #' + want);
|
|
86
|
+
// 旧口径(#59)归档的 superseded 任务仍拒绝——那是被新号取代的残留,不是本条活。
|
|
87
|
+
if (task.status === 'archived') {
|
|
37
88
|
throw badInput(`#${want} 已归档(被新任务取代)——不能再重开;要继续做请新建任务`);
|
|
38
89
|
}
|
|
39
|
-
|
|
90
|
+
|
|
91
|
+
const kind = rawKind === 'comment' ? 'comment' : 'reopen';
|
|
92
|
+
const before = {
|
|
93
|
+
status: task.status,
|
|
94
|
+
consumedAt: task.consumedAt || '',
|
|
95
|
+
completedAt: task.completedAt || '',
|
|
96
|
+
roundSummary: task.roundSummary || '',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
if (!Array.isArray(task.history)) task.history = [];
|
|
100
|
+
// 首次重开:先落一条 origin,把「改之前」的正文留住(后续节点只记事件态)。
|
|
101
|
+
if (task.history.length === 0) {
|
|
102
|
+
task.history.push(snapshotNode(task, { kind: 'origin' }));
|
|
103
|
+
}
|
|
104
|
+
|
|
40
105
|
const body = String(text ?? '').trim();
|
|
106
|
+
if (body) {
|
|
107
|
+
task.text = preserveFrontmatter(task.text, normalizeText(body));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 本轮事件节点:记反馈/选区/附件;text 取**更新后**的正文(旁路点开即这一轮交付形态)
|
|
111
|
+
const node = snapshotNode(task, {
|
|
112
|
+
kind,
|
|
113
|
+
quote,
|
|
114
|
+
feedback: feedback || '',
|
|
115
|
+
attachments,
|
|
116
|
+
});
|
|
117
|
+
// origin 已占「改前」;事件节点用更新后正文,避免与 origin 完全重复时仍要能看反馈字段
|
|
118
|
+
task.history.push(node);
|
|
119
|
+
|
|
120
|
+
// 重开 = 重新进入待领取:清领取/完成标记,让 get/wait 能再领到同一条。
|
|
121
|
+
// (划选评论也走此入口——反馈已写进正文,下一轮 agent 从同号再领。)
|
|
122
|
+
task.status = 'pending';
|
|
123
|
+
task.consumedAt = '';
|
|
124
|
+
task.completedAt = '';
|
|
125
|
+
task.roundSummary = '';
|
|
126
|
+
task.claimedFrom = '';
|
|
127
|
+
task.claimedBy = '';
|
|
128
|
+
task.claimedByName = '';
|
|
41
129
|
|
|
42
|
-
|
|
130
|
+
task.reopenCount = (Number(task.reopenCount) || 0) + 1;
|
|
131
|
+
task.lastReopenedAt = stampNow();
|
|
132
|
+
// 链上的「当前尖」语义:forkKind 记最近一次事件种类(兼容旧 chain 查询展示)
|
|
133
|
+
task.forkKind = kind;
|
|
134
|
+
|
|
135
|
+
// 落点:默认同主题;带改过归属(moveTo)就搬整条。
|
|
43
136
|
let host = t;
|
|
44
137
|
let moved = false;
|
|
45
138
|
let movedFrom = null;
|
|
46
139
|
if (moveTo && moveTo.cwd) {
|
|
47
140
|
const toKey = topicKeyFor(basename(String(moveTo.cwd)));
|
|
48
141
|
if (toKey !== t.key) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
142
|
+
const { relocateInStore } = await import('./task-view.js');
|
|
143
|
+
const relocated = relocateInStore(store, t, task, moveTo);
|
|
144
|
+
if (relocated) {
|
|
145
|
+
host = relocated.topic;
|
|
146
|
+
moved = true;
|
|
147
|
+
movedFrom = { key, name: t.name, id: want };
|
|
148
|
+
}
|
|
52
149
|
}
|
|
53
150
|
}
|
|
54
151
|
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
const newId = nextTaskId(host.tasks);
|
|
58
|
-
const forked = normalizeTask({
|
|
59
|
-
id: newId,
|
|
60
|
-
text: body ? preserveFrontmatter(old.text, normalizeText(body)) : old.text,
|
|
61
|
-
status: 'pending',
|
|
62
|
-
createdAt: stampNow(),
|
|
63
|
-
forkOf: `${key}:${want}`,
|
|
64
|
-
forkKind: 'reopen', // 验收反馈 / 重做派生(#69 任务链;评论派生是 addTask 的 'comment')
|
|
65
|
-
// 同一件活,约束也接着走:
|
|
66
|
-
// timegoal 时间目标继承——新任务从**再次领取**开始重新计时(与旧口径一致)
|
|
67
|
-
// blocksFollowing 闸门继承——旧任务归档后不再挡人,闸门得由新任务接着当
|
|
68
|
-
// blockBy 上游依赖继承(去掉指向自己的那条)
|
|
69
|
-
timegoal: old.timegoal || null,
|
|
70
|
-
blocksFollowing: !!old.blocksFollowing,
|
|
71
|
-
blockBy: normalizeBlockBy(old.blockBy, newId),
|
|
72
|
-
});
|
|
73
|
-
host.tasks.push(forked);
|
|
74
|
-
|
|
75
|
-
// 旧任务:**前进**到终态(归档)。正文与完成总结一个字都不动——留档。
|
|
76
|
-
old.status = 'archived';
|
|
77
|
-
old.archivedAt = stampNow();
|
|
78
|
-
old.archivedReason = 'superseded';
|
|
79
|
-
old.supersededBy = { key: host.key, id: newId };
|
|
80
|
-
old.reopenCount = (Number(old.reopenCount) || 0) + 1;
|
|
81
|
-
old.lastReopenedAt = stampNow();
|
|
152
|
+
// blockBy 仍指向自己时清掉(编号没变,一般不会;搬家后仍校验一次)
|
|
153
|
+
task.blockBy = normalizeBlockBy(task.blockBy, Number(task.id));
|
|
82
154
|
|
|
83
155
|
host.updatedAt = stampNow();
|
|
84
156
|
bumpWorkflowRevision(host);
|
|
85
157
|
if (host !== t) bumpWorkflowRevision(t);
|
|
86
158
|
await saveStore(store);
|
|
159
|
+
|
|
87
160
|
return {
|
|
88
161
|
status: 'ok',
|
|
89
162
|
reopened: true,
|
|
90
|
-
forked:
|
|
91
|
-
id:
|
|
163
|
+
forked: false, // #74:不再新建
|
|
164
|
+
id: Number(task.id),
|
|
92
165
|
key: host.key,
|
|
93
166
|
name: host.name,
|
|
94
167
|
before,
|
|
95
|
-
|
|
168
|
+
kind,
|
|
169
|
+
historyId: node.id,
|
|
96
170
|
moved,
|
|
97
171
|
movedFrom,
|
|
98
|
-
task: normalizeTask(
|
|
99
|
-
archived: normalizeTask(old, t.tasks),
|
|
172
|
+
task: normalizeTask(task, host.tasks),
|
|
100
173
|
};
|
|
101
174
|
}
|
|
175
|
+
|
|
102
176
|
// 取走该主题第一条 pending;没有则返回 null。roundSummary 显式指定本轮完成总结,
|
|
103
177
|
// 缺省回落到主题当前 summary(等待中即本轮现状)。
|
|
104
178
|
// by = 领取方身份 {key,name,cwd}(wait 传入),用于记领取审计。
|
|
@@ -227,4 +301,3 @@ export async function completeTask({ cwd: rawCwd, key: rawKey, id, summary: rawS
|
|
|
227
301
|
//
|
|
228
302
|
// (goal 探针与目标上下文已随 wait 编排迁往 tasktool/wait.js——任务工具语义归
|
|
229
303
|
// tasktool,队列本体不再依赖 timegoal 模块。)
|
|
230
|
-
|
|
@@ -96,8 +96,8 @@ export function normalizeTask(t, siblings, readyOpts = {}) {
|
|
|
96
96
|
const base = {
|
|
97
97
|
id: Number(t.id) || 0,
|
|
98
98
|
text: String(t.text ?? ''),
|
|
99
|
-
// 状态词汇:pending → consumed
|
|
100
|
-
//
|
|
99
|
+
// 状态词汇:pending → consumed(已领取);完成验收后可就地回 pending(#74)。
|
|
100
|
+
// archived 仍保留给旧口径(#59 fork 取代)的残留行,不再由 reopen 写入。
|
|
101
101
|
status: t.status === 'consumed' ? 'consumed' : t.status === 'archived' ? 'archived' : 'pending',
|
|
102
102
|
roundSummary: String(t.roundSummary ?? ''),
|
|
103
103
|
createdAt: String(t.createdAt ?? ''),
|
|
@@ -123,11 +123,12 @@ export function normalizeTask(t, siblings, readyOpts = {}) {
|
|
|
123
123
|
timegoal: sanitizeTaskGoal(t.timegoal),
|
|
124
124
|
// 完成标记(localtask done 写入):带时间目标的任务未到点会被拒绝,写不进来。
|
|
125
125
|
completedAt: String(t.completedAt ?? ''),
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
126
|
+
// 重开轨迹(#74):就地重开,历史进 history[];forkOf 仅兼容旧 #59/#69 派生数据。
|
|
127
|
+
// history 同任务内的链节点(origin / reopen / comment),点开可旁路查看
|
|
128
|
+
// forkOf 旧派生链('队列key:旧编号')——新 reopen 不再写
|
|
129
|
+
// forkKind 最近一次事件种类(reopen / comment),或旧派生种类
|
|
130
|
+
// supersededBy / archived* 旧归档残留字段
|
|
131
|
+
history: normalizeHistory(t.history),
|
|
131
132
|
forkOf: String(t.forkOf ?? ''),
|
|
132
133
|
forkKind: t.forkKind === 'reopen' || t.forkKind === 'comment' ? t.forkKind : '',
|
|
133
134
|
supersededBy: t.supersededBy && typeof t.supersededBy === 'object' ? t.supersededBy : null,
|
|
@@ -227,11 +228,50 @@ export function topicView(t, repoCtx = null, readyOpts = {}) {
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
// ─── 任务链(#69) ────────────────────────────────────────────────────
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
/** 规范化任务内 history 链(#74)。非法项丢弃,顺序保留。 */
|
|
232
|
+
export function normalizeHistory(raw) {
|
|
233
|
+
if (!Array.isArray(raw)) return [];
|
|
234
|
+
const out = [];
|
|
235
|
+
for (const h of raw) {
|
|
236
|
+
if (!h || typeof h !== 'object') continue;
|
|
237
|
+
const kind = h.kind === 'comment' || h.kind === 'origin' ? h.kind : 'reopen';
|
|
238
|
+
const attachments = Array.isArray(h.attachments)
|
|
239
|
+
? h.attachments
|
|
240
|
+
.filter((a) => a && typeof a === 'object')
|
|
241
|
+
.map((a) => ({
|
|
242
|
+
id: String(a.id || ''),
|
|
243
|
+
name: String(a.name || ''),
|
|
244
|
+
type: a.type === 'image' ? 'image' : 'file',
|
|
245
|
+
size: String(a.size || ''),
|
|
246
|
+
url: a.url ? String(a.url) : '',
|
|
247
|
+
}))
|
|
248
|
+
: [];
|
|
249
|
+
out.push({
|
|
250
|
+
id: Number(h.id) || out.length + 1,
|
|
251
|
+
kind,
|
|
252
|
+
at: String(h.at ?? ''),
|
|
253
|
+
text: String(h.text ?? ''),
|
|
254
|
+
summary: String(h.summary ?? ''),
|
|
255
|
+
status: String(h.status ?? ''),
|
|
256
|
+
completedAt: String(h.completedAt ?? ''),
|
|
257
|
+
quote: String(h.quote ?? ''),
|
|
258
|
+
feedback: String(h.feedback ?? ''),
|
|
259
|
+
attachments,
|
|
260
|
+
excerpt: String(h.excerpt ?? '')
|
|
261
|
+
.replace(/^#+\s*/, '')
|
|
262
|
+
.slice(0, 100),
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return out;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// 任务链两套来源(#74 / 兼容 #69):
|
|
269
|
+
// history[] —— 同任务内就地重开/评论节点(主路径)
|
|
270
|
+
// forkOf 派生 —— 旧「新建任务」链(祖先 + 子任务)
|
|
271
|
+
// 三个原语:
|
|
232
272
|
// resolveForkRef —— 发布侧:裸数字(同主题)/'key:id'(跨主题)规范化 + 验证父任务存在
|
|
233
273
|
// forkRow —— 按引用取行(内部;软删/迁出不算存在)
|
|
234
|
-
// taskChain ——
|
|
274
|
+
// taskChain —— 查询侧:history 节点 + 祖先链 + 子任务
|
|
235
275
|
|
|
236
276
|
function forkRow(store, ref) {
|
|
237
277
|
const m = /^(.+):(\d+)$/.exec(String(ref || ''));
|
|
@@ -280,7 +320,7 @@ function chainLite(topic, t) {
|
|
|
280
320
|
};
|
|
281
321
|
}
|
|
282
322
|
|
|
283
|
-
/**
|
|
323
|
+
/** 任务链查询:同任务 history 节点 + 旧 forkOf 祖先/子任务。 */
|
|
284
324
|
export async function taskChain({ id, cwd, key } = {}) {
|
|
285
325
|
const k = resolveTaskKey({ key, cwd });
|
|
286
326
|
const want = Number(id);
|
|
@@ -290,6 +330,41 @@ export async function taskChain({ id, cwd, key } = {}) {
|
|
|
290
330
|
if (!t) throw notFound('主题不存在: ' + k);
|
|
291
331
|
const self = (t.tasks || []).find((x) => Number(x.id) === want && !x.deletedAt && !x.migratedTo);
|
|
292
332
|
if (!self) throw notFound('任务不存在或已删除: #' + want);
|
|
333
|
+
|
|
334
|
+
const history = normalizeHistory(self.history);
|
|
335
|
+
// nodes:history 按时间序 + 当前尖(live)。面板链图只吃这一列。
|
|
336
|
+
const nodes = history.map((h) => ({
|
|
337
|
+
historyId: h.id,
|
|
338
|
+
kind: h.kind,
|
|
339
|
+
at: h.at,
|
|
340
|
+
excerpt: h.excerpt || h.feedback?.slice(0, 100) || '',
|
|
341
|
+
feedback: h.feedback,
|
|
342
|
+
quote: h.quote,
|
|
343
|
+
summary: h.summary,
|
|
344
|
+
status: h.status,
|
|
345
|
+
completedAt: h.completedAt,
|
|
346
|
+
attachmentCount: (h.attachments || []).length,
|
|
347
|
+
current: false,
|
|
348
|
+
}));
|
|
349
|
+
const tipExcerpt =
|
|
350
|
+
String(self.text ?? '')
|
|
351
|
+
.split('\n')
|
|
352
|
+
.map((l) => l.trim())
|
|
353
|
+
.find(Boolean) || '';
|
|
354
|
+
nodes.push({
|
|
355
|
+
historyId: null,
|
|
356
|
+
kind: 'current',
|
|
357
|
+
at: String(self.lastReopenedAt || self.createdAt || ''),
|
|
358
|
+
excerpt: tipExcerpt.replace(/^#+\s*/, '').slice(0, 100),
|
|
359
|
+
feedback: '',
|
|
360
|
+
quote: '',
|
|
361
|
+
summary: String(self.roundSummary || ''),
|
|
362
|
+
status: self.status,
|
|
363
|
+
completedAt: String(self.completedAt || ''),
|
|
364
|
+
attachmentCount: 0,
|
|
365
|
+
current: true,
|
|
366
|
+
});
|
|
367
|
+
|
|
293
368
|
// 祖先链:visited 防环;上限 32(这是条链不是树,合理深度远小于它——超限即数据异常)
|
|
294
369
|
const ancestors = [];
|
|
295
370
|
const seen = new Set([`${k}:${want}`]);
|
|
@@ -306,7 +381,7 @@ export async function taskChain({ id, cwd, key } = {}) {
|
|
|
306
381
|
ancestors.push(chainLite(row.topic, row.task));
|
|
307
382
|
cur = String(row.task.forkOf || '');
|
|
308
383
|
}
|
|
309
|
-
//
|
|
384
|
+
// 子任务:派生落点可能换主题(旧 reopen 带 moveTo / 评论跨队列),所以全 store 扫
|
|
310
385
|
const ref = `${k}:${want}`;
|
|
311
386
|
const children = [];
|
|
312
387
|
for (const topic of Object.values(store.topics)) {
|
|
@@ -322,6 +397,8 @@ export async function taskChain({ id, cwd, key } = {}) {
|
|
|
322
397
|
name: t.name,
|
|
323
398
|
id: want,
|
|
324
399
|
task: normalizeTask(self, t.tasks),
|
|
400
|
+
nodes,
|
|
401
|
+
history,
|
|
325
402
|
ancestors,
|
|
326
403
|
children,
|
|
327
404
|
};
|