Skip to content

Commit dd0ed78

Browse files
authored
release: v0.7.12 + 编码记忆(codingRetrospect)蒸馏/智能调速器/语义保留(合并 #73 与 #74)
合并 v0.7.11(v0.7.12 面板大改+外部HTTP API) 与编码记忆三功能:#73 rebase 到 v0.7.12 后一次吸收。 - v0.7.11 记忆库面板大改版(外部前端化)+ v0.7.12 独立外部 HTTP API(127.0.0.1:8790) - 编码记忆蒸馏 codingRetrospect(rejected_solution/pitfall/constraint 三类型) - 完整转录+原子记忆(distillMaxChars 24000) - 智能调速器(429 串行队列+指数退避) - fix(ci): 恢复 c8/test:coverage(v0.7.11 连带删除致 test CI Missing script) 616 测试全绿。
1 parent cb5ec63 commit dd0ed78

96 files changed

Lines changed: 5103 additions & 12503 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CONTRIBUTING.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Common scripts (all run under `dsh-mneme/`):
6262
| `npm run e2e` | End-to-end smoke test (scripts/e2e-dsh.js) |
6363
| `npm run stress` | Three-axis stress test (scripts/stress-dsh.js) |
6464
| `npm run sync` | src/ → lib/ mirror |
65+
| `node bin/cli.mjs --help` | CLI smoke check (zero-dep external API client, v0.7.12+) |
6566

6667
---
6768

@@ -132,6 +133,14 @@ Versioning follows semantic versioning (`MAJOR.MINOR.PATCH`). Full flow:
132133

133134
---
134135

136+
## External API & CLI (v0.7.12+)
137+
138+
The standalone external API (`src/api-standalone.js`) and the `bin/cli.mjs` client let other plugins and desktop tools read/write memories over loopback HTTP. When touching them:
139+
140+
- Keep the route surface read/write on memories only; new routes need tests in `test/standalone-api.test.js` (they spin the real server on port 0).
141+
- Auth additions/changes must keep `timingSafeEqual` token comparison and the `GET /health` exception.
142+
- The CLI is dependency-free by contract - do not add imports to `bin/cli.mjs`.
143+
135144
## Contact
136145

137146
- **General questions & contributions**: [GitHub Discussions](https://github.com/modusensus/dsh-mneme/discussions) or `[email protected]`

‎SECURITY.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,18 @@ The following security features are implemented and maintained in the project:
4242
| `/health` Auth-Gated Endpoint | Health endpoint requires `apiToken`; error codes are sanitized (no-space / permission / sync-failed) and read failures fail closed as `unknown` | ✅ Implemented |
4343
| Fail-Closed Input Validation | Generation counters and hot-memory parameters are validated (`Number.isInteger`, finite, non-negative) with SQL `CHECK` constraints; invalid input falls back to safe defaults or is rejected | ✅ Implemented |
4444
| Hybrid Score Clamping | Hybrid fusion scores are clamped to [0, 1] to prevent vector + BM25 stacking from breaking normalization bounds | ✅ Implemented |
45+
| Standalone External API (v0.7.12, opt-in) | Optional per-plugin HTTP server for ecosystem integrations, bound to `127.0.0.1` by default with an auto-generated persistent Bearer token (`timingSafeEqual` verified); `/health` is the only unauthenticated route; binding a non-loopback host is an explicit operator decision | Implemented |
4546
| Tag Sanitization | Tag normalization reuses the sanitizer; `autoTag` skips forgotten memories; `setMemoryTags` runs inside a SAVEPOINT for atomic rollback | ✅ Implemented |
4647

48+
### Standalone External API (v0.7.12)
49+
50+
Since v0.7.12 the plugin can optionally start its own HTTP server (`externalApiEnabled`, default **off**) so other plugins, CLIs, and desktop tools can read and write memories without going through the DSH host port.
51+
52+
- **Loopback by default**: the server binds `127.0.0.1:8790` (`externalApiHost` / `externalApiPort`, or persisted panel settings). Rebinding to a non-loopback address exposes the store to your network and is an explicit operator decision.
53+
- **Token authentication**: every route except `GET /health` requires `Authorization: Bearer <token>`; the token is auto-generated on first use, persisted in the plugin settings store, verified with `timingSafeEqual`, and can be rotated from the web panel (Settings -> External API).
54+
- **Surface**: read/write on memories only (`GET/POST/DELETE /memories`, `GET /memories/:id`, `GET /search`, `GET /status`). No profile, rules, commands, or configuration endpoints are exposed; writes go through the same dedupe + quality-filter path as in-conversation saves.
55+
- **CLI**: `bin/cli.mjs` is a thin client over this API and stores its credentials in `~/.dsh-mneme/cli.json` - treat that file like any credential file.
56+
4757
---
4858

4959
## Reporting a Vulnerability

‎dsh-mneme/.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ id_rsa*
2424
*.db-shm
2525
*.sqlite
2626
memory.db
27+
28+
# local tooling state
29+
.mimosa/
30+
.v2c/
31+
out/
32+

‎dsh-mneme/CHANGELOG.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Changelog
22

3+
## [0.7.12] - 2026-09-08
4+
5+
### 新增
6+
7+
- **独立外部 API(生态集成)**:插件可启动自己的 HTTP 服务(默认 `127.0.0.1:8790`,仅回环绑定),其他插件/CLI/桌面工具经 Bearer token 读写记忆,不再依赖 DSH 内部端口。路由:`GET /health`(免鉴权)、`GET /status`、`GET/POST/DELETE /memories`、`GET /memories/:id`、`GET /search`;token 首次启用自动生成并持久化(设置面板可查看复制)。配置:`externalApiEnabled/externalApiPort/externalApiHost` + 面板设置持久化(重启生效);非回环绑定的安全责任由操作者承担。
8+
- **CLI 工具 `dsh-mneme`**:零依赖命令行(`bin/cli.mjs`)——`status` / `list` / `search` / `get` / `add` / `delete` / `config set|show|path`,配置优先级 参数 > 环境变量(DSH_MNEME_URL/TOKEN)> `~/.dsh-mneme/cli.json`;`--json` 机器输出。
9+
- **轻量模式(lightMode)**:面向非技术用户的简化预设——只保留核心的记忆读写与自动注入(autoInject/autoSummarize/hot memory/质量过滤),关闭 autoDream 巩固、实体抽取、语义搜索、rerank、bm25、选择性注入等重资源项;`applyLightModePreset` 纯函数 + `panel_mode` 持久化(持久化优先于 bundle 配置),设置面板一键切换(重启生效)。
10+
- **设置面板新卡片**:「运行模式」(轻量/标准)与「外部访问 API」(开关/地址端口/Token 复制),中英文案齐备。
11+
12+
### 测试
13+
14+
- 612 全绿(+17):独立 API 10 例(401/health/CRUD 闭环/搜索/400 校验)、mode 路由 3 例、external_api kv 2 例、light 预设与 config 用例;`store.count` 支持 minImportance/source 后 total 与行一致。
15+
16+
## [0.7.11] - 2026-09-08
17+
18+
### 新增
19+
20+
- **记忆库面板改版(可扩展性 + 实时性)**:
21+
- **按月分页 + 无限滚动**:记忆浏览从一次性 `limit=500`(超限即静默丢失)改为 100 条/页的时间序分页(`list?order=chrono`,`store.list` 新增 `order` 参数、`/api/dsh-mneme/list` 透传),滚动到底自动拉下一页(IntersectionObserver 哨兵 + 「加载更多」按钮兜底),底栏常显 `已加载/总数`。
22+
- **月份默认折叠**:仅最新一个月展开,历史月份收起为一行标题(带条目计数),月份表头吸顶;几千条记忆也只渲染少量 DOM。
23+
- **搜索全局化**:关键词/语义搜索都改走服务端(`mode=keyword|vector`),命中全库而不仅已加载页;`type` 过滤在搜索结果上继续生效。
24+
- **数据实时性**:记忆子视图激活时即刷新第一页,打开期间每 30s 静默刷新(页面不可见时暂停),新记忆无需手动刷新即可出现;图跳转的记忆若在未加载页,以单条结果呈现并选中。
25+
- **图标与视觉**:内联 Lucide 风格 stroke 图标(路径数据打包进 bundle,运行时零依赖;与 morphicons 消费的 lucide 数据同源),替换文字箭头/子 tab 图标/搜索/刷新/复制等;月份表头、加载更多、空态样式梳理。
26+
- **bundle 默认开启实体抽取**:`cordis.patch.yml` 增加 `entityExtractionEnabled: true`(此前默认 false,图谱实体只在显式配置过的环境增长)。新记忆落库即自动抽取实体/关系,图谱随对话自动生长。
27+
- **记忆库「状态」子页**:记忆总数(含分类型小计)、实体计数(含分类型小计)、向量索引开关状态、近 7 天 LLM 调用/消耗四张卡片,分区独立加载互不阻塞。
28+
- **记忆删除(两步确认)**:详情面板新增红色「删除」按钮——首次点击变为实心红「确认删除?」+「取消」,确认后走新增的 `POST /api/dsh-mneme/delete`(`{id}`,复用 requireAuth 围栏;400 缺 id / 404 不存在),本地列表与计数同步移除。
29+
- **重要性过滤**:分类栏新增 全部/★3+/★4+/★5 服务端过滤芯片(`list?minImportance=`),`store.count` 同步接受过滤参数使分页 total 与行一致;浏览分页、加载更多、自动刷新共用同一过滤态。
30+
- **双语 README**:新增 `README.en.md`(与中文版逐节对齐),两版互挂语言切换链接。
31+
32+
### 修复
33+
34+
- **Issue #72:窗口最大化后图谱节点不可见**:力导向模拟此前以 SVG 元素的 CSS 宽度(`clientWidth`)为布局边界——最大化窗口下元素宽达上千 CSS px,重心(`clientWidth/2`)与钳制区间都落到 380×300 viewBox 之外,节点整体被裁剪出画布(窗口较小时两个空间近似重合,所以一切正常)。现在模拟全程在 viewBox 用户单位(`VIEW_W`/`VIEW_H`)中运行,与绘制空间严格一致;浏览器把 viewBox 等比缩放到元素实际尺寸,小窗、隐藏 tab、最大化均可见、可拖拽,布局不再依赖挂载时的容器测量。
35+
- **Issue #59:DSH ≥0.1.2-rc 上 autoSummarize 从不执行**:DSH 0.1.2-rc 起移除了 `Session.events` 属性,事件只能经 `snapshotEvents()` 获取——`collectMessages()` 拿到的恒为空数组导致 `summarize()` 直接退出,`llm_audit_logs` 全空、从未发起 LLM 调用。`summarize.js` 与 `inject.js`(`lastUserQuery` / `extractRounds`)三处统一改为 `session.snapshotEvents?.() ?? session.events ?? []` 兼容垫片:新 DSH 走 snapshot 方法,老版本回退 `.events`,两边都不破坏。
36+
37+
### 测试
38+
39+
- 595 全绿:新增 snapshotEvents 回归 2 例——summarize(仅暴露 `snapshotEvents()`、无 `.events` 的会话必须触发 LLM 调用并入库 2 条记忆)与 inject(无 `.events` 会话下「短期上下文」热记忆块照常渲染)。
40+
341
## [0.7.10] - 2026-09-07
442

543
### 🆕 Web 面板体验升级:类型色点 / 图谱平移缩放 / 设置页重排 / 侧边栏冲突修复

0 commit comments

Comments
 (0)