fix(identity): 接通身份信号提取与持久化 — 对话中起名跨会话记忆
Some checks failed
CI / Rust Check (push) Has been cancelled
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

根因: 记忆提取管道(COMBINED_EXTRACTION_PROMPT)提取5种画像信号
但无身份信号(agent_name/user_name),不存在从对话到AgentConfig.name
或IdentityFiles的写回路径。

修复内容:
- ProfileSignals 增加 agent_name/user_name 字段
- COMBINED_EXTRACTION_PROMPT 增加身份提取指令
- parse_profile_signals 解析新字段 + 回退推断
- GrowthIntegration 存储身份信号到 VikingStorage
- post_conversation_hook 写回 soul.md + emit Tauri 事件
- streamStore 规则化检测 agent 名字并更新 AgentConfig.name
- cold-start-mapper 新增 detectAgentNameSuggestion

链路: 对话→提取→VikingStorage→hook写回soul.md→事件→前端刷新
This commit is contained in:
iven
2026-04-23 09:20:35 +08:00
parent 17a7a36608
commit 08812e541c
7 changed files with 431 additions and 22 deletions

View File

@@ -146,6 +146,32 @@ export function detectNameSuggestion(message: string): string | undefined {
return undefined;
}
/**
* Detect if user gives the agent a name (e.g., "叫你小马", "以后叫你小马", "你的名字是小马").
* Returns the detected agent name or undefined.
*/
export function detectAgentNameSuggestion(message: string): string | undefined {
if (!message) return undefined;
const patterns = [
/叫你[""''「」]?(\S{1,8})[""''「」]?[吧。!]?/,
/你的名字[是为][""''「」]?(\S{1,8})[""''「」]?[。!]?/,
/以后叫你[""''「」]?(\S{1,8})[""''「」]?[吧。!]?/,
/给你起[个]?名[字]?(?:叫)?[""''「」]?(\S{1,8})[""''「」]?/,
/name you (\S{1,15})/i,
/call you (\S{1,15})/i,
];
for (const pattern of patterns) {
const match = message.match(pattern);
if (match && match[1]) {
const name = match[1].replace(/[吧。!,、]/g, '').trim();
if (name.length >= 1 && name.length <= 8) {
return name;
}
}
}
return undefined;
}
/**
* Determine the next cold start phase based on current phase and user message.
*/