handoff

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
The user wants to resume work. Optional cwd override: $ARGUMENTS
Determine the current project path: if
$ARGUMENTS
is provided, resolve it to an absolute, normalized path (accept relative inputs, e.g.
path.resolve(process.cwd(), $ARGUMENTS)
); otherwise use the current working directory.
Call the
memory_sessions
MCP tool. From the result, pick the most recent session whose normalized
cwd
matches the project path with a directory-boundary check — equality OR
session.cwd.startsWith(projectPath + path.sep)
OR
projectPath.startsWith(session.cwd + path.sep)
. Do NOT use a raw string prefix match: it produces false positives across unrelated repos that share a path prefix (e.g.
/repo-a
vs
/repo-a-staging
). Prefer sessions with status
completed
over
abandoned
. If nothing matches, fall back to the single most recent session overall.
Once a session is selected:
  1. If the session ended on an unanswered user-facing question, surface that question FIRST as the lead. Look for it in
    summary
    or in the last few observations (type
    conversation
    with
    narrative
    ending in
    ?
    ).
  2. Then summarize the session: title/summary, key files touched, key decisions or errors. Use
    memory_recall
    with a query derived from the session's top concepts to fetch supporting observations, limit 10.
  3. End with a short "next step?" pointer the user can act on.
If neither MCP tool is available, fall back to HTTP:
GET $AGENTMEMORY_URL/agentmemory/sessions
and
POST $AGENTMEMORY_URL/agentmemory/recall
with
Authorization: Bearer $AGENTMEMORY_SECRET
when set.
Do not invent observations. If the most recent session has zero observations, say so and offer to start fresh.
用户希望恢复工作。可选的工作目录覆盖参数:$ARGUMENTS
确定当前项目路径:如果提供了
$ARGUMENTS
,将其解析为绝对规范化路径(接受相对输入,例如
path.resolve(process.cwd(), $ARGUMENTS)
);否则使用当前工作目录。
调用
memory_sessions
MCP工具。从结果中选择最近的会话,该会话的规范化
cwd
需通过目录边界检查与项目路径匹配——完全相等,或
session.cwd.startsWith(projectPath + path.sep)
,或
projectPath.startsWith(session.cwd + path.sep)
。请勿使用原始字符串前缀匹配:这会在共享路径前缀的无关仓库中产生误判(例如
/repo-a
/repo-a-staging
)。优先选择状态为
completed
的会话,而非
abandoned
的会话。如果没有匹配项,则退而求其次选择整体最近的单个会话。
选定会话后:
  1. 如果会话以未解答的用户可见问题结束,首先将该问题作为开头展示。在
    summary
    或最后几条观测记录(类型为
    conversation
    narrative
    ?
    结尾)中查找该问题。
  2. 然后总结会话:标题/摘要、涉及的关键文件、关键决策或错误。使用
    memory_recall
    工具,基于会话的核心概念生成查询语句,获取支持性观测记录,限制为10条。
  3. 最后以简短的“下一步?”引导语结尾,供用户采取行动。
如果上述两个MCP工具均不可用,则退而使用HTTP方式:调用
GET $AGENTMEMORY_URL/agentmemory/sessions
,以及在设置了
Authorization: Bearer $AGENTMEMORY_SECRET
时调用
POST $AGENTMEMORY_URL/agentmemory/recall
请勿编造观测记录。如果最近的会话没有任何观测记录,请如实告知并提议重新开始。