nuwa-skill
alchaincyf
你想蒸馏的下一个员工,何必是同事。蒸馏任何人的思维方式——心智模型、决策启发式、表达DNA。Distill how anyone thinks.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Re-s/dsh-memory-s3
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
云端跨会话记忆插件 for DeepSeek Harness:结构化条目 + 向量检索,持久化于 S3 兼容对象存储(AWS S3 / MinIO / Cloudflare R2 / 阿里云 OSS)。
记忆不再困于单机——只要握着同一把桶钥匙,任何机器、任何部署、任何 DSH 实例都能共享与续写同一份记忆。记忆S3 欺骗的收束点是"记忆的位置":从本地文件系统,迁移到对象存储的永恒之海。
preference | project | decision | history | moment 五类条目(moment = 时刻/照片/纪念日,对应 Tulving 情景记忆),带 importance/tags/source/时间戳 + 可选四维字段:subject(主体)/ timeline(时间线归属)/ links(关联引用)/ locked(锁定保护)files/{id} 不可变对象(uuid 键 + If-None-Match 创建 + sha256 完整性),条目 JSON 只存附件元数据数组;本地文件经扩展名白名单 + 魔法字节嗅探 + 大小上限(20MB)三重校验;memory_s3_attach / memory_s3_get_file / memory_s3_detach 三工具links(引用即链接,Obsidian/Zettelkasten 心智)自动回填本地反链索引(lib/backlinks.mjs → backlinks.json,0600 持久化,替换语义);memory_s3_backlinks 查询「谁引用了该条目」(读路径无审批);被引用数(图中心性)是快照注入的排序信号→关联N;locked 条目跳过同 title 自动合并(防无意覆盖)dsh CLI,rc.6+),两种获取方式:npm install -g @deepseek-ai/dshnpx @deepseek-ai/dsh(与 dsh 完全等价,本文命令两种前缀可互换)从 GitHub 获取(推荐,pnpm 语法,dsh plugin add 透传)。以下以 npx @deepseek-ai/dsh 为例(无需全局安装);已全局安装 dsh 时,将 npx @deepseek-ai/dsh 替换为 dsh 即可:
# 方式一:HTTPS 直接安装
npx @deepseek-ai/dsh plugin --profile web add https://github.com/Re-s/dsh-memory-s3.git
# 方式二:指定分支(如 main)/ tag / commit
npx @deepseek-ai/dsh plugin --profile web add https://github.com/Re-s/dsh-memory-s3.git#main
# 方式三:SSH 方式(需配置 GitHub SSH key)
npx @deepseek-ai/dsh plugin --profile web add git@github.com:Re-s/dsh-memory-s3.git
本地开发(源码调试,link 方式):
git clone https://github.com/Re-s/dsh-memory-s3.git
npx @deepseek-ai/dsh plugin --profile web add "link:/path/to/dsh-memory-s3"
配置环境变量:
# S3 凭据(必需;进程内读取,不落盘,绝不进配置文档)
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_SESSION_TOKEN=... # 可选,临时凭据
# 向量召回嵌入(仅当 embedder.provider=openai-compatible 时用;provider=none 则不需要)
export OPENAI_API_KEY=... # 或按 embedder.apiKeyEnv 改名的变量
凭据只走环境变量;bucket / endpoint / region / prefix / writePolicy 等非敏感配置经 DSH 官方设置缝配置——配置与凭据严格分离。
0.2.x 形态下,这些字段是
Configschema 里带头.volatile()的活字段(详见 ARCHITECTURE.md §C):@deepseek-ai/dsh-settings自动为有活字段的 profile entry 生成设置卡片(describe()带回schema+applies: 'live'),HMR/loader/volatile-update负责把值写回 entry config 并热重载,改bucket/endpoint/writePolicy等活字段立即生效、不用重启。settings.yaml顶层memory-s3:段或cordis.patch.yml的 entry config 更新,经同一套update()/mutate()进入 entry config,不做二次解析。
本插件所有可编辑字段(enabled / bucket / prefix / endpoint / region / accessKeyEnv / secretKeyEnv / sessionTokenEnv / writePolicy / snapshotOrder / maxInjectedItems / importanceThreshold / embedder.* / cacheDir / auditRetentionDays / maxFileBytes / allowedFileTypes)都是活字段(Volatile)。配置经同一层 entry config 送达
apply(ctx, config),无需settings.installSection(0.2.0 世系已删)——宿主自动完成三层解析:schema 默认 → entry config(composition base)→ 用户设置段。未挂载 settings 服务的 profile 自动回退到 entry config alone(官方契约:无 provider 时插件不受影响)。
S3 凭据只从环境变量读取(
accessKeyEnv/secretKeyEnv,默认AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY),绝不落盘、绝不进设置文档。
装完还没配 bucket 时会怎样(0.2.2+):插件保持存活但待机,不注册任何工具/注入,启动日志给出一条告警:
[memory-s3] bucket not configured; plugin stands by (no tools/injection registered).
Set a bucket in the "memory-s3" settings section, then restart the profile.
profile 正常启动、GUI 正常打开,插件在设置的 Plugin list 只读清单里可见。填好 bucket 后重启生效(重启生效的字段:enabled、snapshotOrder、maxInjectedItems、importanceThreshold、maxFileBytes、allowedFileTypes 等非活操作数;live 的活字段如 bucket/endpoint/region/prefix/writePolicy 修改后热重载即生效)——配置请改 settings.yaml,本插件没有 GUI 表单入口,原因见下节。
0.2.1 及更早版本存在启动死锁:
bucket在 schema 层必填,而 cordis 加载器在apply()之前校验 entry config,未配置时直接抛$.bucket missing required value并使整个 profile 启动失败,连 GUI 都打不开,也就无从配置。若你卡在这个版本,临时解法是在 profile 的cordis.patch.yml里给- id: memory-s3补一个config.bucket占位值;建议直接升级到 0.2.2+。
Web 设置的 Plugins 分区有两个标签页,本插件只出现在前者:
| 标签页 | 由谁提供 | 本插件 |
|---|---|---|
| Plugin list(只读清单) | dsh-client-ui-settings-plugin-inventory |
✅ 可见 |
| Plugin configuration(可编辑表单) | dsh-client-ui-settings-plugins |
❌ 无入口 |
官方对 Plugin configuration 标签页的渲染规则是双账本交集:
The tab reads which settings namespaces the Host serves and dispatches one slot key per namespace, so what renders is the intersection of two ledgers: the namespaces a live Host plugin registered, and the cards registered under those keys. A served namespace no card claims renders nothing.
即:注册了 settings 命名空间只是必要条件,还需要一张认领该命名空间的「卡片」。而卡片必须由插件自带浏览器半侧,官方在 Known Limitations 中明确了门槛:
A card still needs a browser bundle — the browser half must be a
dsh.clientpackage built in the client module system's lazy-CJS factory format, and theclientBundlepreset that emits it lives inpackages/client/tsdown.client.tsrather than a published package, so a plugin outside this repository has to reproduce that build itself.
本插件是纯 Host 侧插件、不含浏览器 bundle,因此没有可视化表单。这不影响配置能力:本插件以 .volatile() 声明的 Config 字段(上文 §配置)经 dsh-settings 的 describe() 形成活字段卡片(applies: 'live'),用户设置段(settings.yaml 顶层 memory-s3:)进入 entry config 的方式不变,只是运行时由 loader/volatile-update 热重载新值。
另一条官方限制值得知道:命名空间的注册不会主动推送给前端——「the wire announces settings-document commits and connection resets, not registrations」,所以新注册的命名空间要等下一次设置文档提交或重连才会进入前端列表。
$DSH_HOME/settings.yaml在 settings.yaml 顶层写 memory-s3: 段(不是旧文档的 plugins.memory-s3 子段):
memory-s3:
enabled: true
bucket: my-memory-bucket
prefix: dsh-memory-s3 # ⚠️ 多设备共享时必须逐字一致,详见下节「prefix 必须跨设备一致」
endpoint: "" # 留空用 AWS;MinIO/R2 填 https://...
region: us-east-1
writePolicy: ask # ask | auto | off
snapshotOrder: -50 # systemPrompt 注入段顺序
maxInjectedItems: 5 # 快照注入条数上限
importanceThreshold: 3 # 进入"事实层"注入候选的重要性下限
embedder:
provider: openai-compatible
endpoint: https://api.openai.com/v1/embeddings
apiKeyEnv: OPENAI_API_KEY
model: text-embedding-3-small
dimensions: 768 # 显式覆盖;text-embedding-3-small 常见 1536,此处代码默认 768
cacheDir: "" # 留空 = $DSH_HOME/dsh-memory-s3/cache
auditRetentionDays: 0 # 0 = 永久保留
maxFileBytes: 20971520 # 附件大小上限(字节;默认 20MB,>100MB 时加载告警)
allowedFileTypes: [png, jpg, jpeg, gif, webp, pdf, zip, txt, md, json, csv] # 附件扩展名白名单(小写,无点)
在 profile 的 cordis.patch.yml 以小写 id 覆盖该条目的 config(整体替换语义):
- id: memory-s3
config:
enabled: true
bucket: my-memory-bucket
endpoint: ""
region: us-east-1
writePolicy: ask
embedder:
provider: none
用户设置段(方式一)中出现的字段会覆盖 entry config 的同名字段;entry config 又覆盖 schema 默认值。
prefix 决定对象根路径,最终键为:
{bucket}/{prefix}/memories/{type}/{id}.json
{bucket}/{prefix}/files/{id} # 附件
prefix 留空则直接落在桶根({bucket}/memories/...)。
同一个桶里,prefix 不同 = 两份互不可见的记忆库。 而且失败方式极具误导性:
memory_s3_status → configured: true, sync: ok
memory_s3_list → 0 entrie(s)
同步成功、却一条都没有——因为插件在你配的那个 prefix 下确实什么都没有,而它无从知道数据其实躺在隔壁。没有任何报错,看起来就像「桶是空的」。
排查方法是绕过插件直接列桶(凭据取自环境变量):
curl -s --aws-sigv4 "aws:amz:us-east-1:s3" \
--user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
"https://<endpoint-host>/<bucket>/?list-type=2&delimiter=/&max-keys=100" \
| grep -oE '<Prefix>[^<]+</Prefix>' | sort -u
看到 memories/ 直接位于桶根,就说明该用空 prefix;若看到 agent/memory/ 之类,就把 prefix 配成它。
几处容易混淆的地方:
dsh-memory-s3,不是空串。第一台设备若没显式配 prefix,数据会落在 {bucket}/dsh-memory-s3/memories/...agent/memory,照抄会与默认值不一致agent/memory 与 agent/memory/ 请勿混用相关:
prefix是活字段(.volatile()),改完不重启 profile 也会热重载生效(本插件反注册旧注册面、用新 Entry config 重新挂载);已存的记忆数据仍躺在旧路径上,需自行用 S3 工具搬迁。
# 模型工具
memory_s3_save 保存一条记忆(过审批门;可携附件 attachments:[{path, note?}])
memory_s3_search 关键词检索
memory_s3_recall 语义召回
memory_s3_list 列表/过滤
memory_s3_backlinks 查询反链(谁引用了该条目;无审批,读本地索引)
memory_s3_update 更新(过审批门;支持 subject/timeline/links/locked)
memory_s3_delete 删除(过审批门)
memory_s3_forget 抑制自动注入而不删除
memory_s3_attach 给已有条目挂附件(过审批门)
memory_s3_get_file 下载附件到本地(无审批,sha256 校验)
memory_s3_detach 移除附件(过审批门,删 S3 对象 + 条目元数据)
memory_s3_sync 手动同步 S3 增量
memory_s3_status 状态视图
# 命令行(规划中,未实现)
# /memory-s3 status|sync
dsh-memory-s3/
├── index.mjs # 插件入口(唯一 DSH 依赖面)
├── types.d.ts # ctx.memoryS3 类型契约
├── lib/
│ ├── s3store.mjs # S3 对象布局 + CRUD + 乐观并发
│ ├── cache.mjs # 本地缓存(索引 + 条目 LRU)
│ ├── embedder.mjs # 可插拔嵌入器(OpenAI 兼容 / Ollama)
│ ├── vector.mjs # 余弦 top-k + 过滤(纯 JS)
│ ├── entry.mjs # 条目模型校验/序列化(含附件元数据 + subject/timeline/links/locked)
│ ├── backlinks.mjs # 反链索引(links 入边镜像,本地 backlinks.json 持久化)
│ ├── filemeta.mjs # 附件探测:魔法字节 / 扩展名白名单 / 大小上限 / sha256
│ ├── gate.mjs # 审批门策略封装
│ ├── audit.mjs # 审计账本(JSONL)
│ └── strings.mjs # 词表(en/zh)
├── docs/ # requirements / TECH_STACK / ARCHITECTURE / SECURITY / MODEL / OMDSH_REVIEW / PROBLEM_REPORT.tests-v2.1
├── test/ # node --test
├── scripts/ # 冒烟脚本(smoke-rustfs.mjs / smoke-attachments.mjs)
├── cordis.patch.yml # bundle 声明
└── package.json
npm test # node --test 跑 test/*.test.mjs
npm run coverage # 覆盖率报告
提交使用 Conventional Commits(feat/fix/docs/refactor/test/chore)。
El Psy Kongroo.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: session、memory。