@max-null/dsh-memory 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,7 +41,7 @@ npm install @max-null/dsh-memory
41
41
 
42
42
  - **服务** `ctx.memory`:`remember` / `list` / `search` / `forget` / `setStatus`
43
43
  - **工具**:`memory_save`、`memory_list`、`memory_search`、`memory_confirm`、`memory_forget`、`memory_update`
44
- - **注入**:`tool:memory` 指引 section + `memory:recall` 召回 context(global 的 `approved + injected` + 当前会话工作区的 `approved + injected`,带 `[memory:<id>:<namespace>]` 来源标记;摘要化 + 预算截断)
44
+ - **注入**:`tool:memory` 指引 section(工具用法 + 常驻注入判据)+ `memory:self` 机制自述 + `memory:recall` 召回 context(global 的 `approved + injected` + 当前会话工作区的 `approved + injected`,带 `[memory:<id>:<namespace>]` 来源标记;摘要化 + 预算截断)
45
45
  - **检索**:BM25(CJK 单字 + 2-gram,content 与 keywords 字段分离加权;中文多字查询精度显著优于单字切分);可选语义融合(见「可选配置」)
46
46
 
47
47
  ## 两层存储(global / project)
package/dist/index.js CHANGED
@@ -92,15 +92,22 @@ function promptValue(record) {
92
92
  }
93
93
  // 0.3.0:审核语义双语(host 侧 GUIDANCE 无法跟随 DSH locale 动态切换,
94
94
  // 采用中英双语都写、模型自取——设计文档「风险与注意」)。
95
+ // 0.9.2:常驻注入不再是「人工开关」——0.8.0 起模型侧可经 `injected` 参数显式钉住。
96
+ // 旧表述会让模型以为自己没有该权限,也与同段「人工只在例外时介入」自相矛盾。
95
97
  const GUIDANCE = 'Use memory tools for cross-session preferences, habits, and project conventions. '
96
98
  + '记忆工具用于跨会话的偏好、习惯与项目约定。'
97
99
  + 'memory_save writes a memory that takes effect immediately (`approved`) — memories are maintained '
98
100
  + 'by the system and the model, and humans intervene only as exceptions. Credential-like content is '
99
101
  + 'quarantined instead. memory_save 写入即生效(`approved`)——记忆由系统与模型自行维护,人工只在例外时介入;'
100
102
  + '命中危险内容规则(密钥/凭据)的写入会被隔离。'
101
- + 'Approval only marks the content reviewed; whether it is injected every turn is a separate '
102
- + 'human-controlled switch (`injected`). 审核通过只代表内容被认可;是否每轮常驻注入由独立的'
103
- + '人工开关(`injected`)控制。'
103
+ + 'Pass `injected: true` on memory_save / memory_update to pin a memory resident in every turn\'s context: '
104
+ + 'the same switch the settings panel exposes, exempting the record from both automatic rules (promote on '
105
+ + 'repeated hits, demote after long idle). Reserve it for rules, standing agreements and judgement criteria '
106
+ + '— the kind that must apply even when nobody thinks to search for them; facts, references and case notes '
107
+ + 'stay search-only. '
108
+ + '给 memory_save / memory_update 传 `injected: true` 即把这条钉成每轮常驻——与设置面板是同一个开关,'
109
+ + '此后不受两条自动规则(反复命中自动开启 / 长期未命中自动撤下)影响。只用于规则、长期约定与判据这类'
110
+ + '「没人想起来搜也必须生效」的记忆;事实、参考与案例留作按需检索。'
104
111
  + 'When earlier context may be relevant, call memory_search to recall it — reviewable memories '
105
112
  + '相关历史上下文可用 memory_search 检索;被隔离的记录不进检索。'
106
113
  + 'Every memory is plaintext and inspectable with memory_list; memory_forget removes one. '
package/dist/self.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * 记忆机制自述(memory:self 注入内容 + 面板「注入预览」共用)。
3
3
  * 0.3.2 起:LLM 每轮知道本环境有记忆机制;不落用户存储,随发版更新,
4
4
  * 版本号动态读取 package.json("只跟随 dsh-memory 组件发版变动")。
5
+ * 0.9.2:补齐常驻注入机制——`injected` 参数、注入预算上限、预算诊断行的含义。
5
6
  */
6
7
  import { createRequire } from 'node:module';
7
8
  export const SELF_VERSION = (() => {
@@ -25,6 +26,10 @@ export const SELF_DESCRIPTION = `[记忆系统自述] 本环境内置跨会话
25
26
  + '**怎么写**:一条一件事,并给多角度关键词(同义词、缩写、中英),否则将来检索不到它。'
26
27
  + '**锚点(可选)**:若这条记忆描述的是「随某个环境值变化的事实」(某工具版本下的行为、某环境变量决定的配置),用 anchor 参数把它绑到那个值上——值变了它会自动失效并标 stale,不会再被当成仍然正确。'
27
28
  + '写入即生效(`approved`),人工只在例外时介入;命中密钥/凭据规则的写入会被隔离(不进注入与检索)。'
28
- + '每轮注入的是「global + 当前会话工作区」里已生效且开着常驻开关的记忆摘要(受预算限制,超预算按最近更新优先);全文要靠 memory_search。'
29
+ + '**常驻注入**:每轮注入「global + 当前会话工作区」里 approved 且开着常驻开关的记忆单行摘要(形如 `- [memory:id:namespace] 摘要`);全文要靠 memory_search 取。'
30
+ + '开关有两条自动规则:命中累计 2 次自动开启、30 天未命中自动撤下;**给 memory_save / memory_update 传 `injected` 即显式接管**,此后这两条都不再适用。'
31
+ + '**钉的判据是「失效可察觉性」**:这条记忆若没被想起来,你会不会根本意识不到自己漏了它?会 → 钉常驻(规则 / 委托 / 判据);不会 → 留检索(事实 / 参考 / 案例)。'
32
+ + '**注入有预算**(默认 1500 字符,约装 11 条),装不下的整条丢弃、按最近使用优先取舍——所以「钉了常驻」只等于「有资格排队」。'
33
+ + '装不下时注入末尾会出现一行 `(另有 N 条常驻因预算未注入:…短摘要…)`——**那是「有常驻记忆并不在场」的唯一信号**,看到它就该逐条评估撤下。'
29
34
  + '发现某条记忆与实际不符时用 memory_update 修正(保持生效);确认没用的用 memory_forget。'
30
- + '(English: dsh-memory provides cross-session memory. Writes take effect immediately; save durable preferences, corrections and reusable conclusions — not transient state, guesses, or facts readable from the repo (record where to look instead). Always add multi-angle keywords.)';
35
+ + '(English: dsh-memory provides cross-session memory. Writes take effect immediately; save durable preferences, corrections and reusable conclusions — not transient state, guesses, or facts readable from the repo (record where to look instead). Always add multi-angle keywords. Pass `injected: true` to keep one resident every turn — reserve that for rules and standing agreements; facts stay search-only. Resident injection runs on a budget, so a pinned memory is only queued, never guaranteed to be in context.)';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@max-null/dsh-memory",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Cross-session plaintext memory plugin for the DeepSeek Harness — deterministic BM25 recall, writes take effect immediately, signal-driven injection, no embeddings",
5
5
  "license": "MIT",
6
6
  "publishConfig": {