lingshu-skill 5.51.0 → 5.53.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/CHANGELOG.md +65 -0
- package/README.md +1 -1
- package/SKILL-lite.md +1 -1
- package/SKILL-tiny.md +1 -1
- package/SKILL.md +1 -1
- package/assets/panel.html +32 -15
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +7 -7
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +65 -0
- package/scripts/astrbot_plugin_lingshu/engine/README.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +32 -15
- package/scripts/astrbot_plugin_lingshu/engine/scripts/persona.py +134 -38
- package/scripts/persona.py +134 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v5.53(2026-12-04)
|
|
4
|
+
|
|
5
|
+
### 🧠 自我认知四桶真实填充(SELF-MODEL-FILL)
|
|
6
|
+
|
|
7
|
+
四桶长期为空(strengths/uncertainties/autobiography),排查发现两个数据通路依赖**真实数据里不存在的字段**:
|
|
8
|
+
- `uncertainties` 要求 insight 带 confidence 0.4~0.6 ——实测 23 条 insight 里 **0 条**有该字段(只有教训库用)
|
|
9
|
+
- `strengths` 要求带 emotion 字段 ——实测高重要度记忆 **emo 全为 None**
|
|
10
|
+
|
|
11
|
+
**改用真实存在的信号**:
|
|
12
|
+
- `uncertainties` ← `superseded_by`(被新结论取代的旧记忆):"曾经以为…"是认知修正最诚实的痕迹
|
|
13
|
+
- `strengths` ← 重要度≥0.75 且 `access_count`≥3:被系统反复召回=真的在用,不靠自夸
|
|
14
|
+
- `limitations` ← 补 `mistake` 类记忆(13 条)——原路只认 correction=True(全库仅 1 条)
|
|
15
|
+
|
|
16
|
+
**实测**:strengths 8 / uncertainties 8 / limitations 9,全部可溯源到具体记忆。
|
|
17
|
+
|
|
18
|
+
### 🌊 心情流水快照(MOOD-SNAPSHOT)
|
|
19
|
+
|
|
20
|
+
emotion_timeline 长期只有 1 条——根因是 `auto_appraise` 只在 `extract`(封存对话)时调用,日常 remember/capture 不经过它。
|
|
21
|
+
|
|
22
|
+
**补充**:daily_drift 每天写一条**实测** EMA 快照进 emotions.jsonl(genesis=False,标"每日快照")——不是编造情绪,是把真实测得的心情记进流水,让时间线有连续曲线。20h 内只记一次。
|
|
23
|
+
|
|
24
|
+
### 🛡️ PERSONA-GUARD v3(守卫自身缺陷修正)
|
|
25
|
+
|
|
26
|
+
本轮排查中发现 v2 守卫方向错了:无条件拒绝空态写入会让**首次初始化返回 None**,连锁崩掉 overview 与全部单测(实测 9/11、10/12、3/5 挂)。
|
|
27
|
+
|
|
28
|
+
**修正**:只在【会丢数据】时拦(盘上已有名字/特质/历史 + 产物为空);首次创建必须放行;`compile_persona` 任何分支都不返回 None。
|
|
29
|
+
|
|
30
|
+
### 🐛 附带发现
|
|
31
|
+
|
|
32
|
+
四桶条目必须是**纯字符串**——`_ensure_self_model` 会丢弃 dict 类型条目(v5.52 的 {ts,text} 形式被静默清空,导致 added 报 8 但桶里为 0)。
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## v5.52(2026-12-04)
|
|
37
|
+
|
|
38
|
+
### 🌱 内驱真实演化(DRIVE-EVOLVE)
|
|
39
|
+
|
|
40
|
+
**用户反馈**:「好奇心 80 / 理智 70 感觉怎么没有变化」。
|
|
41
|
+
|
|
42
|
+
**根因**:mind_tune 只有 CLI 手动调用路径,auto_dream 的 persona_updates 恒为空——
|
|
43
|
+
初识之后好奇/理智从未变过。设计意图(从用户态度里长出来)一直没有落地机制。
|
|
44
|
+
|
|
45
|
+
**修复**:daily_drift 增加内驱演化段,用可追溯的真实信号驱动,每天最多 ±2:
|
|
46
|
+
- **好奇心↑**:近期探索类请求(调研/查查/深挖/还有什么/研究/探索/再看看/改进/完善/优化/想法)≥3 条 → +2,≥1 条 → +1
|
|
47
|
+
- **理智↑**:近期有 correction(被纠正)或严谨类信号(证据/权衡/取舍/利弊/风险/严谨/不要猜/查清楚/根因)≥3 条 → +2,≥1 条 → +1
|
|
48
|
+
- 每次变动写 history(field=drives.*,source=drift)并 audit_log,可完整溯源。
|
|
49
|
+
|
|
50
|
+
**实测**:本次运行基于近 1 天 37 条记忆(15 条探索类)→ 好奇 80→82、理智 70→72 实际生效。
|
|
51
|
+
|
|
52
|
+
### 📊 特质雷达图扩展到 10 维(RADAR-ENRICH)
|
|
53
|
+
|
|
54
|
+
用户反馈「雷达图显示的东西有点少」——原只有 trait 3 个 + 内驱 2 个 + 亲和度。
|
|
55
|
+
现在纳入**六欲**(求知/表达/连接/成就/安全/掌控),形成 10 维人格全景图(上限 11 轴防糊)。
|
|
56
|
+
|
|
57
|
+
### 🎨 七情占比语义修正(SEMANTIC-FIX)
|
|
58
|
+
|
|
59
|
+
用户困惑「喜怎么满了,但喜·满足是 28%」——pct 是组间相对占比(占活跃情绪总和),
|
|
60
|
+
只有一类情绪时恒为 100%,被误读成强度满格。
|
|
61
|
+
- 进度条宽度改为该组绝对强度(weight);
|
|
62
|
+
- 右侧文字显示 `强度% ·占份额%` 双值;
|
|
63
|
+
- 悬停提示解释「当前只有这一类情绪,所以占比 100%」;
|
|
64
|
+
- 加一行图例说明左/右两个数字各是什么。
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
3
68
|
## v5.51(2026-12-04)
|
|
4
69
|
|
|
5
70
|
### ⚡ 面板实时化双升级(SSE-SPEED + LAZY-MEM)
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
|
|
4
4
|
|
|
5
|
-
> 当前版本 **v5.
|
|
5
|
+
> 当前版本 **v5.53**(变更见 [CHANGELOG.md](CHANGELOG.md))
|
|
6
6
|
|
|
7
7
|
> 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
|
|
8
8
|
|
package/SKILL-lite.md
CHANGED
package/SKILL-tiny.md
CHANGED
package/SKILL.md
CHANGED
package/assets/panel.html
CHANGED
|
@@ -2818,13 +2818,24 @@ function renderMood(){
|
|
|
2818
2818
|
const grpEl = $("emo-groups");
|
|
2819
2819
|
if (grpEl) {
|
|
2820
2820
|
const gs = (m.groups || []).slice(0, 7);
|
|
2821
|
+
// SEMANTIC-FIX(v5.52):pct 是**组间相对占比**(占活跃情绪总和),不是强度。
|
|
2822
|
+
// 只有一种情绪时 pct 恒 100%,用户会误读成"强度满格"——所以:
|
|
2823
|
+
// 进度条宽度 = 该组绝对强度(weight,0-1);右侧文字 = "占 X%"(相对占比)。
|
|
2824
|
+
// 这样"喜 100%"配 28% 的条宽就自洽了:喜占活跃情绪的 100%,但强度只有 28%。
|
|
2821
2825
|
grpEl.innerHTML = gs.length
|
|
2822
|
-
? gs.map(g =>
|
|
2823
|
-
|
|
2826
|
+
? gs.map(g => {
|
|
2827
|
+
const wPct = Math.round((Number(g.weight) || 0) * 100);
|
|
2828
|
+
const share = Number(g.pct) || 0;
|
|
2829
|
+
const tip = `${g.group}:强度 ${wPct}% · 占活跃情绪 ${share}%`
|
|
2830
|
+
+ (gs.length === 1 ? "(当前只有这一类情绪,所以占比 100%)" : "");
|
|
2831
|
+
return `
|
|
2832
|
+
<div class="desire-row" title="${esc(tip)}">
|
|
2824
2833
|
<span style="width:36px">${esc(g.group)}</span>
|
|
2825
|
-
<span class="bar"><i style="width:${
|
|
2826
|
-
<span style="width:
|
|
2827
|
-
</div
|
|
2834
|
+
<span class="bar"><i style="width:${wPct}%;background:var(--accent)"></i></span>
|
|
2835
|
+
<span style="width:74px;text-align:right">${wPct}% <span class="sub" style="font-size:11px">·占${share}%</span></span>
|
|
2836
|
+
</div>`;
|
|
2837
|
+
}).join("")
|
|
2838
|
+
+ `<div class="sub" style="margin-top:6px;font-size:11px">左:该情绪类的绝对强度 · 右:占当前活跃情绪的份额${gs.length === 1 ? "(仅一类时份额恒为 100%)" : ""}</div>`
|
|
2828
2839
|
: `<div class="empty">没有正在起作用的情绪</div>`;
|
|
2829
2840
|
}
|
|
2830
2841
|
// PE-07: 渲染 Russell 双轴坐标图点位 (valence x arousal)
|
|
@@ -3067,23 +3078,29 @@ function renderEvolved(p){
|
|
|
3067
3078
|
const mi = (S.ov && S.ov.mind) || {};
|
|
3068
3079
|
const aff = (S.ov && S.ov.affection) || {};
|
|
3069
3080
|
|
|
3070
|
-
//
|
|
3071
|
-
// UI-DEDUP(v5.50):traits
|
|
3072
|
-
//
|
|
3073
|
-
//
|
|
3074
|
-
// 规则:traits 里已有"好奇/理智"时,内驱维度跳过(只补 traits 没有的);
|
|
3075
|
-
// 维度命名统一用内驱名(好奇心/理智),数值取内驱演化值(更活跃)。
|
|
3081
|
+
// 组装维度(RADAR-6D v5.52):traits 前 2 个 + 内驱 2 个 + 六欲 + 亲和度
|
|
3082
|
+
// UI-DEDUP(v5.50):traits 与 drives 是同一概念两个来源,同名维度只保留一个。
|
|
3083
|
+
// RADAR-ENRICH(v5.52):用户反馈"雷达图显示太少"——把六欲(求知/表达/连接/成就/安全/掌控)
|
|
3084
|
+
// 也纳入,形成 10 维人格全景图;轴太多时用 11 维上限截断防糊成一团。
|
|
3076
3085
|
const dims = [];
|
|
3077
3086
|
const traitNames = Object.keys(traits);
|
|
3078
|
-
Object.entries(traits).slice(0,
|
|
3087
|
+
Object.entries(traits).slice(0, 2).forEach(([k, v]) => {
|
|
3079
3088
|
dims.push({ name: k, val: tval(v) });
|
|
3080
3089
|
});
|
|
3081
3090
|
const hasTrait = (re) => traitNames.some((k) => re.test(k));
|
|
3082
3091
|
if (!hasTrait(/好奇/)) dims.push({ name: "好奇心", val: mi.curiosity ?? 50 });
|
|
3083
3092
|
if (!hasTrait(/理智/)) dims.push({ name: "理智", val: mi.reason ?? 50 });
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3093
|
+
// 六欲:只取有数值的,短名上轴(求知/表达/连接/成就/安全/掌控)
|
|
3094
|
+
const dsr = (S.ov && S.ov.desires) || {};
|
|
3095
|
+
Object.entries(dsr).forEach(([k, v]) => {
|
|
3096
|
+
if (typeof v === "number" && dims.length < 10) {
|
|
3097
|
+
dims.push({ name: k.replace("欲", ""), val: v, hint: k });
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
if (!dims.some((d) => d.name === "亲和度") && dims.length < 11) {
|
|
3101
|
+
dims.push({ name: "亲和度", val: aff.affinity ?? 60 });
|
|
3102
|
+
}
|
|
3103
|
+
const total = Math.max(dims.length, 3);
|
|
3087
3104
|
const cx = 110, cy = 100, radius = 70;
|
|
3088
3105
|
const angleStep = (Math.PI * 2) / total;
|
|
3089
3106
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lingshu-skill",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.53.0",
|
|
4
4
|
"description": "Brain-inspired persistent memory, persona and growth system for AI coding agents. Local-only, zero-dependency Python. Requires Python 3.10+.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"PATCH_NOTES.md": "9296e524f743f358fd11115598398a754cfd69534526dde9c8ad85f14a418f89",
|
|
3
3
|
"README.md": "3d634d743b085eebd2cbb5dd3a00edfa728ed23947e20cc29e7c3b29087ec043",
|
|
4
|
-
"engine/CHANGELOG.md": "
|
|
5
|
-
"engine/README.md": "
|
|
6
|
-
"engine/SKILL-lite.md": "
|
|
7
|
-
"engine/SKILL-tiny.md": "
|
|
8
|
-
"engine/SKILL.md": "
|
|
9
|
-
"engine/assets/panel.html": "
|
|
4
|
+
"engine/CHANGELOG.md": "f78c8e0c25e06a9159234968e3ed49bc210d7f93a2909e69e74006cab462d629",
|
|
5
|
+
"engine/README.md": "d5de5721d86c45a053701ba38c1aad6a96a4245d2f58ecc30344113f34950184",
|
|
6
|
+
"engine/SKILL-lite.md": "e75a6f1ad684802287754eccb7cd4bfad483d59b19e94721bdd7af8cf30fac87",
|
|
7
|
+
"engine/SKILL-tiny.md": "befeea374148268fe9016314de09c21cfa4921e77a8ee90e4e69faae571b27f7",
|
|
8
|
+
"engine/SKILL.md": "1e7f1a21c69be1ae4bf9356c5447b13608d217fa08186c52987cfa51ab68ec35",
|
|
9
|
+
"engine/assets/panel.html": "1b015d80e2d6ec8d52eee7a970f535877938adddc1cef0fd6629778e87f63c42",
|
|
10
10
|
"engine/docs/commands.md": "0ce8c88e5d2d04a8055b45c060ebd53b50c52b79b650312e2ee440845804ca4b",
|
|
11
11
|
"engine/docs/mechanics.md": "aa9683c827ed3419106e84d847ab16dc310c27fc62f588184192aaa1617523cc",
|
|
12
12
|
"engine/docs/models.md": "596bc1a3414f2de5569dcb41a0c494acae7daa534efd5a91dbcc3c4cb308d695",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"engine/scripts/panel_splash.py": "36cd59e593ce52557a180a8767bfa9cd9c803f0cccaa141e7da8babd5a35e925",
|
|
62
62
|
"engine/scripts/panel_update.py": "6ff1a0687c05e3ef4ae846058abea4dacf985a3fe6adcdbb4eef1b38e27139b5",
|
|
63
63
|
"engine/scripts/panels.py": "9db94038c2c11fc5da0f2f7c3292d01053acfaf1b74f1517a1f1c4402895fef4",
|
|
64
|
-
"engine/scripts/persona.py": "
|
|
64
|
+
"engine/scripts/persona.py": "49f4a62e7268c4e63f51599c27eae3dcf40421067db3fdb45027f9f3f573ef9b",
|
|
65
65
|
"engine/scripts/prepublish_tests.py": "8d116de1edd3ab57584a6a2749598cf127e918383da67e50118601e5a3970c2a",
|
|
66
66
|
"engine/scripts/release.py": "b4271c06802d6154e90715cc566e4104f5d6de0b9efa6f4907643e686bb5c48e",
|
|
67
67
|
"engine/scripts/retriever.py": "85a35f8f660767cff1c068e722b51e3b5623c4dffe4822527eee96f9220240d3",
|
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v5.53(2026-12-04)
|
|
4
|
+
|
|
5
|
+
### 🧠 自我认知四桶真实填充(SELF-MODEL-FILL)
|
|
6
|
+
|
|
7
|
+
四桶长期为空(strengths/uncertainties/autobiography),排查发现两个数据通路依赖**真实数据里不存在的字段**:
|
|
8
|
+
- `uncertainties` 要求 insight 带 confidence 0.4~0.6 ——实测 23 条 insight 里 **0 条**有该字段(只有教训库用)
|
|
9
|
+
- `strengths` 要求带 emotion 字段 ——实测高重要度记忆 **emo 全为 None**
|
|
10
|
+
|
|
11
|
+
**改用真实存在的信号**:
|
|
12
|
+
- `uncertainties` ← `superseded_by`(被新结论取代的旧记忆):"曾经以为…"是认知修正最诚实的痕迹
|
|
13
|
+
- `strengths` ← 重要度≥0.75 且 `access_count`≥3:被系统反复召回=真的在用,不靠自夸
|
|
14
|
+
- `limitations` ← 补 `mistake` 类记忆(13 条)——原路只认 correction=True(全库仅 1 条)
|
|
15
|
+
|
|
16
|
+
**实测**:strengths 8 / uncertainties 8 / limitations 9,全部可溯源到具体记忆。
|
|
17
|
+
|
|
18
|
+
### 🌊 心情流水快照(MOOD-SNAPSHOT)
|
|
19
|
+
|
|
20
|
+
emotion_timeline 长期只有 1 条——根因是 `auto_appraise` 只在 `extract`(封存对话)时调用,日常 remember/capture 不经过它。
|
|
21
|
+
|
|
22
|
+
**补充**:daily_drift 每天写一条**实测** EMA 快照进 emotions.jsonl(genesis=False,标"每日快照")——不是编造情绪,是把真实测得的心情记进流水,让时间线有连续曲线。20h 内只记一次。
|
|
23
|
+
|
|
24
|
+
### 🛡️ PERSONA-GUARD v3(守卫自身缺陷修正)
|
|
25
|
+
|
|
26
|
+
本轮排查中发现 v2 守卫方向错了:无条件拒绝空态写入会让**首次初始化返回 None**,连锁崩掉 overview 与全部单测(实测 9/11、10/12、3/5 挂)。
|
|
27
|
+
|
|
28
|
+
**修正**:只在【会丢数据】时拦(盘上已有名字/特质/历史 + 产物为空);首次创建必须放行;`compile_persona` 任何分支都不返回 None。
|
|
29
|
+
|
|
30
|
+
### 🐛 附带发现
|
|
31
|
+
|
|
32
|
+
四桶条目必须是**纯字符串**——`_ensure_self_model` 会丢弃 dict 类型条目(v5.52 的 {ts,text} 形式被静默清空,导致 added 报 8 但桶里为 0)。
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## v5.52(2026-12-04)
|
|
37
|
+
|
|
38
|
+
### 🌱 内驱真实演化(DRIVE-EVOLVE)
|
|
39
|
+
|
|
40
|
+
**用户反馈**:「好奇心 80 / 理智 70 感觉怎么没有变化」。
|
|
41
|
+
|
|
42
|
+
**根因**:mind_tune 只有 CLI 手动调用路径,auto_dream 的 persona_updates 恒为空——
|
|
43
|
+
初识之后好奇/理智从未变过。设计意图(从用户态度里长出来)一直没有落地机制。
|
|
44
|
+
|
|
45
|
+
**修复**:daily_drift 增加内驱演化段,用可追溯的真实信号驱动,每天最多 ±2:
|
|
46
|
+
- **好奇心↑**:近期探索类请求(调研/查查/深挖/还有什么/研究/探索/再看看/改进/完善/优化/想法)≥3 条 → +2,≥1 条 → +1
|
|
47
|
+
- **理智↑**:近期有 correction(被纠正)或严谨类信号(证据/权衡/取舍/利弊/风险/严谨/不要猜/查清楚/根因)≥3 条 → +2,≥1 条 → +1
|
|
48
|
+
- 每次变动写 history(field=drives.*,source=drift)并 audit_log,可完整溯源。
|
|
49
|
+
|
|
50
|
+
**实测**:本次运行基于近 1 天 37 条记忆(15 条探索类)→ 好奇 80→82、理智 70→72 实际生效。
|
|
51
|
+
|
|
52
|
+
### 📊 特质雷达图扩展到 10 维(RADAR-ENRICH)
|
|
53
|
+
|
|
54
|
+
用户反馈「雷达图显示的东西有点少」——原只有 trait 3 个 + 内驱 2 个 + 亲和度。
|
|
55
|
+
现在纳入**六欲**(求知/表达/连接/成就/安全/掌控),形成 10 维人格全景图(上限 11 轴防糊)。
|
|
56
|
+
|
|
57
|
+
### 🎨 七情占比语义修正(SEMANTIC-FIX)
|
|
58
|
+
|
|
59
|
+
用户困惑「喜怎么满了,但喜·满足是 28%」——pct 是组间相对占比(占活跃情绪总和),
|
|
60
|
+
只有一类情绪时恒为 100%,被误读成强度满格。
|
|
61
|
+
- 进度条宽度改为该组绝对强度(weight);
|
|
62
|
+
- 右侧文字显示 `强度% ·占份额%` 双值;
|
|
63
|
+
- 悬停提示解释「当前只有这一类情绪,所以占比 100%」;
|
|
64
|
+
- 加一行图例说明左/右两个数字各是什么。
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
3
68
|
## v5.51(2026-12-04)
|
|
4
69
|
|
|
5
70
|
### ⚡ 面板实时化双升级(SSE-SPEED + LAZY-MEM)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
|
|
4
4
|
|
|
5
|
-
> 当前版本 **v5.
|
|
5
|
+
> 当前版本 **v5.53**(变更见 [CHANGELOG.md](CHANGELOG.md))
|
|
6
6
|
|
|
7
7
|
> 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
|
|
8
8
|
|
|
@@ -2818,13 +2818,24 @@ function renderMood(){
|
|
|
2818
2818
|
const grpEl = $("emo-groups");
|
|
2819
2819
|
if (grpEl) {
|
|
2820
2820
|
const gs = (m.groups || []).slice(0, 7);
|
|
2821
|
+
// SEMANTIC-FIX(v5.52):pct 是**组间相对占比**(占活跃情绪总和),不是强度。
|
|
2822
|
+
// 只有一种情绪时 pct 恒 100%,用户会误读成"强度满格"——所以:
|
|
2823
|
+
// 进度条宽度 = 该组绝对强度(weight,0-1);右侧文字 = "占 X%"(相对占比)。
|
|
2824
|
+
// 这样"喜 100%"配 28% 的条宽就自洽了:喜占活跃情绪的 100%,但强度只有 28%。
|
|
2821
2825
|
grpEl.innerHTML = gs.length
|
|
2822
|
-
? gs.map(g =>
|
|
2823
|
-
|
|
2826
|
+
? gs.map(g => {
|
|
2827
|
+
const wPct = Math.round((Number(g.weight) || 0) * 100);
|
|
2828
|
+
const share = Number(g.pct) || 0;
|
|
2829
|
+
const tip = `${g.group}:强度 ${wPct}% · 占活跃情绪 ${share}%`
|
|
2830
|
+
+ (gs.length === 1 ? "(当前只有这一类情绪,所以占比 100%)" : "");
|
|
2831
|
+
return `
|
|
2832
|
+
<div class="desire-row" title="${esc(tip)}">
|
|
2824
2833
|
<span style="width:36px">${esc(g.group)}</span>
|
|
2825
|
-
<span class="bar"><i style="width:${
|
|
2826
|
-
<span style="width:
|
|
2827
|
-
</div
|
|
2834
|
+
<span class="bar"><i style="width:${wPct}%;background:var(--accent)"></i></span>
|
|
2835
|
+
<span style="width:74px;text-align:right">${wPct}% <span class="sub" style="font-size:11px">·占${share}%</span></span>
|
|
2836
|
+
</div>`;
|
|
2837
|
+
}).join("")
|
|
2838
|
+
+ `<div class="sub" style="margin-top:6px;font-size:11px">左:该情绪类的绝对强度 · 右:占当前活跃情绪的份额${gs.length === 1 ? "(仅一类时份额恒为 100%)" : ""}</div>`
|
|
2828
2839
|
: `<div class="empty">没有正在起作用的情绪</div>`;
|
|
2829
2840
|
}
|
|
2830
2841
|
// PE-07: 渲染 Russell 双轴坐标图点位 (valence x arousal)
|
|
@@ -3067,23 +3078,29 @@ function renderEvolved(p){
|
|
|
3067
3078
|
const mi = (S.ov && S.ov.mind) || {};
|
|
3068
3079
|
const aff = (S.ov && S.ov.affection) || {};
|
|
3069
3080
|
|
|
3070
|
-
//
|
|
3071
|
-
// UI-DEDUP(v5.50):traits
|
|
3072
|
-
//
|
|
3073
|
-
//
|
|
3074
|
-
// 规则:traits 里已有"好奇/理智"时,内驱维度跳过(只补 traits 没有的);
|
|
3075
|
-
// 维度命名统一用内驱名(好奇心/理智),数值取内驱演化值(更活跃)。
|
|
3081
|
+
// 组装维度(RADAR-6D v5.52):traits 前 2 个 + 内驱 2 个 + 六欲 + 亲和度
|
|
3082
|
+
// UI-DEDUP(v5.50):traits 与 drives 是同一概念两个来源,同名维度只保留一个。
|
|
3083
|
+
// RADAR-ENRICH(v5.52):用户反馈"雷达图显示太少"——把六欲(求知/表达/连接/成就/安全/掌控)
|
|
3084
|
+
// 也纳入,形成 10 维人格全景图;轴太多时用 11 维上限截断防糊成一团。
|
|
3076
3085
|
const dims = [];
|
|
3077
3086
|
const traitNames = Object.keys(traits);
|
|
3078
|
-
Object.entries(traits).slice(0,
|
|
3087
|
+
Object.entries(traits).slice(0, 2).forEach(([k, v]) => {
|
|
3079
3088
|
dims.push({ name: k, val: tval(v) });
|
|
3080
3089
|
});
|
|
3081
3090
|
const hasTrait = (re) => traitNames.some((k) => re.test(k));
|
|
3082
3091
|
if (!hasTrait(/好奇/)) dims.push({ name: "好奇心", val: mi.curiosity ?? 50 });
|
|
3083
3092
|
if (!hasTrait(/理智/)) dims.push({ name: "理智", val: mi.reason ?? 50 });
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3093
|
+
// 六欲:只取有数值的,短名上轴(求知/表达/连接/成就/安全/掌控)
|
|
3094
|
+
const dsr = (S.ov && S.ov.desires) || {};
|
|
3095
|
+
Object.entries(dsr).forEach(([k, v]) => {
|
|
3096
|
+
if (typeof v === "number" && dims.length < 10) {
|
|
3097
|
+
dims.push({ name: k.replace("欲", ""), val: v, hint: k });
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
if (!dims.some((d) => d.name === "亲和度") && dims.length < 11) {
|
|
3101
|
+
dims.push({ name: "亲和度", val: aff.affinity ?? 60 });
|
|
3102
|
+
}
|
|
3103
|
+
const total = Math.max(dims.length, 3);
|
|
3087
3104
|
const cx = 110, cy = 100, radius = 70;
|
|
3088
3105
|
const angleStep = (Math.PI * 2) / total;
|
|
3089
3106
|
|
|
@@ -270,11 +270,17 @@ def compile_persona() -> dict:
|
|
|
270
270
|
_disk_now = _slurp_json(HOME / "persona.json") if (HOME / "persona.json").exists() else None
|
|
271
271
|
_disk_named = bool((( _disk_now or {}).get("identity") or {}).get("名字"))
|
|
272
272
|
_incoming_named = bool(((p.get("identity") or {}).get("名字") or "").strip())
|
|
273
|
-
|
|
273
|
+
# PERSONA-GUARD v3:只在【会丢数据】时拦(盘上已有实质内容 + 产物为空),
|
|
274
|
+
# 首次创建(无文件/盘上空)必须放行——v2 的无条件拒绝让初始化返回 None,
|
|
275
|
+
# 连锁崩掉 overview 与全部单测(12-04 03:22 实测)。
|
|
276
|
+
_disk_sub = (bool(str((_disk_now.get("identity") or {}).get("名字") or "").strip())
|
|
277
|
+
or bool(_disk_now.get("traits") or {})
|
|
278
|
+
or bool(_disk_now.get("history") or [])) if isinstance(_disk_now, dict) else False
|
|
279
|
+
if _disk_sub and not _incoming_named and not (p.get("traits") or {}):
|
|
274
280
|
log_event("persona",
|
|
275
|
-
"compile_persona
|
|
281
|
+
"compile_persona 拒绝覆盖:盘上已有实质人格而被空态重建覆盖——已拦下。",
|
|
276
282
|
level="error")
|
|
277
|
-
return
|
|
283
|
+
return _disk_now if isinstance(_disk_now, dict) else default_persona()
|
|
278
284
|
atomic_json(HOME / "persona.json", p)
|
|
279
285
|
# SPEED-1 缓存同步失效:compile_persona 直写绕过了 save_persona 的失效点
|
|
280
286
|
global _lp_cache, _lp_cache_mtime, _lp_cache_time
|
|
@@ -1469,6 +1475,63 @@ def daily_drift(days: int = 1) -> dict:
|
|
|
1469
1475
|
applied = True
|
|
1470
1476
|
audit_log("ai", "daily_drift", "state.mood_score",
|
|
1471
1477
|
f"{int(cur)}→{new}(近{days}天 net={net})")
|
|
1478
|
+
# —— 心情快照(MOOD-SNAPSHOT v5.53)——
|
|
1479
|
+
# 历史问题:emotion_timeline 只有 1 条——因为 auto_appraise 只在 extract(封存对话)
|
|
1480
|
+
# 时调用,日常 remember/capture 不经过它。补一条**每��实测**的 EMA 快照进
|
|
1481
|
+
# emotions.jsonl(genesis=False,标 source=daily-snapshot):
|
|
1482
|
+
# 不是编造情绪,是把当天真实测得的心情记进流水,让时间线有连续曲线。
|
|
1483
|
+
try:
|
|
1484
|
+
import emotion as _emo
|
|
1485
|
+
_m = _emo.mood_now()
|
|
1486
|
+
if _m.get("active") or _m.get("label") not in (None, "", "平静"):
|
|
1487
|
+
_mood_hist = p.setdefault("state", {}).setdefault("_mood_snap_ts", 0)
|
|
1488
|
+
if now - _num(_mood_hist, 0) >= 20 * 3600: # 20h 内只记一次
|
|
1489
|
+
_emo.feel(_m.get("label") or "平静",
|
|
1490
|
+
intensity=max(0.05, min(0.6, _num(_m.get("intensity"), 0.1))),
|
|
1491
|
+
why=f"每日心情快照:{_m.get('label')}(强度 {_num(_m.get('intensity'), 0):.0%})",
|
|
1492
|
+
about="每日快照", genesis=False)
|
|
1493
|
+
p["state"]["_mood_snap_ts"] = now
|
|
1494
|
+
applied = True
|
|
1495
|
+
except Exception as _e:
|
|
1496
|
+
log_event("persona", f"心情快照写入失败(不影响其他):{_e}", level="warn")
|
|
1497
|
+
|
|
1498
|
+
# —— 内驱演化(DRIVE-EVOLVE v5.52)——
|
|
1499
|
+
# 历史问题:mind_tune 只有 CLI 手动路径,从初识后好奇/理智永远不变。
|
|
1500
|
+
# 这里用【真实信号】驱动(都可追溯到记忆库),每天最多 ±2,带 history 留痕:
|
|
1501
|
+
# 好奇↑:近期用户大量要求调研/探索/深挖(说明他喜欢多问一层)
|
|
1502
|
+
# 理智↑:近期被纠正(correction)或要求证据/权衡(说明他要求严谨)
|
|
1503
|
+
try:
|
|
1504
|
+
import re as _re
|
|
1505
|
+
dr = p.setdefault("drives", {})
|
|
1506
|
+
_explore_words = ("调研", "查查", "搜一下", "深挖", "还有啥", "还有什么",
|
|
1507
|
+
"研究", "探索", "再看看", "改进", "完善", "优化", "想法")
|
|
1508
|
+
_rigor_words = ("证据", "权衡", "取舍", "利弊", "风险", "严谨",
|
|
1509
|
+
"不要猜", "查清楚", "根因")
|
|
1510
|
+
_explore_n = sum(1 for t0 in texts if any(w in t0 for w in _explore_words))
|
|
1511
|
+
_rigor_n = sum(1 for t0 in texts if any(w in t0 for w in _rigor_words))
|
|
1512
|
+
_corr_n = sum(1 for m0 in recent if m0.get("correction"))
|
|
1513
|
+
_dcur = 2 if _explore_n >= 3 else (1 if _explore_n >= 1 else 0)
|
|
1514
|
+
_drea = 2 if (_corr_n >= 1 or _rigor_n >= 3) else (1 if _rigor_n >= 1 else 0)
|
|
1515
|
+
for _k, _dv, _why0 in (("curiosity", _dcur, f"近{days}天探索类请求 {_explore_n} 条"),
|
|
1516
|
+
("reason", _drea, f"近{days}天纠正 {_corr_n} 条 / 严谨类 {_rigor_n} 条")):
|
|
1517
|
+
if not _dv:
|
|
1518
|
+
continue
|
|
1519
|
+
_old = dr.get(_k)
|
|
1520
|
+
if not isinstance(_old, (int, float)) or isinstance(_old, bool):
|
|
1521
|
+
continue
|
|
1522
|
+
_new = max(0, min(100, int(_old) + _dv))
|
|
1523
|
+
if _new != int(_old):
|
|
1524
|
+
dr[_k] = _new
|
|
1525
|
+
p.setdefault("history", []).append({
|
|
1526
|
+
"ts": now, "field": f"drives.{_k}", "from": int(_old), "to": _new,
|
|
1527
|
+
"why": f"内驱自然演化:{_why0}", "source": "drift"})
|
|
1528
|
+
audit_log("ai", "drive_evolve", f"drives.{_k}",
|
|
1529
|
+
f"{int(_old)}→{_new}({_why0})")
|
|
1530
|
+
applied = True
|
|
1531
|
+
if applied:
|
|
1532
|
+
save_persona(p)
|
|
1533
|
+
except Exception as _e:
|
|
1534
|
+
log_event("persona", f"内驱演化失败(不影响其他):{_e}", level="warn")
|
|
1472
1535
|
return {
|
|
1473
1536
|
"days": days, "memories": len(recent),
|
|
1474
1537
|
"emotion_hits": hits, "positive": positive, "negative": negative,
|
|
@@ -2588,61 +2651,94 @@ def self_model_autosink() -> dict:
|
|
|
2588
2651
|
sm["autobiography"].sort(key=lambda e: _num(e.get("ts"), 0), reverse=True)
|
|
2589
2652
|
del sm["autobiography"][_SELF_MODEL_MAX:]
|
|
2590
2653
|
|
|
2591
|
-
# —— 路 3
|
|
2592
|
-
# confidence 0.4~0.6
|
|
2654
|
+
# —— 路 3:被取代的旧结论 → uncertainties(IDEA-10 实装版)——
|
|
2655
|
+
# 原实现要求 insight 带 confidence 0.4~0.6 字段,但实测 23 条 insight 里
|
|
2656
|
+
# **0 条有 confidence**(该字段只有教训库用)→ 死代码。
|
|
2657
|
+
# 改用真实存在的信号:superseded_by(被新结论取代的旧记忆)——
|
|
2658
|
+
# "我当时是这么想的,后来发现不成立"正是最诚实的认知修正痕迹。
|
|
2593
2659
|
try:
|
|
2594
2660
|
import memory as _mem
|
|
2595
2661
|
uncer: list = []
|
|
2596
2662
|
for r in _mem.load_all():
|
|
2597
|
-
if not isinstance(r, dict) or r.get("
|
|
2598
|
-
continue
|
|
2599
|
-
conf = _num(r.get("confidence"), -1)
|
|
2600
|
-
if not (0.4 <= conf < 0.6):
|
|
2663
|
+
if not isinstance(r, dict) or not r.get("superseded_by"):
|
|
2601
2664
|
continue
|
|
2602
2665
|
ts_r = _num(r.get("ts"), 0) or _num(r.get("created"), 0)
|
|
2603
|
-
if now - ts_r >
|
|
2666
|
+
if now - ts_r > 90 * 86400: # 三个月前的旧账不再翻
|
|
2604
2667
|
continue
|
|
2605
|
-
|
|
2606
|
-
if
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2668
|
+
t0 = str(r.get("text") or r.get("summary") or "").strip()
|
|
2669
|
+
if not t0:
|
|
2670
|
+
continue
|
|
2671
|
+
uncer.append((ts_r, "曾经以为:" + t0[:140]))
|
|
2672
|
+
uncer.sort(key=lambda e: e[0], reverse=True)
|
|
2673
|
+
existing_u = set(sm["uncertainties"])
|
|
2674
|
+
for _ts, txt in uncer[:8]:
|
|
2675
|
+
if txt in existing_u:
|
|
2612
2676
|
continue
|
|
2613
|
-
sm["uncertainties"].append(
|
|
2614
|
-
added["uncertainties"].append(
|
|
2615
|
-
|
|
2677
|
+
sm["uncertainties"].append(txt) # 纯字符串:_ensure_self_model 只保留 str
|
|
2678
|
+
added["uncertainties"].append(txt)
|
|
2679
|
+
if len(sm["uncertainties"]) > _SELF_MODEL_MAX:
|
|
2680
|
+
del sm["uncertainties"][:-_SELF_MODEL_MAX]
|
|
2616
2681
|
except Exception as e:
|
|
2617
|
-
log_event("persona", f"self_model_autosink
|
|
2682
|
+
log_event("persona", f"self_model_autosink 被取代结论路失败:{e}", level="warn")
|
|
2618
2683
|
|
|
2619
|
-
# —— 路 4
|
|
2620
|
-
#
|
|
2684
|
+
# —— 路 4:反复被召回使用的高价值结论 → strengths(IDEA-10 实装版)——
|
|
2685
|
+
# 原实现要求 importance>=0.8 + access_count>=3 + 带 emotion 字段,
|
|
2686
|
+
# 但实测高重要度记忆 emo 几乎全为 None → 死代码。
|
|
2687
|
+
# 改用真实信号:importance>=0.75 且 access_count>=3——
|
|
2688
|
+
# 被系统反复召回 = 真的在用,这是能力最硬的证据(不靠自夸)。
|
|
2621
2689
|
try:
|
|
2622
2690
|
import memory as _mem
|
|
2623
2691
|
strengths_cand: list = []
|
|
2624
2692
|
for r in _mem.load_all():
|
|
2625
|
-
if not isinstance(r, dict)
|
|
2693
|
+
if not isinstance(r, dict):
|
|
2626
2694
|
continue
|
|
2627
|
-
if
|
|
2695
|
+
if r.get("kind") not in ("insight", "fact"):
|
|
2628
2696
|
continue
|
|
2629
|
-
if
|
|
2697
|
+
if _num(r.get("importance"), 0) < 0.75:
|
|
2630
2698
|
continue
|
|
2631
|
-
|
|
2699
|
+
_acc = int(_num(r.get("access_count"), 0))
|
|
2700
|
+
if _acc < 3:
|
|
2632
2701
|
continue
|
|
2633
|
-
|
|
2634
|
-
if
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2702
|
+
t0 = str(r.get("text") or r.get("summary") or "").strip()
|
|
2703
|
+
if not t0:
|
|
2704
|
+
continue
|
|
2705
|
+
strengths_cand.append((_num(r.get("created"), 0),
|
|
2706
|
+
f"(被召回 {_acc} 次)" + t0[:130]))
|
|
2707
|
+
strengths_cand.sort(key=lambda e: e[0], reverse=True)
|
|
2708
|
+
existing_s = set(sm["strengths"])
|
|
2709
|
+
for _ts, txt in strengths_cand[:8]:
|
|
2710
|
+
if txt in existing_s:
|
|
2711
|
+
continue
|
|
2712
|
+
sm["strengths"].append(txt) # 纯字符串:_ensure_self_model 只保留 str
|
|
2713
|
+
added["strengths"].append(txt)
|
|
2714
|
+
if len(sm["strengths"]) > _SELF_MODEL_MAX:
|
|
2715
|
+
del sm["strengths"][:-_SELF_MODEL_MAX]
|
|
2716
|
+
except Exception as e:
|
|
2717
|
+
log_event("persona", f"self_model_autosink 反复使用路失败:{e}", level="warn")
|
|
2718
|
+
|
|
2719
|
+
# —— 路 5:mistake 类记忆 → limitations 补充源(实装版)——
|
|
2720
|
+
# 原路1只认 correction=True,实测全库仅 1 条 → 短板几乎不积累。
|
|
2721
|
+
# mistake 类(13 条)是"我犯过的错"的一等公民,本该进短板桶。
|
|
2722
|
+
try:
|
|
2723
|
+
import memory as _mem
|
|
2724
|
+
mist = []
|
|
2725
|
+
for r in _mem.load_all():
|
|
2726
|
+
if not isinstance(r, dict) or r.get("kind") != "mistake":
|
|
2727
|
+
continue
|
|
2728
|
+
t0 = str(r.get("text") or "").strip()
|
|
2729
|
+
if t0:
|
|
2730
|
+
mist.append((_num(r.get("created"), 0), t0))
|
|
2731
|
+
mist.sort(key=lambda x: x[0], reverse=True)
|
|
2732
|
+
existing_l = set(sm["limitations"])
|
|
2733
|
+
for _ts, t0 in mist[:8]:
|
|
2734
|
+
if t0 in existing_l:
|
|
2640
2735
|
continue
|
|
2641
|
-
sm["
|
|
2642
|
-
added["
|
|
2643
|
-
|
|
2736
|
+
sm["limitations"].append(t0)
|
|
2737
|
+
added["limitations"].append(t0)
|
|
2738
|
+
if len(sm["limitations"]) > _SELF_MODEL_MAX:
|
|
2739
|
+
del sm["limitations"][:-_SELF_MODEL_MAX]
|
|
2644
2740
|
except Exception as e:
|
|
2645
|
-
log_event("persona", f"self_model_autosink
|
|
2741
|
+
log_event("persona", f"self_model_autosink mistake 路失败:{e}", level="warn")
|
|
2646
2742
|
|
|
2647
2743
|
save_persona(p)
|
|
2648
2744
|
audit_log("ai", "self_model_autosink", "self_model",
|
package/scripts/persona.py
CHANGED
|
@@ -270,11 +270,17 @@ def compile_persona() -> dict:
|
|
|
270
270
|
_disk_now = _slurp_json(HOME / "persona.json") if (HOME / "persona.json").exists() else None
|
|
271
271
|
_disk_named = bool((( _disk_now or {}).get("identity") or {}).get("名字"))
|
|
272
272
|
_incoming_named = bool(((p.get("identity") or {}).get("名字") or "").strip())
|
|
273
|
-
|
|
273
|
+
# PERSONA-GUARD v3:只在【会丢数据】时拦(盘上已有实质内容 + 产物为空),
|
|
274
|
+
# 首次创建(无文件/盘上空)必须放行——v2 的无条件拒绝让初始化返回 None,
|
|
275
|
+
# 连锁崩掉 overview 与全部单测(12-04 03:22 实测)。
|
|
276
|
+
_disk_sub = (bool(str((_disk_now.get("identity") or {}).get("名字") or "").strip())
|
|
277
|
+
or bool(_disk_now.get("traits") or {})
|
|
278
|
+
or bool(_disk_now.get("history") or [])) if isinstance(_disk_now, dict) else False
|
|
279
|
+
if _disk_sub and not _incoming_named and not (p.get("traits") or {}):
|
|
274
280
|
log_event("persona",
|
|
275
|
-
"compile_persona
|
|
281
|
+
"compile_persona 拒绝覆盖:盘上已有实质人格而被空态重建覆盖——已拦下。",
|
|
276
282
|
level="error")
|
|
277
|
-
return
|
|
283
|
+
return _disk_now if isinstance(_disk_now, dict) else default_persona()
|
|
278
284
|
atomic_json(HOME / "persona.json", p)
|
|
279
285
|
# SPEED-1 缓存同步失效:compile_persona 直写绕过了 save_persona 的失效点
|
|
280
286
|
global _lp_cache, _lp_cache_mtime, _lp_cache_time
|
|
@@ -1469,6 +1475,63 @@ def daily_drift(days: int = 1) -> dict:
|
|
|
1469
1475
|
applied = True
|
|
1470
1476
|
audit_log("ai", "daily_drift", "state.mood_score",
|
|
1471
1477
|
f"{int(cur)}→{new}(近{days}天 net={net})")
|
|
1478
|
+
# —— 心情快照(MOOD-SNAPSHOT v5.53)——
|
|
1479
|
+
# 历史问题:emotion_timeline 只有 1 条——因为 auto_appraise 只在 extract(封存对话)
|
|
1480
|
+
# 时调用,日常 remember/capture 不经过它。补一条**每��实测**的 EMA 快照进
|
|
1481
|
+
# emotions.jsonl(genesis=False,标 source=daily-snapshot):
|
|
1482
|
+
# 不是编造情绪,是把当天真实测得的心情记进流水,让时间线有连续曲线。
|
|
1483
|
+
try:
|
|
1484
|
+
import emotion as _emo
|
|
1485
|
+
_m = _emo.mood_now()
|
|
1486
|
+
if _m.get("active") or _m.get("label") not in (None, "", "平静"):
|
|
1487
|
+
_mood_hist = p.setdefault("state", {}).setdefault("_mood_snap_ts", 0)
|
|
1488
|
+
if now - _num(_mood_hist, 0) >= 20 * 3600: # 20h 内只记一次
|
|
1489
|
+
_emo.feel(_m.get("label") or "平静",
|
|
1490
|
+
intensity=max(0.05, min(0.6, _num(_m.get("intensity"), 0.1))),
|
|
1491
|
+
why=f"每日心情快照:{_m.get('label')}(强度 {_num(_m.get('intensity'), 0):.0%})",
|
|
1492
|
+
about="每日快照", genesis=False)
|
|
1493
|
+
p["state"]["_mood_snap_ts"] = now
|
|
1494
|
+
applied = True
|
|
1495
|
+
except Exception as _e:
|
|
1496
|
+
log_event("persona", f"心情快照写入失败(不影响其他):{_e}", level="warn")
|
|
1497
|
+
|
|
1498
|
+
# —— 内驱演化(DRIVE-EVOLVE v5.52)——
|
|
1499
|
+
# 历史问题:mind_tune 只有 CLI 手动路径,从初识后好奇/理智永远不变。
|
|
1500
|
+
# 这里用【真实信号】驱动(都可追溯到记忆库),每天最多 ±2,带 history 留痕:
|
|
1501
|
+
# 好奇↑:近期用户大量要求调研/探索/深挖(说明他喜欢多问一层)
|
|
1502
|
+
# 理智↑:近期被纠正(correction)或要求证据/权衡(说明他要求严谨)
|
|
1503
|
+
try:
|
|
1504
|
+
import re as _re
|
|
1505
|
+
dr = p.setdefault("drives", {})
|
|
1506
|
+
_explore_words = ("调研", "查查", "搜一下", "深挖", "还有啥", "还有什么",
|
|
1507
|
+
"研究", "探索", "再看看", "改进", "完善", "优化", "想法")
|
|
1508
|
+
_rigor_words = ("证据", "权衡", "取舍", "利弊", "风险", "严谨",
|
|
1509
|
+
"不要猜", "查清楚", "根因")
|
|
1510
|
+
_explore_n = sum(1 for t0 in texts if any(w in t0 for w in _explore_words))
|
|
1511
|
+
_rigor_n = sum(1 for t0 in texts if any(w in t0 for w in _rigor_words))
|
|
1512
|
+
_corr_n = sum(1 for m0 in recent if m0.get("correction"))
|
|
1513
|
+
_dcur = 2 if _explore_n >= 3 else (1 if _explore_n >= 1 else 0)
|
|
1514
|
+
_drea = 2 if (_corr_n >= 1 or _rigor_n >= 3) else (1 if _rigor_n >= 1 else 0)
|
|
1515
|
+
for _k, _dv, _why0 in (("curiosity", _dcur, f"近{days}天探索类请求 {_explore_n} 条"),
|
|
1516
|
+
("reason", _drea, f"近{days}天纠正 {_corr_n} 条 / 严谨类 {_rigor_n} 条")):
|
|
1517
|
+
if not _dv:
|
|
1518
|
+
continue
|
|
1519
|
+
_old = dr.get(_k)
|
|
1520
|
+
if not isinstance(_old, (int, float)) or isinstance(_old, bool):
|
|
1521
|
+
continue
|
|
1522
|
+
_new = max(0, min(100, int(_old) + _dv))
|
|
1523
|
+
if _new != int(_old):
|
|
1524
|
+
dr[_k] = _new
|
|
1525
|
+
p.setdefault("history", []).append({
|
|
1526
|
+
"ts": now, "field": f"drives.{_k}", "from": int(_old), "to": _new,
|
|
1527
|
+
"why": f"内驱自然演化:{_why0}", "source": "drift"})
|
|
1528
|
+
audit_log("ai", "drive_evolve", f"drives.{_k}",
|
|
1529
|
+
f"{int(_old)}→{_new}({_why0})")
|
|
1530
|
+
applied = True
|
|
1531
|
+
if applied:
|
|
1532
|
+
save_persona(p)
|
|
1533
|
+
except Exception as _e:
|
|
1534
|
+
log_event("persona", f"内驱演化失败(不影响其他):{_e}", level="warn")
|
|
1472
1535
|
return {
|
|
1473
1536
|
"days": days, "memories": len(recent),
|
|
1474
1537
|
"emotion_hits": hits, "positive": positive, "negative": negative,
|
|
@@ -2588,61 +2651,94 @@ def self_model_autosink() -> dict:
|
|
|
2588
2651
|
sm["autobiography"].sort(key=lambda e: _num(e.get("ts"), 0), reverse=True)
|
|
2589
2652
|
del sm["autobiography"][_SELF_MODEL_MAX:]
|
|
2590
2653
|
|
|
2591
|
-
# —— 路 3
|
|
2592
|
-
# confidence 0.4~0.6
|
|
2654
|
+
# —— 路 3:被取代的旧结论 → uncertainties(IDEA-10 实装版)——
|
|
2655
|
+
# 原实现要求 insight 带 confidence 0.4~0.6 字段,但实测 23 条 insight 里
|
|
2656
|
+
# **0 条有 confidence**(该字段只有教训库用)→ 死代码。
|
|
2657
|
+
# 改用真实存在的信号:superseded_by(被新结论取代的旧记忆)——
|
|
2658
|
+
# "我当时是这么想的,后来发现不成立"正是最诚实的认知修正痕迹。
|
|
2593
2659
|
try:
|
|
2594
2660
|
import memory as _mem
|
|
2595
2661
|
uncer: list = []
|
|
2596
2662
|
for r in _mem.load_all():
|
|
2597
|
-
if not isinstance(r, dict) or r.get("
|
|
2598
|
-
continue
|
|
2599
|
-
conf = _num(r.get("confidence"), -1)
|
|
2600
|
-
if not (0.4 <= conf < 0.6):
|
|
2663
|
+
if not isinstance(r, dict) or not r.get("superseded_by"):
|
|
2601
2664
|
continue
|
|
2602
2665
|
ts_r = _num(r.get("ts"), 0) or _num(r.get("created"), 0)
|
|
2603
|
-
if now - ts_r >
|
|
2666
|
+
if now - ts_r > 90 * 86400: # 三个月前的旧账不再翻
|
|
2604
2667
|
continue
|
|
2605
|
-
|
|
2606
|
-
if
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2668
|
+
t0 = str(r.get("text") or r.get("summary") or "").strip()
|
|
2669
|
+
if not t0:
|
|
2670
|
+
continue
|
|
2671
|
+
uncer.append((ts_r, "曾经以为:" + t0[:140]))
|
|
2672
|
+
uncer.sort(key=lambda e: e[0], reverse=True)
|
|
2673
|
+
existing_u = set(sm["uncertainties"])
|
|
2674
|
+
for _ts, txt in uncer[:8]:
|
|
2675
|
+
if txt in existing_u:
|
|
2612
2676
|
continue
|
|
2613
|
-
sm["uncertainties"].append(
|
|
2614
|
-
added["uncertainties"].append(
|
|
2615
|
-
|
|
2677
|
+
sm["uncertainties"].append(txt) # 纯字符串:_ensure_self_model 只保留 str
|
|
2678
|
+
added["uncertainties"].append(txt)
|
|
2679
|
+
if len(sm["uncertainties"]) > _SELF_MODEL_MAX:
|
|
2680
|
+
del sm["uncertainties"][:-_SELF_MODEL_MAX]
|
|
2616
2681
|
except Exception as e:
|
|
2617
|
-
log_event("persona", f"self_model_autosink
|
|
2682
|
+
log_event("persona", f"self_model_autosink 被取代结论路失败:{e}", level="warn")
|
|
2618
2683
|
|
|
2619
|
-
# —— 路 4
|
|
2620
|
-
#
|
|
2684
|
+
# —— 路 4:反复被召回使用的高价值结论 → strengths(IDEA-10 实装版)——
|
|
2685
|
+
# 原实现要求 importance>=0.8 + access_count>=3 + 带 emotion 字段,
|
|
2686
|
+
# 但实测高重要度记忆 emo 几乎全为 None → 死代码。
|
|
2687
|
+
# 改用真实信号:importance>=0.75 且 access_count>=3——
|
|
2688
|
+
# 被系统反复召回 = 真的在用,这是能力最硬的证据(不靠自夸)。
|
|
2621
2689
|
try:
|
|
2622
2690
|
import memory as _mem
|
|
2623
2691
|
strengths_cand: list = []
|
|
2624
2692
|
for r in _mem.load_all():
|
|
2625
|
-
if not isinstance(r, dict)
|
|
2693
|
+
if not isinstance(r, dict):
|
|
2626
2694
|
continue
|
|
2627
|
-
if
|
|
2695
|
+
if r.get("kind") not in ("insight", "fact"):
|
|
2628
2696
|
continue
|
|
2629
|
-
if
|
|
2697
|
+
if _num(r.get("importance"), 0) < 0.75:
|
|
2630
2698
|
continue
|
|
2631
|
-
|
|
2699
|
+
_acc = int(_num(r.get("access_count"), 0))
|
|
2700
|
+
if _acc < 3:
|
|
2632
2701
|
continue
|
|
2633
|
-
|
|
2634
|
-
if
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2702
|
+
t0 = str(r.get("text") or r.get("summary") or "").strip()
|
|
2703
|
+
if not t0:
|
|
2704
|
+
continue
|
|
2705
|
+
strengths_cand.append((_num(r.get("created"), 0),
|
|
2706
|
+
f"(被召回 {_acc} 次)" + t0[:130]))
|
|
2707
|
+
strengths_cand.sort(key=lambda e: e[0], reverse=True)
|
|
2708
|
+
existing_s = set(sm["strengths"])
|
|
2709
|
+
for _ts, txt in strengths_cand[:8]:
|
|
2710
|
+
if txt in existing_s:
|
|
2711
|
+
continue
|
|
2712
|
+
sm["strengths"].append(txt) # 纯字符串:_ensure_self_model 只保留 str
|
|
2713
|
+
added["strengths"].append(txt)
|
|
2714
|
+
if len(sm["strengths"]) > _SELF_MODEL_MAX:
|
|
2715
|
+
del sm["strengths"][:-_SELF_MODEL_MAX]
|
|
2716
|
+
except Exception as e:
|
|
2717
|
+
log_event("persona", f"self_model_autosink 反复使用路失败:{e}", level="warn")
|
|
2718
|
+
|
|
2719
|
+
# —— 路 5:mistake 类记忆 → limitations 补充源(实装版)——
|
|
2720
|
+
# 原路1只认 correction=True,实测全库仅 1 条 → 短板几乎不积累。
|
|
2721
|
+
# mistake 类(13 条)是"我犯过的错"的一等公民,本该进短板桶。
|
|
2722
|
+
try:
|
|
2723
|
+
import memory as _mem
|
|
2724
|
+
mist = []
|
|
2725
|
+
for r in _mem.load_all():
|
|
2726
|
+
if not isinstance(r, dict) or r.get("kind") != "mistake":
|
|
2727
|
+
continue
|
|
2728
|
+
t0 = str(r.get("text") or "").strip()
|
|
2729
|
+
if t0:
|
|
2730
|
+
mist.append((_num(r.get("created"), 0), t0))
|
|
2731
|
+
mist.sort(key=lambda x: x[0], reverse=True)
|
|
2732
|
+
existing_l = set(sm["limitations"])
|
|
2733
|
+
for _ts, t0 in mist[:8]:
|
|
2734
|
+
if t0 in existing_l:
|
|
2640
2735
|
continue
|
|
2641
|
-
sm["
|
|
2642
|
-
added["
|
|
2643
|
-
|
|
2736
|
+
sm["limitations"].append(t0)
|
|
2737
|
+
added["limitations"].append(t0)
|
|
2738
|
+
if len(sm["limitations"]) > _SELF_MODEL_MAX:
|
|
2739
|
+
del sm["limitations"][:-_SELF_MODEL_MAX]
|
|
2644
2740
|
except Exception as e:
|
|
2645
|
-
log_event("persona", f"self_model_autosink
|
|
2741
|
+
log_event("persona", f"self_model_autosink mistake 路失败:{e}", level="warn")
|
|
2646
2742
|
|
|
2647
2743
|
save_persona(p)
|
|
2648
2744
|
audit_log("ai", "self_model_autosink", "self_model",
|