dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
编码任务复盘记忆:每轮对话后用本地 LLM 蒸馏被否决方案/踩坑/工程约束,按 type:rejected_solution 写入 MemOS,编码任务时对这类记忆加权召回。
复刻 mneme 编码对话复盘蒸馏业务逻辑的 DSH(DeepSeek-Harness / Cordis)插件。 不引入 mneme 二进制、不创建独立数据库;所有记忆存储、向量检索、归档淘汰、记忆生命周期全部复用 MemOS 记忆底座。
解决 AI 编码任务重复踩坑、遗忘被否决实现方案、丢失项目工程约束的问题;支持论文消融实验(插件开启/关闭对照),可演进为生产可用组件。
| 版本 | 状态 | 能力 |
|---|---|---|
| v1 最小科研版 | 已实现 | 插件脚手架 + turn/end 蒸馏 + agent/pre-step 加权召回 + 标签写入 + 基础验证;允许短板:JSON 解析失败直接丢弃、无去重、无价值过滤、日志极简 |
| v2 健壮版 | 已实现(当前) | v1 全部能力 + LLM JSON 解析降级重试(≤1 次)、写入前相似度去重(dedupeThreshold 0.82)、低价值内容过滤、完整日志埋点、边界截断保护、单元测试 |
| 可选扩展 | 预留 | TencentDB-Agent-Memory 同步(sync_to_tencentdb),默认关闭;失败只打日志不阻塞主链路(MemOS 本地插件已内置 captureToTencentMemory 现成底座,扩展时直接复用) |
turn/end)一轮完整交互(用户输入 → DSH 调度 → Worker 执行 → 返回结果)结束后触发:
session.events 过滤本回合事件(用户消息、助手思考/回答、工具调用与结果、代码执行),组装完整对话上下文;max_distill_context 截断,避免蒸馏 Prompt 溢出;rejected_solution:被否决/废弃的实现方案pitfall:调试踩坑记录、报错、问题根因constraint:项目工程约束、架构约定、编码规范type:rejected_solution 调用 MemOS 接口写入记忆;agent/pre-step)Agent 每一轮大模型推理执行之前触发:
codingKeywords 可配);type:rejected_solution 标签的记忆按 boostFactor 提升权重,重排后注入提示词,再执行 LLM 推理;type:rejected_solution 记忆,防止编码记忆对其他业务造成噪声污染。autoRecovery:false、initLogging:false),与主 memos-local-memory 插件共用同一 home/config(同一 SQLite 库与向量文件),不抢占恢复任务与日志通道。dsh plugin --profile web install https://github.com/<your-github-name>/dsh-plugin-memos-code-retrospect
把仓库克隆/拷贝到 <profile>/plugins/dsh-plugin-memos-code-retrospect/,再按下方「注册到 DSH」配置 cordis.patch.yml。
web profile;@memtensor/memos-local-plugin),本插件所有记忆读写依赖其接口;distillModel);集成测试需要本地 ollama(qwen3:14b 或同类指令模型);<profile>/plugins/dsh-plugin-memos-code-retrospect/
├── package.json
├── dist\
│ └── index.js # v2 健壮版主实现
├── test\
│ ├── retrospect.test.mjs # 单元测试(14 用例)
│ └── integration.mjs # 集成测试(真实 MemOS + LLM,参数化)
└── README.md
插件通过 junction 复用 DSH 全局安装内的 @deepseek-ai/dsh-llm(profile node_modules 顶层可能未暴露该包):
$plugin = "<profile>\plugins\dsh-plugin-memos-code-retrospect"
$nm = "$plugin\node_modules\@deepseek-ai"
New-Item -ItemType Directory -Force -Path $nm | Out-Null
New-Item -ItemType Junction -Path "$nm\dsh-llm" -Target "<dsh-global>\node_modules\@deepseek-ai\dsh\node_modules\@deepseek-ai\dsh-llm" | Out-Null
schemastery 与 @memtensor/memos-local-plugin 通常由 profile node_modules 顶层解析;如缺失,同样以 junction 方式链接。
向 profile 的 cordis.patch.yml 追加:
- insert:
- id: dsh-plugin-memos-code-retrospect
name: './plugins/dsh-plugin-memos-code-retrospect/dist/index.js'
config:
enabled: true
profileId: default
recallEnabled: true
captureEnabled: true
boostFactor: 2
recallTopK: 6
contextMaxChars: 3000
maxDistillContextChars: 8192
distillMaxTokens: 2048
distillRetries: 1
dedupeEnabled: true
dedupeThreshold: 0.82
valueFilterEnabled: true
sync_to_tencentdb: false
然后重启 DSH:
Stop-Process -Name dsh -Force
dsh web --port 3080
启动后可通过 dsh --profile web --dump-config 确认插件进入组合树;运行日志中出现 [retrospect] 前缀即加载成功。
cd <plugin-dir>
npm test
# 或直接
node test/retrospect.test.mjs
预期输出:14 passed, 0 failed(覆盖:JSON 解析、价值过滤、编码任务识别、相似度、JSON 解析失败重试、去重命中跳过写入、编码失败蒸馏写入等链路)。
需要本地 ollama 与 qwen3:14b 模型,验证「蒸馏写入 → 下一轮加权召回注入」闭环:
cd <plugin-dir>
$env:MEMOS_IT_HOME = "$env:TEMP\memos-it-data" # 可选,默认仓库下 .it-data/
$env:OLLAMA_BASE = "http://127.0.0.1:11434" # 可选,默认同上
node test/integration.mjs
预期输出:4 passed, 0 failed。测试使用独立临时记忆库,不影响生产数据。
| 配置项 | 默认 | 说明 |
|---|---|---|
enabled | true | 插件总开关,一键启停(对照实验用) |
home | "" | MemOS 数据目录(空则用 resolveHome 默认值,与主插件一致) |
profileId | "default" | 记忆命名空间 profile |
recallEnabled | true | 读取链路(pre-step 加权检索)开关 |
recallTimeoutMs | 3000 | 检索 deadline |
recallTopK | 6 | 最终注入条数 |
boostFactor | 2 | type:rejected_solution 命中 score 倍率(enable_weight) |
contextMaxChars | 3000 | <retrospect_context> 最大长度 |
codingKeywords | 内置词表 | 编码任务识别关键词 |
captureEnabled | true | 写入链路(turn/end 蒸馏)开关 |
distillModel | "" | 蒸馏 LLM 模型(distill_llm),留空跟随会话路由 |
distillMaxTokens | 2048 | 蒸馏输出上限 |
distillTimeoutMs | 60000 | 蒸馏超时 |
distillMinChars | 300 | 本轮对话小于该长度跳过蒸馏 |
maxDistillContextChars | 8192 | 蒸馏最大上下文长度(max_distill_context),超长自动截断 |
distillRetries | 1 | JSON 解析失败重试次数(v2 降级策略) |
dedupeEnabled | true | 写入前去重开关(v2) |
dedupeThreshold | 0.82 | 相似度阈值,超过则视为重复跳过写入 |
valueFilterEnabled | true | 低价值内容过滤开关(v2) |
sync_to_tencentdb | false | TencentDB-Agent-Memory 可选同步(预留,默认关闭) |
构造多轮编码失败场景,验证「踩坑 → 蒸馏写入 → 下一轮召回生效」完整闭环:
[retrospect] distilled trace=...;tags: type:rejected_solution 应看到新 trace;injected rejected_solution recall,模型上下文包含 <retrospect_context>。distillMaxTokens >= 2048 或关闭 think;turn/end,本轮写入的记忆下一轮才可被召回(有意设计,非缺陷);type:rejected_solution 记忆,防止噪声污染(codingKeywords 可配);sync_to_tencentdb 为预留扩展,本次未实现;rejected_solution 标签权重。欢迎提交 Issue / PR。开发约定:
dist/index.js 后同步跑 node test/retrospect.test.mjs,保持 14/14 通过;test/integration.mjs 的闭环用例。MIT (内容由AI生成,仅供参考) (内容由AI生成,仅供参考)