sage-mem 1.6.3 → 1.6.5

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
@@ -12,7 +12,7 @@
12
12
 
13
13
  **Cross-session memory for DeepSeek Harness — plain markdown files, no database, no worker.**
14
14
 
15
- **Current release: `1.6.3`** — the npm badge above is the dynamic source of truth. **Contract baseline: `1.0.0`** — the first stable release, whose public commitments, the capability boundaries and the list of things it explicitly cannot do are frozen in the
15
+ **Current release: `1.6.5`** — the npm badge above is the dynamic source of truth. **Contract baseline: `1.0.0`** — the first stable release, whose public commitments, the capability boundaries and the list of things it explicitly cannot do are frozen in the
16
16
  [frozen contract](https://github.com/gezi-wen/sage-mem/blob/main/docs/1.0.0-contract.md).
17
17
 
18
18
  If it is useful to you, a Star is the most direct feedback.
@@ -482,7 +482,7 @@ Version-by-version compatibility record:
482
482
  | 0.2.0-rc.2 | compatible |
483
483
  | 0.2.1-rc.1 | compatible |
484
484
 
485
- **How to read `compatible`.** It means this plugin's codec and manifest contract has been checked against that host generation (code-level comparison plus the unit/contract suite), **not** that an end-to-end probe was run on that exact host build. The table is a declaration; how each claim was checked is summarized here. Real-host probes so far: `headless` (2026-10-15) and `web` (2026-10-16); the `desktop` profile has **not** been probed yet (see [release-checklist.md](https://github.com/gezi-wen/sage-mem/blob/main/docs/release-checklist.md) §4b). CI runs only on Ubuntu + Node 24 against the `0.2.0-rc.1` peer generation; `engines.node` still declares `>=18`, but Node 18 is not part of the CI matrix.
485
+ **How to read `compatible`.** It means this plugin's codec and manifest contract has been checked against that host generation (code-level comparison plus the unit/contract suite), **not** that an end-to-end probe was run on that exact host build. The table is a declaration; how each claim was checked is summarized here. Real-host probes so far: `headless` (2026-10-15) and `web` (2026-10-16); the `desktop` profile has **not** been probed yet (see [release-checklist.md](https://github.com/gezi-wen/sage-mem/blob/main/docs/release-checklist.md) §4b). CI runs on Ubuntu against **Node 18.x / 20.x / 24.x** with the `0.2.0-rc.1` peer generation; macOS and Windows are not CI-covered, and there is no desktop-host probe yet.
486
486
 
487
487
  Two points worth spelling out:
488
488
 
package/README.zh.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  > File-based cross-session memory for DeepSeek Harness — every memory is a plain markdown file you can open, edit and delete. No database, no worker, no port.
16
16
 
17
- **当前发布版本:`1.6.3`** —— 顶部 npm 徽章是动态权威。**契约基线:`1.0.0`** —— 第一个稳定版,公开承诺、能力边界与「明确做不到」的清单冻结在
17
+ **当前发布版本:`1.6.5`** —— 顶部 npm 徽章是动态权威。**契约基线:`1.0.0`** —— 第一个稳定版,公开承诺、能力边界与「明确做不到」的清单冻结在
18
18
  [契约冻结](https://github.com/gezi-wen/sage-mem/blob/main/docs/1.0.0-contract.md)。
19
19
 
20
20
  如果它对你有用,给个 Star 是最直接的反馈。
@@ -484,7 +484,7 @@ sage-mem 是纯 DSH 插件,用 `package.json` 的 **`engines.dsh`** 声明宿
484
484
  | 0.2.0-rc.2 | compatible |
485
485
  | 0.2.1-rc.1 | compatible |
486
486
 
487
- **`compatible` 怎么读**:它表示本插件的 codec / manifest 契约在该宿主代上核对过(代码层比对 + 单元/契约测试),**不表示**在那个确切宿主构建上跑过端到端探针。这张表是声明,核对方式总结在下面。真实宿主探针目前只跑过 `headless`(2026-10-15)与 `web`(2026-10-16);`desktop` profile **还没跑过**(见 [release-checklist.md](https://github.com/gezi-wen/sage-mem/blob/main/docs/release-checklist.md) §4b)。CI 只在 Ubuntu + Node 24 上、对着 `0.2.0-rc.1` 一代 peer 跑;`engines.node` 仍声明 `>=18`,但 Node 18 不在 CI 矩阵里。
487
+ **`compatible` 怎么读**:它表示本插件的 codec / manifest 契约在该宿主代上核对过(代码层比对 + 单元/契约测试),**不表示**在那个确切宿主构建上跑过端到端探针。这张表是声明,核对方式总结在下面。真实宿主探针目前只跑过 `headless`(2026-10-15)与 `web`(2026-10-16);`desktop` profile **还没跑过**(见 [release-checklist.md](https://github.com/gezi-wen/sage-mem/blob/main/docs/release-checklist.md) §4b)。CI 在 Ubuntu 上覆盖 **Node 18.x / 20.x / 24.x**,peer 钉 `0.2.0-rc.1` 一代;macOS 与 Windows 没有 CI 覆盖,desktop 宿主探针也还没有。
488
488
 
489
489
  两点值得说明:
490
490
 
@@ -97,6 +97,28 @@ export function scoreDoc(queryTerms, tf, dl, stats) {
97
97
  return score
98
98
  }
99
99
 
100
+ /**
101
+ * 与 `scoreDoc` 同一口径的**逐词元贡献**。用于诊断报告:
102
+ * 「这条命中凭什么得分」不能只给一个总分,要能看到是哪个词元贡献了多少。
103
+ *
104
+ * 返回数组(按 queryTerms 顺序,只含真的命中的词元);各项 `score` 之和**严格等于**
105
+ * `scoreDoc` —— 两边共用同一个公式,`scoreDoc` 就是它的求和,不存在第二份实现。
106
+ *
107
+ * @returns {Array<{term:string, tf:number, idf:number, score:number}>}
108
+ */
109
+ export function scoreDocBreakdown(queryTerms, tf, dl, stats) {
110
+ if (!stats || stats.N === 0) return []
111
+ const out = []
112
+ for (const t of queryTerms) {
113
+ const f = tf.get(t)
114
+ if (!f) continue
115
+ const idf = idfOf(stats.df.get(t) ?? 0, stats.N)
116
+ const score = (idf * (f * (BM25_K1 + 1))) / (f + BM25_K1 * (1 - BM25_B + (BM25_B * dl) / stats.avgdl))
117
+ out.push({ term: t, tf: f, idf, score })
118
+ }
119
+ return out
120
+ }
121
+
100
122
  /**
101
123
  * 词元的逆文档频率。加 1 的对数形式:df 等于 N 时(到处都是的词元)趋近 0 而不为负。
102
124
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sage-mem",
3
3
  "description": "Cross-session memory for DeepSeek Harness — plain markdown files, no database, no worker.",
4
- "version": "1.6.3",
4
+ "version": "1.6.5",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {