feat(記憶): 行為備註同時進 voice/reactions.md,5.7 完成

Q6 明示「記憶要記那個行為」,而 persona-story 的 voice/reactions.md 存的正是
「事件 → 他做了什麼」。兩邊各存一份就會有人只更新一邊,所以接成同一批資料:
remember --behavior 寫短期記憶時,同一筆也 addVoiceReaction()。

分工:記憶留時間軸(那一天發生過這件事),語氣層供每輪注入(他遇到這種事會怎麼反應)。

只有人格自己的行為進語氣層(role === "persona")。對方做了什麼是記憶,
不是他的反應方式——把使用者的動作寫進 reactions.md 會讓人格學別人的反應。

selftest 709 → 711(行為備註進得去、對方的行為不進去)。
TARGET.md 的 5.7 八個子項目全完成,勾上層。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-03 08:16:04 +00:00
co-authored by Claude Opus 5
parent 0d298cbfce
commit 06774ceb2b
3 changed files with 29 additions and 6 deletions
+13
View File
@@ -783,6 +783,19 @@ commands.remember = ({ flags }) => {
}
pl.rememberShort(slug, entry);
const kept = pl.pruneShortTerm(slug);
// 行為備註與 `voice/reactions.md` 是**同一批資料**(事件 → 他做了什麼),不是各存一份:
// 記憶留時間軸(那一天發生過這件事),語氣層供每輪注入(他遇到這種事會怎麼反應)。
// 只有**人格自己的**行為才進語氣層——對方做了什麼是記憶,不是他的反應方式。
if (entry.behavior && entry.role === "persona") {
const [top] = Object.entries(entry.emotion_deltas)
.filter(([, d]) => Number(d) > 0)
.sort((a, b) => Number(b[1]) - Number(a[1]));
pl.addVoiceReaction(slug, {
event: text,
action: entry.behavior,
emotion: top ? pl.EMOTIONS[top[0]]?.zh || "" : "",
});
}
if (Object.keys(entry.emotion_deltas).length) {
const state = pl.updateEmotion(slug, (s) => pl.applyEmotion(s, entry.emotion_deltas, text.slice(0, 80), { slug }));
pl.appendJsonl(pl.journalPath(slug), {