@linxin666/dsh-client-ui-task-board 0.1.16 → 0.1.18

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 (37) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +11 -7
  3. package/README.zh.md +11 -7
  4. package/lib/client.js +821 -145
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +1 -1
  7. package/lib/types/client/PluginSettingsCard.d.ts +11 -0
  8. package/lib/types/client/locales.d.ts +21 -0
  9. package/lib/types/client/schedule-presets.d.ts +10 -0
  10. package/lib/types/core/controller.d.ts +57 -1
  11. package/lib/types/core/execution.d.ts +65 -4
  12. package/lib/types/core/scheduler.d.ts +7 -0
  13. package/lib/types/core/store.d.ts +1 -1
  14. package/lib/types/core/tasks.d.ts +43 -0
  15. package/lib/types/core/use-cases/task-archive.d.ts +22 -0
  16. package/lib/types/core/use-cases/task-create.d.ts +1 -6
  17. package/lib/types/core/use-cases/task-update.d.ts +9 -4
  18. package/lib/types/index.d.ts +1 -1
  19. package/package.json +1 -1
  20. package/src/client/PluginSettingsCard.tsx +50 -47
  21. package/src/client/board/NewTaskModal.tsx +136 -3
  22. package/src/client/board/TaskBoard.tsx +48 -19
  23. package/src/client/board/TaskDetail.tsx +97 -8
  24. package/src/client/board.module.css +16 -0
  25. package/src/client/index.ts +71 -2
  26. package/src/client/locales.ts +42 -0
  27. package/src/client/schedule-presets.ts +13 -0
  28. package/src/client/settings-card.module.css +9 -0
  29. package/src/core/controller.ts +92 -2
  30. package/src/core/execution.ts +179 -12
  31. package/src/core/scheduler.ts +15 -0
  32. package/src/core/store.ts +16 -2
  33. package/src/core/tasks.ts +56 -0
  34. package/src/core/use-cases/task-archive.ts +48 -0
  35. package/src/core/use-cases/task-create.ts +12 -3
  36. package/src/core/use-cases/task-update.ts +34 -5
  37. package/src/index.ts +1 -1
package/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: bbbadebabdee529b7a0ea831519cf909a4716844
6
- README.zh.md: 64b6539d2a4505e3824657e62dcfb4dfab88704e
5
+ README.md: ed814f18cf9668624c70d26ef8190d378aaf62f1
6
+ README.zh.md: 54aa8959f94f196196e70107a3a18846f4a45dc5
package/README.md CHANGED
@@ -11,11 +11,12 @@ A hot-pluggable DeepSeek Harness (DSH) client GUI plugin: it adds a **task board
11
11
  ## Features
12
12
 
13
13
  - **Sidebar entry**: injects a "任务看板" (task board) entry row inside the sidebar column (`[data-pane="sidebar"]` on older shells, `[class*="sidebarCol"]` on the DSH 0.1.0-rc.6 AppFrame layout) below the new-session button (wide rail shows icon + text, collapsed rail shows a bare icon, adapting to DSH skin tokens).
14
- - **Multi-column board**: five columns — 待规划 (to plan) / 待办 (to do) / 进行中 (in progress) / 已完成 (done) / 已失败 (failed); cards show title, description, status, update time, and execution count; the top supports search filter, new task, and back to chat.
14
+ - **Multi-column board**: five columns — 待规划 (to plan) / 待办 (to do) / 进行中 (in progress) / 已完成 (done) / 已失败 (failed); cards show title, description, status, update time, and execution count; the top supports search filter, an archive view (done/failed tasks can be archived off the board and restored anytime, keeping execution history and session transcripts traceable), new task, and back to chat.
15
15
  - **Task details**: click a card to open details (title/description/execution prompt/execution log) — it does **not** execute on a single click; the details offer "执行 / 重新执行" (Run / Re-run), "删除" (Delete, with confirm), "查看会话" (View session, jumps to the execution transcript), and a manual move to 待规划/待办.
