mcpField
G
gatefile

gatefile

本地服务
github.com/CloudCorpRecords版本控制03 天前更新

关于 gatefile

gatefile 从仓库文档和配置中提取贡献规则,生成机器可读的 `contribution-gates.json`,面向开源贡献者、维护者和 CI 工作流。每条规则附有源文件引文,并可检测记录与当前规则之间的偏差。

主要功能

  1. 01从文档和工作流文件提取规则
  2. 02为规则附上原文证据
  3. 03生成机器可读的规则文件
  4. 04验证规则变更与缺失
  5. 05生成 README 徽章片段

适用场景

  1. 01贡献前检查仓库的提交要求
  2. 02在 CI 中检测贡献规则漂移
  3. 03为 README 展示贡献门槛

MCP 相关

MCP 服务提供 `extract_gates`、`validate_gates` 和 `gates_badge` 工具,用于提取规则、检查偏差及生成 README Markdown 片段。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"cloudcorprecords-gatefile": {
"command": "npx",
"args": [
"-y",
"@reneturcios/gatefile"
]
}
}
}
启动命令npx -y @reneturcios/gatefile

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@reneturcios/gatefile0.1.4
ocighcr.io/cloudcorprecords/gatefile:0.1.4

工具

3

收录的工具列表 · 更新于 2 天前

参数类型必填说明
repostring是owner/repo 格式的仓库,例如 shadcn-labs/pdfcn
localPathstring否读取此本地目录,而非调用 GitHub API

详细介绍

gatefile

将隐藏的贡献门槛提取到机器可读的文件中。

每个仓库都藏着对外部贡献者的真实规则:开始前先评论、等待分配、提交时签署 DCO、获得担保、签署 CLA。如今,你往往要等 PR 被自动关闭后才会发现这些规则。gatefile 从仓库自己的文档中提取这些规则,生成 contribution-gates.json,这是一种机器可读的格式,可供工具(如 Greenlight)和 CI 使用。

问题

贡献者选中一个 issue,编写代码,提交 PR,然后机器人将其关闭:“你尚未被分配”“未获担保的作者会被自动关闭 PR”“缺少 Signed-off-by”。这些规则一直都写在 CONTRIBUTING.md 里,埋在一大段文字中,而且每个仓库都不一样。维护者一遍遍重复同样的纠正;贡献者一遍遍浪费同样的晚上。

gatefile 的作用

  1. 提取:读取 CONTRIBUTING.md、PR 和 issue 模板、DCO/CLA 工作流文件、lefthook 钩子以及 CLA 文件(通过 GitHub API 或本地目录),并输出发现的门槛,每项都附有实际引用的原文作为依据。
  2. 验证:将已提交的 contribution-gates.json 与最新提取结果进行比较,并报告差异(STALE、MISSING、SEVERITY_CHANGED)。存在差异时退出代码为 1,CI 可据此强制执行。
  3. 徽章:生成 README 片段,用通俗易懂的语言告诉大家这些门槛。

contribution-gates.json 格式

{
  "version": 1,
  "repo": "shadcn-labs/pdfcn",
  "generatedFrom": ["CONTRIBUTING.md"],
  "gates": [
    {
      "id": "claim_first",
      "kind": "claim_first",
      "severity": "blocker",
      "evidence": "Comment before starting work, and check the thread first in case someone else is already working on it.",
      "source": "CONTRIBUTING.md"
    }
  ],
  "conventions": {
    "branchNaming": "Name your branch feat/block-name",
    "prTitleFormat": "PR titles should follow Conventional Commits",
    "requiredChecks": []
  }
}
门槛类型
kindseverity含义
claim_firstblocker开始工作前先在 issue 中评论
assignment_requiredblocker等待分配后再提交 PR
discuss_firstblocker编码前先发起讨论或创建 issue
issue_firstblocker每个 PR 都必须关联一个 issue
vouch_requiredblocker必须由现有成员为你担保
collaborators_onlyblocker只有仓库协作者可以提交 PR
no_direct_prsblocker不接受直接提交的 PR
dco_requiredwarn提交需要带有 Signed-off-by 尾注(DCO)
cla_requiredwarn必须签署贡献者许可协议

严重性:blocker 门槛可能导致 PR 在审核前被关闭或拒绝。warn 门槛可在 PR 提交后补齐。依据始终是源文件中的真实引文,截取至约 140 个字符,不会凭空编造。

使用 Docker 运行

gatefile 也提供 GHCR 上的容器镜像:ghcr.io/cloudcorprecords/gatefile。

将其用作 stdio MCP 服务:

docker run -i ghcr.io/cloudcorprecords/gatefile

可以在镜像名称后传入任意 CLI 命令,以替代默认的 mcp 参数:

docker run ghcr.io/cloudcorprecords/gatefile <command> [args]

用法

CLI
# Extract gates from a repo (GitHub API, GITHUB_TOKEN optional)
gatefile extract shadcn-labs/pdfcn

# Extract from a local clone instead (fully offline)
gatefile extract local --local ./pdfcn --out contribution-gates.json

# Validate the committed file against fresh docs, exit 1 on drift
gatefile validate shadcn-labs/pdfcn --file contribution-gates.json

# Print a README snippet for humans
gatefile badge shadcn-labs/pdfcn
MCP 服务

添加到 MCP 客户端配置中:

{
  "mcpServers": {
    "gatefile": {
      "command": "node",
      "args": ["/path/to/gatefile/dist/mcp.js"]
    }
  }
}

工具:

toolinputs返回内容
extract_gatesrepo 或 localPath完整的 contribution-gates.json 对象
validate_gatesrecorded、repo 或 localPath{ ok, drift[] }
gates_badgerepo 或 localPathREADME Markdown 片段
CI 示例

在 GitHub Actions 工作流中确保门槛文件准确无误:

name: gates
on:
  pull_request:
    paths: ["CONTRIBUTING.md", ".github/**", "contribution-gates.json"]
jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20 }
      - run: npx -y gatefile extract ${{ github.repository }} --out /tmp/fresh.json
      - run: npx -y gatefile validate ${{ github.repository }} --file contribution-gates.json

开发

npm install
npm test        # tsx --test, offline, 23 tests
npm run build   # tsc to dist/
npm run dev -- extract owner/repo --json

TypeScript ESM,Node 20+,使用 zod 定义模式,使用原生 fetch 调用 GitHub API。测试使用 test/fixtures/ 中基于有文档记录的案例构建的真实场景样例(开始前评论并要求 DCO 和 issue 优先;先分配;仅需担保;宽松)。

许可证

MIT,Rene Turcios 2026。

工具套件

此工具是开源贡献工作流中的四款工具之一,它们都以 @reneturcios npm 作用域发布,且每款都提供 CLI 和 MCP 服务(<tool> mcp):

  1. gatefile(npx @reneturcios/gatefile)会提取仓库的贡献门槛,并将其写入已提交的 contribution-gates.json。
  2. greenlight(npx @reneturcios/greenlight)会预检问题(GO / RISKY / TAKEN / GATED / STALE),在 check 和 scan 中使用 gatefile 的输出,然后认领问题、做好准备并提交 PR。
  3. claimcheck(npx @reneturcios/claimcheck)会监控过期认领,以及停留在 fork 上的修复。
  4. prwatch(npx @reneturcios/prwatch)会根据哪些未合并 PR 需要你立即处理,对它们进行分类。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。