dsh-progress-union 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 l3j3y3
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,150 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # dsh-progress-union
2
+
3
+ 进度结合原型:**board 槽位真相源 × 鲸程时间/ETA 引擎**,并向压缩类插件暴露只读的 **progressAnchor 三层锚点**。
4
+
5
+ 基于(fork,均 MIT):
6
+
7
+ - [l3j3y3/dsh-progress-board](https://github.com/l3j3y3/dsh-progress-board) —— 用户可编辑实时进度板(槽位、revision/diff/ack、staleness nudge)
8
+ - [uuhihj/task-progress-bar](https://github.com/uuhihj/task-progress-bar)(鲸程 dsh-progress-widget)—— 事件时间引擎(steps/elapsed/ETA 学习链)
9
+
10
+ ## 它解决什么
11
+
12
+ 长程任务被上下文压缩时最容易丢的是"我干到哪了"。本插件把这件事拆成两个正交数据面并统一出口:
13
+
14
+ - **语义面(board)**:任务槽位 `title/status/percent/current/next`,宿主 KV 持久化,用户面板可改,模型走 `progress_update` 增量补丁——板本体不在上下文里,天然免剪。
15
+ - **时间面(widget)**:turn/step 事件计数、已用时长、按"板完成度 > 官方 todo 完成度 > 本机学习分位 > 内置先验"四档推算的剩余时间。
16
+
17
+ ## 给压缩插件的锚点契约(只读)
18
+
19
+ 同一 builder、双平面出口:
20
+
21
+ - 同进程 service:`ctx.get('progressAnchor').get(sessionId, now?)` / `.list(now?)`
22
+ - HTTP:`GET /progress-union/anchor?sessionId=<id>[&now=<ms>]`(`now` 仅供复现/测试)
23
+ - UI 投影:`sessionProjections` key `progressAnchor`(多会话聚合,仅 revision 稳定字段;时间字段走上面两个平面)
24
+
25
+ Schema(version=1,字段名冻结):
26
+
27
+ ```json
28
+ {
29
+ "version": 1, "sessionId": "", "revision": 0, "updatedAt": 0,
30
+ "board": {
31
+ "enabled": true,
32
+ "summary": { "total": 0, "done": 0, "doing": 0, "todo": 0, "blocked": 0, "percent": 0 },
33
+ "inFlight": [ { "id": "", "title": "", "status": "doing", "percent": 0, "current": "", "next": "" } ],
34
+ "pendingUserChanges": 0
35
+ },
36
+ "time": {
37
+ "startedAt": 0, "elapsedSec": 0, "steps": 0, "etaMin": 0,
38
+ "etaBasis": "board|todo|local|prior|none", "etaP75Min": 0, "overMin": 0,
39
+ "staleMin": 0, "todoDone": 0, "todoTotal": 0
40
+ },
41
+ "userEdits": [ { "revision": 0, "at": 0, "kind": "add|edit|remove", "itemId": "", "title": "", "fields": [] } ],
42
+ "persistent": true,
43
+ "slotTrail": null
44
+ }
45
+ ```
46
+
47
+ 压缩时的四条消费规则:
48
+
49
+ 1. **保护区必嵌**:`board`(summary + inFlight)+ `time` 拼成 ~150–200 token 锚点写入压缩摘要;锚点由宿主状态现读重建,历史消息里的旧投影不累积、可整体剪除。
50
+ 2. **userEdits 是硬约束**:`pendingUserChanges > 0` 时,这些 diff 必须先折叠进摘要或确认已被 ack,**不得随正文剪除**(用户改动优先于模型计划)。已 ack 的旧 diff 完全可剪。
51
+ 3. **revision 对账可剪**:历史段中 `progress_update` 工具返回的 `revision < anchor.revision` ⇒ 该段状态已兑现于锚点,可安全剪;这为"净收益门槛"类算法提供了确定的被切量与恒定的重建成本。
52
+ 4. **staleMin / overMin 必须如实转述**:`staleMin > 0` → 摘要注明"真实进度已中断 N 分钟";`overMin > 0` → "已超预估"。压缩后模型不应把陈旧进行中状态误读为新节奏。
53
+
54
+ 同态保证:同 `(revision, steps, now)` 锚点逐字节相等(无时间戳漂移、无随机),可直接当指纹用。
55
+
56
+ ## 使用
57
+
58
+ - `/progress`(on)/ `/progress off`:语义与 board 原版一致——开过一次持续启用,收起侧栏不关闭。
59
+ - 面板:右侧栏「进度」tab(半开/全面展开/直接编辑);composer 上方迷你条含 `done/total · 预计剩 N min / 已超预估 / 中断`。
60
+ - 单协议收敛:板启用的会话不再注入鲸程的文件上报协议(`progress_update` 是唯一写通道);板关闭时文件上报层、`$DSH_HOME/dsh-progress/` 读取与 `/dsh-progress/status` 全部按鲸程原行为保留。
61
+ - ETA 学习样本沿用鲸程的 `$DSH_HOME/dsh-progress-stats.json`(≥20 条/桶即用本机分位),不迁移不损坏。
62
+
63
+ ## 观察者(辅助主工作模型)
64
+
65
+ 板上还有活干(enabled 且存在未完成项)时,每请求注入一个重建式观察块 `<progress-observer>`(不进历史累积):
66
+
67
+ ```
68
+ <progress-observer revision="7" synced="6 步前">
69
+ - [x] 接口改造(100%)
70
+ - [~] 补集成测试(40%) · 当前:写 observer 用例 · 下一步:跑全量
71
+ - [!] 发版 · 阻塞:等确认
72
+ [官方todo] 完成 1/3,未完:补集成测试、发版
73
+ 对比:官方 todo 完成 2/3 · 板完成 1/3(进度不一致,核对后修正一处)
74
+ 最近改动:…/src/observer.ts(Edit) · …/test/observer.test.mjs(Write)
75
+ 最近输出:「接口改造已完成,接下来补测试。」
76
+ 最近动作:Edit → Bash
77
+ ⚠ 进度已滞后(6 步前):先调用 progress_update 同步再继续;无变化就传 changes=[]。
78
+ </progress-observer>
79
+ ```
80
+
81
+ **事实进输入,判断不进输入**:
82
+
83
+ - 文件改动只取带 `file_path/path` 类参数的工具调用(同路径去重留最新、上限 4 条);作业型命令(Bash)不猜它改了哪个文件;
84
+ - 清单对比只做算术:官方 todo 完成数 ≠ 板完成数时出一行“进度不一致,核对后修正一处”,不映射“哪个文件对应哪个清单项”(那是模型自己的判断);
85
+ - 观察者自补的 current 在清单行里带 `(观察者补,待确认)`——事实刷新闻不等于状态已同步。
86
+
87
+ 两层"及时更新":
88
+
89
+ 1. **观察者自补(事实级)**:模型超过 `maxIdleSteps`(默认 6 步)或 `maxIdleMs`(默认 3 分钟)未写板,且最近 3 分钟内有工具调用——自动把 doing 项的 `current` 刷成 `自动同步:<工具名> · <参数摘要>`(`updatedBy=observer`)。**只动 current,不动 status/percent**(语义判断归模型)。
90
+ 2. **催办(语义级)**:同一滞后条件在观察块里升级为直接指令,模型下一次调用 `changes=[]` 确认即视为已同步(重置计时)。
91
+
92
+ 观察者自己的自动写入不抵消催办——`stepsSinceModel` 只在模型(或用户)写板时重置。空板/全完成/关板时观察块为空串,零 token 开销。
93
+
94
+ 配置(cordis.patch.yml 按实例覆盖):
95
+
96
+ ```yaml
97
+ observer:
98
+ enabled: true
99
+ maxIdleSteps: 6
100
+ maxIdleMs: 180000
101
+ autoSyncCurrent: true
102
+ autoSyncThrottleMs: 60000
103
+ maxItems: 12
104
+ maxOutputs: 2
105
+ maxTools: 3
106
+ ```
107
+
108
+ 另外 `progress_update` 的返回已补拉通道:`inFlight`(≤6 条 doing/blocked 明细)+ `time`(steps/elapsedSec/etaMin/etaBasis/staleMin)——模型本来就必调的确认调用现在同时就是"观察"。
109
+
110
+ ## 辅助 LLM(审查/监视进度)
111
+
112
+ 观察者默认是**规则版(零 LLM 费用)**。可选的辅助模型会把"清单 + 最近输出 + 最近动作 + 最近改动"交给一个小模型做审查,只让它校准 `current / next / percent`:
113
+
114
+ ```yaml
115
+ assistant:
116
+ mode: direct # '' 关(默认)| 'direct'
117
+ baseUrl: http://127.0.0.1:8000/v1
118
+ model: qwen2.5-3b # 小模型即可
119
+ apiKey: '' # 可选;快照只回布尔 hasApiKey
120
+ timeoutMs: 20000
121
+ minIntervalMs: 90000 # 两次审查的最小间隔
122
+ maxCallsPerTurn: 1 # 每回合至多一次
123
+ autoApply: true # false = 只记录建议不落地
124
+ ```
125
+
126
+ - **触发**:板有未完成项,且主模型滞后(`maxIdleSteps`/`maxIdleMs` 超阈值)——与催办/自补同一时机,不额外打扰;
127
+ - **硬约束**:只改 `current/next/percent`;不存在的 id 丢弃;**不增删任务、不改 title/status**;每回合配额 + 最小间隔双节流;失败静默(`assistantError` 入观察块,不阻断板与主流程);
128
+ - **产出**:落地项 `updatedBy=assistant`;审查结论一行进观察块:`助手审查:<note>`;
129
+ - **端点建议**:优先本地/局域网自建 OpenAI 兼容端点(Ollama、LM Studio、自建 llama.cpp、vLLM、SGLang、Strata、Ninfer 等),也就是面板首区块那条提示的含义;
130
+ - 面板侧边栏与全展开两个视图的**第一个内容块**都显示该通道状态(未启用/已启用 + 端点 + 频率),即本插件的"费用提示永远第一"落点。
131
+
132
+ **为什么不做 host 通道**:union 是纯宿主插件,没有取得宿主 chat 调用的公开面;`direct` 是唯一不靠内部 API 的可靠路径,也正好对应"本地小模型"的推荐用法。
133
+
134
+ ## 明确不做
135
+
136
+ - 不修改上游两仓库;不改 dsh-prime-memory / dsh-spirit / dsh-brief-sidebar / dsh-context-compression-improved 的任何代码。
137
+ - `slotTrail` 恒为 `null`:prime-memory 关闭槽位 → L1 记忆的"后置清理扇出"仅有定性方案(见 `docs/`),字段为未来集成预留。
138
+ - 不发 npm;原型验证消费方后再谈发布门禁。
139
+
140
+ ## docs/
141
+
142
+ - `docs/slot-models-comparison.md` —— 官方 todo / board 槽位 / prime-memory 激活槽位 / spirit 回忆卡 的对比与定性结论
143
+ - `docs/slot-trail-fanout.md` —— brief-sidebar 记忆槽位清理扇出的定性方案(A/B/C 三档与裁定)
144
+ - `docs/spirit-reference.md` —— spirit 情绪指向 / 流程注入 / 人设槽位的可借鉴处理法在本原型的落点
145
+
146
+ ## 开发与测试
147
+
148
+ ```bash
149
+ npm test # node --test test/*.test.mjs(41 用例,纯 mock ctx,无需宿主进程)
150
+ ```