# 门控对比

| 方面 | Claude Code | opencode | hermes | OpenProgram |
| --- | --- | --- | --- | --- |
| 按 Agent 门控 | 有 | 有 | 部分，渠道级 | 有 |
| 机制 | 按类型的显式列表 | 单一 `permission` 规则集 | YAML 适配器配置 | 按类型列表加 fnmatch |
| 通配符 | 无，精确名称 | Glob | 无 | fnmatch |
| 门控类型 | 工具、技能、MCP 服务、钩子 | 统一模式空间（`tools:*`、`mcp:*` 等） | 平台适配器 | 工具、技能、MCP |
| 必需依赖 | 无公开文档 | 通过默认拒绝 | 无 | `mcp.required` |
| 插件门控 | 信任等级 | 信任加规则集 | 清单权限 | 信任等级，宿主级 |

## Claude Code

每种类型有自己的列表字段，写精确名称：易读，覆盖面大时啰嗦。

| Agent 字段 | 含义 |
| --- | --- |
| `tools` | 白名单 |
| `disallowedTools` | 黑名单 |
| `skills` | 预加载 |
| `mcpServers` | 引用或内联定义，Agent 能自带 MCP 配置 |
| `hooks` | 按 Agent、限于会话。OpenProgram 在 `openprogram/extensions/plugins/hooks.py` 的插件钩子没有按 Agent 的作用域 |
| `permissionMode` | 该 Agent 的权限模式 |

## opencode

每个 Agent 一个 `permission` 规则集：`{pattern, action: allow | deny}` 规则用 glob 匹配 `tools:bash`、`mcp:slack/*` 这类键。首个匹配生效。

- 新类型只需一个命名空间前缀，不改 schema。
- 一条规则可抵多条（`{pattern: "mcp:*", action: "deny"}`）。
- 代价：用户要学习模式语法。

## hermes

专注平台适配器（Discord、Slack、ntfy 等）。每个适配器的 `plugin.yaml` 规定它在网络上能做什么，属于渠道级，没有对应的 Agent 配置门控。本层没有采用其内容。

## 设计理由

Claude Code 的骨架加 opencode 的通配符。按类型的字段名即含义，`allowed`、`categories`、`required` 可机械地加到既有结构上。fnmatch 用一个辅助函数消除纯列表的啰嗦，精确名称照常可用。单一规则集只是纯重构（[未构建](https://fzkuji.github.io/OpenProgram/docs/reference/design/extension-gating/future-work.zh.html#5-single-ruleset-migration-opencode-style)）。未来框架出现实质不同的模型时再重新考虑。
