agentleFS
SparkElfSparkElf/deepseek-harness-plus/.agents/skills/dsh-repo-release-pr/SKILL.md

dsh-repo-release-pr

Skill1 starsChanged 3 months agoMITView on GitHub

在 SparkElf/deepseek-harness-plus(自有仓库)里发布 npm、开 PR、合并到 master 时使用。讲清 master 的服务端保护规则、加权批准(weighted approval)机制、为什么 PR 作者不能自己批准、以及 release:ship 的完整步骤顺序。排查「push 被拒」「PR 卡在 REVIEW_REQUIRED」「不知道谁来批准」时优先读它。

  • Deletes or force-pushes
  • Installs packages
  • Commits and pushes

The file

Files
SKILL.md

DSH Plus 仓库的发布与 PR 流程

这个技能解决一类反复踩的坑:推代码、发版本、开 PR 时不知道规则,导致被拒或卡住。

核心结论先给:

  1. 禁止直推 master。 服务端规则强制 PR + 批准 + 状态检查,客户端绕不过。
  2. PR 作者不能批准自己的 PR。 加权批准明确排除作者。
  3. 批准需要 2 分,且本机通常只有一个 GitHub 身份 —— 所以「机器人提交 + 人审查」需要两个身份,或缺一不可。
  4. 发布用 release:ship 或按它的步骤顺序手动执行,顺序错了 gate 会失败。
  5. 基座版本升级不走本技能:先按 dsh-base-upgrade 完成裸基座、插件修复、退役判断与 edition 组装,再回到本技能发版。

1. 仓库身份

origin   git@github-sparkelf:SparkElf/deepseek-harness-plus.git

这是自有仓库,不是第三方依赖。改 packages/bundle/plus 等代码 = 改自有源码,正确路径是「改源码 → 构建 → 提 PR → 发布」,不是「打补丁」也不是「提 issue 给上游」。

本机 gh 登录身份用 gh auth status 查。先查身份,再决定流程——只有一个身份时,作者不能批准自己的 PR。


2. master 的服务端保护规则

先用 API 查,不要凭猜:

gh api repos/SparkElf/deepseek-harness-plus/rules/branches/master

当前规则(GET .../branches/master/protection 返回 404,因为用的是新版 rulesets,不是旧保护):

规则含义
pull_request必须走 PR;required_approving_review_count = 1;require_code_owner_review = true;required_review_thread_resolution = true
required_status_checks两个检查必须通过:Required PR evidence、Diff and composition metadata
non_fast_forward禁止强推
deletion禁止删分支

直推会被这样拒绝:

remote: error: GH013: Repository rule violations found for refs/heads/master.
remote: - Changes must be made through a pull request.
remote: - 2 of 2 required status checks are expected.

这是服务端强制,"跳过 CI" 在客户端做不到。


3. 加权批准机制(最容易踩的坑)

策略文件:.github/review-ownership/approval-policy.json

{
  "requiredPoints": 2,
  "defaultPoints": 1,
  "reviewerPoints": {
    "07akioni": 2, "imccyu": 2, "tianyicui": 2,
    "tianyicui-bot": 2, "turtle1999": 2, "turtle2099": 2
  }
}

规则要点(来自 .github/review-ownership/README.md):

  • 阈值 2 分。
  • 高权重审查者各 2 分(一票即达阈值);其他有 write 权限者各 1 分。
  • PR 作者不计分 —— 所以作者自己 approve 无效。
  • 无 write 权限者不计分;已删除账号不计分。
  • CHANGES_REQUESTED 是阻断项,即使分数够也保持 pending。
  • 只有「非 draft + 达阈值 + 无阻断」才返回 success。

因此:

  • 想自动化,需要 bot 账号(如 tianyicui-bot)提交、人类账号审查;或反过来。
  • 只有一个身份时,无法自行合并 —— 这是设计如此,不是 bug。

查 PR 为何卡住:

gh pr view <n> --json reviewDecision,mergeStateStatus,statusCheckRollup

REVIEW_REQUIRED + BLOCKED = 等批准,且通常需要另一个账号。


4. 发布流程(release:ship 的顺序)

一键入口:

pnpm run release:ship --prerelease alpha.96 --family plus [--dry-run]

它按固定顺序做事,手动执行时必须照抄,否则 gate 会失败:

1. 确认个人清单与团队清单(dshPlus.editions.personal / .team / .intranet-team)已按本次要发的包版本更新
2. bump 版本            npx tsx scripts/release/bump.ts --family plus --prerelease alpha.96
3. 必要时加 release-age 豁免(pnpm install --frozen-lockfile 会暴露,ship 会自动补)
4. 本地发布并验证:pnpm run release:local --family plus --out <dir>
   —— release:local 会 pack → verify-packed-install → publish → verify-published
