Vai al contenuto principale
T

dsh-message-edit

twilightspirit/dsh-message-edit

在消息气泡上加修改按钮,通过 DSH surface replace 机制改写模型上下文,fork 继承、支持 markdown、可审计

Installazione

dsh plugin --profile web add github:twilightspirit/dsh-message-edit

README

dsh-message-edit

在消息气泡上提供「修改」按钮:编辑任意一条消息(用户消息 / 助手回复),通过 DSH 核心的 surface replace 机制真正改写模型可见上下文(append-only 日志保留审计),气泡文字同步显示新文本。

Add a "✏️ 修改" button to every message bubble: edit any message (user or assistant reply), rewrite the model-visible context through DSH's core surface-replace mechanism (append-only log keeps audit trail), and the bubble shows the new text in place.

awesome · DSH plugin

功能 / Features

  • 两种消息都可改:用户消息 + 助手回复的消息气泡上都有修改按钮
  • 正文直接替换:编辑后气泡里的文字直接变成新文本(不是额外卡片),格式化内容(粗体 / 表格 / 代码块 / 列表)以轻量 markdown 渲染保留
  • 上下文真正改写:通过 session.append(..., { surfaceOp: { op: "replace", ... } })——DSH 官方机制,模型后续看到的上下文是修改后的版本;append-only 日志保留原事件可审计
  • fork 继承:分支出新对话时,子会话自动继承已修改的上下文
  • 二次/多次修改:连续修改同一条消息也能正确工作(自动追踪 replace 链)
  • 线框风格图标:修改 / 复制按钮与官方 16px outline 图标风格一致

安装 / Install

dsh plugin --profile web add github:TwilightSpirit/dsh-message-edit

或手动将插件加入 ~/.dsh/profiles/web/package.json bundles 列表。

用法 / Usage

  1. 打开任意会话,在用户消息或助手回复的气泡上找到铅笔图标按钮
  2. 点击弹出编辑框,修改文本后点「保存修改」
  3. 气泡正文直接变成新文本;之后模型看到的上下文也是修改后的版本
  4. 已修改的消息按钮会变蓝(提示"已改"),可再次点击继续编辑

原理 / How it works

  • Host 侧:注册 /message-edit RPC 通道。replace 端点定位目标消息(按 messageIdseq),通过 session.append(type, data, { surfaceOp: { op: "replace", start, end }, sourceEventSeqs }) 追加替换事件,改写模型可见的 surface。
  • Client 侧
    • 助手消息:注册官方插槽 conversation.chat.assistant-actions
    • 用户消息:覆盖 keyed user / steering 渲染器
    • 编辑后新文本存 localStorage 覆盖层(dsh-msg-edit:{sessionId}:{seq}),渲染时优先显示新文本(本地覆盖 + host query 兜底,fork 子会话也能查到)
  • fork 继承:监听 session/created,若子会话(header.parentSession 存在)的 seed 前缀内包含被替换消息,重放对应的 replace 事件;幂等检查避免重复。

说明:修改的是"模型看到的上下文",日志文件里旧内容仍在(DSH 的 append-only 安全设计,无法物理抹除),但模型视角和气泡显示都是新文本。

配置 / Config

无额外配置项。插件开箱即用。

依赖 / Dependencies

{
  "@deepseek-ai/dsh-session": "^0.1.0-rc.7"
}

client 端依赖(已在 dsh.client.inject 声明): @deepseek-ai/dsh-client-ui-conversation@deepseek-ai/dsh-client-connection

License

MIT

Plugin correlati