所有人都在用 YOLO 模式。Gryph 强制执行护栏并保留审计追踪。
快速开始 · 演示 · 支持的代理 · 使用场景 · 安全策略
AI 编码代理(Claude Code、Cursor、Windsurf、Gemini CLI、OpenCode)可以读取任意文件、写入任意位置,并在开发者机器上执行任意命令。它们每次会话会运行数十次工具调用。它们能做什么没有边界,出问题时也没有审计追踪。
Gryph 解决了这个问题。 它挂接到代理中,实时强制执行 block、warn 或 guide 操作的 YAML 策略规则,并将每个事件记录到本地 SQLite 数据库以供审查和审计。所有数据都保留在本地。无云端,无遥测。
一位开发者让 Claude Code 重构一个模块。它在 90 秒内运行了 47 次工具调用。然后测试失败了。
没有 Gryph,开发者只能靠猜。有了 Gryph,gryph logs 会显示一切。
# Install Gryph with one command
curl -fsSL https://raw.githubusercontent.com/safedep/gryph/main/install.sh | sh
# Setup gryph for available agents
gryph install # hooks into all detected agents
gryph status # verify setup
# ... use your AI agent normally ...
gryph logs # see what happened
# Homebrew (macOS/Linux)
brew install safedep/tap/gryph
# npm
npm install -g @safedep/gryph
# Go
go install github.com/safedep/gryph/cmd/gryph@latest
适用于 macOS、Linux 和 Windows 的预构建二进制文件可在 GitHub Releases 页面获取。
提示: 将
logging.level设置为full可查看文件差异和原始事件:gryph config set logging.level full。详情请参阅配置。
| Agent | Hook 支持 |
|---|---|
| Claude Code | 完整(PreToolUse、PostToolUse、Notification) |
| Codex | 完整(PreToolUse、PostToolUse、SessionStart、UserPromptSubmit、Stop) |
| Command Code | 完整(PreToolUse、PostToolUse、Stop、SessionStart) |
| Cursor | 完整(文件读取/写入、shell 执行、MCP 工具) |
| Devin CLI | 完整(PreToolUse、PostToolUse、SessionStart、UserPromptSubmit、Stop、SessionEnd) |
| Gemini CLI | 完整(BeforeTool、AfterTool、Notification) |
| OpenCode | 完整(tool.execute、会话事件) |
| Pi Agent | 完整(tool_call、tool_result、会话事件) |
| Windsurf | 完整(文件读取/写入、命令、MCP 工具) |
注意: Codex hooks 需要在 Codex 配置(
~/.codex/config.toml)中启用codex_hooks功能标志:[features] codex_hooks = true
注意: Devin CLI 默认还会从
~/.claude/settings.json加载 Claude Code hooks(read_config_from.claude)。当为两个 agent 都安装了 gryph hooks 时,一个 Devin 会话会同时发出 devin 事件和 claude-code 事件。在 Devin 用户配置中禁用read_config_from.claude可保持单一事件流。
一条命令即可为所有检测到的 agent 安装 hooks。无需逐个 agent 配置。
使用 gryph logs --live 实时流式查看 agent 操作:
| 场景 | Gryph 如何提供帮助 |
|---|---|
| 回放完整会话 | git diff 只显示最终变更。Gryph 显示完整序列:agent 读取了什么、运行了什么、写入并回滚了什么,以及顺序如何。 |
| 捕获不可见的副作用 | Agent 运行的 shell 命令不会在 git 中留下痕迹(npm install、curl、rm)。gryph query --action exec 可将它们全部呈现出来。 |
| 敏感文件访问 | Gryph 会自动标记对 .env、*.pem、*.key 及类似文件的访问。操作会被记录,但内容永远不会被存储。 |
| 阻止有风险的 agent 操作 | 编写 YAML 规则以阻止破坏性命令、拒绝泄露凭据的写入,或按 agent 或项目限定行为范围。请参阅安全策略。 |
| 安全审查 | 将事件导出到你的 SIEM,或使用 OpenSearch 可观测性示例 实现集中式仪表板和威胁检测告警。 |
| 成本与 token 跟踪 | 跟踪跨模型和 agent 的每会话 token 用量及预估成本。查看文档 |
| 比较 agent | 通过 --agent 过滤,查看不同 agent 如何处理同一任务:哪个读取更多、哪个运行更多命令、哪个成本更高。 |
Gryph 将轻量级 hooks 安装到 AI 编码 agent 中。当 agent 读取文件、写入文件或执行命令时,hook 会向 Gryph 发送一个 JSON 事件。事件存储在本地 SQLite 数据库中,可随时查询。由于 Gryph 同时挂钩 pre-tool 和 post-tool 事件,因此能够捕获每个 agent 操作的完整生命周期。
除了日志记录之外,Gryph 还可以对 agent 操作强制执行 YAML 策略。规则可以基于操作类型、文件路径、命令模式、工具名称、agent、项目以及基于每会话计数器的 CEL 表达式,执行 block、warn、guide 或 allow。被阻止的操作永远不会到达 agent 的工具,指导信息会以 stderr 文本的形式返回给 agent,并且每个决策都会被持久化。
gryph policy init # write the example policy to the global config dir
gryph policy edit # open it in $EDITOR and scaffold if missing
gryph policy validate
gryph policy test --action file_write --path ./secrets/db.env
gryph config set policy.enabled true
更多详情请参阅安全策略。
Gryph 还会保护自身的钩子、策略和审计追踪。gryph doctor 会显示每个资产的级别以及它们所获得的配置文件。在 guard 配置文件中,Gryph 会防范代理错误和简单的篡改尝试,检测钩子配置的变更,并在你开启修复功能时进行修复。它无法阻止同用户下的坚定对手或 root。有关限制和你可以做出的声明,请参阅自我保护。管理员可以使用 gryph install --managed 为主机上的每个用户安装 Gryph。请参阅托管安装指南。
在托管主机上,位于用户之外的决策服务会评估策略、保留每个账户的审计追踪、使用机器密钥进行签名并应答审批请求,因此代理用户进程无法读取密钥、编辑追踪记录或伪造决策。此时 locked 配置文件适用于其托管钩子条目能够抵御用户的代理,目前包括 Claude Code、Codex 和 Cursor;对于 Gemini 和 Windsurf,该条目是一个没有锁的 root 所有文件,Gryph 会检测到缺失的钩子而不是阻止它。有关你可以做出的声明,请参阅威胁模型。要在单台主机上试用,请遵循 Linux 操作指南或 macOS 操作指南。
有关所有命令和标志的完整参考,请参阅 CLI 参考。
gryph install # Install hooks for all detected agents
gryph install --dry-run # Preview what would be installed
gryph install --agent claude-code # Install for a specific agent
gryph uninstall # Remove hooks from all agents
gryph uninstall --purge # Remove hooks and purge all data
gryph uninstall --restore-backup # Restore original hook config from backup