@240xu/dsh-message-ops 0.10.9 → 0.11.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/README.md +26 -11
- package/package.json +1 -1
- package/test/revert-contract.test.js +17 -5
package/README.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# @240xu/dsh-message-ops
|
|
2
2
|
|
|
3
|
-
DSH web 插件:**消息回滚 +
|
|
3
|
+
DSH web 插件:**消息回滚 + 单条删除 + 恢复**,并为官方 `session/fork` 提供消息级入口。
|
|
4
|
+
|
|
5
|
+
> 一句话:官方只能分支最后一条消息;本插件让你在任意消息上回滚、删除或分支,日志始终 append-only。
|
|
6
|
+
|
|
7
|
+
## 当前版本速查(0.11.1)
|
|
8
|
+
|
|
9
|
+
| 功能 | 入口 | 是否由本插件写会话日志 |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| 消息回滚 | Ops 面板 / 消息 hover / agent 工具 | 是(append-only surface replace) |
|
|
12
|
+
| 单条删除 | Ops 面板 / 消息 hover / agent 工具 | 是(append-only surface replace) |
|
|
13
|
+
| 恢复 | 输入框上方回撤贴条 / agent 工具 | 是(重放被遮蔽消息) |
|
|
14
|
+
| 分支 | Ops 面板 / 消息 hover | 否,调用官方 `session/fork` |
|
|
15
|
+
| 整会话删除 | 侧栏菜单 → 回收站 | 否,目录 rename 到回收站 |
|
|
16
|
+
| 整会话恢复/永久删除 | Ops 面板 → 回收站 | 否,目录 rename / unlink |
|
|
17
|
+
| Markdown 导出 | 不支持 | 请用官方 `/api/session.export` |
|
|
18
|
+
|
|
19
|
+
`message_ops` agent 工具提供四个动作:`list | revert | delete | restore`。
|
|
4
20
|
|
|
5
21
|
> **0.9.0 是破坏性变更**:移除了本插件的**分支**与 **Markdown 导出**。
|
|
6
22
|
> 两者 dsh 官方都已有(`session/fork` 与 `/api/session.export`),详见下方「为什么不重复造轮子」。
|
|
@@ -25,13 +41,13 @@ DSH web 插件:**消息回滚 + 删除 + 恢复**。只补 dsh 官方**没有*
|
|
|
25
41
|
|
|
26
42
|
## 用法
|
|
27
43
|
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
- **输入框上方的回撤贴条**:展开后可逐条 `Restore
|
|
32
|
-
-
|
|
44
|
+
- **右侧 Ops 面板**(默认入口):消息 / 回收站双 tab,支持全文搜索、角色过滤、含已回滚开关、单条详情。
|
|
45
|
+
- **会话头部**的 `Message ops` 按钮:打开同一面板。
|
|
46
|
+
- **助手/用户消息** hover:`Revert to here`、`Quote to composer`。
|
|
47
|
+
- **输入框上方的回撤贴条**:展开后可逐条 `Restore`(恢复入口)。
|
|
48
|
+
- **侧栏会话行菜单**:整会话移入回收站。
|
|
33
49
|
|
|
34
|
-
|
|
50
|
+
面板流程:**选一条消息 → 查看全文 → 回滚 / 仅删除此条 / 从此条分支(调用官方 fork)→ 破坏性操作需确认**。
|
|
35
51
|
|
|
36
52
|
## 安装
|
|
37
53
|
|
|
@@ -55,7 +71,7 @@ dsh plugin --profile web add file:C:/path/to/dsh-message-ops
|
|
|
55
71
|
- 回滚/删除不重写日志:通过一条承载 `surfaceOp: replace` 的 system 事件实现,
|
|
56
72
|
约束由 DSH 引擎 `assertProvenance` 校验,违规如实上报(HTTP 409)。
|
|
57
73
|
- 回滚/删除前必须勾选风险确认;运行中的会话一律拒绝(提示先停止)。
|
|
58
|
-
-
|
|
74
|
+
- 分支不再由本插件写磁盘:直接调用官方 `session/fork`,失败时提示先停止运行中的会话。
|
|
59
75
|
|
|
60
76
|
## 端点
|
|
61
77
|
|
|
@@ -64,8 +80,7 @@ dsh plugin --profile web add file:C:/path/to/dsh-message-ops
|
|
|
64
80
|
| GET | `/api/message-ops/messages?sessionId=<id>` | 消息级列表(磁盘真相 + 可见性标注 + running 状态) |
|
|
65
81
|
| POST | `/api/message-ops/revert` | `{sessionId, seq}` 回滚到该条(含) |
|
|
66
82
|
| POST | `/api/message-ops/delete` | `{sessionId, seq}` 仅遮蔽该条 |
|
|
67
|
-
|
|
|
68
|
-
| GET | `/api/message-ops/export?sessionId=<id>&seq=<可选>` | 导出 Markdown(seq ≤ 上界,缺省全部),附件下载 |
|
|
83
|
+
| GET | `/api/message-ops/text?sessionId=<id>&seq=<n>` | 单条消息全文(面板详情用) |
|
|
69
84
|
| POST | `/api/message-ops/restore` | `{sessionId, seq}` 回滚恢复:seq 为某次 revert/delete 标记事件的 seq |
|
|
70
85
|
|
|
71
86
|
## 0.2.4 UI GAP(ux-scout dsh-ui-spec G-M1)
|
|
@@ -131,7 +146,7 @@ dsh plugin --profile web add file:C:/path/to/dsh-message-ops
|
|
|
131
146
|
|
|
132
147
|
### Agent 工具 `message_ops`
|
|
133
148
|
|
|
134
|
-
|
|
149
|
+
模型侧可调用四操作:`action: list | revert | delete | restore`,参数
|
|
135
150
|
`sessionId`(必填)、`seq`、`upToSeq`。工具与 HTTP 路由共用同一套核心逻辑
|
|
136
151
|
(`src/ops-core.js`),行为与错误语义完全一致;失败以文本形式返回,不中断回合。
|
|
137
152
|
|
package/package.json
CHANGED
|
@@ -15,8 +15,20 @@ import { zstdCompressSync } from 'node:zlib'
|
|
|
15
15
|
import { createRequire } from 'node:module'
|
|
16
16
|
import { join, dirname } from 'node:path'
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// Optional local contract fixtures. CI does not ship sessionfix; these tests
|
|
19
|
+
// are skipped there rather than hard-failing on a machine-specific path.
|
|
20
|
+
const SEQ_IMPL = process.env.SESSIONFIX_SEQCORE ?? '/data/data/com.termux/files/home/dsh-plugins-src/sessionfix/lib/seqcore.js'
|
|
21
|
+
const GATE_IMPL = process.env.SESSIONFIX_V4GATE ?? '/data/data/com.termux/files/home/dsh-plugins-src/sessionfix/lib/v4gate.mjs'
|
|
22
|
+
let decodeFrames, parseRows, officialValidate
|
|
23
|
+
try {
|
|
24
|
+
({ decodeFrames, parseRows } = await import(SEQ_IMPL))
|
|
25
|
+
;({ officialValidate } = await import(GATE_IMPL))
|
|
26
|
+
} catch {
|
|
27
|
+
decodeFrames = parseRows = officialValidate = undefined
|
|
28
|
+
}
|
|
29
|
+
const contractSkip = process.env.SESSIONFIX_CONTRACT !== '1'
|
|
30
|
+
? 'optional sessionfix contract tests; set SESSIONFIX_CONTRACT=1 to run'
|
|
31
|
+
: (decodeFrames === undefined ? 'sessionfix contract fixtures not available' : false)
|
|
20
32
|
import {
|
|
21
33
|
planNoticeWindow, noticeWindowPreamble, noticeWindowPostamble,
|
|
22
34
|
buildMarkerEvent, buildRestoreNoticeEvent, buildReplayEvent, planRestore, restoreProgress,
|
|
@@ -39,7 +51,7 @@ function idleSessionBase() {
|
|
|
39
51
|
].map((e, i) => ({ ...e, seq: i, time: 1000 + i }))
|
|
40
52
|
}
|
|
41
53
|
|
|
42
|
-
test('契约:合成窗口承载的 revert marker 通过官方三层闸', () => {
|
|
54
|
+
test('契约:合成窗口承载的 revert marker 通过官方三层闸', { skip: contractSkip }, () => {
|
|
43
55
|
const base = idleSessionBase()
|
|
44
56
|
const win = planNoticeWindow(base)
|
|
45
57
|
assert.equal(win.synthetic, true, '空闲会话应规划合成窗口')
|
|
@@ -68,7 +80,7 @@ test('契约:合成窗口必须自带 reason(UI 层硬要求)', () => {
|
|
|
68
80
|
assert.equal(turnEnd.data.reason.kind, 'interrupted')
|
|
69
81
|
})
|
|
70
82
|
|
|
71
|
-
test('契约:缺 reason 的 turn/end 会被官方闸拦下(回归证明这条规则有效)', () => {
|
|
83
|
+
test('契约:缺 reason 的 turn/end 会被官方闸拦下(回归证明这条规则有效)', { skip: contractSkip }, () => {
|
|
72
84
|
const base = idleSessionBase()
|
|
73
85
|
const bad = [...base, { type: 'turn/start', seq: base.length, time: 6000, data: { turn: 2 } },
|
|
74
86
|
{ type: 'step/start', seq: base.length + 1, time: 6001, data: { turn: 2, step: 1 } },
|
|
@@ -80,7 +92,7 @@ test('契约:缺 reason 的 turn/end 会被官方闸拦下(回归证明这
|
|
|
80
92
|
assert.match(v.error, /reason/, `错误信息应指向 reason,实际:${v.error}`)
|
|
81
93
|
})
|
|
82
94
|
|
|
83
|
-
test('契约:完整 restore 链路(notice + 重放)通过官方三层闸', () => {
|
|
95
|
+
test('契约:完整 restore 链路(notice + 重放)通过官方三层闸', { skip: contractSkip }, () => {
|
|
84
96
|
const base = idleSessionBase()
|
|
85
97
|
let cursor = base.length, t = 5000
|
|
86
98
|
const win = planNoticeWindow(base)
|