nx-kv 0.45.1 → 0.46.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/assets/kv-get/SKILL.md +1 -1
  4. package/assets/kv-get/references/timegoal-workflow.md +7 -7
  5. package/assets/kv-get/references/timegoal.md +6 -6
  6. package/package.json +1 -1
  7. package/src/modules/localtask/action-lifecycle.js +3 -6
  8. package/src/modules/localtask/repo/goals.js +5 -6
  9. package/src/modules/localtask/task-lifecycle.js +2 -2
  10. package/src/modules/tasktool/index.js +4 -7
  11. package/src/modules/tasktool/plugins/goal-template.js +2 -2
  12. package/src/modules/tasktool/plugins/taskgoal-store.js +1 -1
  13. package/src/modules/tasktool/plugins/timegoal-cwd-store.js +8 -11
  14. package/src/modules/tasktool/plugins/timegoal-task-store.js +9 -12
  15. package/src/shared/prompt-blocks.js +1 -1
  16. package/src/web/public/assets/{Introduction-EHroxF1H.js → Introduction-BI8Ohz1l.js} +1 -1
  17. package/src/web/public/assets/{bar-BvS_Jfi4.js → bar-Jfji2mz3.js} +1 -1
  18. package/src/web/public/assets/{cloud-DlWk0wnP.js → cloud-cFewR3CF.js} +1 -1
  19. package/src/web/public/assets/{composer-panel-D3w-CjhN.js → composer-panel-CcK0D4Gd.js} +1 -1
  20. package/src/web/public/assets/{deleted-panel-BMJEEBWD.js → deleted-panel-oN8YlGvq.js} +1 -1
  21. package/src/web/public/assets/{dir-BtjHgH4Q.js → dir-BuAtw08k.js} +1 -1
  22. package/src/web/public/assets/{group-Bxq8JamU.js → group-FRUv4mQ6.js} +1 -1
  23. package/src/web/public/assets/{index-ChlZPTea.js → index-CyF6nNWE.js} +2 -2
  24. package/src/web/public/assets/{md-history-CBqcR086.js → md-history-DErcpXhC.js} +1 -1
  25. package/src/web/public/assets/{overview-BP5sB1WX.js → overview-DZHcrz4u.js} +1 -1
  26. package/src/web/public/assets/{refs-Dt7DQIOo.js → refs-BXIwmL5W.js} +1 -1
  27. package/src/web/public/assets/{repos-Zl1_SfPX.js → repos-DYugJZpl.js} +1 -1
  28. package/src/web/public/assets/{route-crumb-PqhQSVWL.js → route-crumb-C3Ce0rzR.js} +1 -1
  29. package/src/web/public/assets/{settings-CXWFvvvv.js → settings-Bpazt87u.js} +2 -2
  30. package/src/web/public/assets/{status-tag-BK-45ld2.js → status-tag-CHCpOgMP.js} +1 -1
  31. package/src/web/public/assets/{task-COFIPegR.js → task-G58spmPC.js} +1 -1
  32. package/src/web/public/assets/{templates-CIxgTTt-.js → templates-Dr0CunY8.js} +1 -1
  33. package/src/web/public/assets/{tool-bar-TIqYxsQl.js → tool-bar-BSIlsHln.js} +1 -1
  34. package/src/web/public/index.html +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  本文件记录对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
4
4
 
5
+ ## [0.46.0] - 2026-11-10 progress 参数彻底退役(#92)
6
+
7
+ ### Removed
8
+
9
+ - **`localtask done --progress`**:flag 彻底删除(0.31.x 起已废弃不生效)——done 只携带
10
+ `--summary`,完成总结就是本轮终态。
11
+ - **`localtask get --summary`**:废弃占位 flag 删除——get 就是单纯的领取语义,不收任何现状。
12
+ - **`timegoal check --progress`**:参数语义废除——check 只要求 `--summary`(当轮现状),
13
+ 日志每轮只记现状 + 剩余时间;CLI 回显、`timegoal log` / `localtask timegoal-log` 输出、
14
+ 任务级 goal 交付模板与 doneguard 默认文案同步去掉 progress 段。
15
+ - **存储写入简化**:任务级 `goal_checks.summary` 列改为纯文本(旧库 JSON `{summary, progress}`
16
+ 编码在读取侧兼容解析,web 任务页 check 标签的历史 progress 行仍可显示,新行不再产生);
17
+ 目录级 timegoal blob 的 check 流水同样不再写入 progress 字段(历史字段原样透出)。
18
+
19
+ ### Docs
20
+
21
+ - `assets/kv-get`(SKILL.md / timegoal / timegoal-workflow)、`README`、
22
+ `docs/project&projectsCli.md`:全部 check/done 命令示例去掉 `--progress`;
23
+ - 单测:`timegoal.test.mjs`、`taskgoal.test.mjs` 按「check 只要 summary」更新断言。
24
+
5
25
  ## [0.45.1] - 2026-11-10 残留 -shm 打开自愈 + 打开失败错误指路
6
26
 
7
27
  ### Fixed
package/README.md CHANGED
@@ -231,7 +231,7 @@ nx-kv timegoal set --cwd "$PWD" --duration 10800 --prompt "<完整全局提示
231
231
  nx-kv timegoal set --cwd "$PWD" --duration 5h --prompt "<完整全局提示词>" --json
232
232
 
233
233
  # 每轮调一次:算出还剩多少时间,并把提示词【原文】回显给你
234
- nx-kv timegoal check --cwd "$PWD" --summary "<当前现状>" --progress "<完成度/下一步>" --json
234
+ nx-kv timegoal check --cwd "$PWD" --summary "<当前现状>" --json
235
235
  # → { reached:false, remainingSec:10780, prompt:"<完整提示词原文>", deadline, ... }
236
236
 
237
237
  # 提示词要改(agent 自我迭代 / 用户在面板上改)——只换提示词,保住计时起点
