dsh-selfnote 0.12.0 → 0.12.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/lib/client.js +4 -0
- package/lib/index.js +12 -3
- package/lib/memory.js +4 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -550,6 +550,9 @@ window.__ModuleLoader__.load({
|
|
|
550
550
|
var segments = [
|
|
551
551
|
{ key: 'notes', label: '自述', value: budget.notes || 0, color: '#60a5fa' },
|
|
552
552
|
{ key: 'profile', label: '画像', value: budget.profile || 0, color: '#a78bfa' },
|
|
553
|
+
// 环境段是最大的一块(上限 320 字),漏了它进度条就画不满:
|
|
554
|
+
// total 里算进去了,条子上却没有对应的格子,看着像「只用了三成」。
|
|
555
|
+
{ key: 'env', label: '环境', value: budget.env || 0, color: '#f472b6' },
|
|
553
556
|
{ key: 'facts', label: '结论', value: budget.facts || 0, color: '#34d399' },
|
|
554
557
|
{ key: 'habits', label: '习惯', value: budget.habits || 0, color: '#fbbf24' },
|
|
555
558
|
]
|
|
@@ -1171,6 +1174,7 @@ window.__ModuleLoader__.load({
|
|
|
1171
1174
|
'本回合注入 ' + (budget.total || 0) + ' / ' + limit +
|
|
1172
1175
|
' 字 · 自述 ' + (budget.notes || 0) +
|
|
1173
1176
|
' 画像 ' + (budget.profile || 0) +
|
|
1177
|
+
' 环境 ' + (budget.env || 0) +
|
|
1174
1178
|
' 结论 ' + (budget.facts || 0) +
|
|
1175
1179
|
' 习惯 ' + (budget.habits || 0),
|
|
1176
1180
|
),
|
package/lib/index.js
CHANGED
|
@@ -339,8 +339,10 @@ function assembleInjection(cfg) {
|
|
|
339
339
|
ranked.map((item) => item.text),
|
|
340
340
|
BUDGET.facts,
|
|
341
341
|
)
|
|
342
|
-
//
|
|
343
|
-
|
|
342
|
+
// 只有真的进了上下文才算「用到」;被检索到但没进上下文的不涨热度。
|
|
343
|
+
// 画像段也是真贴进提示词的一行 —— 被画像吸收的条目同样要记账,
|
|
344
|
+
// 否则「关于他:…」里天天在用的那句会一直显示「0 次 / 从没进过」。
|
|
345
|
+
const factIds = [...new Set([...env.ids, ...(profile.sources ?? [])])]
|
|
344
346
|
// placements:这条事实这一回合落在哪一段(profile / env / facts),没有就是没进上下文。
|
|
345
347
|
// 归属统计靠它,否则只能看到「用过几次」,看不到「从哪条路进去的」。
|
|
346
348
|
const placements = {}
|
|
@@ -516,14 +518,21 @@ function composeInjection(inline) {
|
|
|
516
518
|
injectCache = { key, text: '' }
|
|
517
519
|
return ''
|
|
518
520
|
}
|
|
521
|
+
// 缓存键里带着 facts.jsonl 的 mtime/size,而 touchFacts 恰好要写这个文件 ——
|
|
522
|
+
// 用写之前算的 key 存缓存,等于「自己把自己作废」:下一次装配必然 miss、
|
|
523
|
+
// 重算一遍、再 touch 一次,次数与心跳跟着一起虚高(实测 4 小时涨了 2600 次)。
|
|
524
|
+
// 所以存的是写完之后的键:注入文本不会因为一次记账就重算,
|
|
525
|
+
// 热度变化带来的重排,等这份数据真的被改(增删改一条记忆)时再生效。
|
|
526
|
+
let keyAfter = key
|
|
519
527
|
if (built.factIds.length > 0) {
|
|
520
528
|
try {
|
|
521
529
|
touchFacts(built.factIds)
|
|
530
|
+
keyAfter = injectionKey(cfg)
|
|
522
531
|
} catch {
|
|
523
532
|
/* 记账失败不影响注入 */
|
|
524
533
|
}
|
|
525
534
|
}
|
|
526
|
-
injectCache = { key, text: built.text }
|
|
535
|
+
injectCache = { key: keyAfter, text: built.text }
|
|
527
536
|
return built.text
|
|
528
537
|
}
|
|
529
538
|
|
package/lib/memory.js
CHANGED
|
@@ -881,7 +881,10 @@ export function factHeat(fact, now = Date.now(), halfLifeDays = DEFAULT_HALF_LIF
|
|
|
881
881
|
export function touchFacts(ids, now = Date.now()) {
|
|
882
882
|
const wanted = new Set(ids ?? [])
|
|
883
883
|
if (wanted.size === 0) return 0
|
|
884
|
-
|
|
884
|
+
// 必须存完整时刻,不能只存日期:下面用 now - Date.parse(lastHit) < 1h 去重,
|
|
885
|
+
// 而 'YYYY-MM-DD' 解析出来是当天 00:00 —— 过了午夜那一小时窗口就永远失效,
|
|
886
|
+
// 每装配一次都会 +1(实测 25 分钟能连涨 3 次,把「进过几次」记成「算过几次」)。
|
|
887
|
+
const stamp = new Date(now).toISOString()
|
|
885
888
|
// 热度是软数据:抢不到锁就这回合先不记(lastHit 没变,下一回合还会再试),
|
|
886
889
|
// 别为了记一次点击把事件循环卡住 —— 所以给它的重试窗口比别的写入短。
|
|
887
890
|
const outcome = mutateFacts((facts) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-selfnote",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Self-narrative memory for DeepSeek Harness: the model writes notes to itself, which persist across sessions and are injected back. | 人格库:模型写给自己看的话,跨会话保留并每回合注入。",
|
|
6
6
|
"keywords": [
|