给 DSH agent 的项目记忆:历史相似编辑作为先例出现、越界修改被 scope 锁拦下、认知跨会话持续积累(47 次上游验收修复、去 gold 化 20/20)。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:scd13150/dsh-cognition
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
DSNLE gives your DeepSeek Harness agent a memory of your project.
New tasks start with what you already did: edits from similar past tasks surface as precedents, out-of-scope edits get blocked, and knowledge keeps accumulating across sessions — enforced by DSH's native mechanisms (per-tool gates, kernel-level version guards, the skills knowledge layer, session event sourcing), not by prompt tricks.
Honest status: a research prototype with a working implementation — 47 real-repo fixes verified by upstream test suites, a gold-free 20-task continuous run (20/20), 245 deterministic regression assertions — and openly documented boundaries (docs/research/).
Quick start(3 steps)
Requires: Node.js ≥ 22 + a running DeepSeek Harness.
git clone https://github.com/scd13150/dsh-cognition.git && cd dsnle
node install-dsnle.mjs --set-default # creates the dsnle preset and makes it DSH's default (backs up your config)
Then restart DSH (or open a new session) — the new session should show:
nle_suggest/nle_focus/nle_mutate/nle_select/nle_guard… in your toolsnle-learned-*andnle-reflectionsin your skill catalog
Verify: run nle_check (no args) in the new session — ok: true means installed.
Other install modes / uninstall / troubleshooting
- Keep your global default untouched: omit
--set-default, then set the default preset in DSH settings (agent-presets → default), or pickdsnleper session - Inject into an existing preset:
node install-dsnle.mjs --into <preset-id>(backs up agent.cordis.yml) - Dry-run any command with
--dry-run - Uninstall: delete
~/.dsh/.agent-presets/dsnle/(+ restoresettings.yaml.bak-*if you changed the default); injected mode: restoreagent.cordis.yml.bak-* - No tools in a new session? The session must use the dsnle preset (check settings); running sessions never pick up new presets — always open a fresh session
怎么工作
每个任务走一条可审计的 ritual 链(强制,乱序改码会被 deny):
nle_suggest(定位检索)→ nle_focus(锁 scope)→ [nle_impact(高影响声明)]→ 编辑
→ [nle_reorient(证据推翻 scope)]→ nle_select(对账收尾)→ nle_guard(总闸)
| 层 | 机制 | DSH 原生落点 |
|---|---|---|
| 约束 | 强制链 + scope 锁 + shell 绕行防护 + 版本守卫 | tools/pre-execute 瀑布、fs/edit-intent 内核版本守卫 |
| 观测 | 内容哈希 cell + CON 码(CON200/404/405/422)+ 真相对账 | tools/result 冻结结果、fs 意图观测 |
| 记忆 | learned(关键词→文件,置信度/衰减/跨项目提升)+ precedent(历史会话先例)+ git 共改/churn/rollback | skills provider、sessionQuery 会话检索 |
| 可靠 | 契约门(声明 vs 真相)、guard 总闸、状态防篡改、反射观测 | 事件溯源日志、tokenMeter 成本报告 |
完整工具说明:调用 nle_suggest 等工具的 schema 即自带描述;机制规格见
docs/research/DSH_NLE_SPEC.md。
语义通道(可选)
语义检索(embedding 重排)是可选增强,不启用时自动降级为 BM25 + 符号/先例/共改检索,主链路不受影响。
启用:运行独立 helper 进程(transformers.js 首次运行自动下载模型,~90MB,缓存于 HF 缓存目录):
node nle-semantic/server.mjs --spool <工作区>/.nle-semantic
- 模型:Xenova/all-MiniLM-L6-v2(quantized),384 维,不随本仓库分发,由 transformers.js 自动下载或从 HF 缓存复用
- 离线环境:预先在有网机器跑一次
node nle-semantic/server.mjs --selfcheck生成缓存再迁移;或干脆不用语义通道 - 自检:
node nle-semantic/server.mjs --selfcheck→{"ok":true,"dim":384}
For DSH plugin developers: this repo also ships
docs/DSH_DEV_EXPERIENCE.md — battle-tested deep-dive notes
(dynamic-plugin sandbox traps, fs five-arg contract, preset generations, sessionQuery
deployment differences, tool-pipeline events) distilled from building DSNLE on dsh.
For DSH 插件开发者:仓库另附 docs/DSH_DEV_EXPERIENCE.md
——从零到 85KB 持久插件的全部踩坑提炼(动态插件沙箱陷阱、fs 五参契约、preset 代际语义、
sessionQuery 部署差异、工具管线事件),与 NLE 本体无关,可独立阅读。
已知边界(诚实声明)
- "长期"是初步证据:连续 20 卡(单仓库单日)累积曲线有实证;跨仓库、跨月、有害累积无数据——这正是开源想从真实使用中获得的
- 中文任务对英文代码库召回弱(learned/alias 兜底)
- 语义通道依赖独立 helper 进程;FTS 全文检索若部署禁用(
openAt: "never"),precedent 走字面扫描降级 - 插件注册为 agent-plane 工具,不提供安全隔离;作用域锁是 workflow 约束而非权限边界
研究附录(docs/research/)
| 文档 | 内容 |
|---|---|
| DSNLE_JOURNEY.md | 全程历程与版本链 |
| P7_REFACTOR.md | 模块化重构 + P7 三机制 + 实验后修复 |
| P6_DATA.md / P7_DATA.md | 40 卡实验逐卡数据(含去 gold 化 20 卡) |
| AUDIT_ADJUDICATION.md | 四角度深度审计裁定(修了什么/裁定不修什么及理由) |
| NLE_DSH_FIT.md / DSH_NLE_SPEC.md | 机制规格与 DSH 契合论证 |
| NLE_VALUE_ASSESSMENT.md / REPLAY_REPORT.md / HANDOFF.md | 价值评估、轨迹重放、实验纪律 |
开发
nle-plugin/
nle-rules-core.mjs ← 仓库根(规则唯一源,插件经 import 引入)
dsnle-plugin.mjs ← [生成] 持久插件(preset 挂载入口,勿手改)
frag-apply-*.mjs ×4 ← apply 函数体碎片(改插件逻辑改这里)
build-dsnle.mjs ← 纯拼接构建器
nle-semantic/server.mjs ← 语义/git 信号 helper(可选)
install-dsnle.mjs ← 安装脚本(standalone / --into 两模式)
改代码 → node nle-plugin/build-dsnle.mjs → 重跑安装脚本(覆盖 preset 内副本)→ 新会话生效。
规则层回归:node smoke-test.mjs(无文件依赖纯函数断言)。
实验装置完整回归(fixture-gate 245 断言)依赖实验仓库,不在本仓库分发。
License
链接
同类插件
vectorize-io/hindsight#coding-agents★ 42988
Hindsight:会学习的 Agent 长期记忆系统,自动召回/保存、知识页、深度反思与按仓库隔离的记忆银行。
volcengine/OpenViking#examples/dsh-memory-plugin★ 38990
面向 DeepSeek Harness 的 OpenViking 记忆与上下文插件:pre-step 自动召回与画像注入、会话捕获、`viking://` URI 防护,以及对接 OpenViking 服务端的 recall/write 记忆工具。
agentscope-ai/ReMe#dsh★ 3534
将 DeepSeek Harness 接入 ReMe 本地优先、自进化的个人知识库:自动把已完成的主 Agent 对话沉淀为用户掌控的 Markdown 记忆,通过 reme_search 结合 BM25、可选向量检索和 wikilink 展开搜索对话与资料,并按日整理长期记忆。
zilliztech/memsearch#MemSearch★ 2682
供 DSH 与其他编程 Agent 共享的 Markdown 记忆,支持自动捕获、步骤前上下文注入、搜索召回,以及通过审阅面板实现 memory-to-skill 自进化。
vshulcz/deja-vu#extensions/dsh★ 1093
读取本机上其他三十三个编程智能体已经写下的会话文件——Claude Code、Codex、Cursor、VS Code Copilot Chat、opencode、OpenClaw、Hermes、Kimi、Cline、Zed 等,包括安装之前的历史:提供 deja_recall、deja_session、deja_blame、deja_fix、deja_how、deja_remember 六个工具与 /deja 命令,并可选地把召回结果加入运行时上下文。本地 BM25 索引,不用大模型,不用向量嵌入,不联网(dsh plugin --profile web add dsh-deja)。
adoresever/graph-memory★ 633
DeepSeek Harness 的可追溯、可检索跨会话记忆:把对话知识沉淀为带类型的图节点(任务/技能/事件)与关系边。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。