@@ -44,7 +44,7 @@ nx-kv localtask get --json
44
44
  **自动起表**,交付文本里带一条固定指令:
45
45
 
46
46
  ```bash
47
- nx-kv timegoal check --task task:<topicKey>:<taskId> --summary "<本轮现状>" --progress "<进展/下一步>"
47
+ nx-kv timegoal check --task task:<topicKey>:<taskId> --summary "<本轮现状>"
48
48
  ```
49
49
 
50
50
  每轮推进先跑一次 check(它会原文回显时间目标提示词,防长对话漂移)。
@@ -37,7 +37,7 @@
37
37
  ▼
38
38
  ┌───────────────────────────────────────────────────────┐
39
39
  │ 1. nx-kv timegoal check --cwd "$PWD" \ │
40
- │ --summary "<本轮现状>" --progress "<完成度/下一步>" │
40
+ │ --summary "<本轮现状>" │
41
41
  │ ↓ 拿到 {remainingSec, prompt} │
42
42
  │ 2. 把 prompt 字段当本轮根指令 │
43
43
  │ 3. 干活(按 prompt 指令): │
@@ -82,7 +82,7 @@
82
82
  硬性约束:
83
83
  - 严禁超过本轮剩余时间预算(remainingSec < 30 时立刻停手、写总结、不开新轮)
84
84
  - 严禁自己改 deadline;想缩短就 `timegoal clear` 再 `timegoal set`
85
- - 每轮开始时先 `nx-kv timegoal check --cwd "$PWD" --summary "<本轮现状>" --progress "<完成度/下一步>" --json`,
85
+ - 每轮开始时先 `nx-kv timegoal check --cwd "$PWD" --summary "<本轮现状>" --json`,
86
86
  把返回里的 `prompt` 字段当作本轮根指令;**不要从对话历史里重新拼**——以 store 为准
87
87
  - 写代码必须随附测试;测试失败的修补不计入本轮成果
88
88
  ```
@@ -100,24 +100,24 @@ nx-kv timegoal set --cwd "$PWD" --duration 10800 \
100
100
  --prompt "..." --json
101
101
 
102
102
  # 2. 立刻 check:reached:false
103
- nx-kv timegoal check --cwd "$PWD" --summary "刚起步" --progress "刚 set 完" --json
103
+ nx-kv timegoal check --cwd "$PWD" --summary "刚起步" --json
104
104
 
105
105
  # 3. sleep 6s
106
106
  sleep 6
107
107
 
108
108
  # 4. 再 check:注意 elapsedSec 增加
109
- nx-kv timegoal check --cwd "$PWD" --summary "跑了一轮" --progress "继续" --json
109
+ nx-kv timegoal check --cwd "$PWD" --summary "跑了一轮" --json
110
110
 
111
111
  # 5. update:只换 prompt,deadline 不动
112
112
  nx-kv timegoal update --cwd "$PWD" --prompt "V2 改得更简洁" --json
113
113
 
114
114
  # 6. check:prompt 已是 V2,deadline 仍是 1 小时后
115
- nx-kv timegoal check --cwd "$PWD" --summary "改完 prompt" --progress "继续" --json
115
+ nx-kv timegoal check --cwd "$PWD" --summary "改完 prompt" --json
116
116
 
117
117
  # 7. 等到点后:reached:true
118
118
  # 到点后目标立即失效,但保留期内 show/check 仍查得到 —— 最后一轮照样能读到 prompt
119
119
 
120
- # 8. 回看每轮日志(现状 / 完成度 / 剩余)
120
+ # 8. 回看每轮日志(现状 / 剩余)
121
121
  nx-kv timegoal log --cwd "$PWD" --json
122
122
 
123
123
  # 9. clear
@@ -131,7 +131,7 @@ nx-kv timegoal clear --cwd "$PWD" --json
131
131
  | 现象 | 原因 / 做法 |
132
132
  | --------------------------------------- | ---------------------------------------------------------------------------- |
133
133
  | `reached` 没翻 | 检查客户端时区或 set 时是否给了 `--duration` 过短(默认下限 60s) |
134
- | check 报"缺少参数 --summary" | 每次 check 都要写一条日志,必须带 `--summary` 与 `--progress` |
134
+ | check 报"缺少参数 --summary" | 每次 check 都要写一条日志,必须带 `--summary` |
135
135
  | `reached` 翻 true 但 list 里看不到目标 | 到点即失效(活动列表只留未到点的);保留期内 `show`/`check` 仍查得到,`list --json` 看 `archived` |
136
136
  | update 报"已经到点失效" | 目标已失效不可复活;要继续请用 `set` 开新一局(起点从现在重算) |
137
137
  | update 失败"主题「X」尚未设置 timegoal" | 先 `set` 再 `update`;`update` 不创建 |
@@ -45,7 +45,7 @@ nx-kv timegoal set --cwd "$PWD" \
45
45
 
46
46
  ```
47
47
  每轮开始:
48
- nx-kv timegoal check --cwd "$PWD" --summary "<当前现状>" --progress "<完成度/下一步>" --json
48
+ nx-kv timegoal check --cwd "$PWD" --summary "<当前现状>" --json
49
49
  → { remainingSec, prompt, ... }
50
50
  → 把 prompt 字段当作本轮根指令(不要从对话历史里重新拼)
51
51
 
@@ -108,14 +108,14 @@ nx-kv timegoal set --cwd "$PWD" \
108
108
  nx-kv timegoal set --cwd <dir> --duration <5h|10800> --prompt "<...>" # 设/换(新起点)
109
109
  nx-kv timegoal update --cwd <dir> --prompt "<新版>" [--duration <5h|秒>] # 改提示词/时长(保起点)
110
110
  nx-kv timegoal show --cwd <dir> # 仅查(不算时间)
111
- nx-kv timegoal check --cwd <dir> --summary "<现状>" --progress "<完成度/下一步>" # 算时间 + 回显 prompt + 写一条日志
111
+ nx-kv timegoal check --cwd <dir> --summary "<现状>" # 算时间 + 回显 prompt + 写一条日志
112
112
  nx-kv timegoal clear --cwd <dir> # 清空
