feat: companion 內建吹雪附帶原典記憶,首次載入時寫入

- 新增 canon.ts:41 筆簡短已查證事實(語意、情感、程序、情節),來源標在文字後
- createCompanion 載入內建角色時寫入 memory.json(canon、long,新鮮度固定 1)
- 以來源 canon 判斷,只寫一次;直接寫檔,不增加鞏固用的重要度
- 不含會過期的近況與使用者記憶

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
root
2026-10-14 10:38:26 +00:00
co-authored by Claude Sonnet 5.5
parent b6feaa1809
commit 153ed6218c
3 changed files with 84 additions and 3 deletions
@@ -471,6 +471,21 @@ describe('預設角色語氣', () => {
expect(p).toContain('狐狸')
})
test('內建吹雪首次載入時寫入原典記憶,只寫一次且不含使用者記憶', async () => {
const fs = memoryFs()
const c = createCompanion({ fs, clock: fakeClock(), root: ROOT })
await c.ensureActivated()
await c.prompt()
const path = `${ROOT}/companions/fubuki/memory.json`
const doc = JSON.parse(fs.files.get(path)!)
const canon = doc.items.filter((m: { source: string }) => m.source === 'canon')
expect(canon.length).toBeGreaterThan(0)
expect(canon.every((m: { canon: boolean; kind: string }) => m.canon && m.kind === 'long')).toBe(true)
expect(doc.pending).toBe(0)
await c.prompt()
expect(JSON.parse(fs.files.get(path)!).items.length).toBe(doc.items.length)
})
test('舊的本機資料缺少個性時以內建補上,已有的不被覆蓋', async () => {
const fs = memoryFs()
const c = createCompanion({ fs, clock: fakeClock(), root: ROOT })