dsh-memory-palace 1.8.3-alpha.1 → 1.8.3-alpha.2
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 +2 -0
- package/lib/hybrid/tools.mjs +21 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/hybrid/tools.mjs
CHANGED
|
@@ -88,14 +88,32 @@ export function registerHybridTools({ ctx, getConfig, paths, state }) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// 写入工具返回附一行体量回显(**仅回显、不拦截**),让 agent 具备体量感。
|
|
91
|
+
// 超预算时追加「超出字符数 + 重整门禁状态」指引,避免 agent 自行多轮精简替换凑数:
|
|
92
|
+
// - project 已冷却(含从未重整)→ 建议走 memory_reorganize 全量重整(只允许落盘一次);
|
|
93
|
+
// - project 冷却期内 → 明示项目记忆暂时不可压缩、超预算写入已认可;
|
|
94
|
+
// - user 级无全量重整机制 → 同样明示超预算写入已认可。
|
|
91
95
|
// 预算按 scope 取:project → workspaceBudgetChars;user → userBudgetChars
|
|
92
96
|
// (memory_write / memory_update_section 都有两个 scope,写用户级时用 workspace 会算错倍率)。
|
|
93
97
|
function sizeLine(scope, file, c) {
|
|
94
98
|
try {
|
|
95
|
-
const
|
|
99
|
+
const md = readMdSync(file);
|
|
100
|
+
const size = md.length;
|
|
96
101
|
const budget = scope === "user" ? (c.userBudgetChars || 8000) : (c.workspaceBudgetChars || 6000);
|
|
97
102
|
const ratio = budget > 0 ? (size / budget).toFixed(2) : "0.00";
|
|
98
|
-
|
|
103
|
+
const base = ` 当前 ${size}/${budget} 字符(${ratio}×)`;
|
|
104
|
+
if (budget <= 0 || size <= budget) return base;
|
|
105
|
+
const over = size - budget;
|
|
106
|
+
if (scope === "user") {
|
|
107
|
+
return `${base},超出 ${over} 字符;用户级无全量重整机制——超预算写入已认可,无需重复尝试精简替换。`;
|
|
108
|
+
}
|
|
109
|
+
const last = readLastReorg(md);
|
|
110
|
+
const cooldownMs = (c.reorgCooldownDays ?? 7) * 86400000;
|
|
111
|
+
const lastNote = last ? `上次重整 ${new Date(last).toLocaleString()}` : "从未重整";
|
|
112
|
+
if (Date.now() - last >= cooldownMs) {
|
|
113
|
+
return `${base},超出 ${over} 字符;重整门禁已满足(${lastNote})——如需减量请调用 memory_reorganize 全量重整(只允许落盘一次),无需反复精简替换凑数。`;
|
|
114
|
+
}
|
|
115
|
+
const remainDays = Math.ceil((last + cooldownMs - Date.now()) / 86400000);
|
|
116
|
+
return `${base},超出 ${over} 字符;重整冷却剩约 ${remainDays} 天(${lastNote})——项目记忆暂时不可压缩:超预算写入已认可,无需重复尝试精简替换。`;
|
|
99
117
|
} catch {
|
|
100
118
|
return "";
|
|
101
119
|
}
|
|
@@ -171,7 +189,7 @@ export function registerHybridTools({ ctx, getConfig, paths, state }) {
|
|
|
171
189
|
// 修复:entry 经 flattenEntry 扁平化为单行——含内嵌换行/标题行
|
|
172
190
|
// 时不再原样落盘破坏结构,message 明示合并,不静默撒谎。
|
|
173
191
|
const flatNote = flattened ? "(entry 含多行,已合并为单行)" : "";
|
|
174
|
-
//
|
|
192
|
+
// 体量回显(仅提示,不拦截)——超预算时由 sizeLine 附「超出字符数 + 重整门禁状态」指引。
|
|
175
193
|
const scopeKey = args.scope === "user" ? "user" : "project";
|
|
176
194
|
const sizeNote = wrote > 0 && files[0] ? sizeLine(scopeKey, files[0], c) : "";
|
|
177
195
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-memory-palace",
|
|
3
|
-
"version": "1.8.3-alpha.
|
|
3
|
+
"version": "1.8.3-alpha.2",
|
|
4
4
|
"description": "把 WorkBuddy 的文件式记忆系统移植进 DeepSeek Harness:用户级 + 工作区的人类可读 Markdown 记忆(~/.deepseek-harness/MEMORY.md 与 <cwd>/.deepseek-harness/memory/)。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|