memory-management

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Memory Management Skill

Memory Management Skill

Alma has a built-in memory system with semantic search. Use the
alma
CLI to interact with it.
Alma内置了一套带有语义搜索功能的记忆系统,可通过
alma
CLI与其交互。

Commands

命令

bash
undefined
bash
undefined

List all memories

List all memories

alma memory list
alma memory list

Semantic search

Semantic search

alma memory search <query>
alma memory search <query>

Add a memory

Add a memory

alma memory add <content>
alma memory add <content>

Delete a memory

Delete a memory

alma memory delete <id>
alma memory delete <id>

View memory stats

View memory stats

alma memory stats
undefined
alma memory stats
undefined

When to Use

使用场景

  • User asks anything about the past ("你知道我喜欢什么吗", "我们之前讨论过什么", "上次说的那个方案是什么") → Search memories AND grep threads
  • User says "remember this"
    alma memory add "..."
  • User asks "do you remember..."
    alma memory search "..."
    +
    alma memory grep "..."
  • User says "forget about..." → Search and delete matching memories
  • Time-sensitive info (projects, deadlines) → Store with appropriate context
  • 用户询问任何与过往相关的内容(例如“你知道我喜欢什么吗”、“我们之前讨论过什么”、“上次说的那个方案是什么”)→ 搜索记忆并使用grep查询线程
  • 用户说“帮我记住这个” → 执行
    alma memory add "..."
  • 用户问“你还记得...吗” → 执行
    alma memory search "..."
    +
    alma memory grep "..."
  • 用户说“忘了这个吧” → 搜索并删除匹配的记忆
  • 时效性信息(项目、截止日期)→ 结合适当上下文存储

Search Strategy

搜索策略

When the user asks about past information, always try both layers:
  1. alma memory search "<query>"
    — semantic search for related concepts
  2. alma memory grep "<keyword>"
    — keyword search in conversation history
If one layer returns nothing, try the other. They complement each other.
当用户询问过往信息时,务必同时尝试两种方式
  1. alma memory search "<query>"
    —— 语义搜索相关概念
  2. alma memory grep "<keyword>"
    —— 在对话历史中进行关键词搜索
如果其中一种方式没有结果,尝试另一种,二者可以互补。

Conversation History Search

对话历史搜索

Alma automatically archives all threads as markdown files. You can search through past conversations:
bash
undefined
Alma会自动将所有线程归档为markdown文件,你可以搜索过往对话:
bash
undefined

Keyword search through all archived conversations

Keyword search through all archived conversations

alma memory grep <keyword>
alma memory grep <keyword>

Force re-archive all threads now

Force re-archive all threads now

alma memory archive

Thread archives are stored in the workspace's `threads/` directory as markdown files with YAML frontmatter (threadId, title, createdAt, updatedAt, model, messageCount). Archives are auto-updated every 5 minutes.
alma memory archive

线程归档文件存储在工作区的`threads/`目录下,为带有YAML前置元数据(threadId、标题、创建时间、更新时间、模型、消息数量)的markdown文件。归档文件每5分钟自动更新一次。

Two-Layer Memory

双层记忆机制

  1. Vector Memory (
    alma memory search
    ) — semantic search, finds conceptually related memories
  2. Conversation Archives (
    alma memory grep
    ) — keyword search, finds exact words/phrases in past conversations
Use vector search when the user asks vague questions ("what did we discuss about React?"). Use grep when looking for specific terms, names, or code snippets.
  1. 向量记忆
    alma memory search
    )—— 语义搜索,查找概念相关的记忆
  2. 对话归档
    alma memory grep
    )—— 关键词搜索,在过往对话中查找精确词汇/短语
当用户提出模糊问题时使用向量搜索(例如“我们之前讨论过关于React的什么内容?”)。当查找特定术语、名称或代码片段时使用grep搜索。

Group Chat History

群聊历史

Alma persists all group chat messages to log files. Search and browse them:
bash
undefined
Alma会将所有群聊消息持久化到日志文件中,可搜索和浏览:
bash
undefined

List all known groups

List all known groups

alma group list
alma group list

View recent history (default 50 messages)

View recent history (default 50 messages)

alma group history <chatId> [limit]
alma group history <chatId> [limit]

Search across all group chats

Search across all group chats

alma group search <keyword>

Log files are stored at `~/.config/alma/groups/<chatId>_<date>.log`. Use this when you need to recall what was discussed in a group chat.
alma group search <keyword>

日志文件存储在`~/.config/alma/groups/<chatId>_<date>.log`路径下。当你需要回忆群聊中讨论的内容时可使用此功能。

People Profiles (Per-Person Memory)

个人档案(按用户存储的记忆)

For group chats, Alma maintains structured per-person profiles — more reliable than vector search for remembering who is who.
bash
undefined
对于群聊,Alma维护了结构化的个人档案——相较于向量搜索,这种方式在区分用户身份时更可靠。
bash
undefined

List all known people

List all known people

alma people list
alma people list

View someone's profile

View someone's profile

alma people show <name>
alma people show <name>

Set/overwrite profile

Set/overwrite profile

alma people set <name> <content>
alma people set <name> <content>

Append to profile

Append to profile

alma people append <name> <fact>
alma people append <name> <fact>

Delete profile

Delete profile

alma people delete <name>

**When to update profiles:**
- Someone shares personal info (job, hobbies, preferences)
- You learn their communication style or language preference
- They mention relationships with other people
- Any fact you'd want to remember next time you talk to them

Profiles are stored at `~/.config/alma/people/<name>.md` and automatically loaded into group chat context.
alma people delete <name>

**何时更新档案:**
- 用户分享个人信息(职业、爱好、偏好)
- 你了解到他们的沟通风格或语言偏好
- 他们提及与他人的关系
- 任何你下次与他们交流时需要记住的信息

档案文件存储在`~/.config/alma/people/<name>.md`路径下,并会自动加载到群聊上下文当中。

Tips

小贴士

  • Always confirm what you stored/deleted with the user
  • Use
    alma memory search
    to find related memories before adding duplicates
  • Memories are automatically injected into conversations via semantic search — you don't need to manually recall them every time
  • Use
    alma memory grep
    to search through conversation history when vector search doesn't find what you need
  • For per-person facts, prefer
    alma people
    over
    alma memory
    — structured and won't get mixed up
  • 始终向用户确认你已存储/删除的内容
  • 添加重复记忆前,先使用
    alma memory search
    查找相关记忆
  • 记忆会通过语义搜索自动注入对话中——无需每次手动回忆
  • 当向量搜索无法找到所需内容时,使用
    alma memory grep
    搜索对话历史
  • 对于个人相关信息,优先使用
    alma people
    而非
    alma memory
    ——结构化存储,不会混淆