fix(guardrails): the foreground-wait guard refuses a Monitor tool call

未关闭
#18,858 10 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
64/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
bash, shell
领域
tooling

调研方向

Start by logging the JSON that arrives on stdin in plugins/guardrails/hooks/block-foreground-wait.sh and triggering a Monitor call, to see which tool_name and fields it carries. Compare that with the early exit at lines 65-66 and the Bash|PowerShell matcher in the plugin's hooks.json, which should mean the hook never fires for Monitor at all. Fix the tool-name handling and add a Monitor case to plugins/guardrails/hooks/block-foreground-wait.test.sh; done when that test passes and a real Monitor call is no longer refused.

由索引模型根据 Issue 内容生成。

描述

host-run

Steps to reproduce

  1. In an interactive Claude Code session with the guardrails plugin enabled, call the Monitor tool with a command holding an until loop, for example until [ -s <file> ]; do sleep 60; done; echo done.

Expected behavior

The call runs. Monitor is the tool the guard's own message recommends: "Run the command with run_in_background set to true, or watch it with the Monitor tool".

Actual behavior

The call is refused with PreToolUse:Monitor hook error: [command hook 10]: BLOCKED: This until loop waits in the foreground. Run the command with run_in_background set to true, or watch it with the Monitor tool, and read the result when it finishes. (observed 2026-11-23 in the Software Factory Part Two session).

Severity

Low.

Severity justification

The refusal sends a session to the tool it then refuses; a session can wait for subagent notifications instead, so nothing is lost, but a correct wait is turned away.

Suggested fix location

  • plugins/guardrails/hooks/block-foreground-wait.sh:65-66 exits unless the tool name is Bash, and hooks.json registers the hook only under Bash|PowerShell, so how the Monitor call reached it is not known: the hook payload was not visible. First step: capture the PreToolUse payload of a Monitor call and see which tool_name and fields it carries.
  • plugins/guardrails/hooks/block-foreground-wait.test.sh has no Monitor case; add one.

Environment

Claude Code with guardrails 4.2.0 (installed cache), WSL2 Ubuntu.

session: Software Factory Part Two (workshop 08 alignment pass, ledger Q2113).

主要语言
Shell
星标
22
派生
2
平均合并
2 小时
30 天内合并 PR
960

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

melodic-software/claude-code-plugins 的其他 Issue

查看 melodic-software/claude-code-plugins 的全部 Issue

相似的 Issue

更多 Shell/Bash Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。