dsh-verbatim 0.1.0 → 0.1.1
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/CHANGELOG.md +14 -0
- package/LICENSE +1 -1
- package/README.en.md +24 -22
- package/README.md +24 -22
- package/bin/cli.mjs +2 -1
- package/bin/mcp-memory.mjs +130 -62
- package/client.js +8880 -8857
- package/cordis.patch.yml +1 -1
- package/docs/ARCHITECTURE.md +1 -1
- package/icon.svg +1 -1
- package/index.js +613 -2558
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -3
- package/src/config/exclude-range.js +1 -1
- package/src/config/global-config.js +3 -1
- package/src/config/session-config.js +12 -10
- package/src/config/session-config.test.js +375 -375
- package/src/derive/fact.js +6 -6
- package/src/derive/gist.js +2 -1
- package/src/host/config-views.js +2 -0
- package/src/host/db-admin.js +78 -15
- package/src/host/panel-api.js +1109 -0
- package/src/host/panel-http.js +322 -0
- package/src/host/panel-search.js +236 -0
- package/src/host/panel-session-store.js +411 -0
- package/src/host/rebuild.js +11 -3
- package/src/host/scene-ops.js +75 -6
- package/src/host/session-sync.js +91 -0
- package/src/index.js +2 -1
- package/src/ingest/cli.js +8 -7
- package/src/ingest/export.js +28 -18
- package/src/ingest/package.json +1 -1
- package/src/ingest/reader.js +181 -7
- package/src/model/embedding.js +3 -2
- package/src/model/llm.js +3 -2
- package/src/model/rerank.js +7 -4
- package/src/pipeline.js +159 -763
- package/src/scene/link.js +4 -4
- package/src/scene/package.json +1 -1
- package/src/scene/split.js +11 -11
- package/src/search/_fixtures.js +1 -0
- package/src/search/bench.js +4 -2
- package/src/search/chunk.js +6 -4
- package/src/search/dedupe.js +8 -8
- package/src/search/indexer.js +889 -879
- package/src/search/note-rank.js +64 -12
- package/src/search/regression.test.js +2 -1
- package/src/search/rrf.js +11 -11
- package/src/search/session-shape.js +3 -1
- package/src/search/thread.js +8 -8
- package/src/search/vector-fallback.js +509 -0
- package/src/search/vector-hydrate.js +309 -0
- package/src/search/vector-math.js +125 -0
- package/src/search/vector-store.js +1065 -1598
- package/src/search/vector-store.test.js +30 -0
- package/src/search/window.js +8 -8
- package/src/store/db.js +803 -715
- package/src/store/repo-extras-meta.js +430 -0
- package/src/store/repo-extras-search.js +580 -0
- package/src/store/repo.js +1024 -2133
- package/src/store/repo.test.js +39 -1
- package/src/store/schema.sql +15 -1
- package/src/tools/format.js +594 -503
- package/src/tools/index.js +7 -15
- package/src/tools/memory-forget.js +43 -32
- package/src/tools/memory-remember.js +11 -7
- package/src/tools/memory-search.js +721 -2206
- package/src/tools/remember-forget.test.js +19 -0
- package/src/tools/scope.js +7 -6
- package/src/tools/search-render.js +502 -0
- package/src/tools/time-route.js +71 -66
- package/src/tools/vector-route.js +655 -0
- package/sessions/qqb-p-0000000000-00000000000000000000000000000000.json +0 -12
package/locale/en.json
CHANGED
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-verbatim",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "一字不改的长期记忆 —— 给陪伴型 Agent 记住你们说过的每一句话",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,8 +55,7 @@
|
|
|
55
55
|
"icon.svg",
|
|
56
56
|
"README.md",
|
|
57
57
|
"CHANGELOG.md",
|
|
58
|
-
"LICENSE"
|
|
59
|
-
"sessions/qqb-p-0000000000-00000000000000000000000000000000.json"
|
|
58
|
+
"LICENSE"
|
|
60
59
|
],
|
|
61
60
|
"keywords": [
|
|
62
61
|
"dsh",
|
|
@@ -329,7 +329,7 @@ function toNormalized(ranges, opts) {
|
|
|
329
329
|
* @param {Array<{from:unknown,to:unknown,reason?:string}>|Array<{from:number,to:number}>} ranges
|
|
330
330
|
* 配置原样(字符串)或归一化后的都行
|
|
331
331
|
* @param {{ path?: string }} [opts]
|
|
332
|
-
* @returns {{from:number, to:number, reason
|
|
332
|
+
* @returns {{from:number, to:number, reason?:string|null}|null} 命中返回该区间,否则 null
|
|
333
333
|
* @throws {ConfigError} 区间非法时(配置错误必须抛,不能静默不排除)
|
|
334
334
|
*/
|
|
335
335
|
export function findRange(at, ranges, opts = {}) {
|
|
@@ -76,7 +76,7 @@ export const DEFAULT_GLOBAL_CONFIG = Object.freeze({
|
|
|
76
76
|
apiKey: '',
|
|
77
77
|
/** 兼容从环境变量读 Key(apiKey 为空时才用) */
|
|
78
78
|
apiKeyEnv: '',
|
|
79
|
-
/** 参与精排的候选条数上限(默认 50
|
|
79
|
+
/** 参与精排的候选条数上限(默认 50,保证紧凑候选池全池重排) */
|
|
80
80
|
topN: 50,
|
|
81
81
|
/** 超时毫秒(超时自动降级回 RRF 原序) */
|
|
82
82
|
timeoutMs: 8000,
|
|
@@ -88,6 +88,8 @@ export const DEFAULT_GLOBAL_CONFIG = Object.freeze({
|
|
|
88
88
|
defaultLimit: 8,
|
|
89
89
|
/** 单次最多返回几条 */
|
|
90
90
|
maxLimit: 50,
|
|
91
|
+
/** 固定时区偏移(分钟,默认 480 = UTC+8 Asia/Shanghai;设为 null 回退默认 +480) */
|
|
92
|
+
timezoneOffsetMinutes: 480,
|
|
91
93
|
}),
|
|
92
94
|
|
|
93
95
|
/** 索引 */
|
|
@@ -194,20 +194,22 @@ export function validateSessionConfig(input, opts = {}) {
|
|
|
194
194
|
out[key] = v;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
/** @type {any} */
|
|
198
|
+
const inputObj = input;
|
|
199
|
+
out.excludeRanges = sanitizeExcludeRanges(inputObj.excludeRanges, `${at}.excludeRanges`);
|
|
198
200
|
|
|
199
201
|
// 未知字段原样保留(写回时不丢),只在需要时告警
|
|
200
202
|
const unknown = [];
|
|
201
|
-
for (const key of Object.keys(
|
|
203
|
+
for (const key of Object.keys(inputObj)) {
|
|
202
204
|
if (CONFIG_KEYS.includes(key)) continue;
|
|
203
|
-
out[key] =
|
|
205
|
+
out[key] = inputObj[key];
|
|
204
206
|
unknown.push(key);
|
|
205
207
|
}
|
|
206
208
|
if (unknown.length && onWarn) {
|
|
207
209
|
onWarn(`${at}:有未知配置项 ${unknown.map((k) => JSON.stringify(k)).join(', ')},已保留但不会被使用`);
|
|
208
210
|
}
|
|
209
211
|
|
|
210
|
-
return out;
|
|
212
|
+
return /** @type {{ record: boolean, tools: boolean, autoRecall: boolean, excludeRanges: any[] }} */ (out);
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
/**
|
|
@@ -222,8 +224,8 @@ export function validateSessionConfig(input, opts = {}) {
|
|
|
222
224
|
function sanitizeExcludeRanges(raw, at) {
|
|
223
225
|
if (raw === undefined || raw === null) return [];
|
|
224
226
|
// 复用严格校验:抛错即配置非法;返回值只用于校验,不写回配置
|
|
225
|
-
normalizeRanges(raw, { path: at });
|
|
226
|
-
return raw.map((r) => {
|
|
227
|
+
normalizeRanges(/** @type {any} */ (raw), { path: at });
|
|
228
|
+
return /** @type {any[]} */ (raw).map((r) => {
|
|
227
229
|
const item = { from: r.from, to: r.to };
|
|
228
230
|
if (typeof r.reason === 'string' && r.reason.trim()) item.reason = r.reason.trim();
|
|
229
231
|
return item;
|
|
@@ -240,7 +242,7 @@ function sanitizeExcludeRanges(raw, at) {
|
|
|
240
242
|
*/
|
|
241
243
|
export function loadSessionConfig(sessionId, opts = {}) {
|
|
242
244
|
const file = sessionConfigPath(sessionId, opts);
|
|
243
|
-
const onWarn = typeof opts
|
|
245
|
+
const onWarn = typeof opts === 'object' && opts !== null && typeof opts.onWarn === 'function' ? opts.onWarn : undefined;
|
|
244
246
|
|
|
245
247
|
if (!fs.existsSync(file)) return defaultSessionConfig();
|
|
246
248
|
|
|
@@ -286,7 +288,7 @@ export function loadSessionConfig(sessionId, opts = {}) {
|
|
|
286
288
|
*/
|
|
287
289
|
export function saveSessionConfig(sessionId, patch, opts = {}) {
|
|
288
290
|
const file = sessionConfigPath(sessionId, opts);
|
|
289
|
-
const onWarn = typeof opts
|
|
291
|
+
const onWarn = typeof opts === 'object' && opts !== null && typeof opts.onWarn === 'function' ? opts.onWarn : undefined;
|
|
290
292
|
|
|
291
293
|
if (patch !== undefined && patch !== null && (typeof patch !== 'object' || Array.isArray(patch))) {
|
|
292
294
|
throw new ConfigError(`saveSessionConfig 的 patch 必须是对象,实际是 ${typeName(patch)}`, {
|
|
@@ -370,7 +372,7 @@ export function setSessionExcludeRanges(sessionId, ranges, opts = {}) {
|
|
|
370
372
|
*/
|
|
371
373
|
export function loadSessionExcludeRanges(sessionId, opts = {}) {
|
|
372
374
|
const cfg = loadSessionConfig(sessionId, opts);
|
|
373
|
-
return normalizeRanges(cfg.excludeRanges, { path: `${sessionConfigPath(sessionId, opts)}.excludeRanges` });
|
|
375
|
+
return normalizeRanges(/** @type {any} */ (cfg.excludeRanges), { path: `${sessionConfigPath(sessionId, opts)}.excludeRanges` });
|
|
374
376
|
}
|
|
375
377
|
|
|
376
378
|
/**
|
|
@@ -398,7 +400,7 @@ export function ensureSessionConfig(sessionId, opts = {}) {
|
|
|
398
400
|
* 面板 `panel.status → enabled` 的形状(PANEL.md §5)。
|
|
399
401
|
* `autoRecall` 恒带在返回值里(协议稳定),但面板不渲染开关(D-166)。
|
|
400
402
|
*
|
|
401
|
-
* @param {
|
|
403
|
+
* @param {any} cfg
|
|
402
404
|
* @returns {{ record: boolean, tools: boolean, autoRecall: boolean }}
|
|
403
405
|
*/
|
|
404
406
|
export function enabledOf(cfg) {
|