@kenz1117/dsh-engram 0.13.4 → 0.13.6
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 +19 -0
- package/README.md +3 -1
- package/i18n/ru.txt +5 -0
- package/lib/client.js +1 -1
- package/lib/client.js.map +1 -1
- package/lib/index.js +241 -4
- package/package.json +2 -1
- package/scripts/check-css-classes.mjs +85 -0
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { cpSync, createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { BlockAssembler, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
5
5
|
import { homedir } from "node:os";
|
|
@@ -540,6 +540,11 @@ const zh$2 = {
|
|
|
540
540
|
"store.migrationDbNames": "旧库 {legacy};新库 {next}",
|
|
541
541
|
"store.migrationManualGuidance": "人工处理前请停止相关宿主并备份所有数据库及 sidecar;新库可能已写入记忆,请勿直接覆盖,先用 engram_review / engram_export 审核并人工重新归属",
|
|
542
542
|
"store.migrationRenamed": "[dsh-engram] 项目记忆库已迁移({names}),已记录 .migrated-to;旧库可能包含同前缀目录的记忆。{manual}",
|
|
543
|
+
"store.homeAdoptionMoved": "[dsh-engram] 数据目录已随宿主数据根搬到 {to}(原 {from})。记忆库、词典与模型缓存一并搬走。",
|
|
544
|
+
"store.homeAdoptionCopied": "[dsh-engram] 数据目录已复制到 {to}(原 {from},跨盘无法直接改名);旧目录已在校验后删除。",
|
|
545
|
+
"store.homeAdoptionDeferred": "[dsh-engram] conservative 模式暂缓收编:数据仍在 {from},本次继续使用旧目录。",
|
|
546
|
+
"store.homeAdoptionKeptBoth": "[dsh-engram] 两处都有记忆库({from} 与 {to}):未自动合并,本次继续使用旧目录 {from},请人工确认后清理。",
|
|
547
|
+
"store.homeAdoptionFailed": "[dsh-engram] 数据目录收编失败({from} → {to}):{detail};本次继续使用旧目录,数据未丢失。",
|
|
543
548
|
"store.migrationKeptBoth": "[dsh-engram] 新旧项目记忆库并存,未合并或移动({names})。{manual}",
|
|
544
549
|
"store.migrationDeferred": "[dsh-engram] conservative 模式暂缓旧库迁移({names});旧库保持不变,将打开新的空库。{manual}",
|
|
545
550
|
"store.migrationAlreadyMigrated": "[dsh-engram] 旧库已有迁移记录({names},先前归属 {cwd}):{pointer};先前迁移的库可能含有当前目录的记忆。{manual}",
|
|
@@ -587,6 +592,11 @@ const en$2 = {
|
|
|
587
592
|
"store.migrationDbNames": "old database {legacy}; new database {next}",
|
|
588
593
|
"store.migrationManualGuidance": "before handling this manually, stop the affected hosts and back up every database and sidecar; the new database may already contain memories, so do not overwrite it — review it with engram_review / engram_export and re-assign ownership by hand",
|
|
589
594
|
"store.migrationRenamed": "[dsh-engram] the project memory database was migrated ({names}) and .migrated-to was recorded; the old database may hold memories of directories sharing the same prefix. {manual}",
|
|
595
|
+
"store.homeAdoptionMoved": "[dsh-engram] the data directory moved with the harness home to {to} (was {from}); memories, dictionaries and the model cache moved along.",
|
|
596
|
+
"store.homeAdoptionCopied": "[dsh-engram] the data directory was copied to {to} (was {from}; a cross-device move cannot be a rename); the old directory was removed after verification.",
|
|
597
|
+
"store.homeAdoptionDeferred": "[dsh-engram] conservative mode deferred the adoption: the data is still in {from}, and that directory is used for now.",
|
|
598
|
+
"store.homeAdoptionKeptBoth": "[dsh-engram] both locations hold memory databases ({from} and {to}); nothing was merged automatically, the old directory {from} is used for now — confirm and clean up by hand.",
|
|
599
|
+
"store.homeAdoptionFailed": "[dsh-engram] the data directory adoption failed ({from} → {to}): {detail}; the old directory is used for now and no data was lost.",
|
|
590
600
|
"store.migrationKeptBoth": "[dsh-engram] old and new project memory databases coexist; neither was merged nor moved ({names}). {manual}",
|
|
591
601
|
"store.migrationDeferred": "[dsh-engram] conservative mode deferred the legacy database migration ({names}); the old database is left untouched and a new empty one will be opened. {manual}",
|
|
592
602
|
"store.migrationAlreadyMigrated": "[dsh-engram] the legacy database already has a migration record ({names}, claimed earlier by {cwd}): {pointer}; the database migrated earlier may hold memories of the current directory. {manual}",
|
|
@@ -1460,6 +1470,20 @@ function noteLegacyJevFields(where, fields) {
|
|
|
1460
1470
|
* 插件 Config:所有部署可变项集中于此,禁止在实现里内嵌默认值。
|
|
1461
1471
|
* @module @kenz1117/dsh-engram/config
|
|
1462
1472
|
*/
|
|
1473
|
+
/**
|
|
1474
|
+
* 宿主数据根目录:`$DSH_HOME`,缺省 `~/.dsh`。
|
|
1475
|
+
*
|
|
1476
|
+
* 契约抄自宿主的 `@deepseek-ai/dsh-home-paths`(resolveDshHome):显式值 > `$DSH_HOME`
|
|
1477
|
+
* > `~/.dsh`;空白或只有空格的 `$DSH_HOME` 视同未设置(否则 home 会被解析成当前目录)。
|
|
1478
|
+
* 插件不直接依赖那个包——它是可选 peer,缺了不能让插件起不来;语义保持一致即可。
|
|
1479
|
+
* @param env - 环境变量映射(默认 `process.env`)。
|
|
1480
|
+
* @returns 绝对路径形式的数据根目录。
|
|
1481
|
+
*/
|
|
1482
|
+
function resolveDshHome(env = process.env) {
|
|
1483
|
+
const fromEnv = env.DSH_HOME;
|
|
1484
|
+
const home = fromEnv !== void 0 && fromEnv.trim() !== "" ? fromEnv : join(homedir(), ".dsh");
|
|
1485
|
+
return resolve(home);
|
|
1486
|
+
}
|
|
1463
1487
|
/** 合法配置键集合(未知键 loud 失败)。 */
|
|
1464
1488
|
const CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
1465
1489
|
"legacyMigration",
|
|
@@ -1660,9 +1684,14 @@ function resolveConfig(config = {}) {
|
|
|
1660
1684
|
if (baseUrl === void 0 || baseUrl === "") throw new Error("dsh-engram: embedder.kind=remote requires embedder.baseUrl");
|
|
1661
1685
|
}
|
|
1662
1686
|
}
|
|
1663
|
-
const
|
|
1687
|
+
const dshHome = resolveDshHome();
|
|
1688
|
+
const legacyDbDir = join(homedir(), ".dsh", "engram");
|
|
1689
|
+
const dbDir = config.dbDir ?? join(dshHome, "engram");
|
|
1664
1690
|
return {
|
|
1665
1691
|
dbDir,
|
|
1692
|
+
dshHome,
|
|
1693
|
+
dbDirExplicit: config.dbDir !== void 0,
|
|
1694
|
+
legacyDbDir,
|
|
1666
1695
|
legacyMigration: config.legacyMigration ?? "eager",
|
|
1667
1696
|
injectProfile: config.injectProfile ?? true,
|
|
1668
1697
|
profileTopN: config.profileTopN ?? 8,
|
|
@@ -2504,6 +2533,8 @@ const en = {
|
|
|
2504
2533
|
systemJobEmpty: "The queue is empty: nothing pending and nothing failed.",
|
|
2505
2534
|
systemStorageTotal: "Total",
|
|
2506
2535
|
systemStorageScope: "Store",
|
|
2536
|
+
systemStorageHome: "Harness home",
|
|
2537
|
+
systemStorageOutsideHome: "The data directory sits outside the harness home: the memory database stays where it is and will not follow a relocated home.",
|
|
2507
2538
|
systemStorageActive: "Active",
|
|
2508
2539
|
systemStorageArchived: "Archived",
|
|
2509
2540
|
systemStorageForgotten: "Forgotten",
|
|
@@ -3160,6 +3191,8 @@ const ru = {
|
|
|
3160
3191
|
systemJobEmpty: "Очередь пуста: ни ждущих, ни упавших заданий.",
|
|
3161
3192
|
systemStorageTotal: "Всего",
|
|
3162
3193
|
systemStorageScope: "База",
|
|
3194
|
+
systemStorageHome: "Дом Harness",
|
|
3195
|
+
systemStorageOutsideHome: "Каталог данных лежит вне дома Harness: база памяти остаётся на месте и не переедёт вместе с домом.",
|
|
3163
3196
|
systemStorageActive: "Активные",
|
|
3164
3197
|
systemStorageArchived: "В архиве",
|
|
3165
3198
|
systemStorageForgotten: "Забытые",
|
|
@@ -3814,6 +3847,8 @@ const zh = {
|
|
|
3814
3847
|
systemJobEmpty: "队列为空:没有待处理、也没有失败的作业。",
|
|
3815
3848
|
systemStorageTotal: "总条数",
|
|
3816
3849
|
systemStorageScope: "库",
|
|
3850
|
+
systemStorageHome: "宿主数据根",
|
|
3851
|
+
systemStorageOutsideHome: "数据目录不在宿主数据根之下:记忆库落在别处,迁移 home 时不会跟着走。",
|
|
3817
3852
|
systemStorageActive: "活跃",
|
|
3818
3853
|
systemStorageArchived: "归档",
|
|
3819
3854
|
systemStorageForgotten: "已遗忘",
|
|
@@ -10731,6 +10766,19 @@ var UnknownProjectError = class extends Error {
|
|
|
10731
10766
|
this.name = "UnknownProjectError";
|
|
10732
10767
|
}
|
|
10733
10768
|
};
|
|
10769
|
+
/** 管理面板的路由依赖。 */
|
|
10770
|
+
/**
|
|
10771
|
+
* 路径是否位于某个根之下(用于「数据目录在不在 home 之下」这类判断)。
|
|
10772
|
+
* @param child - 待判断的路径。
|
|
10773
|
+
* @param root - 根目录。
|
|
10774
|
+
* @returns true 表示 child 位于 root 之内(含 root 自身)。
|
|
10775
|
+
*/
|
|
10776
|
+
function isInside(child, root) {
|
|
10777
|
+
const from = resolve(root);
|
|
10778
|
+
const to = resolve(child);
|
|
10779
|
+
if (to === from) return true;
|
|
10780
|
+
return to.startsWith(from.endsWith(sep) ? from : `${from}${sep}`);
|
|
10781
|
+
}
|
|
10734
10782
|
/**
|
|
10735
10783
|
* 注册 /engram 页面与 /api/engram/* 接口(effect 由调用方持有,disposer 可逆)。
|
|
10736
10784
|
* @param ctx - 携带 webServer 服务的宿主上下文。
|
|
@@ -11165,6 +11213,8 @@ function registerEngramRoutes(ctx, deps) {
|
|
|
11165
11213
|
const allTrue = (key) => parts.length > 0 && parts.every((part) => part[key] === true);
|
|
11166
11214
|
json(res, 200, {
|
|
11167
11215
|
dir: deps.dbDir,
|
|
11216
|
+
home: deps.dshHome,
|
|
11217
|
+
outsideHome: !isInside(deps.dbDir, deps.dshHome),
|
|
11168
11218
|
keepOps: LOG_KEEP_OPS,
|
|
11169
11219
|
parts,
|
|
11170
11220
|
totals: {
|
|
@@ -12962,6 +13012,157 @@ function findProjectPalace(palaces, selector) {
|
|
|
12962
13012
|
}
|
|
12963
13013
|
return palaces.find((palace) => palace.kind === "process") ?? palaces[0];
|
|
12964
13014
|
}
|
|
13015
|
+
// src/store/home-adoption.ts
|
|
13016
|
+
/**
|
|
13017
|
+
* 旧数据目录的收编(#51):DSH_HOME 迁移之后,别让记忆库分裂成两份。
|
|
13018
|
+
*
|
|
13019
|
+
* 背景:数据目录默认值此前写死 `~/.dsh/engram`,不看宿主的 `$DSH_HOME`。把 home
|
|
13020
|
+
* 搬到别的盘之后,插件的数据仍然静默留在旧盘上;人以为在用新盘,其实读的是旧盘。
|
|
13021
|
+
* 默认值改成跟 `$DSH_HOME` 之后又来一个坑:旧盘上的库会被留在原地,插件却开始读
|
|
13022
|
+
* 新盘——于是「库不见了」。这里做的就是把那一份搬到新盘去。
|
|
13023
|
+
*
|
|
13024
|
+
* 规矩:
|
|
13025
|
+
* - 显式配置了 `dbDir` 的人自己说了算,这里一个字都不动;
|
|
13026
|
+
* - 目标目录已经有库 → 两边都有数据,不自动合并,保留旧目录继续用(人的记忆在那儿),
|
|
13027
|
+
* 并明确报出两个路径让人处理;
|
|
13028
|
+
* - 搬运失败 → 仍然用旧目录。数据看不见比数据待在新盘上更糟;
|
|
13029
|
+
* - 跨盘(EXDEV)先复制到临时目录、逐个文件核对大小,确认无误才改名并删旧,
|
|
13030
|
+
* 任何一步出错都不删旧目录。
|
|
13031
|
+
*
|
|
13032
|
+
* @module @kenz1117/dsh-engram/store/home-adoption
|
|
13033
|
+
*/
|
|
13034
|
+
/** 目录里是否有数据库文件(记忆库本体;只有字典/模型不算“有库”)。 */
|
|
13035
|
+
function hasDatabase(dir) {
|
|
13036
|
+
if (!existsSync(dir)) return false;
|
|
13037
|
+
let entries;
|
|
13038
|
+
try {
|
|
13039
|
+
entries = readdirSync(dir);
|
|
13040
|
+
} catch {
|
|
13041
|
+
return false;
|
|
13042
|
+
}
|
|
13043
|
+
return entries.some((name) => name.endsWith(".db"));
|
|
13044
|
+
}
|
|
13045
|
+
/** 目录是否为空(没有任何条目)。 */
|
|
13046
|
+
function isEmptyDir(dir) {
|
|
13047
|
+
if (!existsSync(dir)) return true;
|
|
13048
|
+
try {
|
|
13049
|
+
return readdirSync(dir).length === 0;
|
|
13050
|
+
} catch {
|
|
13051
|
+
return false;
|
|
13052
|
+
}
|
|
13053
|
+
}
|
|
13054
|
+
/** 递归列出相对路径与字节数(复制后的核对依据)。 */
|
|
13055
|
+
function fileSizes(dir) {
|
|
13056
|
+
const out = /* @__PURE__ */ new Map();
|
|
13057
|
+
const walk = (current, prefix) => {
|
|
13058
|
+
for (const name of readdirSync(current)) {
|
|
13059
|
+
const full = join(current, name);
|
|
13060
|
+
const rel = prefix === "" ? name : `${prefix}/${name}`;
|
|
13061
|
+
const stat = statSync(full);
|
|
13062
|
+
if (stat.isDirectory()) walk(full, rel);
|
|
13063
|
+
else out.set(rel, stat.size);
|
|
13064
|
+
}
|
|
13065
|
+
};
|
|
13066
|
+
walk(dir, "");
|
|
13067
|
+
return out;
|
|
13068
|
+
}
|
|
13069
|
+
/** 两份目录的文件清单与大小是否一致。 */
|
|
13070
|
+
function sameContent(a, b) {
|
|
13071
|
+
const left = fileSizes(a);
|
|
13072
|
+
const right = fileSizes(b);
|
|
13073
|
+
if (left.size !== right.size) return false;
|
|
13074
|
+
for (const [name, size] of left) if (right.get(name) !== size) return false;
|
|
13075
|
+
return true;
|
|
13076
|
+
}
|
|
13077
|
+
/**
|
|
13078
|
+
* 决定并(必要时)执行旧目录收编。
|
|
13079
|
+
* @param target - 新数据目录(`$DSH_HOME/engram` 或显式配置)。
|
|
13080
|
+
* @param legacy - 旧默认目录(`~/.dsh/engram`)。
|
|
13081
|
+
* @param policy - 迁移策略:`eager` 自动搬,`conservative` 只报不动。
|
|
13082
|
+
* @returns 实际应使用的目录与搬运结果。
|
|
13083
|
+
*/
|
|
13084
|
+
function adoptLegacyDbDir(options) {
|
|
13085
|
+
const { target, legacy, policy } = options;
|
|
13086
|
+
const base = { legacyDbDir: legacy };
|
|
13087
|
+
if (target === legacy) return {
|
|
13088
|
+
...base,
|
|
13089
|
+
dbDir: target,
|
|
13090
|
+
outcome: "none"
|
|
13091
|
+
};
|
|
13092
|
+
if (!hasDatabase(legacy)) return {
|
|
13093
|
+
...base,
|
|
13094
|
+
dbDir: target,
|
|
13095
|
+
outcome: "none"
|
|
13096
|
+
};
|
|
13097
|
+
if (hasDatabase(target)) return {
|
|
13098
|
+
...base,
|
|
13099
|
+
dbDir: legacy,
|
|
13100
|
+
outcome: "kept-both"
|
|
13101
|
+
};
|
|
13102
|
+
if (policy === "conservative") return {
|
|
13103
|
+
...base,
|
|
13104
|
+
dbDir: legacy,
|
|
13105
|
+
outcome: "deferred"
|
|
13106
|
+
};
|
|
13107
|
+
try {
|
|
13108
|
+
if (isEmptyDir(target) && existsSync(target)) rmSync(target, {
|
|
13109
|
+
recursive: true,
|
|
13110
|
+
force: true
|
|
13111
|
+
});
|
|
13112
|
+
renameSync(legacy, target);
|
|
13113
|
+
return {
|
|
13114
|
+
...base,
|
|
13115
|
+
dbDir: target,
|
|
13116
|
+
outcome: "moved"
|
|
13117
|
+
};
|
|
13118
|
+
} catch (error) {
|
|
13119
|
+
if (error.code !== "EXDEV") return {
|
|
13120
|
+
...base,
|
|
13121
|
+
dbDir: legacy,
|
|
13122
|
+
outcome: "failed",
|
|
13123
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
13124
|
+
};
|
|
13125
|
+
}
|
|
13126
|
+
const staging = `${target}.adopting`;
|
|
13127
|
+
try {
|
|
13128
|
+
rmSync(staging, {
|
|
13129
|
+
recursive: true,
|
|
13130
|
+
force: true
|
|
13131
|
+
});
|
|
13132
|
+
mkdirSync(join(staging, ".."), { recursive: true });
|
|
13133
|
+
cpSync(legacy, staging, {
|
|
13134
|
+
recursive: true,
|
|
13135
|
+
errorOnExist: true,
|
|
13136
|
+
force: false
|
|
13137
|
+
});
|
|
13138
|
+
if (!sameContent(legacy, staging)) throw new Error("copied tree differs from the source (file list or size mismatch)");
|
|
13139
|
+
rmSync(target, {
|
|
13140
|
+
recursive: true,
|
|
13141
|
+
force: true
|
|
13142
|
+
});
|
|
13143
|
+
renameSync(staging, target);
|
|
13144
|
+
rmSync(legacy, {
|
|
13145
|
+
recursive: true,
|
|
13146
|
+
force: true
|
|
13147
|
+
});
|
|
13148
|
+
return {
|
|
13149
|
+
...base,
|
|
13150
|
+
dbDir: target,
|
|
13151
|
+
outcome: "copied"
|
|
13152
|
+
};
|
|
13153
|
+
} catch (error) {
|
|
13154
|
+
rmSync(staging, {
|
|
13155
|
+
recursive: true,
|
|
13156
|
+
force: true
|
|
13157
|
+
});
|
|
13158
|
+
return {
|
|
13159
|
+
...base,
|
|
13160
|
+
dbDir: legacy,
|
|
13161
|
+
outcome: "failed",
|
|
13162
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
13163
|
+
};
|
|
13164
|
+
}
|
|
13165
|
+
}
|
|
12965
13166
|
/** kind → базовый идентификатор комнаты. Фиксированное соответствие: однотипные
|
|
12966
13167
|
* записи всегда попадают в одну комнату. Идентификатор — это ДАННЫЕ, он пишется
|
|
12967
13168
|
* в память (slot_room) и не зависит от языка интерфейса; отображаемое имя берётся
|
|
@@ -18567,7 +18768,7 @@ function estimateTokens(text) {
|
|
|
18567
18768
|
return Math.ceil(wide * WIDE_TOKENS_PER_CHAR + narrow / 4);
|
|
18568
18769
|
}
|
|
18569
18770
|
// package.json
|
|
18570
|
-
var version = "0.13.
|
|
18771
|
+
var version = "0.13.6";
|
|
18571
18772
|
// src/index.ts
|
|
18572
18773
|
/**
|
|
18573
18774
|
* dsh-engram:DeepSeek Harness 跨会话长期记忆插件(host 半)。
|
|
@@ -19075,6 +19276,41 @@ function persistPalaceLanguage(ctx, language) {
|
|
|
19075
19276
|
*/
|
|
19076
19277
|
async function apply(ctx, config = {}) {
|
|
19077
19278
|
const resolvedConfig = resolveConfig(config);
|
|
19279
|
+
const adoption = resolvedConfig.dbDirExplicit ? {
|
|
19280
|
+
dbDir: resolvedConfig.dbDir,
|
|
19281
|
+
legacyDbDir: resolvedConfig.legacyDbDir,
|
|
19282
|
+
outcome: "none"
|
|
19283
|
+
} : adoptLegacyDbDir({
|
|
19284
|
+
target: resolvedConfig.dbDir,
|
|
19285
|
+
legacy: resolvedConfig.legacyDbDir,
|
|
19286
|
+
policy: resolvedConfig.legacyMigration
|
|
19287
|
+
});
|
|
19288
|
+
if (adoption.outcome === "moved") console.warn(message("store.homeAdoptionMoved", {
|
|
19289
|
+
from: adoption.legacyDbDir,
|
|
19290
|
+
to: adoption.dbDir
|
|
19291
|
+
}));
|
|
19292
|
+
if (adoption.outcome === "copied") console.warn(message("store.homeAdoptionCopied", {
|
|
19293
|
+
from: adoption.legacyDbDir,
|
|
19294
|
+
to: adoption.dbDir
|
|
19295
|
+
}));
|
|
19296
|
+
if (adoption.outcome === "deferred") console.warn(message("store.homeAdoptionDeferred", {
|
|
19297
|
+
from: adoption.legacyDbDir,
|
|
19298
|
+
to: adoption.dbDir
|
|
19299
|
+
}));
|
|
19300
|
+
if (adoption.outcome === "kept-both") console.warn(message("store.homeAdoptionKeptBoth", {
|
|
19301
|
+
from: adoption.legacyDbDir,
|
|
19302
|
+
to: adoption.dbDir
|
|
19303
|
+
}));
|
|
19304
|
+
if (adoption.outcome === "failed") console.warn(message("store.homeAdoptionFailed", {
|
|
19305
|
+
from: adoption.legacyDbDir,
|
|
19306
|
+
to: adoption.dbDir,
|
|
19307
|
+
detail: adoption.detail ?? ""
|
|
19308
|
+
}));
|
|
19309
|
+
const effectiveConfig = adoption.dbDir === resolvedConfig.dbDir ? resolvedConfig : {
|
|
19310
|
+
...resolvedConfig,
|
|
19311
|
+
dbDir: adoption.dbDir,
|
|
19312
|
+
...config.modelCacheDir === void 0 ? { modelCacheDir: join(adoption.dbDir, "models") } : {}
|
|
19313
|
+
};
|
|
19078
19314
|
const registry = loadRegistry({ dbDir: resolvedConfig.dbDir });
|
|
19079
19315
|
/** Что записано в настройке: `auto` — решения о языке дворца ещё нет. */
|
|
19080
19316
|
const languageSetting = readLanguageSetting(config.language);
|
|
@@ -19088,7 +19324,7 @@ async function apply(ctx, config = {}) {
|
|
|
19088
19324
|
if (!determination.decision.conflict) language = determination.decision.language;
|
|
19089
19325
|
}
|
|
19090
19326
|
const resolved = {
|
|
19091
|
-
...
|
|
19327
|
+
...effectiveConfig,
|
|
19092
19328
|
language,
|
|
19093
19329
|
languageSetting
|
|
19094
19330
|
};
|
|
@@ -20003,6 +20239,7 @@ async function apply(ctx, config = {}) {
|
|
|
20003
20239
|
exportDir: `${resolved.dbDir}/exports`,
|
|
20004
20240
|
mirrorDir: `${resolved.dbDir}/palaces`,
|
|
20005
20241
|
dbDir: resolved.dbDir,
|
|
20242
|
+
dshHome: resolved.dshHome,
|
|
20006
20243
|
pluginVersion: VERSION,
|
|
20007
20244
|
language: resolved.language,
|
|
20008
20245
|
panelAccess: resolved.panelAccess,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kenz1117/dsh-engram",
|
|
3
3
|
"description": "Local-first cross-session long-term memory for DeepSeek Harness: dual-scope SQLite stores, hybrid FTS5 + local-vector retrieval with RRF, an evidence gate, provenance audit and SM-2 spaced repetition. 23 narrow tools, zero external services, zero API keys.",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.6",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"logo": "icon-256.svg",
|
|
7
7
|
"publishConfig": {
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"lint": "biome check src tests",
|
|
61
61
|
"coverage": "vitest run --coverage",
|
|
62
62
|
"check:hooks": "node scripts/check-hook-order.mjs",
|
|
63
|
+
"check:css": "node scripts/check-css-classes.mjs",
|
|
63
64
|
"typecheck": "tsc --noEmit",
|
|
64
65
|
"backfill": "node scripts/backfill-embeddings.mjs"
|
|
65
66
|
},
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Проверка соответствия CSS-классов разметке.
|
|
4
|
+
*
|
|
5
|
+
* CSS Modules не проверяются типами: `styles.foo` напечатается как строка, а
|
|
6
|
+
* если правила для `.foo` нет — className станет "undefined" или класс просто
|
|
7
|
+
* не применится. Один раз так снесли базовое правило `.item` (сетка строки
|
|
8
|
+
* списка) вместе с половиной файла — и это не поймал ни один тест.
|
|
9
|
+
*
|
|
10
|
+
* Что проверяем:
|
|
11
|
+
* 1. каждый класс, который разметка берёт у CSS-модуля, имеет правило
|
|
12
|
+
* в каком-нибудь *.module.css клиента;
|
|
13
|
+
* 2. в клиентских стилях нет классов, которые никто не использует
|
|
14
|
+
* (информация, не ошибка: чистка стилей — отдельная задача).
|
|
15
|
+
*
|
|
16
|
+
* Запуск: node scripts/check-css-classes.mjs
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs'
|
|
20
|
+
import { join } from 'node:path'
|
|
21
|
+
|
|
22
|
+
const SRC = 'src/client'
|
|
23
|
+
|
|
24
|
+
/** Рекурсивно собирает файлы по расширению. */
|
|
25
|
+
function collect(dir, exts) {
|
|
26
|
+
const out = []
|
|
27
|
+
for (const name of readdirSync(dir)) {
|
|
28
|
+
const full = join(dir, name)
|
|
29
|
+
if (statSync(full).isDirectory()) out.push(...collect(full, exts))
|
|
30
|
+
else if (exts.some(ext => name.endsWith(ext))) out.push(full)
|
|
31
|
+
}
|
|
32
|
+
return out
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const styleFiles = collect(SRC, ['.css'])
|
|
36
|
+
const sourceFiles = collect(SRC, ['.ts', '.tsx'])
|
|
37
|
+
|
|
38
|
+
// 1. Какие классы вообще объявлены (в любом модуле клиента).
|
|
39
|
+
const declared = new Set()
|
|
40
|
+
for (const file of styleFiles) {
|
|
41
|
+
const css = readFileSync(file, 'utf8')
|
|
42
|
+
for (const match of css.matchAll(/\.([A-Za-z][A-Za-z0-9_-]*)/g)) declared.add(match[1])
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 2. Какие классы берёт разметка.
|
|
46
|
+
const used = new Map()
|
|
47
|
+
for (const file of sourceFiles) {
|
|
48
|
+
const text = readFileSync(file, 'utf8')
|
|
49
|
+
const found = new Set()
|
|
50
|
+
for (const match of text.matchAll(/styles\.([A-Za-z][A-Za-z0-9_]*)/g)) found.add(match[1])
|
|
51
|
+
for (const match of text.matchAll(/styles\[`([A-Za-z]+)[$`]/g)) found.add(match[1])
|
|
52
|
+
for (const name of found) {
|
|
53
|
+
if (!used.has(name)) used.set(name, [])
|
|
54
|
+
used.get(name).push(file)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Динамические имена (styles[`status${x}`]) требуют не точного класса,
|
|
59
|
+
// а хотя бы одного правила с таким префиксом.
|
|
60
|
+
const dynamic = new Set()
|
|
61
|
+
for (const file of sourceFiles) {
|
|
62
|
+
const text = readFileSync(file, 'utf8')
|
|
63
|
+
for (const match of text.matchAll(/styles\[`([A-Za-z]+)\$\{/g)) dynamic.add(match[1])
|
|
64
|
+
}
|
|
65
|
+
const hasPrefix = name => [...declared].some(declaredName => declaredName.startsWith(name))
|
|
66
|
+
|
|
67
|
+
const missing = [...used.entries()].filter(([name]) => {
|
|
68
|
+
if (declared.has(name)) return false
|
|
69
|
+
if (dynamic.has(name)) return !hasPrefix(name)
|
|
70
|
+
return true
|
|
71
|
+
}).sort()
|
|
72
|
+
if (missing.length > 0) {
|
|
73
|
+
for (const [name, files] of missing) {
|
|
74
|
+
console.error(` нет правила для класса «${name}» — его берёт ${[...new Set(files)].join(', ')}`)
|
|
75
|
+
}
|
|
76
|
+
console.error(`пропущено классов без правил: ${missing.length}`)
|
|
77
|
+
process.exit(1)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 3. Информация: объявленные, но не используемые классы (чистка — отдельная задача).
|
|
81
|
+
const unused = [...declared].filter(name => !used.has(name)).sort()
|
|
82
|
+
console.log(`классов в стилях: ${declared.size}; используется разметкой: ${used.size}; без правил: 0`)
|
|
83
|
+
if (unused.length > 0) {
|
|
84
|
+
console.log(`объявлено, но не используется (${unused.length}): ${unused.join(', ')}`)
|
|
85
|
+
}
|