sage-mem 2.33.1 → 2.33.3
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.en.md +1 -1
- package/README.md +1 -1
- package/lib/intake/merge.js +8 -2
- package/lib/intake/policy.js +25 -2
- package/package.json +5 -5
package/README.en.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: `2.33.
|
|
15
|
+
**Current release: `2.33.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
|
|
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.
|
package/README.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
|
-
**当前发布版本:`2.33.
|
|
17
|
+
**当前发布版本:`2.33.3`** —— 顶部 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 是最直接的反馈。
|
package/lib/intake/merge.js
CHANGED
|
@@ -16,7 +16,7 @@ import { join } from 'node:path'
|
|
|
16
16
|
import { parseFrontmatter, stripFrontmatterBlock } from '../memory/frontmatter.js'
|
|
17
17
|
import { frontmatterField } from '../memory/frontmatter.js'
|
|
18
18
|
import { ensureIndexEntry } from '../memory/index-file.js'
|
|
19
|
-
import {
|
|
19
|
+
import { isReserved } from '../memory/naming.js'
|
|
20
20
|
import { scanMemoryDirDetailed } from '../memory/scan.js'
|
|
21
21
|
import { warnLog, writeFileExclusive } from '../memory/util.js'
|
|
22
22
|
import { proposeFor } from './policy.js'
|
|
@@ -138,7 +138,13 @@ export function createIntakeMerger({ ctx, memoryDir, store }) {
|
|
|
138
138
|
return { ok: false, action: proposal.action, targetFile: proposal.targetFile, error: proposal.reason }
|
|
139
139
|
}
|
|
140
140
|
// 用户声明的保护名(`reserved.json`)在真落盘前再兜一道:policy 只认识两个内置名。
|
|
141
|
-
|
|
141
|
+
//
|
|
142
|
+
// ⚠️ 2026-12-05 修:原来这里是 `RESERVED_FILES.has(String(targetFile).toLowerCase())` ——
|
|
143
|
+
// **直接小写,丢了 `basename`**。于是 `targetFile = '../MEMORY.md'` 比对的是 `'../memory.md'`,
|
|
144
|
+
// 不在 `RESERVED_FILES` 里 → 放行 → `join(memoryDir, '../MEMORY.md')` 写到目录外。
|
|
145
|
+
// `isReserved` 走 `nameKey`(`basename(...).toLowerCase()`),那半正是挡路径成分的。
|
|
146
|
+
// 第一道闸门现在放在 `proposeFor` 里(名字合法性),这里是第二道(保留名)。
|
|
147
|
+
if (isReserved(proposal.targetFile)) {
|
|
142
148
|
return { ok: false, action: 'reject', targetFile: proposal.targetFile, error: '目标是保留名(索引 / 流水 / 用户声明的保护名),不接受外来写入' }
|
|
143
149
|
}
|
|
144
150
|
|
package/lib/intake/policy.js
CHANGED
|
@@ -35,7 +35,7 @@ export const SUBMIT_TYPES = Object.freeze(['project', 'reference'])
|
|
|
35
35
|
export const SUBMIT_KINDS = Object.freeze(['new', 'patch'])
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* 内置保留名(索引 / 流水)。**用户自己声明的**保留名不在这里判 —— 那要读
|
|
39
|
-
eserved.json,
|
|
38
|
+
* 内置保留名(索引 / 流水)。**用户自己声明的**保留名不在这里判 —— 那要读 reserved.json,
|
|
40
39
|
* 属于 IO 层,由 merge.js 在真正落盘前再兜一道。这里只保证「外来提交永远占不到这两个名字」。
|
|
41
40
|
*/
|
|
42
41
|
const RESERVED_BUILTIN = new Set([INDEX_FILE_KEY, SESSION_LOG_KEY])
|
|
@@ -198,6 +198,30 @@ export function proposeFor(submission, existingNames) {
|
|
|
198
198
|
for (const n of existingNames ?? []) set.add(String(n).toLowerCase())
|
|
199
199
|
const name = String(submission?.name ?? '')
|
|
200
200
|
const targetFile = name.toLowerCase().endsWith('.md') ? name : `${name}.md`
|
|
201
|
+
// ⚠️ **名字合法性必须在这里再判一次**(2026-12-05 修)。
|
|
202
|
+
//
|
|
203
|
+
// `validateSubmission` 判过一次(`:131`),但那是**提交流程**。归并器的 approve 路径
|
|
204
|
+
// 是**从磁盘读 pending 文件**再走到这里(`merge.js:127`),中间不经过 validateSubmission ——
|
|
205
|
+
// 也就是说 pending 目录是它唯一信任的东西。实测(修前):
|
|
206
|
+
//
|
|
207
|
+
// name = '../MEMORY.md' → targetFile = '../MEMORY.md' → action = 'create'
|
|
208
|
+
//
|
|
209
|
+
// 于是 `join(memoryDir, '../MEMORY.md')` 落在记忆目录**外面**,先在父目录建临时文件、
|
|
210
|
+
// 再 link 成目标(`writeFileExclusive` 的写法),最后把这一条补进索引。
|
|
211
|
+
// 覆盖不了已有文件(`link` 撞名是 EEXIST),但「在目录外凭空创建一份文件」这件事
|
|
212
|
+
// 本身就不该发生 —— 而且它绕过的正是本文件 `:38` 那句「外来提交永远占不到这两个名字」的承诺。
|
|
213
|
+
//
|
|
214
|
+
// 判据用 `isPlainMdName`(与全库同一份,定义在 `shared/md-name.js`):它挡路径分隔符、
|
|
215
|
+
// `..`、点文件、NTFS 非法字符与保留设备名。**不要**在这里自己拼正则 —— 那是第 N 份手抄。
|
|
216
|
+
if (!isPlainMdName(targetFile)) {
|
|
217
|
+
return { action: 'reject', targetFile: '', reason: '名字不是合法的单段 .md 文件名(含路径成分 / 点文件 / 非法字符)—— 外来提交不接受' }
|
|
218
|
+
}
|
|
219
|
+
// 内置保留名:库里同一份判据是 `memory/naming.js` 的 `isReserved`,但它经 `nameKey`
|
|
220
|
+
// 依赖 `node:path`,而本文件是**纯策略层**(零 node 内建,`structure-test` 第 5 组盯着)。
|
|
221
|
+
// 走到这里 `targetFile` 已经是单段名了,直接小写比对与 `nameKey` 等价。
|
|
222
|
+
if (RESERVED_BUILTIN.has(targetFile.toLowerCase())) {
|
|
223
|
+
return { action: 'reject', targetFile, reason: '目标是内置保留名(索引 / 流水),不接受外来写入' }
|
|
224
|
+
}
|
|
201
225
|
const exists = set.has(targetFile.toLowerCase())
|
|
202
226
|
if (submission?.kind === 'new') {
|
|
203
227
|
return exists
|
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": "2.33.
|
|
4
|
+
"version": "2.33.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"icon": "./icon.png",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"zod": "^4.4.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@deepseek-ai/cordis": "4.0
|
|
48
|
-
"@deepseek-ai/dsh-client-locale": "0.2.
|
|
49
|
-
"@deepseek-ai/dsh-skill-filesystem": "0.2.
|
|
50
|
-
"@deepseek-ai/dsh-typert-protocol": "0.2.
|
|
47
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
48
|
+
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.5",
|
|
49
|
+
"@deepseek-ai/dsh-skill-filesystem": "0.2.2-rc.5",
|
|
50
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.5",
|
|
51
51
|
"react": "^18.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|