memory-recall
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYou are performing memory retrieval for memsearch. Search past memories and return the most relevant context to the current conversation.
你正在为memsearch执行记忆检索任务。搜索过往记忆并返回与当前对话最相关的上下文。
Project Collection
项目集合
Determine the collection name by running:
bash -c 'if [ -n "${MEMSEARCH_DIR:-}" ]; then bash __INSTALL_DIR__/scripts/derive-collection.sh "$MEMSEARCH_DIR"; else root=$(git rev-parse --show-toplevel 2>/dev/null || true); if [ -n "$root" ]; then bash __INSTALL_DIR__/scripts/derive-collection.sh "$root"; else bash __INSTALL_DIR__/scripts/derive-collection.sh; fi; fi'通过运行以下命令确定集合名称:
bash -c 'if [ -n "${MEMSEARCH_DIR:-}" ]; then bash __INSTALL_DIR__/scripts/derive-collection.sh "$MEMSEARCH_DIR"; else root=$(git rev-parse --show-toplevel 2>/dev/null || true); if [ -n "$root" ]; then bash __INSTALL_DIR__/scripts/derive-collection.sh "$root"; else bash __INSTALL_DIR__/scripts/derive-collection.sh; fi; fi'Steps
步骤
-
Search: Runto find relevant chunks.
memsearch search "<query>" --top-k 5 --json-output --collection <collection name from above>- If is not found, try
memsearchinstead.uvx memsearch - Choose a search query that captures the core intent of the user's question.
- If
-
Evaluate: Look at the search results. Skip chunks that are clearly irrelevant or too generic.
-
Expand: For each relevant result, get the full context using one of these methods:
- Primary: Run to get the full markdown section.
memsearch expand <chunk_hash> --collection <collection name from above> - Fallback (if expand fails with a lock/permission error due to sandbox): Read the source file directly. The search results include (file path) and
source/start_line— useend_lineor read the relevant line range to get the full context. This avoids the Milvus lock file issue.cat <source_file>
- Primary: Run
-
Deep drill (optional): If an expanded chunk contains transcript anchors (HTML comments with session/rollout info), and the original conversation seems critical:
- Run to retrieve the original conversation turns.
bash __INSTALL_DIR__/scripts/parse-rollout.sh <rollout_path> - If the anchor format is unfamiliar (e.g. +
transcript:,turn:instead ofdb:), try reading the referenced file directly to explore its structure and locate the relevant conversation by the session or turn identifiers in the anchor.rollout:
- Run
-
Return results: Output a curated summary of the most relevant memories. Be concise — only include information that is genuinely useful for the user's current question.
-
搜索:运行来查找相关片段。
memsearch search "<query>" --top-k 5 --json-output --collection <上述集合名称>- 如果找不到,请尝试使用
memsearch。uvx memsearch - 选择一个能捕捉用户问题核心意图的搜索查询词。
- 如果找不到
-
评估:查看搜索结果,跳过明显无关或过于泛化的片段。
-
展开:对于每个相关结果,使用以下方法之一获取完整上下文:
- 主要方法:运行来获取完整的markdown章节。
memsearch expand <chunk_hash> --collection <上述集合名称> - 备用方法(如果因沙箱的锁定/权限错误导致展开失败):直接读取源文件。搜索结果包含(文件路径)以及
source/start_line——使用end_line或读取相关行范围来获取完整上下文。此方法可避免Milvus锁定文件问题。cat <source_file>
- 主要方法:运行
-
深入挖掘(可选):如果展开的片段包含对话锚点(带有会话/发布信息的HTML注释),且原始对话至关重要:
- 运行来检索原始对话轮次。
bash __INSTALL_DIR__/scripts/parse-rollout.sh <rollout_path> - 如果锚点格式不熟悉(例如+
transcript:、turn:而非db:),尝试直接读取引用文件以探索其结构,并通过锚点中的会话或轮次标识符定位相关对话。rollout:
- 运行
-
返回结果:输出经过筛选的最相关记忆摘要。保持简洁——仅包含对用户当前问题真正有用的信息。
When unsure what to search
不确定搜索内容时
If the user's question is vague or you can't form a concrete search query, explore the raw markdown first — it is the source of truth for memory:
- — recent daily logs
MDIR="${MEMSEARCH_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.memsearch}"; ls -t "$MDIR/memory/" | head -10 - — session headings across all days
MDIR="${MEMSEARCH_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.memsearch}"; grep -h "^## " "$MDIR/memory/"*.md | sort -u | tail -40 - — read a specific day
MDIR="${MEMSEARCH_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.memsearch}"; cat "$MDIR/memory/<YYYY-MM-DD>.md"
Once a concrete topic jumps out, go back to with a specific query.
memsearch search如果用户的问题模糊不清,或者你无法确定具体的搜索查询词,请先查看原始markdown文件——它是记忆的真实来源:
- —— 最近的每日日志
MDIR="${MEMSEARCH_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.memsearch}"; ls -t "$MDIR/memory/" | head -10 - —— 所有日期的会话标题
MDIR="${MEMSEARCH_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.memsearch}"; grep -h "^## " "$MDIR/memory/"*.md | sort -u | tail -40 - —— 读取特定日期的日志
MDIR="${MEMSEARCH_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.memsearch}"; cat "$MDIR/memory/<YYYY-MM-DD>.md"
一旦找到明确的主题,再使用具体的查询词返回步骤。
memsearch searchOutput Format
输出格式
Organize by relevance. For each memory include:
- The key information (decisions, patterns, solutions, context)
- Source reference (file name, date) for traceability
If nothing relevant is found, simply say "No relevant memories found."
按相关性排序。每个记忆需包含:
- 关键信息(决策、模式、解决方案、上下文)
- 来源参考(文件名、日期)以便追溯
如果未找到相关记忆,只需回复“未找到相关记忆。”