113
113
  nx-kv timegoal list # 所有有 timegoal 的目录(到点的单列在归档区)
114
- nx-kv timegoal log --cwd <dir> # 回看每轮 check 的记录(现状/完成度/剩余)
114
+ nx-kv timegoal log --cwd <dir> # 回看每轮 check 的记录(现状/剩余)
115
115
  ```
116
116
 
117
- > `check` **必须**带 `--summary` 与 `--progress`:每次检查都会往该目录的 timegoal
118
- > 日志里追加一条(现状 + 完成度 + 剩余时间)。缺参数会直接报
117
+ > `check` **必须**带 `--summary`:每次检查都会往该目录的 timegoal
118
+ > 日志里追加一条(现状 + 剩余时间)。缺参数会直接报
119
119
  > `缺少参数 --summary`——这是刻意设计的:没有现状的日志等于没记。
120
120
  > 日志只保留**最近 200 条**,长跑任务不会把 store 撑爆。
121
121
 
@@ -154,7 +154,7 @@ nx-kv timegoal log --cwd <dir> # 回看每
154
154
  - **两种 timegoal**:目录级(`--cwd`,与目录一对一)与**任务级**(`--task
155
155
  task:<topicKey>:<taskId>`,发布时 `localtask add --duration 2h` 随任务携带,
156
156
  **领取即计时**)。任务级的 goal key 会随任务交付的 instruction 一起给你,
157
- 直接照抄执行即可;`timegoal check --task <key> --summary … --progress …` 记日志,
157
+ 直接照抄执行即可;`timegoal check --task <key> --summary …` 记日志,
158
158
  未到点 `localtask done` 会拒绝标记完成。
159
159
  - 不阻塞任何东西:可以同时跑人机接力、派任务给别的 agent、外部 cron
160
160
  - 不需要登录 KV 后端:纯本机
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx-kv",
3
- "version": "0.45.1",
3
+ "version": "0.46.0",
4
4
  "description": "nx-kv — KV 清单管理中枢(远程)+ 本机本地任务队列(localtask):serve 驱动 CLI 与 Web 面板,同源同构,附带可安装 skill 供 agent 提交 / 领取 / 阻塞接收任务",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,8 +51,7 @@ export const lifecycleActions = [
51
51
  '领取任务:有任务立即领(含任务级 timegoal 的 check 指令);没任务默认立即返回 timeout,项目开启「持续 get」后自动唤起阻塞窗口等人回填',
52
52
  flags: {
53
53
  cwd: CWD,
54
- // #171:现状参数已取消——**保留 flag 只为不打断旧调用**(传了也不生效)
55
- summary: { type: 'string', hint: '已废弃:当前现状不再收(面板上没有对应输入界面)' },
54
+ // #171/#92:现状参数彻底删除——get 就是单纯的领取语义,不收任何现状
56
55
  timeout: { type: 'number', hint: '阻塞上限(秒);仅项目开启「持续 get」时有意义' },
57
56
  'no-open': { type: 'boolean', hint: '不自动打开浏览器(测试用)' },
58
57
  param: { type: 'array', hint: '外部参数(平面扩展):k=v,可重复或逗号分隔;进交付模板 ctx,模板里 {{k}} / {{params.k}} 取' },
@@ -163,8 +162,7 @@ export const lifecycleActions = [
163
162
  cwd: CWD,
164
163
  key: KEY,
165
164
  summary: { type: 'string', required: true, hint: '完成总结(记为本轮终态 + timegoal 日志)' },
166
- // #171:进度参数已取消——保留 flag 只为不打断旧调用(传了也不生效)
167
- progress: { type: 'string', hint: '已废弃:完成度/下一步不再收(面板上没有对应输入界面)' },
165
+ // #92:进度参数彻底删除——done 只携带 summary
168
166
  },
169
167
  run: (ctx) =>
170
168
  service.completeTask({ id: ctx.id, cwd: ctx.cwd, key: ctx.key, summary: ctx.summary }),
@@ -186,7 +184,7 @@ export const lifecycleActions = [
186
184
  id: 'localtask.timegoalLog',
187
185
  cli: ['localtask', 'timegoal-log'],
188
186
  http: ['GET', '/api/localtasks/timegoal-log'],
189
- summary: '查看任务级时间目标的每轮 check 记录(时间、已用/剩余、是否到点、当轮总结与进度)',
187
+ summary: '查看任务级时间目标的每轮 check 记录(时间、已用/剩余、是否到点、当轮总结)',
190
188
  flags: { id: { type: 'number', required: true, hint: '任务编号' }, cwd: CWD, key: KEY },
191
189
  run: async (ctx) => {
192
190
  const topicKey = ctx.key || service.normalizeCwd(ctx.cwd).key;
@@ -202,7 +200,6 @@ export const lifecycleActions = [
202
200
  ` R${i + 1} ${e.checkedAt} 已用 ${e.elapsedSec}s · 剩余 ${e.remainingSec}s${e.reached ? ' · 已到点' : ''}`,
203
201
  );
204
202
  if (e.summary) lines.push(` ${e.summary}`);
205
- if (e.progress) lines.push(` 进度: ${e.progress}`);
206
203
  });
207
204
  return lines.join('\n');
208
205
  },
@@ -9,9 +9,9 @@
9
9
  // 归档的目标仍可被 show/check 查到(agent 最后一轮要拿到 reached:true + prompt
10
10
  // 原文才能收尾);超过保留期的「自动失效」才是真删(连 goal_checks 级联)。
11
11
  //
12
- // goal_checks.summary 一列装两条内容:存 JSON `{summary, progress}` ——
13
- // schema 没给 progress 单独的列(§12.2 审计裁决),而交付文本要它;统一 JSON
14
- // 编码避免「分隔符被用户撞上」的歧义。人读稍差,机器解析零歧义。
12
+ // goal_checks.summary 一列一条内容:当轮总结(纯文本)。
13
+ // 旧库可能存过 JSON `{summary, progress}` 编码(progress 已废)——读取侧做
14
+ // 兼容解析(见 timegoal-task-store.getTaskGoalLog),新写入一律纯文本。
15
15
  import { db, txw } from './open.js';
16
16
  import { nowMs } from '../../../core/db/time.js';
17
17
 
@@ -109,7 +109,7 @@ export function purgeGoal(conn, goalId) {
109
109
  }
110
110
 
111
111
  /** 追加一条 check 流水(只增不改)。@returns {{id: number}} */
112
- export function appendCheck(conn, { goalId, atMs, elapsedSec, remainingSec, overtimeSec, reached, summary, progress }) {
112
+ export function appendCheck(conn, { goalId, atMs, elapsedSec, remainingSec, overtimeSec, reached, summary }) {
113
113
  const r = conn.run(
114
114
  `INSERT INTO goal_checks (goal_id, at, elapsed_sec, remaining_sec, overtime_sec, reached, summary)
