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

Abierto
#21,023 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
bash, git, shell

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Shell
Estrellas
22
Forks
2
Merge medio
3 h 20 min
PR fusionados (30 d)
956

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de melodic-software/claude-code-plugins

Todos los issues de melodic-software/claude-code-plugins

Issues similares

Más issues de Shell/Bash

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.