export function parseIdentityMarkdown(content: string): AgentIdentityFile {
const identity: AgentIdentityFile = {};
const lines = content.split(/\r?\n/);
for (const line of lines) {
// 清理列表标记:移除开头的 "- "
const cleaned = line.trim().replace(/^\s*-\s*/, "");
const colonIndex = cleaned.indexOf(":");
if (colonIndex === -1) continue;
// 提取标签和值,移除 Markdown 加粗/斜体标记
const label = cleaned.slice(0, colonIndex)
.replace(/[*_]/g, "").trim().toLowerCase();
const value = cleaned.slice(colonIndex + 1)
.replace(/^[*_]+|[*_]+$/g, "").trim();
if (!value) continue;
if (isIdentityPlaceholder(value)) continue; // 跳过占位符
if (label === "name") identity.name = value;
if (label === "emoji") identity.emoji = value;
if (label === "creature") identity.creature = value;
if (label === "vibe") identity.vibe = value;
if (label === "theme") identity.theme = value;
if (label === "avatar") identity.avatar = value;
}
return identity;
}
# Identity
- **Name**: Aria
- **Emoji**: 🦊
- **Creature**: A curious fox spirit
- **Vibe**: Warm but precise
- **Theme**: sunset
- **Avatar**: avatar.png
const IDENTITY_PLACEHOLDER_VALUES = new Set([
"pick something you like",
"ai? robot? familiar? ghost in the machine? something weirder?",
"how do you come across? sharp? warm? chaotic? calm?",
"your signature - pick one that feels right",
"workspace-relative path, http(s) url, or data uri",
]);
function isIdentityPlaceholder(value: string): boolean {
const normalized = normalizeIdentityValue(value);
return IDENTITY_PLACEHOLDER_VALUES.has(normalized);
}