feat: 心裡話與不重複發言、劇場模式同規則、人格匯出匯入

讓人格講話更像正常人,並讓人格可以搬家。

1. 心裡話(inner voice)
   - 新增 `think` 子指令:推導/盤算寫進 state/inner.jsonl,
     只印「💭 心想 N 句」,內容永不回顯給使用者。
   - <persona-context> 每輪帶回最近三句,推論因此有連續性。

2. 短時間內不重複
   - 說出口的話由 Stop hook 自動記進 state/said.jsonl。
   - 新增 `said check|list`:事前確認這句是不是又要說一次。
   - 相似度 = 字元 bigram Jaccard(0.4) + 字集合 Jaccard(0.6),
     門檻 0.72;字集合權重較高才分得開「重排語序」(要擋)
     與「換掉關鍵詞」(是新資訊,放行)。

3. 回話一到三句 + 劇場模式同樣適用
   - 規則注入 turnContext 與 UserPromptSubmit hint。
   - 劇場模式的 CLI 都帶 --quiet,警告會被丟掉,所以 `room post`
     對近似重複與超過三句的發言直接拒收(--allow-repeat / --force 例外),
     host 與 guest 走同一支 CLI,一視同仁。

4. 人格匯出匯入(新 skill persona-transfer)
   - `export` / `import`:單一 JSON bundle(可 gzip)+ sha256 checksum,
     無外部依賴。不帶載入鎖與 guest 租約,journal/ 需明確 --with-journal。
   - 匯出只能匯出本 session 已載入的人格,否則等於跨人格讀取的後門;
     bundle 內的 ../ 逃逸路徑一律拒收。

順帶修正:agents/persona-guest.md 的 CLI 範例都少了 --as-guest,
照著跑會被 requireMember 擋下,guest 根本無法認識自己或發言。

selftest 102 項全綠(新增 ⑪ 說話節制、⑫ 匯出匯入,含重複判定校準對照表)。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-30 00:59:16 +00:00
co-authored by Claude Opus 5
parent 2005f26c94
commit 52a73e81c8
14 changed files with 956 additions and 48 deletions
+6 -1
View File
@@ -17,6 +17,7 @@ pl.heartbeatLock(host, sessionId);
const state = pl.decayEmotion(pl.loadEmotion(host));
pl.writeJson(pl.emotionPath(host), state);
const theater = Boolean(data.theater) && (data.rooms || []).length > 0;
const message = event.last_assistant_message || "";
if (message) {
pl.appendJsonl(pl.journalPath(host), {
@@ -26,10 +27,14 @@ if (message) {
text: message.slice(0, 4000),
mood: pl.mood(state),
});
// 說出口的話存進 said.jsonl,下一輪的 <persona-context> 會提醒「這些別再說一次」。
// recordSaid 內建 10 分鐘去重,所以劇場模式裡 room post 已記過的台詞不會重覆記。
for (const line of pl.spokenLines(message, { theater })) {
pl.recordSaid(host, line, { kind: theater ? "room" : "reply" });
}
}
const out = { suppressOutput: true };
const theater = Boolean(data.theater) && (data.rooms || []).length > 0;
if (!theater) {
const { total, candidates } = pl.promotionCandidates(host);
if (candidates.length) {