docs: document PreToolUse hook permissionDecision "ask" behavior - #6411
Conversation
|
Thanks for the PR! Template looks good ✓ — all required sections present and filled in. Problem: this is a docs-only gap — the hooks page lists Direction: aligned. The hooks system is on the roadmap ( Size: not applicable — docs only, no core paths touched. +6 lines, 1 file. Approach: scope is tight and minimal. The added paragraph sits naturally between the output options list and the existing Note, explaining exactly what was missing. I verified each claim against Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ — 所有必填部分均已填写。 问题:纯文档缺口 — hooks 页面列出了 方向:对齐。Hooks 系统在路线图中( 规模:不适用 — 纯文档改动,未触及核心路径。+6 行,1 个文件。 方案:范围紧凑且最小化。新增段落自然地放在输出选项列表和现有 Note 之间,准确补充了缺失的说明。已对照 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
Code ReviewThe diff is 6 lines added to
Placement is correct — the paragraph sits between the output options list and the existing Note, which is the natural reading order. No issues found. Clean docs-only change. TestingDocs-only — no runtime behavior to test. Verified the patched section renders correctly in context: 中文说明代码审查Diff 是在
段落位置正确——放在输出选项列表和现有 Note 之间,符合自然阅读顺序。 未发现问题。干净的纯文档改动。 测试纯文档——无可测试的运行时行为。已验证修补后的内容在上下文中正确渲染(见上方代码块)。 — Qwen Code · qwen3.7-max |
|
This is a clean, focused docs PR that fills a real gap. The hooks page listed I verified every claim against If I had to maintain this in six months, I'd thank the author — it's the kind of small, accurate docs contribution that saves future hook authors from guessing. Approving. 中文说明这是一个干净、聚焦的文档 PR,填补了真实的缺口。hooks 页面列出了 已对照 如果六个月后要维护这段内容,我会感谢作者——这是那种小而准确的文档贡献,让未来的 hook 作者不用靠猜。批准。 — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
What this PR does
Documents what each
permissionDecisionvalue does for aPreToolUsehook indocs/users/features/hooks.md. The doc already lists"allow","deny", and"ask"as the allowed values but never explained their behavior — most importantly"ask", which now pauses the tool and surfaces a TUI confirmation before the tool runs, and falls back to"deny"in contexts that cannot prompt (headless--promptruns and background subagents).Why it's needed
A
PreToolUsehook returningpermissionDecision: "ask"recently changed from behaving like"deny"to actually prompting the user for confirmation. A hook author reading the docs had no way to know what"ask"does or that it degrades to"deny"in non-interactive contexts, so a security-conscious hook could not choose between"deny"and"ask"intentionally. The added description makes the three values' semantics explicit, matching the current runtime behavior.Reviewer Test Plan
How to verify
Cross-check the added description against the source of truth:
"ask"bounces the tool from execution back to awaiting-approval and builds a synthetic confirmation — seebounceToAwaitingApprovalForAskinpackages/core/src/core/coreToolScheduler.ts(ProceedOnce re-executes, Cancel cancels).canPromptForAskBouncein the same file: a non-interactive CLI (unlessSTREAM_JSON), background agents, and suppressed permission prompts returnfalse, so"ask"becomes deny there.Docs-only change — no runtime behavior is affected. No pages were added, moved, or renamed, so navigation (
_meta.ts) and theqc-helperdoc index are unchanged.Evidence (Before & After)
N/A — documentation-only change.
Tested on
Environment (optional)
N/A
Risk & Scope
PreToolUsepermissionDecisionsemantics are documented; thedecision/"ask"fields on other hook events were not expanded.Linked Issues
N/A
中文说明
本 PR 的作用
在
docs/users/features/hooks.md中补充说明PreToolUse钩子的permissionDecision各取值的行为。文档此前已列出"allow"、"deny"、"ask"三个允许值,但从未说明其行为——尤其是"ask":它现在会暂停工具调用并在 TUI 中弹出确认,在无法弹出确认的场景(headless--prompt运行与后台子代理)中回退为"deny"。为什么需要
PreToolUse钩子返回permissionDecision: "ask"的行为近期从“等同"deny"”变为“真正提示用户确认”。文档读者无法得知"ask"的作用,也不知道它在非交互场景会退化为"deny",因此安全敏感的钩子无法有意识地在"deny"与"ask"之间选择。新增的说明使三个取值的语义明确,并与当前运行时行为一致。复核测试计划
仅文档改动,不影响运行时行为。未新增、移动或重命名任何页面,因此导航(
_meta.ts)与qc-helper文档索引无需改动。对照packages/core/src/core/coreToolScheduler.ts中的bounceToAwaitingApprovalForAsk与canPromptForAskBounce即可核对。证据(前后对比)
N/A —— 纯文档改动。
风险与范围
PreToolUse的permissionDecision语义,未扩展其他钩子事件上的decision/"ask"字段。Generated by Claude Code