dsh-workbench-tasks 5.3.0 → 5.5.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/lib/index.js CHANGED
@@ -31,6 +31,7 @@ import { registerOverviewAction } from "./stats/overview.js";
31
31
  import { registerConfigActions } from "./infra/config.js";
32
32
  import { registerDataActions } from "./infra/data.js";
33
33
  import { registerPublisherCommand } from "./publisher/command.js";
34
+ import { TASK_ROLES } from "./publisher/roles.js";
34
35
  import { commandCatalog } from "./publisher/catalog.js";
35
36
 
36
37
  export const inject = ["workbench"];
@@ -136,6 +137,7 @@ export function apply(ctx) {
136
137
  description: "任务树 + 统计/记录/时间线/配置/数据五个视图:紧急/已关闭/已开启/已完成/总览,可按标签筛选(需安装标签插件),附统计报表与只读数据浏览",
137
138
  version: ADDON_VERSION,
138
139
  category: "work",
140
+ roles: TASK_ROLES,
139
141
  tables: ["task", "task_node", "task_timeline", "task_timeline_link", "task_workspace", "task_workspace_link"],
140
142
  sync: taskSync,
141
143
  // 贡献声明:任务往「条目操作」插槽里挂「从邮件建任务」。
@@ -167,7 +169,7 @@ export function apply(ctx) {
167
169
  ],
168
170
  primaryAction: "tasks.create",
169
171
  keyArgs: ["tableId", "tablePath", "createMissing", "pathDescriptions", "title", "description", "priority", "difficulty", "targetDate", "tags", "tagIds", "dedupeKey"],
170
- dedupe: "同 dedupeKey 的未删除任务会被复用;自动记录建议使用稳定键,如 dsh-session:<id>。",
172
+ dedupe: "同 dedupeKey 的未删除任务会被复用;自动记录建议使用稳定键,如 dsh-session:<会话>:<需求标识>:<条目序号>。",
171
173
  relations: [
172
174
  { kind: "taskNode", via: "tableId", description: "先调用 taskNodes.overview 查看全文描述、类型、路径与子树计数,再用 tasks.create 的 tableId 选表;group/root_group 只能装子节点,table 才能直接放任务。创建必须显式tableId或tablePath且互斥;无默认表。优先tasks.capabilities/resolveTable核对职责;新路径授权后用createMissing+pathDescriptions。" },
173
175
  { kind: "tag", via: "tags / tagIds", description: "用标签做主题归类(工作/生活/学习/开发 已是标签);传标签名会自动建。" },
@@ -215,7 +217,7 @@ export function apply(ctx) {
215
217
  { name: "type", type: "0|1|2|3|4", description: "仅 tasks.update 使用:0=改状态 1=改优先级 2=改标题 3=改描述 4=改感受;这是“更新模式”,不是任务类型(任务没有类型字段,用标签表达)" },
216
218
  { name: "review", type: "string", description: "完成后的感受/复盘自由文本,通常随完成一起写入" },
217
219
  { name: "range / from / to", type: "7d|30d|90d|365d|all / YYYY-MM-DD", description: "仅统计类 action:range 是快捷区间(缺省 30d),from+to 手动区间是闭区间 [from,to],两端都含;同时传时以 from/to 为准" },
218
- { name: "dedupeKey", type: "string", description: "去重键:同键的未删除任务会被复用而不是新建,自动记录建议用 dsh-session:<id>" },
220
+ { name: "dedupeKey", type: "string", description: "去重键:同键的未删除任务会被复用而不是新建,自动记录建议用 dsh-session:<会话>:<需求标识>:<条目序号>" },
219
221
  { name: "source / timelineId / timelineKey / restartKey", type: "0|1|2 / string", description: "来源:0=无时间线普通任务;1=加入手动创建的有效时间线,需要timelineId(timelineKey为deprecated兼容别名);2=重启,需restartKey且原任务已有有效归属,自动继承同一线;无归属先手动建线并关联,失败零写。重启固定开启、优先级1–10缺省1。" },
220
222
  ],
221
223
  notFor: ["不要用它保存聊天记录、日志或临时笔记"],
@@ -1,6 +1,5 @@
1
1
  /**
2
- * `/wb-task-publisher` 的 brief 构造:把用户原话与发布 SOP 拼成一条
3
- * 模型可见的用户消息。纯函数,不依赖 ctx,便于单测。
2
+ * 任务发布者的业务规则及命令页的只读模板。
4
3
  */
5
4
 
6
5
  /** 需求正文长度上限:超过时让用户拆分或改用附件,不静默截断。 */
@@ -12,7 +11,7 @@ const SOP_STEPS = [
12
11
  "C. 归属(任务表 + 工作区):先调用 taskNodes.overview 拿全量任务树,按职责选择任务表;出现多个候选且职责相当必须问用户,禁止按热度、第一个候选或分数自动选择。没有合适节点时自行建模:给出路径、命名与理由,直接调用 taskNodes.create 建组或建表(已明确授权的场景也可用 tasks.create 的 createMissing + pathDescriptions),不必等用户确认;只有确有新职能域才新建上级组,不得为单条任务建整条组层级。再调用 taskWorkspaces.list(默认按 updated_at 倒序,候选多时 pageSize 用到 100)取工作区,结合任务职责与工作区的 title/name/description/dir 判断归属,合法结果只有三种:不关联工作区、关联一个、关联多个。没有合适候选时自行判断:能明确对应某个工作目录就用 taskWorkspaces.create 建一个再挂,判断不了就不挂;禁止为了挂而造,禁止按名称相似或列表第一条自动挂。创建任务时把确认的工作区 id 传进 tasks.create 的 workspaceIds(整体替换语义,任一 id 非法会让整次创建回滚)。历史任务只作线索,不作现行规则。",
13
12
  "D. 时间线:判断现有时间线是否匹配、是否需要新建、能否与历史任务形成同一条线 / 重启链(restartKey)/ 后续任务。能挂现有时间线就挂;预计会形成 2 个及以上任务的链条时直接调用 taskTimelines.create 新开一条并挂入;只有一单的线不建,明确写「无时间线归属」,不要为了凑线硬挂。",
14
13
  "E. 标签:标签不在意 id,所以不要被现有标签列表限制。tasks.tagOptions / tasks.tags 只是参考(了解既有命名风格),不是候选清单,不要先查一遍再从里面挑。按业务域、功能面、动作、影响面自由联想,越具体越好、越多越好(通常 5–8 个,上不封顶);但每条必须语义准确、能独立看懂,不要为凑数堆同义词、空泛词或近似重复,回看时合并重复的。创建时直接传 tags: [\"标签名\"],不要用 tagIds,也不必先 tags.create(未知名字由 form.autoCreateTags 决定,默认自动创建)。标签域未安装时仍传 tags:任务照常创建、回执 notices 会说明标签缺失,不要因此停问、重试或声称已打标。",
15
- "F. 发布:先调用 tasks.list 以标题关键词查重;创建时 source 用 0,dedupeKey 用「dsh-session:」前缀拼接 sessionId(用户手写发布可用自定义键),并把 C 步确认的 workspaceIds、E 步写出的 tags 一起传入。创建回执必须给出任务 id、任务表路径、工作区归属、时间线归属、标签(完整名称;新建的单独标出,没标注的视为沿用)、计划完成日期与「本次自建」段,并给用户一屏摘要,不要原样贴 action JSON。「本次自建」要写明本次新建的任务组或表(完整路径)、时间线(标题 + id)、工作区(名称 + id + dir);没有自建就写「本次自建:无」。",
14
+ "F. 发布:先调用 tasks.list 以标题关键词查重;创建时 source 用 0,dedupeKey 按条目生成:用会话标识、首次提出该需求的用户消息标识和固定条目序号拼成稳定键;重试沿用原键,后续独立需求另用新键,禁止只用会话标识,并把 C 步确认的 workspaceIds、E 步写出的 tags 一起传入。创建回执必须给出任务 id、任务表路径、工作区归属、时间线归属、标签(完整名称;新建的单独标出,没标注的视为沿用)、计划完成日期与「本次自建」段,并给用户一屏摘要,不要原样贴 action JSON。「本次自建」要写明本次新建的任务组或表(完整路径)、时间线(标题 + id)、工作区(名称 + id + dir);没有自建就写「本次自建:无」。",
16
15
  "G. 何时停下来问:只有三种情况先给草案并提问、不创建:任务表多候选且职责相当、信息互相冲突、查重命中同主题任务。缺任务表 / 时间线 / 工作区不属于停问条件,按 C/D 自行补齐并在回执的「本次自建」里说明;信息齐全且归属唯一时直接发布。",
17
16
  ];
18
17
 
@@ -20,9 +19,30 @@ const SOP_STEPS = [
20
19
  // 边界规则里不再重复授权话题,否则两处口径会互相打架(F 说自行补齐就能发,边界说必须先停下要授权)。
21
20
  const BOUNDARIES = [
22
21
  "不要改 tasks.create / tasks.update 的 schema 与业务语义,也不要为了完成流程伪造数据或证据。",
23
- "一次性问答、临时查询不建任务;物品登记走 storage.create,只有开发/修复工作项才进任务表。",
22
+ "tasks.update 只用于回修本轮自己刚发布的任务:描述纠错、归属或时间线修正、补充验收标准。不得改他人任务的内容或状态;任务完成、关闭与接取仍属任务执行者。",
23
+ "一次性问答、临时查询不建任务;物品登记提示交给物品插件办理,只有开发/修复工作项才进任务表。",
24
24
  ];
25
25
 
26
+ /** 宿主注入与命令页模板共用这份规则,避免把业务规则重复塞进用户消息。 */
27
+ export const PUBLISHER_INSTRUCTIONS = [
28
+ "选中角色后,讨论或仅需草案时只读;用户明确要求发布(包括调用发布命令)才按以下流程写入。依据用户原话和附件辨别需求。",
29
+ "## 本轮角色与产出目标",
30
+ "你是任务发布助手:把用户的一句话需求整理成可执行、可核对、可追踪的任务,再决定是否发布。产出是「润色后的任务草案 + 归属与时间线判断 + 发布结果或待确认问题」,不是直接改代码。",
31
+ "",
32
+ "## 发布 SOP(按顺序执行)",
33
+ ...SOP_STEPS,
34
+ "",
35
+ "## 输出格式",
36
+ "1. 现状调研:三条以内,标注证据来源;没有证据就写「未核实」。",
37
+ "2. 任务草案:标题、背景、目标、范围与非目标、验收标准、优先级、难度、计划完成日期。",
38
+ "3. 归属、时间线与标签:任务表完整路径(含 tableId)、工作区归属(无工作区,或名称 + id 列表)、时间线归属或「无时间线归属」、标签(列出全部名称,新建的单独标出)、理由。",
39
+ "4. 发布回执或待确认问题:已发布时给任务 id、路径、工作区归属(无工作区时写明「无工作区」,多个时列全名称与 id)、时间线、标签(完整名称;新建的单独标出,未打标须说明原因)、完成日期与「本次自建」段(没有自建就写「本次自建:无」);未发布时给需要用户拍板的具体问题。",
40
+ "",
41
+ "## 边界规则",
42
+ ...BOUNDARIES.map((line) => "- " + line),
43
+ "",
44
+ ].join("\n").trim();
45
+
26
46
  function textOf(value) {
27
47
  return typeof value === "string" ? value : "";
28
48
  }
@@ -51,26 +71,12 @@ export function buildPublisherBrief({ requirement, sessionId, now, preview } = {
51
71
  "## 用户原话(逐字保留,不要先改写)",
52
72
  raw.trim(),
53
73
  "",
54
- "## 本轮角色与产出目标",
55
- "你是任务发布助手:把用户的一句话需求整理成可执行、可核对、可追踪的任务,再决定是否发布。产出是「润色后的任务草案 + 归属与时间线判断 + 发布结果或待确认问题」,不是直接改代码。",
56
- "",
57
- "## 发布 SOP(按顺序执行)",
58
- ...SOP_STEPS,
59
- "",
60
- "## 输出格式",
61
- "1. 现状调研:三条以内,标注证据来源;没有证据就写「未核实」。",
62
- "2. 任务草案:标题、背景、目标、范围与非目标、验收标准、优先级、难度、计划完成日期。",
63
- "3. 归属、时间线与标签:任务表完整路径(含 tableId)、工作区归属(无工作区,或名称 + id 列表)、时间线归属或「无时间线归属」、标签(列出全部名称,新建的单独标出)、理由。",
64
- "4. 发布回执或待确认问题:已发布时给任务 id、路径、工作区归属(无工作区时写明「无工作区」,多个时列全名称与 id)、时间线、标签(完整名称;新建的单独标出,未打标须说明原因)、完成日期与「本次自建」段(没有自建就写「本次自建:无」);未发布时给需要用户拍板的具体问题。",
65
- "",
66
- "## 边界规则",
67
- ...BOUNDARIES.map((line) => "- " + line),
68
- "",
74
+ PUBLISHER_INSTRUCTIONS,
69
75
  "## 会话信息",
70
76
  "sessionId: " + sid,
71
77
  // 不要把 dsh-session: 前缀和裸 sessionId 连写:DSH 会把 "dsh-session:<base64url>" 当会话引用 URI,
72
78
  // 裸 id 不是合法 payload,会让下一轮在模型调用前就解析失败。这里只描述拼法,由模型自行组装。
73
- "dedupeKey 建议: 用 \"dsh-session:\" 前缀拼接上面的 sessionId(前缀后接的是会话 id 本身)",
79
+ "dedupeKey 建议: 按 F 步为每个独立条目生成稳定键",
74
80
  "生成时间: " + stamp,
75
81
  ].join("\n");
76
82
  }
@@ -19,6 +19,7 @@ export const TEMPLATE_PLACEHOLDERS = {
19
19
  export const TASK_COMMANDS = [
20
20
  {
21
21
  name: "wb-task-publisher",
22
+ roleId: "wb-addon-tasks/publisher",
22
23
  title: { zh: "发布任务", en: "Publish task" },
23
24
  summary: {
24
25
  zh: "按调研、润色、归属、时间线、标签、查重的固定流程发布任务",
@@ -40,12 +41,12 @@ export const TASK_COMMANDS = [
40
41
  { text: "/wb-task-publisher 修复配置页重置按钮不生效(附复现步骤)" },
41
42
  ],
42
43
  sentText: {
43
- zh: "已把发布引导送入下一轮:先调研现状,再润色、判归属与时间线、自由联想标签、查重,缺任务表/时间线/工作区会自行补齐,最后发布并在回执说明标签与自建内容。",
44
- en: "Publisher guidance sent to the next turn: research, polish, ownership, timeline, tags, dedupe — missing tables, timelines or workspaces are created without asking — then publish, listing tags and anything it created.",
44
+ zh: "本次需求已交给任务发布者。需要连续发布时,可在输入框选择该角色。",
45
+ en: "Sent this request to the task publisher. Select the role in the composer for continued use.",
45
46
  },
46
47
  notes: {
47
- zh: "命令会把你的原话与发布 SOP 送入下一轮模型:先调研现状,再润色、判归属与时间线、自由联想标签(未知名字自动创建)、查重,缺任务表 / 时间线 / 工作区时会自行补齐、不再追着你确认,并在回执里列出全部标签(新建的单独标出)与「本次自建」内容。可以在需求后附截图或文档。",
48
- en: "The command sends your words plus the publishing SOP into the next model turn: research the current state, polish, decide ownership and timeline, invent tags freely (unknown names are created automatically), check for duplicates, missing tables, timelines or workspaces are created without asking and listed in the receipt along with the final tags. Screenshots or docs can be attached.",
48
+ zh: "仅本次请求使用任务发布者。可附截图或文档,宿主会为本轮加载下方工作规则。",
49
+ en: "Uses the task publisher for this request only. Screenshots and documents are supported. The host loads the workflow below for this turn.",
49
50
  },
50
51
  buildBrief: (options) => buildPublisherBrief(options),
51
52
  },
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 任务插件注册的斜杠命令:把「用户原话 + 各自 SOP」送进下一轮模型。
2
+ * 任务插件注册的斜杠命令:把用户原话、附件交给单次绑定角色的下一轮。
3
3
  * 命令本身不建任务、不写业务数据;无 commands 服务(ACP/无 UI)时静默跳过。
4
4
  *
5
5
  * 命令的元信息与正文生成函数都在 catalog.js:这里只做注册循环,
@@ -17,7 +17,7 @@ function newMessageId() {
17
17
  return "msg-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 10);
18
18
  }
19
19
 
20
- /** 取当前会话 id;拿不到时用 unknown,仅用于 dedupeKey 提示。 */
20
+ /** 取当前会话 id;用于绑定命令生成的消息。 */
21
21
  function sessionIdOf(agent) {
22
22
  return String((agent && agent.session && agent.session.id) || (agent && agent.id) || "");
23
23
  }
@@ -40,8 +40,8 @@ export function registerPublisherCommand(ctx) {
40
40
  // 正文由 followup 带入模型历史,命令日志里不再重复记一遍。
41
41
  recordInput: false,
42
42
  handler: ({ agent, rawInput, attachments } = {}) => {
43
- const requirement = typeof rawInput === "string" ? rawInput.trim() : "";
44
- if (requirement.length === 0) {
43
+ const requirement = typeof rawInput === "string" ? rawInput : "";
44
+ if (!requirement.trim()) {
45
45
  return { kind: "success", text: usageText(entry, "zh") };
46
46
  }
47
47
  const limit = entry.limit;
@@ -56,18 +56,19 @@ export function registerPublisherCommand(ctx) {
56
56
  if (!agent || typeof agent.followup !== "function") {
57
57
  return { kind: "error", text: "当前会话无法接收下一轮消息," + entry.title.zh + "引导没有送出。" };
58
58
  }
59
- const brief = entry.buildBrief({
60
- requirement,
61
- sessionId: sessionIdOf(agent),
62
- now: new Date(),
63
- });
64
- const extra = Array.isArray(attachments) ? attachments : [];
65
- const content = extra.length > 0
66
- ? [...extra, { type: "text", text: brief }]
67
- : [{ type: "text", text: brief }];
59
+ const host = ctx.workbench;
60
+ const sessionId = sessionIdOf(agent);
61
+ if (!sessionId || typeof host?.bindMessageRole !== "function") {
62
+ return { kind: "error", text: "当前会话无法绑定单次发布角色,请检查工作台宿主版本和会话状态。" };
63
+ }
64
+ const id = newMessageId();
65
+ const content = [...(Array.isArray(attachments) ? attachments : []), { type: "text", text: requirement }];
66
+ let cancel;
68
67
  try {
69
- agent.followup({ id: newMessageId(), role: "user", content, source: { kind: "user" } });
68
+ cancel = host.bindMessageRole(sessionId, id, entry.roleId);
69
+ agent.followup({ id, role: "user", content, source: { kind: "user" } });
70
70
  } catch (error) {
71
+ cancel?.();
71
72
  const message = error && error.message ? error.message : String(error);
72
73
  return { kind: "error", text: entry.title.zh + "引导送入失败:" + message };
73
74
  }
@@ -0,0 +1,29 @@
1
+ /** 任务插件贡献的会话角色。动作清单只描述工作台调用的上界。 */
2
+ import { PUBLISHER_INSTRUCTIONS } from "./brief.js";
3
+
4
+ const reads = ["tasks.get", "tasks.list", "tasks.workspaces", "tasks.timeline", "taskNodes.overview", "taskWorkspaces.list"];
5
+
6
+ export const TASK_ROLES = [
7
+ {
8
+ id: "publisher",
9
+ name: "任务发布者",
10
+ description: "整理需求、核对归属与验收标准,按要求发布任务。",
11
+ version: "1.1.0",
12
+ instructions: PUBLISHER_INSTRUCTIONS,
13
+ actions: [...reads, "tasks.update", "tasks.timelines", "tasks.tags", "tasks.tagOptions", "taskTimelines.get",
14
+ "tasks.create", "taskNodes.create", "taskWorkspaces.create", "taskTimelines.create", "taskTimelines.attach"],
15
+ },
16
+ {
17
+ id: "executor",
18
+ name: "任务执行者",
19
+ description: "围绕已有任务推进工作,记录阻塞、进展或验收证据。",
20
+ version: "1.0.0",
21
+ instructions: [
22
+ "先从用户引用或上文定位任务,再用 tasks.get 核对当前状态、工作区与验收标准。若有多个候选,列出编号并请用户选定。",
23
+ "用户询问进度时只读。收到执行要求后围绕选定任务推进工作,保留可核对的交付证据。",
24
+ "按需用 tasks.update 回写该任务的进展或阻塞,保留原始需求和验收标准。只有验收完成并有证据时才用 tasks.complete。",
25
+ "回执给出任务编号、实际完成项、证据和待处理事项。切换角色本身不启动工作或改变状态。",
26
+ ].join("\n"),
27
+ actions: [...reads, "tasks.update", "tasks.complete"],
28
+ },
29
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-tasks",
3
- "version": "5.3.0",
3
+ "version": "5.5.0",
4
4
  "description": "个人工作台任务插件:任务树、优先级、截止日、时间线与重启",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -17,8 +17,8 @@
17
17
  "id": "wb-addon-tasks",
18
18
  "title": "任务",
19
19
  "description": "任务树 + 统计/记录/时间线/工作区/配置/数据/命令/Action 八个视图:紧急/已关闭/已开启/已完成/总览,可按标签筛选,附统计报表与表数据浏览",
20
- "version": "5.3.0",
21
- "minShell": "0.8.4",
20
+ "version": "5.5.0",
21
+ "minShell": "0.15.0",
22
22
  "tables": [
23
23
  "task",
24
24
  "task_node",
@@ -101,7 +101,7 @@
101
101
  "./package.json": "./package.json"
102
102
  },
103
103
  "dependencies": {
104
- "dsh-workbench-host": "^0.10.6"
104
+ "dsh-workbench-host": "^0.17.0"
105
105
  },
106
106
  "dsh": {
107
107
  "bundle": {