16
16
  - **Real execution**: on "执行" (Run), the plugin connects a workspace session through the client runtime (`workspaces.connectWorkspace`, reusing a blank session or letting the host create one), names the session after the task title, and drives a real agent via `session.prompt([{ type: 'text', text }], 'queue')`; it then subscribes to that session's snapshot and, once the round really finishes, sets the card to 已完成/已失败 and records the execution result. The execution session appears in the session list and can be opened to view the real transcript.
17
+ - **Per-task execution targets**: a task can pin where and how it runs — **workspace** (the execution session lands in that workspace), **mode** (the agent preset the session is composed from, switched through `agentPresets.select` while the session is still blank), and **permission** (a sandbox preset applied through the `/permission <id>` slash command: read-only / workspace-write / danger-full-access). Blank pins fall back to the runtime defaults (recent workspace / deployment preset / session default). A pin that cannot be applied fails the run **before** the prompt is sent, so a task never silently runs under settings it did not ask for.
17
18
  - **Status write-back**: card status (进行中 → 完成/失败) is driven by the real session state; after a page refresh/restart, leftover running tasks are auto-reconciled against the current session state (reconcile).
18
- - **Scheduled tasks**: the details panel can schedule a task — an enable switch + a 5-field cron expression (分 时 日 月 周, supporting `*` / `*/n` / `a-b` / comma lists) + common presets (daily 09:00, every hour, every 10 minutes, Mondays 09:00); enabling computes and persists the "下次运行时间" (next run time), and the card shows a scheduled marker; at the due time it automatically takes the same real-execution path (as manual run), and the execution session remains linkable.
19
+ - **Scheduled tasks**: the new-task dialog and the details panel can schedule a task — an enable switch + a 5-field cron expression (分 时 日 月 周, supporting `*` / `*/n` / `a-b` / comma lists) + common presets (daily 09:00, every hour, every 10 minutes, Mondays 09:00); enabling computes and persists the "下次运行时间" (next run time), and the card shows a scheduled marker; at the due time it automatically takes the same real-execution path (as manual run), and the execution session remains linkable.
19
20
  - **System-prompt injection**: the host half (`src/index.ts`) registers a `plugin:task-board` section (order 200) via `SystemPrompt.section`, declaring this plugin's existence, capabilities, and limits to every agent — it is injected when the plugin is in the composition (after mount + DSH restart) and disappears when removed (after unmount + restart), so an agent needs no external docs to know how to work with this board.
20
21
 
21
22
  ## Directory structure