5. 推分支、开 PR
6. 等 checks、用 --admin 合并、打 tag、从远端读回 master

为什么清单要先于 bump:release:ship 只改版本号,不会替你决定哪些包进入个人版/团队版。清单里写的版本必须与本次 release:local 实际发布的版本一致,否则安装验证会解析到旧版本。

没有 standalone manifest 这一步。0.2.9 之后不再发布 packages/standalone/*,profile manifest 由 dsh-plus install --edition 直接写出;旧步骤 verify:standalone-manifest 已不存在。若看到文档要求“重新生成 standalone manifests”,那是 0.2.9 之前的流程,不要执行。

发布是本地全量验证:release:local 会 pack → verify-packed-install(装到临时目录)→ publish → verify-published(轮询 registry 直到 latest 解析)。E409 Cannot publish over previously staged version 不是失败,是 registry 的暂存窗口,重跑即幂等完成。

手动发布:

pnpm run release:local --family plus --out /tmp/plus-<ver>   # 去掉 --dry-run 才真正发

5. 发布后的收尾

# 合并后给 merge commit 打 tag
git tag plus-npm-v0.2.0-rc.36 <merge commit>
git push origin plus-npm-v0.2.0-rc.36

bump 脚本自己会打印这一行,注意读它的输出。


6. 清理分支前必做

删本地分支前先确认它们是否已进 master。注意工具会误报:

  • git cherry 对 squash 合并(本仓库的常规做法)必然误报 —— squash 改变了 SHA,patch-id 认不出,会报「未进 master」而实际已进。
  • 可靠判据(按可靠性排序):
    1. 新增文件是否都在 master:git diff --name-only --diff-filter=A <merge-base> <branch>,逐个查 git cat-file -e master:<file>。
    2. 试合并产生的冲突性质:git merge --no-commit --no-ff <branch>,若冲突内容是版本倒退(如 rc.35 vs rc.25),说明分支只是落后,不该合并。
    3. git merge-tree 不可靠:它会把冲突标记(<<<<<<<)输出成"差异",造成假阳性。
  • 删前先建备份 tag,并验证可从 tag 恢复:
    git tag backup/pre-cleanup-$(date +%Y%m%d-%H%M%S)/<name> <branch>
    git branch __restore_test <tag> && git branch -D __restore_test   # 证明可恢复

6.1 提升前必须已经合并到 master(本次实测踩坑)

镜像构建读的是 PLUS_REPO,默认就是 当前工作树:

# /root/.dsh/dsh-plus-mirror:50
PLUS_REPO=${PLUS_REPO:-/root/projects/deepseek-harness-plus}

所以在未合并的分支上建镜像、再切 3080,等于把没经过 master 门禁的产物推上生产。2026-10-10 实测:镜像建在 fix/alpha2-substitution-set(未合并),3080 切换后页面白屏,报

client-modules: duplicate factory registration for
  "@deepseek-ai/dsh-client-ui-permission-presets"

而当时 master 上的真实状态(overrides 里 5 个指向不存在的 npm 版本)被这一层掩盖了 —— 症状描述的是分支,不是发布版,所有诊断都对着错的产物。

正确顺序:

  1. 先 git merge(或 PR squash 合并)到 master;
  2. 从 master 建镜像;
  3. 再切 3080 / 更新工作区镜像 pin。

判断「镜像建在哪个 revision」:

cd <mirror> && git log --oneline -1     # 应等于 origin/master 的 tip

6.2 一个 prunable worktree 会掩盖分支状态

git worktree list 里标 prunable 的条目(gitdir 指向已删除的位置)不会自动消失, git status 也不会提示。git worktree prune -v 清理后,分支相对 master 的真实差异才呈现出来。

本次有 3 个 prunable(/tmp/revwt、/tmp/revwt2、/tmp/dsh-master-check), 另有 2 个真实 worktree(/tmp/pre、/tmp/wt2)保留着补丁生成用的 base。


7. 工作树(worktree)

git worktree list 可能列出构建缓存工作树,例如:

.cache/plus-web-build-cache/official-source   (detached HEAD)

它由 tests/plus-web/global-setup.mjs 创建和销毁(resetBuildCache() 里 git worktree remove --force + rmSync),是派生数据,manifest.json 记录 officialRevision 和包哈希。它的「未提交改动」是构建产物改写(如 / → ./),不是人的工作。可以安全清理:

git worktree remove --force .cache/plus-web-build-cache/official-source
rm -rf .cache/plus-web-build-cache

代价:下次 test:plus-web 会全量重建(pnpm install + 构建)。体积可达数百 MB。


8. 部署推进工具在这里(不要用 command -v 判存在)

发布 npm 之后,运行中的部署不会自动更新。升级部署由一组脚本负责,它们住在 /root/.dsh/,而该目录不在 PATH 上。因此 command -v dsh-plus-build 会报"找不到",但工具其实就在那儿:

# 错误做法:只查 PATH
command -v dsh-plus-build        # ✗ 找不到 —— 结论是错的

# 正确做法
ls -la /root/.dsh/dsh-plus-*     # ✓ dsh-plus-build / dsh-plus-switch / dsh-plus-refresh
工具位置职责
dsh-plus-build <mirror>/root/.dsh/两次 pnpm install + pnpm run build --profile official + 校验品牌记录
dsh-plus-switch <mirror>/root/.dsh/切换 3080 服务的 mirror,按阶段推进
dsh-plus-refresh rebuild|accept|restart|all/root/.dsh/重建 / 记录 accept / 重启,按此顺序
dsh-3080-restart/usr/local/bin(软链到 /root/.dsh/)唯一在 PATH 上的那个

call them rather than写一份自己的实现 —— 手写一份部分实现会「报成功、HTTP 200、却在跑旧版本」,因为运行时解析的是 mirror 里的源码,而手写步骤往往只改了 profile 里的发行版号。

另外官方还有一份强制 runbook:scripts/PLUS_PROFILE_PROMOTION.md(仓库内)。以及对应的门禁:

pnpm run verify:plus-profile-upgrade -- --baseline <旧>/profile --candidate <新>/profile --report
pnpm run verify:plus-profile-upgrade -- --baseline <旧>/profile --candidate <新>/profile \
  --policy packages/bundle/plus/production-profile-policy.json     # 阻断性

注意:升级部署是独立于 npm 发布的一步,且比发布更重(要过闭包门禁、桌面/移动端验收、Session 恢复)。npm 发出去不等于部署会更新。


9. 速查

# 身份与规则(先查这两个)
gh auth status
gh api repos/SparkElf/deepseek-harness-plus/rules/branches/master

# PR 卡在哪
gh pr view <n> --json reviewDecision,mergeStateStatus,statusCheckRollup

# CI 实际耗时(别把 ship.ts 的 45 分钟超时当成预期耗时)
gh run view <run-id>

10. 反面清单

  • ❌ 直推 master —— 服务端规则必拒。
  • ❌ 用自己的账号提交后又想自己 approve —— 作者不计分,权重为 0;用 gh pr merge --admin(ship.ts 就是这么做的)。
  • ❌ 把 ship.ts 的 CHECKS_TIMEOUT_MILLISECONDS = 45 * 60_000 当成 CI 预期耗时 —— 那是超时上限,实测多数 job 3–4 分钟就完成。
  • ❌ 用 command -v dsh-plus-build 判断部署工具是否存在 —— 它们在 /root/.dsh/,不在 PATH 上,会误判为"工具不存在"。
  • ❌ 以为 npm 发布后部署会自动更新 —— 升级部署是独立、更重的一步,要过闭包门禁与浏览器验收。
  • ❌ 自己写一份部署推进步骤 —— 这正是 dsh-promote-deployment 技能要防的错误;调用现成脚本。
  • ❌ 用 git cherry 判断分支是否已合并 —— squash 合并下必然误报。
  • ❌ 用 git merge-tree 判断分支独有改动 —— 冲突标记会被当成真差异。
  • ❌ 发布前不更新 dshPlus.editions.* 清单 —— 用户装到的 edition 会停在旧包版本。
  • ❌ 继续找 packages/standalone 或 verify:standalone-manifest —— 0.2.9 之后已不存在。
  • ❌ 把 E409 当成发布失败 —— 那是暂存窗口,重跑即完成。
  • ❌ 删分支不先建备份 tag —— 本仓库分支常常只存在于本地,删了就没了。

本机的 npm 凭证与发布 registry(踩过的坑)

  • 凭证位置:/root/.npmrc,其中只有一条 //registry.npmjs.org/:_authToken=...,身份是 forestlightelf。 只使用,不回显:不要 cat 这个文件,也不要把值写进任何仓库文件或对话。
  • 默认 registry 是镜像站:registry=https://registry.npmmirror.com 是只读镜像,不接受发布 (用它跑 npm publish 会以看不出的方式失败或报 ENEEDAUTH)。发布必须显式指定官方源:

    npm publish --registry https://registry.npmjs.org --access public
  • 自查身份(不泄露 token):

    npm whoami --registry https://registry.npmjs.org   # 期望 forestlightelf
  • 发布后确认(官方源可能有几分钟延迟,别立刻断言失败):

    npm view <pkg> version --registry https://registry.npmjs.org
  • 本仓库的插件包带 prepack: pnpm run build,发布前确认 lib/ 能构建; 若 pnpm 不可用可先手动 npm run build 再用 --ignore-scripts 发布。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.