end-session
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEnd session
结束会话
Close out the session so the next one starts from an accurate picture instead of reconstructing
one. A session's durable output is more than its diff: what it learned (memory), what it
moved (issues and the board), what a human must now do (follow-ups), what its docs now
get wrong, and what it left behind (the workspace). Sweep those, in that order.
Announce at start: "I'm using the end-session skill to close out this session."
Run shell snippets in bash (Git Bash on Windows). Where is unavailable, use the equivalent
GitHub MCP operation: a missing CLI changes the interface, not the step.
ghThis skill leaves shipping to the skill: no version bump, changelog section, source push,
or PR. A finished branch is shipped first, then this runs; a mid-flight branch stays mid-flight,
recorded where it stands.
shipThree rules hold throughout:
- Evidence, not recollection. An empty bucket is a valid outcome; say so and move on. An invented memory, comment, or entry is worse than none.
- List before deleting. Every deletion — file, branch, worktree, container — is shown as a list and waits for a yes.
- Ask before committing or discarding, except where a setting pre-authorizes it.
结束会话,让下一次会话从准确的现状开始,而不是靠重新拼凑还原。一次会话的持久产出不只是它的 diff,还包括它学到了什么(memory)、推进了什么(issues 和 Board)、现在必须由人处理什么(follow-ups)、文档中有哪些内容已经过时,以及遗留了什么(workspace)。按这个顺序逐一检查。
开始时宣告:「我正在使用 end-session Skill 来结束本次会话。」
在 bash(Windows 上使用 Git Bash)中运行 shell 代码段。如果无法使用 ,则使用等效的 GitHub MCP 操作:缺少 CLI 只会改变执行接口,不会改变步骤。
gh本 Skill 将发布工作留给 Skill:不执行版本号递增、changelog 条目、源代码 push 或 PR。已完成的 branch 会先发布,然后才运行本 Skill;仍在进行中的 branch 保持原状,并记录其当前进度。
ship整个过程中始终遵循三条规则:
- 以证据为准,而不是凭记忆。 没有产出也是有效结果;说明情况后继续。虚构的 memory、comment 或条目比没有更糟。
- 先列出,再删除。 每一次删除——文件、branch、worktree、container——都要先以列表形式展示,并等待用户确认。
- 提交或丢弃前先询问, 除非某项设置已预先授权。
0. Settings
0. 设置
This skill reads , ,
, and . Follow
to read them and complete any that are missing; the
definitions sit beside it. Resolve each value once, here, and reuse it below.
docs/agents/workspace.mddocs/agents/issue-tracker.mddocs/agents/human-follow-up.mddocs/agents/docs.mddocs/agents/triage-labels.md.agents/skills/end-session/settings/README.mddiscover:Invoked by handoff: when the arguments say , the
handoff document is already written and registered. Carry its path into the report, and treat the
user's work as continuing on the other machine, not in this checkout.
invoked by handoff; document at <path>本 Skill 读取 、、、 和 。按照 的说明读取这些文件,并补齐任何缺失项;相关定义就在该文件旁。在这里将每个 值解析一次,并在下文复用。
docs/agents/workspace.mddocs/agents/issue-tracker.mddocs/agents/human-follow-up.mddocs/agents/docs.mddocs/agents/triage-labels.md.agents/skills/end-session/settings/README.mddiscover:**由 handoff 调用:**当参数显示 时,handoff 文档已经写好并登记。将其路径带入报告,并将用户的工作视为正在另一台机器上继续,而不是在这个 checkout 中继续。
invoked by handoff; document at <path>1. Take stock
1. 盘点
Establish what the session did before writing anything:
bash
git status --short --branch
git branch --show-current
git log --oneline origin/main..HEAD
gh pr list --author @me --state open --json number,title,headRefNameThen run the . Sort what the session produced into the buckets below;
each routes to a later step.
Workspace status command| Bucket | Step |
|---|---|
| Durable facts about how to work in this repository or environment | 2. Memory |
| Work started, finished, blocked, discovered, or understood differently | 3. Issues |
| Actions only a human can now take | 4. Human follow-ups |
| Decisions, findings, and state changes the docs should hold | 5. Docs |
| Files, branches, worktrees, containers left behind | 6. Workspace |
在写入任何内容前,确定本次会话做了什么:
bash
git status --short --branch
git branch --show-current
git log --oneline origin/main..HEAD
gh pr list --author @me --state open --json number,title,headRefName然后运行 。将本次会话的产出分类到以下类别;每一项都对应后续步骤。
Workspace status command| 类别 | 步骤 |
|---|---|
| 关于如何在此仓库或环境中工作的持久事实 | 2. Memory |
| 已开始、已完成、被阻塞、已发现,或理解发生了变化的工作 | 3. Issues |
| 现在只有人能采取的操作 | 4. Human follow-ups |
| 文档应当记录的决定、发现和状态变更 | 5. Docs |
| 遗留的文件、branch、worktree、container | 6. Workspace |
2. Memory
2. Memory
Memory lives outside the repository, one fact per file, in the memory directory the harness names
in its instructions. Use that path exactly as given: a path derived from the checkout location
differs per machine and per tool, and writes to a wrong one succeed silently and are never read. If
the harness names no memory directory, skip this step and say so in the report. there
is the index: one line per memory, never content.
MEMORY.mdSave a candidate only when a fresh session here would get it wrong without the note and the
repository does not already record it. , the docs, the issue tracker, the changelog,
and Git history are durable; a memory restating them goes stale the moment they change. Memory is
for what is written nowhere: a trap that cost time, a preference the user stated, the state of
half-decided work.
AGENTS.md- Read first, and update a matching memory rather than adding a near-duplicate.
MEMORY.md - Correct or delete a memory this session proved wrong.
- Write absolute dates, link related memories with , and keep every
[[slug]]pointer in step with the files.MEMORY.md - Keep an unpatched security weakness out of memory bodies; point at where it is tracked instead.
Memory 位于仓库之外,按照 harness 说明指定的 memory 目录组织,每个文件只保存一项事实。严格使用给定的路径:从 checkout 位置推导出的路径会因机器和工具而异,写入错误路径会静默成功,却永远不会被读取。如果 harness 未指定 memory 目录,则跳过此步骤并在报告中说明。该目录中的 是索引:每条 memory 占一行,绝不写入正文。
MEMORY.md仅当没有这条记录,新的会话在这里就会判断错误,并且仓库中尚未记录该信息时,才保存候选 memory。、文档、issue tracker、changelog 和 Git history 都是持久信息源;重复记录这些内容的 memory 会在它们发生变化后立即过时。Memory 只用于记录其他地方没有的信息:曾经耗费时间的陷阱、用户明确表达的偏好,以及尚处于决策中途的工作状态。
AGENTS.md- 先读取 ;如果已有匹配的 memory,则更新它,而不是添加近似重复项。
MEMORY.md - 如果本次会话证明某条 memory 有误,则更正或删除它。
- 写入绝对日期,使用 关联相关 memory,并确保
[[slug]]中的每个指针都与文件保持同步。MEMORY.md - 不要在 memory 正文中保留尚未修补的安全弱点;应指向其受跟踪的位置。
3. Issues and the board
3. Issues 与 Board
Issues carry the work; the carries its state. Labels are the five in
, plus any in
.
Board.agents/skills/end-session/settings/triage-labels.mdExtra labelsdocs/agents/triage-labels.mdBoard writes need the token's scope, and fail silently without it. Check
for (not just ). If it is missing, report it and skip board
writes; the fix () needs a real terminal.
ghprojectgh auth statusprojectread:projectgh auth refresh -h github.com -s projectRead and write the only through , never
or : it finds an item from its issue, matches field and option
names whatever their case or dash, writes an item's fields in one request, and reads every write
back. below is the setting's two words:
Board.agents/skills/end-session/board.mjsgh project item-edititem-list<board>Boardbash
node .agents/skills/end-session/board.mjs file --board "<board>" --item <owner/name#N> --set "Status=Todo"
node .agents/skills/end-session/board.mjs set --board "<board>" --item <owner/name#N> --set "Blocked by=<reason>"
node .agents/skills/end-session/board.mjs audit --board "<board>" --repo <Public repository>fileset--set "<Field>="P2errorStart from what is open, in the and again in the
when there is one — always selected explicitly with :
Public repositoryPrivate issue repository-Rbash
gh issue list -R <repository> --state open --json number,title,labels \
--jq '[.[] | {number, title, labels: [.labels[].name]}]'For each issue the session touched:
- Shipped — comment the outcome and what changed about the understanding of the problem. Close it once its PR has merged; while the PR is open, leave it open and name the PR.
- Advanced but unfinished — comment where it stands and the next concrete step, written for a reader arriving cold.
- Blocked — comment the blocker, and set the that record it.
Board fields - Understanding changed — correct the body, or comment the correction. An issue describing the wrong problem costs more than a missing one.
- Newly discovered work — record it as says: an issue, labelled and filed on the
New workwithBoard; or aboard.mjs filedraft item (Board, whosegh project item-create --format jsonis the item's), left for the work's commitment to turn into an issue, its fields set withid. Set its board fields either way. Work that never reaches the board is invisible to the next session.board.mjs set --item-id <id>
Then run , with for the and again for the
when there is one. Set Done on each item the session's
work closed; report the rest of , every item and every issue
rather than fixing what the session never touched. The private tracker's results stay out of
anything public.
board.mjs audit--repoPublic repositoryPrivate issue repositoryclosedNotDoneclosedNotDoneopenDonemissingA security finding follows the route, never a public issue before its fix
ships. Keep private-repository links and content out of public issues, PRs, and commits. Leave
issues the session never touched to the skill.
Security findingstriageIssues 承载工作,Board 承载其状态。标签包括 中的五项,以及 中列出的所有 。
.agents/skills/end-session/settings/triage-labels.mddocs/agents/triage-labels.mdExtra labelsBoard 写入需要 token 具备 scope,缺少该权限时会静默失败。通过 检查 ,不能只检查 。如果缺少该权限,则报告并跳过 Board 写入;修复命令 需要在真实终端中执行。
ghprojectgh auth statusprojectread:projectgh auth refresh -h github.com -s project读取和写入 时只能使用 ,不要使用 或 :它会从 issue 查找对应条目,匹配字段名和选项名(无论大小写或连字符形式),在一次请求中写入条目字段,并回读每次写入。下方的 代表 设置中的两个词:
Board.agents/skills/end-session/board.mjsgh project item-edititem-list<board>Boardbash
node .agents/skills/end-session/board.mjs file --board "<board>" --item <owner/name#N> --set "Status=Todo"
node .agents/skills/end-session/board.mjs set --board "<board>" --item <owner/name#N> --set "Blocked by=<reason>"
node .agents/skills/end-session/board.mjs audit --board "<board>" --repo <Public repository>fileset--set "<Field>="P2error从 中当前开放的条目开始;如果存在 ,也对其执行相同操作——始终使用 显式选择仓库:
Public repositoryPrivate issue repository-Rbash
gh issue list -R <repository> --state open --json number,title,labels \
--jq '[.[] | {number, title, labels: [.labels[].name]}]'对于本次会话涉及的每个 issue:
- 已发布——评论最终结果,以及对问题的理解发生了哪些变化。PR 合并后关闭 issue;PR 仍开放时保持 issue 开放,并注明该 PR。
- 已推进但未完成——评论当前进度和下一步具体行动,让初次接触该工作的读者也能理解。
- 被阻塞——评论阻塞原因,并设置记录该情况的 。
Board fields - 理解发生变化——更正正文,或评论更正内容。描述错误问题的 issue 比缺失 issue 更糟糕。
- 新发现的工作——按照 所述方式记录:创建 issue,添加标签并通过
New work登记到board.mjs file;或者创建 Board 草稿条目(Board,其gh project item-create --format json就是该条目的 ID),暂不将其转为 issue,但应承诺后续转为 issue,并通过id设置字段。无论采用哪种方式,都要设置其 Board 字段。未进入 Board 的工作对下一次会话而言是不可见的。board.mjs set --item-id <id>
然后运行 ,对 使用 ;如果存在 ,也再运行一次。将本次会话的工作所关闭的每个 条目标记为 Done;其余 、每个 条目和每个 issue 均予以报告,而不是修复本次会话从未触及的内容。私有 tracker 的结果不得进入任何公开内容。
board.mjs auditPublic repository--repoPrivate issue repositoryclosedNotDoneclosedNotDoneopenDonemissing安全发现遵循 路径;在修复发布之前,绝不创建公开 issue。将私有仓库的链接和内容排除在公开 issue、PR 和 commit 之外。未触及的 issue 留给 skill 处理。
Security findingstriage4. Human follow-ups
4. Human follow-ups
Run the in for every
required human action left by the session's completed work, including ones other skills
already started (docs-updater, ): reconcile those rather than duplicating them.
## Procedure.agents/skills/end-session/settings/human-follow-up.mdship针对本次会话已完成工作留下的每项必要人工操作,运行 中的 ,包括其他 Skill 已开始处理的事项(docs-updater、ship):应进行协调,而不是重复创建。
.agents/skills/end-session/settings/human-follow-up.md## Procedure5. Docs
5. Docs
Run the skill on the session's work, in a subagent where the harness has one, told to
follow ; otherwise follow it yourself. A subagent cannot ask
the user, so complete its settings first, here, by following its step 0. Use mode for work not
yet merged, and mode for work already refreshed and merged, recording any drift it
reports as new work, as step 3 does. Merged work whose report owed a wiki search gets one
more run in mode, limited to the wikis: those stale references are fixed, not filed.
Tell it this is , and give it the session's discoveries as a list of changes beside
the diff: decisions and findings land in the
documents whose when they match, honoring each one's marker. Run step 4's procedure for any
human actions it returns. Its edits come back uncommitted, and join step 6's question about
uncommitted work. Keep its report for step 7.
docs-updater.agents/skills/docs-updater/SKILL.mdfixcheckshipshipfixend-sessionDoc map- Companion. When the is set and its checkout exists, inspect it from its own root: the outer repository's
Private companion,git logandgit showcannot see inside it. When the checkout is absent, report that companion docs could not be reconciled, and create no directory in its place. Commit companion changes by thegit diffin## Procedure..agents/skills/end-session/settings/workspace.md - Changelog debt. A behavior change committed this session without its entry (its
Unreleasedfragment, withchangelog.d/) is debt to report;Scheme: stamp-on-tagwrites the changelog.ship - One tracker. A backlog, roadmap, or TODO file the session added to the tree duplicates the issue tracker; offer to move its content into issues.
在 harness 支持 subagent 时,以 subagent 方式运行 skill 来处理本次会话的工作,并要求其遵循 ;否则自行执行。Subagent 无法询问用户,因此先在此处按照其步骤 0 完成设置。对于尚未合并的工作,使用 模式;对于 已刷新且已合并的工作,使用 模式,并按照步骤 3 将其报告的任何偏差记录为新工作。如果已合并工作的 报告表明还需要进行 wiki 搜索,则再以 模式运行一次,但仅限于 wiki:这些过时引用应予修复,而不是创建 issue。
docs-updater.agents/skills/docs-updater/SKILL.mdfixshipcheckshipfix告知它本次运行的是 ,并以变更列表形式提供本次会话的发现,与 diff 并列:决定和发现应落到 文档中——当其 when 标记匹配时,并遵循每个文档的 marker。对其返回的所有人工操作运行步骤 4 的流程。其编辑结果以未提交状态返回,并纳入步骤 6 关于未提交工作的询问。保留其报告,供步骤 7 使用。
end-sessionDoc map- **Companion。**设置 且其 checkout 存在时,从它自身的根目录进行检查:外层仓库的
Private companion、git log和git show无法看到其中的内容。Checkout 不存在时,报告无法协调 companion 文档,并且不要在其原位置创建目录。按照git diff中的.agents/skills/end-session/settings/workspace.md提交 companion 更改。## Procedure - **Changelog 欠账。**本次会话提交了行为变更,却没有添加对应的 条目(位于
Unreleased中,并采用changelog.d/),则应将其作为欠账报告;changelog 由Scheme: stamp-on-tag写入。ship - **单一 tracker。**本次会话添加到目录树中的 backlog、roadmap 或 TODO 文件与 issue tracker 重复,应主动提议将其内容移入 issues。
6. Workspace
6. Workspace
Uncommitted work first — it is the one thing cleanup can lose for good:
bash
git status --short
git stash listRun the same in the companion when it exists. For each change, ask: commit it on its branch, stash
it with a named message, or leave it. Leaving it is a valid answer; say so in the report. A
companion change is committed only by the in
.
## Procedure.agents/skills/end-session/settings/workspace.mdBranches. A branch is finished when its PR merged at or after the branch's local tip — true for
squash and merge commits alike, where misses every squashed branch:
git branch --mergedbash
git fetch --prune origin
for branch in $(git for-each-ref --format='%(refname:short)' refs/heads | grep -vx main); do
tip=$(git rev-parse "$branch")
pr=$(gh pr list --state all --head "$branch" --json number,state,headRefOid \
--jq 'sort_by(.number) | last | select(.) | "\(.number) \(.state) \(.headRefOid)"')
read -r number state head <<< "$pr"
verdict=unfinished
if [ "$state" = MERGED ]; then
git cat-file -e "$head^{commit}" 2>/dev/null || git fetch -q origin "pull/$number/head"
git merge-base --is-ancestor "$tip" "$head" && verdict=finished
elif [ -z "$number" ] && git merge-base --is-ancestor "$tip" origin/main; then
verdict=finished
fi
echo "$branch ${number:-no-pr} ${state:-none} $verdict"
done
git worktree listDelete finished branches with once the user agrees ( refuses squashed ones). A
branch with an open PR, no PR and commits of its own, or commits after its merged head holds work:
keep it, and name in the report when it is ready. A remote branch still listed after the
prune gets the same check before . Remove a finished worktree with
, then .
git branch -D-dshipgit push origin --deletegit worktree remove <path>git worktree pruneReturn to last, after the tidying below, unless the tree has uncommitted tracked changes
or the user is continuing on this branch in this checkout. Record ,
run , then . If the sync refuses to fast-forward, local has
commits of its own: report it and leave as it is. A companion that has diverged from its
upstream (commits on both sides) is reported, never merged, rebased, reset or force-pushed. For
each dependency lockfile in , install from that lockfile in its
folder, in the frozen form the repository's gives (,
, ), asking first where gates
installs. Then run from .
mainbefore="$(git rev-parse HEAD)"git switch mainSync with mainmainmaingit diff --name-only "$before" HEADAGENTS.mdnpm cipnpm install --frozen-lockfiledotnet tool restoreAGENTS.mdHook: after syncdocs/agents/workspace.mdFiles. Delete , and stray scratch files the session left in the tree, by
explicit path after listing them. stay unless the user explicitly asks;
blanket deletes such as would take them too, so delete only by path.
Safe-to-remove pathsNever-remove pathsgit clean -xThen:
- — report what is running and ask before stopping it; a running database may be deliberate. Never run its Never run commands here.
Dev stack - — when it reports drift, regenerate, and commit both sides.
Generated-config check - from
Hook: end-session cleanup.docs/agents/workspace.md - , last. Name the exact state of each repository rather than calling the checkout synchronized.
Final portability check
先处理未提交的工作——这是清理过程中唯一可能永久丢失的内容:
bash
git status --short
git stash list如果存在 companion,也在其中运行相同命令。对于每项更改,询问用户:提交到所在 branch、以命名消息 stash,还是保持不变。保持不变也是有效答案,应在报告中说明。Companion 更改只能按照 中的 提交。
.agents/skills/end-session/settings/workspace.md## Procedure**Branches。**当 PR 在 branch 的本地 tip 处或之后合并时,该 branch 视为已完成——无论采用 squash 还是 merge commit; 会漏掉所有经过 squash 的 branch:
git branch --mergedbash
git fetch --prune origin
for branch in $(git for-each-ref --format='%(refname:short)' refs/heads | grep -vx main); do
tip=$(git rev-parse "$branch")
pr=$(gh pr list --state all --head "$branch" --json number,state,headRefOid \
--jq 'sort_by(.number) | last | select(.) | "\(.number) \(.state) \(.headRefOid)"')
read -r number state head <<< "$pr"
verdict=unfinished
if [ "$state" = MERGED ]; then
git cat-file -e "$head^{commit}" 2>/dev/null || git fetch -q origin "pull/$number/head"
git merge-base --is-ancestor "$tip" "$head" && verdict=finished
elif [ -z "$number" ] && git merge-base --is-ancestor "$tip" origin/main; then
verdict=finished
fi
echo "$branch ${number:-no-pr} ${state:-none} $verdict"
done
git worktree list用户同意后,使用 删除已完成的 branch( 会拒绝经过 squash 的 branch)。如果某个 branch 有开放 PR、没有 PR 但包含自己的 commit,或者其 merged head 之后还有 commit,则它仍承载工作:应保留,并在准备好时在报告中注明 。Prune 后仍列出的 remote branch,也应先执行相同检查,再运行 。使用 删除已完成的 worktree,然后运行 。
git branch -D-dshipgit push origin --deletegit worktree remove <path>git worktree prune最后返回 ,并在完成下方整理后执行;除非目录树中存在未提交的 tracked 更改,或者用户正在此 checkout 的该 branch 上继续工作。记录 ,运行 ,然后执行 。如果同步拒绝 fast-forward,说明本地 有自己的 commit:报告情况并保持 不变。如果 companion 已与其 upstream 分叉(双方都有 commit),则只进行报告,绝不 merge、rebase、reset 或 force-push。对于 中列出的每个 dependency lockfile,在其所在目录中按照仓库 给出的冻结形式进行安装(、、);如果 对安装操作设置了门控,则先询问。然后运行 中的 。
mainbefore="$(git rev-parse HEAD)"git switch mainSync with mainmainmaingit diff --name-only "$before" HEADAGENTS.mdnpm cipnpm install --frozen-lockfiledotnet tool restoreAGENTS.mddocs/agents/workspace.mdHook: after sync**文件。**先以列表形式展示,再按明确路径删除 以及本次会话遗留在目录树中的零散临时文件。 保持不变,除非用户明确要求;诸如 之类的一揽子删除操作也会将其删除,因此只能按路径删除。
Safe-to-remove pathsNever-remove pathsgit clean -x然后:
- Dev stack——报告正在运行的内容,并在停止前询问;正在运行的数据库可能是有意保留的。此处绝不运行其 Never run 命令。
- Generated-config check——如果报告存在漂移,则重新生成并提交两侧内容。
- 运行 中的
docs/agents/workspace.md。Hook: end-session cleanup - 最后执行 Final portability check。明确说明每个仓库的确切状态,不要笼统称 checkout 已同步。
7. Report
7. Report
Run this last, so the counts are the session's final state. Set from
and from (empty for ).
For each other repository the session wrote to (pushed to, or opened a PR or issue in), run it again
with that repository's own settings.
public_repositoryPublic repositorycompanion_repositoryPrivate issue repositorynonebash
count_open() {
if result="$(gh api --paginate "$endpoint" --jq "$field" 2>&1)"; then
printf '%s' "$result" | grep -c .
else
case "$result" in
*disabled*|*"not enabled"*|*"no analysis found"*|*"must be enabled"*) echo disabled ;;
*) echo "not readable" ;;
esac
fi
}
for column in "public $public_repository" "companion $companion_repository"; do
read -r role repository <<< "$column"
[ -n "$repository" ] || continue
echo "$role open PRs: $(gh pr list -R "$repository" --state open --limit 500 --json number --jq length 2>/dev/null || echo 'not readable')"
field='.[].number'
for kind in dependabot code-scanning secret-scanning; do
endpoint="repos/$repository/$kind/alerts?state=open&per_page=100"
echo "$role $kind: $(count_open)"
done
if [ "$role" = public ]; then
endpoint="repos/$repository/security-advisories?state=draft&per_page=100"
field='.[].ghsa_id'
echo "$role draft advisories: $(count_open)"
elif ! labels="$(gh label list -R "$repository" --limit 500 --json name --jq '.[].name' 2>/dev/null)"; then
echo "$role security issues: not readable"
elif ! printf '%s\n' "$labels" | grep -qx security; then
echo "$role security issues: no label"
else
gh issue list -R "$repository" --state open --label security --limit 500 --json labels --jq "
[.[] | [.labels[].name] | any(. == \"wontfix\" or . == \"deferred-trigger\")] |
\"$role security issues: open \(map(select(. | not)) | length), accepted risk \(map(select(.)) | length)\"" \
2>/dev/null || echo "$role security issues: not readable"
fi
doneThen print this template, every section every time, with where there is nothing to say:
nonemarkdown
undefined最后运行此步骤,确保计数反映会话结束时的最终状态。通过 设置 ,通过 设置 (值为 时留空)。对于本次会话写入的其他每个仓库(执行过 push,或在其中创建了 PR 或 issue),使用该仓库自身的设置再次运行。
Public repositorypublic_repositoryPrivate issue repositorycompanion_repositorynonebash
count_open() {
if result="$(gh api --paginate "$endpoint" --jq "$field" 2>&1)"; then
printf '%s' "$result" | grep -c .
else
case "$result" in
*disabled*|*"not enabled"*|*"no analysis found"*|*"must be enabled"*) echo disabled ;;
*) echo "not readable" ;;
esac
fi
}
for column in "public $public_repository" "companion $companion_repository"; do
read -r role repository <<< "$column"
[ -n "$repository" ] || continue
echo "$role open PRs: $(gh pr list -R "$repository" --state open --limit 500 --json number --jq length 2>/dev/null || echo 'not readable')"
field='.[].number'
for kind in dependabot code-scanning secret-scanning; do
endpoint="repos/$repository/$kind/alerts?state=open&per_page=100"
echo "$role $kind: $(count_open)"
done
if [ "$role" = public ]; then
endpoint="repos/$repository/security-advisories?state=draft&per_page=100"
field='.[].ghsa_id'
echo "$role draft advisories: $(count_open)"
elif ! labels="$(gh label list -R "$repository" --limit 500 --json name --jq '.[].name' 2>/dev/null)"; then
echo "$role security issues: not readable"
elif ! printf '%s\n' "$labels" | grep -qx security; then
echo "$role security issues: no label"
else
gh issue list -R "$repository" --state open --label security --limit 500 --json labels --jq "
[.[] | [.labels[].name] | any(. == \"wontfix\" or . == \"deferred-trigger\")] |
\"$role security issues: open \(map(select(. | not)) | length), accepted risk \(map(select(.)) | length)\"" \
2>/dev/null || echo "$role security issues: not readable"
fi
done然后打印以下模板,每次都包含所有章节;没有内容可写时使用 :
nonemarkdown
undefinedEnd of session: <repository>, <date>
End of session: <repository>, <date>
What this session did
What this session did
- Memory: <added, updated or deleted, each with its reason; or why this step was skipped>
- Issues: <commented, closed, labelled or opened, by number>
- Workspace: <deleted; kept and why; uncommitted changes, unpushed branches, running containers>
- Settings files written: <list from step 0>
- Handoff document: <its path, when handoff invoked this skill>
- Not done: <everything skipped or left unfinished, and changelog debt>
- Memory: <added, updated or deleted, each with its reason; or why this step was skipped>
- Issues: <commented, closed, labelled or opened, by number>
- Workspace: <deleted; kept and why; uncommitted changes, unpushed branches, running containers>
- Settings files written: <list from step 0>
- Handoff document: <its path, when handoff invoked this skill>
- Not done: <everything skipped or left unfinished, and changelog debt>
Docs
Docs
- Searched: <documents checked, the terms searched for, and where, from docs-updater's report>
- Updated: <documents and their commit state, the companion's too, or that it was absent>
- Drift reported, not fixed: <list>
- Searched: <documents checked, the terms searched for, and where, from docs-updater's report>
- Updated: <documents and their commit state, the companion's too, or that it was absent>
- Drift reported, not fixed: <list>
Repository status
Repository status
| Public | Private companion | |
|---|---|---|
| Open PRs: this session | n | n |
| Open PRs: others and bots | n | n |
| Dependabot alerts | n | n |
| Code scanning alerts | n | n |
| Secret scanning alerts | n | n |
| Draft advisories | n | n/a |
| n/a | n |
| n/a | n |
| Public | Private companion | |
|---|---|---|
| Open PRs: this session | n | n |
| Open PRs: others and bots | n | n |
| Dependabot alerts | n | n |
| Code scanning alerts | n | n |
| Secret scanning alerts | n | n |
| Draft advisories | n | n/a |
| n/a | n |
| n/a | n |
Human steps before the next session
Human steps before the next session
- <what, where, and why it blocks>
- <what, where, and why it blocks>
Human follow-ups
Human follow-ups
- <verified issue or wiki link, or what is unpublished and why>
- **Status cells** hold a count, `n/a`, or what the snippet printed: `disabled`, `not readable` or
`no label`. Those three are never written as `0`: none of them says nothing is open. `this session`
counts the PRs this session opened that are still open, and `others and bots` is the rest of the
total. An open `security` issue also labelled `wontfix` or `deferred-trigger` is an accepted risk.
- **Columns.** Leave out the companion column when there is no companion. Each other repository
gets its own pair, headed by its public name; a companion whose repository cannot be resolved has
`not readable` in every cell.
- **Human steps before the next session** holds only what stops the next session: a PR to merge, an
expired login, work to push from this machine, a decision the user owes. Tracked work with no such
urgency is a follow-up.
- **Counts and roles only.** The security rows carry no title, identifier or package name, and the
report names a companion by its role, never its repository. A report holding a companion's counts
stays out of public issues, PRs and commits.
Name plainly what was not done. An accurate "these three things are still open" is the point of the
skill.- <verified issue or wiki link, or what is unpublished and why>
- **状态单元格**只能保存计数、`n/a` 或代码片段打印出的结果:`disabled`、`not readable` 或 `no label`。这三个值绝不能写成 `0`:它们都不表示“没有开放项”。`this session` 统计本次会话创建且仍开放的 PR;`others and bots` 是总数中的其余部分。开放的 `security` issue 如果还带有 `wontfix` 或 `deferred-trigger` 标签,则属于已接受风险。
- **列。**没有 companion 时省略 companion 列。其他每个仓库各自拥有一对列,并以公开名称作为标题;如果无法解析某个 companion 的仓库,则其每个单元格都写 `not readable`。
- **下次会话前需要人工处理的步骤**只包含会阻碍下次会话的事项:待合并的 PR、过期登录、需要从本机 push 的工作,或需要用户作出的决定。已跟踪但没有这种紧迫性的工作属于 follow-up。
- **只记录计数和角色。**security 行不得包含标题、标识符或包名;报告中 companion 只以其角色称呼,绝不写其仓库名。包含 companion 计数的报告不得进入公开 issue、PR 和 commit。
明确说明未完成的内容。准确指出“这三项仍未完成”正是本 Skill 的核心。