115
115
  VALUES (:g, :at, :elapsed, :remaining, :overtime, :reached, :summary)`,
@@ -120,8 +120,7 @@ export function appendCheck(conn, { goalId, atMs, elapsedSec, remainingSec, over
120
120
  remaining: Number(remainingSec) || 0,
121
121
  overtime: Number(overtimeSec) || 0,
122
122
  reached: reached ? 1 : 0,
123
- // progress 没有独立的列(schema §12.2)→ 与 summary 合一,统一 JSON 编码
124
- summary: JSON.stringify({ summary: String(summary || ''), progress: String(progress || '') }),
123
+ summary: String(summary || ''),
125
124
  }
126
125
  );
127
126
  return { id: Number(r.lastInsertRowid) };
@@ -365,8 +365,8 @@ export async function completeTask({ cwd: rawCwd, key: rawKey, id, summary: rawS
365
365
  };
366
366
  }
367
367
  if (st.hasGoal) {
368
- // #171:done 不再收 --progress(面板上没有对应输入界面)——日志只留完成总结
369
- const rec = await recordTaskCheck({ topicKey: key, taskId: want, summary, progress: '完成' });
368
+ // #92:done 只携带 summary——日志最终一条 = 完成总结(progress 是伪概念)
369
+ const rec = await recordTaskCheck({ topicKey: key, taskId: want, summary });
370
370
  goal = { recorded: rec.recorded, reached: true, checkedAt: rec.checkedAt };
371
371
  } else {
372
372
  // goal 已被保留期清理(任务拖了 7 天以上才标完成)→ 放行 + 说明:
@@ -73,7 +73,6 @@ function renderCheck(d) {
73
73
  ` 状态:${status}`,
74
74
  ` 截止:${d.deadline}(now=${d.now})`,
75
75
  ` 现状:${d.summary}`,
76
- ` 完成度 / 下一步:${d.progress}`,
77
76
  ` 日志:本目录已记录 ${d.logCount} 次检查(${d.checkedAt})`,
78
77
  ` 本轮提示词(${d.promptRendered ? '实时渲染' : 'store 原文'}):`,
79
78
  prompt,
@@ -183,18 +182,17 @@ export default {
183
182
  cli: ['timegoal', 'check'],
184
183
  http: ['GET', '/api/timegoals/check'],
185
184
  summary:
186
- '时间运算 + 原文回显 prompt + 写入一次状态日志;每次必须提供当前现状 --summary 与完成度/下一步 --progress',
185
+ '时间运算 + 原文回显 prompt + 写入一次状态日志;每次必须提供当前现状 --summary',
187
186
  flags: {
188
187
  cwd: { type: 'string', hint: '工作目录(与 --task 二选一)' },
189
188
  task: { type: 'string', hint: '任务级 goal key(task:<topicKey>:<taskId>;带时长任务领取时自带)' },
190
189
  summary: { type: 'string', required: true, hint: '当前现状(每次 check 记录到日志,≤2000 字)' },
191
- progress: { type: 'string', required: true, hint: '完成度/本轮成果/下一步(写入日志,≤2000 字)' },
192
190
  },
193
191
  run: (ctx) => {
194
192
  if (!ctx.cwd && !ctx.task) throw badInput('请给 --cwd <工作目录> 或 --task <任务goal key>');
195
193
  return ctx.task
196
- ? service.checkGoalByKey(ctx.task, { summary: ctx.summary, progress: ctx.progress })
197
- : service.checkTimegoal({ cwd: ctx.cwd, summary: ctx.summary, progress: ctx.progress });
194
+ ? service.checkGoalByKey(ctx.task, { summary: ctx.summary })
195
+ : service.checkTimegoal({ cwd: ctx.cwd, summary: ctx.summary });
198
196
  },
199
197
  render: renderCheck,
200
198
  },
@@ -219,7 +217,7 @@ export default {
219
217
  id: 'timegoal.log',
220
218
  cli: ['timegoal', 'log'],
221
219
  http: ['GET', '/api/timegoals/log'],
222
- summary: '查看本目录 timegoal 的检查日志(每轮 check 的现状 + 完成度)',
220
+ summary: '查看本目录 timegoal 的检查日志(每轮 check 的现状)',
223
221
  flags: { cwd: CWD },
224
222
  run: (ctx) => service.getTimegoalLog({ cwd: ctx.cwd }),
225
223
  render: (d) => {
@@ -232,7 +230,6 @@ export default {
232
230
  for (const e of d.entries) {
233
231
  lines.push(` ${e.checkedAt} ${e.reached ? '已到点' : `剩 ${fmtDur(e.remainingSec)}`}`);
234
232
  lines.push(` 现状:${e.summary}`);
235
- lines.push(` 下一步:${e.progress}`);
236
233
  }
237
234
  return lines.join('\n');
238
235
  },
@@ -15,12 +15,12 @@
15
15
  // {{goal.startedAt}} {{goal.deadline}} {{goal.remainingHuman}} {{goal.remainingSec}}
16
16
  // {{goal.elapsedHuman}} {{goal.elapsedSec}} {{goal.overtimeSec}} {{goal.reached}}
17
17
  // {{goal.extra}}
18
- // {{check.summary}} {{check.progress}} {{check.at}} {{check.count}}(仅 check 渲染时)
18
+ // {{check.summary}} {{check.at}} {{check.count}}(仅 check 渲染时)
19
19
  import { formatDuration, renderInstruction } from '../../../core/instruction-template.js';
20
20
 
21
21
  export const TASK_GOAL_PROMPT_TEMPLATE = [
22
22
  '本任务带时间目标(领取即计时,持续 {{goal.durationHuman}})。',
23
- '- 每轮推进先执行:nx-kv timegoal check --task {{goal.goalKey}} --summary "<本轮现状>" --progress "<进展/下一步>"',
23
+ '- 每轮推进先执行:nx-kv timegoal check --task {{goal.goalKey}} --summary "<本轮现状>"',
24
24
  '- 时间未到不得标记完成——应派出 sub agent 重新提出新的需求,再继续推进。',
25
25
  '- check 返回 reached:true 后才允许:nx-kv localtask done --id {{task.id}} --summary "<完成总结>"',
26
26
  '{{#if goal.extra}}',
@@ -9,7 +9,7 @@
9
9
  // → 任务记录带 timegoal 声明 { duration, prompt }(时长人类写法,领取时才解析)
10
10
  // 2. 领取:交付时刻(buildTaskDelivery)调 ensureTaskGoal → **领取即起表**
11
11
  // (起点 = consumedAt),并把 check 指令作为 goal.prompt 固化
12
- // 3. 推进:agent 每轮 `timegoal check --task <goalKey> --summary --progress`
12
+ // 3. 推进:agent 每轮 `timegoal check --task <goalKey> --summary`
13
13
  // 4. 完成:`localtask done --id ...` —— **未到时间拒绝标记完成**,提示派
14
14
  // sub agent 重新提出新的需求;到点自动记录最终 check
15
15
  //
@@ -229,7 +229,7 @@ export async function showTimegoal({ cwd: rawCwd } = {}) {
229
229
  * check 的共同实现(队列级):写一条流水 + 组装返回。
230
230
  * 日志先成功落库,再返回——「这轮 check 发生过」有据可查。
231
231
  */
232
- function applyCwdCheck(conn, blob, key, name, cwd, summary, progress) {
232
+ function applyCwdCheck(conn, blob, key, name, cwd, summary) {
233
233
  const at = nowMs();
234
234
  if (!blob) {
235
235
  return {
@@ -240,7 +240,6 @@ function applyCwdCheck(conn, blob, key, name, cwd, summary, progress) {
240
240
  overtimeSec: 0,
241
241
  prompt: '',
242
242
  summary,
243
- progress,
244
243
  key,
245
244
  name,
246
245
  cwd,
@@ -262,7 +261,6 @@ function applyCwdCheck(conn, blob, key, name, cwd, summary, progress) {
262
261
  overtimeSec: result.overtimeSec,
263
262
  reached: result.reached,
264
263
  summary,
265
- progress,
266
264
  });
267
265
  blob.totalChecks = (Number(blob.totalChecks) || blob.checks.length - 1) + 1;
268
266
  writeCwdGoal(conn, blob, at);
@@ -271,7 +269,6 @@ function applyCwdCheck(conn, blob, key, name, cwd, summary, progress) {
271
269
  ...result,
272
270
  prompt: goal.prompt, // 永远原文回显,绝不拼接/裁剪
273
271
  summary,
274
- progress,
275
272
  checkedAt: stampOf(at),
276
273
  startedAt: goal.startedAt,
277
274
  deadline: goal.deadline,
@@ -288,18 +285,17 @@ function applyCwdCheck(conn, blob, key, name, cwd, summary, progress) {
288
285
 
289
286
  /**
290
287
  * 时间运算 + 回显原 prompt,并追加一条状态日志。
291
- * - 每次有效 check 都要求调用方提供 `summary`(当前现状)与 `progress`
292
- * (完成度/下一步),空值、缺值、超长都拒绝,保证日志有用且可比较。
288
+ * - 每次有效 check 都要求调用方提供 `summary`(当前现状),空值、缺值、超长都
289
+ * 拒绝,保证日志有用且可比较。
293
290
  * - 有 goal:日志先成功落库,再返回 reached/time/prompt 和本次日志记录。
294
- * - 无 goal:仍需要提交 summary/progress,但不写日志(没有目标就不该有 goal 日志)。
291
+ * - 无 goal:仍需要提交 summary,但不写日志(没有目标就不该有 goal 日志)。
295
292
  * `prompt` 永远从库原文回显 —— 不让 agent 在长对话里漂移。
296
293
  */
297
- export async function checkTimegoal({ cwd: rawCwd, summary: rawSummary, progress: rawProgress } = {}) {
294
+ export async function checkTimegoal({ cwd: rawCwd, summary: rawSummary } = {}) {
298
295
  if (rawCwd === undefined || rawCwd === null || !String(rawCwd).trim()) {
299
296
  throw badInput('需要 --cwd "<工作目录>"');
300
297
  }
301
298
  const summary = normalizeLogField(rawSummary, 'summary', 2000);
302
- const progress = normalizeLogField(rawProgress, 'progress', 2000);
303
299
  const { key, name, cwd } = normalizeCwd(rawCwd);
304
300
  // ⚠️ check 是**写路径**(每轮都要写一条流水),"自动失效"(超过保留期 → 整条删掉)
305
301
  // 在这里顺便落库。读路径(show / list / 面板的 /api/timegoals/all)刻意不写:
@@ -307,12 +303,12 @@ export async function checkTimegoal({ cwd: rawCwd, summary: rawSummary, progress
307
303
  recycleAllCwdGoals({ persist: true });
308
304
  return withCwdGoalDb((conn) => {
309
305
  const blob = readCwdGoal(conn, key);
310
- return applyCwdCheck(conn, blob, key, name, cwd, summary, progress);
306
+ return applyCwdCheck(conn, blob, key, name, cwd, summary);
311
307
  });
312
308
  }
313
309
 
314
310
  /**
315
- * 读本目录 timegoal 的检查日志(每次 check 追加一条:现状 + 完成度)。
311
+ * 读本目录 timegoal 的检查日志(每次 check 追加一条:当轮现状)。
316
312
  * 这是 timegoal 的"历史"——回看每轮干了什么、剩多少时间。
317
313
  */
318
314
  export async function getTimegoalLog({ cwd: rawCwd } = {}) {
@@ -334,6 +330,7 @@ export async function getTimegoalLog({ cwd: rawCwd } = {}) {
334
330
  overtimeSec: Number(e.overtimeSec) || 0,
335
331
  reached: !!e.reached,
336
332
  summary: String(e.summary || ''),
333
+ // 历史 blob 可能带 progress 字段——参数已废不再写入,历史行原样透出
337
334
  progress: String(e.progress || ''),
338
335
  })),
339
336
  key,
@@ -4,7 +4,7 @@
4
4
  // 见 localtask/repo/goals.js)。任务级 goal 与**单条任务**一对一;
5
5
  // 起点 = **领取时刻**(localtask 领取路径调 startTaskGoal 时传入 consumedAt)。
6
6
  //
7
- // goal_checks 行的 progress 与 summary 合存在同一列(JSON 编码,见 goals.js)。
7
+ // goal_checks 行的 summary 存当轮总结(纯文本;旧库 JSON 编码在读取侧兼容,见 goals.js)。
8
8
  import { badInput } from '../../../core/errors.js';
9
9
  import { tx } from '../../../core/db/index.js';
10
10
  import { db as ltDb } from '../../localtask/repo/open.js';
@@ -151,11 +151,10 @@ export async function showGoalByKey(rawKey) {
151
151
  }
152
152
 
153
153
  /** 任务维度的最终 check(完成动作自动记录一条日志——「结束必须 check」的记录器语义)。 */
154
- export async function checkGoalByKey(rawKey, { summary: rawSummary, progress: rawProgress } = {}) {
154
+ export async function checkGoalByKey(rawKey, { summary: rawSummary } = {}) {
155
155
  const key = String(rawKey || '').trim();
156
156
  if (!key) throw badInput('请给 --cwd <工作目录> 或 --task <任务goal key>');
157
157
  const summary = normalizeLogField(rawSummary, 'summary', 2000);
158
- const progress = normalizeLogField(rawProgress, 'progress', 2000);
159
158
  const parsed = parseTaskGoalKey(key);
160
159
  if (!parsed) throw badInput('goal key 不合法(应为 task:<topicKey>:<seq>): ' + key);
161
160
  return tx(
@@ -170,21 +169,20 @@ export async function checkGoalByKey(rawKey, { summary: rawSummary, progress: ra
170
169
  overtimeSec: 0,
171
170
  prompt: '',
172
171
  summary,
173
- progress,
174
172
  key,
175
173
  name: key,
176
174
  cwd: '',
177
175
  now: stampNow(new Date(nowMs())),
178
176
  };
179
177
  }
180
- return applyGoalCheck(conn, row, parsed, summary, progress);
178
+ return applyGoalCheck(conn, row, parsed, summary);
181
179
  },
182
180
  { db: ltDb(), mode: 'IMMEDIATE' }
183
181
  );
184
182
  }
185
183
 
186
184
  /** 任务级 check 的共同实现:写一条 goal_checks 流水 + 组装返回。 */
187
- function applyGoalCheck(conn, row, parsed, summary, progress) {
185
+ function applyGoalCheck(conn, row, parsed, summary) {
188
186
  const at = nowMs();
189
187
  const goal = goalRowToGoal(row);
190
188
  const result = evalTimegoal(goal, at);
@@ -202,7 +200,6 @@ function applyGoalCheck(conn, row, parsed, summary, progress) {
202
200
  overtimeSec: result.overtimeSec,
203
201
  reached: result.reached,
204
202
  summary,
205
- progress,
206
203
  });
207
204
  const totalChecks = goalsRepo.countChecks(Number(row.id), conn);
208
205
  // 每轮 check 同源渲染(任务 #87):读任务**当下**的原文与附加要求,
@@ -232,7 +229,7 @@ function applyGoalCheck(conn, row, parsed, summary, progress) {
232
229
  startedAt: row.started_at,
233
230
  deadline: row.deadline,
234
231
  nowMs: at,
235
- check: { summary, progress, at: checkedAt, count: totalChecks },
232
+ check: { summary, at: checkedAt, count: totalChecks },
236
233
  });
237
234
  const promptTemplate = String(row.prompt || '');
238
235
  return {
@@ -242,7 +239,6 @@ function applyGoalCheck(conn, row, parsed, summary, progress) {
242
239
  task: { id: taskSeq, text: String((taskRow && taskRow.body) || '') },
243
240
  goal: ctx.goal,
244
241
  summary,
245
- progress,
246
242
  checkedAt,
247
243
  startedAt: goal.startedAt,
248
244
  deadline: goal.deadline,
@@ -257,15 +253,14 @@ function applyGoalCheck(conn, row, parsed, summary, progress) {
257
253
  };
258
254
  }
259
255
 
260
- export async function recordTaskCheck({ topicKey, taskId: seq, summary, progress } = {}) {
256
+ export async function recordTaskCheck({ topicKey, taskId: seq, summary } = {}) {
261
257
  const sum = normalizeLogField(summary, 'summary', 2000);
262
- const prog = normalizeLogField(progress, 'progress', 2000);
263
258
  if (!topicKey || seq === undefined || seq === null) return { recorded: false, reason: 'no_goal' };
264
259
  return tx(
265
260
  (conn) => {
266
261
  const row = goalsRepo.getGoalRowByTaskKey(topicKey, seq, conn);
267
262
  if (!row) return { recorded: false, reason: 'no_goal' };
268
- const payload = applyGoalCheck(conn, row, { topicKey: String(topicKey), seq: Number(seq) }, sum, prog);
263
+ const payload = applyGoalCheck(conn, row, { topicKey: String(topicKey), seq: Number(seq) }, sum);
269
264
  return { recorded: true, reached: payload.reached, checkedAt: payload.checkedAt };
270
265
  },
271
266
  { db: ltDb(), mode: 'IMMEDIATE' }
@@ -303,6 +298,8 @@ export async function getTaskGoalLog({ topicKey, taskId: seq } = {}) {
303
298
  let progress = '';
304
299
  try {
305
300
  const v = JSON.parse(String(c.summary || '{}'));
301
+ // 旧库的 summary 列存过 JSON `{summary, progress}` 编码——progress 参数
302
+ // 已废(不再写入),但历史行原样读出,web check 标签仍可显示
306
303
  if (v && typeof v === 'object') {
307
304
  summary = String(v.summary || '');
308
305
  progress = String(v.progress || '');
@@ -173,7 +173,7 @@ export const DEFAULT_DONEGUARD_TEMPLATE = [
173
173
  '{{#if goal.blocked}}',
174
174
  '〔完成门禁 · 时间未到〕任务 #{{task.id}} 还不能 done:持续 {{goal.durationHuman}},已过 {{goal.elapsedHuman}}({{percent goal.elapsedSec goal.durationSec}}%),剩余 {{goal.remainingHuman}}。',
175
175
  '- 现在可做:{{#if (gte (percent goal.elapsedSec goal.durationSec) 67)}}收尾整理(收敛改动 / 补验证 / 写清遗留),或派 sub agent 提出新的需求继续推进{{else}}继续推进主线,并派 sub agent 重新提出新的需求{{/if}}。',
176
- '- 每轮推进先跑:nx-kv timegoal check --task {{goal.goalKey}} --summary "<本轮现状>" --progress "<进展/下一步>"',
176
+ '- 每轮推进先跑:nx-kv timegoal check --task {{goal.goalKey}} --summary "<本轮现状>"',
177
177
  '- 到点后再:nx-kv localtask done --id {{task.id}} --summary "<完成总结>"',
178
178
  '{{/if}}',
179
179
  ].join('\n');
@@ -1,4 +1,4 @@
1
- import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-CBqcR086.js";import{a as S,i as C}from"./upload-BIMbGcCB.js";import{r as ee}from"./md-parse-awNLHAzO.js";import{t as w}from"./route-crumb-PqhQSVWL.js";import{a as T,c as E,i as D,l as O,o as te,r as k,s as A,t as j,u as ne}from"./tool-bar-TIqYxsQl.js";var M=s(e(),1),N=u(),P=t(),F=`doc`,I=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function re({crumb:e=null,title:t,pathLabel:n=``,dirty:r=!1,writable:i=!1,onSave:a=null,onSaveLabel:o=`保存`,menuGroups:s=[],saving:c=!1,external:l=!1,afterTitle:u=null}){let d=D(),{layout:f,setLayout:p}=te(F),[m,h]=(0,M.useState)(!1),g={};for(let e of s||[])for(let t of e?.items||[])t&&t.id&&(g[t.id]=t);g.save=a&&{id:`save`,label:c?`保存中…`:o,run:a,primary:!0,disabled:c||!r};let _=e=>e===`more`||!!g[e],v=f.filter(e=>O(F,e)&&_(e.id)),y=f.filter(e=>A(F,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,P.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>k(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,P.jsx)(`button`,{type:`button`,className:t.primary||e===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!t.disabled,onClick:()=>b(e),children:t.label||E(F,e).label||e},e):null},S=I.map(e=>({...e,items:y.filter(t=>E(F,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!E(F,e.id).menuGroup);return i?(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,P.jsxs)(j,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,P.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,P.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||E(F,e.id).danger;return(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||E(F,e.id).label||e.id,t?.hint?(0,P.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||E(F,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||E(F,e.id).label||e.id},e.id)}),(0,P.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,N.createPortal)((0,P.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,P.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,P.jsx)(T,{kind:F,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsx)(`div`,{className:`docp-actions`,children:(0,P.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function L(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}function R(e){let t=String(e??``).replace(/^/,``).replace(/\r\n/g,`
1
+ import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-DErcpXhC.js";import{a as S,i as C}from"./upload-BIMbGcCB.js";import{r as ee}from"./md-parse-awNLHAzO.js";import{t as w}from"./route-crumb-C3Ce0rzR.js";import{a as T,c as E,i as D,l as O,o as te,r as k,s as A,t as j,u as ne}from"./tool-bar-BSIlsHln.js";var M=s(e(),1),N=u(),P=t(),F=`doc`,I=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function re({crumb:e=null,title:t,pathLabel:n=``,dirty:r=!1,writable:i=!1,onSave:a=null,onSaveLabel:o=`保存`,menuGroups:s=[],saving:c=!1,external:l=!1,afterTitle:u=null}){let d=D(),{layout:f,setLayout:p}=te(F),[m,h]=(0,M.useState)(!1),g={};for(let e of s||[])for(let t of e?.items||[])t&&t.id&&(g[t.id]=t);g.save=a&&{id:`save`,label:c?`保存中…`:o,run:a,primary:!0,disabled:c||!r};let _=e=>e===`more`||!!g[e],v=f.filter(e=>O(F,e)&&_(e.id)),y=f.filter(e=>A(F,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,P.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>k(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,P.jsx)(`button`,{type:`button`,className:t.primary||e===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!t.disabled,onClick:()=>b(e),children:t.label||E(F,e).label||e},e):null},S=I.map(e=>({...e,items:y.filter(t=>E(F,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!E(F,e.id).menuGroup);return i?(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,P.jsxs)(j,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,P.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,P.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||E(F,e.id).danger;return(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||E(F,e.id).label||e.id,t?.hint?(0,P.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||E(F,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||E(F,e.id).label||e.id},e.id)}),(0,P.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,N.createPortal)((0,P.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,P.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,P.jsx)(T,{kind:F,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,P.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,P.jsx)(`span`,{className:`grow`}),u,(0,P.jsx)(`div`,{className:`docp-actions`,children:(0,P.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function L(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}function R(e){let t=String(e??``).replace(/^/,``).replace(/\r\n/g,`
2
2
  `),n=t.match(/^---\n([\s\S]*?)\n---\n?/),r=n?t.slice(n[0].length):t;for(let e of r.split(`