@@ -45,8 +46,9 @@ scripts/dsh-task-board.js # one-click mount/unmount/sta
45
46
  - **The middle column cannot be replaced through a slot**: the `conversation` slot is single and already taken by ui-conversation. The board view mounts on the center column (`[data-pane="conversation"]` on older shells, `[class*="centerCol"]` on the DSH 0.1.0-rc.6 AppFrame layout) as a tail child node (outside React's ownership), toggled via the `<html data-dsh-taskboard-active>` attribute, keeping the chat subtree below mounted and stateful.
46
47
  - **Persistence uses browser localStorage**: client plugins run in the browser and DSH has no browser-writable file channel (matching skin-center's research on `cordis.patch.yml`); localStorage is also how DSH's own client snapshot store (`createSnapshotStore` persist) persists.
47
48
  - **Execution rides the client runtime**: `ctx.sessions.list` subscribes to session state (`running` / `byId`), `ctx.workspaces.connectWorkspace()` creates/reuses a session, `session.prompt()` drives a real agent, and `ctx.sessions.open()` jumps to the transcript.
49
+ - **Execution targets ride the same runtime faces**: the workspace pin passes the task's id to `workspaces.connectWorkspace()` (validated against the workspace list first, so a stale pin fails locally); the mode pin recomposes the blank execution session via `api.agentPresets.select` — only legal before the first turn, so it runs before `session.prompt`, and `sessions.noteAgentPreset` keeps the list label current; the permission pin admits a `/permission <id>` slash command through `session.command` — the same mechanism the shell's own permission picker uses. A rejected admission or a line no command claims fails the run before the prompt.
48
50
  - **Background settlement relies on list reconciliation**: an unopened session has no chat-snapshot window (cold), so settlement keys off the session list — every list change reconciles running tasks; result judgment takes, in order, "missing from list → cancelled / still running → wait / chat snapshot visible → by lastAgentError / tail of raw history → a turn-error node proves failure / otherwise success", and reconciliation is idempotent.
49
- - **Scheduled tasks run in the browser scheduler**: the plugin is pure-client (no server channel), so "run at the due time" is done by the in-tab scheduler — a tick every minute, with an immediate catch-up tick when the page returns from the background; before firing it first moves "next run" forward to the next cron match so the same tick never fires twice; it does not fire early in page load (before the session-list baseline is ready), avoiding mis-execution. Limitation: the tab must stay open (schedules missed while closed are "miss = skip", and only already-deferred due tasks are caught up on the next open); a task that is 进行中 (in progress) skips the current due time and waits for the next cron match.
51
+ - **Scheduled tasks run in the browser scheduler**: the plugin is pure-client (no server channel), so "run at the due time" is done by the in-tab scheduler — a tick every minute, with an immediate catch-up tick when the page returns from the background; before firing it first moves "next run" forward to the next cron match so the same tick never fires twice; it does not fire early in page load (before the session-list baseline is ready), avoiding mis-execution. Every tick first re-reads the persisted ledger, so a task deleted in another tab can never be fired from a stale in-memory copy. Limitation: the tab must stay open (schedules missed while closed are "miss = skip", and only already-deferred due tasks are caught up on the next open); a task that is 进行中 (in progress) skips the current due time and waits for the next cron match.
50
52
  - **Same-origin tabs share one ledger**: additions, edits, and deletions in any tab propagate to the others through storage events (`LocalStorageTaskStore.subscribeExternal`), so a task deleted in one tab can never keep firing from another tab's stale in-memory copy — nor be written back by that copy's later persistence (schedule roll-forward, execution settlement).
51
53
 
52
54
  ## Install
@@ -115,10 +117,11 @@ The rows registered in the profile manifest:
115
117
 
116
118
  1. `npm run build` → `node scripts/dsh-task-board.js mount` → refresh `http://127.0.0.1:3080`.
117
119
  2. A "任务看板" (task board) entry row appears below "新会话" in the sidebar; click it → the middle column switches to the five-column board.
118
- 3. "+ 新建任务" (New task) with title/description/Prompt → the card appears in 待办 (to do).
119
- 4. Click the card → details show content and Prompt; click "执行" (Run) → the card becomes 进行中 (in progress) (a session named after the task title appears in the session list); after the agent finishes the card lands in 已完成 (done) or 已失败 (failed), the detail execution log has a result and time, and "查看会话" (View session) jumps to the real transcript.
120
- 5. Scheduled task: details → tick "定时运行" (Scheduled run) to enable, pick the preset "每 10 分钟" (every 10 minutes, cron `*/10 * * * *`); a scheduled marker appears on the card; wait for the next whole 10-minute mark, watch the card automatically enter 进行中 (in progress) and eventually complete, with "上次触发" (last trigger) showing a time and a new execution-log row (the session is linkable).
121
- 6. Refresh the page / restart DSH → tasks remain; unmount the plugin → the GUI restores to its original state.
120
+ 3. "+ 新建任务" (New task) with title/description/Prompt → the card appears in 待办 (to do). The dialog also offers 工作区/模式/权限 (workspace / mode / permission) pins — leave them blank for runtime defaults.
121
+ 4. Pin a workspace/mode/permission on a task (in the dialog or the task detail) → run it → the execution session appears under the pinned workspace, its list row shows the pinned preset, and the session's permission selector shows the pinned permission.
122
+ 5. Click the card → details show content and Prompt; click "执行" (Run) → the card becomes 进行中 (in progress) (a session named after the task title appears in the session list); after the agent finishes the card lands in 已完成 (done) or 已失败 (failed), the detail execution log has a result and time, and "查看会话" (View session) jumps to the real transcript.
123
+ 6. Scheduled task: details → tick "定时运行" (Scheduled run) to enable, pick the preset "每 10 分钟" (every 10 minutes, cron `*/10 * * * *`); a scheduled marker appears on the card; wait for the next whole 10-minute mark, watch the card automatically enter 进行中 (in progress) and eventually complete, with "上次触发" (last trigger) showing a time and a new execution-log row (the session is linkable).
124
+ 7. Refresh the page / restart DSH → tasks remain; unmount the plugin → the GUI restores to its original state.
122
125
 
123
126
  ## Acceptance checklist
124
127
 
@@ -128,5 +131,6 @@ The rows registered in the profile manifest:
128
131
  - Execution really starts a session (its transcript is visible in the session list); card status follows the real execution progress; the details can jump to the execution session
129
132
  - Delete has a confirm step, and the local store is synced-removed after deletion
130
133
  - Scheduled tasks: cron config/preset/validation, next-run time, auto real execution at the due time, status write-back, scheduled card marker, scheduling resumes after refresh (browser-side scheduling, the tab must stay open)
134
+ - Per-task execution targets: workspace/mode/permission pins persist across refresh, drive the execution session, and an un-appliable pin (missing workspace, locked preset, unknown permission command) fails the run with the reason visible in the execution log
131
135
  - One-click mount/unmount; after unmount the GUI restores and other managed segments are unaffected
132
136
  - README + automated tests covering storage read/write, state transitions, execution trigger, cron parsing, and the scheduler
package/README.zh.md CHANGED
@@ -11,11 +11,12 @@
11
11
  ## 功能
12
12
 
13
13
  - **侧边栏入口**:侧边栏列(旧版 `[data-pane="sidebar"]`,DSH 0.1.0-rc.6 AppFrame 布局为 `[class*="sidebarCol"]`)内、新会话按钮下方注入「任务看板」入口行(宽栏显示图标+文字,折叠 rail 显示纯图标,随 DSH 皮肤 token 自适应)。
14
- - **多列看板**:待规划 / 待办 / 进行中 / 已完成 / 已失败 五列;卡片显示标题、描述、状态、更新时间、执行次数;顶部支持搜索过滤、新建任务、返回对话。
14
+ - **多列看板**:待规划 / 待办 / 进行中 / 已完成 / 已失败 五列;卡片显示标题、描述、状态、更新时间、执行次数;顶部支持搜索过滤、归档视图(已完成/已失败任务可归档,归档后移出看板,可随时恢复,执行记录与会话 transcript 保留可追溯)、新建任务、返回对话。
15
15
  - **任务详情**:点卡片打开详情(标题/描述/执行 Prompt/执行记录),**不会**一点就执行;详情内提供「执行 / 重新执行」「删除(带确认)」「查看会话(跳转到执行 transcript)」以及手动移到待规划/待办。
16
16
  - **真实执行**:点「执行」后,插件通过客户端 runtime 连接工作区会话(`workspaces.connectWorkspace`,空白会话复用或 host 新建),把任务标题设为会话名,以任务 Prompt 调用 `session.prompt([{ type: 'text', text }], 'queue')` 驱动真实 agent;随后订阅该会话快照,轮次真实结束后把卡片置为 已完成/已失败 并记录执行结果。执行会话会出现在会话列表,可点进对话查看真实 transcript。
17
+ - **任务级执行目标**:任务可钉住「在哪跑、怎么跑」——**工作区**(执行会话落在指定工作区)、**模式**(会话以指定 agent 预设组合,趁会话仍为空白时走 `agentPresets.select` 切换)、**权限**(经 `/permission <id>` 斜杠命令应用的沙箱预设:read-only / workspace-write / danger-full-access)。留空即回退运行时默认(最近工作区 / 部署预设 / 会话默认)。钉不住的目标会在发 Prompt **之前**失败,任务绝不会悄悄按没要求过的设置运行。
17
18
  - **状态回写**:卡片状态(进行中 → 完成/失败)由真实会话状态驱动;刷新页面/重启后,遗留的 running 任务会按会话现状自动对账(reconcile)。
18
- - **定时任务**:详情面板可为任务配置定时执行——启用开关 + 5 段 cron 表达式(分 时 日 月 周,支持 `*` / `*/n` / `a-b` / 逗号列表)+ 常用预设(每天 09:00、每小时、每 10 分钟、每周一 09:00);启用即计算并持久化「下次运行时间」,卡片显示定时标识;到点自动走真实执行链路(同手动执行),执行会话照常可跳转。
19
+ - **定时任务**:新建任务与详情面板均可配置定时执行——启用开关 + 5 段 cron 表达式(分 时 日 月 周,支持 `*` / `*/n` / `a-b` / 逗号列表)+ 常用预设(每天 09:00、每小时、每 10 分钟、每周一 09:00);启用即计算并持久化「下次运行时间」,卡片显示定时标识;到点自动走真实执行链路(同手动执行),执行会话照常可跳转。
19
20
  - **系统提示词注入**:host 半边(`src/index.ts`)通过 `SystemPrompt.section` 注册 `plugin:task-board` 段(order 200),向每个 agent 声明本插件存在、能力与限制——插件在组合中(mount 后重启 DSH)即注入,移出组合(unmount 后重启)即消失,agent 无需任何外部文档就能知道如何与本看板协作。
20
21
 
21
22
  ## 目录结构
@@ -45,8 +46,9 @@ scripts/dsh-task-board.js # 一键挂载/卸载/状态
45
46
  - **中间列无法通过槽位替换**:`conversation` 槽位是 single 且已被 ui-conversation 占用。看板视图以 DOM 方式挂在中间列(旧版 `[data-pane="conversation"]`,DSH 0.1.0-rc.6 AppFrame 布局为 `[class*="centerCol"]`;挂载选择器两者都保留)内(React 不管的尾部子节点),通过 `<html data-dsh-taskboard-active>` 属性切换显隐,底下的对话子树保持挂载有状态。
46
47
  - **持久化用浏览器 localStorage**:客户端插件跑在浏览器里,DSH 没有浏览器可写的文件通道(与 skin-center 对 `cordis.patch.yml` 的调研结论一致);localStorage 也是 DSH 客户端自身快照存储(`createSnapshotStore` persist)的持久化方式。
47
48
  - **执行走客户端 runtime**:`ctx.sessions.list` 订阅会话状态(`running` / `byId`),`ctx.workspaces.connectWorkspace()` 创建/复用会话,`session.prompt()` 真实驱动 agent,`ctx.sessions.open()` 跳转 transcript。
49
+ - **执行目标走同样的 runtime 脸**:工作区钉子把任务指定的 id 传给 `workspaces.connectWorkspace()`(先对照工作区列表校验,失效的钉子就地失败);模式钉子通过 `api.agentPresets.select` 重组仍为空白状态的执行会话——只有首轮之前合法,所以排在 `session.prompt` 之前执行,`sessions.noteAgentPreset` 让会话列表标签即时更新;权限钉子经 `session.command` 提交 `/permission <id>` 斜杠命令——与壳自带权限选择器同一机制。提交被拒或没有命令认领该行时,在发 Prompt 前失败。
48
50
  - **后台结算靠列表对账**:未打开的会话没有对话快照窗口(cold),所以执行结算以会话列表为准——每次列表变化都对账 running 任务;结果判定依次取「列表缺失→已取消 / 仍在跑→等待 / 对话快照可见→按 lastAgentError / 原始历史尾部→turn-error 节点证明失败 / 否则按成功」,对账幂等。
49
- - **定时任务在浏览器端调度**:插件是纯客户端(无服务端通道),所以「到点执行」由标签页内的调度器完成——每分钟 tick 一次,页面从后台恢复可见时立即补 tick;到点触发前先把「下次运行」顺延到下一个 cron 匹配点再执行,同一 tick 不会重复触发;页面加载早期(会话列表基线未就绪)不触发,避免误执行。限制:需要标签页保持打开(关闭期间错过的调度按「错过即跳过」处理,下次打开时只补跑已顺延的到期任务);任务处于「进行中」时到点跳过本次,等下一个 cron 匹配点。
51
+ - **定时任务在浏览器端调度**:插件是纯客户端(无服务端通道),所以「到点执行」由标签页内的调度器完成——每分钟 tick 一次,页面从后台恢复可见时立即补 tick;到点触发前先把「下次运行」顺延到下一个 cron 匹配点再执行,同一 tick 不会重复触发;页面加载早期(会话列表基线未就绪)不触发,避免误执行;每次 tick 先重读持久化账本,在别的标签页删除的任务绝不会从陈旧内存副本被触发。限制:需要标签页保持打开(关闭期间错过的调度按「错过即跳过」处理,下次打开时只补跑已顺延的到期任务);任务处于「进行中」时到点跳过本次,等下一个 cron 匹配点。
50
52
  - **多标签页同源共享同一份台账**:任一标签页的增删改通过 storage 事件同步到其他标签页(`LocalStorageTaskStore.subscribeExternal`),删除的任务不会在其他标签页的内存副本里残留触发,也不会被其他标签页的后续持久化写回复活。
51
53
 
52
54
  ## 安装
@@ -115,10 +117,11 @@ profile 清单中注册的行:
115
117
 
116
118
  1. `npm run build` → `node scripts/dsh-task-board.js mount` → 刷新 `http://127.0.0.1:3080`。
117
119
  2. 侧边栏「新会话」下方出现「任务看板」入口行;点击 → 中间列切换为五列看板。
118
- 3. 「+ 新建任务」填标题/描述/Prompt → 卡片出现在「待办」。
119
- 4. 点卡片 → 详情可见内容与 Prompt;点「执行」→ 卡片变「进行中」(会话列表出现以任务标题命名的会话);agent 跑完后卡片落「已完成」或「已失败」,详情执行记录有结果与时间,可「查看会话」跳转到真实 transcript。
120
- 5. 定时任务:详情 →「定时运行」勾选启用,选预设「每 10 分钟」(cron `*/10 * * * *`),卡片出现定时标识;等待下一个整 10 分钟点,观察卡片自动进入「进行中」并最终完成,详情「上次触发」出现时间、执行记录新增一条(会话可跳转)。
121
- 6. 刷新页面/重启 DSH → 任务仍在;卸载插件 → GUI 恢复原状。
120
+ 3. 「+ 新建任务」填标题/描述/Prompt → 卡片出现在「待办」;对话框同时提供 工作区/模式/权限 三项钉子,留空即运行时默认。
121
+ 4. 在对话框或详情里给任务钉上工作区/模式/权限 → 执行 → 执行会话落在指定工作区下,列表行显示指定预设,会话的权限选择器显示指定权限。
122
+ 5. 点卡片 → 详情可见内容与 Prompt;点「执行」→ 卡片变「进行中」(会话列表出现以任务标题命名的会话);agent 跑完后卡片落「已完成」或「已失败」,详情执行记录有结果与时间,可「查看会话」跳转到真实 transcript。
123
+ 6. 定时任务:详情 →「定时运行」勾选启用,选预设「每 10 分钟」(cron `*/10 * * * *`),卡片出现定时标识;等待下一个整 10 分钟点,观察卡片自动进入「进行中」并最终完成,详情「上次触发」出现时间、执行记录新增一条(会话可跳转)。
124
+ 7. 刷新页面/重启 DSH → 任务仍在;卸载插件 → GUI 恢复原状。
122
125
 
123
126
  ## 验收对照
124
127
 
@@ -128,5 +131,6 @@ profile 清单中注册的行:
128
131
  - 执行真实启动会话(会话列表可见 transcript);卡片状态随真实执行进度变化;详情可跳转到执行会话
129
132
  - 删除有确认环节,删除后本地存储同步移除
130
133
  - 定时任务:cron 配置/预设/校验、下次运行时间、到点自动真实执行、状态回写、定时卡片标识、刷新后调度恢复(浏览器端调度,标签页需保持打开)
134
+ - 任务级执行目标:工作区/模式/权限 钉子刷新后仍在,驱动执行会话;钉不住的钉子(工作区缺失、预设被锁、权限命令无人认领)在发 Prompt 前失败,执行记录可见原因
131
135
  - 一键挂载/卸载;卸载后 GUI 恢复原状,其它 managed 段不受影响
132
136
  - README + 覆盖存储读写/状态流转/执行触发/cron 解析/调度器的自动化测试