sage-mem 2.29.0 → 2.30.0
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/client.js +30 -41
- package/lib/index.js +6 -19
- package/lib/memory/scan.js +53 -2
- package/lib/mirror/policy.js +34 -11
- package/lib/typert/schemas.js +4 -0
- package/package.json +1 -1
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.
|
|
15
|
+
**Current release: `2.30.0`** — 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.
|
|
17
|
+
**当前发布版本:`2.30.0`** —— 顶部 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/client.js
CHANGED
|
@@ -1741,7 +1741,8 @@ const StarmapRuntime = (function (require, _react) {
|
|
|
1741
1741
|
const isStrArr = (v) => { if (!Array.isArray(v)) throw new Error("expected string array"); for (const x of v) isStr(x); };
|
|
1742
1742
|
// 字段必须与宿主 `lib/typert.host.js` 的 fileSchema **同宽**(strict 会剥掉未声明字段):
|
|
1743
1743
|
// 少了 tags / locked,列表页的「按标签筛」与「锁定」按钮就永远拿到 undefined。
|
|
1744
|
-
|
|
1744
|
+
// 2.30.0 加 `exposedBy`(可选):外部访问面板据此画勾选,不再自己算白名单判据。
|
|
1745
|
+
const fileSchema = optionalFields(parseSchema({ "file": isStr, "type": isStr, "description": isStr, "size": isNum, "tags": isStrArr, "locked": isBool }), { "revision": isStr, "exposedBy": isStr });
|
|
1745
1746
|
const listSchema = { fields: fileSchema.fields, parse(v) { if (!Array.isArray(v)) throw new Error("expected array"); v.forEach((f) => fileSchema.parse(f)); return v; } };
|
|
1746
1747
|
const readSchema = withOptional(parseSchema({ "name": isStr, "content": isStr }), ["revision"]);
|
|
1747
1748
|
const writeSchema = optionalFields(parseSchema({ "ok": isBool, "file": isStr }), { "error": isStr, "code": isStr, "revision": isStr });
|
|
@@ -8104,21 +8105,12 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8104
8105
|
const exposed = new Set(exposedNames);
|
|
8105
8106
|
const endpoint = (status && status.endpoint) || null;
|
|
8106
8107
|
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
*/
|
|
8114
|
-
function parseTagsOf(raw) {
|
|
8115
|
-
return String(raw == null ? "" : raw)
|
|
8116
|
-
.split(/[,,、]+/)
|
|
8117
|
-
.map(function (s) { return s.replace(/[\[\]"'#:]/g, "").trim(); })
|
|
8118
|
-
.filter(function (s) { return s !== ""; })
|
|
8119
|
-
.slice(0, 20)
|
|
8120
|
-
.map(function (s) { return s.slice(0, 40); });
|
|
8121
|
-
}
|
|
8108
|
+
// 标签切分直接用 `50-shared-ui.js` 的 `parseTagInput`(认 `,` `,` `、`,剥 YAML 字符,截断)。
|
|
8109
|
+
//
|
|
8110
|
+
// 这里曾经复制过一份 `parseTagsOf`,理由写的是「50 在内层作用域、68 够不着」——**那是错的**。
|
|
8111
|
+
// `client/*.js` 拼成的是**同一个 factory 作用域**(`scripts/build-client.mjs` 只是逐字节拼接),
|
|
8112
|
+
// `50` 与 `68` 的顶层声明同级。2026-12-04 那次白屏的真凶是另一次全局替换(`enabled` 未定义),
|
|
8113
|
+
// 与这里无关。2026-12-04 晚(2.29.1)删掉复制品、改回调用。
|
|
8122
8114
|
|
|
8123
8115
|
/** 前缀候选:默认那两个 + 另外两类(面板把「不给」也画出来,免得以为漏了)。 */
|
|
8124
8116
|
const PREFIX_CHOICES = ["project_", "reference_", "user_", "feedback_"];
|
|
@@ -8237,9 +8229,9 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8237
8229
|
|
|
8238
8230
|
/** 标签白名单:逗号分隔(中英文逗号都收)。空 = 不按标签开放。 */
|
|
8239
8231
|
function saveTags() {
|
|
8240
|
-
//
|
|
8232
|
+
// 走共享的 parseTagInput:认半角逗号、全角逗号与顿号,并剥掉 YAML 里有语法含义的字符。
|
|
8241
8233
|
// 旧实现只切 `[,,]`,中文输入法敲出的「记忆系统、发布」会被当成一个标签(审计 P3-1)。
|
|
8242
|
-
saveExternal({ tags:
|
|
8234
|
+
saveExternal({ tags: parseTagInput(tagDraft) }, t("ext.notice.saved"));
|
|
8243
8235
|
}
|
|
8244
8236
|
|
|
8245
8237
|
/**
|
|
@@ -8250,7 +8242,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8250
8242
|
* 并**只在真的变了**才发请求 —— 否则点一下输入框再点走,就会白刷一次提示。
|
|
8251
8243
|
*/
|
|
8252
8244
|
function saveTagsIfChanged() {
|
|
8253
|
-
const next =
|
|
8245
|
+
const next = parseTagInput(tagDraft);
|
|
8254
8246
|
const cur = (ext && Array.isArray(ext.tags) ? ext.tags : []).map(function (s) { return String(s).trim(); }).filter(function (s) { return s !== ""; });
|
|
8255
8247
|
if (next.join("\u0000") === cur.join("\u0000")) return;
|
|
8256
8248
|
saveTags();
|
|
@@ -8267,29 +8259,21 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8267
8259
|
}
|
|
8268
8260
|
|
|
8269
8261
|
/**
|
|
8270
|
-
* 某个文件**现在是否在白名单里** ——
|
|
8262
|
+
* 某个文件**现在是否在白名单里** —— 直接读后端给的 `exposedBy`。
|
|
8271
8263
|
*
|
|
8272
|
-
*
|
|
8273
|
-
*
|
|
8274
|
-
*
|
|
8264
|
+
* 2.30.0 起前端**不再自己算**:判据只有 `lib/mirror/policy.js` 的 `exposedByOf` 一处。
|
|
8265
|
+
* 之前那份复制品(按 include / exclude / prefixes / tags 现算)曾经漏掉 tags 维度、
|
|
8266
|
+
* 大小写口径也与后端不同 —— 症状是「勾着但没导出去」,或者反过来。
|
|
8275
8267
|
*
|
|
8276
|
-
*
|
|
8268
|
+
* `exposedBy` 缺省(旧宿主不返回)时按 `'none'` 处理:宁可少勾,也不假装。
|
|
8277
8269
|
*/
|
|
8278
8270
|
function isIncluded(name) {
|
|
8279
|
-
if (!ext) return false;
|
|
8280
8271
|
const n = String(name);
|
|
8281
|
-
const inc = (ext.include || []).map(String);
|
|
8282
|
-
const exc = (ext.exclude || []).map(String);
|
|
8283
|
-
if (exc.indexOf(n) >= 0) return false;
|
|
8284
|
-
if (inc.indexOf(n) >= 0) return true;
|
|
8285
|
-
const lower = n.toLowerCase();
|
|
8286
|
-
// 与后端 `lib/mirror/policy.js` 的 `isExposed` **同序**:排除 > 包含 > 前缀 > 标签。
|
|
8287
|
-
// 前端**刻意不判 `enabled`** —— 关着的时候勾选是「打开后要导出什么」,不是「现在正在导出」。
|
|
8288
|
-
if ((ext.prefixes || []).some(function (p) { return lower.indexOf(String(p).toLowerCase()) === 0; })) return true;
|
|
8289
8272
|
const hit = (files || []).filter(function (f) { return String(f && f.file) === n; })[0];
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8273
|
+
if (!hit || typeof hit.exposedBy !== "string") return false;
|
|
8274
|
+
// ⚠️ `'exclude'` 表示「被显式排除」,不是「勾上」—— 只判 `!== 'none'` 会把它画成勾选态
|
|
8275
|
+
// (2026-12-04 实验室里抓到:一条被排除的记忆显示成勾着)。
|
|
8276
|
+
return hit.exposedBy !== "none" && hit.exposedBy !== "exclude";
|
|
8293
8277
|
}
|
|
8294
8278
|
|
|
8295
8279
|
/**
|
|
@@ -8569,12 +8553,17 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8569
8553
|
}, function (e) { setBusy(""); setErr(String((e && e.message) || e)); });
|
|
8570
8554
|
}
|
|
8571
8555
|
|
|
8572
|
-
/**
|
|
8556
|
+
/**
|
|
8557
|
+
* patch 的「复制建议」:只复制「建议改成」那一段,不复制整份 patch。
|
|
8558
|
+
*
|
|
8559
|
+
* 走 `56-health-prompt.js` 的 `copyPromptText`:它带 `execCommand` 降级。
|
|
8560
|
+
* 只认 `navigator.clipboard` 的写法在**局域网 http 部署(非安全上下文)下必然失败** ——
|
|
8561
|
+
* 同一个产品里两处复制行为不同,用户只会觉得「这里坏了」(2.29.1 统一)。
|
|
8562
|
+
*/
|
|
8573
8563
|
function copySuggestion(text) {
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
setNotice(t("ext.intake.notice.copied"));
|
|
8564
|
+
Promise.resolve(copyPromptText(String(text == null ? "" : text))).then(function (ok) {
|
|
8565
|
+
if (ok === true) setNotice(t("ext.intake.notice.copied"));
|
|
8566
|
+
else setErr(t("ext.intake.err.noClipboard"));
|
|
8578
8567
|
}, function () { setErr(t("ext.intake.err.noClipboard")); });
|
|
8579
8568
|
}
|
|
8580
8569
|
|
package/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { INDEX_FILE_KEY, SESSION_LOG_KEY, isPlainMdName } from './shared/md-name
|
|
|
13
13
|
import { parseAliases, parseBaseline, parseBaselinePriority, parseFrontmatter, parseTags } from './memory/frontmatter.js'
|
|
14
14
|
import { ageDays, bigrams, score, selectBaseline, selectRelevant } from './memory/retrieval.js'
|
|
15
15
|
import { isReserved, nameKey, safeName } from './memory/naming.js'
|
|
16
|
-
import { MEMORY_ARCHIVE_DIR, addArchiveMeta, extractTitle, inspectDir, inspectMemoryEntry, readArchivedMeta, readVerified, scanArchived, scanCheckpointOpen, scanMemoryFiles, scanStars, shadowsReserved } from './memory/scan.js'
|
|
16
|
+
import { MEMORY_ARCHIVE_DIR, addArchiveMeta, extractTitle, inspectDir, inspectMemoryEntry, readArchivedMeta, readVerified, listMemoryFiles, scanArchived, scanCheckpointOpen, scanMemoryFiles, scanStars, shadowsReserved } from './memory/scan.js'
|
|
17
17
|
import { listConflicts, patchConflict, readConflict, removeConflict, summarizeConflict } from './memory/conflicts.js'
|
|
18
18
|
import { invalidateMemory, undoMemoryInvalidation } from './memory/arbitrate.js'
|
|
19
19
|
import { prepareWrite, readSnapshot, revisionOf, writeSnapshot } from './memory/write-protocol.js'
|
|
@@ -118,25 +118,12 @@ export class MemoryGateway extends TypertRemoteService {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/** 列出 memory 目录全部记忆文件(文件名 + 类型 + 描述 + 大小 + 自定义标签 + 是否锁定)。 */
|
|
121
|
+
/**
|
|
122
|
+
* 列出记忆目录里的全部条目(2.30.0 搬到 `memory/list-files.js`:本文件卡 1000 行)。
|
|
123
|
+
* 字段与语义不变,多了 `exposedBy` —— 外部访问面板据此画勾选,不再自己算判据。
|
|
124
|
+
*/
|
|
121
125
|
async listFiles() {
|
|
122
|
-
|
|
123
|
-
// Q05:锁表坏了也照样列文件,但不假装「都没锁」;逐条 locked 只有布尔,未知只能靠日志。
|
|
124
|
-
if (lockState.status === 'unknown') warnLog(this.ctx, `锁表不可读,列表里的锁定状态未知(不是「都没锁」):${lockState.reason}`)
|
|
125
|
-
return files.map(f => {
|
|
126
|
-
const meta = parseFrontmatter(f.content)
|
|
127
|
-
return {
|
|
128
|
-
file: f.file,
|
|
129
|
-
type: meta.type || 'reference',
|
|
130
|
-
description: meta.description || '',
|
|
131
|
-
size: f.content.length,
|
|
132
|
-
tags: meta.tags,
|
|
133
|
-
// 2.21.0:删除确认必须能交回「我看到的是哪一版」。与 readFile 用同一个
|
|
134
|
-
// 正文字节 sha256(write-protocol.revisionOf),名字不再是身份。
|
|
135
|
-
revision: revisionOf(Buffer.from(f.content, 'utf8')),
|
|
136
|
-
// 锁定状态跟着每条一起给:卡片上的「锁定 / 已锁定」按钮要据此渲染
|
|
137
|
-
locked: lockState.status === 'unknown' ? false : lockState.locked.has(nameKey(f.file)),
|
|
138
|
-
}
|
|
139
|
-
})
|
|
126
|
+
return listMemoryFiles(this.ctx, MEMORY_DIR)
|
|
140
127
|
}
|
|
141
128
|
|
|
142
129
|
/**
|
package/lib/memory/scan.js
CHANGED
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
import { MAX_FILE_BYTES, MEMORY_DIR } from './config.js'
|
|
14
14
|
import { parseBaseline, parseFrontmatter } from './frontmatter.js'
|
|
15
|
-
import { isMemoryEntry, isReserved } from './naming.js'
|
|
15
|
+
import { isMemoryEntry, isReserved, nameKey } from './naming.js'
|
|
16
|
+
import { readExternalSettings } from '../settings.js'
|
|
17
|
+
import { readLockState } from './lock.js'
|
|
18
|
+
import { revisionOf } from './write-protocol.js'
|
|
19
|
+
import { exposedByOf } from '../mirror/policy.js'
|
|
16
20
|
import { warnLog } from './util.js'
|
|
17
21
|
import { createDirWatcher } from './watch.js'
|
|
18
22
|
import { CHECKPOINT_FILE_NAME, TASKS_DIR_NAME, TODO_SECTION, itemsOf, normalizeTaskId, parseCheckpoint } from './checkpoint.js'
|
|
@@ -721,4 +725,51 @@ export async function scanCheckpointOpen(stateRoot) {
|
|
|
721
725
|
const out = { ok: true, tasks, truncated: truncated || itemsTruncated }
|
|
722
726
|
if (skipped > 0) out.skipped = skipped
|
|
723
727
|
return out
|
|
724
|
-
}
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* 列出记忆目录里的全部条目(2.30.0 从 `lib/index.js` 的 `MemoryGateway.listFiles` 搬来)。
|
|
731
|
+
*
|
|
732
|
+
* 为什么搬:组合根有「本地 import 条数 ≤ 20」的硬线,再加一条就 21 —— 而这里
|
|
733
|
+
* 本来就在组合根的 import 名单里,把函数挂过来不增加条数。
|
|
734
|
+
*
|
|
735
|
+
* 比原来多的一件事是 `exposedBy`:面板的勾选框不再自己算「这条在不在外部访问白名单里」,
|
|
736
|
+
* 而是直接用后端结论。判据只有 `mirror/policy.js` 的 `exposedByOf` 一处 ——
|
|
737
|
+
* 前端那份复制品曾经漏掉 `tags` 维度、大小写口径也不同。
|
|
738
|
+
*
|
|
739
|
+
* @param {object} ctx — 宿主上下文(只用 `warnLog`)
|
|
740
|
+
* @param {string} memoryDir — 记忆目录
|
|
741
|
+
* @returns {Promise<Array<object>>}
|
|
742
|
+
*/
|
|
743
|
+
export async function listMemoryFiles(ctx, memoryDir) {
|
|
744
|
+
const [files, lockState, externalRead] = await Promise.all([
|
|
745
|
+
scanMemoryFiles(ctx, ''),
|
|
746
|
+
readLockState(memoryDir),
|
|
747
|
+
// 设置读不出来不该让列表整个失败:退化成「一条都不在白名单里」,面板仍能显示文件。
|
|
748
|
+
readExternalSettings().catch(() => ({ external: null, diagnostics: [] })),
|
|
749
|
+
])
|
|
750
|
+
const external = externalRead && externalRead.external ? externalRead.external : null
|
|
751
|
+
|
|
752
|
+
// Q05:锁表坏了也照样列文件,但不假装「都没锁」;逐条 locked 只有布尔,未知只能靠日志。
|
|
753
|
+
if (lockState.status === 'unknown') {
|
|
754
|
+
warnLog(ctx, `锁表不可读,列表里的锁定状态未知(不是「都没锁」):${lockState.reason}`)
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
return files.map(f => {
|
|
758
|
+
const meta = parseFrontmatter(f.content)
|
|
759
|
+
return {
|
|
760
|
+
file: f.file,
|
|
761
|
+
type: meta.type || 'reference',
|
|
762
|
+
description: meta.description || '',
|
|
763
|
+
size: f.content.length,
|
|
764
|
+
tags: meta.tags,
|
|
765
|
+
// 2.21.0:删除确认必须能交回「我看到的是哪一版」。与 readFile 用同一个
|
|
766
|
+
// 正文字节 sha256(write-protocol.revisionOf),名字不再是身份。
|
|
767
|
+
revision: revisionOf(Buffer.from(f.content, 'utf8')),
|
|
768
|
+
// 锁定状态跟着每条一起给:卡片上的「锁定 / 已锁定」按钮要据此渲染
|
|
769
|
+
locked: lockState.status === 'unknown' ? false : lockState.locked.has(nameKey(f.file)),
|
|
770
|
+
// 2.30.0:`'exclude' | 'include' | 'prefix' | 'tag' | 'none'`。
|
|
771
|
+
// **不看总开关** —— 关着的时候面板仍要按「意图」把勾选画出来(2.29.0 定的语义)。
|
|
772
|
+
exposedBy: exposedByOf(f.file, meta.tags, external),
|
|
773
|
+
}
|
|
774
|
+
})
|
|
775
|
+
}
|
package/lib/mirror/policy.js
CHANGED
|
@@ -224,31 +224,54 @@ export function parseExternalPatch(external) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
|
-
*
|
|
227
|
+
* 一条记忆**凭什么**算在白名单里 —— `'exclude' | 'include' | 'prefix' | 'tag' | 'none'`。
|
|
228
228
|
*
|
|
229
|
-
* 优先级(先命中先返回):逐条排除 > 逐条包含 > 前缀 > 标签 >
|
|
229
|
+
* 优先级(先命中先返回):逐条排除 > 逐条包含 > 前缀 > 标签 > 不在白名单。
|
|
230
230
|
* `exclude` 压过一切是刻意的:面板上「取消勾选」必须能压过「`project_` 整类打开」,
|
|
231
231
|
* 否则用户会看到一个关不掉的开关。
|
|
232
232
|
*
|
|
233
|
+
* ⚠️ **本函数不看 `enabled`**。它回答的是「设置上算不算」,不是「现在导不导」。
|
|
234
|
+
* 面板的勾选框要的正是这个:总开关关着的时候,用户仍然可以先勾名单,打开即生效
|
|
235
|
+
* (2.29.0 定的语义)。「现在导不导」由 `isExposed` 负责。
|
|
236
|
+
*
|
|
233
237
|
* @param {string} name — 文件名(`project_x.md`)
|
|
234
238
|
* @param {string[]} [tags] — 该条 frontmatter 的 tags
|
|
235
239
|
* @param {object} external — `resolveExternal` 的产物
|
|
240
|
+
* @returns {'exclude'|'include'|'prefix'|'tag'|'none'}
|
|
236
241
|
*/
|
|
237
|
-
export function
|
|
238
|
-
if (!external
|
|
242
|
+
export function exposedByOf(name, tags, external) {
|
|
243
|
+
if (!external) return 'none'
|
|
239
244
|
const file = String(name ?? '')
|
|
240
|
-
if (file === '') return
|
|
245
|
+
if (file === '') return 'none'
|
|
241
246
|
// 前缀只是「看起来像」,名字本身还得是**单段 .md**:`project_../../etc/passwd` 以
|
|
242
247
|
// `project_` 开头,但它不是一个记忆名。导出层拿到的名字来自 `scan.js`(已经过滤过),
|
|
243
248
|
// 这道判定是给面板逐条勾选与将来的调用方兜底的 —— 判据只有一份,就别指望上游一定干净。
|
|
244
|
-
if (!isPlainMdName(file)) return
|
|
249
|
+
if (!isPlainMdName(file)) return 'none'
|
|
245
250
|
const lower = file.toLowerCase()
|
|
246
|
-
if ((external.exclude ?? []).some((n) => String(n).toLowerCase() === lower)) return
|
|
247
|
-
if ((external.include ?? []).some((n) => String(n).toLowerCase() === lower)) return
|
|
248
|
-
if ((external.prefixes ?? []).some((p) => lower.startsWith(String(p).toLowerCase()))) return
|
|
251
|
+
if ((external.exclude ?? []).some((n) => String(n).toLowerCase() === lower)) return 'exclude'
|
|
252
|
+
if ((external.include ?? []).some((n) => String(n).toLowerCase() === lower)) return 'include'
|
|
253
|
+
if ((external.prefixes ?? []).some((p) => lower.startsWith(String(p).toLowerCase()))) return 'prefix'
|
|
249
254
|
const own = (Array.isArray(tags) ? tags : []).map((t) => String(t).toLowerCase())
|
|
250
|
-
if (own.length && (external.tags ?? []).some((t) => own.includes(String(t).toLowerCase()))) return
|
|
251
|
-
return
|
|
255
|
+
if (own.length && (external.tags ?? []).some((t) => own.includes(String(t).toLowerCase()))) return 'tag'
|
|
256
|
+
return 'none'
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* 一条记忆**现在**要不要被导出 —— **唯一判据**。
|
|
261
|
+
*
|
|
262
|
+
* 2026-12-04 起它只是 `exposedByOf` + 总开关:原因与「导不导」共用同一张优先级表,
|
|
263
|
+
* 不再各写一遍。面板也不再自己算(`listFiles` 会把 `exposedBy` 一起给出去)。
|
|
264
|
+
*
|
|
265
|
+
* @param {string} name — 文件名(`project_x.md`)
|
|
266
|
+
* @param {string[]} [tags] — 该条 frontmatter 的 tags
|
|
267
|
+
* @param {object} external — `resolveExternal` 的产物
|
|
268
|
+
*/
|
|
269
|
+
export function isExposed(name, tags, external) {
|
|
270
|
+
if (!external || !external.enabled) return false
|
|
271
|
+
const why = exposedByOf(name, tags, external)
|
|
272
|
+
// ⚠️ `'exclude'` 也是**不暴露** —— 它表示「这条被显式排除了」。
|
|
273
|
+
// 只写 `!== 'none'` 会把「被排除」判成「暴露」(2026-12-04 由 `mirror-policy-test` 抓到)。
|
|
274
|
+
return why !== 'none' && why !== 'exclude'
|
|
252
275
|
}
|
|
253
276
|
|
|
254
277
|
/**
|
package/lib/typert/schemas.js
CHANGED
|
@@ -74,6 +74,10 @@ export const fileSchema = z.object({
|
|
|
74
74
|
// 锁定状态(拒绝归档)跟着每条一起给 —— strict 会把没声明的字段剥掉,
|
|
75
75
|
// 不在这里声明,卡片上的「锁定 / 已锁定」按钮就永远拿到 undefined。
|
|
76
76
|
'locked': z.boolean().readonly(),
|
|
77
|
+
// 2.30.0:这条在外部访问白名单里的去向 —— 'exclude' | 'include' | 'prefix' | 'tag' | 'none'。
|
|
78
|
+
// 字段**可选**(additive 契约:只加不改)。面板据此画勾选,不再自己算判据 ——
|
|
79
|
+
// 前端那份复制品曾经漏掉 tags 维度,大小写口径也与后端不同。
|
|
80
|
+
'exposedBy': z.string().readonly().optional(),
|
|
77
81
|
}).readonly()
|
|
78
82
|
|
|
79
83
|
export const listResultSchema = z.array(fileSchema)
|
package/package.json
CHANGED