SuperAPI AI 工具集

gate-push

部署与运维

查看项目

更新于 10-16 09:06

技能介绍

gate-push 是一个面向分支到 PR 的单动词质量门禁流水线技能,适用于用户希望在一条命令内对某个分支完成门禁校验、推送并打开 PR 的场景。

【用途】 通过运行 /dh:gate-push <branch-name>,将分支上下文解析为 /dh:complete-implementation 的输入,并执行该质量门禁流水线。

【使用方式与前置要求】 使用 <sam_cli/> 或 <dh_scripts/> 前,需先加载 dh:dh-cli-usage。

必需输入:branch_name = $ARGUMENTS(必须非空)。 若为空,则停止并提示: COMPLETION BLOCKED — Missing required argument <branch-name>. 随后重新运行: /dh:gate-push <branch-name>

【分支到 backlog 的查找算法】 将 branch_name 规范化为查找 slug:

  1. 若存在分支类型前缀(feature/、fix/、chore/ 等),仅移除第一个 / 及其之前的前缀部分。
  2. 将剩余的 /、_ 和 - 替换为空格(例如 feature/auth/login-fix → auth login fix)。
  3. 去除首尾空白。
  4. 将结果存为 normalized_slug。 预期模式为 type/slug(例如 feature/foo-bar);多段分支(type/segment1/segment2)同样支持,并按相同替换规则规范化。

策略 1(标题匹配): <sam_cli/> backlog list --title "<normalized_slug>"

策略 2(主题回退匹配,仅在策略 1 零结果时使用): <sam_cli/> backlog list --topic "<normalized_slug>"

若仅返回一条结果,则将其作为匹配项。 若返回多条结果,不得猜测,应停止并执行下述“无匹配/无法解析回退流程”。

【解析 complete-implementation 输入】 从匹配项按以下顺序解析:

  • 若 match.issue 存在(backlog 输出中的 issue 编号字段)→ target = #<match.issue>
  • 否则若 match.plan 存在且非空 → target = <match.plan>(直接使用 backlog 条目的 plan 字段)
  • 否则无可解析目标

【执行门禁流水线】 若 target 已解析: Skill(skill: "dh:complete-implementation", args: "<target>")

/dh:complete-implementation 是质量门禁各阶段以及最终推送/PR 行为的唯一真实来源;此处不重复其门禁逻辑。

【无匹配/无法解析回退流程】 若未找到 backlog 匹配项、匹配项既无 issue 也无 plan、或存在多个匹配项:

  • 不在循环中途提示。
  • 停止并提示: COMPLETION BLOCKED — Branch cannot be resolved to a single backlog issue/plan.

必需前置条件:

  • 确保在流程开始时(例如通过 /dh:work-backlog-item --auto ...)或 /dh:implement-feature 开始时已确定分支到 backlog 的映射。
  • 确保匹配到的 backlog 条目具有 issue 编号或关联 plan。

随后重新运行: /dh:gate-push <branch-name>

【成功检查】 成功完成后,验证该分支的 PR 可见性。

仅限 GitHub 后端 — 此步骤要求配置了 gh CLI 的 GitHub 远程仓库。 对于 beads 及其他非 GitHub 后端,跳过此步骤,并使用后端原生工具验证(例如用 bd show <issue-id> 查看合并请求状态)。

if gh repo view --json name >/dev/null 2>&1; then gh pr list --head <branch-name> else echo "Remote is not a GitHub repository — PR visibility check not applicable for this backend." fi

--head 使用原始输入分支(branch_name),而非 normalized_slug。