3
3
  `)){let t=e.trim();if(t)return t}return``}function z(e){let t=R(e).match(/^#\s+(.+)$/);return t?t[1].trim():``}function ie(e,t){let n=String(e??``),r=String(t||``).trim()||`未命名文档`,i=n.replace(/\r\n/g,`
4
4
  `),a=i.match(/^---\n([\s\S]*?)\n---\n?/),o=a?i.slice(0,a[0].length):``,s=(a?i.slice(a[0].length):i).split(`
@@ -1 +1 @@
1
- import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{w as r}from"./workspace-C_5X2gIr.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-TIqYxsQl.js";var l=n(e(),1),u=r(),d=t();function f({kind:e,renderers:t={},actions:n={},titles:r={},disabled:f={},labels:p={},className:m=``}){let{layout:h,setLayout:g}=s(e),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),C=(0,l.useRef)(null),w=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!_)return;let e=e=>{C.current?.contains(e.target)||w.current?.contains(e.target)||v(!1)},t=e=>{e.key===`Escape`&&v(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_]);let T=h.filter(t=>o(e,t)),E=h.filter(t=>c(e,t)),D=t=>p[t]||a(e,t).label||t,O=(e,t={})=>(0,d.jsx)(`button`,{type:`button`,className:t.primary?`btn small primary`:`btn small ghost`,title:r[e]||D(e),disabled:!!f[e],onClick:()=>n[e]&&n[e](),children:D(e)},e),k=n=>n===`more`?(0,d.jsxs)(`button`,{ref:C,type:`button`,className:`btn small ghost`+(_?` is-open`:``),title:r.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":_,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();b({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),v(e=>!e)},children:[D(`more`),` ▾`]},`more`):t[n]?(0,d.jsx)(`span`,{className:`ta-slot`,children:t[n]({open:_})},n):O(n,{primary:a(e,n).section===`primary`});return(0,d.jsxs)(`div`,{className:`ta-bar`+(m?` ${m}`:``),children:[T.map(e=>k(e.id)),_&&y&&(0,u.createPortal)((0,d.jsxs)(`div`,{ref:w,className:`ta-more-menu`,role:`menu`,style:{top:y.top,right:y.right},children:[E.length===0&&(0,d.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),E.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!f[e.id],title:r[e.id]||D(e.id),onClick:()=>{v(!1),n[e.id]&&n[e.id]()},children:D(e.id)},e.id)),(0,d.jsx)(`div`,{className:`ta-more-sep`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{v(!1),S(!0)},children:`自定义工具栏…`})]}),document.body),x&&(0,u.createPortal)((0,d.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>S(!1),children:(0,d.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,d.jsx)(i,{kind:e,layout:h,setLayout:g,onClose:()=>S(!1)})})}),document.body)]})}export{f as t};
1
+ import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{w as r}from"./workspace-C_5X2gIr.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-BSIlsHln.js";var l=n(e(),1),u=r(),d=t();function f({kind:e,renderers:t={},actions:n={},titles:r={},disabled:f={},labels:p={},className:m=``}){let{layout:h,setLayout:g}=s(e),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),C=(0,l.useRef)(null),w=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!_)return;let e=e=>{C.current?.contains(e.target)||w.current?.contains(e.target)||v(!1)},t=e=>{e.key===`Escape`&&v(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_]);let T=h.filter(t=>o(e,t)),E=h.filter(t=>c(e,t)),D=t=>p[t]||a(e,t).label||t,O=(e,t={})=>(0,d.jsx)(`button`,{type:`button`,className:t.primary?`btn small primary`:`btn small ghost`,title:r[e]||D(e),disabled:!!f[e],onClick:()=>n[e]&&n[e](),children:D(e)},e),k=n=>n===`more`?(0,d.jsxs)(`button`,{ref:C,type:`button`,className:`btn small ghost`+(_?` is-open`:``),title:r.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":_,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();b({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),v(e=>!e)},children:[D(`more`),` ▾`]},`more`):t[n]?(0,d.jsx)(`span`,{className:`ta-slot`,children:t[n]({open:_})},n):O(n,{primary:a(e,n).section===`primary`});return(0,d.jsxs)(`div`,{className:`ta-bar`+(m?` ${m}`:``),children:[T.map(e=>k(e.id)),_&&y&&(0,u.createPortal)((0,d.jsxs)(`div`,{ref:w,className:`ta-more-menu`,role:`menu`,style:{top:y.top,right:y.right},children:[E.length===0&&(0,d.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),E.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!f[e.id],title:r[e.id]||D(e.id),onClick:()=>{v(!1),n[e.id]&&n[e.id]()},children:D(e.id)},e.id)),(0,d.jsx)(`div`,{className:`ta-more-sep`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{v(!1),S(!0)},children:`自定义工具栏…`})]}),document.body),x&&(0,u.createPortal)((0,d.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>S(!1),children:(0,d.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,d.jsx)(i,{kind:e,layout:h,setLayout:g,onClose:()=>S(!1)})})}),document.body)]})}export{f as t};