Repository navigation
docs: 新增 hooks/__protocol__.md 契约 cheat-sheet (v0.6.3) - #8
Merged
Merged
Conversation
新增 hooks/__protocol__.md(7 节): - 协议总表:5 个事件 × exit 码 × stdout 形态 × 阻断语义 - 三端兼容矩阵:Codex / ZCode / Kimi - fail-open 约定:__main__ 必须 swallow Exception → exit 0 - PreToolUse 硬拦截边界:唯一 exit 2 的 hook + 综述行契约 - 新增 hook checklist:7 步自检清单 - 协议变更策略:同一 commit 改本文件 + 实现 + 测试 + OpenSpec - 与 OpenSpec spec 的对应映射 tests/run_all.py 顶部 docstring 增加单源引用 OpenSpec spec: hook-protocol (3 Requirements) 已合入 验证:unittest 14/14 + run_all 141/141/0 + openspec strict 6/6 + diff clean 实现定位行号锁在 v0.6.2: - SessionStart 摘要:env_check.py:34 - UserPromptSubmit JSON:user_prompt_validator.py:104,117 - PreToolUse stderr:pre_tool_git_guard.py:159 - PostToolUse JSON:post_tool_lint.py:226,253,275 - Stop 摘要:stop_summary.py:46
This was referenced Sep 22, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sections
Why
MEDIUM #7 评审已指出协议契约散布在 8 处(5 个 hook docstring + 2 份 docs + gate_lib 钩子间互引)。
新加 hook 时容易在退出码语义(0 vs 2 vs fail-open)与 JSON 协议(stdout / additionalContext / stderr)走偏。
Verification
Spec