commit-context

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
The user wants commit context for: $ARGUMENTS
Run
git blame
(or
git log -L
) on the target file, function, or line in $ARGUMENTS to extract the most recent commit SHA that touched it. Use
git blame -L <start>,<end> <file>
when a line range is given,
git log -L :<function>:<file>
when a function name is given, and
git log -n 1 -- <file>
when only a path is given.
With the SHA in hand, look up the linked agent session via the
memory_commit_lookup
MCP tool with
sha: "<full-sha>"
. If the MCP tool is unavailable, fall back to HTTP:
GET $AGENTMEMORY_URL/agentmemory/session/by-commit?sha=<sha>
with
Authorization: Bearer $AGENTMEMORY_SECRET
when the secret is set.
Present the result as:
  • The commit SHA, short SHA, branch, author, message
  • The linked session(s): id, project, started/ended timestamps, observation count, summary if any
  • A short list of the most important observations from that session (importance >= 7) when available via
    memory_recall
Do not fabricate intent. If the commit has no linked session, say so plainly and surface only what
git show
reveals. If
memory_commit_lookup
returns an empty
commit: null
body, that means the commit predates session linking — do not invent a session.
用户需要以下内容的提交上下文:$ARGUMENTS
在$ARGUMENTS指定的目标文件、函数或代码行上运行
git blame
(或
git log -L
),提取最近修改该内容的提交SHA值。如果指定了行范围,使用
git blame -L <start>,<end> <file>
;如果指定了函数名,使用
git log -L :<function>:<file>
;如果仅指定了路径,使用
git log -n 1 -- <file>
获取SHA值后,通过
memory_commit_lookup
MCP工具,传入参数
sha: "<full-sha>"
来查询关联的Agent会话。如果MCP工具不可用,当设置了密钥时,回退使用HTTP请求:
GET $AGENTMEMORY_URL/agentmemory/session/by-commit?sha=<sha>
,请求头携带
Authorization: Bearer $AGENTMEMORY_SECRET
结果呈现格式如下:
  • 提交SHA、短SHA、分支、作者、提交信息
  • 关联的会话:ID、项目、开始/结束时间戳、观测次数、摘要(如有)
  • 该会话中最重要的观测列表(重要性≥7)(当可通过
    memory_recall
    获取时)
请勿编造意图。如果该提交没有关联的会话,请直接说明,仅展示
git show
返回的内容。如果
memory_commit_lookup
返回
commit: null
的空响应体,说明该提交早于会话关联功能的启用,请勿虚构会话。