Make warn-plugin-cache-walk's fast exit test the command, not the whole payload

オープン
#21,023 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
bash, git, shell

調査の方向性

Start with plugins/guardrails/hooks/warn-plugin-cache-walk.sh, especially lines 18, 23, and 26, and inspect the existing tests for this hook. Feed JSON on stdin with a realistic transcript_path under ~/.claude; verify a command without .claude/ or CLAUDE_CONFIG_DIR exits before jq and that verdicts stay unchanged. Measure per-call time before and after on Windows Git Bash and record it in the PR.

索引モデルが issue の本文から書いたものです。

説明

Problem

plugins/guardrails/hooks/warn-plugin-cache-walk.sh:18 is meant to exit early when a call cannot touch
~/.claude, before jq runs. It tests the whole PreToolUse payload for .claude/ or
claude_config_dir. Every payload carries transcript_path, which sits under ~/.claude/projects/,
so the test always matches and the early exit never fires. Every Bash call then pays for the jq
parse at :23; the real check on the command at :26 still decides correctly.

Evidence

  • Read on origin/main this pass: the test at :18 runs on ${INPUT,,}, the raw payload; :26
    repeats it on .tool_input.command.
  • Inferred, not measured: the per-call cost of the extra jq parse on Windows.

Proposed approach

Make the fast test ignore transcript_path and cwd (for example, match only text after
"command":), or drop :18 if it cannot be made cheaper than the jq parse. Measure before and
after on Windows Git Bash.

Acceptance criteria

  • A Bash call whose command does not mention .claude/ or CLAUDE_CONFIG_DIR exits before jq runs, with a transcript path under ~/.claude in the payload.
  • Verdicts unchanged: existing tests pass, plus a test with a realistic transcript_path.
  • Measured per-call time before and after, recorded in the PR.

Constraints and gotchas

  • Never loosen the guard; this is a speed change with verdict parity.
  • Test only by feeding JSON on stdin.

Context

Found while researching #21019 (closed). Part of the hook-speed work under #20549.

主要言語
Shell
スター
22
フォーク
2
平均マージ
3時間 20分
マージ済み PR(30日)
956

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

melodic-software/claude-code-plugins のほかの issue

melodic-software/claude-code-plugins の issue をすべて見る

似ている issue

Shell/Bash の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。